| Issue |
162688
|
| Summary |
[LoopVectorize] Assertion `(BestFactor.Width == LegacyVF.Width || BestPlan.hasEarlyExit() || ... && " VPlan cost model and legacy cost model disagreed"' failed.
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
ewlu
|
Full assertion:
```
Assertion `(BestFactor.Width == LegacyVF.Width || BestPlan.hasEarlyExit() || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop, BestFactor.Width) || planContainsAdditionalSimplifications( getPlanFor(LegacyVF.Width), CostCtx, OrigLoop, LegacyVF.Width)) && " VPlan cost model and legacy cost model disagreed"' failed.
```
Testcase:
```llvm ir
target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128"
target triple = "riscv64-unknown-linux-gnu"
define void @init(i32 %conv2.i) #0 {
entry:
%sext.i = and i32 %conv2.i, 32767
br label %for.cond.i.us
for.cond.i.us: ; preds = %for.body.i.us, %entry
br label %for.body.i.us
for.body.i.us: ; preds = %for.body.i.us, %for.cond.i.us
%v.051.i.us = phi i16 [ %add.i.us, %for.body.i.us ], [ 0, %for.cond.i.us ]
%idxprom5.i.us = sext i16 %v.051.i.us to i64
%arrayidx6.i.us = getelementptr i32, ptr null, i64 %idxprom5.i.us
%0 = load i32, ptr %arrayidx6.i.us, align 4
%conv7.i.us = trunc i32 %0 to i16
%arrayidx11.i.us = getelementptr [1 x [1 x i16]], ptr null, i64 %idxprom5.i.us
store i16 %conv7.i.us, ptr %arrayidx11.i.us, align 2
%conv18.i.us = trunc i32 %0 to i8
%arrayidx22.i.us = getelementptr i8, ptr null, i64 %idxprom5.i.us
store i8 %conv18.i.us, ptr %arrayidx22.i.us, align 1
%arrayidx28.i.us = getelementptr [1 x i64], ptr null, i64 %idxprom5.i.us
store i64 0, ptr %arrayidx28.i.us, align 8
%add.i.us = add i16 %v.051.i.us, 4
%conv.i.us = sext i16 %add.i.us to i32
%cmp.i.us = icmp sgt i32 %sext.i, %conv.i.us
br i1 %cmp.i.us, label %for.body.i.us, label %for.cond.i.us
}
attributes #0 = { "target-features"="+v" }
```
Original C program before reduction:
```c
# 1 "<built-in>"
# 1 "red.c"
extern short a[][1][1][1];
extern char b[][1];
extern long c[][1][1][1];
void d(long long s[], int t[]) {
for (short u = 0;;)
for (short v = 0; v < (short)s[u]; v += 4) {
a[u][v][u][u] = t[v];
b[u][v] = t[v];
c[u][u][v][u] = 0;
}
}
long long s[1];
int t[1];
void init() { d(s, t); }
```
Commands/backtrace:
```
$ /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt --passes="loop-vectorize" reduced.ll
WARNING: You're attempting to print out a bitcode file.
This is inadvisable as it may cause display problems. If
you REALLY want to taste LLVM bitcode first-hand, you
can force output with the `-f' option.
opt: /scratch/ewlu/daily-upstream-build/llvm/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7096: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || BestPlan.hasEarlyExit() || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop, BestFactor.Width) || planContainsAdditionalSimplifications( getPlanFor(LegacyVF.Width), CostCtx, OrigLoop, LegacyVF.Width)) && " VPlan cost model and legacy cost model disagreed"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt --passes=loop-vectorize reduced.ll
1. Running pass "function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)" on module "reduced.ll"
2. Running pass "loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>" on function "init"
#0 0x0000627db0e2afe0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x35f2fe0)
#1 0x0000627db0e27cfa SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#2 0x00007d8278845330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#3 0x00007d827889eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#4 0x00007d827889eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#5 0x00007d827889eb2c pthread_kill ./nptl/pthread_kill.c:89:10
#6 0x00007d827884527e raise ./signal/../sysdeps/posix/raise.c:27:6
#7 0x00007d82788288ff abort ./stdlib/abort.c:81:7
#8 0x00007d827882881b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#9 0x00007d827883b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#10 0x0000627dae8dd8a6 llvm::LoopVectorizationPlanner::computeBestVF() (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x10a58a6)
#11 0x0000627dae8df80c llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x10a780c)
#12 0x0000627dae8e2c01 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x10aac01)
#13 0x0000627dae8e30aa llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x10ab0aa)
#14 0x0000627dae101583 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x8c9583)
#15 0x0000627db0bf8b23 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x33c0b23)
#16 0x0000627dae103db3 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x8cbdb3)
#17 0x0000627db0bf75e7 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x33bf5e7)
#18 0x0000627dadd7d5d3 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x5455d3)
#19 0x0000627db0bf6ee3 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x33beee3)
#20 0x0000627dadd887f6 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x5507f6)
#21 0x0000627dadd7b77a optMain (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x54377a)
#22 0x00007d827882a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#23 0x00007d827882a28b call_init ./csu/../csu/libc-start.c:128:20
#24 0x00007d827882a28b __libc_start_main ./csu/../csu/libc-start.c:347:5
#25 0x0000627dadd71b15 _start (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x539b15)
Aborted
```
Godbolt: https://godbolt.org/z/zP71E49TP
Found via fuzzer
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs