[clang] [HLSL] Add support for modulo of floating point scalar and vectors (PR #135125)
Sarah Spall via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 10 07:56:28 PDT 2025
================
@@ -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;
----------------
spall wrote:
this wasn't abiguous?
https://github.com/llvm/llvm-project/pull/135125
More information about the cfe-commits
mailing list