[clang] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use temp var (PR #105930)

Justin Bogner via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 26 22:43:16 PDT 2024


================
@@ -16,262 +16,220 @@
 #ifdef __HLSL_ENABLE_16_BIT
 // DXIL_NATIVE_HALF: define noundef i1 @
 // SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.i16
+// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.[[ICF:dx]].all.i16
+// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.[[ICF:spv]].all.i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t(int16_t p0) { return all(p0); }
----------------
bogner wrote:

We can simplify this test significantly more by passing in the expected prefixes on the FileCheck command line via `-D`. Consider, if we invoked FileCheck in the following four ways:
```sh
FileCheck %s --check-prefixes=CHECK,CHECK-HALF -DFNATTRS="spir_func noundef" -DTARGET=spv
FileCheck %s --check-prefixes=CHECK,CHECK-NOHALF -DFNATTRS="spir_func noundef" -DTARGET=spv
FileCheck %s --check-prefixes=CHECK,CHECK-HALF -DFNATTRS=noundef -DTARGET=dx
FileCheck %s --check-prefixes=CHECK,CHECK-NOHALF -DFNATTRS=noundef -DTARGET=dx
```

Then the integer checks inside the `__HLSL_ENABLE_16_BIT` ifdef would simpy be
```c++
// CHECK-HALF: define [[FNATTRS]] i1 @
// CHECK-HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.i16
// CHECK-HALF: ret i1 %hlsl.all
```

where the type of the `all.XYZ` is the only thing that needs to change, and the later f16 checks would similarly be
```c++
// CHECK: define [[FNATTRS]] i1 @
// CHECK-HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.f16
// CHECK-NOHALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.f32
// CHECK: ret i1 %hlsl.all
```
with the same caveat.

Finally, the checks that don't depend on 16 bit types would simply be
```c++
// CHECK: define [[FNATTRS]] i1 @
// CHECK: %hlsl.all = call i1 @llvm.[[TARGET]].all.XYZ
// CHECK: ret i1 %hlsl.all
```

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


More information about the cfe-commits mailing list