================
@@ -0,0 +1,110 @@
+// RUN: %clang_cc1 -finclude-default-header -triple 
dxil-pc-shadermodel6.3-library %s \
+// RUN:  -fnative-half-type -emit-llvm -disable-llvm-passes -o - | \
+// RUN:  FileCheck %s
+// RUN: %clang_cc1 -finclude-default-header -triple 
spirv-unknown-vulkan-compute %s \
+// RUN:  -fnative-half-type -emit-llvm -disable-llvm-passes -o - | \
+// RUN:  FileCheck %s
+
+ half2 half_vec_mod_by_int(half2 p1) {
+// CHECK-LABEL: half_vec_mod_by_int
+// CHECK: %rem = frem reassoc nnan ninf nsz arcp afn <2 x half> %{{.*}}, splat 
(half 0xH4000)
+    return  p1 % 2;
+}
+
+ half2 half_vec_mod_by_float(half2 p1) {
+// CHECK-LABEL: half_vec_mod_by_float
+// CHECK: %rem = frem reassoc nnan ninf nsz arcp afn <2 x half> %{{.*}}, splat 
(half 0xH4000)
+    return  p1 % (half)2.0;
+}
+
+ half2 half_vec_mod_by_half(half2 p1, half p2 ) {
+// CHECK-LABEL: half_vec_mod_by_half
+// CHECK:  %splat.splatinsert = insertelement <2 x half> poison, half %{{.*}}, 
i64 0
+// CHECK:  %splat.splat = shufflevector <2 x half> %splat.splatinsert, <2 x 
half> poison, <2 x i32> zeroinitializer
+// CHECK:  %rem = frem reassoc nnan ninf nsz arcp afn <2 x half> %{{.*}}, 
%splat.splat
+    return  p1 % p2;
+}
+
+ half2 half_vec_mod_by_half_vec(half2 p1, half2 p2 ) {
+// CHECK-LABEL: half_vec_mod_by_half_vec
+// CHECK: %rem = frem reassoc nnan ninf nsz arcp afn <2 x half> %{{.*}}, 
%{{.*}}
+    return  p1 % p2;
+}
+
+ half half_vec_mod_by_int(half p1) {
+// CHECK-LABEL: half_vec_mod_by_int
+// CHECK: %rem = frem reassoc nnan ninf nsz arcp afn half  %{{.*}}, 0xH4000
+    return  p1 % 2;
----------------
farzonl wrote:

Thats a Good question. so no it isn't ambigious because in 
SemaExpr::CheckRemainderOperands if we get into either the 
`CheckVectorOperands` for the vector cases or `UsualArithmeticConversions` for 
the scalar cases.  the integer literal go  through a conversion to match the 
non literal type. I saw ints become halfs or floats depending on what the 
variable type was. 

The float literal however did not do this. The float literal would cast the  
half variables to a float so to prevent this in the testing i cast the float 
literals to half. If thats a bug I'll try an address it in a future pr.

https://github.com/llvm/llvm-project/pull/135125
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to