bug_id
string
issue_url
string
bug_type
string
base_commit
string
knowledge_cutoff
timestamp[s]
lit_test_dir
list
hints
dict
patch
string
tests
list
issue
dict
verified
bool
test_commit
string
117537
https://github.com/llvm/llvm-project/issues/117537
crash
c979ec05642f292737d250c6682d85ed49bc7b6e
2024-11-25T10:47:02
[ "llvm/test/Transforms/SimpleLoopUnswitch" ]
{ "fix_commit": "fc5c89900f2a4b50e0f3a88ef7c89115d93684f4", "components": [ "SimpleLoopUnswitch" ], "bug_location_lineno": { "llvm/include/llvm/Analysis/MemorySSAUpdater.h": null, "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/include/llvm/IR/Instruction.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null, "llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/include/llvm/IR/CmpPredicate.h": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": [ [ 1248, 1255 ] ], "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanValue.h": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/include/llvm/Analysis/ScalarEvolution.h": null, "llvm/lib/Analysis/VectorUtils.cpp": null }, "bug_location_funcname": { "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": [ "buildClonedLoopBlocks" ], "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/lib/Analysis/VectorUtils.cpp": null } }
commit fc5c89900f2a4b50e0f3a88ef7c89115d93684f4 Author: Nikita Popov <[email protected]> Date: Wed Nov 27 11:47:22 2024 +0100 [SimpleLoopUnswitch] Fix LCSSA phi node invalidation Fixes https://github.com/llvm/llvm-project/issues/117537. diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp index aa3cbc5e4bdd..d8ef450eeb9a 100644 --- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp +++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp @@ -1248,8 +1248,9 @@ static BasicBlock *buildClonedLoopBlocks( assert(VMap.lookup(&I) == &ClonedI && "Mismatch in the value map!"); // Forget SCEVs based on exit phis in case SCEV looked through the phi. - if (SE && isa<PHINode>(I)) - SE->forgetValue(&I); + if (SE) + if (auto *PN = dyn_cast<PHINode>(&I)) + SE->forgetLcssaPhiWithNewPredecessor(&L, PN); BasicBlock::iterator InsertPt = MergeBB->getFirstInsertionPt();
[ { "file": "llvm/test/Transforms/SimpleLoopUnswitch/pr117537.ll", "commands": [ "opt -S -passes='print<scalar-evolution>,simple-loop-unswitch<nontrivial>,print<scalar-evolution>' -verify-scev < %s 2>&1" ], "tests": [ { "test_name": "test", "test_body": "define void @test(ptr %p) {\nentry:\n %check = icmp eq ptr %p, null\n br label %bb0\n\nbb0: ; preds = %loop0, %entry\n br i1 %check, label %loop0, label %latch\n\nlatch: ; preds = %bb0\n br i1 %check, label %exit0, label %loop0\n\nexit0: ; preds = %latch\n ret void\n\nloop0: ; preds = %latch, %bb0\n %v = load atomic i32, ptr %p unordered, align 8\n %add = add i32 %v, 3\n br i1 true, label %preheader, label %bb0\n\npreheader: ; preds = %loop0\n br label %loop1\n\nloop1: ; preds = %backedge, %preheader\n %iv1 = phi i32 [ %add, %preheader ], [ %iv1.next, %backedge ]\n %iv1.next = add i32 %iv1, -33\n br label %loop2\n\nbackedge: ; preds = %loop2\n br i1 true, label %exit1, label %loop1\n\nloop2: ; preds = %loop2, %loop1\n %iv0 = phi i32 [ %iv1, %loop1 ], [ %iv0.next, %loop2 ]\n %iv0.next = add nsw i32 %iv0, 1\n %cmp = icmp sgt i32 %iv0.next, 0\n br i1 %cmp, label %backedge, label %loop2\n\nexit1: ; preds = %backedge\n ret void\n}\n", "additional_args": null, "lli_expected_out": null } ] } ]
{ "title": "[SCEV] Assertion `isAvailableAtLoopEntry(Op, L) && \"SCEVAddRecExpr operand is not available at loop entry!\"' failed.", "body": "Faulty IR:\n```\n; ModuleID = 'test.ll'\nsource_filename = \"/nfs/build-cache/zvm-dev-4598/jdk11/x86_64/fastdebug/lib/server/boilerplate.ll\"\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @test(ptr addrspace(1) %p) {\nentry:\n %check = icmp eq ptr addrspace(1) %p, null\n br label %bb0\n\nbb0: ; preds = %loop0, %entry\n br i1 %check, label %loop0, label %latch\n\nlatch: ; preds = %bb0\n br i1 %check, label %exit0, label %loop0\n\nexit0: ; preds = %latch\n ret void\n\nloop0: ; preds = %latch, %bb0\n %0 = load atomic i32, ptr addrspace(1) %p unordered, align 8\n %add = add i32 %0, 3\n br i1 true, label %preheader, label %bb0\n\npreheader: ; preds = %loop0\n br label %loop1\n\nloop1: ; preds = %backedge, %preheader\n %iv1 = phi i32 [ %add, %preheader ], [ %1, %backedge ]\n %1 = add i32 %iv1, -33\n br label %loop2\n\nbackedge: ; preds = %loop2\n br i1 true, label %exit1, label %loop1\n\nloop2: ; preds = %loop2, %loop1\n %iv0 = phi i32 [ %iv1, %loop1 ], [ %2, %loop2 ]\n %2 = add nsw i32 %iv0, 1\n %3 = icmp sgt i32 %2, 0\n br i1 %3, label %backedge, label %loop2\n\nexit1: ; preds = %backedge\n ret void\n}\n```\nfails when run with `opt -passes='print<scalar-evolution>,simple-loop-unswitch<nontrivial>,print<scalar-evolution>' `\nDemo of failure: https://godbolt.org/z/qhboK5r3j\n", "author": "Nirhar", "labels": [ "crash", "llvm:transforms" ], "comments": [ { "author": "Nirhar", "body": "Here is the IR after simple-loop-unswitch pass:\n![res](https://github.com/user-attachments/assets/8a35df98-54f4-45f6-9e96-626fd6814e7f)\n\n\nAt the point of crash, the SCEV for Exit Value of `%iv0`(which I assume, as we crashed while printing it) is `(-4 + (-1 * %1) + %.us-phi)`, which is incorrect. The crash happens because `%1` is in a block that does not properly dominate `%iv0`. Looks like, simple-loop-unswitch is either incorrectly updating the SCEV in the pass, or is incorrectly reporting SCEV to be preserved. As of now, I'm not sure which is the case. " }, { "author": "Nirhar", "body": "@nikic @dtcxzyw @EugeneZelenko any thoughts? I'm inclined to having a patch that removes SCEV from simple-loop-unswitch 's list of preserved analyses." }, { "author": "dtcxzyw", "body": "> I'm inclined to having a patch that removes SCEV from simple-loop-unswitch 's list of preserved analyses.\n\nSome SCEVs should be invalidated in `unswitchNontrivialInvariants`. Removing SCEV from the list of preserved analyses doesn't fix the issue.\n" } ] }
true
null
109376
https://github.com/llvm/llvm-project/issues/109376
crash
1c47fa9b620d0abb280647b4f361ada43784d00e
2024-09-20T05:30:57
[ "llvm/test/Transforms/SLPVectorizer" ]
{ "fix_commit": "3db0f8c895d4e814a18b754f9afbb1e03bd839a5", "components": [ "SLPVectorizer" ], "bug_location_lineno": { "llvm/include/llvm/Analysis/MemorySSAUpdater.h": null, "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [ [ 18668, 18673 ] ], "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/include/llvm/IR/Instruction.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null, "llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/include/llvm/IR/CmpPredicate.h": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanValue.h": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/include/llvm/Analysis/ScalarEvolution.h": null, "llvm/lib/Analysis/VectorUtils.cpp": null }, "bug_location_funcname": { "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [ "tryToReduce" ], "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/lib/Analysis/VectorUtils.cpp": null } }
commit 3db0f8c895d4e814a18b754f9afbb1e03bd839a5 Author: Alexey Bataev <[email protected]> Date: Mon Sep 23 10:49:54 2024 -0700 [SLP]Update TrackedToOrig mappings after reduction vectorization Need to update mappings in TrackedToOrig to correctly provide mapping between updated reduced value after vectorization and its original value, otherwise the compiler might miss this update and it may cause compiler crash later, when it tries to find the original instruction mapping for the updated value. Fixes https://github.com/llvm/llvm-project/issues/109376 diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index a88702b81096..04b8fc09a724 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -18668,6 +18668,14 @@ public: // Vectorize a tree. Value *VectorizedRoot = V.vectorizeTree(LocalExternallyUsedValues, InsertPt); + // Update TrackedToOrig mapping, since the tracked values might be + // updated. + for (Value *RdxVal : Candidates) { + Value *OrigVal = TrackedToOrig.at(RdxVal); + Value *TransformedRdxVal = TrackedVals.at(OrigVal); + if (TransformedRdxVal != RdxVal) + TrackedToOrig.try_emplace(TransformedRdxVal, OrigVal); + } Builder.SetInsertPoint(InsertPt);
[ { "file": "llvm/test/Transforms/SLPVectorizer/X86/reduced-value-vectorized-later.ll", "commands": [ "opt -S -passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s" ], "tests": [ { "test_name": "test", "test_body": "define i16 @test() {\nentry:\n %subi = add i16 0, 0\n %sub40.i = add i16 %subi, 0\n %sub41.i = add i16 %subi, 0\n %sub42.i = add i16 %subi, 0\n %sub43.i = add i16 %subi, 0\n %sub44.i = add i16 %subi, 0\n %sub45.i = add i16 %subi, 0\n %sub46.i = add i16 0, 0\n %sub47.i = add i16 0, 0\n %sub48.i = add i16 0, 0\n %sub49.i = add i16 0, 0\n %or40.i = or i16 %sub40.i, %sub41.i\n %or41.i = or i16 %or40.i, %sub42.i\n %or42.i = or i16 %or41.i, %sub43.i\n %or43.i = or i16 %or42.i, %sub44.i\n %or44.i = or i16 %or43.i, %sub45.i\n %or45.i = or i16 %or44.i, %sub46.i\n %or46.i = or i16 %or45.i, %sub47.i\n %or47.i = or i16 %or46.i, %sub48.i\n %or48.i = or i16 %or47.i, %sub49.i\n %or50.i = or i16 %or48.i, %subi\n %subii = add i16 0, 0\n %subi16.i = add i16 %subii, 0\n %subi17.i = add i16 %subii, 0\n %0 = or i16 %subi16.i, %subi17.i\n %1 = or i16 %0, %or50.i\n ret i16 %1\n}\n", "additional_args": null, "lli_expected_out": null } ] } ]
{ "title": "[SLPVectorizer] Assertion `Iter != this->end() && \"DenseMap::at failed due to a missing key\"' failed.", "body": "Reproducer: https://godbolt.org/z/v5bqhPWqb\r\n```\r\n; bin/opt -passes=slp-vectorizer reduced.ll -S\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine i16 @test() {\r\nentry:\r\n %sub.i487.i.reass.i = add i16 0, 0\r\n %sub.i487.i.reass.40.i = add i16 %sub.i487.i.reass.i, 0\r\n %sub.i487.i.reass.41.i = add i16 %sub.i487.i.reass.i, 0\r\n %sub.i487.i.reass.42.i = add i16 %sub.i487.i.reass.i, 0\r\n %sub.i487.i.reass.43.i = add i16 %sub.i487.i.reass.i, 0\r\n %sub.i487.i.reass.44.i = add i16 %sub.i487.i.reass.i, 0\r\n %sub.i487.i.reass.45.i = add i16 %sub.i487.i.reass.i, 0\r\n %sub.i487.i.reass.46.i = add i16 0, 0\r\n %sub.i487.i.reass.47.i = add i16 0, 0\r\n %sub.i487.i.reass.48.i = add i16 0, 0\r\n %sub.i487.i.reass.49.i = add i16 0, 0\r\n %or374461.i.40.i = or i16 %sub.i487.i.reass.40.i, %sub.i487.i.reass.41.i\r\n %or374461.i.41.i = or i16 %or374461.i.40.i, %sub.i487.i.reass.42.i\r\n %or374461.i.42.i = or i16 %or374461.i.41.i, %sub.i487.i.reass.43.i\r\n %or374461.i.43.i = or i16 %or374461.i.42.i, %sub.i487.i.reass.44.i\r\n %or374461.i.44.i = or i16 %or374461.i.43.i, %sub.i487.i.reass.45.i\r\n %or374461.i.45.i = or i16 %or374461.i.44.i, %sub.i487.i.reass.46.i\r\n %or374461.i.46.i = or i16 %or374461.i.45.i, %sub.i487.i.reass.47.i\r\n %or374461.i.47.i = or i16 %or374461.i.46.i, %sub.i487.i.reass.48.i\r\n %or374461.i.48.i = or i16 %or374461.i.47.i, %sub.i487.i.reass.49.i\r\n %or374461.i.50.i = or i16 %or374461.i.48.i, %sub.i487.i.reass.i\r\n %sub.i487.i96.reass.i = add i16 0, 0\r\n %sub.i487.i96.reass.16.i = add i16 %sub.i487.i96.reass.i, 0\r\n %sub.i487.i96.reass.17.i = add i16 %sub.i487.i96.reass.i, 0\r\n %0 = or i16 %sub.i487.i96.reass.16.i, %sub.i487.i96.reass.17.i\r\n %1 = or i16 %0, %or374461.i.50.i\r\n ret i16 %1\r\n}\r\n```\r\n```\r\nopt: /root/llvm-project/llvm/include/llvm/ADT/DenseMap.h:204: const ValueT& llvm::DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT, BucketT>::at(llvm::DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT, BucketT>::const_arg_type_t<KeyT>) const [with DerivedT = llvm::DenseMap<llvm::Value*, llvm::Value*>; KeyT = llvm::Value*; ValueT = llvm::Value*; KeyInfoT = llvm::DenseMapInfo<llvm::Value*, void>; BucketT = llvm::detail::DenseMapPair<llvm::Value*, llvm::Value*>; llvm::DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT, BucketT>::const_arg_type_t<KeyT> = const llvm::Value*]: Assertion `Iter != this->end() && \"DenseMap::at failed due to a missing key\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer <source>\r\n1.\tRunning pass \"function(slp-vectorizer)\" on module \"<source>\"\r\n2.\tRunning pass \"slp-vectorizer\" on function \"test\"\r\n #0 0x0000000005035d68 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5035d68)\r\n #1 0x00000000050334ac SignalHandler(int) Signals.cpp:0:0\r\n #2 0x0000707bdcc42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x0000707bdcc969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x0000707bdcc42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x0000707bdcc287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x0000707bdcc2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x0000707bdcc39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x000000000409326e llvm::DenseMapBase<llvm::DenseMap<llvm::Value*, llvm::Value*, llvm::DenseMapInfo<llvm::Value*, void>, llvm::detail::DenseMapPair<llvm::Value*, llvm::Value*>>, llvm::Value*, llvm::Value*, llvm::DenseMapInfo<llvm::Value*, void>, llvm::detail::DenseMapPair<llvm::Value*, llvm::Value*>>::at(llvm::Value const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x409326e)\r\n #9 0x000000000413473f (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&) SLPVectorizer.cpp:0:0\r\n#10 0x00000000041370d1 llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41370d1)\r\n#11 0x000000000413b996 llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*) (.constprop.0) SLPVectorizer.cpp:0:0\r\n#12 0x000000000413ff36 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x413ff36)\r\n#13 0x0000000004146401 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\r\n#14 0x000000000414708b llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x414708b)\r\n#15 0x0000000002f1a1ae llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2f1a1ae)\r\n#16 0x0000000004e38158 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e38158)\r\n#17 0x0000000000e0b02e 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+0xe0b02e)\r\n#18 0x0000000004e36b7e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e36b7e)\r\n#19 0x0000000000e0a83e 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+0xe0a83e)\r\n#20 0x0000000004e365b0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e365b0)\r\n#21 0x00000000008feef2 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+0x8feef2)\r\n#22 0x00000000008f1d7c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8f1d7c)\r\n#23 0x0000707bdcc29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#24 0x0000707bdcc29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#25 0x00000000008e984e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8e984e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```\r\nllvm version: e8a739062490ce1bb30974f216ba187cd7b5a2a4", "author": "dtcxzyw", "labels": [ "llvm:SLPVectorizer", "crash-on-valid" ], "comments": [] }
true
null
113143
https://github.com/llvm/llvm-project/issues/113143
crash
42ba452aa94e4da277842d8990ad958a6256e558
2024-10-21T10:11:54
[ "llvm/test/Transforms/SLPVectorizer" ]
{ "fix_commit": "9e03920cbf946e7ba282e99213707643a23ae5fb", "components": [ "SLPVectorizer" ], "bug_location_lineno": { "llvm/include/llvm/Analysis/MemorySSAUpdater.h": null, "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [ [ 12466, 12472 ] ], "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/include/llvm/IR/Instruction.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null, "llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/include/llvm/IR/CmpPredicate.h": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanValue.h": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/include/llvm/Analysis/ScalarEvolution.h": null, "llvm/lib/Analysis/VectorUtils.cpp": null }, "bug_location_funcname": { "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [ "BoUpSLP::isGatherShuffledSingleRegisterEntry" ], "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/lib/Analysis/VectorUtils.cpp": null } }
commit 9e03920cbf946e7ba282e99213707643a23ae5fb Author: Alexey Bataev <[email protected]> Date: Mon Oct 21 08:57:36 2024 -0700 [SLP]Ignore root gather node, when searching for reuses Root gather/buildvector node should be ignored when SLP vectorizer tries to find matching gather nodes, vectorized earlier. This node is definitely the last one in the pipeline and it does not have users. It may cause the compiler crash Fixes #113143 diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 1098bf578d2d..a11e3f3815cb 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -12466,7 +12466,7 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry( // Build a list of tree entries where V is used. SmallPtrSet<const TreeEntry *, 4> VToTEs; for (const TreeEntry *TEPtr : ValueToGatherNodes.find(V)->second) { - if (TEPtr == TE) + if (TEPtr == TE || TEPtr->Idx == 0) continue; assert(any_of(TEPtr->Scalars, [&](Value *V) { return GatheredScalars.contains(V); }) &&
[ { "file": "llvm/test/Transforms/SLPVectorizer/X86/root-gather-reused-scalar.ll", "commands": [ "opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s" ], "tests": [ { "test_name": "test", "test_body": "define void @test(ptr %a, i32 %0, i32 %1, i1 %cmp1) {\nentry:\n %2 = load i32, ptr %a, align 4\n %tobool10.not = icmp eq i32 %0, 0\n %cmp4.3 = icmp ne i32 %1, 0\n %3 = and i1 %cmp4.3, %tobool10.not\n %cmp2.2 = xor i1 %tobool10.not, true\n %conv3.2 = zext i1 %cmp2.2 to i32\n %cmp4.2 = icmp ne i32 %2, %conv3.2\n %cmp2.1 = xor i1 %cmp1, true\n %conv3.1 = zext i1 %cmp2.1 to i32\n %cmp4.1 = icmp ne i32 %2, %conv3.1\n %4 = select i1 %3, i1 %cmp4.2, i1 false\n %5 = select i1 %4, i1 %cmp4.1, i1 false\n %and.3 = zext i1 %5 to i32\n store i32 %and.3, ptr %a, align 4\n ret void\n}\n", "additional_args": null, "lli_expected_out": null } ] } ]
{ "title": "clang crashes on valid code at -O2 on x86_64-linux-gnu: Assertion `TEPtr->UserTreeIndices.size() == 1 && \"Expected only single user of a gather node.\"' failed ", "body": "It appears to be a recent regression as it doesn't reproduce with 19.1.0 and earlier. \r\n\r\nCompiler Explorer: https://godbolt.org/z/a1W3c5ard\r\n\r\n```\r\n[523] % clangtk -v\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git df8b785838a2db01b4d056e603f7317209accefb)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\r\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nCandidate multilib: .;@m64\r\nSelected multilib: .;@m64\r\n[524] % \r\n[524] % clangtk -O2 small.c\r\nclang-20: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:12559: std::optional<llvm::TargetTransformInfo::ShuffleKind> llvm::slpvectorizer::BoUpSLP::isGatherShuffledSingleRegisterEntry(const llvm::slpvectorizer::BoUpSLP::TreeEntry*, llvm::ArrayRef<llvm::Value*>, llvm::MutableArrayRef<int>, llvm::SmallVectorImpl<const llvm::slpvectorizer::BoUpSLP::TreeEntry*>&, unsigned int, bool): Assertion `TEPtr->UserTreeIndices.size() == 1 && \"Expected only single user of a gather node.\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/20241020-clangtk-m64-O2-build-231331/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20241020-clangtk-m64-O2-build-231331/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/20 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-572b89.o -x c small.c\r\n1.\t<eof> parser at end of file\r\n2.\tOptimizer\r\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"small.c\"\r\n4.\tRunning pass \"slp-vectorizer\" on function \"main\"\r\n #0 0x0000560576c8b9af llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x43f29af)\r\n #1 0x0000560576c89184 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007f4623c27420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #3 0x00007f462365e00b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #4 0x00007f462363d859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\r\n #5 0x00007f462363d729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #6 0x00007f462363d729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #7 0x00007f462364efd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #8 0x0000560578707edc llvm::slpvectorizer::BoUpSLP::isGatherShuffledSingleRegisterEntry(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::MutableArrayRef<int>, llvm::SmallVectorImpl<llvm::slpvectorizer::BoUpSLP::TreeEntry const*>&, unsigned int, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5e6eedc)\r\n #9 0x0000560578708cd8 llvm::slpvectorizer::BoUpSLP::isGatherShuffledEntry(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallVectorImpl<int>&, llvm::SmallVectorImpl<llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, 6u>>&, unsigned int, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5e6fcd8)\r\n#10 0x000056057870a6f3 llvm::InstructionCost llvm::slpvectorizer::BoUpSLP::processBuildVector<llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator, llvm::InstructionCost, llvm::TargetTransformInfo, llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP, llvm::SmallPtrSetImpl<llvm::Value*>>(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::Type*, llvm::TargetTransformInfo&, llvm::ArrayRef<llvm::Value*>&, llvm::slpvectorizer::BoUpSLP&, llvm::SmallPtrSetImpl<llvm::Value*>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5e716f3)\r\n#11 0x000056057870cde7 llvm::slpvectorizer::BoUpSLP::getEntryCost(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallPtrSetImpl<llvm::Value*>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5e73de7)\r\n#12 0x0000560578745f69 llvm::slpvectorizer::BoUpSLP::getTreeCost(llvm::ArrayRef<llvm::Value*>) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5eacf69)\r\n#13 0x000056057874b57b (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&) SLPVectorizer.cpp:0:0\r\n#14 0x000056057874eb79 llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5eb5b79)\r\n#15 0x000056057875349b llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (.constprop.0) SLPVectorizer.cpp:0:0\r\n#16 0x0000560578757d50 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5ebed50)\r\n#17 0x000056057875e590 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\r\n#18 0x000056057875f263 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5ec6263)\r\n#19 0x00005605781e0e66 llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5947e66)\r\n#20 0x0000560576614891 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3d7b891)\r\n#21 0x000056057410e656 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x1875656)\r\n#22 0x00005605766131fd llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3d7a1fd)\r\n#23 0x000056057410d196 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x1874196)\r\n#24 0x0000560576612c31 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3d79c31)\r\n#25 0x0000560576f44dd3 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#26 0x0000560576f483a8 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x46af3a8)\r\n#27 0x000056057764462c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4dab62c)\r\n#28 0x000056057951629c clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x6c7d29c)\r\n#29 0x0000560577644a48 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4daba48)\r\n#30 0x000056057790d3d9 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x50743d9)\r\n#31 0x00005605778895ce clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4ff05ce)\r\n#32 0x00005605779f9f26 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5160f26)\r\n#33 0x0000560573cd1fe5 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x1438fe5)\r\n#34 0x0000560573cc9afa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#35 0x0000560573cce52e clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x143552e)\r\n#36 0x0000560573bba67b main (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x132167b)\r\n#37 0x00007f462363f083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#38 0x0000560573cc958e _start (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x143058e)\r\nclangtk: error: unable to execute command: Aborted\r\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git df8b785838a2db01b4d056e603f7317209accefb)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nclangtk: note: diagnostic msg: \r\n********************\r\n\r\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\r\nPreprocessed source(s) and associated run script(s) are located at:\r\nclangtk: note: diagnostic msg: /tmp/small-d99d4e.c\r\nclangtk: note: diagnostic msg: /tmp/small-d99d4e.sh\r\nclangtk: note: diagnostic msg: \r\n\r\n********************\r\n[525] % \r\n[525] % cat small.c\r\nint a, b, c, d, e, f;\r\nint main() {\r\n for (f = 0; f < 4; f++) {\r\n d &= (((a > 0) != b) != c) && b;\r\n for (b = 0; b < 1; b++)\r\n if (e)\r\n break;\r\n }\r\n return 0;\r\n}\r\n```\r\n\r\n", "author": "zhendongsu", "labels": [ "llvm:SLPVectorizer", "crash-on-valid" ], "comments": [] }
true
null
122496
https://github.com/llvm/llvm-project/issues/122496
miscompilation
b4ce29ab31b29ca926704c160e3909298ddf2b2b
2025-01-10T16:59:46
[ "llvm/test/Transforms/LoopVectorize" ]
{ "fix_commit": "8df64ed77727ab9b7540819f2fe64379e88a50be", "components": [ "LoopVectorize" ], "bug_location_lineno": { "llvm/include/llvm/Analysis/MemorySSAUpdater.h": null, "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [ [ 3806, 3812 ] ], "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/include/llvm/IR/Instruction.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [ [ 621, 648 ] ], "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null, "llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/include/llvm/IR/CmpPredicate.h": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanValue.h": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/include/llvm/Analysis/ScalarEvolution.h": null, "llvm/lib/Analysis/VectorUtils.cpp": null }, "bug_location_funcname": { "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [ "LoopVectorizationCostModel::collectLoopUniforms" ], "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [ "legalizeAndOptimizeInductions" ], "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/lib/Analysis/VectorUtils.cpp": null } }
commit 8df64ed77727ab9b7540819f2fe64379e88a50be Author: Florian Hahn <[email protected]> Date: Sun Jan 12 22:03:21 2025 +0000 [LV] Don't consider IV increments uniform if exit value is used outside. In some cases, there might be a chain of uniform instructions producing the exit value. To generate correct code in all cases, consider the IV increment not uniform, if there are users outside the loop. Instead, let VPlan narrow the IV, if possible using the logic from 3ff1d01985752. Test case from #122602 verified with Alive2: https://alive2.llvm.org/ce/z/bA4EGj Fixes https://github.com/llvm/llvm-project/issues/122496. Fixes https://github.com/llvm/llvm-project/issues/122602. diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index b017b61a45a0..d32a463a996c 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -3806,7 +3806,7 @@ void LoopVectorizationCostModel::collectLoopUniforms(ElementCount VF) { // uniform after vectorization. bool UniformIndUpdate = all_of(IndUpdate->users(), [&](User *U) -> bool { auto *I = cast<Instruction>(U); - return I == Ind || !TheLoop->contains(I) || Worklist.count(I) || + return I == Ind || Worklist.count(I) || IsVectorizedMemAccessUse(I, IndUpdate); }); if (!UniformIndUpdate) diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp index f440bf2eb022..545d277d7aa0 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp @@ -621,28 +621,6 @@ static void legalizeAndOptimizeInductions(VPlan &Plan) { Def->replaceAllUsesWith(Clone); } - // Check if any uniform VPReplicateRecipes using the phi recipe are used by - // ExtractFromEnd. Those must be replaced by a regular VPReplicateRecipe to - // ensure the final value is available. - // TODO: Remove once uniformity analysis is done on VPlan. - for (VPUser *U : Users) { - auto *ExitIRI = dyn_cast<VPIRInstruction>(U); - VPValue *Op; - if (!ExitIRI || !match(ExitIRI->getOperand(0), - m_VPInstruction<VPInstruction::ExtractFromEnd>( - m_VPValue(Op), m_VPValue()))) - continue; - auto *RepR = dyn_cast<VPReplicateRecipe>(Op); - if (!RepR || !RepR->isUniform()) - continue; - assert(!RepR->isPredicated() && "RepR must not be predicated"); - Instruction *I = RepR->getUnderlyingInstr(); - auto *Clone = - new VPReplicateRecipe(I, RepR->operands(), /*IsUniform*/ false); - Clone->insertAfter(RepR); - RepR->replaceAllUsesWith(Clone); - } - // Replace wide pointer inductions which have only their scalars used by // PtrAdd(IndStart, ScalarIVSteps (0, Step)). if (auto *PtrIV = dyn_cast<VPWidenPointerInductionRecipe>(&Phi)) {
[ { "file": "<issue>", "commands": [ "opt -passes=loop-vectorize -S %s" ], "tests": [ { "test_name": "<module>", "test_body": "; bin/opt -passes=loop-vectorize test.ll -S\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@f = global [8 x [1 x i32]] zeroinitializer\n\ndefine i32 @main() {\nentry:\n br label %for.body6.i\n\nfor.body6.i: ; preds = %for.body6.i, %entry\n %conv34.i = phi i32 [ %conv.i, %for.body6.i ], [ 0, %entry ]\n %storemerge3133.i = phi i16 [ %inc.i, %for.body6.i ], [ 0, %entry ]\n %idxprom.i = zext i32 %conv34.i to i64\n %arrayidx.i = getelementptr [8 x [1 x i32]], ptr @f, i64 0, i64 %idxprom.i\n store i32 0, ptr %arrayidx.i, align 4\n %inc.i = add i16 %storemerge3133.i, 1\n %conv.i = zext i16 %inc.i to i32\n %cmp4.i = icmp ult i16 %storemerge3133.i, 3\n br i1 %cmp4.i, label %for.body6.i, label %for.cond11thread-pre-split.i\n\nfor.cond11thread-pre-split.i: ; preds = %for.body6.i\n %0 = add i32 %conv.i, -9\n %cmp24.i = icmp ult i32 %0, -6\n br i1 %cmp24.i, label %for.cond23.i, label %for.end27.i\n\nfor.cond23.i: ; preds = %for.cond23.i, %for.cond11thread-pre-split.i\n br label %for.cond23.i\n\nfor.end27.i: ; preds = %for.cond11thread-pre-split.i\n ret i32 0\n}", "additional_args": null, "lli_expected_out": "" } ] } ]
{ "title": "[clang] Miscompilation at -O2/3", "body": "This code prints 0 at `-O0/1` and triggers SIGKILL at `-O2/3`:\n\n```c\nint printf(const char *, ...);\nint a;\nshort b, c;\nlong e;\nint f[8][1];\nunsigned g;\nint h(int i) {\n long d = 0;\n for (; (a -= i) >= 0; d += 6)\n ;\n return d;\n}\nvoid j() {\n g = 0;\n for (; h(90) + g <= 0; g++) {\n int k = -1;\n b = 0;\n for (; k + g - -1 + b <= 3; b++)\n f[b + 3][0] = c;\n for (; b + g - 3 + e <= 8; e++)\n ;\n for (; e <= 3;)\n ;\n }\n}\nint main() {\n j();\n printf(\"%d\\n\", f[0][0]);\n}\n```\n\nCompiler Explorer: https://godbolt.org/z/3x8Yc3fnW\n\nIt seems to be a recent regression. ", "author": "cardigan1008", "labels": [ "regression", "miscompilation", "vectorizers" ], "comments": [ { "author": "fhahn", "body": "Bisecting now" }, { "author": "dtcxzyw", "body": "Reproducer: https://godbolt.org/z/6bzT9rs3K\n```\n; bin/opt -passes=loop-vectorize test.ll -S\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@f = global [8 x [1 x i32]] zeroinitializer\n\ndefine i32 @main() {\nentry:\n br label %for.body6.i\n\nfor.body6.i: ; preds = %for.body6.i, %entry\n %conv34.i = phi i32 [ %conv.i, %for.body6.i ], [ 0, %entry ]\n %storemerge3133.i = phi i16 [ %inc.i, %for.body6.i ], [ 0, %entry ]\n %idxprom.i = zext i32 %conv34.i to i64\n %arrayidx.i = getelementptr [8 x [1 x i32]], ptr @f, i64 0, i64 %idxprom.i\n store i32 0, ptr %arrayidx.i, align 4\n %inc.i = add i16 %storemerge3133.i, 1\n %conv.i = zext i16 %inc.i to i32\n %cmp4.i = icmp ult i16 %storemerge3133.i, 3\n br i1 %cmp4.i, label %for.body6.i, label %for.cond11thread-pre-split.i\n\nfor.cond11thread-pre-split.i: ; preds = %for.body6.i\n %0 = add i32 %conv.i, -9\n %cmp24.i = icmp ult i32 %0, -6\n br i1 %cmp24.i, label %for.cond23.i, label %for.end27.i\n\nfor.cond23.i: ; preds = %for.cond23.i, %for.cond11thread-pre-split.i\n br label %for.cond23.i\n\nfor.end27.i: ; preds = %for.cond11thread-pre-split.i\n ret i32 0\n}\n```\n[llubi](https://github.com/dtcxzyw/llvm-ub-aware-interpreter) output:\n\nBefore:\n```\nEntering function main\n br label %for.body6.i jump to %for.body6.i\n phi i32 %conv34.i -> i32 0\n phi i16 %storemerge3133.i -> i16 0\n %idxprom.i = zext i32 %conv34.i to i64 -> i64 0\n %arrayidx.i = getelementptr [8 x [1 x i32]], ptr @f, i64 0, i64 %idxprom.i -> Ptr 16[@f]\n store i32 0, ptr %arrayidx.i, align 4\n %inc.i = add i16 %storemerge3133.i, 1 -> i16 1\n %conv.i = zext i16 %inc.i to i32 -> i32 1\n %cmp4.i = icmp ult i16 %storemerge3133.i, 3 -> T\n br i1 %cmp4.i, label %for.body6.i, label %for.cond11thread-pre-split.i jump to %for.body6.i\n phi i32 %conv34.i -> i32 1\n phi i16 %storemerge3133.i -> i16 1\n %idxprom.i = zext i32 %conv34.i to i64 -> i64 1\n %arrayidx.i = getelementptr [8 x [1 x i32]], ptr @f, i64 0, i64 %idxprom.i -> Ptr 20[@f + 4]\n store i32 0, ptr %arrayidx.i, align 4\n %inc.i = add i16 %storemerge3133.i, 1 -> i16 2\n %conv.i = zext i16 %inc.i to i32 -> i32 2\n %cmp4.i = icmp ult i16 %storemerge3133.i, 3 -> T\n br i1 %cmp4.i, label %for.body6.i, label %for.cond11thread-pre-split.i jump to %for.body6.i\n phi i32 %conv34.i -> i32 2\n phi i16 %storemerge3133.i -> i16 2\n %idxprom.i = zext i32 %conv34.i to i64 -> i64 2\n %arrayidx.i = getelementptr [8 x [1 x i32]], ptr @f, i64 0, i64 %idxprom.i -> Ptr 24[@f + 8]\n store i32 0, ptr %arrayidx.i, align 4\n %inc.i = add i16 %storemerge3133.i, 1 -> i16 3\n %conv.i = zext i16 %inc.i to i32 -> i32 3\n %cmp4.i = icmp ult i16 %storemerge3133.i, 3 -> T\n br i1 %cmp4.i, label %for.body6.i, label %for.cond11thread-pre-split.i jump to %for.body6.i\n phi i32 %conv34.i -> i32 3\n phi i16 %storemerge3133.i -> i16 3\n %idxprom.i = zext i32 %conv34.i to i64 -> i64 3\n %arrayidx.i = getelementptr [8 x [1 x i32]], ptr @f, i64 0, i64 %idxprom.i -> Ptr 28[@f + 12]\n store i32 0, ptr %arrayidx.i, align 4\n %inc.i = add i16 %storemerge3133.i, 1 -> i16 4\n %conv.i = zext i16 %inc.i to i32 -> i32 4\n %cmp4.i = icmp ult i16 %storemerge3133.i, 3 -> F\n br i1 %cmp4.i, label %for.body6.i, label %for.cond11thread-pre-split.i jump to %for.cond11thread-pre-split.i\n %0 = add i32 %conv.i, -9 -> i32 -5\n %cmp24.i = icmp ult i32 %0, -6 -> F\n br i1 %cmp24.i, label %for.cond23.i, label %for.end27.i jump to %for.end27.i\n ret i32 0\nExiting function main\n```\nAfter:\n```\nEntering function main\n br i1 false, label %scalar.ph, label %vector.ph jump to %vector.ph\n br label %vector.body jump to %vector.body\n %0 = zext i32 0 to i64 -> i64 0\n %1 = getelementptr [8 x [1 x i32]], ptr @f, i64 0, i64 %0 -> Ptr 16[@f]\n %2 = getelementptr i32, ptr %1, i32 0 -> Ptr 16[@f]\n store <4 x i32> zeroinitializer, ptr %2, align 4\n %3 = add i16 0, 1 -> i16 1\n %4 = zext i16 %3 to i32 -> i32 1\n %5 = zext i16 %3 to i32 -> i32 1\n %6 = zext i16 %3 to i32 -> i32 1\n %7 = zext i16 %3 to i32 -> i32 1\n br label %middle.block jump to %middle.block\n br i1 true, label %for.cond11thread-pre-split.i, label %scalar.ph jump to %for.cond11thread-pre-split.i\n phi i32 %conv.i.lcssa -> i32 1\n %8 = add i32 %conv.i.lcssa, -9 -> i32 -8\n %cmp24.i = icmp ult i32 %8, -6 -> T\n br i1 %cmp24.i, label %for.cond23.i.preheader, label %for.end27.i jump to %for.cond23.i.preheader\n br label %for.cond23.i jump to %for.cond23.i\n br label %for.cond23.i jump to %for.cond23.i\n br label %for.cond23.i jump to %for.cond23.i\n ...\n```\n" } ] }
true
null
91178
https://github.com/llvm/llvm-project/issues/91178
miscompilation
7098cd215b95286794d9e0c822e8323ad0509750
2024-05-06T09:44:48
[ "llvm/test/Transforms/InstCombine", "llvm/test/Transforms/PGOProfile" ]
{ "fix_commit": "d085b42cbbefe79a41113abcd2b1e1f2a203acef", "components": [ "InstructionSimplify" ], "bug_location_lineno": { "llvm/include/llvm/Analysis/MemorySSAUpdater.h": null, "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": [ [ 4312, 4317 ] ], "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/include/llvm/IR/Instruction.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null, "llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/include/llvm/IR/CmpPredicate.h": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanValue.h": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/include/llvm/Analysis/ScalarEvolution.h": null, "llvm/lib/Analysis/VectorUtils.cpp": null }, "bug_location_funcname": { "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": [ "simplifyWithOpReplaced" ], "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/lib/Analysis/VectorUtils.cpp": null } }
commit d085b42cbbefe79a41113abcd2b1e1f2a203acef Author: Yingwei Zheng <[email protected]> Date: Wed May 8 10:04:09 2024 +0800 [InstSimplify] Do not simplify freeze in `simplifyWithOpReplaced` (#91215) See the LangRef: > All uses of a value returned by the same ‘freeze’ instruction are guaranteed to always observe the same value, while different ‘freeze’ instructions may yield different values. It is incorrect to replace freezes with the simplified value. Proof: https://alive2.llvm.org/ce/z/3Dn9Cd https://alive2.llvm.org/ce/z/Qyh5h6 Fixes https://github.com/llvm/llvm-project/issues/91178 diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 4061dae83c10..37a7259a5cd0 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -4312,6 +4312,10 @@ static Value *simplifyWithOpReplaced(Value *V, Value *Op, Value *RepOp, if (match(I, m_Intrinsic<Intrinsic::is_constant>())) return nullptr; + // Don't simplify freeze. + if (isa<FreezeInst>(I)) + return nullptr; + // Replace Op with RepOp in instruction operands. SmallVector<Value *, 8> NewOps; bool AnyReplaced = false;
[ { "file": "llvm/test/Transforms/InstCombine/icmp.ll", "commands": [ "opt < %s -passes=instcombine -S" ], "tests": [ { "test_name": "icmp_freeze_sext", "test_body": "target datalayout = \"e-p:64:64:64-p1:16:16:16-p2:32:32:32-p3:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64\"\n\ndefine i1 @icmp_freeze_sext(i16 %x, i16 %y) {\n %cmp1 = icmp uge i16 %x, %y\n %ext = sext i1 %cmp1 to i16\n %ext.fr = freeze i16 %ext\n %cmp2 = icmp uge i16 %ext.fr, %y\n ret i1 %cmp2\n}\n", "additional_args": null, "lli_expected_out": null } ] }, { "file": "llvm/test/Transforms/InstCombine/select.ll", "commands": [ "opt < %s -passes=instcombine -S" ], "tests": [ { "test_name": "test_replace_freeze_oneuse", "test_body": "target datalayout = \"e-p:64:64-p1:16:16-p2:32:32:32-p3:64:64:64\"\n\ndefine i8 @test_replace_freeze_oneuse(i1 %x, i8 %y) {\n %ext = zext i1 %x to i8\n %shl = shl nuw i8 %ext, %y\n %shl.fr = freeze i8 %shl\n %sel = select i1 %x, i8 0, i8 %shl.fr\n ret i8 %sel\n}\n", "additional_args": null, "lli_expected_out": null }, { "test_name": "sequence_select_with_same_cond_extra_use", "test_body": "target datalayout = \"e-p:64:64-p1:16:16-p2:32:32:32-p3:64:64:64\"\n\ndeclare void @use32(i32)\n\ndefine i32 @sequence_select_with_same_cond_extra_use(i1 %c1, i1 %c2) {\n %s1 = select i1 %c1, i32 23, i32 45\n call void @use32(i32 %s1)\n %s2 = select i1 %c2, i32 666, i32 %s1\n %s3 = select i1 %c1, i32 789, i32 %s2\n ret i32 %s3\n}\n", "additional_args": null, "lli_expected_out": null }, { "test_name": "test_replace_freeze_multiuse", "test_body": "target datalayout = \"e-p:64:64-p1:16:16-p2:32:32:32-p3:64:64:64\"\n\ndefine i8 @test_replace_freeze_multiuse(i1 %x, i8 %y) {\n %ext = zext i1 %x to i8\n %shl = shl nuw i8 %ext, %y\n %shl.fr = freeze i8 %shl\n %sel = select i1 %x, i8 0, i8 %shl.fr\n %add = add i8 %shl.fr, %sel\n ret i8 %add\n}\n", "additional_args": null, "lli_expected_out": null } ] } ]
{ "title": "[InstCombine] Miscompilation which simplifies a use of a multi-use freeze", "body": "Reduced test case: https://alive2.llvm.org/ce/z/_JyUGw\r\n```\r\ndefine i8 @func78(i1 %0, i8 %1) {\r\n %3 = zext i1 %0 to i8\r\n %4 = shl i8 %3, %1\r\n %5 = freeze i8 %4\r\n %6 = select i1 %0, i8 0, i8 %5\r\n %7 = call i8 @llvm.fshr.i8(i8 0, i8 %5, i8 %6)\r\n ret i8 %7\r\n}\r\n```\r\n\r\n```\r\n----------------------------------------\r\ndefine i8 @func78(i1 %#0, i8 %#1) {\r\n#2:\r\n %#3 = zext i1 %#0 to i8\r\n %#4 = shl i8 %#3, %#1\r\n %#5 = freeze i8 %#4\r\n %#6 = select i1 %#0, i8 0, i8 %#5\r\n %#7 = fshr i8 0, i8 %#5, i8 %#6\r\n ret i8 %#7\r\n}\r\n=>\r\ndefine i8 @func78(i1 %#0, i8 %#1) nofree noundef willreturn memory(none) {\r\n#2:\r\n %#3 = zext i1 %#0 to i8\r\n %#4 = shl nuw i8 %#3, %#1\r\n %#5 = freeze i8 %#4\r\n ret i8 %#5\r\n}\r\nTransformation doesn't verify!\r\n\r\nERROR: Value mismatch\r\n\r\nExample:\r\ni1 %#0 = #x0 (0)\r\ni8 %#1 = #x08 (8)\r\n\r\nSource:\r\ni8 %#3 = #x00 (0)\r\ni8 %#4 = poison\r\ni8 %#5 = #x00 (0)\r\ni8 %#6 = #x00 (0)\r\ni8 %#7 = #x00 (0)\r\n\r\nTarget:\r\ni8 %#3 = #x00 (0)\r\ni8 %#4 = poison\r\ni8 %#5 = #x9d (157, -99)\r\nSource value: #x00 (0)\r\nTarget value: #x9d (157, -99)\r\n\r\nSummary:\r\n 0 correct transformations\r\n 1 incorrect transformations\r\n 0 failed-to-prove transformations\r\n 0 Alive2 errors\r\n```", "author": "dtcxzyw", "labels": [ "miscompilation", "llvm:instcombine" ], "comments": [] }
true
null
119002
https://github.com/llvm/llvm-project/issues/119002
crash
6797b0f0c002c9f3dda7a2b502ddf33e2c8f6777
2024-12-06T17:29:17
[ "llvm/test/Transforms/SLPVectorizer" ]
{ "fix_commit": "376dad72abb4960cd93e37e3e98de3950b5c3dfe", "components": [ "SLPVectorizer" ], "bug_location_lineno": { "llvm/include/llvm/Analysis/MemorySSAUpdater.h": null, "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [ [ 16215, 16220 ] ], "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/include/llvm/IR/Instruction.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null, "llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/include/llvm/IR/CmpPredicate.h": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanValue.h": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/include/llvm/Analysis/ScalarEvolution.h": null, "llvm/lib/Analysis/VectorUtils.cpp": null }, "bug_location_funcname": { "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [ "BoUpSLP::vectorizeTree" ], "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/lib/Analysis/VectorUtils.cpp": null } }
commit 376dad72abb4960cd93e37e3e98de3950b5c3dfe Author: Alexey Bataev <[email protected]> Date: Fri Dec 6 13:39:05 2024 -0800 [SLP]Move resulting vector before inert point, if the late generated buildvector fully matched If the perfect diamond match was detected for the postponed buildvectors and the vector for the previous node comes after the current node, need to move the vector register before the current inserting point to prevent compiler crash. Fixes #119002 diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 51841a842ce0..50590e51ae0e 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -16215,6 +16215,11 @@ BoUpSLP::vectorizeTree(const ExtraValueToDebugLocsMap &ExternallyUsedValues, } Builder.SetCurrentDebugLocation(UserI->getDebugLoc()); Value *Vec = vectorizeTree(TE, /*PostponedPHIs=*/false); + if (auto *VecI = dyn_cast<Instruction>(Vec); + VecI && VecI->getParent() == Builder.GetInsertBlock() && + Builder.GetInsertPoint()->comesBefore(VecI)) + VecI->moveBeforePreserving(*Builder.GetInsertBlock(), + Builder.GetInsertPoint()); if (Vec->getType() != PrevVec->getType()) { assert(Vec->getType()->isIntOrIntVectorTy() && PrevVec->getType()->isIntOrIntVectorTy() &&
[ { "file": "llvm/test/Transforms/SLPVectorizer/X86/perfect-matched-reused-bv.ll", "commands": [ "opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -mattr=+avx512f < %s" ], "tests": [ { "test_name": "test", "test_body": "define void @test() {\nbb:\n br label %bb1\n\nbb1: ; preds = %bb4, %bb\n %phi = phi i32 [ 0, %bb ], [ %add6, %bb4 ]\n %phi2 = phi i32 [ 0, %bb ], [ %add, %bb4 ]\n %or = or i32 %phi2, 0\n %or3 = or i32 %phi, 0\n br i1 false, label %bb7, label %bb4\n\nbb4: ; preds = %bb1\n %add = add i32 0, 0\n %add5 = add i32 0, 0\n %add6 = add i32 %phi, 0\n br i1 false, label %bb7, label %bb1\n\nbb7: ; preds = %bb4, %bb1\n %phi8 = phi i32 [ %or, %bb1 ], [ %add5, %bb4 ]\n %phi9 = phi i32 [ %or3, %bb1 ], [ %add6, %bb4 ]\n ret void\n}\n", "additional_args": null, "lli_expected_out": null } ] } ]
{ "title": "Instruction does not dominate all uses! LLVM ERROR: Broken module found, compilation aborted! (yet another)", "body": "To reproduce run the test below with -passes slp-vectorizer\n```\n; ModuleID = './reduced.ll'\nsource_filename = \"./reduced.ll\"\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @wombat() #0 gc \"statepoint-example\" {\nbb:\n br label %bb1\n\nbb1: ; preds = %bb4, %bb\n %phi = phi i32 [ 0, %bb ], [ %add6, %bb4 ]\n %phi2 = phi i32 [ 0, %bb ], [ %add, %bb4 ]\n %or = or i32 %phi2, 0\n %or3 = or i32 %phi, 0\n br i1 false, label %bb7, label %bb4\n\nbb4: ; preds = %bb1\n %add = add i32 0, 0\n %add5 = add i32 0, 0\n %add6 = add i32 %phi, 0\n br i1 false, label %bb7, label %bb1\n\nbb7: ; preds = %bb4, %bb1\n %phi8 = phi i32 [ %or, %bb1 ], [ %add5, %bb4 ]\n %phi9 = phi i32 [ %or3, %bb1 ], [ %add6, %bb4 ]\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+prfchw,-cldemote,+avx,+aes,+sahf,+pclmul,-xop,+crc32,-amx-fp8,+xsaves,-avx512fp16,-usermsr,-sm4,-egpr,+sse4.1,-avx512ifma,+xsave,+sse4.2,-tsxldtrk,-sm3,-ptwrite,-widekl,-movrs,+invpcid,+64bit,+xsavec,-avx10.1-512,-avx512vpopcntdq,+cmov,-avx512vp2intersect,+avx512cd,+movbe,-avxvnniint8,-ccmp,-amx-int8,-kl,-avx10.1-256,+evex512,-avxvnni,+rtm,+adx,+avx2,-hreset,-movdiri,-serialize,-sha512,-vpclmulqdq,+avx512vl,-uintr,-cf,+clflushopt,-raoint,-cmpccxadd,+bmi,-amx-tile,+sse,-avx10.2-256,-gfni,-avxvnniint16,-amx-fp16,-zu,-ndd,+xsaveopt,+rdrnd,+avx512f,-amx-bf16,-avx512bf16,-avx512vnni,-push2pop2,+cx8,+avx512bw,+sse3,+pku,-nf,-amx-tf32,-amx-avx512,+fsgsbase,-clzero,-mwaitx,-lwp,+lzcnt,-sha,-movdir64b,-ppx,-wbnoinvd,-enqcmd,-amx-transpose,-avx10.2-512,-avxneconvert,-tbm,-pconfig,-amx-complex,+ssse3,+cx16,+bmi2,+fma,+popcnt,-avxifma,+f16c,-avx512bitalg,-rdpru,+clwb,+mmx,+sse2,+rdseed,-avx512vbmi2,-prefetchi,-amx-movrs,-rdpid,-fma4,-avx512vbmi,-shstk,-vaes,-waitpkg,-sgx,+fxsr,+avx512dq,-sse4a,-avx512f\" }\n```\nReproducer: https://godbolt.org/z/Kqddzds1c\n\nStack dump:\n```\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes slp-vectorizer <source>\n1.\tRunning pass \"verify\" on module \"<source>\"\n #0 0x00000000051b4a48 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x51b4a48)\n #1 0x00000000051b243c SignalHandler(int) Signals.cpp:0:0\n #2 0x00007c6fb5442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007c6fb54969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007c6fb5442476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007c6fb54287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x00000000007e2469 llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0\n #7 0x00000000050f32d8 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x50f32d8)\n #8 0x0000000004ff2498 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4ff2498)\n #9 0x00000000009057ae llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9057ae)\n#10 0x0000000004fb1d10 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4fb1d10)\n#11 0x0000000000910d7a 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+0x910d7a)\n#12 0x00000000009033f9 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9033f9)\n#13 0x00007c6fb5429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#14 0x00007c6fb5429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#15 0x00000000008facde _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8facde)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```", "author": "TatyanaDoubts", "labels": [ "llvm:SLPVectorizer", "crash" ], "comments": [] }
true
null
113462
https://github.com/llvm/llvm-project/issues/113462
crash
3605d9a456185f4af78c01a2684b822b57bca9b0
2024-10-23T14:33:27
[ "llvm/test/Transforms/SLPVectorizer" ]
{ "fix_commit": "b65b2b4ab60763515694c740935989f908a03312", "components": [ "SLPVectorizer" ], "bug_location_lineno": { "llvm/include/llvm/Analysis/MemorySSAUpdater.h": null, "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [ [ 9840, 9852 ] ], "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/include/llvm/IR/Instruction.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null, "llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/include/llvm/IR/CmpPredicate.h": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanValue.h": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/include/llvm/Analysis/ScalarEvolution.h": null, "llvm/lib/Analysis/VectorUtils.cpp": null }, "bug_location_funcname": { "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [ "computeExtractCost" ], "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/lib/Analysis/VectorUtils.cpp": null } }
commit b65b2b4ab60763515694c740935989f908a03312 Author: Alexey Bataev <[email protected]> Date: Wed Oct 23 12:03:38 2024 -0700 [SLP]Expand vector to the whole register size in extracts adjustment Need to expand the number of elements to the whole register to correctly process estimation and avoid compiler crash. Fixes #113462 diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index d824c40c401d..889c4d94ba5e 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -9840,13 +9840,14 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis { ::getShuffleCost(TTI, *RegShuffleKind, getWidenedType(ScalarTy, EltsPerVector), SubMask); } + const unsigned BaseVF = getFullVectorNumberOfElements( + *R.TTI, VL.front()->getType(), alignTo(NumElts, EltsPerVector)); for (unsigned Idx : Indices) { - assert((Idx + EltsPerVector) <= alignTo(NumElts, EltsPerVector) && + assert((Idx + EltsPerVector) <= BaseVF && "SK_ExtractSubvector index out of range"); - Cost += ::getShuffleCost( - TTI, TTI::SK_ExtractSubvector, - getWidenedType(ScalarTy, alignTo(NumElts, EltsPerVector)), {}, - CostKind, Idx, getWidenedType(ScalarTy, EltsPerVector)); + Cost += ::getShuffleCost(TTI, TTI::SK_ExtractSubvector, + getWidenedType(ScalarTy, BaseVF), {}, CostKind, + Idx, getWidenedType(ScalarTy, EltsPerVector)); } // Second attempt to check, if just a permute is better estimated than // subvector extract.
[ { "file": "llvm/test/Transforms/SLPVectorizer/partial-register-extract.ll", "commands": [ "opt -S --passes=slp-vectorizer < %s" ], "tests": [ { "test_name": "<module>", "test_body": "target datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndeclare void @callee(i32, i64)\n\ndefine i32 @main(i32 %g_274.promoted2477.i.i.i, ptr %p) {\nentry:\n %g_274.promoted2477.i.i.i1 = load i32, ptr %p, align 4\n br i1 false, label %for.inc347.i.i.i, label %for.cond159.preheader.i.i.i\n\nfor.cond159.preheader.i.i.i: ; preds = %entry\n %tobool239.not.us.i.i.i.not = icmp eq i32 %g_274.promoted2477.i.i.i1, 0\n %tobool239.not.us.i.1.i.i = icmp eq i32 %g_274.promoted2477.i.i.i1, 0\n %tobool239.not.us.i.3.i.i = icmp eq i32 %g_274.promoted2477.i.i.i1, 0\n %0 = or i1 %tobool239.not.us.i.3.i.i, %tobool239.not.us.i.1.i.i\n %tobool239.not.us.i.4.i.i = icmp eq i32 %g_274.promoted2477.i.i.i1, 0\n %inc34.i21362404.us.v.i.4.i.i = select i1 %tobool239.not.us.i.4.i.i, i64 0, i64 0\n %tobool239.not.us.i.5.i.i = icmp eq i32 0, 0\n %inc34.i21362404.us.v.i.5.i.i = select i1 %tobool239.not.us.i.5.i.i, i64 0, i64 0\n %inc34.i21362404.us.i.5.i.i = or i64 %inc34.i21362404.us.v.i.4.i.i, %inc34.i21362404.us.v.i.5.i.i\n %1 = or i1 %tobool239.not.us.i.5.i.i, %tobool239.not.us.i.4.i.i\n %inc34.i21362404.us.v.i.6.i.i = select i1 false, i64 0, i64 0\n %inc34.i21362404.us.i.6.i.i = or i64 %inc34.i21362404.us.i.5.i.i, %inc34.i21362404.us.v.i.6.i.i\n %tobool239.not.us.i.7.i.i = icmp eq i32 0, 0\n %inc34.i21362404.us.v.i.7.i.i = select i1 false, i64 0, i64 0\n %inc34.i21362404.us.i.7.i.i = or i64 %inc34.i21362404.us.i.6.i.i, %inc34.i21362404.us.v.i.7.i.i\n %inc34.i21362404.us.v.i.8.i.i = select i1 false, i64 0, i64 0\n %inc34.i21362404.us.i.8.i.i = or i64 %inc34.i21362404.us.i.7.i.i, %inc34.i21362404.us.v.i.8.i.i\n %inc34.i21362404.us.v.i.9.i.i = select i1 false, i64 0, i64 0\n %inc34.i21362404.us.i.9.i.i = or i64 %inc34.i21362404.us.i.8.i.i, %inc34.i21362404.us.v.i.9.i.i\n %tobool239.not.us.i.10.i.i = icmp eq i32 0, 0\n %tobool239.not.us.i.11.i.i = icmp eq i32 0, 0\n %2 = or i1 %tobool239.not.us.i.11.i.i, %tobool239.not.us.i.10.i.i\n %tobool239.not.us.i.12.i.i = icmp eq i32 %g_274.promoted2477.i.i.i, 0\n %3 = or i1 %tobool239.not.us.i.12.i.i, %2\n %tobool239.not.us.i.13.i.i = icmp eq i32 0, 0\n %tobool239.not.us.i.14.i.i = icmp eq i32 0, 0\n %4 = or i1 %tobool239.not.us.i.14.i.i, %tobool239.not.us.i.13.i.i\n %tobool239.not.us.i.16.i.i = icmp eq i32 0, 0\n %tobool239.not.us.i.17.i.i = icmp eq i32 0, 0\n %5 = or i1 %tobool239.not.us.i.17.i.i, %tobool239.not.us.i.16.i.i\n %tobool239.not.us.i.18.i.i = icmp eq i32 0, 0\n %6 = or i1 %tobool239.not.us.i.18.i.i, %5\n %tobool239.not.us.i.19.i.i = icmp eq i32 0, 0\n %tobool239.not.us.i.20.i.i = icmp eq i32 0, 0\n %7 = or i1 %tobool239.not.us.i.20.i.i, %tobool239.not.us.i.19.i.i\n %tobool239.not.us.i.21.i.i = icmp eq i32 0, 0\n %8 = or i1 %tobool239.not.us.i.21.i.i, %7\n %tobool239.not.us.i.22.i.i = icmp eq i32 0, 0\n %tobool239.not.us.i.23.i.i = icmp eq i32 0, 0\n %9 = or i1 %tobool239.not.us.i.23.i.i, %tobool239.not.us.i.22.i.i\n %tobool239.not.us.i.24.i.i = icmp eq i32 0, 0\n %10 = or i1 %tobool239.not.us.i.24.i.i, %9\n %11 = select i1 %10, i1 true, i1 %8\n %12 = select i1 %11, i1 true, i1 %6\n %13 = select i1 %12, i1 true, i1 %4\n %14 = select i1 %13, i1 true, i1 %3\n %15 = select i1 %14, i1 true, i1 %tobool239.not.us.i.7.i.i\n %16 = select i1 %15, i1 true, i1 %1\n %17 = or i1 %0, %tobool239.not.us.i.i.i.not\n %18 = select i1 %16, i1 true, i1 %17\n %and252.us.i.24.i.i = select i1 %18, i32 0, i32 0\n br label %for.inc347.i.i.i\n\nfor.inc347.i.i.i: ; preds = %for.cond159.preheader.i.i.i, %entry\n %g_202.promoted.i.i.i = phi i32 [ %and252.us.i.24.i.i, %for.cond159.preheader.i.i.i ], [ 0, %entry ]\n %.us-phi24612468.i.i.i = phi i64 [ %inc34.i21362404.us.i.9.i.i, %for.cond159.preheader.i.i.i ], [ 0, %entry ]\n call void @callee(i32 %g_202.promoted.i.i.i, i64 %.us-phi24612468.i.i.i)\n ret i32 0\n}", "additional_args": null, "lli_expected_out": null } ] } ]
{ "title": "[SLPVectorizer] Assertion `(Idx + EltsPerVector) <= alignTo(NumElts, EltsPerVector) && \"SK_ExtractSubvector index out of range\"' failed.", "body": "Reproducer: https://godbolt.org/z/fxYWYnWKs\r\n```\r\n; bin/opt -passes=slp-vectorizer reduced.ll -S\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndeclare void @callee(i32, i64)\r\n\r\ndefine i32 @main(i32 %g_274.promoted2477.i.i.i, ptr %p) {\r\nentry:\r\n %g_274.promoted2477.i.i.i1 = load i32, ptr %p, align 4\r\n br i1 false, label %for.inc347.i.i.i, label %for.cond159.preheader.i.i.i\r\n\r\nfor.cond159.preheader.i.i.i: ; preds = %entry\r\n %tobool239.not.us.i.i.i.not = icmp eq i32 %g_274.promoted2477.i.i.i1, 0\r\n %tobool239.not.us.i.1.i.i = icmp eq i32 %g_274.promoted2477.i.i.i1, 0\r\n %tobool239.not.us.i.3.i.i = icmp eq i32 %g_274.promoted2477.i.i.i1, 0\r\n %0 = or i1 %tobool239.not.us.i.3.i.i, %tobool239.not.us.i.1.i.i\r\n %tobool239.not.us.i.4.i.i = icmp eq i32 %g_274.promoted2477.i.i.i1, 0\r\n %inc34.i21362404.us.v.i.4.i.i = select i1 %tobool239.not.us.i.4.i.i, i64 0, i64 0\r\n %tobool239.not.us.i.5.i.i = icmp eq i32 0, 0\r\n %inc34.i21362404.us.v.i.5.i.i = select i1 %tobool239.not.us.i.5.i.i, i64 0, i64 0\r\n %inc34.i21362404.us.i.5.i.i = or i64 %inc34.i21362404.us.v.i.4.i.i, %inc34.i21362404.us.v.i.5.i.i\r\n %1 = or i1 %tobool239.not.us.i.5.i.i, %tobool239.not.us.i.4.i.i\r\n %inc34.i21362404.us.v.i.6.i.i = select i1 false, i64 0, i64 0\r\n %inc34.i21362404.us.i.6.i.i = or i64 %inc34.i21362404.us.i.5.i.i, %inc34.i21362404.us.v.i.6.i.i\r\n %tobool239.not.us.i.7.i.i = icmp eq i32 0, 0\r\n %inc34.i21362404.us.v.i.7.i.i = select i1 false, i64 0, i64 0\r\n %inc34.i21362404.us.i.7.i.i = or i64 %inc34.i21362404.us.i.6.i.i, %inc34.i21362404.us.v.i.7.i.i\r\n %inc34.i21362404.us.v.i.8.i.i = select i1 false, i64 0, i64 0\r\n %inc34.i21362404.us.i.8.i.i = or i64 %inc34.i21362404.us.i.7.i.i, %inc34.i21362404.us.v.i.8.i.i\r\n %inc34.i21362404.us.v.i.9.i.i = select i1 false, i64 0, i64 0\r\n %inc34.i21362404.us.i.9.i.i = or i64 %inc34.i21362404.us.i.8.i.i, %inc34.i21362404.us.v.i.9.i.i\r\n %tobool239.not.us.i.10.i.i = icmp eq i32 0, 0\r\n %tobool239.not.us.i.11.i.i = icmp eq i32 0, 0\r\n %2 = or i1 %tobool239.not.us.i.11.i.i, %tobool239.not.us.i.10.i.i\r\n %tobool239.not.us.i.12.i.i = icmp eq i32 %g_274.promoted2477.i.i.i, 0\r\n %3 = or i1 %tobool239.not.us.i.12.i.i, %2\r\n %tobool239.not.us.i.13.i.i = icmp eq i32 0, 0\r\n %tobool239.not.us.i.14.i.i = icmp eq i32 0, 0\r\n %4 = or i1 %tobool239.not.us.i.14.i.i, %tobool239.not.us.i.13.i.i\r\n %tobool239.not.us.i.16.i.i = icmp eq i32 0, 0\r\n %tobool239.not.us.i.17.i.i = icmp eq i32 0, 0\r\n %5 = or i1 %tobool239.not.us.i.17.i.i, %tobool239.not.us.i.16.i.i\r\n %tobool239.not.us.i.18.i.i = icmp eq i32 0, 0\r\n %6 = or i1 %tobool239.not.us.i.18.i.i, %5\r\n %tobool239.not.us.i.19.i.i = icmp eq i32 0, 0\r\n %tobool239.not.us.i.20.i.i = icmp eq i32 0, 0\r\n %7 = or i1 %tobool239.not.us.i.20.i.i, %tobool239.not.us.i.19.i.i\r\n %tobool239.not.us.i.21.i.i = icmp eq i32 0, 0\r\n %8 = or i1 %tobool239.not.us.i.21.i.i, %7\r\n %tobool239.not.us.i.22.i.i = icmp eq i32 0, 0\r\n %tobool239.not.us.i.23.i.i = icmp eq i32 0, 0\r\n %9 = or i1 %tobool239.not.us.i.23.i.i, %tobool239.not.us.i.22.i.i\r\n %tobool239.not.us.i.24.i.i = icmp eq i32 0, 0\r\n %10 = or i1 %tobool239.not.us.i.24.i.i, %9\r\n %11 = select i1 %10, i1 true, i1 %8\r\n %12 = select i1 %11, i1 true, i1 %6\r\n %13 = select i1 %12, i1 true, i1 %4\r\n %14 = select i1 %13, i1 true, i1 %3\r\n %15 = select i1 %14, i1 true, i1 %tobool239.not.us.i.7.i.i\r\n %16 = select i1 %15, i1 true, i1 %1\r\n %17 = or i1 %0, %tobool239.not.us.i.i.i.not\r\n %18 = select i1 %16, i1 true, i1 %17\r\n %and252.us.i.24.i.i = select i1 %18, i32 0, i32 0\r\n br label %for.inc347.i.i.i\r\n\r\nfor.inc347.i.i.i: ; preds = %for.cond159.preheader.i.i.i, %entry\r\n %g_202.promoted.i.i.i = phi i32 [ %and252.us.i.24.i.i, %for.cond159.preheader.i.i.i ], [ 0, %entry ]\r\n %.us-phi24612468.i.i.i = phi i64 [ %inc34.i21362404.us.i.9.i.i, %for.cond159.preheader.i.i.i ], [ 0, %entry ]\r\n call void @callee(i32 %g_202.promoted.i.i.i, i64 %.us-phi24612468.i.i.i)\r\n ret i32 0\r\n}\r\n```\r\n```\r\nopt: /root/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:9844: llvm::InstructionCost llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator::computeExtractCost(llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<int>, llvm::ArrayRef<std::optional<llvm::TargetTransformInfo::ShuffleKind> >, unsigned int): Assertion `(Idx + EltsPerVector) <= alignTo(NumElts, EltsPerVector) && \"SK_ExtractSubvector index out of range\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer <source>\r\n1.\tRunning pass \"function(slp-vectorizer)\" on module \"<source>\"\r\n2.\tRunning pass \"slp-vectorizer\" on function \"main\"\r\n #0 0x00000000050d8608 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x50d8608)\r\n #1 0x00000000050d5fbc SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007ed1b9642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x00007ed1b96969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x00007ed1b9642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x00007ed1b96287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00007ed1b962871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x00007ed1b9639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x000000000413c75f llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator::computeExtractCost(llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<int>, llvm::ArrayRef<std::optional<llvm::TargetTransformInfo::ShuffleKind>>, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x413c75f)\r\n #9 0x0000000004140d8b llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator::adjustExtracts(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::MutableArrayRef<int>, llvm::ArrayRef<std::optional<llvm::TargetTransformInfo::ShuffleKind>>, unsigned int, bool&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4140d8b)\r\n#10 0x000000000417b42a llvm::InstructionCost llvm::slpvectorizer::BoUpSLP::processBuildVector<llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator, llvm::InstructionCost, llvm::TargetTransformInfo, llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP, llvm::SmallPtrSetImpl<llvm::Value*>>(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::Type*, llvm::TargetTransformInfo&, llvm::ArrayRef<llvm::Value*>&, llvm::slpvectorizer::BoUpSLP&, llvm::SmallPtrSetImpl<llvm::Value*>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x417b42a)\r\n#11 0x000000000417cae7 llvm::slpvectorizer::BoUpSLP::getEntryCost(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallPtrSetImpl<llvm::Value*>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x417cae7)\r\n#12 0x00000000041b6e11 llvm::slpvectorizer::BoUpSLP::getTreeCost(llvm::ArrayRef<llvm::Value*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41b6e11)\r\n#13 0x00000000041bc5df (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&) SLPVectorizer.cpp:0:0\r\n#14 0x00000000041bfb71 llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41bfb71)\r\n#15 0x00000000041c431b llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (.constprop.0) SLPVectorizer.cpp:0:0\r\n#16 0x00000000041c856e llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41c856e)\r\n#17 0x00000000041cf231 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\r\n#18 0x00000000041cfedb llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41cfedb)\r\n#19 0x0000000002f64f0e llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2f64f0e)\r\n#20 0x0000000004ed9788 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4ed9788)\r\n#21 0x0000000000e2773e 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+0xe2773e)\r\n#22 0x0000000004ed81ae llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4ed81ae)\r\n#23 0x0000000000e26e8e 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+0xe26e8e)\r\n#24 0x0000000004ed7be0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4ed7be0)\r\n#25 0x000000000090a07a 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+0x90a07a)\r\n#26 0x00000000008fce7c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8fce7c)\r\n#27 0x00007ed1b9629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#28 0x00007ed1b9629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#29 0x00000000008f493e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8f493e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```\r\n\r\nllvm version: 8a9921f5692ab33451d11454b40a023ca0965a69\r\n", "author": "dtcxzyw", "labels": [ "llvm:SLPVectorizer", "crash-on-valid" ], "comments": [] }
true
null
89959
https://github.com/llvm/llvm-project/issues/89959
crash
bc8a4ea11070d06374b403cd09b771a99cc6ba1a
2024-04-24T17:43:58
[ "llvm/test/Transforms/IRCE" ]
{ "fix_commit": "22da5a6e34ed6146752b24d9156a678b50fddaef", "components": [ "InductiveRangeCheckElimination" ], "bug_location_lineno": { "llvm/include/llvm/Analysis/MemorySSAUpdater.h": null, "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/include/llvm/IR/Instruction.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null, "llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/include/llvm/IR/CmpPredicate.h": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": [ [ 279, 284 ] ], "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanValue.h": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/include/llvm/Analysis/ScalarEvolution.h": null, "llvm/lib/Analysis/VectorUtils.cpp": null }, "bug_location_funcname": { "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": [ "InductiveRangeCheck::parseRangeCheckICmp" ], "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/lib/Analysis/VectorUtils.cpp": null } }
commit 22da5a6e34ed6146752b24d9156a678b50fddaef Author: Yingwei Zheng <[email protected]> Date: Fri Apr 26 16:25:33 2024 +0800 [IRCE] Skip icmp ptr in `InductiveRangeCheck::parseRangeCheckICmp` (#89967) Fixes https://github.com/llvm/llvm-project/issues/89959. diff --git a/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp b/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp index 9df28747570c..104e8ceb7967 100644 --- a/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp +++ b/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp @@ -279,6 +279,9 @@ bool InductiveRangeCheck::parseRangeCheckICmp(Loop *L, ICmpInst *ICI, Value *LHS = ICI->getOperand(0); Value *RHS = ICI->getOperand(1); + if (!LHS->getType()->isIntegerTy()) + return false; + // Canonicalize to the `Index Pred Invariant` comparison if (IsLoopInvariant(LHS)) { std::swap(LHS, RHS);
[ { "file": "llvm/test/Transforms/IRCE/pr89959.ll", "commands": [ "opt -passes=irce -S < %s 2>&1" ], "tests": [ { "test_name": "<module>", "test_body": "\n; Make sure we don't crash.\ndefine void @pr89959() {\n;\ntop:\n br label %L3\n\nL3:\n %value_phi = phi ptr [ null, %top ], [ %0, %L13 ]\n %0 = getelementptr i8, ptr %value_phi, i64 8\n %.not = icmp ule ptr %value_phi, null\n br i1 %.not, label %L13, label %L15\n\nL13:\n br label %L3\n\nL15:\n ret void\n}", "additional_args": null, "lli_expected_out": null } ] } ]
{ "title": "Assertion in Scalar Evolution when running IRCE", "body": "The following IR crashes with \r\n```llvm\r\ndefine void @foo() {\r\ntop:\r\n br label %L3\r\n\r\nL3: ; preds = %L13, %top\r\n %value_phi = phi ptr [ null, %top ], [ %0, %L13 ]\r\n %0 = getelementptr i8, ptr %value_phi, i64 8\r\n %.not = icmp ule ptr %value_phi, null\r\n br i1 %.not, label %L13, label %L15\r\n\r\nL13: ; preds = %L3\r\n br label %L3\r\n\r\nL15: ; preds = %L3\r\n ret void\r\n}\r\n```\r\n\r\n`opt --passes=irce` \r\n\r\nhttps://godbolt.org/z/1sbvaT7r1 ", "author": "gbaraldi", "labels": [ "llvm:SCEV", "crash-on-valid" ], "comments": [] }
true
null
117517
https://github.com/llvm/llvm-project/issues/117517
crash
7e3187e12a2cef8b2552e08ce9423aca9c09d813
2024-11-25T05:18:47
[ "llvm/test/Transforms/SLPVectorizer" ]
{ "fix_commit": "57bbdbd7ae3698a274edd4dd6ef1b53d9129e552", "components": [ "SLPVectorizer" ], "bug_location_lineno": { "llvm/include/llvm/Analysis/MemorySSAUpdater.h": null, "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [ [ 1143, 1151 ] ], "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/include/llvm/IR/Instruction.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null, "llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/include/llvm/IR/CmpPredicate.h": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanValue.h": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/include/llvm/Analysis/ScalarEvolution.h": null, "llvm/lib/Analysis/VectorUtils.cpp": null }, "bug_location_funcname": { "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [ "addMask" ], "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/lib/Analysis/VectorUtils.cpp": null } }
commit 57bbdbd7ae3698a274edd4dd6ef1b53d9129e552 Author: Alexey Bataev <[email protected]> Date: Mon Nov 25 07:56:45 2024 -0800 [SLP]Relax assertion in mask combine for non-power-of-2 number of elements The nodes may contain non-power-of-2 number of elements. Need to relax the assertion to avoid possible compiler crash Fixes #117517 diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index d033b7c2ef4a..73218f377a06 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -1143,9 +1143,7 @@ static void addMask(SmallVectorImpl<int> &Mask, ArrayRef<int> SubMask, assert( (!ExtendingManyInputs || SubMask.size() > Mask.size() || // Check if input scalars were extended to match the size of other node. - (SubMask.size() == Mask.size() && - std::all_of(std::next(Mask.begin(), Mask.size() / 2), Mask.end(), - [](int Idx) { return Idx == PoisonMaskElem; }))) && + (SubMask.size() == Mask.size() && Mask.back() == PoisonMaskElem)) && "SubMask with many inputs support must be larger than the mask."); if (Mask.empty()) { Mask.append(SubMask.begin(), SubMask.end());
[ { "file": "llvm/test/Transforms/SLPVectorizer/X86/non-power-2-num-elems-reused.ll", "commands": [ "opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-10 < %s" ], "tests": [ { "test_name": "<module>", "test_body": "\ndefine i64 @test() {\n;\nentry:\n %xor148.2.i = xor i32 0, 0\n %conv193.i = zext i32 %xor148.2.i to i64\n %conv193.1.i = zext i32 %xor148.2.i to i64\n %or194.1.i = or i64 %conv193.i, %conv193.1.i\n %xor148.2.i.1 = xor i32 0, 0\n %conv193.i.1 = zext i32 %xor148.2.i.1 to i64\n %or194.i.1 = or i64 %or194.1.i, %conv193.i.1\n %conv193.1.i.1 = zext i32 %xor148.2.i.1 to i64\n %or194.1.i.1 = or i64 %or194.i.1, %conv193.1.i.1\n %xor148.2.i.2 = xor i32 0, 0\n %conv193.i.2 = zext i32 %xor148.2.i.2 to i64\n %or194.i.2 = or i64 %or194.1.i.1, %conv193.i.2\n %conv193.1.i.2 = zext i32 %xor148.2.i.2 to i64\n %or194.1.i.2 = or i64 %or194.i.2, %conv193.1.i.2\n %xor148.2.i.3 = xor i32 0, 0\n %conv193.i.3 = zext i32 %xor148.2.i.3 to i64\n %or194.i.3 = or i64 %or194.1.i.2, %conv193.i.3\n %conv193.1.i.3 = zext i32 %xor148.2.i.3 to i64\n %or194.1.i.3 = or i64 %or194.i.3, %conv193.1.i.3\n %xor148.2.i.4 = xor i32 0, 0\n %conv193.i.4 = zext i32 %xor148.2.i.4 to i64\n %or194.i.4 = or i64 %or194.1.i.3, %conv193.i.4\n %conv193.1.i.4 = zext i32 %xor148.2.i.4 to i64\n %or194.1.i.4 = or i64 %or194.i.4, %conv193.1.i.4\n %xor148.2.i.5 = xor i32 0, 0\n %conv193.i.5 = zext i32 %xor148.2.i.5 to i64\n %or194.i.5 = or i64 %or194.1.i.4, %conv193.i.5\n %conv193.1.i.5 = zext i32 %xor148.2.i.5 to i64\n %or194.1.i.5 = or i64 %or194.i.5, %conv193.1.i.5\n %xor148.2.i.6 = xor i32 0, 0\n %conv193.i.6 = zext i32 %xor148.2.i.6 to i64\n %or194.i.6 = or i64 %or194.1.i.5, %conv193.i.6\n %or54.i.i.6 = or i32 %xor148.2.i.6, 0\n %conv193.1.i.6 = zext i32 %or54.i.i.6 to i64\n %xor148.2.i.7 = xor i32 0, 0\n %conv193.i.7 = zext i32 %xor148.2.i.7 to i64\n %0 = or i64 %or194.i.6, %conv193.i.7\n %conv193.1.i.7 = zext i32 %xor148.2.i.7 to i64\n %1 = or i64 %0, %conv193.1.i.7\n %or194.1.i.7 = or i64 %1, %conv193.1.i.6\n ret i64 %or194.1.i.7\n}", "additional_args": null, "lli_expected_out": null } ] } ]
{ "title": "[SLPVectorizer] Assertion \"SubMask with many inputs support must be larger than the mask.\" failed.", "body": "Reproducer: https://godbolt.org/z/Mzbe1G875\r\n```\r\n; bin/opt -passes=slp-vectorizer test.ll -S\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine i64 @test() {\r\nentry:\r\n %xor148.2.i = xor i32 0, 0\r\n %conv193.i = zext i32 %xor148.2.i to i64\r\n %conv193.1.i = zext i32 %xor148.2.i to i64\r\n %or194.1.i = or i64 %conv193.i, %conv193.1.i\r\n %xor148.2.i.1 = xor i32 0, 0\r\n %conv193.i.1 = zext i32 %xor148.2.i.1 to i64\r\n %or194.i.1 = or i64 %or194.1.i, %conv193.i.1\r\n %conv193.1.i.1 = zext i32 %xor148.2.i.1 to i64\r\n %or194.1.i.1 = or i64 %or194.i.1, %conv193.1.i.1\r\n %xor148.2.i.2 = xor i32 0, 0\r\n %conv193.i.2 = zext i32 %xor148.2.i.2 to i64\r\n %or194.i.2 = or i64 %or194.1.i.1, %conv193.i.2\r\n %conv193.1.i.2 = zext i32 %xor148.2.i.2 to i64\r\n %or194.1.i.2 = or i64 %or194.i.2, %conv193.1.i.2\r\n %xor148.2.i.3 = xor i32 0, 0\r\n %conv193.i.3 = zext i32 %xor148.2.i.3 to i64\r\n %or194.i.3 = or i64 %or194.1.i.2, %conv193.i.3\r\n %conv193.1.i.3 = zext i32 %xor148.2.i.3 to i64\r\n %or194.1.i.3 = or i64 %or194.i.3, %conv193.1.i.3\r\n %xor148.2.i.4 = xor i32 0, 0\r\n %conv193.i.4 = zext i32 %xor148.2.i.4 to i64\r\n %or194.i.4 = or i64 %or194.1.i.3, %conv193.i.4\r\n %conv193.1.i.4 = zext i32 %xor148.2.i.4 to i64\r\n %or194.1.i.4 = or i64 %or194.i.4, %conv193.1.i.4\r\n %xor148.2.i.5 = xor i32 0, 0\r\n %conv193.i.5 = zext i32 %xor148.2.i.5 to i64\r\n %or194.i.5 = or i64 %or194.1.i.4, %conv193.i.5\r\n %conv193.1.i.5 = zext i32 %xor148.2.i.5 to i64\r\n %or194.1.i.5 = or i64 %or194.i.5, %conv193.1.i.5\r\n %xor148.2.i.6 = xor i32 0, 0\r\n %conv193.i.6 = zext i32 %xor148.2.i.6 to i64\r\n %or194.i.6 = or i64 %or194.1.i.5, %conv193.i.6\r\n %or54.i.i.6 = or i32 %xor148.2.i.6, 0\r\n %conv193.1.i.6 = zext i32 %or54.i.i.6 to i64\r\n %xor148.2.i.7 = xor i32 0, 0\r\n %conv193.i.7 = zext i32 %xor148.2.i.7 to i64\r\n %0 = or i64 %or194.i.6, %conv193.i.7\r\n %conv193.1.i.7 = zext i32 %xor148.2.i.7 to i64\r\n %1 = or i64 %0, %conv193.1.i.7\r\n %or194.1.i.7 = or i64 %1, %conv193.1.i.6\r\n ret i64 %or194.1.i.7\r\n}\r\n```\r\n```\r\nopt: /root/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:1143: void addMask(llvm::SmallVectorImpl<int>&, llvm::ArrayRef<int>, bool): Assertion `(!ExtendingManyInputs || SubMask.size() > Mask.size() || (SubMask.size() == Mask.size() && std::all_of(std::next(Mask.begin(), Mask.size() / 2), Mask.end(), [](int Idx) { return Idx == PoisonMaskElem; }))) && \"SubMask with many inputs support must be larger than the mask.\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer <source>\r\n1.\tRunning pass \"function(slp-vectorizer)\" on module \"<source>\"\r\n2.\tRunning pass \"slp-vectorizer\" on function \"test\"\r\n #0 0x00000000051b7378 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x51b7378)\r\n #1 0x00000000051b4d6c SignalHandler(int) Signals.cpp:0:0\r\n #2 0x0000751221842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x00007512218969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x0000751221842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x00007512218287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x000075122182871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x0000751221839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x00000000041e91f7 llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator::finalize(llvm::ArrayRef<int>, llvm::ArrayRef<std::pair<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, unsigned int>>, llvm::ArrayRef<int>, unsigned int, llvm::function_ref<void (llvm::Value*&, llvm::SmallVectorImpl<int>&)>) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41e91f7)\r\n #9 0x00000000042256f9 llvm::InstructionCost llvm::slpvectorizer::BoUpSLP::processBuildVector<llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator, llvm::InstructionCost, llvm::TargetTransformInfo, llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP, llvm::SmallPtrSetImpl<llvm::Value*>>(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::Type*, llvm::TargetTransformInfo&, llvm::ArrayRef<llvm::Value*>&, llvm::slpvectorizer::BoUpSLP&, llvm::SmallPtrSetImpl<llvm::Value*>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x42256f9)\r\n#10 0x000000000422f707 llvm::slpvectorizer::BoUpSLP::getEntryCost(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallPtrSetImpl<llvm::Value*>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x422f707)\r\n#11 0x00000000042636a1 llvm::slpvectorizer::BoUpSLP::getTreeCost(llvm::ArrayRef<llvm::Value*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x42636a1)\r\n#12 0x00000000042691b0 (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&) SLPVectorizer.cpp:0:0\r\n#13 0x000000000426c681 llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x426c681)\r\n#14 0x0000000004270deb llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (.constprop.0) SLPVectorizer.cpp:0:0\r\n#15 0x00000000042758a6 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x42758a6)\r\n#16 0x000000000427bf86 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\r\n#17 0x000000000427ca9b llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x427ca9b)\r\n#18 0x0000000002fcc5ce llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2fcc5ce)\r\n#19 0x0000000004fb6a68 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4fb6a68)\r\n#20 0x0000000000e3dd4e 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+0xe3dd4e)\r\n#21 0x0000000004fb548e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4fb548e)\r\n#22 0x0000000000e3d3fe 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+0xe3d3fe)\r\n#23 0x0000000004fb4ec0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4fb4ec0)\r\n#24 0x000000000090ce7a 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+0x90ce7a)\r\n#25 0x00000000008ff519 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8ff519)\r\n#26 0x0000751221829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#27 0x0000751221829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#28 0x00000000008f6d6e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8f6d6e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```", "author": "dtcxzyw", "labels": [ "llvm:SLPVectorizer", "crash-on-valid" ], "comments": [] }
true
null
127128
https://github.com/llvm/llvm-project/issues/127128
crash
1ff5f328d9824694cc356ebf78adad8816a6de86
2025-02-13T20:59:01
[ "llvm/test/Transforms/SLPVectorizer" ]
{ "fix_commit": "ac217ee389d63124432e5e6890851a678f7a676b", "components": [ "SLPVectorizer" ], "bug_location_lineno": { "llvm/include/llvm/Analysis/MemorySSAUpdater.h": null, "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [ [ 13206, 13213 ] ], "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/include/llvm/IR/Instruction.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null, "llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/include/llvm/IR/CmpPredicate.h": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanValue.h": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/include/llvm/Analysis/ScalarEvolution.h": null, "llvm/lib/Analysis/VectorUtils.cpp": null }, "bug_location_funcname": { "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [ "BoUpSLP::isGatherShuffledSingleRegisterEntry" ], "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/lib/Analysis/VectorUtils.cpp": null } }
commit ac217ee389d63124432e5e6890851a678f7a676b Author: Alexey Bataev <[email protected]> Date: Thu Feb 13 14:19:51 2025 -0800 [SLP] Check for PHI nodes (potentially cycles!) when checking dependencies When checking for dependecies for gather nodes with users with the same last instruction, cannot rely on the index order, if there is (even potential!) cycle in the graph, which may cause order not work correctly and cause compiler crash. Fixes #127128 diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index fb72a112b9ac..780cafe91d6b 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -13206,8 +13206,16 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry( continue; // If the user instruction is used for some reason in different // vectorized nodes - make it depend on index. + // If any vector node is PHI node, this dependency might not work + // because of cycle dependencies, so disable it. if (TEUseEI.UserTE != UseEI.UserTE && - TEUseEI.UserTE->Idx < UseEI.UserTE->Idx) + (TEUseEI.UserTE->Idx < UseEI.UserTE->Idx || + any_of( + VectorizableTree, + [](const std::unique_ptr<TreeEntry> &TE) { + return TE->State == TreeEntry::Vectorize && + TE->getOpcode() == Instruction::PHI; + }))) continue; }
[ { "file": "llvm/test/Transforms/SLPVectorizer/X86/delayed-gather-emission.ll", "commands": [ "opt -passes=slp-vectorizer -mtriple=x86_64 -mattr=+avx2 -S < %s" ], "tests": [ { "test_name": "test", "test_body": "define void @test() {\nentry:\n %.pre.pre = load float, ptr poison, align 4\n br label %bb1\n\nbb1: ; preds = %bb2, %entry\n %.pre = phi float [ %.pre.pre, %entry ], [ %i2, %bb2 ]\n %foxtrot.0 = phi float [ undef, %entry ], [ %gulf.0, %bb2 ]\n br label %bb2\n\nbb2: ; preds = %bb2, %bb1\n %i = phi float [ %.pre, %bb1 ], [ %i2, %bb2 ]\n %gulf.0 = phi float [ %foxtrot.0, %bb1 ], [ %div, %bb2 ]\n %div = fdiv float %i, %gulf.0\n %i1 = load float, ptr poison, align 4\n %div1 = fdiv float %gulf.0, %i1\n %mul = fmul float %div, %div1\n tail call void @foo(float %mul)\n %i2 = load float, ptr poison, align 4\n %tobool = fcmp une float %i2, 0.000000e+00\n br i1 %tobool, label %bb1, label %bb2\n}\n\ndeclare void @foo(float)\n", "additional_args": null, "lli_expected_out": null } ] }, { "file": "llvm/test/Transforms/SLPVectorizer/X86/phi-node-with-cycle.ll", "commands": [ "opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -mcpu=haswell < %s" ], "tests": [ { "test_name": "<module>", "test_body": "\ndefine void @test(float %0) {\n;\n %2 = fdiv float 0.000000e+00, 0.000000e+00\n %3 = fdiv float 0.000000e+00, 0.000000e+00\n %4 = fdiv float %0, 0.000000e+00\n br label %5\n\n5:\n %6 = fmul float %4, 0.000000e+00\n %7 = fsub float 0.000000e+00, %6\n %8 = fmul float %3, 0.000000e+00\n %9 = fsub float 0.000000e+00, %8\n br label %11\n\n10:\n br label %11\n\n11:\n %12 = phi float [ %7, %5 ], [ 0.000000e+00, %10 ]\n %13 = phi float [ %9, %5 ], [ 0.000000e+00, %10 ]\n br label %14\n\n14:\n %15 = fmul float %2, 0.000000e+00\n %16 = fsub float %12, %15\n %17 = fmul float %4, 0.000000e+00\n %18 = fsub float %13, %17\n %19 = fadd float %16, %18\n %20 = call float @llvm.fabs.f32(float %19)\n ret void\n}\n", "additional_args": null, "lli_expected_out": null } ] } ]
{ "title": "SLPVectorizer miscompilation", "body": "```llvm\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:10:11:12:13\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine swiftcc { ptr addrspace(10), i8 } @julia__dir2ori_404(float %0) {\n %2 = fdiv float 0.000000e+00, 0.000000e+00\n %3 = fdiv float 0.000000e+00, 0.000000e+00\n %4 = fdiv float %0, 0.000000e+00\n br label %5\n\n5: ; preds = %1\n %6 = fmul float %4, 0.000000e+00\n %7 = fsub float 0.000000e+00, %6\n %8 = fmul float %3, 0.000000e+00\n %9 = fsub float 0.000000e+00, %8\n br label %11\n\n10: ; No predecessors!\n br label %11\n\n11: ; preds = %10, %5\n %12 = phi float [ %7, %5 ], [ 0.000000e+00, %10 ]\n %13 = phi float [ %9, %5 ], [ 0.000000e+00, %10 ]\n br label %14\n\n14: ; preds = %11\n %15 = fmul float %2, 0.000000e+00\n %16 = fsub float %12, %15\n %17 = fmul float %4, 0.000000e+00\n %18 = fsub float %13, %17\n %19 = fadd float %16, %18\n %20 = call float @llvm.fabs.f32(float %19)\n ret { ptr addrspace(10), i8 } zeroinitializer\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.fabs.f32(float) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n```\nproduces \n```\nInstruction does not dominate all uses!\n %4 = insertelement <2 x float> <float poison, float 0.000000e+00>, float %0, i32 0\n %2 = shufflevector <2 x float> %4, <2 x float> <float 0.000000e+00, float poison>, <2 x i32> <i32 2, i32 0>\nLLVM ERROR: Broken module found, compilation aborted!\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer -mcpu=haswell <source>\n1.\tRunning pass \"verify\" on module \"<source>\"\n #0 0x00000000054edec8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x54edec8)\n #1 0x00000000054eb884 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007faaea842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007faaea8969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007faaea842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007faaea8287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x000000000082790d llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0\n #7 0x000000000542b6e8 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x542b6e8)\n #8 0x0000000005329278 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5329278)\n #9 0x000000000095605e llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x95605e)\n#10 0x00000000052e7b50 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x52e7b50)\n#11 0x000000000096174a 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+0x96174a)\n#12 0x0000000000953c7c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x953c7c)\n#13 0x00007faaea829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#14 0x00007faaea829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#15 0x000000000094b555 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x94b555)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```\non 19 and trunk.\nGodbolt: https://godbolt.org/z/qxKP6198T", "author": "Zentrik", "labels": [ "llvm:SLPVectorizer", "crash-on-valid" ], "comments": [ { "author": "Zentrik", "body": "Bisected thanks to manyclangs to 66775f8ccdcc8264ef349518e1c59d96d4227823 (8e2b2c4181506efc5b9321c203dd107bbd63392b seemed to be good) @alexey-bataev" } ] }
true
null
116852
https://github.com/llvm/llvm-project/issues/116852
crash
d8a1c6d72739c99f4b52a84e907b96b685b44c5e
2024-11-19T18:03:10
[ "llvm/test/Transforms/SLPVectorizer" ]
{ "fix_commit": "79682c4d57620e623fb30271cc8003d0c9e14a01", "components": [ "SLPVectorizer" ], "bug_location_lineno": { "llvm/include/llvm/Analysis/MemorySSAUpdater.h": null, "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [ [ 13614, 13620 ] ], "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/include/llvm/IR/Instruction.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null, "llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/include/llvm/IR/CmpPredicate.h": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanValue.h": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/include/llvm/Analysis/ScalarEvolution.h": null, "llvm/lib/Analysis/VectorUtils.cpp": null }, "bug_location_funcname": { "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [ "BoUpSLP::gather" ], "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/lib/Analysis/VectorUtils.cpp": null } }
commit 79682c4d57620e623fb30271cc8003d0c9e14a01 Author: Alexey Bataev <[email protected]> Date: Tue Nov 19 11:03:11 2024 -0800 [SLP]Check if the buildvector root is not a part of the graph before deletion If the buildvector root has no uses, it might be still needed as a part of the graph, so need to check that it is not a part of the graph before deletion. Fixes #116852 diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index dc0dffd9fcbf..e70627b6afc1 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -13614,7 +13614,10 @@ Value *BoUpSLP::gather( } else { Vec = CreateShuffle(Root, Vec, Mask); if (auto *OI = dyn_cast<Instruction>(OriginalRoot); - OI && OI->hasNUses(0)) + OI && OI->hasNUses(0) && + none_of(VectorizableTree, [&](const std::unique_ptr<TreeEntry> &TE) { + return TE->VectorizedValue == OI; + })) eraseInstruction(OI); } }
[ { "file": "llvm/test/Transforms/SLPVectorizer/X86/bv-root-part-of-graph.ll", "commands": [ "opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s" ], "tests": [ { "test_name": "<module>", "test_body": "\ndefine void @test() {\n;\nbb:\n br label %bb1\n\nbb1:\n %phi = phi i32 [ 0, %bb ], [ %or21, %bb1 ]\n %sitofp = sitofp i32 0 to float\n %fadd = fadd float %sitofp, %sitofp\n %fadd2 = fadd float %fadd, 0.000000e+00\n %fcmp = fcmp ogt float %fadd2, 0.000000e+00\n %select = select i1 %fcmp, i32 0, i32 0\n %select3 = select i1 false, i32 %select, i32 0\n %fadd4 = fadd float %sitofp, 0.000000e+00\n %fadd5 = fadd float %fadd4, 0.000000e+00\n %fcmp6 = fcmp ogt float %fadd5, 0.000000e+00\n %select7 = select i1 %fcmp6, i32 0, i32 0\n %select8 = select i1 false, i32 %select7, i32 0\n %or = or i32 %select3, %select8\n %sitofp9 = sitofp i32 0 to float\n %fmul = fmul float 0.000000e+00, 0.000000e+00\n %fadd10 = fadd float %sitofp9, %fmul\n %fadd11 = fadd float %fadd10, 0.000000e+00\n %fcmp12 = fcmp ogt float %fadd11, 0.000000e+00\n %select13 = select i1 %fcmp12, i32 0, i32 0\n %select14 = select i1 false, i32 %select13, i32 0\n %or15 = or i32 %select14, %or\n %fadd16 = fadd float %fmul, 0.000000e+00\n %fadd17 = fadd float %fadd16, 0.000000e+00\n %fcmp18 = fcmp ogt float %fadd17, 0.000000e+00\n %select19 = select i1 %fcmp18, i32 0, i32 0\n %select20 = select i1 false, i32 %select19, i32 0\n %or21 = or i32 %or15, %select20\n br label %bb1\n}", "additional_args": null, "lli_expected_out": null } ] } ]
{ "title": "Assertion `I->use_empty() && \"trying to erase instruction with users.\"' failed.", "body": "To reproduce run the test below with -passes=slp-vectorizer\r\n```\r\n; ModuleID = './reduced.ll'\r\nsource_filename = \"./reduced.ll\"\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine void @wombat() gc \"statepoint-example\" {\r\nbb:\r\n br label %bb1\r\n\r\nbb1: ; preds = %bb1, %bb\r\n %phi = phi i32 [ 0, %bb ], [ %or21, %bb1 ]\r\n %sitofp = sitofp i32 0 to float\r\n %fadd = fadd float %sitofp, %sitofp\r\n %fadd2 = fadd float %fadd, 0.000000e+00\r\n %fcmp = fcmp ogt float %fadd2, 0.000000e+00\r\n %select = select i1 %fcmp, i32 0, i32 0\r\n %select3 = select i1 false, i32 %select, i32 0\r\n %fadd4 = fadd float %sitofp, 0.000000e+00\r\n %fadd5 = fadd float %fadd4, 0.000000e+00\r\n %fcmp6 = fcmp ogt float %fadd5, 0.000000e+00\r\n %select7 = select i1 %fcmp6, i32 0, i32 0\r\n %select8 = select i1 false, i32 %select7, i32 0\r\n %or = or i32 %select3, %select8\r\n %sitofp9 = sitofp i32 0 to float\r\n %fmul = fmul float 0.000000e+00, 0.000000e+00\r\n %fadd10 = fadd float %sitofp9, %fmul\r\n %fadd11 = fadd float %fadd10, 0.000000e+00\r\n %fcmp12 = fcmp ogt float %fadd11, 0.000000e+00\r\n %select13 = select i1 %fcmp12, i32 0, i32 0\r\n %select14 = select i1 false, i32 %select13, i32 0\r\n %or15 = or i32 %select14, %or\r\n %fadd16 = fadd float %fmul, 0.000000e+00\r\n %fadd17 = fadd float %fadd16, 0.000000e+00\r\n %fcmp18 = fcmp ogt float %fadd17, 0.000000e+00\r\n %select19 = select i1 %fcmp18, i32 0, i32 0\r\n %select20 = select i1 false, i32 %select19, i32 0\r\n %or21 = or i32 %or15, %select20\r\n br label %bb1\r\n}\r\n```\r\nReproducer: https://godbolt.org/z/T8j1xEoKM\r\nStack dump:\r\n```\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer <source>\r\n1.\tRunning pass \"function(slp-vectorizer)\" on module \"<source>\"\r\n2.\tRunning pass \"slp-vectorizer\" on function \"wombat\"\r\n #0 0x0000000005194b38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5194b38)\r\n #1 0x000000000519252c SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007eacdf842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x00007eacdf8969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x00007eacdf842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x00007eacdf8287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00007eacdf82871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x00007eacdf839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x000000000419bb4f (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x419bb4f)\r\n #9 0x000000000425f0bf llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\r\n#10 0x000000000425fa7b llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x425fa7b)\r\n#11 0x0000000002fbe41e llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2fbe41e)\r\n#12 0x0000000004f949e8 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f949e8)\r\n#13 0x0000000000e4027e 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+0xe4027e)\r\n#14 0x0000000004f9340e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f9340e)\r\n#15 0x0000000000e3f92e 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+0xe3f92e)\r\n#16 0x0000000004f92e40 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f92e40)\r\n#17 0x0000000000909fda 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+0x909fda)\r\n#18 0x00000000008fc70a optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8fc70a)\r\n#19 0x00007eacdf829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#20 0x00007eacdf829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#21 0x00000000008f3e9e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8f3e9e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```\r\n", "author": "TatyanaDoubts", "labels": [ "llvm:SLPVectorizer", "crash" ], "comments": [] }
true
null
99411
https://github.com/llvm/llvm-project/issues/99411
crash
cb3de24b5c0a662ba4a03c6c06a2d765d558bf62
2024-07-18T00:03:03
[ "llvm/test/Transforms/SLPVectorizer" ]
{ "fix_commit": "b634e057ddecc41dce046887d0f0854fed305374", "components": [ "SLPVectorizer" ], "bug_location_lineno": { "llvm/include/llvm/Analysis/MemorySSAUpdater.h": null, "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [ [ 11852, 11859 ] ], "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/include/llvm/IR/Instruction.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null, "llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/include/llvm/IR/CmpPredicate.h": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanValue.h": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/include/llvm/Analysis/ScalarEvolution.h": null, "llvm/lib/Analysis/VectorUtils.cpp": null }, "bug_location_funcname": { "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [ "castToScalarTyElem" ], "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/lib/Analysis/VectorUtils.cpp": null } }
commit b634e057ddecc41dce046887d0f0854fed305374 Author: Han-Kuan Chen <[email protected]> Date: Thu Jul 18 19:54:46 2024 +0800 [SLP][REVEC] Fix false assumption of the source for castToScalarTyElem. (#99424) The argument V may come from adjustExtracts, which is the vector operand of ExtractElementInst. In addition, it is not existed in getTreeEntry. The vector operand of ExtractElementInst may have a type of <1 x Ty>, ensuring that the number of elements in ScalarTy and VecTy are equal. reference: https://github.com/llvm/llvm-project/issues/99411 diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index d88c6307b994..b994645cece6 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -11852,8 +11852,7 @@ class BoUpSLP::ShuffleInstructionBuilder final : public BaseShuffleAnalysis { Value *castToScalarTyElem(Value *V, std::optional<bool> IsSigned = std::nullopt) { auto *VecTy = cast<VectorType>(V->getType()); - assert(getNumElements(ScalarTy) < getNumElements(VecTy) && - (getNumElements(VecTy) % getNumElements(ScalarTy) == 0)); + assert(getNumElements(VecTy) % getNumElements(ScalarTy) == 0); if (VecTy->getElementType() == ScalarTy->getScalarType()) return V; return Builder.CreateIntCast(
[ { "file": "llvm/test/Transforms/SLPVectorizer/revec-fix-99411.ll", "commands": [ "opt -mtriple x86_64-unknown-linux-gnu -passes=slp-vectorizer -S %s" ], "tests": [ { "test_name": "<module>", "test_body": "\ndefine void @e() {\n;\nentry:\n %0 = extractelement <1 x i64> zeroinitializer, i64 0\n %bf.value = and i64 %0, 0\n %bf.set = or i64 0, %bf.value\n store i64 %bf.set, ptr getelementptr inbounds (i8, ptr null, i64 8), align 8\n %bf.value2 = and i64 0, 0\n %bf.set4 = or i64 0, %bf.value2\n store i64 %bf.set4, ptr null, align 8\n ret void\n}", "additional_args": null, "lli_expected_out": null } ] } ]
{ "title": "A/F: `getNumElements(ScalarTy) < getNumElements(VecTy) && (getNumElements(VecTy) % getNumElements(ScalarTy) == 0)' failed after 1813ffd", "body": "Several of our internal tests started hitting an assertion failure while building, one of which I bisected back to commit 1813ffd. Consider the following code:\r\n```c++\r\ntypedef long long __m64 __attribute__((__vector_size__(8), __aligned__(8)));\r\nstatic __inline__ long long foo(__m64 m) { return (long long) m; }\r\nstruct c {\r\n long a : 43;\r\n long b : 61;\r\n} d;\r\nvoid e() {\r\n volatile __m64 f;\r\n long g, i = d.b = g = foo(f);\r\n d.a = i;\r\n}\r\n```\r\nWhen compiled with optimizations with a compiler that includes 1813ffd, it hits an assertion failure:\r\n```\r\n$ ~/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang -c -O2 repro.cpp \r\nclang: /home/dyung/src/upstream/llvm_clean_git/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:11853: llvm::Value* llvm::slpvectorizer::BoUpSLP::ShuffleInstructionBuilder::castToScalarTyElem(llvm::Value*, std::optional<bool>): Assertion `getNumElements(ScalarTy) < getNumElements(VecTy) && (getNumElements(VecTy) % getNumElements(ScalarTy) == 0)' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0. Program arguments: /home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang -c -O2 repro.cpp\r\n1. <eof> parser at end of file\r\n2. Optimizer\r\n3. Running pass \"function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>)\" on module \"repro.cpp\" \r\n4. Running pass \"slp-vectorizer\" on function \"_Z7test119v\"\r\n #0 0x00005650f775179f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x41a279f) \r\n #1 0x00005650f774f2fc llvm::sys::CleanupOnSignal(unsigned long) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x41a02fc) \r\n #2 0x00005650f76947e8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0 \r\n #3 0x00007ff89a3f9420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420) \r\n #4 0x00007ff899ec600b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1 \r\n #5 0x00007ff899ea5859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7 \r\n #6 0x00007ff899ea5729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8 \r\n #7 0x00007ff899ea5729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34 \r\n #8 0x00007ff899eb6fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6) \r\n #9 0x00005650f903005c llvm::slpvectorizer::BoUpSLP::ShuffleInstructionBuilder::castToScalarTyElem(llvm::Value*, std::optional<bool>) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5a8105c)\r\n#10 0x00005650f9071f00 llvm::slpvectorizer::BoUpSLP::ShuffleInstructionBuilder::adjustExtracts(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::MutableArrayRef<int>, llvm::ArrayRef<std::optional<llvm::TargetTransformInfo::ShuffleKind>>, unsigned int, bool&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5ac2f00) \r\n#11 0x00005650f909dfdd llvm::Value* llvm::slpvectorizer::BoUpSLP::processBuildVector<llvm::slpvectorizer::BoUpSLP::ShuffleInstructionBuilder, llvm::Value*, llvm::IRBuilder<llvm::TargetFolder, llvm::IRBuilderDefaultInserter>, llvm::slpvectorizer::BoUpSLP>(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::Type*, llvm::IRBuilder<llvm::TargetFolder, llvm::IRBuilderDefaultInserter>&, llvm::slpvectorizer::BoUpSLP&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5aeefdd)\r\n#12 0x00005650f90a941a llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5afa41a)\r\n#13 0x00005650f90a80e3 llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5af90e3)\r\n#14 0x00005650f90a9484 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5afa484)\r\n#15 0x00005650f90a7cdf llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5af8cdf)\r\n#16 0x00005650f90ac099 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5afd099)\r\n#17 0x00005650f90a7cdf llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5af8cdf)\r\n#18 0x00005650f90a9e6c llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5afae6c)\r\n#19 0x00005650f90c7263 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::MapVector<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>, llvm::DenseMap<llvm::Value*, unsigned int, llvm::DenseMapInfo<llvm::Value*, void>, llvm::detail::DenseMapPair<llvm::Value*, unsigned int>>, llvm::SmallVector<std::pair<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>>, 0u>> const&, llvm::SmallVectorImpl<std::pair<llvm::Value*, llvm::Value*>>&, llvm::Instruction*) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5b18263)\r\n#20 0x00005650f90cacbc llvm::slpvectorizer::BoUpSLP::vectorizeTree() (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5b1bcbc)\r\n#21 0x00005650f90e045b llvm::SLPVectorizerPass::vectorizeStoreChain(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, unsigned int, unsigned int, unsigned int&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5b3145b) \r\n#22 0x00005650f90e1a5e llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&)::'lambda'(std::set<std::pair<unsigned int, int>, llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&)::StoreDistCompare, std::allocator<std::pair<unsigned int, int>>> const&)::operator()(std::set<std::pair<unsigned int, int>, llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&)::StoreDistCompare, std::allocator<std::pair<unsigned int, int>>> const&) const SLPVectorizer.cpp:0:0\r\n#23 0x00005650f90e39a0 llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5b349a0)\r\n#24 0x00005650f90e42c3 llvm::SLPVectorizerPass::vectorizeStoreChains(llvm::slpvectorizer::BoUpSLP&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5b352c3)\r\n#25 0x00005650f90e57dd llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\r\n#26 0x00005650f90e6253 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5b37253)\r\n#27 0x00005650f8baedb6 llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x55ffdb6)\r\n#28 0x00005650f70f6421 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x3b47421)\r\n#29 0x00005650f4cb9ca6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x170aca6)\r\n#30 0x00005650f70f4ded llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x3b45ded)\r\n#31 0x00005650f4cbac56 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x170bc56)\r\n#32 0x00005650f70f2f31 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x3b43f31)\r\n#33 0x00005650f7a062c8 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#34 0x00005650f7a09645 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#35 0x00005650f7a09ce6 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x445ace6)\r\n#36 0x00005650f808091c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x4ad191c)\r\n#37 0x00005650f9e7fe6c clang::ParseAST(clang::Sema&, bool, bool) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x68d0e6c)\r\n#38 0x00005650f8080d28 clang::CodeGenAction::ExecuteAction() (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x4ad1d28)\r\n#39 0x00005650f8318339 clang::FrontendAction::Execute() (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x4d69339)\r\n#40 0x00005650f829a98e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x4ceb98e)\r\n#41 0x00005650f8403dc6 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x4e54dc6)\r\n#42 0x00005650f489f105 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x12f0105)\r\n#43 0x00005650f489811a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#44 0x00005650f80c610d void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0\r\n#45 0x00005650f7694cf0 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x40e5cf0)\r\n#46 0x00005650f80c672f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0\r\n#47 0x00005650f808aa6c clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x4adba6c)\r\n#48 0x00005650f808b4fd clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x4adc4fd)\r\n#49 0x00005650f80935d5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x4ae45d5)\r\n#50 0x00005650f489c37b clang_main(int, char**, llvm::ToolContext const&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x12ed37b)\r\n#51 0x00005650f478ee1b main (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x11dfe1b)\r\n#52 0x00007ff899ea7083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#53 0x00005650f4897bae _start (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x12e8bae)\r\nclang: error: clang frontend command failed with exit code 134 (use -v to see invocation)\r\nclang version 19.0.0 (https://github.com/llvm/llvm-project.git 1813ffd6b2eb04ee2c296a4399a18748740a439d)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin\r\nBuild config: +assertions\r\n```\r\nIf built using the a compiler built from fa0e529 (the parent commit of 1813ffd), the compilation succeeds:\r\n```\r\n$ ~/src/upstream/fa0e52995929ab67dfb468d71fe793be5e1c7f03-linux/bin/clang -c -O2 repro.cpp\r\n$\r\n```\r\n", "author": "dyung", "labels": [ "llvm:SLPVectorizer", "crash" ], "comments": [ { "author": "madhur13490", "body": "@dyung https://godbolt.org/z/ofneqo6zK I don't see here. Am I missing anything?" }, { "author": "dyung", "body": "> @dyung https://godbolt.org/z/ofneqo6zK I don't see here. Am I missing anything?\r\n\r\nI don't know if it reproduces on an ARM targeting compiler, I used an x86-64 targeting x86-64 compiler. Also the compiler currently used by godbolt was built from commit f56cdd4a45b7bbe84be5d4ba9442eb7071605efc which does not include 1813ffd6b2eb04ee2c296a4399a18748740a439d which introduced the issue." }, { "author": "HanKuanChen", "body": "Close the issue since https://github.com/llvm/llvm-project/commit/b634e057ddecc41dce046887d0f0854fed305374 is merged." } ] }
true
null
97053
https://github.com/llvm/llvm-project/issues/97053
miscompilation
a3571376ad9555de07e4d8f74f92de1eaa4c486e
2024-06-28T12:58:31
[ "llvm/test/Transforms/InstCombine" ]
{ "fix_commit": "4d2ae88d1617a910ec3a1436ce53579523ac2f97", "components": [ "InstCombine" ], "bug_location_lineno": { "llvm/include/llvm/Analysis/MemorySSAUpdater.h": null, "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/include/llvm/IR/Instruction.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": [ [ 419, 424 ], [ 426, 431 ], [ 471, 478 ] ], "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null, "llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/include/llvm/IR/CmpPredicate.h": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanValue.h": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/include/llvm/Analysis/ScalarEvolution.h": null, "llvm/lib/Analysis/VectorUtils.cpp": null }, "bug_location_funcname": { "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": [ "InstCombinerImpl::visitExtractElementInst" ], "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/lib/Analysis/VectorUtils.cpp": null } }
commit 4d2ae88d1617a910ec3a1436ce53579523ac2f97 Author: Nikita Popov <[email protected]> Date: Wed Jul 3 10:58:38 2024 +0200 [InstCombine] Fix invalid scalarization of div If the binop is not speculatable, and the extract index is out of range, then scalarizing will perform the operation on a poison operand, resulting in immediate UB, instead of the previous poison result. Fixes https://github.com/llvm/llvm-project/issues/97053. diff --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp index 3de56a403803..753ed55523c8 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp @@ -419,6 +419,7 @@ Instruction *InstCombinerImpl::visitExtractElementInst(ExtractElementInst &EI) { // If extracting a specified index from the vector, see if we can recursively // find a previously computed scalar that was inserted into the vector. auto *IndexC = dyn_cast<ConstantInt>(Index); + bool HasKnownValidIndex = false; if (IndexC) { // Canonicalize type of constant indices to i64 to simplify CSE if (auto *NewIdx = getPreferredVectorIndex(IndexC)) @@ -426,6 +427,7 @@ Instruction *InstCombinerImpl::visitExtractElementInst(ExtractElementInst &EI) { ElementCount EC = EI.getVectorOperandType()->getElementCount(); unsigned NumElts = EC.getKnownMinValue(); + HasKnownValidIndex = IndexC->getValue().ult(NumElts); if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(SrcVec)) { Intrinsic::ID IID = II->getIntrinsicID(); @@ -471,8 +473,11 @@ Instruction *InstCombinerImpl::visitExtractElementInst(ExtractElementInst &EI) { return UnaryOperator::CreateWithCopiedFlags(UO->getOpcode(), E, UO); } + // If the binop is not speculatable, we cannot hoist the extractelement if + // it may make the operand poison. BinaryOperator *BO; - if (match(SrcVec, m_BinOp(BO)) && cheapToScalarize(SrcVec, Index)) { + if (match(SrcVec, m_BinOp(BO)) && cheapToScalarize(SrcVec, Index) && + (HasKnownValidIndex || isSafeToSpeculativelyExecute(BO))) { // extelt (binop X, Y), Index --> binop (extelt X, Index), (extelt Y, Index) Value *X = BO->getOperand(0), *Y = BO->getOperand(1); Value *E0 = Builder.CreateExtractElement(X, Index);
[ { "file": "llvm/test/Transforms/InstCombine/scalarization.ll", "commands": [ "opt -passes=instcombine -S < %s" ], "tests": [ { "test_name": "extract_element_binop_splat_variable_index_may_trap", "test_body": "define i8 @extract_element_binop_splat_variable_index_may_trap(<4 x i8> %x, <4 x i8> %y, i32 %z) {\n %b = sdiv <4 x i8> splat (i8 42), %y\n %r = extractelement <4 x i8> %b, i32 %z\n ret i8 %r\n}\n", "additional_args": null, "lli_expected_out": null }, { "test_name": "extract_element_binop_splat_variable_index", "test_body": "define i8 @extract_element_binop_splat_variable_index(<4 x i8> %x, i32 %y) {\n %b = sdiv <4 x i8> %x, splat (i8 42)\n %r = extractelement <4 x i8> %b, i32 %y\n ret i8 %r\n}\n", "additional_args": null, "lli_expected_out": null } ] } ]
{ "title": "Wrong swap between `sdiv` and `extractelement` by InstCombine", "body": "https://alive2.llvm.org/ce/z/mGNeLx\r\n\r\n\r\n```ll\r\n----------------------------------------\r\ndefine i8 @fun0(<4 x i8> %val0, i32 %val1) {\r\n#0:\r\n %val2 = sdiv <4 x i8> { 42, 42, 42, 42 }, %val0\r\n %val3 = extractelement <4 x i8> %val2, i32 %val1\r\n ret i8 %val3\r\n}\r\n=>\r\ndefine i8 @fun0(<4 x i8> %val0, i32 %val1) {\r\n#0:\r\n %#1 = extractelement <4 x i8> %val0, i32 %val1\r\n %val3 = sdiv i8 42, %#1\r\n ret i8 %val3\r\n}\r\nTransformation doesn't verify!\r\n\r\nERROR: Source is more defined than target\r\n\r\nExample:\r\n<4 x i8> %val0 = < #x01 (1), #x08 (8), #x02 (2), #x04 (4) >\r\ni32 %val1 = #x20000000 (536870912)\r\n\r\nSource:\r\n<4 x i8> %val2 = < #x2a (42), #x05 (5), #x15 (21), #x0a (10) >\r\ni8 %val3 = poison\r\n\r\nTarget:\r\ni8 %#1 = poison\r\ni8 %val3 = UB triggered!\r\n\r\n\r\nSummary:\r\n 0 correct transformations\r\n 1 incorrect transformations\r\n 0 failed-to-prove transformations\r\n 0 Alive2 errors\r\n```\r\n\r\n\r\n`sdiv` and `extractelement` cannot be swapped for vector operands as it can trigger UB, diving an integer by `poison`.", "author": "bongjunj", "labels": [ "miscompilation", "llvm:instcombine" ], "comments": [] }
true
null
98143
https://github.com/llvm/llvm-project/issues/98143
crash
f4be6812e203690073280b9ac8d60092d75bbdce
2024-07-09T10:43:20
[ "llvm/test/Instrumentation/NumericalStabilitySanitizer" ]
{ "fix_commit": "70a9535f714e2fdb84af243a1a316012c8019049", "components": [ "Instrumentation" ], "bug_location_lineno": { "llvm/include/llvm/Analysis/MemorySSAUpdater.h": null, "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/include/llvm/IR/Instruction.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null, "llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/include/llvm/IR/CmpPredicate.h": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": [ [ 1725, 1730 ] ], "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanValue.h": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/include/llvm/Analysis/ScalarEvolution.h": null, "llvm/lib/Analysis/VectorUtils.cpp": null }, "bug_location_funcname": { "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": [ "NumericalStabilitySanitizer::createShadowValueWithOperandsAvailable" ], "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/lib/Analysis/VectorUtils.cpp": null } }
commit 70a9535f714e2fdb84af243a1a316012c8019049 Author: Alexander Shaposhnikov <[email protected]> Date: Thu Jul 25 21:34:08 2024 -0700 [Instrumentation][nsan] Add support for Freeze instruction (#100490) Add support for Freeze. This fixes https://github.com/llvm/llvm-project/issues/98143 . diff --git a/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp index b382fedde027..832506f639a7 100644 --- a/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp @@ -1725,6 +1725,9 @@ Value *NumericalStabilitySanitizer::createShadowValueWithOperandsAvailable( Map.getShadow(S->getTrueValue()), Map.getShadow(S->getFalseValue())); + if (auto *Freeze = dyn_cast<FreezeInst>(&Inst)) + return Builder.CreateFreeze(Map.getShadow(Freeze->getOperand(0))); + if (auto *Extract = dyn_cast<ExtractElementInst>(&Inst)) return Builder.CreateExtractElement( Map.getShadow(Extract->getVectorOperand()), Extract->getIndexOperand());
[ { "file": "llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll", "commands": [ "opt -passes=nsan -nsan-shadow-type-mapping=dqq -nsan-truncate-fcmp-eq=false -S %s", "opt -passes=nsan -nsan-shadow-type-mapping=dlq -nsan-truncate-fcmp-eq=false -S %s" ], "tests": [ { "test_name": "freeze_vector_insert", "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\n; Function Attrs: sanitize_numerical_stability\ndefine void @freeze_vector_insert(<2 x float> %vec, i32 %idx, float %scalar) #0 {\nentry:\n %0 = insertelement <2 x float> %vec, float %scalar, i32 %idx\n %frozen = freeze <2 x float> %0\n ret void\n}\n\nattributes #0 = { sanitize_numerical_stability }\n", "additional_args": null, "lli_expected_out": null }, { "test_name": "vector_shuffle", "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\n; Function Attrs: sanitize_numerical_stability\ndefine void @vector_shuffle(<2 x float> %0) #0 {\nentry:\n %1 = shufflevector <2 x float> %0, <2 x float> splat (float 1.000000e+00), <2 x i32> <i32 1, i32 3>\n ret void\n}\n\nattributes #0 = { sanitize_numerical_stability }\n", "additional_args": null, "lli_expected_out": null } ] } ]
{ "title": "ICE: Unimplemented support for freeze compiling with numerical sanitizer", "body": "```\r\nfatal error: error in backend: Unimplemented support for freeze\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0. Program arguments: /afs/cern.ch/user/i/innocent/w5/bin/clang++ -c -DGNU_GCC -D_GNU_SOURCE -DTBB_USE_GLIBCXX_VERSION=120301 -DTBB_SUPPRESS_DEPRECATED_MESSAGES -DTBB_PREVIEW_RESUMABLE_TASKS=1 -DTBB_PREVIEW_TASK_GROUP_EXTENSIONS=1 -DBOOST_SPIRIT_THREADSAFE -DPHOENIX_THREADSAFE -DBOOST_MATH_DISABLE_STD_FPCLASSIFY -DBOOST_UUID_RANDOM_PROVIDER_FORCE_POSIX -DCMSSW_GIT_HASH=\\\"CMSSW_14_1_CLANG_X_2024-07-07-2300\\\" -DPROJECT_NAME=\\\"CMSSW\\\" -DPROJECT_VERSION=\\\"CMSSW_14_1_CLANG_X_2024-07-07-2300\\\" -Isrc -I/cvmfs/cms-ib.cern.ch/sw/x86_64/week1/el8_amd64_gcc12/cms/cmssw/CMSSW_14_1_CLANG_X_2024-07-07-2300/src -I/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/alpaka/1.1.0-0a6641b4bfdf883c8da5b9e8620be504/include -I/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/pcre/8.43-e34796d17981e9b6d174328c69446455/include -isystem/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/boost/1.80.0-a1544032d9d65904ac2112b6d35bba55/include -I/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/bz2lib/1.0.6-d065ccd79984efc6d4660f410e4c81de/include -isystem/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/clhep/2.4.7.1-8e40efd27b7394c1fa4e9c7e432d85cd/include -I/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/gsl/2.6-5e2ce72ea2977ff21a2344bbb52daf5c/include -isystem/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/hls/2019.08-0e37f055a3ed22611ce5edecb14d0695/include -I/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/libuuid/2.34-27ce4c3579b5b1de2808ea9c4cd8ed29/include -isystem/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/lcg/root/6.30.07-5b5d83179d6ed7bc60aa7a5006899eba/include -isystem/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/tbb/v2021.9.0-1dc6d66b4b014f4ae4733b04914ce7d4/include -I/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/cms/vdt/0.4.3-f094bee80112624813c07f9336e08d7d/include -I/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/xz/5.2.5-6f3f49b07db84e10c9be594a1176c114/include -I/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/zlib/1.2.11-1a082fc322b0051b504cc023f21df178/include -I/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/eigen/3bb6a48d8c171cf20b5f8e48bfb4e424fbd4f79e-3ca740c03e68b1a067f3ed0679234a78/include/eigen3 -I/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/fmt/8.0.1-258b4791803c34b7e98cf43693e54d87/include -I/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/md5/1.0.0-5b594b264e04ae51e893b1d69a797ec6/include -I/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/OpenBLAS/0.3.15-c877ab57fa7b04ce290093588c6c5717/include -I/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/tinyxml2/6.2.0-88fe0ec301baf763fa3c485e5b67ed91/include -O3 -pthread -pipe -Werror=main -Werror=pointer-arith -Werror=overlength-strings -Wno-vla -Werror=overflow -std=c++17 -ftree-vectorize -Werror=array\r\n-bounds -Werror=type-limits -fvisibility-inlines-hidden -fno-math-errno --param vect-max-version-for-alias-checks=50 -Xassembler --compress-debug-sections -Wno-error=array-bounds -Warray-bounds -fuse-ld=bfd -march=x86-\r\n64-v2 -felide-constructors -fmessage-length=0 -Wall -Wno-long-long -Wreturn-type -Wextra -Wpessimizing-move -Wclass-memaccess -Wno-cast-function-type -Wno-unused-but-set-parameter -Wno-ignored-qualifiers -Wno-unused-pa\r\nrameter -Wunused -Wparentheses -Werror=return-type -Werror=missing-braces -Werror=unused-value -Werror=unused-label -Werror=address -Werror=format -Werror=sign-compare -Werror=write-strings -Werror=delete-non-virtual-d\r\ntor -Werror=strict-aliasing -Werror=narrowing -Werror=reorder -Werror=unused-variable -Werror=conversion-null -Wnon-virtual-dtor -Werror=switch -fdiagnostics-show-option -Wno-unused-local-typedefs -Wno-attributes -Wno-\r\npsabi -Wno-c99-extensions -Wno-c++11-narrowing -D__STRICT_ANSI__ -Wno-unused-private-field -Wno-unknown-pragmas -Wno-unused-command-line-argument -Wno-unknown-warning-option -ftemplate-depth=1024 -Wno-error=potentially\r\n-evaluated-expression -Wno-tautological-type-limit-compare -Wno-vla-cxx-extension -fsized-deallocation --gcc-toolchain=/afs/cern.ch/work/i/innocent/public/w5 -Ofast -fno-reciprocal-math -mrecip=none -DEIGEN_DONT_PARALL\r\nELIZE -DEIGEN_MAX_ALIGN_BYTES=64 -Wno-error=unused-variable -DALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT=128 -DALPAKA_DISABLE_VENDOR_RNG -DBOOST_DISABLE_ASSERTS -g -fsanitize=numerical -fPIC -MMD -MF tmp/el8_amd64_gcc12/src/\r\nTrackingTools/TrajectoryState/src/TrackingToolsTrajectoryState/BasicTrajectoryState.cc.d src/TrackingTools/TrajectoryState/src/BasicTrajectoryState.cc -o tmp/el8_amd64_gcc12/src/TrackingTools/TrajectoryState/src/Tracki\r\nngToolsTrajectoryState/BasicTrajectoryState.cc.o\r\n1. <eof> parser at end of file\r\n2. Optimizer\r\n3. Running pass \"nsan\" on module \"src/TrackingTools/TrajectoryState/src/BasicTrajectoryState.cc\"\r\n #0 0x000000000389df7b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x389df7b)\r\n #1 0x000000000389bd04 llvm::sys::CleanupOnSignal(unsigned long) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x389bd04)\r\n #2 0x00000000037dc354 llvm::CrashRecoveryContext::HandleExit(int) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x37dc354)\r\n #3 0x0000000003892523 llvm::sys::Process::Exit(int, bool) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x3892523)\r\n #4 0x0000000000be52a7 (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0xbe52a7)\r\n #5 0x00000000037e7dea llvm::report_fatal_error(llvm::Twine const&, bool) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x37e7dea)\r\n #6 0x0000000004fbbf2c (anonymous namespace)::NumericalStabilitySanitizer::createShadowValueWithOperandsAvailable(llvm::Instruction&, llvm::TargetLibraryInfo const&, (anonymous namespace)::ValueToShadowMap const&) Nume\r\nricalStabilitySanitizer.cpp:0:0\r\n #7 0x0000000004fbcd55 llvm::NumericalStabilitySanitizerPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x4fbcd55)\r\n #8 0x0000000003b38ac2 llvm::detail::PassModel<llvm::Module, llvm::NumericalStabilitySanitizerPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/afs/cern.ch/user/i/in\r\nnocent/w5/bin/clang+++0x3b38ac2)\r\n #9 0x0000000003229bad llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x3229bad)\r\n#10 0x0000000003b46c3e (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<l\r\nlvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#11 0x0000000003b4a1ef (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) Back\r\nendUtil.cpp:0:0\r\n#12 0x0000000003b4acc1 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm:\r\n:Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/afs/cern.ch/user/i/inn\r\nocent/w5/bin/clang+++0x3b4acc1)\r\n#13 0x0000000004168f3b clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x4168f3b)\r\n#14 0x0000000005bd82cc clang::ParseAST(clang::Sema&, bool, bool) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x5bd82cc)\r\n#15 0x0000000004430459 clang::FrontendAction::Execute() (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x4430459)\r\n#16 0x00000000043b1c9b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x43b1c9b)\r\n#17 0x0000000004500ae7 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x4500ae7)\r\n#18 0x0000000000be70c4 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0xbe70c4)\r\n#19 0x0000000000be0aac ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#20 0x00000000041b6519 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allo\r\ncator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0\r\n#21 0x00000000037dc253 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x37dc253)\r\n#22 0x00000000041b6d16 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:\r\n0:0\r\n#23 0x000000000417b1db clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x417b1db)\r\n#24 0x000000000417bbee clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/afs/cern.ch/user/i/innocent/w5/bin/clan\r\ng+++0x417bbee)\r\n#25 0x000000000418e11c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x418e11\r\nc)\r\n#26 0x0000000000be40ae clang_main(int, char**, llvm::ToolContext const&) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0xbe40ae)\r\n#27 0x0000000000aad1af main (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0xaad1af)\r\n#28 0x00007f2127913d85 __libc_start_main (/usr/lib64/libc.so.6+0x3ad85)\r\n#29 0x0000000000be04fe _start (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0xbe04fe)\r\nclang++: error: clang frontend command failed with exit code 70 (use -v to see invocation)\r\nclang version 19.0.0git ([email protected]:llvm/llvm-project.git 857700ff6fb9f9f653c3788445df06db07e7bb59)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /afs/cern.ch/work/i/innocent/public/w5/bin\r\nclang++: note: diagnostic msg:\r\n********************\r\n\r\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\r\nPreprocessed source(s) and associated run script(s) are located at:\r\nclang++: note: diagnostic msg: tmp/el8_amd64_gcc12/src/TrackingTools/TrajectoryState/src/TrackingToolsTrajectoryState/BasicTrajectoryState-33393f.cpp\r\nclang++: note: diagnostic msg: tmp/el8_amd64_gcc12/src/TrackingTools/TrajectoryState/src/TrackingToolsTrajectoryState/BasicTrajectoryState-33393f.sh\r\nclang++: note: diagnostic msg:\r\n```\r\n[nsanCrash.tgz](https://github.com/user-attachments/files/16142152/nsanCrash.tgz)\r\n", "author": "VinInn", "labels": [ "crash-on-valid", "compiler-rt:nsan" ], "comments": [ { "author": "dtcxzyw", "body": "cc @alexander-shaposhnikov " }, { "author": "VinInn", "body": "compilation is stiill failing with\r\n```clang version 20.0.0git ([email protected]:llvm/llvm-project.git ba8126b6fef79bd344a247f6291aaec7b67bdff0)```\r\nwith the same error message \"fatal error: error in backend: Unimplemented support for freeze\"\r\n" } ] }
true
null
131281
https://github.com/llvm/llvm-project/issues/131281
crash
887cf1f8cea240cd50fb80bc9487b22f67d74263
2025-03-14T05:50:22
[ "llvm/test/Transforms/LoopVectorize" ]
{ "fix_commit": "166937b49dac0919fae362c0deecb723b03be764", "components": [ "LoopVectorize" ], "bug_location_lineno": { "llvm/include/llvm/Analysis/MemorySSAUpdater.h": null, "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [ [ 1912, 1917 ] ], "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/include/llvm/IR/Instruction.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null, "llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/include/llvm/IR/CmpPredicate.h": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanValue.h": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/include/llvm/Analysis/ScalarEvolution.h": null, "llvm/lib/Analysis/VectorUtils.cpp": null }, "bug_location_funcname": { "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [ "create" ], "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/lib/Analysis/VectorUtils.cpp": null } }
commit 166937b49dac0919fae362c0deecb723b03be764 Author: Florian Hahn <[email protected]> Date: Mon Mar 17 18:41:34 2025 +0000 [LV] Cleanup after expanding SCEV predicate to constant. In some cases, SCEV isn't able to prove that no wrap checks are needed, while constant folding in SCEVExpander can. In those cases, we may leave around IR for computing the trip count, which is unused at this point but may be re-used later, triggering an assertion when trying to clean up SCEVExp after vectorization. Directly run the cleaner after expanding to a constant predicate to prevent any generated code from being re-used. Fixes https://github.com/llvm/llvm-project/issues/131281. diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 0e38ccc565ea..cbfccaab01e2 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -1912,6 +1912,12 @@ public: SCEVCheckCond = SCEVExp.expandCodeForPredicate( &UnionPred, SCEVCheckBlock->getTerminator()); + if (isa<Constant>(SCEVCheckCond)) { + // Clean up directly after expanding the predicate to a constant, to + // avoid further expansions re-using anything left over from SCEVExp. + SCEVExpanderCleaner SCEVCleaner(SCEVExp); + SCEVCleaner.cleanup(); + } } const auto &RtPtrChecking = *LAI.getRuntimePointerChecking();
[ { "file": "llvm/test/Transforms/LoopVectorize/scev-predicate-reasoning.ll", "commands": [ "opt -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -lv-strided-pointer-ivs=true -S %s" ], "tests": [ { "test_name": "no_signed_wrap_iv_via_btc", "test_body": "declare i1 @cond()\n\n; Function Attrs: mustprogress\ndefine void @no_signed_wrap_iv_via_btc(ptr %dst, i32 %N) #0 {\nentry:\n %sub = add i32 %N, -100\n %sub4 = add i32 %N, -99\n br label %outer\n\nouter: ; preds = %loop, %entry\n %c = call i1 @cond()\n br i1 %c, label %loop, label %exit\n\nloop: ; preds = %loop, %outer\n %iv = phi i32 [ 0, %outer ], [ %inc, %loop ]\n %add2 = add i32 %sub4, %iv\n %add.ext = sext i32 %add2 to i64\n %gep.dst = getelementptr i32, ptr %dst, i64 %add.ext\n store i32 0, ptr %gep.dst, align 4\n %inc = add i32 %iv, 1\n %add = add i32 %sub, %inc\n %ec = icmp sgt i32 %add, %N\n br i1 %ec, label %outer, label %loop\n\nexit: ; preds = %outer\n ret void\n}\n\nattributes #0 = { mustprogress }\n", "additional_args": null, "lli_expected_out": null } ] } ]
{ "title": "[clang] Crash at -O2: Assertion `all_of(I->users()... \"during expansion\"' failed.", "body": "This code crashes at `-O2`:\n\n```c\nint a, b, c, d;\nvoid e() {\n int *f = 0;\n for (;;)\n for (; c - 100 + d <= b; d++) {\n f[d + a] = 1;\n a = 1 + c - 100;\n }\n}\nvoid main() {}\n```\n\nCompiler Explorer: https://godbolt.org/z/P3f6ef98P\n\nBisected to https://github.com/llvm/llvm-project/commit/ddffb74afd870d284ba07f1cf6c67117a8ab8b33, which was committed by @artagnon \n\nCrash:\n\n```console\nclang: /root/llvm-project/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp:2402: void llvm::SCEVExpanderCleaner::cleanup(): Assertion `all_of(I->users(), [&InsertedSet](Value *U) { return InsertedSet.contains(cast<Instruction>(U)); }) && \"removed instruction should only be used by instructions inserted \" \"during expansion\"' failed.\n```\n\nBacktrace:\n\n```c\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O2 -Wall -Wextra <source>\n1.\t<eof> parser at end of file\n2.\tOptimizer\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"<source>\"\n4.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"e\"\n #0 0x0000000003e7dc08 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e7dc08)\n #1 0x0000000003e7b8c4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e7b8c4)\n #2 0x0000000003dc0618 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0\n #3 0x00007507d4042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #4 0x00007507d40969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #5 0x00007507d4042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #6 0x00007507d40287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #7 0x00007507d402871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #8 0x00007507d4039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #9 0x0000000003fea367 llvm::SCEVExpanderCleaner::cleanup() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fea367)\n#10 0x000000000597bc1f (anonymous namespace)::GeneratedRTChecks::~GeneratedRTChecks() LoopVectorize.cpp:0:0\n#11 0x00000000059d28c8 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x59d28c8)\n#12 0x00000000059d4e29 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x59d4e29)\n#13 0x00000000059d54a3 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x59d54a3)\n#14 0x00000000055481fe 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/clang+0x55481fe)\n#15 0x000000000381c880 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x381c880)\n#16 0x00000000011a852e 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/clang+0x11a852e)\n#17 0x000000000381b19b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x381b19b)\n#18 0x00000000011a764e 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/clang+0x11a764e)\n#19 0x000000000381aba0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x381aba0)\n#20 0x000000000412e684 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\n#21 0x0000000004132031 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4132031)\n#22 0x0000000004837120 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4837120)\n#23 0x000000000643be7c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x643be7c)\n#24 0x0000000004837528 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4837528)\n#25 0x0000000004b00005 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4b00005)\n#26 0x0000000004a8398e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4a8398e)\n#27 0x0000000004bedf9e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4bedf9e)\n#28 0x0000000000d5391f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd5391f)\n#29 0x0000000000d4b2da ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#30 0x000000000487fa49 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0\n#31 0x0000000003dc0ac4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dc0ac4)\n#32 0x000000000488003f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0\n#33 0x00000000048426fd clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x48426fd)\n#34 0x000000000484377e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x484377e)\n#35 0x000000000484b695 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x484b695)\n#36 0x0000000000d5076c clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd5076c)\n#37 0x0000000000c17ff4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc17ff4)\n#38 0x00007507d4029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#39 0x00007507d4029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#40 0x0000000000d4ad85 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd4ad85)\n```", "author": "cardigan1008", "labels": [ "vectorizers", "crash-on-valid", "generated by fuzzer" ], "comments": [ { "author": "artagnon", "body": "@fhahn Could you kindly look into this? I'm on vacation until the 24th." }, { "author": "dtcxzyw", "body": "Reduced: https://godbolt.org/z/Wbvj9fExo\n```\n; bin/opt -passes=loop-vectorize test.ll -S\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @e(i32 %0) {\nentry:\n %sub = add i32 %0, -100\n %sub4 = add i32 %0, -99\n br label %for.cond\n\nfor.cond: ; preds = %for.body, %entry\n br label %for.body\n\nfor.body: ; preds = %for.body, %for.cond\n %inc510 = phi i32 [ %inc, %for.body ], [ 0, %for.cond ]\n %add2 = add i32 %sub4, %inc510\n %idxprom = sext i32 %add2 to i64\n %arrayidx = getelementptr i32, ptr null, i64 %idxprom\n store i32 0, ptr %arrayidx, align 4\n %inc = add i32 %inc510, 1\n %add = add i32 %sub, %inc\n %cmp.not = icmp sgt i32 %add, %0\n br i1 %cmp.not, label %for.cond, label %for.body, !llvm.loop !0\n}\n\n!0 = distinct !{!0, !1, !2}\n!1 = !{!\"llvm.loop.mustprogress\"}\n!2 = !{!\"llvm.loop.peeled.count\", i32 1}\n\n```" }, { "author": "fhahn", "body": "@artagnon sure, it looks like the underlying issue existed before, but with https://github.com/llvm/llvm-project/commit/ddffb74afd870d284ba07f1cf6c67117a8ab8b33 we now crash.\n\nSCEVExpansion can prove that the AddRec never wraps via constant folding the runtime check, but really SCEV should be able to prove that: https://github.com/llvm/llvm-project/pull/131538" } ] }
true
null
121518
https://github.com/llvm/llvm-project/issues/121518
crash
2a5050aa5ef56b01cf4a8f73e0d0eddd6d9ce2a9
2025-01-02T20:14:01
[ "llvm/test/Transforms/LoopVectorize" ]
{ "fix_commit": "e258bca9505f35e0a22cb213a305eea9b76d11ea", "components": [ "LoopVectorize", "ScalarEvolution" ], "bug_location_lineno": { "llvm/include/llvm/Analysis/MemorySSAUpdater.h": null, "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": [ [ 3404, 3410 ] ], "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/include/llvm/IR/Instruction.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": [ [ 1451, 1457 ] ], "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null, "llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/include/llvm/IR/CmpPredicate.h": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": [ [ 30, 40 ] ], "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanValue.h": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/include/llvm/Analysis/ScalarEvolution.h": null, "llvm/lib/Analysis/VectorUtils.cpp": null }, "bug_location_funcname": { "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": [ "VPExpandSCEVRecipe::execute" ], "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": [ "SCEVExpander::expandCodeFor" ], "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": [ "vputils::getOrCreateVPValueForSCEVExpr" ], "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/lib/Analysis/VectorUtils.cpp": null } }
commit e258bca9505f35e0a22cb213a305eea9b76d11ea Author: Florian Hahn <[email protected]> Date: Tue Feb 11 13:03:12 2025 +0100 [VPlan] Only skip expansion for SCEVUnknown if it isn't an instruction. (#125235) Update getOrCreateVPValueForSCEVExpr to only skip expansion of SCEVUnknown if the underlying value isn't an instruction. Instructions may be defined in a loop and using them without expansion may break LCSSA form. SCEVExpander will take care of preserving LCSSA if needed. We could also try to pass LoopInfo, but there are some users of the function where it won't be available and main benefit from skipping expansion is slightly more concise VPlans. Note that SCEVExpander is now used to expand SCEVUnknown with floats. Adjust the check in expandCodeFor to only check the types and casts if the type of the value is different to the requested type. Otherwise we crash when trying to expand a float and requesting a float type. Fixes https://github.com/llvm/llvm-project/issues/121518. PR: https://github.com/llvm/llvm-project/pull/125235 diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp index 3a761bc4e811..d429fe96f9be 100644 --- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp @@ -1451,7 +1451,7 @@ Value *SCEVExpander::expandCodeFor(const SCEV *SH, Type *Ty) { // Expand the code for this SCEV. Value *V = expand(SH); - if (Ty) { + if (Ty && Ty != V->getType()) { assert(SE.getTypeSizeInBits(Ty) == SE.getTypeSizeInBits(SH->getType()) && "non-trivial casts should be done with the SCEVs directly!"); V = InsertNoopCastOfTo(V, Ty); diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp index 618c8aef3840..1855fb67aa54 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp @@ -3404,7 +3404,7 @@ void VPExpandSCEVRecipe::execute(VPTransformState &State) { } const DataLayout &DL = State.CFG.PrevBB->getDataLayout(); - SCEVExpander Exp(SE, DL, "induction"); + SCEVExpander Exp(SE, DL, "induction", /*PreserveLCSSA=*/true); Value *Res = Exp.expandCodeFor(Expr, Expr->getType(), &*State.Builder.GetInsertPoint()); diff --git a/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp b/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp index e40af3e2e3d3..1a7322ec0aff 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp @@ -30,11 +30,18 @@ VPValue *vputils::getOrCreateVPValueForSCEVExpr(VPlan &Plan, const SCEV *Expr, VPValue *Expanded = nullptr; if (auto *E = dyn_cast<SCEVConstant>(Expr)) Expanded = Plan.getOrAddLiveIn(E->getValue()); - else if (auto *E = dyn_cast<SCEVUnknown>(Expr)) - Expanded = Plan.getOrAddLiveIn(E->getValue()); else { - Expanded = new VPExpandSCEVRecipe(Expr, SE); - Plan.getEntry()->appendRecipe(Expanded->getDefiningRecipe()); + auto *U = dyn_cast<SCEVUnknown>(Expr); + // Skip SCEV expansion if Expr is a SCEVUnknown wrapping a non-instruction + // value. Otherwise the value may be defined in a loop and using it directly + // will break LCSSA form. The SCEV expansion takes care of preserving LCSSA + // form. + if (U && !isa<Instruction>(U->getValue())) { + Expanded = Plan.getOrAddLiveIn(U->getValue()); + } else { + Expanded = new VPExpandSCEVRecipe(Expr, SE); + Plan.getEntry()->appendRecipe(Expanded->getDefiningRecipe()); + } } Plan.addSCEVExpansion(Expr, Expanded); return Expanded;
[ { "file": "llvm/test/Transforms/LoopVectorize/X86/scev-checks-unprofitable.ll", "commands": [ "opt -p loop-vectorize -vectorizer-min-trip-count=8 -mcpu=skylake-avx512 -S %s" ], "tests": [ { "test_name": "<module>", "test_body": "\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n; Test case for https://github.com/llvm/llvm-project/issues/121518. Make sure\n; that we preserve LCSSA form when using %iv.1 from loop.1 in the trip count\n; expression when vectorizing loop.2\ndefine void @value_defined_in_loop1_used_for_trip_counts(i32 %start, i1 %c, ptr %dst) {\n;\nentry:\n %select = select i1 %c, i32 0, i32 7\n %zext = zext i32 %select to i64\n br label %loop.1\n\nloop.1:\n %iv.1 = phi i64 [ 0, %entry ], [ %zext, %loop.1 ]\n br i1 false, label %loop.1.exit, label %loop.1\n\nloop.1.exit:\n br i1 %c, label %loop.2, label %loop.3\n\nloop.2:\n %iv.2 = phi i64 [ 0, %loop.1.exit ], [ %iv.2.next, %loop.2 ]\n %iv.3 = phi i32 [ %start, %loop.1.exit ], [ %iv.3.next, %loop.2 ]\n %iv.3.next = add i32 %iv.3, 1\n %iv.2.next = add i64 %iv.2, 1\n %shl = shl i32 %iv.3, 1\n %zext8 = zext i32 %shl to i64\n %gep.dst = getelementptr i8, ptr %dst, i64 %zext8\n store i16 0, ptr %gep.dst, align 2\n %ec.2 = icmp ult i64 %iv.2, %iv.1\n br i1 %ec.2, label %loop.2, label %exit.1\n\nloop.3:\n %iv.4 = phi i64 [ 0, %loop.1.exit ], [ %iv.4.next, %loop.3 ]\n %gep.dst.2 = getelementptr i8, ptr %dst, i64 %iv.4\n store i8 0, ptr %gep.dst.2, align 1\n %iv.4.next = add i64 %iv.4, 1\n %ec.3 = icmp ult i64 %iv.4.next, %iv.1\n br i1 %ec.3, label %loop.3, label %exit.1\n\nexit.1:\n ret void\n}\n;.\n;.", "additional_args": null, "lli_expected_out": null } ] }, { "file": "llvm/test/Transforms/LoopVectorize/float-induction.ll", "commands": [ "opt < %s -passes=loop-vectorize,dce,instcombine -force-vector-interleave=1 -force-vector-width=4 -S", "opt < %s -passes=loop-vectorize,dce,instcombine -force-vector-interleave=2 -force-vector-width=4 -S", "opt < %s -passes=loop-vectorize,dce,instcombine -force-vector-interleave=2 -force-vector-width=1 -S", "opt < %s -passes=loop-vectorize,dce,simplifycfg,instcombine,simplifycfg -force-vector-interleave=1 -force-vector-width=2 -simplifycfg-require-and-preserve-domtree=1 -keep-loops=false -S" ], "tests": [ { "test_name": "fp_iv_loop3", "test_body": "@fp_inc = external global float, align 4\n\ndefine void @fp_iv_loop3(float %init, ptr noalias captures(none) %A, ptr noalias captures(none) %B, ptr noalias captures(none) %C, i32 %N) {\nentry:\n %cmp9 = icmp sgt i32 %N, 0\n br i1 %cmp9, label %for.body.lr.ph, label %for.end\n\nfor.body.lr.ph: ; preds = %entry\n %0 = load float, ptr @fp_inc, align 4\n br label %for.body\n\nfor.body: ; preds = %for.body, %for.body.lr.ph\n %indvars.iv = phi i64 [ 0, %for.body.lr.ph ], [ %indvars.iv.next, %for.body ]\n %y.012 = phi float [ 0x3FB99999A0000000, %for.body.lr.ph ], [ %conv1, %for.body ]\n %x.011 = phi float [ %init, %for.body.lr.ph ], [ %add, %for.body ]\n %arrayidx = getelementptr inbounds float, ptr %A, i64 %indvars.iv\n store float %x.011, ptr %arrayidx, align 4\n %add = fadd fast float %x.011, %0\n %conv1 = fadd fast float %y.012, -5.000000e-01\n %add2 = fadd fast float %conv1, %add\n %arrayidx4 = getelementptr inbounds float, ptr %B, i64 %indvars.iv\n store float %add2, ptr %arrayidx4, align 4\n %arrayidx6 = getelementptr inbounds float, ptr %C, i64 %indvars.iv\n store float %conv1, ptr %arrayidx6, align 4\n %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1\n %lftr.wideiv = trunc i64 %indvars.iv.next to i32\n %exitcond = icmp eq i32 %lftr.wideiv, %N\n br i1 %exitcond, label %for.end.loopexit, label %for.body\n\nfor.end.loopexit: ; preds = %for.body\n br label %for.end\n\nfor.end: ; preds = %for.end.loopexit, %entry\n ret void\n}\n\n!llvm.module.flags = !{!0}\n\n!0 = !{i32 2, !\"Debug Info Version\", i32 3}\n", "additional_args": null, "lli_expected_out": null } ] } ]
{ "title": "Assertion `all_of(I->users(), [&InsertedSet](Value *U) { return InsertedSet.contains(cast<Instruction>(U)); }) && \"removed instruction should only be used by instructions inserted \" \"during expansion\"' failed.", "body": "To reproduce run opt with the test below (-passes=loop-vectorize ):\n```\n; ModuleID = './reduced.ll'\nsource_filename = \"./reduced.ll\"\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine ptr addrspace(1) @wombat(i32 %arg) gc \"statepoint-example\" {\nbb:\n %select = select i1 false, i32 0, i32 8\n br label %bb3\n\nbb1: ; preds = %bb3\n br i1 false, label %bb4, label %bb9\n\nbb2: ; No predecessors!\n %zext = zext i32 %select to i64\n br label %bb3\n\nbb3: ; preds = %bb3, %bb2, %bb\n %phi = phi i64 [ %zext, %bb2 ], [ 0, %bb3 ], [ 0, %bb ]\n br i1 false, label %bb1, label %bb3\n\nbb4: ; preds = %bb4, %bb1\n %phi5 = phi i64 [ %add7, %bb4 ], [ 0, %bb1 ]\n %phi6 = phi i32 [ %add, %bb4 ], [ %arg, %bb1 ]\n %add = add i32 %phi6, 1\n %add7 = add i64 %phi5, 1\n %shl = shl i32 %phi6, 1\n %zext8 = zext i32 %shl to i64\n %getelementptr = getelementptr i8, ptr addrspace(1) null, i64 %zext8\n store i16 0, ptr addrspace(1) %getelementptr, align 2\n %icmp = icmp ult i64 %phi5, %phi\n br i1 %icmp, label %bb4, label %bb15\n\nbb9: ; preds = %bb9, %bb1\n %phi10 = phi i64 [ %add12, %bb9 ], [ 0, %bb1 ]\n %getelementptr11 = getelementptr i8, ptr addrspace(1) null, i64 %phi10\n store i8 0, ptr addrspace(1) %getelementptr11, align 1\n %add12 = add i64 %phi10, 1\n %icmp13 = icmp ult i64 %add12, %phi\n br i1 %icmp13, label %bb9, label %bb14\n\nbb14: ; preds = %bb9\n ret ptr addrspace(1) null\n\nbb15: ; preds = %bb4\n ret ptr addrspace(1) null\n}\n```\nReproducer: https://godbolt.org/z/67vadzMbr\nStack dump:\n```\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=loop-vectorize <source>\n1.\tRunning pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"<source>\"\n2.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"wombat\"\n #0 0x000000000525d5d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x525d5d8)\n #1 0x000000000525afdc SignalHandler(int) Signals.cpp:0:0\n #2 0x00007cf6f6042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007cf6f60969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007cf6f6042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007cf6f60287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x00007cf6f602871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x00007cf6f6039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x00000000045a6237 llvm::SCEVExpanderCleaner::cleanup() (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x45a6237)\n #9 0x00000000041cf7df (anonymous namespace)::GeneratedRTChecks::~GeneratedRTChecks() LoopVectorize.cpp:0:0\n#10 0x0000000004227f36 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4227f36)\n#11 0x0000000004229cc9 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4229cc9)\n#12 0x000000000422a303 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x422a303)\n#13 0x0000000003029e0e 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+0x3029e0e)\n#14 0x000000000505b4d0 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x505b4d0)\n#15 0x0000000000e6bc0e 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+0xe6bc0e)\n#16 0x0000000005059deb llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5059deb)\n#17 0x0000000000e6b29e 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+0xe6b29e)\n#18 0x00000000050597f0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x50597f0)\n#19 0x0000000000941fba 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+0x941fba)\n#20 0x0000000000934559 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x934559)\n#21 0x00007cf6f6029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#22 0x00007cf6f6029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#23 0x000000000092be35 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x92be35)\nProgram terminated with signal: SIGSEGV\n```", "author": "TatyanaDoubts", "labels": [ "release:backport", "vectorizers", "llvm:SCEV", "crash" ], "comments": [ { "author": "TatyanaDoubts", "body": "Triage on our side found the fault commit\n\ncommit 6dc23b70097e4135ecde33f49550b1f473a5c385\n\nAuthor: Nikita Popov <[[email protected]](mailto:[email protected])>\n\nDate: Mon Nov 11 12:36:29 2024 +0100\n\n \n\n [SCEVExpander] Don't try to reuse SCEVUnknown values (#115141)\n\n \n\n The expansion of a SCEVUnknown is trivial (it's just the wrapped value).\n\n If we try to reuse an existing value it might be a more complex\n\n expression that simplifies to the SCEVUnknown.\n\n \n\n This is inspired by [WRONG code: GVN? Loop opts? · Issue #114879 · llvm/llvm-project](https://github.com/llvm/llvm-project/issues/114879) ,\n\n because SCEVExpander replacing a constant with a phi node is just silly.\n\n (I don't consider this a fix for that issue though.)\n\n@nikic , could you please have a look? Thank you!" }, { "author": "danilaml", "body": "Looks like when `FindValueInExprValueMap` returns a `nullptr` (like it does for a phi in reproducer after `SCEVUnknown` changes) the code runs `fixupLCSSAFormFor`. This function runs `llvm::formLCSSAForInstructions` that can insert a new LCSSA phi and more importantly can rewrite the uses of instructions in the worklist. So what happens is this function is run, new phi is added, some old phi uses are replaced with this new phi, then the changes are \"rolled back\", i.e. the cleanup is called on SCEVExpander, it tries to remove the inserted lcssa phi but it doesn't know how to rewrite the uses back so it just asserts (since those users were not inserted by the expander itself, they were already there - they just had their arguments replaced to use instruction from expander).\n\n@nikic this looks like an old issue, although I wasn't yet able to figure out how to trigger it before `SCEVUnknown` changes (and if it even practically possible or just theoretically)." }, { "author": "danilaml", "body": "`fixupLCSSAFormFor` was introduced by @fhahn so perhaps they have a better understanding where the issue lies." }, { "author": "nikic", "body": "I think there are two issues here:\n1. It looks like LV is generating references to the TC that break LCSSA form.\n2. SCEVExpander cleanup can't handle the case where LCSSA formation modified existing uses." }, { "author": "nikic", "body": "This is a possible fix for the SCEVExpander issue: https://github.com/nikic/llvm-project/commit/3217b044ce2b153621f91f8edaaa90984c0998e7\n\nBut after thinking about this, I'm not convinced that SCEVExpander really needs fixing. It is being invoked in PreserveLCSSA mode, so it should be able to rely on the original IR being in LCSSA form.\n\nNote that the `[[N_RND_UP:%.*]] = add i64 [[PHI]], 15` in https://github.com/nikic/llvm-project/commit/3217b044ce2b153621f91f8edaaa90984c0998e7#diff-9e3a00a1cffe1764ee50ab6c79bdea53cd1847cf7b77810a4cdc6835bfc79a52R44 doesn't satisfy LCSSA form, it should be using `PHI_LCSSA`.\n\nMaybe @fhahn could take a look at the LoopVectorize issue?\n\nI could also be convinced to land the SCEVExpander change, as it seems harmless even if LV is fixed..." }, { "author": "fhahn", "body": "Yep, I'll take a look in the next few days" }, { "author": "fhahn", "body": "https://github.com/llvm/llvm-project/pull/125235 should fix the place where LCSSA is broken" } ] }
true
null
81415
https://github.com/llvm/llvm-project/issues/81415
crash
0ea64ad88abcbb939547a92000d98efb2b00d95f
2024-02-11T14:16:02
[ "llvm/test/Transforms/LoopVectorize" ]
{ "fix_commit": "0dacba3ad1b5214ca35eda14987c0b76568a070e", "components": [ "LoopVectorize" ], "bug_location_lineno": { "llvm/include/llvm/Analysis/MemorySSAUpdater.h": null, "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/include/llvm/IR/Instruction.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [ [ 977, 985 ], [ 990, 1000 ] ], "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null, "llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/include/llvm/IR/CmpPredicate.h": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanValue.h": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/include/llvm/Analysis/ScalarEvolution.h": null, "llvm/lib/Analysis/VectorUtils.cpp": null }, "bug_location_funcname": { "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [ "VPlanTransforms::truncateToMinimalBitwidths" ], "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/lib/Analysis/VectorUtils.cpp": null } }
commit 0dacba3ad1b5214ca35eda14987c0b76568a070e Author: Florian Hahn <[email protected]> Date: Fri Feb 16 12:58:39 2024 +0000 [VPlan] Handle truncating ICMPs in truncateToMinimalBWs. Update truncateToMinimalBitwidths to handle truncating ICMPs. For ICMPs, the new target type will be the same as the original type. In that case, only truncate the operands, but skip the extend. This is in line with what the original truncateToMinimalBitwidths did for compares. Fixes https://github.com/llvm/llvm-project/issues/81415. diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp index 16855a9227a1..99198cfa9955 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp @@ -977,9 +977,6 @@ void VPlanTransforms::truncateToMinimalBitwidths( Type *OldResTy = TypeInfo.inferScalarType(ResultVPV); unsigned OldResSizeInBits = OldResTy->getScalarSizeInBits(); assert(OldResTy->isIntegerTy() && "only integer types supported"); - if (OldResSizeInBits == NewResSizeInBits) - continue; - assert(OldResSizeInBits > NewResSizeInBits && "Nothing to shrink?"); (void)OldResSizeInBits; auto *NewResTy = IntegerType::get(Ctx, NewResSizeInBits); @@ -990,11 +987,17 @@ void VPlanTransforms::truncateToMinimalBitwidths( if (auto *VPW = dyn_cast<VPRecipeWithIRFlags>(&R)) VPW->dropPoisonGeneratingFlags(); - // Extend result to original width. - auto *Ext = new VPWidenCastRecipe(Instruction::ZExt, ResultVPV, OldResTy); - Ext->insertAfter(&R); - ResultVPV->replaceAllUsesWith(Ext); - Ext->setOperand(0, ResultVPV); + if (OldResSizeInBits != NewResSizeInBits) { + // Extend result to original width. + auto *Ext = + new VPWidenCastRecipe(Instruction::ZExt, ResultVPV, OldResTy); + Ext->insertAfter(&R); + ResultVPV->replaceAllUsesWith(Ext); + Ext->setOperand(0, ResultVPV); + assert(OldResSizeInBits > NewResSizeInBits && "Nothing to shrink?"); + } else + assert(cast<VPWidenRecipe>(&R)->getOpcode() == Instruction::ICmp && + "Only ICmps should not need extending the result."); if (isa<VPWidenMemoryInstructionRecipe>(&R)) { assert(!cast<VPWidenMemoryInstructionRecipe>(&R)->isStore() && "stores cannot be narrowed");
[ { "file": "llvm/test/Transforms/LoopVectorize/trunc-reductions.ll", "commands": [ "opt -passes=loop-vectorize,dce,instcombine -force-vector-interleave=1 -force-vector-width=8 -S < %s" ], "tests": [ { "test_name": "reduction_and_or", "test_body": "define i32 @reduction_and_or(i16 %a, i32 %b, ptr %src) {\nentry:\n %ext1 = zext i16 %a to i32\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %or67 = phi i32 [ 10, %entry ], [ %or, %loop ]\n %t = trunc i32 %b to i16\n %ext = sext i16 %t to i32\n %cmp = icmp sgt i32 %ext, %ext1\n %ext2 = zext i1 %cmp to i32\n %cmp3 = icmp sge i32 %iv, %ext2\n %ext4 = zext i1 %cmp3 to i32\n %div = sdiv i32 %ext4, %b\n %and = and i32 %div, 0\n %gep = getelementptr inbounds i32, ptr %src, i32 %iv\n %l = load i32, ptr %gep, align 4\n %add = add i32 %and, %l\n %or = or i32 %or67, %add\n %iv.next = add nsw i32 %iv, 1\n %tobool.not = icmp eq i32 %iv.next, 999\n br i1 %tobool.not, label %exit, label %loop\n\nexit: ; preds = %loop\n %or.lcssa = phi i32 [ %or, %loop ]\n ret i32 %or.lcssa\n}\n", "additional_args": null, "lli_expected_out": null } ] } ]
{ "title": "clang crashes at -O{s,2,3} on x86_64-linux-gnu: Assertion `MinBWs.size() == NumProcessedRecipes && \"some entries in MinBWs haven't been processed\"' failed", "body": "It appears to be a recent regression as it does not reproduce with 17.0.1 and earlier versions.\r\n\r\nCompiler Explorer: https://godbolt.org/z/vGGoa684a\r\n\r\n```\r\n[511] % clangtk -v\r\nclang version 19.0.0git (https://github.com/llvm/llvm-project.git 5932fcc47855fdd209784f38820422d2369b84b2)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/opfuzz/bin\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\r\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nCandidate multilib: .;@m64\r\nSelected multilib: .;@m64\r\n[512] % \r\n[512] % clangtk -Os small.c\r\nclang-19: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp:1038: static void llvm::VPlanTransforms::truncateToMinimalBitwidths(llvm::VPlan&, const llvm::MapVector<llvm::Instruction*, long unsigned int>&, llvm::LLVMContext&): Assertion `MinBWs.size() == NumProcessedRecipes && \"some entries in MinBWs haven't been processed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-19 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/20240211-clangtk-m64-Os-Weverything-pipe-fPIC-build-024130/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20240211-clangtk-m64-Os-Weverything-pipe-fPIC-build-024130/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/19 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Os -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-d74fff.o -x c small.c\r\n1.\t<eof> parser at end of file\r\n2.\tOptimizer\r\n #0 0x000055fb61397fcf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x3f04fcf)\r\n #1 0x000055fb613954f4 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007fdd88b17420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #3 0x00007fdd8851e00b raise /build/glibc-wuryBv/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #4 0x00007fdd884fd859 abort /build/glibc-wuryBv/glibc-2.31/stdlib/abort.c:81:7\r\n #5 0x00007fdd884fd729 get_sysdep_segment_value /build/glibc-wuryBv/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #6 0x00007fdd884fd729 _nl_load_domain /build/glibc-wuryBv/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #7 0x00007fdd8850efd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #8 0x000055fb62c44895 llvm::VPlanTransforms::truncateToMinimalBitwidths(llvm::VPlan&, llvm::MapVector<llvm::Instruction*, unsigned long, llvm::DenseMap<llvm::Instruction*, unsigned int, llvm::DenseMapInfo<llvm::Instruction*, void>, llvm::detail::DenseMapPair<llvm::Instruction*, unsigned int>>, llvm::SmallVector<std::pair<llvm::Instruction*, unsigned long>, 0u>> const&, llvm::LLVMContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x57b1895)\r\n #9 0x000055fb62b2644a llvm::LoopVectorizationPlanner::buildVPlansWithVPRecipes(llvm::ElementCount, llvm::ElementCount) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x569344a)\r\n#10 0x000055fb62b2d861 llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x569a861)\r\n#11 0x000055fb62b30a1f llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x569da1f)\r\n#12 0x000055fb62b33acd llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x56a0acd)\r\n#13 0x000055fb62b34d20 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x56a1d20)\r\n#14 0x000055fb62717536 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x5284536)\r\n#15 0x000055fb5ea6d61d llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x15da61d)\r\n#16 0x000055fb60d5cb3d llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x38c9b3d)\r\n#17 0x000055fb5ea509a6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x15bd9a6)\r\n#18 0x000055fb60d5aa6d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x38c7a6d)\r\n#19 0x000055fb6161dc90 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#20 0x000055fb61620f60 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#21 0x000055fb616215cb clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x418e5cb)\r\n#22 0x000055fb61c5730a clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x47c430a)\r\n#23 0x000055fb63944ee9 clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x64b1ee9)\r\n#24 0x000055fb61c566a8 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x47c36a8)\r\n#25 0x000055fb61ed4429 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x4a41429)\r\n#26 0x000055fb61e508de clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x49bd8de)\r\n#27 0x000055fb61fb8d46 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x4b25d46)\r\n#28 0x000055fb5e655986 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x11c2986)\r\n#29 0x000055fb5e64cfba ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#30 0x000055fb5e652434 clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x11bf434)\r\n#31 0x000055fb5e564aab main (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x10d1aab)\r\n#32 0x00007fdd884ff083 __libc_start_main /build/glibc-wuryBv/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#33 0x000055fb5e64ca7e _start (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x11b9a7e)\r\nclangtk: error: unable to execute command: Aborted\r\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\r\nclang version 19.0.0git (https://github.com/llvm/llvm-project.git 5932fcc47855fdd209784f38820422d2369b84b2)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/opfuzz/bin\r\nclangtk: note: diagnostic msg: \r\n********************\r\n\r\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\r\nPreprocessed source(s) and associated run script(s) are located at:\r\nclangtk: note: diagnostic msg: /tmp/small-ca7a0b.c\r\nclangtk: note: diagnostic msg: /tmp/small-ca7a0b.sh\r\nclangtk: note: diagnostic msg: \r\n\r\n********************\r\n[513] % \r\n[513] % cat small.c\r\nstatic int *a, **b = &a, f = 1;\r\nint c, d, h;\r\nshort e, g;\r\nint main() {\r\n int **i[9] = {&a, &a, &a, &a, &a, &a, &a, &a, &a};\r\n for (; d; d++)\r\n if ((**b < e) | f) {\r\n int *j = &f, k;\r\n c = h;\r\n k = g > ((long)j == 1);\r\n }\r\n return 0;\r\n}\r\n```", "author": "zhendongsu", "labels": [ "vectorizers", "crash" ], "comments": [ { "author": "zhendongsu", "body": "Another related test that reproduces the crash only at -Os.\r\n\r\n```\r\n[513] % clangtk -v\r\nclang version 19.0.0git (https://github.com/llvm/llvm-project.git e769fb8699e3fa8e40623764f7713bfc783b0330)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/opfuzz/bin\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\r\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nCandidate multilib: .;@m64\r\nSelected multilib: .;@m64\r\n[514] % \r\n[514] % clangtk -Os small.c\r\nclang-19: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp:1038: static void llvm::VPlanTransforms::truncateToMinimalBitwidths(llvm::VPlan&, const llvm::MapVector<llvm::Instruction*, long unsigned int>&, llvm::LLVMContext&): Assertion `MinBWs.size() == NumProcessedRecipes && \"some entries in MinBWs haven't been processed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-19 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/DUP/20240215-clangtk-m64-Os-Weverything-pipe-fPIC-build-144944/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/DUP/20240215-clangtk-m64-Os-Weverything-pipe-fPIC-build-144944/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/19 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Os -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-a3d3db.o -x c small.c\r\n1.\t<eof> parser at end of file\r\n2.\tOptimizer\r\n #0 0x000055bf09b51e2f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x3f38e2f)\r\n #1 0x000055bf09b4f354 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007fdb52bbc420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #3 0x00007fdb525c300b raise /build/glibc-wuryBv/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #4 0x00007fdb525a2859 abort /build/glibc-wuryBv/glibc-2.31/stdlib/abort.c:81:7\r\n #5 0x00007fdb525a2729 get_sysdep_segment_value /build/glibc-wuryBv/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #6 0x00007fdb525a2729 _nl_load_domain /build/glibc-wuryBv/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #7 0x00007fdb525b3fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #8 0x000055bf0b405565 llvm::VPlanTransforms::truncateToMinimalBitwidths(llvm::VPlan&, llvm::MapVector<llvm::Instruction*, unsigned long, llvm::DenseMap<llvm::Instruction*, unsigned int, llvm::DenseMapInfo<llvm::Instruction*, void>, llvm::detail::DenseMapPair<llvm::Instruction*, unsigned int>>, llvm::SmallVector<std::pair<llvm::Instruction*, unsigned long>, 0u>> const&, llvm::LLVMContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x57ec565)\r\n #9 0x000055bf0b2e62ba llvm::LoopVectorizationPlanner::buildVPlansWithVPRecipes(llvm::ElementCount, llvm::ElementCount) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x56cd2ba)\r\n#10 0x000055bf0b2ed661 llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x56d4661)\r\n#11 0x000055bf0b2f081f llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x56d781f)\r\n#12 0x000055bf0b2f38cd llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x56da8cd)\r\n#13 0x000055bf0b2f4b20 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x56dbb20)\r\n#14 0x000055bf0aed6086 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x52bd086)\r\n#15 0x000055bf0721ff8d llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x1606f8d)\r\n#16 0x000055bf0951611d llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x38fd11d)\r\n#17 0x000055bf072032e6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x15ea2e6)\r\n#18 0x000055bf0951404d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x38fb04d)\r\n#19 0x000055bf09dd88c0 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#20 0x000055bf09ddbb80 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#21 0x000055bf09ddc1eb clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x41c31eb)\r\n#22 0x000055bf0a41298a clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x47f998a)\r\n#23 0x000055bf0c10e439 clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x64f5439)\r\n#24 0x000055bf0a411d18 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x47f8d18)\r\n#25 0x000055bf0a6903e9 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x4a773e9)\r\n#26 0x000055bf0a60d21e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x49f421e)\r\n#27 0x000055bf0a776736 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x4b5d736)\r\n#28 0x000055bf06e06b76 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x11edb76)\r\n#29 0x000055bf06dfe1aa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#30 0x000055bf06e03624 clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x11ea624)\r\n#31 0x000055bf06d15abb main (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x10fcabb)\r\n#32 0x00007fdb525a4083 __libc_start_main /build/glibc-wuryBv/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#33 0x000055bf06dfdc6e _start (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x11e4c6e)\r\nclangtk: error: unable to execute command: Aborted\r\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\r\nclang version 19.0.0git (https://github.com/llvm/llvm-project.git e769fb8699e3fa8e40623764f7713bfc783b0330)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/opfuzz/bin\r\nclangtk: note: diagnostic msg: \r\n********************\r\n\r\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\r\nPreprocessed source(s) and associated run script(s) are located at:\r\nclangtk: note: diagnostic msg: /tmp/small-585ede.c\r\nclangtk: note: diagnostic msg: /tmp/small-585ede.sh\r\nclangtk: note: diagnostic msg: \r\n\r\n********************\r\n[515] % \r\n[515] % cat small.c\r\nint a = 1, b, c, d;\r\nshort e() { return a == 1 ? a : a % b; }\r\nstatic int f;\r\nshort g;\r\nunsigned short h;\r\nint main() {\r\n int *i[10] = {&f};\r\n for (c = -2; c; c++) {\r\n g = e();\r\n d |= f & ((b >= (g > h)) / a);\r\n }\r\n return 0;\r\n}\r\n```" }, { "author": "fhahn", "body": "Thanks for the test case, should be fixed! \r\n\r\nIt looks like this only gets triggered when the resulting truncated compare is dead. Please let me know if you see any issues with similar cases where the resulting loop/compares in the loop aren't dead." } ] }
true
null
108620
https://github.com/llvm/llvm-project/issues/108620
crash
03618ceabd003be94190b068db11b607fd1108ef
2024-09-13T18:15:02
[ "llvm/test/Transforms/SLPVectorizer" ]
{ "fix_commit": "1e3536ef3141d6429f3616af624b81b6d6ab2959", "components": [ "SLPVectorizer" ], "bug_location_lineno": { "llvm/include/llvm/Analysis/MemorySSAUpdater.h": null, "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [ [ 1283, 1293 ], [ 14222, 14235 ], [ 14373, 14378 ], [ 14426, 14436 ], [ 14530, 14537 ], [ 14757, 14762 ], [ 17660, 17666 ], [ 17956, 17961 ], [ 18024, 18031 ] ], "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/include/llvm/IR/Instruction.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null, "llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/include/llvm/IR/CmpPredicate.h": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanValue.h": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/include/llvm/Analysis/ScalarEvolution.h": null, "llvm/lib/Analysis/VectorUtils.cpp": null }, "bug_location_funcname": { "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [ "BoUpSLP::vectorizeTree", "tryToReduce" ], "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/lib/Analysis/VectorUtils.cpp": null } }
commit 1e3536ef3141d6429f3616af624b81b6d6ab2959 Author: Alexey Bataev <[email protected]> Date: Fri Sep 13 15:40:22 2024 -0700 [SLP]Fix PR108620: Need to check, if the reduced value was transformed Before trying to include the scalar into the list of ExternallyUsedValues, need to check, if it was transformed in previous iteration and use the transformed value, not the original one, to avoid compiler crash when building external uses. Fixes https://github.com/llvm/llvm-project/issues/108620 diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 0afe02fc08ff..5f2bf082fb87 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -1283,11 +1283,8 @@ public: /// Vectorize the tree but with the list of externally used values \p /// ExternallyUsedValues. Values in this MapVector can be replaced but the /// generated extractvalue instructions. - /// \param ReplacedExternals containd list of replaced external values - /// {scalar, replace} after emitting extractelement for external uses. Value * vectorizeTree(const ExtraValueToDebugLocsMap &ExternallyUsedValues, - SmallVectorImpl<std::pair<Value *, Value *>> &ReplacedExternals, Instruction *ReductionRoot = nullptr); /// \returns the cost incurred by unwanted spills and fills, caused by @@ -14222,14 +14219,12 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) { Value *BoUpSLP::vectorizeTree() { ExtraValueToDebugLocsMap ExternallyUsedValues; - SmallVector<std::pair<Value *, Value *>> ReplacedExternals; - return vectorizeTree(ExternallyUsedValues, ReplacedExternals); + return vectorizeTree(ExternallyUsedValues); } -Value *BoUpSLP::vectorizeTree( - const ExtraValueToDebugLocsMap &ExternallyUsedValues, - SmallVectorImpl<std::pair<Value *, Value *>> &ReplacedExternals, - Instruction *ReductionRoot) { +Value * +BoUpSLP::vectorizeTree(const ExtraValueToDebugLocsMap &ExternallyUsedValues, + Instruction *ReductionRoot) { // All blocks must be scheduled before any instructions are inserted. for (auto &BSIter : BlocksSchedules) { scheduleBlock(BSIter.second.get()); @@ -14373,6 +14368,7 @@ Value *BoUpSLP::vectorizeTree( SmallDenseSet<Value *, 4> UsedInserts; DenseMap<std::pair<Value *, Type *>, Value *> VectorCasts; SmallDenseSet<Value *, 4> ScalarsWithNullptrUser; + SmallDenseSet<ExtractElementInst *, 4> IgnoredExtracts; // Extract all of the elements with the external uses. for (const auto &ExternalUse : ExternalUses) { Value *Scalar = ExternalUse.Scalar; @@ -14426,11 +14422,16 @@ Value *BoUpSLP::vectorizeTree( if (ReplaceInst) { // Leave the instruction as is, if it cheaper extracts and all // operands are scalar. - auto *CloneInst = Inst->clone(); - CloneInst->insertBefore(Inst); - if (Inst->hasName()) - CloneInst->takeName(Inst); - Ex = CloneInst; + if (auto *EE = dyn_cast<ExtractElementInst>(Inst)) { + IgnoredExtracts.insert(EE); + Ex = EE; + } else { + auto *CloneInst = Inst->clone(); + CloneInst->insertBefore(Inst); + if (Inst->hasName()) + CloneInst->takeName(Inst); + Ex = CloneInst; + } } else if (auto *ES = dyn_cast<ExtractElementInst>(Scalar); ES && isa<Instruction>(Vec)) { Value *V = ES->getVectorOperand(); @@ -14530,8 +14531,12 @@ Value *BoUpSLP::vectorizeTree( } Value *NewInst = ExtractAndExtendIfNeeded(Vec); // Required to update internally referenced instructions. - Scalar->replaceAllUsesWith(NewInst); - ReplacedExternals.emplace_back(Scalar, NewInst); + if (Scalar != NewInst) { + assert((!isa<ExtractElementInst>(Scalar) || + !IgnoredExtracts.contains(cast<ExtractElementInst>(Scalar))) && + "Extractelements should not be replaced."); + Scalar->replaceAllUsesWith(NewInst); + } continue; } @@ -14757,6 +14762,9 @@ Value *BoUpSLP::vectorizeTree( if (Entry->getOpcode() == Instruction::GetElementPtr && !isa<GetElementPtrInst>(Scalar)) continue; + if (auto *EE = dyn_cast<ExtractElementInst>(Scalar); + EE && IgnoredExtracts.contains(EE)) + continue; #ifndef NDEBUG Type *Ty = Scalar->getType(); if (!Ty->isVoidTy()) { @@ -17660,7 +17668,6 @@ public: // because of the vectorization. DenseMap<Value *, WeakTrackingVH> TrackedVals(ReducedVals.size() * ReducedVals.front().size()); - SmallVector<std::pair<Value *, Value *>> ReplacedExternals; // The compare instruction of a min/max is the insertion point for new // instructions and may be replaced with a new compare instruction. @@ -17956,6 +17963,8 @@ public: if (Cnt >= Pos && Cnt < Pos + ReduxWidth) continue; Value *RdxVal = Candidates[Cnt]; + if (auto It = TrackedVals.find(RdxVal); It != TrackedVals.end()) + RdxVal = It->second; if (!Visited.insert(RdxVal).second) continue; // Check if the scalar was vectorized as part of the vectorization @@ -18024,8 +18033,8 @@ public: InsertPt = GetCmpForMinMaxReduction(RdxRootInst); // Vectorize a tree. - Value *VectorizedRoot = V.vectorizeTree(LocalExternallyUsedValues, - ReplacedExternals, InsertPt); + Value *VectorizedRoot = + V.vectorizeTree(LocalExternallyUsedValues, InsertPt); Builder.SetInsertPoint(InsertPt);
[ { "file": "llvm/test/Transforms/SLPVectorizer/X86/reduced-val-extracted-and-externally-used.ll", "commands": [ "opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s" ], "tests": [ { "test_name": "test", "test_body": "define void @test(i32 %arg) {\nbb:\n br label %bb1\n\nbb1: ; preds = %bb1, %bb\n %phi = phi i32 [ 0, %bb ], [ %add27, %bb1 ]\n %phi2 = phi i32 [ 0, %bb ], [ %add24, %bb1 ]\n %phi3 = phi i32 [ 0, %bb ], [ %xor26, %bb1 ]\n %add = add i32 %phi2, 0\n %add4 = add i32 %phi2, 0\n %xor = xor i32 %add, %add4\n %add5 = add i32 %phi, 0\n %add6 = add i32 %phi2, 0\n %add7 = add i32 %phi2, 0\n %xor8 = xor i32 %add6, %xor\n %xor9 = xor i32 %xor8, %add5\n %xor10 = xor i32 %xor9, %add7\n %add11 = add i32 %phi, 0\n %add12 = add i32 %phi2, 0\n %add13 = add i32 %phi2, 0\n %xor14 = xor i32 %add12, %xor10\n %xor15 = xor i32 %xor14, %add11\n %xor16 = xor i32 %xor15, %add13\n %add17 = add i32 %phi, 0\n %add18 = add i32 %phi2, 0\n %add19 = add i32 %phi2, 0\n %xor20 = xor i32 %add18, %xor16\n %xor21 = xor i32 %xor20, %add17\n %xor22 = xor i32 %xor21, %add19\n %add23 = add i32 %phi2, 0\n %add24 = add i32 %arg, 0\n %xor25 = xor i32 %add23, %xor22\n %xor26 = xor i32 %xor25, %add24\n %add27 = add i32 1, 0\n %icmp = icmp ult i32 %add27, 0\n br label %bb1\n}\n", "additional_args": null, "lli_expected_out": null } ] } ]
{ "title": "Assertion `(I->use_empty() || all_of(I->uses(), [&](Use &U) { return isDeleted( cast<Instruction>(U.getUser())); })) && \"trying to erase instruction with users.\"' failed.", "body": "To reproduce run the following test with -passes=slp-vectorizer\r\n```\r\n; ModuleID = './reduced.ll'\r\nsource_filename = \"./reduced.ll\"\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine void @wombat(i32 %arg) gc \"statepoint-example\" {\r\nbb:\r\n br label %bb1\r\n\r\nbb1: ; preds = %bb1, %bb\r\n %phi = phi i32 [ 0, %bb ], [ %add27, %bb1 ]\r\n %phi2 = phi i32 [ 0, %bb ], [ %add24, %bb1 ]\r\n %phi3 = phi i32 [ 0, %bb ], [ %xor26, %bb1 ]\r\n %add = add i32 %phi2, 0\r\n %add4 = add i32 %phi2, 0\r\n %xor = xor i32 %add, %add4\r\n %add5 = add i32 %phi, 0\r\n %add6 = add i32 %phi2, 0\r\n %add7 = add i32 %phi2, 0\r\n %xor8 = xor i32 %add6, %xor\r\n %xor9 = xor i32 %xor8, %add5\r\n %xor10 = xor i32 %xor9, %add7\r\n %add11 = add i32 %phi, 0\r\n %add12 = add i32 %phi2, 0\r\n %add13 = add i32 %phi2, 0\r\n %xor14 = xor i32 %add12, %xor10\r\n %xor15 = xor i32 %xor14, %add11\r\n %xor16 = xor i32 %xor15, %add13\r\n %add17 = add i32 %phi, 0\r\n %add18 = add i32 %phi2, 0\r\n %add19 = add i32 %phi2, 0\r\n %xor20 = xor i32 %add18, %xor16\r\n %xor21 = xor i32 %xor20, %add17\r\n %xor22 = xor i32 %xor21, %add19\r\n %add23 = add i32 %phi2, 0\r\n %add24 = add i32 %arg, 0\r\n %xor25 = xor i32 %add23, %xor22\r\n %xor26 = xor i32 %xor25, %add24\r\n %add27 = add i32 1, 0\r\n %icmp = icmp ult i32 %add27, 0\r\n br label %bb1\r\n}\r\n```\r\nReproducer: https://godbolt.org/z/77hKre61P\r\n\r\nStack dump:\r\n```\r\nopt: /root/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:2663: void llvm::slpvectorizer::BoUpSLP::removeInstructionsAndOperands(llvm::ArrayRef<U*>) [with T = llvm::Instruction]: Assertion `(I->use_empty() || all_of(I->uses(), [&](Use &U) { return isDeleted( cast<Instruction>(U.getUser())); })) && \"trying to erase instruction with users.\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer <source>\r\n1.\tRunning pass \"function(slp-vectorizer)\" on module \"<source>\"\r\n2.\tRunning pass \"slp-vectorizer\" on function \"wombat\"\r\n #0 0x00000000050106b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x50106b8)\r\n #1 0x000000000500ddfc SignalHandler(int) Signals.cpp:0:0\r\n #2 0x0000737fffa42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x0000737fffa969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x0000737fffa42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x0000737fffa287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x0000737fffa2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x0000737fffa39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x00000000040b91cf void llvm::slpvectorizer::BoUpSLP::removeInstructionsAndOperands<llvm::Instruction>(llvm::ArrayRef<llvm::Instruction*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40b91cf)\r\n #9 0x000000000410b80a llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::MapVector<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>, llvm::DenseMap<llvm::Value*, unsigned int, llvm::DenseMapInfo<llvm::Value*, void>, llvm::detail::DenseMapPair<llvm::Value*, unsigned int>>, llvm::SmallVector<std::pair<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>>, 0u>> const&, llvm::SmallVectorImpl<std::pair<llvm::Value*, llvm::Value*>>&, llvm::Instruction*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x410b80a)\r\n#10 0x0000000004115bed (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&) SLPVectorizer.cpp:0:0\r\n#11 0x0000000004118321 llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4118321)\r\n#12 0x000000000411cb18 llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x411cb18)\r\n#13 0x00000000041212fa llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41212fa)\r\n#14 0x0000000004127719 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\r\n#15 0x00000000041283cb llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41283cb)\r\n#16 0x0000000002efda4e llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2efda4e)\r\n#17 0x0000000004e12948 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e12948)\r\n#18 0x0000000000e06f8e 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+0xe06f8e)\r\n#19 0x0000000004e1136e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e1136e)\r\n#20 0x0000000000e0679e 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+0xe0679e)\r\n#21 0x0000000004e10da0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e10da0)\r\n#22 0x00000000008fb642 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+0x8fb642)\r\n#23 0x00000000008ee4cc optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8ee4cc)\r\n#24 0x0000737fffa29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#25 0x0000737fffa29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#26 0x00000000008e5f9e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8e5f9e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```", "author": "TatyanaDoubts", "labels": [ "llvm:SLPVectorizer", "crash" ], "comments": [] }
true
null
119665
https://github.com/llvm/llvm-project/issues/119665
crash
7ae78a6cdb6ce9ad1534ed10519649fb3d47aca9
2024-12-12T07:13:14
[ "llvm/test/Transforms/LoopVectorize" ]
{ "fix_commit": "3706dfef660097f24fb5efbac0d7f14b424492ed", "components": [ "LoopVectorize" ], "bug_location_lineno": { "llvm/include/llvm/Analysis/MemorySSAUpdater.h": null, "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [ [ 2937, 2946 ], [ 2950, 2955 ] ], "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/include/llvm/IR/Instruction.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null, "llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/include/llvm/IR/CmpPredicate.h": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanValue.h": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/include/llvm/Analysis/ScalarEvolution.h": null, "llvm/lib/Analysis/VectorUtils.cpp": null }, "bug_location_funcname": { "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [ "InnerLoopVectorizer::fixVectorizedLoop" ], "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/lib/Analysis/VectorUtils.cpp": null } }
commit 3706dfef660097f24fb5efbac0d7f14b424492ed Author: Florian Hahn <[email protected]> Date: Mon Feb 10 16:29:42 2025 +0000 [LV] Forget LCSSA phi with new pred before other SCEV invalidation. (#119897) `forgetLcssaPhiWithNewPredecessor` performs additional invalidation if there is an existing SCEV for the phi, but earlier `forgetBlockAndLoopDispositions` or `forgetLoop` may already invalidate the SCEV for the phi. Change the order to first call `forgetLcssaPhiWithNewPredecessor` to ensure it runs before its SCEV gets invalidated too eagerly. Fixes https://github.com/llvm/llvm-project/issues/119665. PR: https://github.com/llvm/llvm-project/pull/119897 diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 610e4904a80a..f2241be60ce0 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -2937,10 +2937,6 @@ void InnerLoopVectorizer::fixVectorizedLoop(VPTransformState &State) { if (EnableVPlanNativePath) fixNonInductionPHIs(State); - // Forget the original basic block. - PSE.getSE()->forgetLoop(OrigLoop); - PSE.getSE()->forgetBlockAndLoopDispositions(); - // After vectorization, the exit blocks of the original loop will have // additional predecessors. Invalidate SCEVs for the exit phis in case SE // looked through single-entry phis. @@ -2950,6 +2946,10 @@ void InnerLoopVectorizer::fixVectorizedLoop(VPTransformState &State) { for (PHINode &PN : Exit->phis()) PSE.getSE()->forgetLcssaPhiWithNewPredecessor(OrigLoop, &PN); + // Forget the original basic block. + PSE.getSE()->forgetLoop(OrigLoop); + PSE.getSE()->forgetBlockAndLoopDispositions(); + // Don't apply optimizations below when no vector region remains, as they all // require a vector loop at the moment. if (!State.Plan->getVectorLoopRegion())
[ { "file": "llvm/test/Transforms/LoopVectorize/invalidate-scev-at-scope-after-vectorization.ll", "commands": [ "opt -passes='print<scalar-evolution>,loop-vectorize' -force-vector-width=4 -scalar-evolution-classify-expressions=false -S %s" ], "tests": [ { "test_name": "<module>", "test_body": "\n; Test case for https://github.com/llvm/llvm-project/issues/119665.\n\n; %loop.2's backedge-taken-count depends on %add.1 from %loop.1 via its\n; corresponding SCEV at the scope of %loop.2. After vectorizing %loop.1, %add.1\n; isn't available at the entry of %loop.2 anymore and %add.1 at %loop.2's scope\n; must be invalidated, as well as %loop.2's backedge-taken count.\ndefine void @test_invalidate_scevs_at_scope(ptr %p) {\n;\nentry:\n br label %loop.1\n\nloop.1:\n %iv.1 = phi i32 [ 0, %entry ], [ %iv.1.next, %loop.1 ]\n %1 = load i32, ptr %p, align 4\n %add.1 = add i32 %1, %iv.1\n %iv.1.next = add i32 %iv.1, 1\n %c.1 = icmp eq i32 %iv.1, 100\n br i1 %c.1, label %exit.1, label %loop.1\n\nexit.1:\n %add.lcssa = phi i32 [ %add.1, %loop.1 ]\n br label %loop.2\n\nloop.2:\n %iv.2 = phi i64 [ 0, %exit.1 ], [ %iv.2.next, %loop.2 ]\n %iv.2.trunc = trunc i64 %iv.2 to i32\n %iv.2.next = add i64 %iv.2, 1\n %gep = getelementptr inbounds i64, ptr %p, i64 %iv.2\n store i64 %iv.2, ptr %gep\n %add.2 = add i32 %add.lcssa, %iv.2.trunc\n %c.2 = icmp slt i32 %add.2, 100\n br i1 %c.2, label %loop.2, label %exit.2\n\nexit.2:\n ret void\n}\n\n;.\n;.", "additional_args": null, "lli_expected_out": null } ] } ]
{ "title": "[clang] Crash at -O2: Assertion `isAvailableAtLoopEntry(LHS, L) && \"LHS is not available at Loop Entry\"' failed.", "body": "This code crashes at `-O2`: \n```c\nint a, e;\nint *b;\nshort c[];\nshort d;\nvoid f() {\n int g;\n for (;;)\n for (; a - 3 + g < 6; g = g + 1)\n c[g] = d;\n}\nvoid h();\nvoid i() {\n h();\n f();\n}\nvoid h() {\n e = 0;\n for (; e <= 50; ++e) {\n int *j = &a;\n *j = *b + e;\n }\n}\n```\n\nCompiler Explorer: https://godbolt.org/z/jfo65eK9x\n\nCrash:\n```console\nclang: /root/llvm-project/llvm/lib/Analysis/ScalarEvolution.cpp:11744: bool llvm::ScalarEvolution::isLoopEntryGuardedByCond(const llvm::Loop*, llvm::CmpInst::Predicate, const llvm::SCEV*, const llvm::SCEV*): Assertion `isAvailableAtLoopEntry(LHS, L) && \"LHS is not available at Loop Entry\"' failed.\n```\nBacktrace:\n```console\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O2 -Wall -Wextra -fno-strict-aliasing <source>\n1.\t<eof> parser at end of file\n2.\tOptimizer\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"<source>\"\n4.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"i\"\n #0 0x0000000003c19758 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3c19758)\n #1 0x0000000003c17464 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3c17464)\n #2 0x0000000003b649c8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0\n #3 0x000079aa17242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #4 0x000079aa172969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #5 0x000079aa17242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #6 0x000079aa172287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #7 0x000079aa1722871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #8 0x000079aa17239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #9 0x0000000002c90a7b llvm::ScalarEvolution::isLoopEntryGuardedByCond(llvm::Loop const*, llvm::CmpInst::Predicate, llvm::SCEV const*, llvm::SCEV const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x2c90a7b)\n#10 0x0000000002ca6d97 llvm::ScalarEvolution::getTripCountFromExitCount(llvm::SCEV const*, llvm::Type*, llvm::Loop const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x2ca6d97)\n#11 0x00000000058449e4 llvm::VPlan::createInitialVPlan(llvm::Type*, llvm::PredicatedScalarEvolution&, bool, bool, llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x58449e4)\n#12 0x000000000572a8ce llvm::LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(llvm::VFRange&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x572a8ce)\n#13 0x000000000572dd5a llvm::LoopVectorizationPlanner::buildVPlansWithVPRecipes(llvm::ElementCount, llvm::ElementCount) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x572dd5a)\n#14 0x000000000572e24f llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x572e24f)\n#15 0x000000000573044f llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x573044f)\n#16 0x0000000005732a89 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5732a89)\n#17 0x00000000057330c3 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x57330c3)\n#18 0x0000000005283abe 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/clang+0x5283abe)\n#19 0x00000000035c8550 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x35c8550)\n#20 0x00000000010fa0ee 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/clang+0x10fa0ee)\n#21 0x00000000035c6e6b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x35c6e6b)\n#22 0x00000000010f977e 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/clang+0x10f977e)\n#23 0x00000000035c6870 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x35c6870)\n#24 0x0000000003eca382 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\n#25 0x0000000003ecdbfd clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3ecdbfd)\n#26 0x000000000459e07e clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x459e07e)\n#27 0x000000000655704c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x655704c)\n#28 0x000000000459e458 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x459e458)\n#29 0x0000000004856fc9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4856fc9)\n#30 0x00000000047d989e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x47d989e)\n#31 0x000000000494267e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x494267e)\n#32 0x0000000000cb92df cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xcb92df)\n#33 0x0000000000cb0d7a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#34 0x00000000045e2229 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0\n#35 0x0000000003b64e74 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3b64e74)\n#36 0x00000000045e281f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0\n#37 0x00000000045a7f3d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45a7f3d)\n#38 0x00000000045a902d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45a902d)\n#39 0x00000000045b0565 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45b0565)\n#40 0x0000000000cb6123 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xcb6123)\n#41 0x0000000000b84564 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xb84564)\n#42 0x000079aa17229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#43 0x000079aa17229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#44 0x0000000000cb0825 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xcb0825)\n```\n", "author": "cardigan1008", "labels": [ "release:backport", "vectorizers", "crash", "regression:18" ], "comments": [ { "author": "shafik", "body": "Looks like a clang-18 regression: https://godbolt.org/z/K7MMKxjzb" }, { "author": "dtcxzyw", "body": "Reduced reproducer: https://godbolt.org/z/s4G9Yb1vG\n```\n; bin/opt -passes=\"print<scalar-evolution>,loop-vectorize\" test.ll -S\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @i(ptr %p) {\nentry:\n br label %for.body.i\n\nfor.body.i: ; preds = %for.body.i, %entry\n %0 = phi i32 [ 0, %entry ], [ %inc.i, %for.body.i ]\n %1 = load i32, ptr %p, align 4\n %add.i = add i32 %1, %0\n %inc.i = add i32 %0, 1\n %exitcond.not.i = icmp eq i32 %0, 1\n br i1 %exitcond.not.i, label %for.cond.i.preheader, label %for.body.i\n\nfor.cond.i.preheader: ; preds = %for.body.i\n br label %for.cond.i\n\nfor.cond.i.loopexit: ; preds = %for.body.i1\n br label %for.cond.i\n\nfor.cond.i: ; preds = %for.cond.i.loopexit, %for.cond.i.preheader\n br label %for.body.i1\n\nfor.body.i1: ; preds = %for.body.i1, %for.cond.i\n %indvars.iv.i = phi i64 [ %indvars.iv.next.i, %for.body.i1 ], [ 0, %for.cond.i ]\n %indvars4.i = trunc i64 %indvars.iv.i to i32\n %indvars.iv.next.i = add i64 %indvars.iv.i, 1\n %add.reass.i = add i32 %add.i, %indvars4.i\n %cmp.i = icmp slt i32 %add.reass.i, 0\n br i1 %cmp.i, label %for.body.i1, label %for.cond.i.loopexit\n}\n\n```" }, { "author": "fhahn", "body": "Thanks, let me take a look" } ] }
true
null
87378
https://github.com/llvm/llvm-project/issues/87378
crash
d8db13edd60b195e6692deb04d63e633319e486a
2024-04-02T17:38:53
[ "llvm/test/Transforms/LoopVectorize" ]
{ "fix_commit": "6261c53c6f9c82bfca5df2ed5917876d748ed079", "components": [ "LoopVectorize" ], "bug_location_lineno": { "llvm/include/llvm/Analysis/MemorySSAUpdater.h": null, "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/include/llvm/IR/Instruction.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": [ [ 175, 181 ] ], "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null, "llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": [ [ 913, 918 ], [ 920, 928 ], [ 1016, 1021 ], [ 1221, 1226 ] ], "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/include/llvm/IR/CmpPredicate.h": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanValue.h": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/include/llvm/Analysis/ScalarEvolution.h": null, "llvm/lib/Analysis/VectorUtils.cpp": null }, "bug_location_funcname": { "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": [ "GEPFlagsTy", "VPInstruction", "VPRecipeWithIRFlags" ], "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": [ "createOr", "createSelect" ], "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/lib/Analysis/VectorUtils.cpp": null } }
commit 6261c53c6f9c82bfca5df2ed5917876d748ed079 Author: Florian Hahn <[email protected]> Date: Tue Apr 2 21:48:35 2024 +0100 [VPlan] Make sure OR VPInstructions are treated as disjoint ops. Make sure that VPInstructions with OR opcodes are properly registered as disjoint ops. Fixes https://github.com/llvm/llvm-project/issues/87378. diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h b/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h index 5d03b66b0ce3..ebca2d855a46 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h +++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h @@ -175,7 +175,10 @@ public: VPValue *createOr(VPValue *LHS, VPValue *RHS, DebugLoc DL = {}, const Twine &Name = "") { - return createInstruction(Instruction::BinaryOps::Or, {LHS, RHS}, DL, Name); + + return tryInsertInstruction(new VPInstruction( + Instruction::BinaryOps::Or, {LHS, RHS}, + VPRecipeWithIRFlags::DisjointFlagsTy(false), DL, Name)); } VPValue *createSelect(VPValue *Cond, VPValue *TrueVal, VPValue *FalseVal, diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h index 3baca43f7276..707a826ecdc2 100644 --- a/llvm/lib/Transforms/Vectorize/VPlan.h +++ b/llvm/lib/Transforms/Vectorize/VPlan.h @@ -913,6 +913,11 @@ public: WrapFlagsTy(bool HasNUW, bool HasNSW) : HasNUW(HasNUW), HasNSW(HasNSW) {} }; + struct DisjointFlagsTy { + char IsDisjoint : 1; + DisjointFlagsTy(bool IsDisjoint) : IsDisjoint(IsDisjoint) {} + }; + protected: struct GEPFlagsTy { char IsInBounds : 1; @@ -920,9 +925,6 @@ protected: }; private: - struct DisjointFlagsTy { - char IsDisjoint : 1; - }; struct ExactFlagsTy { char IsExact : 1; }; @@ -1016,6 +1018,12 @@ public: : VPSingleDefRecipe(SC, Operands, DL), OpType(OperationType::FPMathOp), FMFs(FMFs) {} + template <typename IterT> + VPRecipeWithIRFlags(const unsigned char SC, IterT Operands, + DisjointFlagsTy DisjointFlags, DebugLoc DL = {}) + : VPSingleDefRecipe(SC, Operands, DL), OpType(OperationType::DisjointOp), + DisjointFlags(DisjointFlags) {} + protected: template <typename IterT> VPRecipeWithIRFlags(const unsigned char SC, IterT Operands, @@ -1221,6 +1229,14 @@ public: : VPRecipeWithIRFlags(VPDef::VPInstructionSC, Operands, WrapFlags, DL), Opcode(Opcode), Name(Name.str()) {} + VPInstruction(unsigned Opcode, std::initializer_list<VPValue *> Operands, + DisjointFlagsTy DisjointFlag, DebugLoc DL = {}, + const Twine &Name = "") + : VPRecipeWithIRFlags(VPDef::VPInstructionSC, Operands, DisjointFlag, DL), + Opcode(Opcode), Name(Name.str()) { + assert(Opcode == Instruction::Or && "only OR opcodes can be disjoint"); + } + VPInstruction(unsigned Opcode, std::initializer_list<VPValue *> Operands, FastMathFlags FMFs, DebugLoc DL = {}, const Twine &Name = "");
[ { "file": "llvm/test/Transforms/LoopVectorize/pr87378-vpinstruction-or-drop-poison-generating-flags.ll", "commands": [ "opt -p loop-vectorize -mattr=\"+v\" -S %s" ], "tests": [ { "test_name": "<module>", "test_body": "\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\n; Test case for https://github.com/llvm/llvm-project/issues/87378.\ndefine void @pr87378_vpinstruction_or_drop_poison_generating_flags(ptr %arg, i64 %a, i64 %b, i64 %c) {\n;\nentry:\n br label %loop.header\n\nloop.header:\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %c.1 = icmp ule i64 %iv, %a\n br i1 %c.1, label %then.1, label %else.1\n\nthen.1:\n %c.2 = icmp ule i64 %iv, %b\n br i1 %c.2, label %else.1, label %merge\n\nelse.1:\n %c.3 = icmp ule i64 %iv, %c\n br i1 %c.3, label %then.2, label %loop.latch\n\nthen.2:\n br label %merge\n\nmerge:\n %idx = phi i64 [ poison, %then.1 ], [ %iv, %then.2 ]\n %getelementptr = getelementptr i16, ptr %arg, i64 %idx\n store i16 0, ptr %getelementptr, align 2\n br label %loop.latch\n\nloop.latch:\n %iv.next = add i64 %iv, 1\n %icmp = icmp eq i64 %iv, 1000\n br i1 %icmp, label %exit, label %loop.header\n\nexit:\n ret void\n}\n;.\n;.", "additional_args": null, "lli_expected_out": null } ] } ]
{ "title": "[LoopVectorize] Assertion `OpType == OperationType::DisjointOp && \"recipe cannot have a disjoing flag\"' failed.", "body": "Reduced LLVM IR:\r\n``` llvm ir\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine i32 @main() #0 {\r\nentry:\r\n br label %for.body300.us.us.i\r\n\r\nfor.body300.us.us.i: ; preds = %if.end559.us.us.i, %entry\r\n br label %for.body326.us.us.i\r\n\r\nfor.body326.us.us.i: ; preds = %if.end559.us.us.i, %for.body300.us.us.i\r\n %indvars.iv18 = phi i64 [ 0, %for.body300.us.us.i ], [ %indvars.iv.next19, %if.end559.us.us.i ]\r\n br i1 false, label %cond.end339.us.us.i, label %cond.end354.us.us.i\r\n\r\ncond.end339.us.us.i: ; preds = %for.body326.us.us.i\r\n br i1 false, label %cond.end339.us.us.i.if.then357.us.us.i_crit_edge, label %cond.end339.us.us.i.cond.end354.us.us.i_crit_edge\r\n\r\ncond.end339.us.us.i.cond.end354.us.us.i_crit_edge: ; preds = %cond.end339.us.us.i\r\n br label %cond.end354.us.us.i\r\n\r\ncond.end339.us.us.i.if.then357.us.us.i_crit_edge: ; preds = %cond.end339.us.us.i\r\n br label %if.then357.us.us.i\r\n\r\ncond.end354.us.us.i: ; preds = %cond.end339.us.us.i.cond.end354.us.us.i_crit_edge, %for.body326.us.us.i\r\n br i1 false, label %cond.end354.us.us.i.if.then357.us.us.i_crit_edge, label %if.end559.us.us.i\r\n\r\ncond.end354.us.us.i.if.then357.us.us.i_crit_edge: ; preds = %cond.end354.us.us.i\r\n br label %if.then357.us.us.i\r\n\r\nif.then357.us.us.i: ; preds = %cond.end354.us.us.i.if.then357.us.us.i_crit_edge, %cond.end339.us.us.i.if.then357.us.us.i_crit_edge\r\n %.pre1143.i7 = phi i64 [ poison, %cond.end339.us.us.i.if.then357.us.us.i_crit_edge ], [ %indvars.iv18, %cond.end354.us.us.i.if.then357.us.us.i_crit_edge ]\r\n %arrayidx429.us.us.i = getelementptr [14 x i16], ptr null, i64 0, i64 %.pre1143.i7\r\n store i16 0, ptr %arrayidx429.us.us.i, align 2\r\n br label %if.end559.us.us.i\r\n\r\nif.end559.us.us.i: ; preds = %if.then357.us.us.i, %cond.end354.us.us.i\r\n %indvars.iv.next19 = add i64 %indvars.iv18, 1\r\n %0 = trunc i64 %indvars.iv18 to i32\r\n %cmp323.us.us.i = icmp slt i32 %0, 1\r\n br i1 %cmp323.us.us.i, label %for.body326.us.us.i, label %for.body300.us.us.i\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl256b,+zvl32b,+zvl64b,-e,-experimental-smmpm,-experimental-smnpm,-experimental-ssnpm,-experimental-sspm,-experimental-ssqosid,-experimental-supm,-experimental-zaamo,-experimental-zabha,-experimental-zalasr,-experimental-zalrsc,-experimental-zcmop,-experimental-zfbfmin,-experimental-zicfilp,-experimental-zicfiss,-experimental-zimop,-experimental-ztso,-experimental-zvfbfmin,-experimental-zvfbfwma,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smepmp,-ssaia,-ssccptr,-sscofpmf,-sscounterenw,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-za128rs,-za64rs,-zacas,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmp,-zcmt,-zdinx,-zfa,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-zmmul,-zvbb,-zvbc,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\n```\r\n\r\nBacktrace:\r\n```\r\nopt: /scratch/tc-testing/tc-apr-2/llvm/llvm/lib/Transforms/Vectorize/VPlan.h:1131: bool llvm::VPRecipeWithIRFlags::isDisjoint() const: Assertion `OpType == OperationType::DisjointOp && \"recipe cannot have a disjoing flag\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt reduced.ll --passes=loop-vectorize\r\n #0 0x00005bd204995b60 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2d84b60)\r\n #1 0x00005bd204992f6f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2d81f6f)\r\n #2 0x00005bd2049930c5 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x000076eef1a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x000076eef1a969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x000076eef1a969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x000076eef1a969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x000076eef1a42476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x000076eef1a287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x000076eef1a2871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x000076eef1a39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x00005bd203b25ea2 llvm::VPlanTransforms::dropPoisonGeneratingRecipes(llvm::VPlan&, llvm::function_ref<bool (llvm::BasicBlock*)>)::'lambda'(llvm::VPRecipeBase*)::operator()(llvm::VPRecipeBase*) const VPlanTransforms.cpp:0:0\r\n#12 0x00005bd203b2c77d llvm::VPlanTransforms::dropPoisonGeneratingRecipes(llvm::VPlan&, llvm::function_ref<bool (llvm::BasicBlock*)>) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1f1b77d)\r\n#13 0x00005bd203a05435 llvm::LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(llvm::VFRange&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1df4435)\r\n#14 0x00005bd203a05c9e llvm::LoopVectorizationPlanner::buildVPlansWithVPRecipes(llvm::ElementCount, llvm::ElementCount) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1df4c9e)\r\n#15 0x00005bd203a0c319 llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1dfb319)\r\n#16 0x00005bd203a0f8a9 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1dfe8a9)\r\n#17 0x00005bd203a1273e llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1e0173e)\r\n#18 0x00005bd203a1388d llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1e0288d)\r\n#19 0x00005bd20291a276 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0xd09276)\r\n#20 0x00005bd2047bc141 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2bab141)\r\n#21 0x00005bd202911bd6 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/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0xd00bd6)\r\n#22 0x00005bd2047bae3b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2ba9e3b)\r\n#23 0x00005bd202919dc6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0xd08dc6)\r\n#24 0x00005bd2047b8cb1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2ba7cb1)\r\n#25 0x00005bd202193ce5 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) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x582ce5)\r\n#26 0x00005bd202186316 optMain (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x575316)\r\n#27 0x000076eef1a29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#28 0x000076eef1a29e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#29 0x000076eef1a29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#30 0x00005bd20217bf95 _start (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x56af95)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt reduced.l\r\n```\r\n\r\nGodbolt: https://godbolt.org/z/jj39h3z7M\r\n\r\nMinor spelling nit: `disjoing -> disjoint`\r\n\r\nFound via fuzzer.\r\n\r\nLikely caused/exposed by https://github.com/llvm/llvm-project/commit/6ef829941b38f7e8a28c4cba1ff25cd0ae9f7d3d https://github.com/llvm/llvm-project/pull/83821 @fhahn ", "author": "patrick-rivos", "labels": [ "vectorizers", "crash" ], "comments": [] }
true
null
131818
https://github.com/llvm/llvm-project/issues/131818
crash
84909d797782a0dcf240f79a8e5e863d8165c03f
2025-03-18T15:06:59
[ "llvm/test/Transforms/SLPVectorizer" ]
{ "fix_commit": "45090b3059562b32723cd25679db75d1574ab04e", "components": [ "SLPVectorizer" ], "bug_location_lineno": { "llvm/include/llvm/Analysis/MemorySSAUpdater.h": null, "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [ [ 14086, 14096 ] ], "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/include/llvm/IR/Instruction.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null, "llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/include/llvm/IR/CmpPredicate.h": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanValue.h": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/include/llvm/Analysis/ScalarEvolution.h": null, "llvm/lib/Analysis/VectorUtils.cpp": null }, "bug_location_funcname": { "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [ "BoUpSLP::isGatherShuffledSingleRegisterEntry" ], "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/lib/Analysis/VectorUtils.cpp": null } }
commit 45090b3059562b32723cd25679db75d1574ab04e Author: Alexey Bataev <[email protected]> Date: Tue Mar 18 09:32:23 2025 -0700 [SLP]Check the whole def-use chain in the tree to find proper dominance, if the last instruction is the same If the insertion point (last instruction) of the user nodes is the same, need to check the whole def-use chain in the tree to find proper dominance to prevent a compiler crash. Fixes #131818 diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 24171f1d9a06..4a835bc797ab 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -14086,11 +14086,18 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry( auto CheckParentNodes = [&](const TreeEntry *User1, const TreeEntry *User2, unsigned EdgeIdx) { const TreeEntry *Ptr1 = User1; + const TreeEntry *Ptr2 = User2; + SmallDenseMap<const TreeEntry *, unsigned> PtrToIdx; + while (Ptr2) { + PtrToIdx.try_emplace(Ptr2, EdgeIdx); + EdgeIdx = Ptr2->UserTreeIndex.EdgeIdx; + Ptr2 = Ptr2->UserTreeIndex.UserTE; + } while (Ptr1) { unsigned Idx = Ptr1->UserTreeIndex.EdgeIdx; Ptr1 = Ptr1->UserTreeIndex.UserTE; - if (Ptr1 == User2) - return Idx < EdgeIdx; + if (auto It = PtrToIdx.find(Ptr1); It != PtrToIdx.end()) + return Idx < It->second; } return false; };
[ { "file": "llvm/test/Transforms/SLPVectorizer/X86/same-last-instruction-different-parents.ll", "commands": [ "opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s" ], "tests": [ { "test_name": "<module>", "test_body": "\ndefine i32 @test(i32 %0, i1 %1) {\n;\n %3 = sitofp i32 %0 to double\n %4 = sitofp i32 %0 to double\n %5 = sitofp i32 %0 to double\n br i1 %1, label %6, label %9\n\n6:\n %7 = tail call double @llvm.fmuladd.f64(double %4, double 0.000000e+00, double 0.000000e+00)\n %8 = tail call double @llvm.fmuladd.f64(double %5, double 0.000000e+00, double 0.000000e+00)\n br label %18\n\n9:\n br i1 false, label %15, label %10\n\n10:\n %11 = call double @llvm.copysign.f64(double 0.000000e+00, double %3)\n %12 = tail call double @llvm.fmuladd.f64(double %11, double %4, double 0.000000e+00)\n %13 = call double @llvm.copysign.f64(double 0.000000e+00, double %5)\n %14 = tail call double @llvm.fmuladd.f64(double %13, double 0.000000e+00, double 0.000000e+00)\n br label %15\n\n15:\n %16 = phi double [ %12, %10 ], [ 0.000000e+00, %9 ]\n %17 = phi double [ %14, %10 ], [ 0.000000e+00, %9 ]\n br label %18\n\n18:\n %19 = phi double [ %17, %15 ], [ %8, %6 ]\n %20 = phi double [ %16, %15 ], [ %7, %6 ]\n %21 = fmul double %20, %19\n %22 = fptosi double %21 to i32\n ret i32 %22\n}", "additional_args": null, "lli_expected_out": null } ] } ]
{ "title": "[clang] Crash at -O3: Instruction does not dominate all uses!", "body": "This code crashes at `-O3`:\n\n```c\nint a;\ndouble b;\nlong c;\nint d(long f, long g) {\n if (f + g)\n return 1;\n for (long e = 0; e < g; e++)\n *(char *)e = 5;\n return 0;\n}\nint h(int f) {\n double i = 0.270112271089232341485679099e4;\n b = 0.1e1;\n for (; c; c--) {\n i = i * (80 + f) * (9 + f) + a;\n a = 0;\n b = b * f * (d(-42, f) + f) + 0.11623987080032122878585294e22;\n }\n return i / b;\n}\nvoid main() {}\n```\n\nCompiler Explorer: https://godbolt.org/z/b4YEsPMrq\n\nBisected to https://github.com/llvm/llvm-project/commit/d57884011e8c57b118b831614b692ba4bc8b5aca, which was committed by @alexey-bataev \n\nCrash:\n\n```console\nInstruction does not dominate all uses!\n %3 = insertelement <2 x i32> %2, i32 %f, i64 1\n %0 = insertelement <2 x i32> %3, i32 %add1, i64 0\nin function h\nfatal error: error in backend: Broken function found, compilation aborted!\n```\n\nBacktrace:\n\n```console\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O3 -Wall -Wextra <source>\n1.\t<eof> parser at end of file\n2.\tCode generation\n3.\tRunning pass 'Function Pass Manager' on module '<source>'.\n4.\tRunning pass 'Module Verifier' on function '@h'\n #0 0x0000000003e87c38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e87c38)\n #1 0x0000000003e858c4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e858c4)\n #2 0x0000000003dcacb6 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dcacb6)\n #3 0x0000000003e7cfee llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e7cfee)\n #4 0x0000000000d4e5a0 LLVMErrorHandler(void*, char const*, bool) cc1_main.cpp:0:0\n #5 0x0000000003dd5443 llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dd5443)\n #6 0x0000000003dd55a8 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dd55a8)\n #7 0x0000000003887952 (anonymous namespace)::VerifierLegacyPass::runOnFunction(llvm::Function&) Verifier.cpp:0:0\n #8 0x00000000037d28df llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x37d28df)\n #9 0x00000000037d2c91 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x37d2c91)\n#10 0x00000000037d3531 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x37d3531)\n#11 0x000000000413d67e clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x413d67e)\n#12 0x00000000048429a0 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x48429a0)\n#13 0x00000000064aecac clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x64aecac)\n#14 0x0000000004842da8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4842da8)\n#15 0x0000000004b127f5 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4b127f5)\n#16 0x0000000004a94a2e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4a94a2e)\n#17 0x0000000004c024fe clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4c024fe)\n#18 0x0000000000d50baf cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd50baf)\n#19 0x0000000000d4836a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#20 0x000000000488b309 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0\n#21 0x0000000003dcabf4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dcabf4)\n#22 0x000000000488b91f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0\n#23 0x000000000484e38d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x484e38d)\n#24 0x000000000484f41e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x484f41e)\n#25 0x0000000004856af5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4856af5)\n#26 0x0000000000d4d9a8 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd4d9a8)\n#27 0x0000000000c146c4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc146c4)\n#28 0x00007acc03029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#29 0x00007acc03029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#30 0x0000000000d47e15 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd47e15)\n```", "author": "cardigan1008", "labels": [ "llvm:SLPVectorizer", "crash-on-valid" ], "comments": [] }
true
null
104714
https://github.com/llvm/llvm-project/issues/104714
crash
a2d8743cc86f96f6b1cbd85798328bd3fb2bf4de
2024-08-18T15:54:27
[ "llvm/test/Transforms/LoopVectorize" ]
{ "fix_commit": "cb4efe1d078144a72306732a56afea3885650e8d", "components": [ "LoopVectorize" ], "bug_location_lineno": { "llvm/include/llvm/Analysis/MemorySSAUpdater.h": null, "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [ [ 7237, 7242 ], [ 7292, 7298 ] ], "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/include/llvm/IR/Instruction.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null, "llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/include/llvm/IR/CmpPredicate.h": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanValue.h": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/include/llvm/Analysis/ScalarEvolution.h": null, "llvm/lib/Analysis/VectorUtils.cpp": null }, "bug_location_funcname": { "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [ "LoopVectorizationPlanner::computeBestVF", "LoopVectorizationPlanner::cost" ], "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/lib/Analysis/VectorUtils.cpp": null } }
commit cb4efe1d078144a72306732a56afea3885650e8d Author: Florian Hahn <[email protected]> Date: Thu Aug 22 21:38:06 2024 +0100 [VPlan] Don't trigger VF assertion if VPlan has extra simplifications. There are cases where VPlans contain some simplifications that are very hard to accurately account for up-front in the legacy cost model. Those cases are caused by un-simplified inputs, which trigger the assert ensuring both the legacy and VPlan-based cost model agree on the VF. To avoid false positives due to missed simplifications in general, only trigger the assert if the chosen VPlan doesn't contain any additional simplifications. Fixes https://github.com/llvm/llvm-project/issues/104714. Fixes https://github.com/llvm/llvm-project/issues/105713. diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 8e9324ba718b..32e8f3312578 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -7237,6 +7237,56 @@ InstructionCost LoopVectorizationPlanner::cost(VPlan &Plan, return Cost; } +/// Return true if the original loop \ TheLoop contains any instructions that do +/// not have corresponding recipes in \p Plan and are not marked to be ignored +/// in \p CostCtx. This means the VPlan contains simplification that the legacy +/// cost-model did not account for. +static bool +planContainsAdditionalSimplifications(VPlan &Plan, ElementCount VF, + VPCostContext &CostCtx, Loop *TheLoop, + LoopVectorizationCostModel &CM) { + // First collect all instructions for the recipes in Plan. + auto GetInstructionForCost = [](const VPRecipeBase *R) -> Instruction * { + if (auto *S = dyn_cast<VPSingleDefRecipe>(R)) + return dyn_cast_or_null<Instruction>(S->getUnderlyingValue()); + if (auto *WidenMem = dyn_cast<VPWidenMemoryRecipe>(R)) + return &WidenMem->getIngredient(); + return nullptr; + }; + + DenseSet<Instruction *> SeenInstrs; + auto Iter = vp_depth_first_deep(Plan.getEntry()); + for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(Iter)) { + for (VPRecipeBase &R : *VPBB) { + if (auto *IR = dyn_cast<VPInterleaveRecipe>(&R)) { + auto *IG = IR->getInterleaveGroup(); + unsigned NumMembers = IG->getNumMembers(); + for (unsigned I = 0; I != NumMembers; ++I) { + if (Instruction *M = IG->getMember(I)) + SeenInstrs.insert(M); + } + continue; + } + if (Instruction *UI = GetInstructionForCost(&R)) + SeenInstrs.insert(UI); + } + } + + // Return true if the loop contains any instructions that are not also part of + // the VPlan or are skipped for VPlan-based cost computations. This indicates + // that the VPlan contains extra simplifications. + return any_of( + TheLoop->blocks(), [&SeenInstrs, VF, &CostCtx, &CM](BasicBlock *BB) { + return any_of(*BB, [&SeenInstrs, VF, &CostCtx, &CM](Instruction &I) { + if (isa<PHINode>(&I)) + return false; + return !SeenInstrs.contains(&I) && + !CostCtx.skipCostComputation(&I, true) && + !CM.canTruncateToMinimalBitwidth(&I, VF); + }); + }); +} + VectorizationFactor LoopVectorizationPlanner::computeBestVF() { if (VPlans.empty()) return VectorizationFactor::Disabled(); @@ -7292,7 +7342,20 @@ VectorizationFactor LoopVectorizationPlanner::computeBestVF() { // cost-model and will be retired once the VPlan-based cost-model is // stabilized. VectorizationFactor LegacyVF = selectVectorizationFactor(); - assert(BestFactor.Width == LegacyVF.Width && + VPlan &BestPlan = getPlanFor(BestFactor.Width); + + // Pre-compute the cost and use it to check if BestPlan contains any + // simplifications not accounted for in the legacy cost model. If that's the + // case, don't trigger the assertion, as the extra simplifications may cause a + // different VF to be picked by the VPlan-based cost model. + LLVMContext &LLVMCtx = OrigLoop->getHeader()->getContext(); + VPCostContext CostCtx(CM.TTI, *CM.TLI, Legal->getWidestInductionType(), + LLVMCtx, CM); + precomputeCosts(BestPlan, BestFactor.Width, CostCtx); + assert((BestFactor.Width == LegacyVF.Width || + planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), + BestFactor.Width, CostCtx, + OrigLoop, CM)) && " VPlan cost model and legacy cost model disagreed"); assert((BestFactor.Width.isScalar() || BestFactor.ScalarCost > 0) && "when vectorizing, the scalar cost must be computed.");
[ { "file": "llvm/test/Transforms/LoopVectorize/RISCV/blocks-with-dead-instructions.ll", "commands": [ "opt -p loop-vectorize -S %s" ], "tests": [ { "test_name": "empty_block_with_phi_2", "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @empty_block_with_phi_2(ptr %src, i64 %N) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i32 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i32 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %loop.latch, label %else\n\nelse: ; preds = %loop.header\n br label %loop.latch\n\nloop.latch: ; preds = %else, %loop.header\n %p = phi i16 [ %l, %loop.header ], [ 99, %else ]\n store i16 %p, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 1\n %0 = icmp eq i64 %iv.next, %N\n br i1 %0, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n", "additional_args": null, "lli_expected_out": null }, { "test_name": "dead_load_in_block", "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @dead_load_in_block(ptr %dst, ptr %src, i8 %N, i64 %x) #0 {\nentry:\n %N.ext = zext i8 %N to i64\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %l.0 = load i32, ptr %src, align 4\n %c.0 = icmp eq i32 %l.0, 0\n br i1 %c.0, label %loop.latch, label %then\n\nthen: ; preds = %loop.header\n %gep.src.x = getelementptr i32, ptr %src, i64 %x\n %l.dead = load i32, ptr %gep.src.x, align 4\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n %gep.dst = getelementptr i32, ptr %dst, i64 %iv\n store i32 0, ptr %gep.dst, align 4\n %iv.next = add i64 %iv, 3\n %cmp = icmp ult i64 %iv, %N.ext\n br i1 %cmp, label %loop.header, label %exit\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n", "additional_args": null, "lli_expected_out": null }, { "test_name": "multiple_blocks_with_dead_insts_3", "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @multiple_blocks_with_dead_insts_3(ptr %src) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 0, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %else\n\nthen: ; preds = %loop.header\n %dead.gep.1 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nelse: ; preds = %loop.header\n %dead.gep.2 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %else, %then\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %ec = icmp eq i64 %iv.next, 1000\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n", "additional_args": null, "lli_expected_out": null }, { "test_name": "multiple_blocks_with_dead_insts_4", "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @multiple_blocks_with_dead_insts_4(ptr %src, i64 %N) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %else\n\nthen: ; preds = %loop.header\n br label %then.1\n\nthen.1: ; preds = %then\n %dead.gep.1 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nelse: ; preds = %loop.header\n %dead.gep.2 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %else, %then.1\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %ec = icmp eq i64 %iv.next, %N\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n", "additional_args": null, "lli_expected_out": null }, { "test_name": "empty_block_with_phi_1", "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @empty_block_with_phi_1(ptr %src, i64 %N) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i32 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i32 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %loop.latch\n\nthen: ; preds = %loop.header\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n %p = phi i16 [ %l, %loop.header ], [ 99, %then ]\n store i16 %p, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 1\n %0 = icmp eq i64 %iv.next, %N\n br i1 %0, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n", "additional_args": null, "lli_expected_out": null }, { "test_name": "block_with_dead_inst_2", "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @block_with_dead_inst_2(ptr %src) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 0, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %loop.latch, label %else\n\nelse: ; preds = %loop.header\n %dead.gep = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %else, %loop.header\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %ec = icmp eq i64 %iv.next, 1000\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n", "additional_args": null, "lli_expected_out": null }, { "test_name": "multiple_blocks_with_dead_inst_multiple_successors_6", "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @multiple_blocks_with_dead_inst_multiple_successors_6(ptr %src, i1 %ic, i64 %N) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %else\n\nthen: ; preds = %loop.header\n br i1 %ic, label %then.1, label %else\n\nthen.1: ; preds = %then\n %dead.gep.1 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nelse: ; preds = %then, %loop.header\n br label %else.2\n\nelse.2: ; preds = %else\n %dead.gep.2 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %else.2, %then.1\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %ec = icmp eq i64 %iv.next, %N\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n", "additional_args": null, "lli_expected_out": null }, { "test_name": "multiple_blocks_with_dead_inst_multiple_successors_5", "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @multiple_blocks_with_dead_inst_multiple_successors_5(ptr %src) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %else\n\nthen: ; preds = %loop.header\n br label %then.1\n\nthen.1: ; preds = %then\n %dead.gep.1 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nelse: ; preds = %loop.header\n br label %else.2\n\nelse.2: ; preds = %else\n %dead.gep.2 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %else.2, %then.1\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %ec = icmp eq i64 %iv.next, 1000\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n", "additional_args": null, "lli_expected_out": null }, { "test_name": "block_with_dead_inst_1", "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @block_with_dead_inst_1(ptr %src, i64 %N) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %loop.latch\n\nthen: ; preds = %loop.header\n %dead.gep = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %0 = icmp eq i64 %iv.next, %N\n br i1 %0, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n", "additional_args": null, "lli_expected_out": null } ] } ]
{ "title": "[VPlan] Assertion `VF.Width == BestVF && \"VPlan cost model and legacy cost model disagreed\"' failed.", "body": "Tested using d082f1f37d8cb7a0c6875537ba873a631b154d53\r\n\r\nC Testcase:\r\n```c\r\nint a;\r\nextern int b[];\r\nsigned char c;\r\nint d[1];\r\nvoid e() {\r\n for (short f = 2; f < c; f += 3) {\r\n a = ({ d[f - 1]; }) ? d[f] : 0;\r\n b[f] = 0;\r\n }\r\n}\r\n```\r\nCommand:\r\n```\r\n/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/clang -march=rv64gcv_zvl256b -O3 red.c -o /dev/null\r\n```\r\n\r\nTestcase:\r\n```llvm ir\r\n; ModuleID = 'reduced.bc'\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine void @e(i8 %0, i64 %indvars.iv) #0 {\r\nentry:\r\n %1 = zext i8 %0 to i64\r\n br label %for.body\r\n\r\nfor.cond.for.cond.cleanup_crit_edge: ; preds = %cond.end\r\n ret void\r\n\r\nfor.body: ; preds = %cond.end, %entry\r\n %indvars.iv1 = phi i64 [ 0, %entry ], [ %indvars.iv.next, %cond.end ]\r\n %sub = add i64 0, 0\r\n %arrayidx = getelementptr [1 x i32], ptr null, i64 0, i64 %sub\r\n %2 = load i32, ptr %arrayidx, align 4\r\n %tobool.not = icmp eq i32 %2, 0\r\n br i1 %tobool.not, label %cond.end, label %cond.true\r\n\r\ncond.true: ; preds = %for.body\r\n %arrayidx5 = getelementptr [1 x i32], ptr null, i64 0, i64 %indvars.iv\r\n %3 = load i32, ptr %arrayidx5, align 4\r\n br label %cond.end\r\n\r\ncond.end: ; preds = %cond.true, %for.body\r\n %arrayidx7 = getelementptr [0 x i32], ptr null, i64 0, i64 %indvars.iv1\r\n store i32 0, ptr %arrayidx7, align 4\r\n %indvars.iv.next = add i64 %indvars.iv1, 3\r\n %cmp = icmp ult i64 %indvars.iv1, %1\r\n br i1 %cmp, label %for.body, label %for.cond.for.cond.cleanup_crit_edge\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl256b,+zvl32b,+zvl64b,-b,-e,-experimental-smmpm,-experimental-smnpm,-experimental-ssnpm,-experimental-sspm,-experimental-ssqosid,-experimental-supm,-experimental-zacas,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\n```\r\n\r\nCommand/backtrace:\r\n```\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes loop-vectorize reduced.ll -S\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10037: bool llvm::LoopVectorizePass::processLoop(llvm::Loop*): Assertion `VF.Width == BestVF && \"VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes loop-vectorize reduced.ll -S\r\n1. Running pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"reduced.ll\"\r\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"e\"\r\n #0 0x000063e889a673c0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2ff63c0)\r\n #1 0x000063e889a647df llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2ff37df)\r\n #2 0x000063e889a64935 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007a5322242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007a53222969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007a53222969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007a53222969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x00007a5322242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007a53222287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x00007a532222871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x00007a5322239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x000063e888a5ba9a llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1feaa9a)\r\n#12 0x000063e888a5df51 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1fecf51)\r\n#13 0x000063e888a5e5c7 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1fed5c7)\r\n#14 0x000063e8878c6096 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe55096)\r\n#15 0x000063e88987deef llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e0ceef)\r\n#16 0x000063e8878c91d6 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/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe581d6)\r\n#17 0x000063e88987cc6b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e0bc6b)\r\n#18 0x000063e8878c54c6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe544c6)\r\n#19 0x000063e88987accd llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e09ccd)\r\n#20 0x000063e8870f3eb6 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) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x682eb6)\r\n#21 0x000063e8870e5c41 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x674c41)\r\n#22 0x00007a5322229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#23 0x00007a5322229e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#24 0x00007a5322229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#25 0x000063e8870dbff5 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x66aff5)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\nGodbolt: https://godbolt.org/z/v1nbzWqMb\r\n\r\nFound via fuzzer.\r\n\r\ncc @fhahn ", "author": "patrick-rivos", "labels": [ "vectorizers", "crash" ], "comments": [ { "author": "patrick-rivos", "body": "Linking some meta-discussion about the assert here: https://github.com/llvm/llvm-project/issues/100591" }, { "author": "zhendongsu", "body": "Some additional reproducers on x86_64-linux-gnu in case they are of help:\r\n\r\n```\r\n[519] % clangtk -v\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git 410f751144e8b2e9574f03e0d0fb8560fe3cb797)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\r\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nCandidate multilib: .;@m64\r\nSelected multilib: .;@m64\r\n[520] % \r\n[520] % clangtk -Os small.c\r\nclang-20: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7288: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `BestFactor.Width == LegacyVF.Width && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/WAIT/20240822-clangtk-m64-Os-Wall-Wextra-pipe-fPIC-build-182745/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/WAIT/20240822-clangtk-m64-Os-Wall-Wextra-pipe-fPIC-build-182745/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/20 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Os -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-e51115.o -x c small.c\r\n1.\t<eof> parser at end of file\r\n2.\tOptimizer\r\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"small.c\"\r\n4.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\r\n #0 0x00005559685ec3ef llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x42ea3ef)\r\n #1 0x00005559685e9934 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007f0380f76420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #3 0x00007f03809ad00b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #4 0x00007f038098c859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\r\n #5 0x00007f038098c729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #6 0x00007f038098c729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #7 0x00007f038099dfd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #8 0x0000555969ef4948 llvm::LoopVectorizationPlanner::computeBestVF() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5bf2948)\r\n #9 0x0000555969f0f9ea llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c0d9ea)\r\n#10 0x0000555969f12691 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c10691)\r\n#11 0x0000555969f12d43 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c10d43)\r\n#12 0x0000555969a9d326 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x579b326)\r\n#13 0x0000555967f872a1 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c852a1)\r\n#14 0x0000555965ae2ae6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x17e0ae6)\r\n#15 0x0000555967f85bed llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c83bed)\r\n#16 0x0000555965ae19e6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x17df9e6)\r\n#17 0x0000555967f83cf1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c81cf1)\r\n#18 0x00005559688a0c29 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#19 0x00005559688a3d83 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x45a1d83)\r\n#20 0x0000555968f440fa clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4c420fa)\r\n#21 0x000055596ad8938c clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x6a8738c)\r\n#22 0x0000555968f44598 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4c42598)\r\n#23 0x00005559691dec59 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4edcc59)\r\n#24 0x00005559691603be clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4e5e3be)\r\n#25 0x00005559692cb886 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4fc9886)\r\n#26 0x00005559656b5dd5 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13b3dd5)\r\n#27 0x00005559656aee7a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#28 0x00005559656b284e clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13b084e)\r\n#29 0x00005559655a31bb main (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x12a11bb)\r\n#30 0x00007f038098e083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#31 0x00005559656ae90e _start (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13ac90e)\r\nclangtk: error: unable to execute command: Aborted\r\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git 410f751144e8b2e9574f03e0d0fb8560fe3cb797)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nclangtk: note: diagnostic msg: \r\n********************\r\n\r\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\r\nPreprocessed source(s) and associated run script(s) are located at:\r\nclangtk: note: diagnostic msg: /tmp/small-1b0f28.c\r\nclangtk: note: diagnostic msg: /tmp/small-1b0f28.sh\r\nclangtk: note: diagnostic msg: \r\n\r\n********************\r\n[521] % \r\n[521] % cat small.c\r\nchar a;\r\nint b, *c = &b, d[3], e;\r\nint main() {\r\n int f, g[3] = {0,0,0};\r\n g[e] = *c = 0;\r\n for (; *c < 3; (*c)++) {\r\n f = a ? b % a : 0;\r\n g[2] &= d[*c] & f;\r\n }\r\n return 0;\r\n}\r\n```\r\n\r\n```\r\n[537] % clangtk -O3 small.c\r\nclang-20: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7288: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `BestFactor.Width == LegacyVF.Width && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/WAIT/20240814-clangtk-m64-O3-build-085604/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/WAIT/20240814-clangtk-m64-O3-build-085604/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/20 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-83d1cf.o -x c small.c\r\n1.\t<eof> parser at end of file\r\n2.\tOptimizer\r\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,chr,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"small.c\"\r\n4.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\r\n #0 0x0000558427a123ef llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x42ea3ef)\r\n #1 0x0000558427a0f934 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007fa32f70a420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #3 0x00007fa32f14100b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #4 0x00007fa32f120859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\r\n #5 0x00007fa32f120729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #6 0x00007fa32f120729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #7 0x00007fa32f131fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #8 0x000055842931a948 llvm::LoopVectorizationPlanner::computeBestVF() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5bf2948)\r\n #9 0x00005584293359ea llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c0d9ea)\r\n#10 0x0000558429338691 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c10691)\r\n#11 0x0000558429338d43 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c10d43)\r\n#12 0x0000558428ec3326 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x579b326)\r\n#13 0x00005584273ad2a1 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c852a1)\r\n#14 0x0000558424f08ae6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x17e0ae6)\r\n#15 0x00005584273abbed llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c83bed)\r\n#16 0x0000558424f079e6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x17df9e6)\r\n#17 0x00005584273a9cf1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c81cf1)\r\n#18 0x0000558427cc6c29 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#19 0x0000558427cc9d83 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x45a1d83)\r\n#20 0x000055842836a0fa clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4c420fa)\r\n#21 0x000055842a1af38c clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x6a8738c)\r\n#22 0x000055842836a598 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4c42598)\r\n#23 0x0000558428604c59 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4edcc59)\r\n#24 0x00005584285863be clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4e5e3be)\r\n#25 0x00005584286f1886 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4fc9886)\r\n#26 0x0000558424adbdd5 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13b3dd5)\r\n#27 0x0000558424ad4e7a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#28 0x0000558424ad884e clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13b084e)\r\n#29 0x00005584249c91bb main (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x12a11bb)\r\n#30 0x00007fa32f122083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#31 0x0000558424ad490e _start (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13ac90e)\r\nclangtk: error: unable to execute command: Aborted\r\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git 410f751144e8b2e9574f03e0d0fb8560fe3cb797)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nclangtk: note: diagnostic msg: \r\n********************\r\n\r\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\r\nPreprocessed source(s) and associated run script(s) are located at:\r\nclangtk: note: diagnostic msg: /tmp/small-aeee73.c\r\nclangtk: note: diagnostic msg: /tmp/small-aeee73.sh\r\nclangtk: note: diagnostic msg: \r\n\r\n********************\r\n[538] % \r\n[538] % cat small.c\r\nint a[1], *d, e, f[1];\r\nstatic int b, c, *volatile g = &c;\r\nvoid h(int i) { b = b >> 1 ^ a[b ^ i & 1]; }\r\nvoid j(long i) {\r\n b = b >> 1 ^ b;\r\n b = b >> 1 ^ a[b ^ 1];\r\n h(i >> 1);\r\n h(i >> 3);\r\n h(i >> 2);\r\n h(i >> 4);\r\n h(i >> 5);\r\n}\r\nstatic void m() {\r\n int l;\r\n while (e) {\r\n c = 0;\r\n for (; c < 5; c++) {\r\n l = 0;\r\n for (; l < 7; l++)\r\n if (*d)\r\n j(f[c * l]);\r\n }\r\n }\r\n}\r\nint main() {\r\n if (e) {\r\n m();\r\n g;\r\n }\r\n return 0;\r\n}\r\n```\r\n" }, { "author": "fhahn", "body": "@zhendongsu thanks for the report, it was the same issue as the test case @sjoerdmeijer shared at https://github.com/llvm/llvm-project/issues/100591, which was a different underlying issue to the one for this issue.\r\n\r\nBoth should be fixed now, please let me know if you find any other instances of this triggering." }, { "author": "zhendongsu", "body": "Hi @fhahn, here is another related instance that still triggers:\r\n```\r\n[512] % clangtk -v\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git f22b1da8791edd557ce34c87190e329df2e1c892)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\r\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nCandidate multilib: .;@m64\r\nSelected multilib: .;@m64\r\n[513] % \r\n[513] % clangtk -Os small.c\r\nclang-20: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7359: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), BestFactor.Width, CostCtx, OrigLoop, CM)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/20240825-clangtk-m64-Os-Wall-Wextra-pipe-fPIC-build-043108/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20240825-clangtk-m64-Os-Wall-Wextra-pipe-fPIC-build-043108/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/20 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Os -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-d7ba19.o -x c small.c\r\n1.\t<eof> parser at end of file\r\n2.\tOptimizer\r\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"small.c\"\r\n4.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\r\n #0 0x0000564ef7a4babf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x42ddabf)\r\n #1 0x0000564ef7a49004 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007f89634f9420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #3 0x00007f8962f3000b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #4 0x00007f8962f0f859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\r\n #5 0x00007f8962f0f729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #6 0x00007f8962f0f729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #7 0x00007f8962f20fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #8 0x0000564ef9358b42 llvm::LoopVectorizationPlanner::computeBestVF() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5beab42)\r\n #9 0x0000564ef937504a llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c0704a)\r\n#10 0x0000564ef9377c81 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c09c81)\r\n#11 0x0000564ef9378333 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c0a333)\r\n#12 0x0000564ef8f026e6 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x57946e6)\r\n#13 0x0000564ef73e68d1 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c788d1)\r\n#14 0x0000564ef4f4ff46 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x17e1f46)\r\n#15 0x0000564ef73e521d llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c7721d)\r\n#16 0x0000564ef4f4ee46 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x17e0e46)\r\n#17 0x0000564ef73e3321 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c75321)\r\n#18 0x0000564ef7d04bb1 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#19 0x0000564ef7d07d73 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4599d73)\r\n#20 0x0000564ef83a840c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4c3a40c)\r\n#21 0x0000564efa1f004c clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x6a8204c)\r\n#22 0x0000564ef83a8828 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4c3a828)\r\n#23 0x0000564ef8643cb9 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4ed5cb9)\r\n#24 0x0000564ef85c543e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4e5743e)\r\n#25 0x0000564ef8730876 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4fc2876)\r\n#26 0x0000564ef4b21e55 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13b3e55)\r\n#27 0x0000564ef4b1aefa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#28 0x0000564ef4b1e8ce clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13b08ce)\r\n#29 0x0000564ef4a0f1bb main (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x12a11bb)\r\n#30 0x00007f8962f11083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#31 0x0000564ef4b1a98e _start (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13ac98e)\r\nclangtk: error: unable to execute command: Aborted\r\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git f22b1da8791edd557ce34c87190e329df2e1c892)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nclangtk: note: diagnostic msg: \r\n********************\r\n\r\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\r\nPreprocessed source(s) and associated run script(s) are located at:\r\nclangtk: note: diagnostic msg: /tmp/small-6fc973.c\r\nclangtk: note: diagnostic msg: /tmp/small-6fc973.sh\r\nclangtk: note: diagnostic msg: \r\n\r\n********************\r\n[514] % \r\n[514] % cat small.c\r\nint a, d;\r\nstatic int b = 1, c;\r\nvoid e() {\r\n while (a)\r\n b--;\r\n}\r\nint main() {\r\n for (d = 0; d < 3; d++)\r\n if (a)\r\n for (c = 0; c < 2; c++)\r\n if (b)\r\n break;\r\n return 0;\r\n}\r\n```\r\n\r\nCompiler Explorer: https://godbolt.org/z/zanjboPYo" }, { "author": "zhendongsu", "body": "Hi @fhahn, another reproducer that triggers at -O{s,2,3}:\r\n```\r\n[520] % clangtk -v\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git 7e6b1504c7cf6976ac8e9012c4513ffa258bd8eb)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\r\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nCandidate multilib: .;@m64\r\nSelected multilib: .;@m64\r\n[521] % \r\n[521] % clangtk -O3 small.c\r\nclang-20: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7359: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), BestFactor.Width, CostCtx, OrigLoop, CM)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/20240826-clangtk-m64-Os-build-191303/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20240826-clangtk-m64-Os-build-191303/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/20 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-bd6e8d.o -x c small.c\r\n1.\t<eof> parser at end of file\r\n2.\tOptimizer\r\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,chr,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"small.c\"\r\n4.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\r\n #0 0x0000561e24237f5f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x42f4f5f)\r\n #1 0x0000561e242354a4 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007f7461dc8420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #3 0x00007f74617ff00b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #4 0x00007f74617de859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\r\n #5 0x00007f74617de729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #6 0x00007f74617de729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #7 0x00007f74617effd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #8 0x0000561e25b45232 llvm::LoopVectorizationPlanner::computeBestVF() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c02232)\r\n #9 0x0000561e25b616ca llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c1e6ca)\r\n#10 0x0000561e25b64301 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c21301)\r\n#11 0x0000561e25b649b3 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c219b3)\r\n#12 0x0000561e256ef0a6 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x57ac0a6)\r\n#13 0x0000561e23bd2da1 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c8fda1)\r\n#14 0x0000561e21724f86 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x17e1f86)\r\n#15 0x0000561e23bd16ed llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c8e6ed)\r\n#16 0x0000561e21723e86 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x17e0e86)\r\n#17 0x0000561e23bcf7f1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c8c7f1)\r\n#18 0x0000561e244f0f41 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#19 0x0000561e244f4103 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x45b1103)\r\n#20 0x0000561e24b9480c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4c5180c)\r\n#21 0x0000561e269dcc5c clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x6a99c5c)\r\n#22 0x0000561e24b94c28 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4c51c28)\r\n#23 0x0000561e24e30189 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4eed189)\r\n#24 0x0000561e24db162e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4e6e62e)\r\n#25 0x0000561e24f1cde6 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4fd9de6)\r\n#26 0x0000561e212f6ed5 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13b3ed5)\r\n#27 0x0000561e212eff7a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#28 0x0000561e212f394e clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13b094e)\r\n#29 0x0000561e211e41eb main (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x12a11eb)\r\n#30 0x00007f74617e0083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#31 0x0000561e212efa0e _start (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13aca0e)\r\nclangtk: error: unable to execute command: Aborted\r\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git 7e6b1504c7cf6976ac8e9012c4513ffa258bd8eb)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nclangtk: note: diagnostic msg: \r\n********************\r\n\r\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\r\nPreprocessed source(s) and associated run script(s) are located at:\r\nclangtk: note: diagnostic msg: /tmp/small-796071.c\r\nclangtk: note: diagnostic msg: /tmp/small-796071.sh\r\nclangtk: note: diagnostic msg: \r\n\r\n********************\r\n[522] % \r\n[522] % cat small.c\r\nchar a;\r\nstatic char b, *c = &b, **d = &c;\r\nint e;\r\nunsigned f;\r\nchar g(int h) { return a << h; }\r\nint main() {\r\n char ***i[2] = {&d, &d};\r\n int *j;\r\n for (; f < 3; f++) {\r\n j = &e;\r\n *j = g(**d);\r\n }\r\n return 0;\r\n}\r\n```\r\n\r\nCompiler Explorer: https://godbolt.org/z/7Y5PzTx4P" } ] }
true
null
128770
https://github.com/llvm/llvm-project/issues/128770
crash
7f482aa848c5f136d2b32431f91f88492c78c709
2025-02-25T20:34:44
[ "llvm/test/Transforms/SLPVectorizer" ]
{ "fix_commit": "418a9872851ef5342b29baa36dd672129f129953", "components": [ "SLPVectorizer" ], "bug_location_lineno": { "llvm/include/llvm/Analysis/MemorySSAUpdater.h": null, "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [ [ 13353, 13358 ], [ 13453, 13459 ] ], "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/include/llvm/IR/Instruction.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null, "llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/include/llvm/IR/CmpPredicate.h": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanValue.h": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/include/llvm/Analysis/ScalarEvolution.h": null, "llvm/lib/Analysis/VectorUtils.cpp": null }, "bug_location_funcname": { "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [ "BoUpSLP::isGatherShuffledSingleRegisterEntry" ], "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/lib/Analysis/VectorUtils.cpp": null } }
commit 418a9872851ef5342b29baa36dd672129f129953 Author: Alexey Bataev <[email protected]> Date: Wed Feb 26 12:59:27 2025 -0800 [SLP]Do not use node, if it is a subvector or buildvector node If the buildvector has some matches with another node, which is a subvector of another buildvector node, need to check for this and cancel matching to avoid incorrect ordering of the nodes. Fixes #128770 diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 02fea2eaf9d4..b25b09306aca 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -13353,6 +13353,14 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry( return EdgeInfo(const_cast<TreeEntry *>(TE), 0); return TE->UserTreeIndex; }; + auto HasGatherUser = [&](const TreeEntry *TE) { + while (TE->Idx != 0 && TE->UserTreeIndex) { + if (TE->UserTreeIndex.EdgeIdx == UINT_MAX) + return true; + TE = TE->UserTreeIndex.UserTE; + } + return false; + }; const EdgeInfo TEUseEI = GetUserEntry(TE); if (!TEUseEI) return std::nullopt; @@ -13453,7 +13461,8 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry( // If the user instruction is used for some reason in different // vectorized nodes - make it depend on index. if (TEUseEI.UserTE != UseEI.UserTE && - TEUseEI.UserTE->Idx < UseEI.UserTE->Idx) + (TEUseEI.UserTE->Idx < UseEI.UserTE->Idx || + HasGatherUser(TEUseEI.UserTE))) continue; }
[ { "file": "llvm/test/Transforms/SLPVectorizer/X86/buildvector-reused-with-bv-subvector.ll", "commands": [ "opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -mcpu=skylake < %s" ], "tests": [ { "test_name": "<module>", "test_body": "\ndefine void @test(ptr %0, i64 %1, i64 %2) {\n;\n %4 = ptrtoint ptr %0 to i64\n %5 = ptrtoint ptr %0 to i64\n %6 = ptrtoint ptr %0 to i64\n %7 = ptrtoint ptr %0 to i64\n %8 = ptrtoint ptr %0 to i64\n br label %.preheader.lr.ph\n\n.preheader.lr.ph:\n br label %.preheader.us.us.preheader\n\n.preheader.us.us.preheader:\n %9 = or i64 %1, %7\n %10 = or i64 %2, %7\n %11 = or i64 %1, %4\n %12 = or i64 %1, %8\n %13 = or i64 %5, %8\n %14 = or i64 %8, %4\n %15 = or i64 %5, %6\n %16 = or i64 %6, %4\n br label %.preheader.us.us\n\n.preheader.us.us:\n %diff.check1 = icmp ult i64 %9, 32\n %diff.check2 = icmp ult i64 %10, 32\n %conflict.rdx3 = or i1 %diff.check1, %diff.check2\n %diff.check4 = icmp ult i64 %11, 32\n %conflict.rdx5 = or i1 %conflict.rdx3, %diff.check4\n %diff.check6 = icmp ult i64 %12, 32\n %conflict.rdx7 = or i1 %conflict.rdx5, %diff.check6\n %diff.check8 = icmp ult i64 %13, 32\n %conflict.rdx9 = or i1 %conflict.rdx7, %diff.check8\n %diff.check10 = icmp ult i64 %14, 32\n %conflict.rdx11 = or i1 %conflict.rdx9, %diff.check10\n %diff.check12 = icmp ult i64 %15, 32\n %conflict.rdx13 = or i1 %conflict.rdx11, %diff.check12\n %diff.check14 = icmp ult i64 %16, 32\n %conflict.rdx15 = or i1 %conflict.rdx13, %diff.check14\n br i1 %conflict.rdx15, label %scalar.ph, label %.preheader.us.us\n\nscalar.ph:\n ret void\n}", "additional_args": null, "lli_expected_out": null } ] } ]
{ "title": "SLP: Instruction does not dominate all uses (insertelement/shufflevector)", "body": "[slp.ll.gz](https://github.com/user-attachments/files/18972113/slp.ll.gz)\n\nReproducer: `opt -passes=slp-vectorizer slp.ll -mcpu=skylake`\n\n@alexey-bataev can you please take a look?", "author": "vzakhari", "labels": [ "llvm:SLPVectorizer", "crash" ], "comments": [] }
true
null
93298
https://github.com/llvm/llvm-project/issues/93298
crash
f31b197d9df141effd439de8be51ce24f3e8f200
2024-05-24T12:01:44
[ "llvm/test/Transforms/DeadStoreElimination" ]
{ "fix_commit": "243ffbdf8b25285d04ee4393e86094312cb7c64f", "components": [ "DeadStoreElimination" ], "bug_location_lineno": { "llvm/include/llvm/Analysis/MemorySSAUpdater.h": null, "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": [ [ 2109, 2118 ] ], "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/include/llvm/IR/Instruction.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null, "llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/include/llvm/IR/CmpPredicate.h": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanValue.h": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/include/llvm/Analysis/ScalarEvolution.h": null, "llvm/lib/Analysis/VectorUtils.cpp": null }, "bug_location_funcname": { "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": [ "eliminateRedundantStoresOfExistingValues" ], "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/lib/Analysis/VectorUtils.cpp": null } }
commit 243ffbdf8b25285d04ee4393e86094312cb7c64f Author: eaeltsin <[email protected]> Date: Mon May 27 09:26:44 2024 +0200 [DSE] Check write location in IsRedundantStore (#93400) Fix https://github.com/llvm/llvm-project/issues/93298. diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp index ed4212d29cef..172cce2cfa38 100644 --- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -2109,10 +2109,12 @@ struct DSEState { if (auto *MemSetI = dyn_cast<MemSetInst>(UpperInst)) { if (auto *SI = dyn_cast<StoreInst>(DefInst)) { // MemSetInst must have a write location. - MemoryLocation UpperLoc = *getLocForWrite(UpperInst); + auto UpperLoc = getLocForWrite(UpperInst); + if (!UpperLoc) + return false; int64_t InstWriteOffset = 0; int64_t DepWriteOffset = 0; - auto OR = isOverwrite(UpperInst, DefInst, UpperLoc, *MaybeDefLoc, + auto OR = isOverwrite(UpperInst, DefInst, *UpperLoc, *MaybeDefLoc, InstWriteOffset, DepWriteOffset); Value *StoredByte = isBytewiseValue(SI->getValueOperand(), DL); return StoredByte && StoredByte == MemSetI->getOperand(1) &&
[ { "file": "llvm/test/Transforms/DeadStoreElimination/simple.ll", "commands": [ "opt < %s -passes=dse -S", "opt < %s -aa-pipeline=basic-aa -passes=dse -S" ], "tests": [ { "test_name": "test48", "test_body": "target datalayout = \"E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128\"\n\ndefine i32 @test48(ptr %P, ptr noalias %Q, ptr %R) {\n store i32 1, ptr %Q, align 4\n store i32 2, ptr %P, align 4\n store i32 3, ptr %Q, align 4\n %l = load i32, ptr %R, align 4\n ret i32 %l\n}\n", "additional_args": null, "lli_expected_out": null }, { "test_name": "test49", "test_body": "target datalayout = \"E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128\"\n\n; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)\ndeclare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0\n\ndefine void @test49() {\nbb:\n call void @llvm.memset.p0.i64(ptr readonly null, i8 0, i64 0, i1 false)\n store ptr null, ptr null, align 8\n ret void\n}\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\n", "additional_args": null, "lli_expected_out": null } ] } ]
{ "title": "[DSE] crash on applying * to std::nullopt", "body": "[reduced5.zip](https://github.com/llvm/llvm-project/files/15433764/reduced5.zip)\r\n\r\nThe command\r\n```\r\nopt -passes=dse reduced5.ll\r\n```\r\nfails occasionally. Debug version reliably complains\r\n```\r\ninclude/c++/v1/optional:805: assertion this->has_value() failed: optional operator* called on a disengaged value\r\n```\r\nwith stack trace\r\n```\r\n frame #3: 0x00005555663c6a43 opt`std::__u::optional<llvm::MemoryLocation>::operator*(this= Has Value=false ) && at optional:805:5\r\n frame #4: 0x00005555663c4d58 opt`(anonymous namespace)::DSEState::eliminateRedundantStoresOfExistingValues(this=0x00007fffffff9130)::'lambda'()::operator()() const at DeadStoreElimination.cpp:2119:39\r\n frame #5: 0x00005555663bf842 opt`(anonymous namespace)::DSEState::eliminateRedundantStoresOfExistingValues(this=0x00007fffffff9960) at DeadStoreElimination.cpp:2132:12\r\n frame #6: 0x00005555663b8956 opt`(anonymous namespace)::eliminateDeadStores(F=0x000033187fe3e008, AA=0x000033187feaafc8, MSSA=0x000033187fe603f0, DT=0x000033187fef6d78, PDT=0x000033187fed18d0, TLI=0x000033187fe0cd18, LI=0x000033187fe11cc8) at DeadStoreElimination.cpp:2332:23\r\n frame #7: 0x00005555663b6b3e opt`llvm::DSEPass::run(this=0x000033187fe08ad8, F=0x000033187fe3e008, AM=0x00007fffffffc1d8) at DeadStoreElimination.cpp:2355:18\r\n```\r\n\r\nThe local fix is\r\n```\r\n==== llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp#184\r\n# action=edit type=text\r\n--- llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp\t2024-04-15 20:27:56.000000000 -0700\r\n+++ llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp\t2024-05-24 04:36:17.000000000 -0700\r\n@@ -2109,10 +2109,12 @@\r\n if (auto *MemSetI = dyn_cast<MemSetInst>(UpperInst)) {\r\n if (auto *SI = dyn_cast<StoreInst>(DefInst)) {\r\n // MemSetInst must have a write location.\r\n- MemoryLocation UpperLoc = *getLocForWrite(UpperInst);\r\n+ auto UpperLoc = getLocForWrite(UpperInst);\r\n+ if (!UpperLoc)\r\n+ return false;\r\n int64_t InstWriteOffset = 0;\r\n int64_t DepWriteOffset = 0;\r\n- auto OR = isOverwrite(UpperInst, DefInst, UpperLoc, *MaybeDefLoc,\r\n+ auto OR = isOverwrite(UpperInst, DefInst, *UpperLoc, *MaybeDefLoc,\r\n InstWriteOffset, DepWriteOffset);\r\n Value *StoredByte = isBytewiseValue(SI->getValueOperand(), DL);\r\n return StoredByte && StoredByte == MemSetI->getOperand(1) &&\r\n```\r\nwhich basically reverts a piece of https://github.com/llvm/llvm-project/commit/81d69e1bda9e4b6a83f29ba1f614e43ab4700972\r\n\r\nLooks like the actual problem happened earlier?\r\n\r\nPlease take a look, this is blocking us significantly.\r\n\r\n", "author": "eaeltsin", "labels": [ "crash", "llvm:transforms" ], "comments": [ { "author": "eaeltsin", "body": "@nikic @fhahn FYI\r\n\r\nthe reproducer was cooked by @alinas \r\n" } ] }
true
null
77553
https://github.com/llvm/llvm-project/issues/77553
crash
c9c8f0c2fcf3b25ec310a75216f1d5b582ec343f
2024-01-10T04:18:48
[ "llvm/test/Transforms/InstCombine" ]
{ "fix_commit": "66eedd1dd370d22ddf994540c20848618d64d1a6", "components": [ "InstCombine" ], "bug_location_lineno": { "llvm/include/llvm/Analysis/MemorySSAUpdater.h": null, "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": [ [ 1704, 1714 ] ], "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/include/llvm/IR/Instruction.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null, "llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/include/llvm/IR/CmpPredicate.h": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanValue.h": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/include/llvm/Analysis/ScalarEvolution.h": null, "llvm/lib/Analysis/VectorUtils.cpp": null }, "bug_location_funcname": { "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": [ "InstCombinerImpl::foldSelectInstWithICmp" ], "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/lib/Analysis/VectorUtils.cpp": null } }
commit 66eedd1dd370d22ddf994540c20848618d64d1a6 Author: hanbeom <[email protected]> Date: Thu Jan 11 17:34:30 2024 +0900 [InstCombine] Fix worklist management in select fold (#77738) `InstCombine` uses `Worklist` to manage change history. `setOperand`, which was previously used to change the `Select` Instruction, does not, so it is `run` twice, which causes an `LLVM ERROR`. This problem is resolved by changing `setOperand` to `replaceOperand` as the change history will be registered in the Worklist. Fixes #77553. diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp index ab55f235920a..21bfc91148bf 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -1704,11 +1704,11 @@ Instruction *InstCombinerImpl::foldSelectInstWithICmp(SelectInst &SI, if (CmpRHS != CmpLHS && isa<Constant>(CmpRHS) && !isa<Constant>(CmpLHS)) { if (CmpLHS == TrueVal && Pred == ICmpInst::ICMP_EQ) { // Transform (X == C) ? X : Y -> (X == C) ? C : Y - SI.setOperand(1, CmpRHS); + replaceOperand(SI, 1, CmpRHS); Changed = true; } else if (CmpLHS == FalseVal && Pred == ICmpInst::ICMP_NE) { // Transform (X != C) ? Y : X -> (X != C) ? Y : C - SI.setOperand(2, CmpRHS); + replaceOperand(SI, 2, CmpRHS); Changed = true; } }
[ { "file": "llvm/test/Transforms/InstCombine/select.ll", "commands": [ "opt < %s -passes=instcombine -S" ], "tests": [ { "test_name": "src_select_xxory_eq0_xorxy_y", "test_body": "target datalayout = \"e-p:64:64-p1:16:16-p2:32:32:32-p3:64:64:64\"\n\ndefine i32 @src_select_xxory_eq0_xorxy_y(i32 %x, i32 %y) {\n %xor = xor i32 %x, %y\n %xor0 = icmp eq i32 %xor, 0\n %cond = select i1 %xor0, i32 %xor, i32 %y\n ret i32 %cond\n}\n", "additional_args": null, "lli_expected_out": null } ] } ]
{ "title": "LLVM ERROR while InstCombine", "body": "```\r\n$ bllvm0/bin/clang --version\r\nclang version 18.0.0git ([email protected]:ParkHanbum/llvm-project.git a9f39ff2b628e38826d5b95c1e8ae3cb7c692de9)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /home/m/bllvm0/bin\r\n```\r\nmy clang version.\r\n\r\nIR that caused the error\r\n```\r\ndefine i32 @no_trans_select_xor_eq0_xor_and(i32 %x, i32 %y) {\r\n; CHECK-LABEL: @no_trans_select_xor_eq0_xor_and(\r\n; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]\r\n; CHECK-NEXT: [[XOR0:%.*]] = icmp eq i32 [[XOR]], 0\r\n; CHECK-NEXT: [[AND:%.*]] = and i32 [[X]], [[Y]]\r\n; CHECK-NEXT: [[COND:%.*]] = select i1 [[XOR0]], i32 [[XOR]], i32 [[AND]]\r\n; CHECK-NEXT: ret i32 [[COND]]\r\n;\r\n %xor = xor i32 %x, %y\r\n %xor0 = icmp eq i32 %xor, 0\r\n %and = and i32 %x, %y\r\n %cond = select i1 %xor0, i32 %xor, i32 %and\r\n ret i32 %cond\r\n}\r\n```\r\n\r\nand Debug message :\r\n```\r\n$ bllvm0/bin/opt -passes=instcombine temp.ll -debug\r\nINSTCOMBINE ITERATION #1 on no_trans_select_xor_eq0_xor_and\r\nADD: ret i32 %cond\r\nADD: %cond = select i1 %xor0, i32 %xor, i32 %and\r\nADD: %and = and i32 %x, %y\r\nADD: %xor0 = icmp eq i32 %xor, 0\r\nADD: %xor = xor i32 %x, %y\r\nIC: Visiting: %xor = xor i32 %x, %y\r\nIC: Visiting: %xor0 = icmp eq i32 %xor, 0\r\nIC: Visiting: %and = and i32 %x, %y\r\nIC: Visiting: %cond = select i1 %xor0, i32 %xor, i32 %and\r\nIC: Mod = %cond = select i1 %xor0, i32 %xor, i32 %and\r\n New = %cond = select i1 %xor0, i32 0, i32 %and\r\nADD: %cond = select i1 %xor0, i32 0, i32 %and\r\nIC: Visiting: %cond = select i1 %xor0, i32 0, i32 %and\r\nIC: Visiting: ret i32 %cond\r\n\r\n\r\nINSTCOMBINE ITERATION #2 on no_trans_select_xor_eq0_xor_and\r\nADD: ret i32 %cond\r\nADD: %cond = select i1 %xor0, i32 0, i32 %and\r\nADD: %and = and i32 %x, %y\r\nADD: %xor0 = icmp eq i32 %xor, 0\r\nADD: %xor = xor i32 %x, %y\r\nIC: Visiting: %xor = xor i32 %x, %y\r\nIC: Visiting: %xor0 = icmp eq i32 %xor, 0\r\nIC: Old = %xor0 = icmp eq i32 %xor, 0\r\n New = <badref> = icmp eq i32 %x, %y\r\nADD: %xor0 = icmp eq i32 %x, %y\r\nIC: ERASE %1 = icmp eq i32 %xor, 0\r\nADD DEFERRED: %xor = xor i32 %x, %y\r\nIC: ERASE %xor = xor i32 %x, %y\r\nIC: Visiting: %xor0 = icmp eq i32 %x, %y\r\nIC: Visiting: %and = and i32 %x, %y\r\nIC: Visiting: %cond = select i1 %xor0, i32 0, i32 %and\r\nIC: Visiting: ret i32 %cond\r\nLLVM ERROR: Instruction Combining did not reach a fixpoint after 1 iterations\r\n\r\n```\r\n\r\nIf time isn't tight, I'd like to take on this issue.\r\n\r\n", "author": "ParkHanbum", "labels": [ "llvm:instcombine", "crash-on-valid" ], "comments": [ { "author": "nikic", "body": "The problem is likely that https://github.com/llvm/llvm-project/blob/084f1c2ee074a5ac8186ea4b5b181b48bf4621b6/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp#L1704-L1714 calls setOperand() instead of replaceOperand()." }, { "author": "ParkHanbum", "body": "@nikic can I try this?" }, { "author": "nikic", "body": "Sure." } ] }
true
null
124759
https://github.com/llvm/llvm-project/issues/124759
crash
b923f6cf8faca82b8df2a936d8ff36a6125aedcc
2025-01-28T14:48:43
[ "llvm/test/Analysis/LoopAccessAnalysis" ]
{ "fix_commit": "275baedfde9dcd344bc4f11f552b046a69a4bf3f", "components": [ "LoopAccessAnalysis" ], "bug_location_lineno": { "llvm/include/llvm/Analysis/MemorySSAUpdater.h": null, "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": [ [ 1362, 1369 ], [ 1443, 1450 ] ], "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/include/llvm/IR/Instruction.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null, "llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/include/llvm/IR/CmpPredicate.h": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanValue.h": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/include/llvm/Analysis/ScalarEvolution.h": null, "llvm/lib/Analysis/VectorUtils.cpp": null }, "bug_location_funcname": { "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": [ "AccessAnalysis::processMemAccesses" ], "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/lib/Analysis/VectorUtils.cpp": null } }
commit 275baedfde9dcd344bc4f11f552b046a69a4bf3f Author: Florian Hahn <[email protected]> Date: Fri Feb 28 20:56:12 2025 +0000 [LAA] Consider accessed addrspace when mapping underlying obj to access. (#129087) In some cases, it is possible for the same underlying object to be accessed via pointers to different address spaces. This could lead to pointers from different address spaces ending up in the same dependency set, which isn't allowed (and triggers an assertion). Update the mapping from underlying object -> last access to also include the accessing address space. Fixes https://github.com/llvm/llvm-project/issues/124759. PR: https://github.com/llvm/llvm-project/pull/129087 diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp index cf3bb6a8eae1..38ee82b77a94 100644 --- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp +++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp @@ -1362,8 +1362,10 @@ void AccessAnalysis::processMemAccesses() { bool SetHasWrite = false; - // Map of pointers to last access encountered. - typedef DenseMap<const Value*, MemAccessInfo> UnderlyingObjToAccessMap; + // Map of (pointer to underlying objects, accessed address space) to last + // access encountered. + typedef DenseMap<std::pair<const Value *, unsigned>, MemAccessInfo> + UnderlyingObjToAccessMap; UnderlyingObjToAccessMap ObjToLastAccess; // Set of access to check after all writes have been processed. @@ -1443,8 +1445,10 @@ void AccessAnalysis::processMemAccesses() { UnderlyingObj->getType()->getPointerAddressSpace())) continue; - auto [It, Inserted] = - ObjToLastAccess.try_emplace(UnderlyingObj, Access); + auto [It, Inserted] = ObjToLastAccess.try_emplace( + {UnderlyingObj, + cast<PointerType>(Ptr->getType())->getAddressSpace()}, + Access); if (!Inserted) { DepCands.unionSets(Access, It->second); It->second = Access;
[ { "file": "llvm/test/Analysis/LoopAccessAnalysis/underlying-object-different-address-spaces.ll", "commands": [ "opt -passes='print<access-info>' -disable-output %s 2>&1" ], "tests": [ { "test_name": "<module>", "test_body": "\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\n; Test case for https://github.com/llvm/llvm-project/issues/124759. The same\n; underlying object is access through pointers with different address spaces.\ndefine void @same_underlying_object_different_address_spaces(ptr %dst1.as1, ptr %dst2.as1) {\n;\nentry:\n %alloc = alloca i8, i64 0, align 128\n %as3 = addrspacecast ptr %alloc to ptr addrspace(3)\n %as4 = addrspacecast ptr %alloc to ptr addrspace(4)\n br label %loop\n\nloop:\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n store i32 0, ptr addrspace(4) %as4, align 4\n store i32 0, ptr %dst1.as1, align 4\n %l = load i64, ptr addrspace(3) %as3, align 4\n store i64 %l, ptr %dst2.as1, align 4\n %iv.next = add i64 %iv, 1\n %c = icmp eq i64 %iv.next, 100\n br i1 %c, label %loop, label %exit\n\nexit:\n ret void\n}", "additional_args": null, "lli_expected_out": null } ] } ]
{ "title": "LoopVectorizer `assert(AddressSpace == AS && with addrspacecast` is hit", "body": "The following code produces an assert in RuntimeCheckingPtrGroup::addPointer()\n\n\n``` llvm\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-unknown-elf\"\n\ndefine void @__mux_host_0(ptr addrspace(1) %_arg_resultPtr, ptr addrspace(1) %add.ptr.i.sroa_idx.i.i.i.i) {\nloopIR.i.preheader:\n %0 = alloca i8, i64 0, align 128\n %_arg_localAccessor = addrspacecast ptr %0 to ptr addrspace(3)\n %arrayidx.ascast.i.i.i.i.i.i = addrspacecast ptr %0 to ptr addrspace(4)\n br label %loopIR2.i\n\nloopIR2.i: ; preds = %loopIR2.i, %loopIR.i.preheader\n %1 = phi i64 [ 0, %loopIR.i.preheader ], [ %3, %loopIR2.i ]\n store i32 0, ptr addrspace(4) %arrayidx.ascast.i.i.i.i.i.i, align 4\n store float 0.000000e+00, ptr addrspace(1) %add.ptr.i.sroa_idx.i.i.i.i, align 4\n %2 = load i64, ptr addrspace(3) %_arg_localAccessor, align 4\n store i64 0, ptr addrspace(1) %_arg_resultPtr, align 4\n %3 = add i64 %1, 1\n br i1 false, label %loopIR2.i, label %exitIR.i\n\nexitIR.i: ; preds = %loopIR2.i\n ret void\n}\n```\n\nThis crashes with `opt --passes loop-vectorize /tmp/reduced.ll -S -o -` as follows:\n\n```\n./bin/opt --passes loop-vectorize /tmp/reduced.ll -S -o -\nopt: /home/colin/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp:423: bool llvm::RuntimeCheckingPtrGroup::addPointer(unsigned int, const llvm::SCEV*, const llvm::SCEV*, unsigned int, bool, llvm::ScalarEvolution&): Assertion `AddressSpace == AS && \"all pointers in a checking group must be in the same address space\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0. Program arguments: ./bin/opt --passes loop-vectorize /tmp/reduced.ll -S -o -\n1. Running pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"/tmp/reduced.ll\"\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"__mux_host_0\"\n #0 0x00005a58a99c2ddc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/colin/llvm-project/llvm/lib/Support/Unix/Signals.inc:798:22\n #1 0x00005a58a99c31fd PrintStackTraceSignalHandler(void*) /home/colin/llvm-project/llvm/lib/Support/Unix/Signals.inc:874:1\n #2 0x00005a58a99c0663 llvm::sys::RunSignalHandlers() /home/colin/llvm-project/llvm/lib/Support/Signals.cpp:105:20\n #3 0x00005a58a99c2674 SignalHandler(int) /home/colin/llvm-project/llvm/lib/Support/Unix/Signals.inc:415:1\n #4 0x00007c96b3242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #5 0x00007c96b32969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #6 0x00007c96b32969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #7 0x00007c96b32969fc pthread_kill ./nptl/pthread_kill.c:89:10\n #8 0x00007c96b3242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\n #9 0x00007c96b32287f3 abort ./stdlib/abort.c:81:7\n#10 0x00007c96b322871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\n#11 0x00007c96b3239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n#12 0x00005a58a8936a8b llvm::RuntimeCheckingPtrGroup::addPointer(unsigned int, llvm::SCEV const*, llvm::SCEV const*, unsigned int, bool, llvm::ScalarEvolution&) /home/colin/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp:429:37\n#13 0x00005a58a8936a20 llvm::RuntimeCheckingPtrGroup::addPointer(unsigned int, llvm::RuntimePointerChecking const&) /home/colin/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp:413:20\n#14 0x00005a58a8936f8d llvm::RuntimePointerChecking::groupChecks(llvm::EquivalenceClasses<llvm::PointerIntPair<llvm::Value*, 1u, bool, llvm::PointerLikeTypeTraits<llvm::Value*>, llvm::PointerIntPairInfo<llvm::Value*, 1u, llvm::PointerLikeTypeTraits<llvm::Value*>>>, std::less<llvm::PointerIntPair<llvm::Value*, 1u, bool, llvm::PointerLikeTypeTraits<llvm::Value*>, llvm::PointerIntPairInfo<llvm::Value*, 1u, llvm::PointerLikeTypeTraits<llvm::Value*>>>>>&, bool) /home/colin/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp:554:11\n#15 0x00005a58a893678d llvm::RuntimePointerChecking::generateChecks(llvm::EquivalenceClasses<llvm::PointerIntPair<llvm::Value*, 1u, bool, llvm::PointerLikeTypeTraits<llvm::Value*>, llvm::PointerIntPairInfo<llvm::Value*, 1u, llvm::PointerLikeTypeTraits<llvm::Value*>>>, std::less<llvm::PointerIntPair<llvm::Value*, 1u, bool, llvm::PointerLikeTypeTraits<llvm::Value*>, llvm::PointerIntPairInfo<llvm::Value*, 1u, llvm::PointerLikeTypeTraits<llvm::Value*>>>>>&, bool) /home/colin/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp:389:26\n#16 0x00005a58a893a016 (anonymous namespace)::AccessAnalysis::canCheckPtrAtRT(llvm::RuntimePointerChecking&, llvm::ScalarEvolution*, llvm::Loop*, llvm::DenseMap<llvm::Value*, llvm::SCEV const*, llvm::DenseMapInfo<llvm::Value*, void>, llvm::detail::DenseMapPair<llvm::Value*, llvm::SCEV const*>> const&, llvm::Value*&, bool) /home/colin/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp:1243:3\n#17 0x00005a58a8940750 llvm::LoopAccessInfo::analyzeLoop(llvm::AAResults*, llvm::LoopInfo const*, llvm::TargetLibraryInfo const*, llvm::DominatorTree*) /home/colin/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp:2638:31\n#18 0x00005a58a89422b3 llvm::LoopAccessInfo::LoopAccessInfo(llvm::Loop*, llvm::ScalarEvolution*, llvm::TargetTransformInfo const*, llvm::TargetLibraryInfo const*, llvm::AAResults*, llvm::DominatorTree*, llvm::LoopInfo*) /home/colin/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp:3028:15\n#19 0x00005a58a894ae40 std::_MakeUniq<llvm::LoopAccessInfo>::__single_object std::make_unique<llvm::LoopAccessInfo, llvm::Loop*, llvm::ScalarEvolution*, llvm::TargetTransformInfo*&, llvm::TargetLibraryInfo const*&, llvm::AAResults*, llvm::DominatorTree*, llvm::LoopInfo*>(llvm::Loop*&&, llvm::ScalarEvolution*&&, llvm::TargetTransformInfo*&, llvm::TargetLibraryInfo const*&, llvm::AAResults*&&, llvm::DominatorTree*&&, llvm::LoopInfo*&&) /usr/include/c++/11/bits/unique_ptr.h:962:30\n#20 0x00005a58a8942883 llvm::LoopAccessInfoManager::getInfo(llvm::Loop&) /home/colin/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp:3084:41\n#21 0x00005a58a831900e llvm::LoopVectorizationLegality::canVectorizeMemory() /home/colin/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp:1208:7\n#22 0x00005a58a831bc45 llvm::LoopVectorizationLegality::canVectorize(bool) /home/colin/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp:1840:7\n#23 0x00005a58a800b8b5 llvm::LoopVectorizePass::processLoop(llvm::Loop*) /home/colin/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10349:7\n#24 0x00005a58a800dde6 llvm::LoopVectorizePass::runImpl(llvm::Function&) /home/colin/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10779:27\n#25 0x00005a58a800e133 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/colin/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10816:39\n#26 0x00005a58a65ef71b llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/colin/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:92:3\n#27 0x00005a58a96e6133 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/colin/llvm-project/llvm/include/llvm/IR/PassManagerImpl.h:85:18\n#28 0x00005a58a4a21a65 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/colin/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:92:3\n#29 0x00005a58a96e513e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /home/colin/llvm-project/llvm/lib/IR/PassManager.cpp:129:23\n#30 0x00005a58a4a21995 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /home/colin/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:92:3\n#31 0x00005a58a96e5d5f llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /home/colin/llvm-project/llvm/include/llvm/IR/PassManagerImpl.h:85:18\n#32 0x00005a58a476e632 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) /home/colin/llvm-project/llvm/tools/opt/NewPMDriver.cpp:541:10\n#33 0x00005a58a473c69f optMain /home/colin/llvm-project/llvm/tools/opt/optdriver.cpp:739:27\n#34 0x00005a58a4739e81 main /home/colin/llvm-project/llvm/tools/opt/opt.cpp:25:64\n#35 0x00007c96b3229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\n#36 0x00007c96b3229e40 call_init ./csu/../csu/libc-start.c:128:20\n#37 0x00007c96b3229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\n#38 0x00005a58a4739d65 _start (./bin/opt+0xb93d65)\n```\n\nI've done some debugging and in `RuntimeCheckingPtrGroup::addPointer()` II can see the first two elements if RTCheck have the same dependency set but different address spaces.\n\nI did try removing the dependency set being equal continuing the loop here https://github.com/llvm/llvm-project/blob/main/llvm/lib/Analysis/LoopAccessAnalysis.cpp#L1219\n\n``` cpp\n // Only need to check pointers between two different dependency sets.\n if (RtCheck.Pointers[i].DependencySetId ==\n RtCheck.Pointers[j].DependencySetId)\n continue;\n```\nThis does seem to fix the issue but I was wary on whether this was just another symptom rather than the proper fix.\n", "author": "coldav", "labels": [ "release:backport", "release:cherry-pick-failed", "crash", "llvm:analysis" ], "comments": [ { "author": "coldav", "body": "Since nobody is looking at this, and it shows up as an assert for this, I'll try upstreaming my fix." }, { "author": "fhahn", "body": "@coldav sorry I missed this one. I think skipping the check you mentioned is probably not the right fix. I am looking into avoiding grouping pointers with different address spaces in the same dependency set.\n\nI am not super familiar with address space semantics, I am not sure if it is valid to access the same object with pointers to different address spaces?" }, { "author": "hvdijk", "body": "> I am not super familiar with address space semantics, I am not sure if it is valid to access the same object with pointers to different address spaces?\n\nIt depends on the address spaces. Address spaces may or may not overlap. If they do not overlap, then LLVM can assume that an object accessed from one address space and an object accessed from another do not alias. If the address spaces do overlap, however, that assumption is not valid. For the X86 target, address spaces 1-255 are reserved for user-defined code (https://llvm.org/docs/CodeGenerator.html#x86-address-spaces-supported) and interpreted for codegen purposes as aliases for address space zero, meaning all these address spaces overlap exactly." }, { "author": "fhahn", "body": "Put up https://github.com/llvm/llvm-project/pull/129087 to avoid adding pointers from different addrspaces in the same dependency set" }, { "author": "coldav", "body": "Thanks @fhahn " }, { "author": "fhahn", "body": "Manual PR to pick https://github.com/llvm/llvm-project/pull/129317" } ] }
true
null
114860
https://github.com/llvm/llvm-project/issues/114860
crash
7dffc96a54f90569d6226dd5713c80fc8f30c76f
2024-11-04T20:12:18
[ "llvm/test/Transforms/LoopVectorize" ]
{ "fix_commit": "144bdf3eb7128518ed162c5a168e3ec90922cd9e", "components": [ "LoopVectorize" ], "bug_location_lineno": { "llvm/include/llvm/Analysis/MemorySSAUpdater.h": null, "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [ [ 7521, 7526 ] ], "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/include/llvm/IR/Instruction.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null, "llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/include/llvm/IR/CmpPredicate.h": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanValue.h": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/include/llvm/Analysis/ScalarEvolution.h": null, "llvm/lib/Analysis/VectorUtils.cpp": null }, "bug_location_funcname": { "llvm/lib/Analysis/MemorySSAUpdater.cpp": null, "llvm/lib/Transforms/Scalar/LICM.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null, "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [ "LoopVectorizationPlanner::computeBestVF" ], "llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null, "llvm/lib/Transforms/Utils/LoopPeel.cpp": null, "llvm/lib/Transforms/Scalar/Scalarizer.cpp": null, "llvm/lib/IR/AsmWriter.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.cpp": null, "llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null, "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null, "llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null, "llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null, "llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null, "llvm/lib/Analysis/LoopAccessAnalysis.cpp": null, "llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null, "llvm/lib/Analysis/InstructionSimplify.cpp": null, "llvm/lib/IR/ConstantFold.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null, "llvm/include/llvm/Transforms/Utils/Evaluator.h": null, "llvm/lib/Transforms/Utils/Evaluator.cpp": null, "llvm/include/llvm/Analysis/ValueTracking.h": null, "llvm/lib/Analysis/LazyValueInfo.cpp": null, "llvm/lib/Analysis/ValueTracking.cpp": null, "llvm/lib/IR/Instruction.cpp": null, "llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null, "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null, "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null, "llvm/lib/Analysis/ScalarEvolution.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null, "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null, "llvm/lib/Transforms/Scalar/GVNSink.cpp": null, "llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null, "llvm/include/llvm/Analysis/SimplifyQuery.h": null, "llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null, "llvm/lib/Transforms/Utils/Local.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.h": null, "llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null, "llvm/lib/IR/Value.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null, "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null, "llvm/include/llvm/IR/PatternMatch.h": null, "llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null, "llvm/lib/Transforms/Scalar/Reassociate.cpp": null, "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null, "llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null, "llvm/lib/Transforms/Utils/ValueMapper.cpp": null, "llvm/lib/Transforms/Utils/SCCPSolver.cpp": null, "llvm/lib/Transforms/Vectorize/VPlan.h": null, "llvm/lib/Transforms/Scalar/BDCE.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null, "llvm/lib/IR/Instructions.cpp": null, "llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null, "llvm/lib/Transforms/Utils/LowerSwitch.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null, "llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null, "llvm/lib/Analysis/InlineCost.cpp": null, "llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null, "llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null, "llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null, "llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null, "llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null, "llvm/lib/Analysis/ConstantFolding.cpp": null, "llvm/lib/Transforms/IPO/GlobalOpt.cpp": null, "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null, "llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null, "llvm/lib/Analysis/LoopCacheAnalysis.cpp": null, "llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null, "llvm/lib/Transforms/Scalar/GVN.cpp": null, "llvm/lib/Transforms/Scalar/NewGVN.cpp": null, "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null, "llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null, "llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null, "llvm/lib/IR/Operator.cpp": null, "llvm/include/llvm/Analysis/AliasAnalysis.h": null, "llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null, "llvm/lib/Analysis/BasicAliasAnalysis.cpp": null, "llvm/lib/Transforms/Scalar/JumpThreading.cpp": null, "llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null, "llvm/lib/Analysis/VectorUtils.cpp": null } }
commit 144bdf3eb7128518ed162c5a168e3ec90922cd9e Author: Florian Hahn <[email protected]> Date: Fri Nov 8 20:53:03 2024 +0000 [VPlan] Also check if plan for best legacy VF contains simplifications. The plan for the VF chosen by the legacy cost model could also contain additional simplifications that cause cost differences. Also check if it contains simplifications. Fixes https://github.com/llvm/llvm-project/issues/114860. diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index c07af8519049..82d85b112397 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -7521,6 +7521,8 @@ VectorizationFactor LoopVectorizationPlanner::computeBestVF() { precomputeCosts(BestPlan, BestFactor.Width, CostCtx); assert((BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), + CostCtx, OrigLoop) || + planContainsAdditionalSimplifications(getPlanFor(LegacyVF.Width), CostCtx, OrigLoop)) && " VPlan cost model and legacy cost model disagreed"); assert((BestFactor.Width.isScalar() || BestFactor.ScalarCost > 0) &&
[ { "file": "llvm/test/Transforms/LoopVectorize/RISCV/select-invariant-cond-cost.ll", "commands": [ "opt -p loop-vectorize -S %s" ], "tests": [ { "test_name": "test_invariant_cond_for_select", "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @test_invariant_cond_for_select(ptr %dst, i8 %x) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %c.1 = icmp eq i8 %x, 0\n %c.2 = icmp sgt i64 %iv, 0\n %c.2.ext = zext i1 %c.2 to i64\n %sel = select i1 %c.1, i64 %c.2.ext, i64 0\n %sel.trunc = trunc i64 %sel to i8\n %gep = getelementptr inbounds i8, ptr %dst, i64 %iv\n store i8 %sel.trunc, ptr %gep, align 1\n %iv.next = add i64 %iv, 4\n %ec = icmp ult i64 %iv, 14\n br i1 %ec, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n", "additional_args": null, "lli_expected_out": null } ] } ]
{ "title": "[VPlan] Assertion \" VPlan cost model and legacy cost model disagreed\"' failed.", "body": "Testcase:\r\n```c\r\nextern char a[];\r\nchar *b;\r\nint c = 40502824327348188;\r\nlong d[9][9];\r\nint main() {\r\n for (long e = 0; e < 9; ++e)\r\n for (long f = 0; f < 9; ++f)\r\n d[e][f] = 6032102684657866;\r\n for (unsigned char f = b[4]; f < 18; f += c - 216)\r\n a[f] = f % 2 ? d[f][f] : d[f][f] + 2036854775807 > 0;\r\n}\r\n```\r\n```\r\n/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/clang -I/scratch/tc-testing/compiler-fuzz-ci/csmith-build/include -fsigned-char -fno-strict-aliasing -fwrapv -march=rv64gcv -flto -O3 -fuse-ld=lld red.c -o rv64gcv.out\r\n```\r\n\r\n\r\nReduced testcase:\r\n```llvm ir\r\n; ModuleID = 'reduced.bc'\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine i32 @main() #0 {\r\nentry:\r\n br label %for.body15\r\n\r\nfor.cond.cleanup14.loopexit: ; preds = %for.body15\r\n ret i32 0\r\n\r\nfor.body15: ; preds = %for.body15, %entry\r\n %indvars.iv1 = phi i64 [ %indvars.iv.next, %for.body15 ], [ 0, %entry ]\r\n %tobool.not = icmp eq i8 0, 0\r\n %cmp24 = icmp sgt i64 %indvars.iv1, 0\r\n %conv26 = zext i1 %cmp24 to i64\r\n %cond = select i1 %tobool.not, i64 %conv26, i64 0\r\n %conv27 = trunc i64 %cond to i8\r\n store i8 %conv27, ptr null, align 1\r\n %indvars.iv.next = add i64 %indvars.iv1, 4\r\n %cmp12 = icmp ult i64 %indvars.iv1, 14\r\n br i1 %cmp12, label %for.body15, label %for.cond.cleanup14.loopexit\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-b,-e,-experimental-smctr,-experimental-ssctr,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-experimental-zvbc32e,-experimental-zvkgs,-h,-sha,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smmpm,-smnpm,-smrnmi,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssnpm,-sspm,-ssqosid,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-supm,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-svvptc,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zacas,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\n```\r\n\r\nCommand/backtrace:\r\n```\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt --passes \"loop-vectorize\" reduced.ll -f\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7519: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt --passes loop-vectorize reduced.ll -f\r\n1. Running pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"reduced.ll\"\r\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\r\n #0 0x00005f3d9fc9dc00 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x3169c00)\r\n #1 0x00005f3d9fc9b00f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x316700f)\r\n #2 0x00005f3d9fc9b165 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007abb28242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007abb282969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007abb282969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007abb282969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x00007abb28242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007abb282287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x00007abb2822871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x00007abb28239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x00005f3d9ebfb878 llvm::LoopVectorizationPlanner::computeBestVF() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20c7878)\r\n#12 0x00005f3d9ec12dec llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20dedec)\r\n#13 0x00005f3d9ec15f01 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20e1f01)\r\n#14 0x00005f3d9ec16577 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20e2577)\r\n#15 0x00005f3d9da0cba6 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xed8ba6)\r\n#16 0x00005f3d9faa518f llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2f7118f)\r\n#17 0x00005f3d9da0fdd6 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/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xedbdd6)\r\n#18 0x00005f3d9faa351b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2f6f51b)\r\n#19 0x00005f3d9da0bc66 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xed7c66)\r\n#20 0x00005f3d9faa407d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2f7007d)\r\n#21 0x00005f3d9d20ca8d 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) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x6d8a8d)\r\n#22 0x00005f3d9d1fe911 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x6ca911)\r\n#23 0x00007abb28229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#24 0x00007abb28229e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#25 0x00007abb28229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#26 0x00005f3d9d1f4e65 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x6c0e65)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\n\r\nFound via fuzzer on Oct 24th\r\n\r\nGodbolt: https://godbolt.org/z/zhseEjTso\r\n\r\ncc @fhahn ", "author": "patrick-rivos", "labels": [ "vectorizers", "crash" ], "comments": [] }
true
null