| Issue |
244777
|
| Summary |
Assertion failed on -o1 and above "Invalid child # of SDNode!" in combineOr for `or` with an all-ones/zero constant vector (`<8 x i64>`)
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
haoxintu
|
## Description
```c
typedef unsigned long long v8 __attribute__((ext_vector_type(8)));
v8
k (v8 a)
{
v8 x = a.s00000000; /* splat of lane 0 */
v8 s = __builtin_shufflevector ((v8) 1, a, 6, 2, 8, 0, 3, 7, 4, 14);
return (x & s) | (v8) { -1, 0, 0, 0, 0, -1, 0, -1 };
}
```
```
$ clang -O1 -c repro.c # also -O2, -O3, -Os; -O0 is fine
clang: llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1070: const llvm::SDValue& llvm::SDNode::getOperand(unsigned int) const:
Assertion `Num < NumOperands && "Invalid child # of SDNode!"' failed.
...
#12 combineOr(llvm::SDNode*, llvm::SelectionDAG&, llvm::TargetLowering::DAGCombinerInfo&, llvm::X86Subtarget const&) X86ISelLowering.cpp
#14 llvm::SelectionDAG::Combine(...)
```
`llc -O2` on this IR (llvm-reduce) asserts the same way:
```llvm
define <8 x i64> @k1(<8 x i64> %vecins) {
entry:
%xor = shufflevector <8 x i64> %vecins, <8 x i64> zeroinitializer, <8 x i32> zeroinitializer
%shuffle = shufflevector <8 x i64> splat (i64 1), <8 x i64> %vecins, <8 x i32> <i32 6, i32 2, i32 8, i32 0, i32 3, i32 7, i32 4, i32 14>
%and = and <8 x i64> %xor, %shuffle
%or = or <8 x i64> %and, <i64 -1, i64 0, i64 0, i64 0, i64 0, i64 -1, i64 0, i64 -1>
ret <8 x i64> %or
}
```
The constant operand of the `or` has all-ones lanes. That is the case handled by #215538 ("[X86] combineOr - undemand and freeze elements if the other operand's element is allones"), which may be where this started.
Reproduced in Godbolt (x86-64 clang assertions trunk, -O2): https://godbolt.org/z/qsTMPz1Mo
## Checked Versions
- Assertion at -O1/-O2/-O3/-Os with clang trunk 2012344e5da8 (2026-11-19). -O0 is fine.
- clang 21.1.8 and llc 21.1.8 compile it, so this is a regression.
Thanks.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs