| 1 |
; RUN: llvm-as %s -o %t.bc |
| 2 |
; RUN: llvm-spirv %t.bc -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV |
| 3 |
; RUN: llvm-spirv %t.bc -o %t.spv |
| 4 |
; RUN: spirv-val %t.spv |
| 5 |
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc |
| 6 |
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM |
| 7 |
|
| 8 |
; Check saturation conversion is translated when there is forward declaration |
| 9 |
; of SPIRV entry. |
| 10 |
|
| 11 |
; CHECK-SPIRV: Decorate [[SAT:[0-9]+]] SaturatedConversion |
| 12 |
; CHECK-SPIRV: ConvertFToU {{[0-9]+}} [[SAT]] |
| 13 |
|
| 14 |
; CHECK-LLVM: convert_uchar_satf |
| 15 |
|
| 16 |
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1" |
| 17 |
target triple = "spir64" |
| 18 |
|
| 19 |
declare spir_func zeroext i8 @_Z30__spirv_ConvertFToU_Ruchar_satf(float) |
| 20 |
|
| 21 |
define spir_func void @forward(float %val, ptr addrspace(1) %dst) { |
| 22 |
entry: |
| 23 |
br label %for.cond |
| 24 |
|
| 25 |
for.cond: ; preds = %for.body, %entry |
| 26 |
%new_val.0 = phi i8 [ undef, %entry ], [ %call1, %for.body ] |
| 27 |
%i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ] |
| 28 |
%cmp = icmp ult i32 %i.0, 1 |
| 29 |
br i1 %cmp, label %for.body, label %for.end |
| 30 |
|
| 31 |
for.body: ; preds = %for.cond |
| 32 |
%call1 = call spir_func zeroext i8 @_Z30__spirv_ConvertFToU_Ruchar_satf(float noundef %val) |
| 33 |
%inc = add i32 %i.0, 1 |
| 34 |
br label %for.cond |
| 35 |
|
| 36 |
for.end: ; preds = %for.cond |
| 37 |
store i8 %new_val.0, ptr addrspace(1) %dst, align 1 |
| 38 |
ret void |
| 39 |
} |