-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Backport to 15][LLVM->SPIRV] Fix target id in decorates when there i…
…s forward decl (#2606) (#2614) When there is forward declaration of a spirv entry, its decorates are not translated until its definition is seen. Forward id is re-used for its entry. Id in entry decorates should use forward id as well. (cherry picked from commit 305f488)
- Loading branch information
Showing
4 changed files
with
56 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
; RUN: llvm-as %s -o %t.bc | ||
; RUN: llvm-spirv %t.bc -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV | ||
; RUN: llvm-spirv %t.bc -o %t.spv | ||
; RUN: spirv-val %t.spv | ||
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc | ||
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM | ||
|
||
; Check saturation conversion is translated when there is forward declaration | ||
; of SPIRV entry. | ||
|
||
; CHECK-SPIRV: Decorate [[SAT:[0-9]+]] SaturatedConversion | ||
; CHECK-SPIRV: ConvertFToU {{[0-9]+}} [[SAT]] | ||
|
||
; CHECK-LLVM: convert_uchar_satf | ||
|
||
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1" | ||
target triple = "spir64" | ||
|
||
declare spir_func zeroext i8 @_Z30__spirv_ConvertFToU_Ruchar_satf(float) | ||
|
||
define spir_func void @forward(float %val, ptr addrspace(1) %dst) { | ||
entry: | ||
br label %for.cond | ||
|
||
for.cond: ; preds = %for.body, %entry | ||
%new_val.0 = phi i8 [ undef, %entry ], [ %call1, %for.body ] | ||
%i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ] | ||
%cmp = icmp ult i32 %i.0, 1 | ||
br i1 %cmp, label %for.body, label %for.end | ||
|
||
for.body: ; preds = %for.cond | ||
%call1 = call spir_func zeroext i8 @_Z30__spirv_ConvertFToU_Ruchar_satf(float noundef %val) | ||
%inc = add i32 %i.0, 1 | ||
br label %for.cond | ||
|
||
for.end: ; preds = %for.cond | ||
store i8 %new_val.0, ptr addrspace(1) %dst, align 1 | ||
ret void | ||
} |