[clang] [HLSL] Implement support for HLSL intrinsic - select (PR #107129)

Sarah Spall via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 5 12:40:04 PDT 2024


================
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
+// RUN:   -o - | FileCheck %s --check-prefixes=CHECK
+
+// CHECK: %hlsl.select = select i1
+// CHECK: ret i32 %hlsl.select
+int test_select_bool_int(bool cond0, int tVal, int fVal) {
+  return select<int>(cond0, tVal, fVal); }
+
+struct S { int a; };
+// CHECK: %hlsl.select = select i1
+// CHECK: store ptr %hlsl.select
+// CHECK: ret void
+struct S test_select_infer(bool cond0, struct S tVal, struct S fVal) {
+  return select(cond0, tVal, fVal); }
+
+// CHECK: %hlsl.select = select i1
+// CHECK: ret <2 x i32> %hlsl.select
+vector<int,2> test_select_bool_vector(bool cond0, vector<int, 2> tVal,
+                                      vector<int, 2> fVal) {
+  return select<vector<int,2> >(cond0, tVal, fVal); }
----------------
spall wrote:

No, would it be better to use that form in all the tests? I can change that.

https://github.com/llvm/llvm-project/pull/107129


More information about the cfe-commits mailing list