[HLSL][LongVec] Add support for the ddx_coarse intrinsic
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
A little suprised this does not work after https://github.com/llvm/llvm-project/pull/216905
```llvm
// CHECK-LABEL: <5 x float> @{{.*}}test_f32_ddx_coarse5
// CHECK: %hlsl.ddx.coarse = call {{.*}} <5 x float> @llvm.[[TGT]].ddx.coarse.v5f32(<5 x float> %{{.*}})
// CHECK: ret <5 x float> %hlsl.ddx.coarse
vector test_f32_ddx_coarse5(vector val) {
return ddx_coarse(val);
}
```
We do seem to be scalarizing it
```tablegen
def int_dx_ddx_coarse : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>], [IntrNoMem, IntrTriviallyScalarizable]>;
```
Looking at this pr scalarizer pass is working https://github.com/llvm/llvm-project/pull/216893/changes#diff-25d675fbf92f2e339a17aca021727e6e5ee609ab08c4f0c3e8cf3e29f68024ecR5
```llvm
; CHECK-LABEL: define <17 x float> @test_ddx_coarse(
; CHECK-SCALAR-COUNT-17: call float @dx.op.unary.f32(i32 83, float {{.*}})
; CHECK-VECTOR: call <17 x float> @llvm.dx.ddx.coarse.v17f32
define <17 x float> @test_ddx_coarse(<17 x float> %a) {
%result = call <17 x float> @llvm.dx.ddx.coarse.v17f32(<17 x float> %a)
ret <17 x float> %result
}
```
Even though the test is passing for DXC we will need to investigate and make sure the test is correct.
> XFAIL: OffloadTest-clang-warp-d3d12 :: Feature/HLSLLib/ddx-coarse.long-vector.32.test (147 of 710)
Contributor guide
Research direction
Start with the ddx-coarse.long-vector.32.test and the int_dx_ddx_coarse intrinsic definition. Review the scalarizer pass behavior referenced in the issue, then run the long-vector test to verify whether vector values lower to the expected llvm.dx.ddx.coarse intrinsic rather than being incorrectly scalarized. Done means the test is correct and the XFAIL is no longer needed if support is complete.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 62/100