| Issue |
241483
|
| Summary |
[SLPVectorizer] Assertion `must be scheduled at this point` with a repeated copyable scalar
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
arie2026
|
This is another instance of the `scheduleBlock` "must be scheduled at this point" assertion (cf. #223139 and earlier,
all closed); it still fails on current main. The scalar `%sub1` appears in the tree as a duplicated trunc operand
(lanes 0 and 2), as a copyable lane in two chained copyable nodes (`or`, then `and`), and as the main op of a
copyable node `[%sub1, 0, 0, 0]` under a split gather. In the final schedule only the `[%sub1]` bundle never becomes ready.
Reproducer (`opt -mtriple=x86_64-unknown-linux-gnu -mattr=+avx2 -passes=slp-vectorizer`; also reproduces on 5e457cda8d5a and f2808fc79):
```llvm
define i32 @f(ptr %out, i32 %x, i32 %q) {
entry:
%sub1 = add i32 %q, 1
%conv = trunc i32 %sub1 to i8
%priv = getelementptr i8, ptr %out, i64 16
store i8 %conv, ptr %priv, align 1
%and.1 = and i32 %x, 0
%sub2.1 = and i32 %x, 0
%or.1 = or i32 %and.1, %sub2.1
%conv.1 = trunc i32 %or.1 to i8
%p.1 = getelementptr i8, ptr %out, i64 17
store i8 %conv.1, ptr %p.1, align 1
%conv.2 = trunc i32 %sub1 to i8
%p.2 = getelementptr i8, ptr %out, i64 18
store i8 %conv.2, ptr %p.2, align 1
%and.3 = or i32 %x, 1
%sub2.3 = and i32 %x, 0
%or.3 = or i32 %and.3, %sub2.3
%conv.3 = trunc i32 %or.3 to i8
%p.3 = getelementptr i8, ptr %out, i64 19
store i8 %conv.3, ptr %p.3, align 1
%and.4 = and i32 %x, 0
%sub2.4 = and i32 %sub1, 0
%or.4 = or i32 %and.4, %sub2.4
%conv.4 = trunc i32 %or.4 to i8
%p.4 = getelementptr i8, ptr %out, i64 20
store i8 %conv.4, ptr %p.4, align 1
%and.5 = and i32 0, 0
%sub2.5 = and i32 0, 0
%or.5 = or i32 %and.5, %sub2.5
%conv.5 = trunc i32 %or.5 to i8
%p.5 = getelementptr i8, ptr %out, i64 21
store i8 %conv.5, ptr %p.5, align 1
%and.6 = and i32 0, 0
%sub2.6 = and i32 0, 0
%or.6 = or i32 %and.6, %sub2.6
%conv.6 = trunc i32 %or.6 to i8
%p.6 = getelementptr i8, ptr %out, i64 22
store i8 %conv.6, ptr %p.6, align 1
%and.7 = and i32 0, 0
%sub2.7 = and i32 0, 0
%or.7 = or i32 %and.7, %sub2.7
%conv.7 = trunc i32 %or.7 to i8
%p.7 = getelementptr i8, ptr %out, i64 23
store i8 %conv.7, ptr %p.7, align 1
ret i32 0
}
```
```
$ opt -mtriple=x86_64-unknown-linux-gnu -mattr=+avx2 -passes=slp-vectorizer -disable-output test.ll
opt: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:28977: void llvm::slpvectorizer::BoUpSLP::scheduleBlock(const BoUpSLP &, BlockScheduling *): Assertion `all_of(Bundles, [](const ScheduleBundle *Bundle) { return Bundle->isScheduled(); }) && "must be scheduled at this point"' failed.
#11 BoUpSLP::scheduleBlock(...)
#12 BoUpSLP::vectorizeTree(...)
#13 llvm::SLPVectorizerPass::vectorizeStoreChainImpl(...)
#14 llvm::SLPVectorizerPass::vectorizeStoreChain(...)
#15 llvm::SLPVectorizerPass::vectorizeStores(...)
#18 llvm::SLPVectorizerPass::vectorizeStoreChains(...)
#19 llvm::SLPVectorizerPass::runImpl(...)
#20 llvm::SLPVectorizerPass::run(...)
```
Expected: no crash. Either every bundle gets scheduled, or the tree is rejected during `buildTree`.
Notes: removing any one of these avoids the crash: the second `trunc %sub1`, the `%sub1` in lane 0, `and %sub1, 0`, or
`%and.3 = or` (as opposed to `and`). Plain x86-64 without `+avx2` doesn't crash. I suspect the copyable-dependency counting in
`addScheduleCopyableData` ("chain of same copyable elements"), but this is not bisected.
Found with a mutation-based IR fuzzer. Triage, test-case minimization and parts of this write-up were
assisted by an LLM; verified the reproducer on 9dce18f0e.
Assisted-by: Claude (Anthropic)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs