Issue |
152220
|
Summary |
[DirectX] Vector `mad` operations not being scalarized for integer types
|
Labels |
new issue
|
Assignees |
|
Reporter |
kmpeng
|
Discovered while running the offload-test-suite.
https://godbolt.org/z/TMEKbMaYP
``` hlsl
// RUN: %clang-dxc -T cs_6_5 -enable-16bit-types %s
StructuredBuffer<int16_t4> M0 : register(t0);
StructuredBuffer<int16_t4> A0 : register(t1);
StructuredBuffer<int16_t4> B0 : register(t2);
RWStructuredBuffer<int16_t4> Out0 : register(u3);
[numthreads(1,1,1)]
void main() {
Out0[0] = mad(M0[0], A0[0], B0[0]);
}
```
```
# .---command stderr------------
# | error: Cannot create IMad operation: Invalid overload type
# | These should never be used!!!
# | UNREACHABLE executed at E:/llvm-project/llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp:1025!
```
The llvm ir shows that the mad instruction `%dx.imad.i = tail call <4 x i16> @llvm.dx.imad.v4i16(<4 x i16> %17, <4 x i16> %27, <4 x i16> %37)` is not being scalarized when it should be. This is happening with all bit sizes of `int` and `uint`.
Fix is to add `dx_imad` and `dx_umad` here:
https://github.com/llvm/llvm-project/blob/64eba6ef9610a4a82e1610ecd806b8488144bad0/llvm/lib/Target/DirectX/DirectXTargetTransformInfo.cpp#L58-L59
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs