[clang] [llvm] [HLSL] Implement `WaveReadLaneAt` intrinsic (PR #111010)
Farzon Lotfi via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 4 14:22:05 PDT 2024
================
@@ -0,0 +1,56 @@
+; RUN: opt -S -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-compute %s | FileCheck %s
+
+; Test that for scalar values, WaveReadLaneAt maps down to the DirectX op
+
+define noundef half @wave_rla_half(half noundef %expr, i32 noundef %idx) #0 {
+entry:
+; CHECK: call half @dx.op.waveReadLaneAt.f16(i32 117, half %expr, i32 %idx)
+ %ret = call half @llvm.dx.wave.read.lane.at.f16(half %expr, i32 %idx)
+ ret half %ret
+}
+
+define noundef float @wave_rla_float(float noundef %expr, i32 noundef %idx) #0 {
+entry:
+; CHECK: call float @dx.op.waveReadLaneAt.f32(i32 117, float %expr, i32 %idx)
+ %ret = call float @llvm.dx.wave.read.lane.at(float %expr, i32 %idx)
+ ret float %ret
+}
+
+define noundef double @wave_rla_double(double noundef %expr, i32 noundef %idx) #0 {
+entry:
+; CHECK: call double @dx.op.waveReadLaneAt.f64(i32 117, double %expr, i32 %idx)
+ %ret = call double @llvm.dx.wave.read.lane.at(double %expr, i32 %idx)
+ ret double %ret
+}
+
+define noundef i1 @wave_rla_i1(i1 noundef %expr, i32 noundef %idx) #0 {
+entry:
+; CHECK: call i1 @dx.op.waveReadLaneAt.i1(i32 117, i1 %expr, i32 %idx)
+ %ret = call i1 @llvm.dx.wave.read.lane.at.i1(i1 %expr, i32 %idx)
+ ret i1 %ret
+}
+
+define noundef i16 @wave_rla_i16(i16 noundef %expr, i32 noundef %idx) #0 {
+entry:
+; CHECK: call i16 @dx.op.waveReadLaneAt.i16(i32 117, i16 %expr, i32 %idx)
+ %ret = call i16 @llvm.dx.wave.read.lane.at.i16(i16 %expr, i32 %idx)
----------------
farzonl wrote:
Now that i'm seeing how the intrinsic looks I think I would prefer it to be one word like it is on the dxop. Dots are used to indicate namespaces and type information and doing it like this is making the intrinsic look confusing.
```suggestion
%ret = call i16 @llvm.dx.waveReadLaneAt.i16(i16 %expr, i32 %idx)
```
https://github.com/llvm/llvm-project/pull/111010
More information about the cfe-commits
mailing list