Skip to content

Commit 2168dd6

Browse files
karolherbstsys-ce-bb
authored andcommitted
Rounding modes on int to int conversions are valid OpenCL C builtin functions (#3120)
The OpenCL CTS also tests for this, so those can't be ignored. Fixes: 04144823 ("Rewrite OpenCL explicit conversion builtins handling (#2464)") Original commit: KhronosGroup/SPIRV-LLVM-Translator@024ae2bcdf18fe4
1 parent 38c794f commit 2168dd6

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

llvm-spirv/lib/SPIRV/OCLToSPIRV.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -800,9 +800,6 @@ void OCLToSPIRVBase::visitCallConvert(CallInst *CI, StringRef MangledName,
800800
OC = OpFConvert;
801801
}
802802

803-
if (!Rounding.empty() && (isa<IntegerType>(SrcTy) && IsTargetInt))
804-
return;
805-
806803
assert(CI->getCalledFunction() && "Unexpected indirect call");
807804
mutateCallInst(
808805
CI, getSPIRVFuncName(OC, "_R" + DestTy + VecSize + Sat + Rounding));

llvm-spirv/test/transcoding/OpenCL/convert_functions.ll

+6
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
; CHECK-SPIRV: Name [[#Func1:]] "_Z20convert_uint_satfunc"
1515
; CHECK-SPIRV: Name [[#Func2:]] "_Z21convert_float_rtzfunc"
1616
; CHECK-SPIRV-DAG: TypeVoid [[#VoidTy:]]
17+
; CHECK-SPIRV-DAG: TypeInt [[#CharTy:]] 8
1718
; CHECK-SPIRV-DAG: TypeFloat [[#FloatTy:]] 32
1819

1920
; CHECK-SPIRV: Function [[#VoidTy]] [[#Func]]
21+
; CHECK-SPIRV: SConvert [[#CharTy]] [[#ConvertId:]] [[#]]
2022
; CHECK-SPIRV: ConvertSToF [[#FloatTy]] [[#ConvertId:]] [[#]]
2123
; CHECK-SPIRV: FunctionCall [[#VoidTy]] [[#]] [[#Func]] [[#ConvertId]]
2224
; CHECK-SPIRV: FunctionCall [[#VoidTy]] [[#]] [[#Func1]] [[#]]
@@ -55,13 +57,17 @@ entry:
5557
; CHECK-LLVM: call spir_func void @_Z18convert_float_func(float %[[Call]])
5658
; CHECK-LLVM: call spir_func void @_Z20convert_uint_satfunc(i32 %[[#]])
5759
; CHECK-LLVM: call spir_func void @_Z21convert_float_rtzfunc(float %[[Call]])
60+
call spir_func signext i8 @_Z16convert_char_rtei(i32 noundef %0) #1
5861
%call = call spir_func float @_Z13convert_floati(i32 noundef %0) #1
5962
call spir_func void @_Z18convert_float_func(float noundef %call) #0
6063
call spir_func void @_Z20convert_uint_satfunc(i32 noundef %0) #0
6164
call spir_func void @_Z21convert_float_rtzfunc(float noundef %call) #0
6265
ret void
6366
}
6467

68+
; Function Attrs: convergent nounwind willreturn memory(none)
69+
declare spir_func signext i8 @_Z16convert_char_rtei(i32 noundef) #1
70+
6571
; Function Attrs: convergent nounwind willreturn memory(none)
6672
declare spir_func float @_Z13convert_floati(i32 noundef) #1
6773

0 commit comments

Comments
 (0)