Skip to content

Assertion `(BestFactor.Width == LegacyVF.Width || BestPlan.hasEarlyExit() || ... || planContainsAdditionalSimplifications(getPlanFor(LegacyVF.Width), CostCtx, OrigLoop)) && " VPlan cost model and legacy cost model disagreed"' failed. #139065

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TatyanaDoubts opened this issue May 8, 2025 · 1 comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] vectorizers

Comments

@TatyanaDoubts
Copy link

Full Assertion message:

Assertion `(BestFactor.Width == LegacyVF.Width || BestPlan.hasEarlyExit() || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop) || planContainsAdditionalSimplifications(getPlanFor(LegacyVF.Width), CostCtx, OrigLoop)) && " VPlan cost model and legacy cost model disagreed"' failed.

To reproduce run opt -passes=loop-vectorize with the test below:

; ModuleID = './reduced.ll'
source_filename = "./reduced.ll"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32-ni:1-p2:32:8:8:32-ni:2"
target triple = "aarch64-none-linux-gnu"

define i32 @wombat() gc "statepoint-example" {
bb:
  br label %bb2

bb1:                                              ; preds = %bb2
  %phi = phi i8 [ %or, %bb2 ]
  ret i32 0

bb2:                                              ; preds = %bb2, %bb
  %phi3 = phi i8 [ 0, %bb ], [ %or, %bb2 ]
  %phi4 = phi i32 [ 2, %bb ], [ %add, %bb2 ]
  %phi5 = phi i32 [ 0, %bb ], [ %srem, %bb2 ]
  %phi6 = phi i32 [ 0, %bb ], [ %phi4, %bb2 ]
  %mul = mul i32 %phi5, 0
  %trunc = trunc i32 %mul to i8
  %or = or i8 %trunc, %phi3
  %srem = srem i32 0, %phi6
  %add = add i32 %phi4, 1
  %icmp = icmp ugt i32 %phi4, 3
  br i1 %icmp, label %bb1, label %bb2
}

Reproducer: https://godbolt.org/z/7qEMh5Mq9

Stack dump:

0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=loop-vectorize <source>
1.	Running pass "function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)" on module "<source>"
2.	Running pass "loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>" on function "wombat"
 #0 0x0000000005589f78 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5589f78)
 #1 0x0000000005587904 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x00007198a6842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x00007198a68969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x00007198a6842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x00007198a68287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x00007198a682871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #7 0x00007198a6839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #8 0x00000000044b82a6 llvm::LoopVectorizationPlanner::computeBestVF() (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x44b82a6)
 #9 0x00000000044ce21a llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x44ce21a)
#10 0x00000000044d0df0 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x44d0df0)
#11 0x00000000044d1443 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x44d1443)
#12 0x000000000324211e llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x324211e)
#13 0x0000000005383340 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5383340)
#14 0x0000000000e8682e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe8682e)
#15 0x0000000005381c13 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5381c13)
#16 0x0000000000e8567e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe8567e)
#17 0x0000000005381620 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5381620)
#18 0x0000000000949a9a 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) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x949a9a)
#19 0x000000000093d26c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x93d26c)
#20 0x00007198a6829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#21 0x00007198a6829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#22 0x0000000000934ea5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x934ea5)
Program terminated with signal: SIGSEGV
Compiler returned: 139
@frederick-vs-ja
Copy link
Contributor

This looks very like a duplicate of #139060.

@frederick-vs-ja frederick-vs-ja added vectorizers crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels May 8, 2025
@fhahn fhahn closed this as completed in 8c6c525 May 9, 2025
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this issue May 9, 2025
Fixed-order recurrence phis cannot be scalarized, they will always be
widened at the moment. Make sure they are not incorrectly considered
profitable to scalarize, similar to 41c1a7b.

Fixes llvm/llvm-project#139060.
Fixes llvm/llvm-project#139065.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] vectorizers
Projects
None yet
Development

No branches or pull requests

3 participants