| Issue |
244568
|
| Summary |
[X86] lowerShuffleAsZeroOrAnyExtend creates a v4i32 VZEXT_MOVL of a v4f32 load (invalid node)
|
| Labels |
backend:X86,
crash
|
| Assignees |
|
| Reporter |
chfast
|
```llvm
define <8 x float> @f(ptr %p) {
%v = load <8 x float>, ptr %p
%r = shufflevector <8 x float> %v, <8 x float> <float poison, float poison, float poison, float poison, float poison, float poison, float poison, float 0.0>, <8 x i32> <i32 poison, i32 poison, i32 poison, i32 poison, i32 4, i32 poison, i32 15, i32 poison>
ret <8 x float> %r
}
```
Compiler Explorer: https://godbolt.org/z/6W5cb9bMj. It has llc trunk, which compiles it, and llc assertions trunk, which aborts by default and compiles with `-mattr=+sse4.1`.
`llc -mtriple=x86_64-linux-gnu`, with assertions:
```
LLVM ERROR: invalid node: result #0 must have the same type as operand #0 (v4f32), but has type v4i32
...
#14 llvm::X86SelectionDAGInfo::verifyTargetNode
#15 llvm::SelectionDAG::getNode
#16 lowerShuffleAsZeroOrAnyExtend
#17 lower128BitShuffle
#18 lowerVECTOR_SHUFFLE
```
`-mtriple=i686-linux-gnu -mattr=+sse2` also aborts. With `-mattr=+sse4.1` or higher it compiles.
After type legalization the upper half is
```
t21: v4f32 = BUILD_VECTOR poison:f32, poison:f32, poison:f32, ConstantFP:f32<0.000000e+00>
t25: v4f32,ch = load<(load (s128) from %ir.p + 16, basealign 32)> t0, t24, poison:i64
t27: v4f32 = vector_shuffle<4,u,3,u> t21, t25
```
`lowerV4F32Shuffle` calls `lowerShuffleAsZeroOrAnyExtend` with `MVT::v4i32`, but passes the v4f32 inputs as they are:
```cpp
if (Subtarget.hasSSE2())
if (SDValue ZExt = lowerShuffleAsZeroOrAnyExtend(
DL, MVT::v4i32, V1, V2, Mask, Zeroable, Subtarget, DAG)) {
```
The VZEXT_MOVL match added in f63a08bcbf76 (#208309) uses `V1` without a bitcast, so it creates a v4i32 VZEXT_MOVL of the v4f32 load:
```cpp
if (VT == MVT::v4i32 &&
(V1.getOpcode() == ISD::SCALAR_TO_VECTOR || isa<MemSDNode>(V1)) &&
Mask[0] == 0 && (NumElements - 1) == (int)Zeroable.countLeadingOnes())
return DAG.getNode(X86ISD::VZEXT_MOVL, DL, VT, V1);
```
`lowerShuffleAsSpecificExtension` bitcasts its input to `VT`. Doing the same here, `DAG.getBitcast(VT, V1)`, fixes the example (`movss 16(%rdi), %xmm1`); I did not run the regression tests with that change. Builds without assertions do not check the node and already emit that `movss` (llc trunk on Compiler Explorer), so only builds with assertions abort.
Found by fuzzing while reviewing #243097. It reproduces on main at 6a68b4da94d8 and with the PR applied.
Assisted-by: Claude Code (Claude Opus 5.5)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs