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 | properties
dict | bisect
string | 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/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": [
[
1248,
1255
]
],
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": [
"buildClonedLoopBlocks"
],
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit fc5c89900f2a4b50e0f3a88ef7c89115d93684f4
Author: Nikita Popov <npopov@redhat.com>
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\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
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
2d8d622c738e636c4405072825c01bb14f87bb2f
| null |
101337
|
https://github.com/llvm/llvm-project/issues/101337
|
crash
|
1b936e4812ab395328203f65cacd4ffe02bb318e
| 2024-07-31T14:11:24
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "cd08fadd03904806fa26a1f117879ddae34fbf67",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
[
7080,
7086
]
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"LoopVectorizationPlanner::cost"
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit cd08fadd03904806fa26a1f117879ddae34fbf67
Author: Florian Hahn <flo@fhahn.com>
Date: Mon Aug 12 14:45:43 2024 +0100
[LV] Include chains feeding inductions in cost precomputation.
Include chain of ops feeding inductions in cost precomputation for
inductions, not just the induction increment. In VPlan, those
instructions will be cleaned up, as both phi and increment are generated
by VPWidenIntOrFpInductionRecipe independently.
Fixes https://github.com/llvm/llvm-project/issues/101337.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 542d74ef0e1e..41e4b0fcd9b0 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7080,7 +7080,16 @@ InstructionCost LoopVectorizationPlanner::cost(VPlan &Plan,
for (const auto &[IV, IndDesc] : Legal->getInductionVars()) {
Instruction *IVInc = cast<Instruction>(
IV->getIncomingValueForBlock(OrigLoop->getLoopLatch()));
- SmallVector<Instruction *> IVInsts = {IV, IVInc};
+ SmallVector<Instruction *> IVInsts = {IVInc};
+ for (unsigned I = 0; I != IVInsts.size(); I++) {
+ for (Value *Op : IVInsts[I]->operands()) {
+ auto *OpI = dyn_cast<Instruction>(Op);
+ if (Op == IV || !OpI || !OrigLoop->contains(OpI) || !Op->hasOneUse())
+ continue;
+ IVInsts.push_back(OpI);
+ }
+ }
+ IVInsts.push_back(IV);
for (User *U : IV->users()) {
auto *CI = cast<Instruction>(U);
if (!CostCtx.CM.isOptimizableIVTruncate(CI, VF))
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/X86/induction-costs.ll",
"commands": [
"opt -p loop-vectorize -mtriple=x86_64-apple-macosx -S %s"
],
"tests": [
{
"test_name": "iv_and_step_trunc",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine i16 @iv_and_step_trunc() {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %rec = phi i16 [ 0, %entry ], [ %rec.next, %loop ]\n %iv.next = add i64 %iv, 1\n %0 = trunc i64 %iv to i16\n %1 = trunc i64 %iv.next to i16\n %rec.next = mul i16 %0, %1\n %ec = icmp eq i64 %iv, 1\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i16 %rec\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "wombat2",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine void @wombat2(i32 %arg, ptr %dst) #0 {\nentry:\n %mul = mul i32 %arg, 3\n %zext = zext i32 %arg to i64\n br label %loop\n\nloop: ; preds = %loop, %entry\n %phi = phi i64 [ 4, %entry ], [ %add, %loop ]\n %phi2 = phi i32 [ %mul, %entry ], [ %trunc.1, %loop ]\n %getelementptr = getelementptr i32, ptr %dst, i64 %phi\n %and = and i32 %phi2, 12\n store i32 %and, ptr %getelementptr, align 4\n %mul3 = mul i64 %phi, %zext\n %add = add i64 %phi, 1\n %icmp = icmp ugt i64 %phi, 65\n %trunc.0 = trunc i64 %mul3 to i60\n %trunc.1 = trunc i60 %trunc.0 to i32\n br i1 %icmp, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { \"target-cpu\"=\"skylake-avx512\" \"target-features\"=\"-avx512f\" }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "with_dead_use",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine void @with_dead_use(i32 %arg, ptr %dst) #0 {\nentry:\n %mul = mul i32 %arg, 3\n %zext = zext i32 %arg to i64\n br label %loop\n\nloop: ; preds = %loop, %entry\n %phi = phi i64 [ 4, %entry ], [ %add, %loop ]\n %phi2 = phi i32 [ %mul, %entry ], [ %trunc, %loop ]\n %getelementptr = getelementptr i32, ptr %dst, i64 %phi\n %and = and i32 %phi2, 12\n store i32 %and, ptr %getelementptr, align 4\n %mul3 = mul i64 %phi, %zext\n %add = add i64 %phi, 1\n %icmp = icmp ugt i64 %phi, 65\n %trunc = trunc i64 %mul3 to i32\n %dead.and = and i32 %trunc, 123\n br i1 %icmp, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { \"target-cpu\"=\"skylake-avx512\" \"target-features\"=\"-avx512f\" }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "test_scalar_predicated_cost",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine i32 @test_scalar_predicated_cost(i64 %x, i64 %y, ptr %A) #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 %cmp9.not = icmp ule i64 %iv, %y\n br i1 %cmp9.not, label %loop.latch, label %if.then\n\nif.then: ; preds = %loop.header\n %or = or i64 %x, %iv\n %gep = getelementptr i32, ptr %A, i64 %iv\n %t = trunc i64 %or to i32\n store i32 %t, ptr %gep, align 4\n br label %loop.latch\n\nloop.latch: ; preds = %if.then, %loop.header\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv, 100\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret i32 0\n}\n\nattributes #0 = { \"min-legal-vector-width\"=\"0\" \"target-cpu\"=\"skylake-avx512\" }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "truncated_ivs_with_wide_and_scalar_uses",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine void @truncated_ivs_with_wide_and_scalar_uses(i1 %c, ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.16 = trunc i64 %iv to i16\n %iv.32 = trunc i64 %iv to i32\n %gep = getelementptr i16, ptr %dst, i32 %iv.32\n %sel = select i1 %c, i16 %iv.16, i16 10\n store i16 %sel, ptr %gep, align 2\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv, 64\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "multiple_truncated_ivs_with_wide_uses",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine void @multiple_truncated_ivs_with_wide_uses(i1 %c, ptr %A, ptr %B) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.16 = trunc i64 %iv to i16\n %iv.32 = trunc i64 %iv to i32\n %sel = select i1 %c, i16 %iv.16, i16 10\n %gep.A = getelementptr i16, ptr %A, i64 %iv\n store i16 %sel, ptr %gep.A, align 2\n %gep.B = getelementptr i32, ptr %B, i64 %iv\n store i32 %iv.32, ptr %gep.B, align 4\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv, 64\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "wide_iv_trunc_reuse",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine void @wide_iv_trunc_reuse(ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 1, %entry ], [ %iv.next, %loop ]\n %iv.2 = phi i32 [ 0, %entry ], [ %iv.trunc, %loop ]\n store i32 %iv.2, ptr %dst, align 4\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv, 0\n %iv.trunc = trunc i64 %iv to i32\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "iv_used_widened_and_truncated",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine i32 @iv_used_widened_and_truncated(ptr %dst, i64 %N) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep = getelementptr { i32, [8 x i32] }, ptr %dst, i64 %iv\n %t = trunc i64 %iv to i32\n store i32 %t, ptr %gep, align 8\n %iv.next = add i64 %iv, 1\n %c = icmp eq i64 %iv, %N\n br i1 %c, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i32 0\n}\n\nattributes #0 = { \"min-legal-vector-width\"=\"0\" \"target-cpu\"=\"skylake-avx512\" }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "wombat",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine void @wombat(i32 %arg, ptr %dst) #0 {\nentry:\n %mul = mul i32 %arg, 3\n %zext = zext i32 %arg to i64\n br label %loop\n\nloop: ; preds = %loop, %entry\n %phi = phi i64 [ 4, %entry ], [ %add, %loop ]\n %phi2 = phi i32 [ %mul, %entry ], [ %trunc, %loop ]\n %getelementptr = getelementptr i32, ptr %dst, i64 %phi\n %and = and i32 %phi2, 12\n store i32 %and, ptr %getelementptr, align 4\n %mul3 = mul i64 %phi, %zext\n %add = add i64 %phi, 1\n %icmp = icmp ugt i64 %phi, 65\n %trunc = trunc i64 %mul3 to i32\n br i1 %icmp, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { \"target-cpu\"=\"skylake-avx512\" \"target-features\"=\"-avx512f\" }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "wide_iv_trunc",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine void @wide_iv_trunc(ptr %dst, i64 %N) {\nentry:\n %cmp = icmp ult i64 %N, 8\n br i1 %cmp, label %loop, label %exit\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.trunc = trunc i64 %iv to i32\n store i32 %iv.trunc, ptr %dst, align 4\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv, %N\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop, %entry\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "multiple_pointer_ivs_with_scalar_uses_only",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine void @multiple_pointer_ivs_with_scalar_uses_only(ptr %A, ptr %B) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv.1 = phi i32 [ 100, %entry ], [ %dec, %loop ]\n %iv.2 = phi i32 [ 2048, %entry ], [ %add38, %loop ]\n %ptr.iv.1 = phi ptr [ %A, %entry ], [ %outptr.0, %loop ]\n %ptr.iv.2 = phi ptr [ %B, %entry ], [ %incdec.ptr36, %loop ]\n %ptr.iv.3 = phi ptr [ %B, %entry ], [ %incdec.ptr33, %loop ]\n %incdec.ptr33 = getelementptr i8, ptr %ptr.iv.3, i64 1\n %0 = load i8, ptr %ptr.iv.3, align 1\n %conv34 = zext i8 %0 to i32\n %incdec.ptr36 = getelementptr i8, ptr %ptr.iv.2, i64 1\n %1 = load i8, ptr %ptr.iv.2, align 1\n %conv37 = zext i8 %1 to i32\n %add38 = add i32 %conv34, %conv37\n %shr42 = lshr i32 %iv.2, 1\n %conv43 = trunc i32 %shr42 to i8\n store i8 %conv43, ptr %ptr.iv.1, align 1\n %dec = add i32 %iv.1, 1\n %outptr.0 = getelementptr i8, ptr %ptr.iv.1, i64 2\n %cmp30.not = icmp eq i32 %dec, 0\n br i1 %cmp30.not, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { \"min-legal-vector-width\"=\"0\" \"target-cpu\"=\"skylake-avx512\" }\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "Assertion `VF.Width == BestVF && \"VPlan cost model and legacy cost model disagreed\"' failed.",
"body": "To reproduce run opt with \r\n```\r\n-passes=loop-vectorize --mcpu=skylake-avx512 --mattr=+prfchw,-cldemote,+avx,+aes,+sahf,+pclmul,-xop,+crc32,+xsaves,-avx512fp16,-usermsr,-sm4,-egpr,+sse4.1,-avx512ifma,+xsave,+sse4.2,-tsxldtrk,-sm3,-ptwrite,-widekl,+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,-gfni,-avxvnniint16,-amx-fp16,-zu,-ndd,+xsaveopt,+rdrnd,+avx512f,-amx-bf16,-avx512bf16,-avx512vnni,-push2pop2,+cx8,+avx512bw,+sse3,+pku,-nf,+fsgsbase,-clzero,-mwaitx,-lwp,+lzcnt,-sha,-movdir64b,-ppx,-wbnoinvd,-enqcmd,-avxneconvert,-tbm,-pconfig,-amx-complex,+ssse3,+cx16,+bmi2,+fma,+popcnt,-avxifma,+f16c,-avx512bitalg,-rdpru,+clwb,+mmx,+sse2,+rdseed,-avx512vbmi2,-prefetchi,-rdpid,-fma4,-avx512vbmi,-shstk,-vaes,-waitpkg,-sgx,+fxsr,+avx512dq,-sse4a,-avx512f\r\n```\r\nwith the following test:\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) #0 gc \"statepoint-example\" {\r\nbb:\r\n %mul = mul i32 %arg, 3\r\n %zext = zext i32 %arg to i64\r\n br label %bb1\r\n\r\nbb1: ; preds = %bb1, %bb\r\n %phi = phi i64 [ %add, %bb1 ], [ 4, %bb ]\r\n %phi2 = phi i32 [ %trunc, %bb1 ], [ %mul, %bb ]\r\n %getelementptr = getelementptr i32, ptr addrspace(1) null, i64 %phi\r\n %and = and i32 %phi2, 0\r\n store i32 0, ptr addrspace(1) %getelementptr, align 4\r\n %mul3 = mul i64 %phi, %zext\r\n %add = add i64 %phi, 1\r\n %icmp = icmp ugt i64 %phi, 65\r\n %trunc = trunc i64 %mul3 to i32\r\n br i1 %icmp, label %bb4, label %bb1\r\n\r\nbb4: ; preds = %bb1\r\n ret void\r\n}\r\n```\r\nReproducer: https://godbolt.org/z/nPsP7h51n\r\n\r\nStack dump:\r\n```\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=loop-vectorize --mcpu=skylake-avx512 --mattr=+prfchw,-cldemote,+avx,+aes,+sahf,+pclmul,-xop,+crc32,+xsaves,-avx512fp16,-usermsr,-sm4,-egpr,+sse4.1,-avx512ifma,+xsave,+sse4.2,-tsxldtrk,-sm3,-ptwrite,-widekl,+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,-gfni,-avxvnniint16,-amx-fp16,-zu,-ndd,+xsaveopt,+rdrnd,+avx512f,-amx-bf16,-avx512bf16,-avx512vnni,-push2pop2,+cx8,+avx512bw,+sse3,+pku,-nf,+fsgsbase,-clzero,-mwaitx,-lwp,+lzcnt,-sha,-movdir64b,-ppx,-wbnoinvd,-enqcmd,-avxneconvert,-tbm,-pconfig,-amx-complex,+ssse3,+cx16,+bmi2,+fma,+popcnt,-avxifma,+f16c,-avx512bitalg,-rdpru,+clwb,+mmx,+sse2,+rdseed,-avx512vbmi2,-prefetchi,-rdpid,-fma4,-avx512vbmi,-shstk,-vaes,-waitpkg,-sgx,+fxsr,+avx512dq,-sse4a,-avx512f <source>\r\n1.\tRunning pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"<source>\"\r\n2.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"wombat\"\r\n #0 0x0000000004f053c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f053c8)\r\n #1 0x0000000004f02b3c SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007458cc042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x00007458cc0969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x00007458cc042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x00007458cc0287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00007458cc02871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x00007458cc039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x0000000003f83f37 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3f83f37)\r\n #9 0x0000000003f86659 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*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3f86659)\r\n#10 0x0000000003f86cd2 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3f86cd2)\r\n#11 0x0000000002e596ce 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+0x2e596ce)\r\n#12 0x0000000004d02758 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d02758)\r\n#13 0x0000000000de089e 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+0xde089e)\r\n#14 0x0000000004d0114e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d0114e)\r\n#15 0x0000000000de0eee 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+0xde0eee)\r\n#16 0x0000000004cff2b0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4cff2b0)\r\n#17 0x00000000008e3752 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+0x8e3752)\r\n#18 0x00000000008d667c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8d667c)\r\n#19 0x00007458cc029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#20 0x00007458cc029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#21 0x00000000008cdade _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8cdade)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```",
"author": "TatyanaDoubts",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "patrick-rivos",
"body": "Potentially related: https://github.com/llvm/llvm-project/issues/100591"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
7d0a5848f2c72854d7d5a795fcc265b8ba787782
| null |
83931
|
https://github.com/llvm/llvm-project/issues/83931
|
crash
|
d95a0d7c0ff324c1e84606d26591416e6bf02984
| 2024-03-05T00:39:01
|
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "d51fcd4ed86ac6075c8a25b053c2b66051feaf62",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": [
[
6544,
6549
]
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": [
"InstCombiner::getFlippedStrictnessPredicateAndConstant"
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit d51fcd4ed86ac6075c8a25b053c2b66051feaf62
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Tue Mar 5 21:08:15 2024 +0800
[InstCombine] Handle scalable splat in `getFlippedStrictnessPredicateAndConstant` (#83980)
This patch adds support for canonicalization of icmp with a scalable
splat. Some optimizations assume that `icmp pred X, APInt C` is in
canonical form.
Fixes https://github.com/llvm/llvm-project/issues/83931.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 55207a8343d0..1cebab8203ea 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -6544,6 +6544,13 @@ InstCombiner::getFlippedStrictnessPredicateAndConstant(CmpInst::Predicate Pred,
if (!SafeReplacementConstant)
SafeReplacementConstant = CI;
}
+ } else if (isa<VectorType>(C->getType())) {
+ // Handle scalable splat
+ Value *SplatC = C->getSplatValue();
+ auto *CI = dyn_cast_or_null<ConstantInt>(SplatC);
+ // Bail out if the constant can't be safely incremented/decremented.
+ if (!CI || !ConstantIsOk(CI))
+ return std::nullopt;
} else {
// ConstantExpr?
return std::nullopt;
|
[
{
"file": "llvm/test/Transforms/InstCombine/pr83931.ll",
"commands": [
"opt -S -passes=instcombine < %s"
],
"tests": [
{
"test_name": "dont_crash",
"test_body": "define <vscale x 2 x i1> @dont_crash(<vscale x 2 x i64> %x) {\nentry:\n %div = sdiv <vscale x 2 x i64> %x, splat (i64 309383)\n %ret = icmp sge <vscale x 2 x i64> %div, zeroinitializer\n ret <vscale x 2 x i1> %ret\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": "scalable_sign_bits",
"test_body": "target datalayout = \"e-p:64:64-p1:16:16-p2:32:32:32-p3:64:64:64\"\n\ndefine <vscale x 2 x i32> @scalable_sign_bits(<vscale x 2 x i8> %x) {\n %a = sext <vscale x 2 x i8> %x to <vscale x 2 x i32>\n %b = shl <vscale x 2 x i32> %a, splat (i32 16)\n ret <vscale x 2 x i32> %b\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "scalable_non_zero",
"test_body": "target datalayout = \"e-p:64:64-p1:16:16-p2:32:32:32-p3:64:64:64\"\n\ndefine <vscale x 2 x i1> @scalable_non_zero(<vscale x 2 x i32> %x) {\n %a = or <vscale x 2 x i32> %x, splat (i32 1)\n %b = add <vscale x 2 x i32> %a, splat (i32 -1)\n %cmp = icmp ult <vscale x 2 x i32> %b, splat (i32 56)\n ret <vscale x 2 x i1> %cmp\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/InstCombine/vscale_cmp.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "sge",
"test_body": "define <vscale x 2 x i1> @sge(<vscale x 2 x i8> %x) {\n %cmp = icmp sge <vscale x 2 x i8> %x, zeroinitializer\n ret <vscale x 2 x i1> %cmp\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[InstCombine][RISC-V] UNREACHABLE executed at InstCombineCompares.cpp:2788",
"body": "Testcase:\r\n```c\r\nchar a;\r\nint b;\r\nlong *c[5][5];\r\nint main() {\r\n for (int d = -2041027590; d; d++)\r\n a |= b <= c[3][d][8] / 309383;\r\n}\r\n```\r\n\r\nReduced LLVM IR:\r\n```llvm ir\r\n; ModuleID = 'reduced.ll'\r\nsource_filename = \"red.c\"\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\n; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, argmem: read, inaccessiblemem: none) uwtable vscale_range(2,1024)\r\ndefine noundef signext i32 @main() #0 {\r\nentry:\r\n %0 = getelementptr inbounds i8, <vscale x 2 x ptr> zeroinitializer, i64 64\r\n %wide.masked.gather = call <vscale x 2 x i64> @llvm.masked.gather.nxv2i64.nxv2p0(<vscale x 2 x ptr> %0, i32 8, <vscale x 2 x i1> shufflevector (<vscale x 2 x i1> insertelement (<vscale x 2 x i1> poison, i1 true, i64 0), <vscale x 2 x i1> poison, <vscale x 2 x i32> zeroinitializer), <vscale x 2 x i64> poison)\r\n %1 = sdiv <vscale x 2 x i64> %wide.masked.gather, shufflevector (<vscale x 2 x i64> insertelement (<vscale x 2 x i64> poison, i64 309383, i64 0), <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer)\r\n %2 = icmp sge <vscale x 2 x i64> %1, zeroinitializer\r\n %3 = zext <vscale x 2 x i1> %2 to <vscale x 2 x i8>\r\n %4 = call i8 @llvm.vector.reduce.or.nxv2i8(<vscale x 2 x i8> %3)\r\n store i8 %4, ptr null, align 1\r\n ret i32 0\r\n}\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(read)\r\ndeclare <vscale x 2 x i64> @llvm.masked.gather.nxv2i64.nxv2p0(<vscale x 2 x ptr>, i32 immarg, <vscale x 2 x i1>, <vscale x 2 x i64>) #1\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\r\ndeclare i8 @llvm.vector.reduce.or.nxv2i8(<vscale x 2 x i8>) #2\r\n\r\n; uselistorder directives\r\nuselistorder <vscale x 2 x i64> poison, { 1, 2, 0 }\r\n\r\nattributes #0 = { nofree norecurse nosync nounwind memory(readwrite, argmem: read, inaccessiblemem: none) uwtable vscale_range(2,1024) \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"generic-rv64\" \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v\" }\r\nattributes #1 = { nocallback nofree nosync nounwind willreturn memory(read) }\r\nattributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\r\n```\r\n\r\nBacktrace:\r\n```\r\n> /scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/opt -passes=\"instcombine\" reduced.ll --disable-output\r\nUnhandled icmp predicate!\r\nUNREACHABLE executed at /scratch/tc-testing/tc-feb-22-llvm/llvm/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:2788!\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-feb-22-llvm/build/build-llvm-linux/bin/opt -passes=instcombine reduced.ll --disable-output\r\n #0 0x00005565be2171a0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/opt+0x2ce31a0)\r\n #1 0x00005565be2145af llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/opt+0x2ce05af)\r\n #2 0x00005565be214705 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007f8b9f842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007f8b9f8969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007f8b9f8969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007f8b9f8969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x00007f8b9f842476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007f8b9f8287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x00005565be14ca5e (/scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/opt+0x2c18a5e)\r\n#10 0x00005565bd1c1139 llvm::InstCombinerImpl::foldICmpDivConstant(llvm::ICmpInst&, llvm::BinaryOperator*, llvm::APInt const&) (/scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/opt+0x1c8d139)\r\n#11 0x00005565bd1d710e llvm::InstCombinerImpl::foldICmpBinOpWithConstant(llvm::ICmpInst&, llvm::BinaryOperator*, llvm::APInt const&) (/scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/opt+0x1ca310e)\r\n#12 0x00005565bd1d7393 llvm::InstCombinerImpl::foldICmpInstWithConstant(llvm::ICmpInst&) (/scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/opt+0x1ca3393)\r\n#13 0x00005565bd1e46eb llvm::InstCombinerImpl::visitICmpInst(llvm::ICmpInst&) (/scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/opt+0x1cb06eb)\r\n#14 0x00005565bd1457a5 llvm::InstCombinerImpl::run() (/scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/opt+0x1c117a5)\r\n#15 0x00005565bd146e85 combineInstructionsOverFunction(llvm::Function&, llvm::InstructionWorklist&, llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::ProfileSummaryInfo*, llvm::LoopInfo*, llvm::InstCombineOptions const&) InstructionCombining.cpp:0:0\r\n#16 0x00005565bd147ef5 llvm::InstCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/opt+0x1c13ef5)\r\n#17 0x00005565bc1e5c96 llvm::detail::PassModel<llvm::Function, llvm::InstCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/opt+0xcb1c96)\r\n#18 0x00005565be044751 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/opt+0x2b10751)\r\n#19 0x00005565bc1dd5b6 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-feb-22-llvm/build/build-llvm-linux/bin/opt+0xca95b6)\r\n#20 0x00005565be04344b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/opt+0x2b0f44b)\r\n#21 0x00005565bc1e5746 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/opt+0xcb1746)\r\n#22 0x00005565be0412c1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/opt+0x2b0d2c1)\r\n#23 0x00005565bba77e55 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-feb-22-llvm/build/build-llvm-linux/bin/opt+0x543e55)\r\n#24 0x00005565bba6a296 optMain (/scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/opt+0x536296)\r\n#25 0x00007f8b9f829d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#26 0x00007f8b9f829e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#27 0x00007f8b9f829e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#28 0x00005565bba5f5a5 _start (/scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/opt+0x52b5a5)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-feb-22-llvm/build/build-llvm-linux/bin/opt reduced.ll\r\n```\r\n\r\nGodbolt: https://godbolt.org/z/9qdYfPTrE\r\n\r\nAssert being tripped: https://github.com/llvm/llvm-project/blob/main/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp#L2788\r\n\r\nFound via fuzzer.",
"author": "patrick-rivos",
"labels": [
"crash",
"llvm:instcombine"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Reduced test case: https://godbolt.org/z/5qocbWsW3\r\n```\r\ndefine <vscale x 2 x i1> @test(<vscale x 2 x i64> %p) {\r\nentry:\r\n %1 = sdiv <vscale x 2 x i64> %p, splat (i64 309383)\r\n %2 = icmp sge <vscale x 2 x i64> %1, zeroinitializer\r\n ret <vscale x 2 x i1> %2\r\n}\r\n\r\n```"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
Cannot find a good commit
| null |
129373
|
https://github.com/llvm/llvm-project/issues/129373
|
hang
|
88460137d97c0b8d3742203e0173ab9ed6c5c8a7
| 2025-03-01T09:39:32
|
[
"llvm/test/Transforms/VectorCombine"
] |
{
"fix_commit": "5ddf40fa78705384966c22da78e12134df7bd723",
"components": [
"VectorCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [
[
1579,
1584
]
],
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [
"VectorCombine::scalarizeLoadExtract"
],
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 5ddf40fa78705384966c22da78e12134df7bd723
Author: Simon Pilgrim <llvm-dev@redking.me.uk>
Date: Sat Mar 1 16:54:22 2025 +0000
[VectorCombine] scalarizeLoadExtract - don't create scalar loads if any extract is waiting to be erased (#129375)
If any extract is waiting to be erased, then bail out as this will distort the cost calculation and possibly lead to infinite loops.
Fixes #129373
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index bb4e1c0f67e7..2e8458e2cd03 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -1579,6 +1579,11 @@ bool VectorCombine::scalarizeLoadExtract(Instruction &I) {
if (!UI || UI->getParent() != LI->getParent())
return false;
+ // If any extract is waiting to be erased, then bail out as this will
+ // distort the cost calculation and possibly lead to infinite loops.
+ if (UI->use_empty())
+ return false;
+
// Check if any instruction between the load and the extract may modify
// memory.
if (LastCheckedInst->comesBefore(UI)) {
|
[
{
"file": "llvm/test/Transforms/VectorCombine/X86/load-extractelement-scalarization.ll",
"commands": [
"opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=sse2",
"opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=avx2"
],
"tests": [
{
"test_name": "multiple_extract",
"test_body": "define void @multiple_extract(ptr %p) {\n %vp = load ptr, ptr %p, align 8\n %v = load <2 x i32>, ptr %vp, align 16\n %e0 = extractelement <2 x i32> %v, i64 0\n %e1 = extractelement <2 x i32> %v, i64 1\n store i32 %e0, ptr %p, align 4\n %p1 = getelementptr inbounds nuw i8, ptr %p, i64 4\n store i32 %e1, ptr %p1, align 4\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "unused_extract",
"test_body": "define void @unused_extract(ptr %p) {\n %load = load <4 x float>, ptr %p, align 8\n %shuffle0 = shufflevector <4 x float> zeroinitializer, <4 x float> %load, <4 x i32> <i32 0, i32 4, i32 1, i32 5>\n %shuffle1 = shufflevector <4 x float> %shuffle0, <4 x float> zeroinitializer, <4 x i32> <i32 0, i32 4, i32 poison, i32 poison>\n %extract = extractelement <4 x float> %load, i64 1\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[VectorCombine] scalarizeLoadExtract - infinite loop if we scalarize a dead extract waiting to be erased",
"body": "Reduced test case:\n\n```ll\ndefine void @infinite_loop(ptr %p0) {\n %load = load <4 x float>, ptr %p0, align 8\n %shuffle0 = shufflevector <4 x float> zeroinitializer, <4 x float> %load, <4 x i32> <i32 0, i32 4, i32 1, i32 5>\n %shuffle1 = shufflevector <4 x float> %shuffle0, <4 x float> zeroinitializer, <4 x i32> <i32 0, i32 4, i32 poison, i32 poison>\n %extract = extractelement <4 x float> %load, i64 1\n ret void\n}\n```\n\nscalarizeLoadExtract iterates across all users of a load, and doesn't account for possible orders in the worklist that prevent unused instructions that use the load from being erased afterward.\n\nFix incoming",
"author": "RKSimon",
"labels": [
"release:backport",
"vectorizers",
"hang"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
035e64c0ec02b237a266ebc672718037fdd53eb2
| null |
180780
|
https://github.com/llvm/llvm-project/issues/180780
|
crash
|
0215f6b6cf810d9ab6d02fc7bbec5c26ad4701ff
| 2026-02-10T17:09:08
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "d3afa171ee236dfef4b7cd4b4dd0b0fb165a48cc",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
[
5883,
5891
]
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"LoopVectorizationCostModel::setCostBasedWideningDecision"
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit d3afa171ee236dfef4b7cd4b4dd0b0fb165a48cc
Author: Florian Hahn <flo@fhahn.com>
Date: Wed Feb 11 20:52:07 2026 +0000
[LV] Don't scalarize loads that need predication in legacy CM.
The legacy cost model tries to scalarize loads that are used as
pointers. Skip if the load would need predicating when scalarized,
because that would incur very high costs, see useEmulatedMaskMemRefHack.
Fixes https://github.com/llvm/llvm-project/issues/180780.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 164d74f1a440..9b2641c2b9bb 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -5883,9 +5883,9 @@ void LoopVectorizationCostModel::setCostBasedWideningDecision(ElementCount VF) {
// if the loaded register is involved in an address computation, it is
// instead changed here when we know this is the case.
InstWidening Decision = getWideningDecision(I, VF);
- if (Decision == CM_Widen || Decision == CM_Widen_Reverse ||
- (!isPredicatedInst(I) && !Legal->isUniformMemOp(*I, VF) &&
- Decision == CM_Scalarize)) {
+ if (!isPredicatedInst(I) &&
+ (Decision == CM_Widen || Decision == CM_Widen_Reverse ||
+ (!Legal->isUniformMemOp(*I, VF) && Decision == CM_Scalarize))) {
// Scalarize a widened load of address or update the cost of a scalar
// load of an address.
setWideningDecision(
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/X86/cost-model.ll",
"commands": [
"opt < %s -passes=loop-vectorize -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7-avx -S"
],
"tests": [
{
"test_name": "known_deref_load_tail_folding",
"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\"\ntarget triple = \"x86_64-apple-macosx10.8.0\"\n\n@src.arr = external global [15 x double]\n@dst.arr.a = external global [10 x double]\n@dst.arr.b = external global [15 x double]\n\ndefine void @known_deref_load_tail_folding() #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 1, %entry ], [ %iv.next, %loop ]\n %gep.src = getelementptr double, ptr @src.arr, i64 %iv\n %val = load double, ptr %gep.src, align 8\n %cmp = fcmp oeq double %val, 0.000000e+00\n %dst.select = select i1 %cmp, ptr @dst.arr.a, ptr @dst.arr.b\n store double 0.000000e+00, ptr %dst.select, align 8\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv.next, 12\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { \"target-cpu\"=\"haswell\" }\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[LV]VPlan cost model and legacy cost model disagreed",
"body": "https://godbolt.org/z/o9sPfa35r\n@fhahn \nMaybe related to https://github.com/llvm/llvm-project/commit/7defb0a4a35817ee7accb310d99912152a542ec2",
"author": "alexey-bataev",
"labels": [
"vectorizers",
"crash-on-valid"
],
"comments": [
{
"author": "alexey-bataev",
"body": "Ping!"
},
{
"author": "fhahn",
"body": "It's not related to https://github.com/llvm/llvm-project/commit/7defb0a4a35817ee7accb310d99912152a542ec2, but will fix soon"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null | null |
116249
|
https://github.com/llvm/llvm-project/issues/116249
|
miscompilation
|
c1f6cb74634509d0e4204dadd46566185fa33e2b
| 2024-11-14T15:57:03
|
[
"llvm/test/Transforms/IndVarSimplify"
] |
{
"fix_commit": "40a647fc7dc6048c92e2d580b61f5feca0785980",
"components": [
"IndVarSimplify"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": [
[
1530,
1535
]
],
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": [
"IndVarSimplify::canonicalizeExitCondition"
],
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 40a647fc7dc6048c92e2d580b61f5feca0785980
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Fri Nov 15 09:15:37 2024 +0800
[IndVarSimplify] Drop samesign flags after narrowing compares (#116263)
Samesign flag cannot be preserved after narrowing the compare since the
position of the sign bit is changed.
Closes https://github.com/llvm/llvm-project/issues/116249.
diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
index 2b2d516a7079..8a3e0bc3eb97 100644
--- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -1530,6 +1530,8 @@ bool IndVarSimplify::canonicalizeExitCondition(Loop *L) {
L->getLoopPreheader()->getTerminator()->getIterator());
ICmp->setOperand(Swapped ? 1 : 0, LHSOp);
ICmp->setOperand(Swapped ? 0 : 1, NewRHS);
+ // Samesign flag cannot be preserved after narrowing the compare.
+ ICmp->setSameSign(false);
if (LHS->use_empty())
DeadInsts.push_back(LHS);
};
|
[
{
"file": "llvm/test/Transforms/IndVarSimplify/finite-exit-comparisons.ll",
"commands": [
"opt -passes=indvars -S < %s -indvars-predicate-loops=0"
],
"tests": [
{
"test_name": "test_drop_icmp_samesign",
"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\"\n\ndefine i8 @test_drop_icmp_samesign(i1 %cond, i32 range(i32 0, 32) %x) {\nentry:\n br i1 %cond, label %for.body, label %else\n\nelse: ; preds = %entry\n %call1 = call i8 @callee()\n br label %exit\n\nfor.body: ; preds = %for.body, %entry\n %call2 = call i8 @callee()\n %ext = zext i8 %call2 to i32\n %cond2 = icmp samesign ugt i32 %x, %ext\n br i1 %cond2, label %for.body, label %exit\n\nexit: ; preds = %for.body, %else\n %res = phi i8 [ %call1, %else ], [ %call2, %for.body ]\n ret i8 %res\n}\n\ndeclare i8 @callee()\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[IndVarSimplify] samesign flag should be dropped after narrowing",
"body": "Found with https://github.com/dtcxzyw/llvm-ub-aware-interpreter.\r\nReproducer: https://alive2.llvm.org/ce/z/fcnvLv\r\n```\r\n; bin/opt -passes=indvars test.ll -S\r\ndefine i8 @test(i1 %cond, i32 range(i32 0, 32) %x) {\r\nentry:\r\n br i1 %cond, label %for.body, label %else\r\n\r\nelse:\r\n %call1 = call i8 @callee()\r\n br label %exit\r\n\r\nfor.body:\r\n %call2 = call i8 @callee()\r\n %ext = zext i8 %call2 to i32\r\n %cond2 = icmp samesign ugt i32 %x, %ext\r\n br i1 %cond2, label %for.body, label %exit\r\n\r\nexit:\r\n %res = phi i8 [ %call1, %else ], [ %call2, %for.body ]\r\n ret i8 %res\r\n}\r\n```\r\n```\r\n\r\n----------------------------------------\r\ndeclare i8 @callee()\r\n\r\ndefine i8 @test(i1 %cond, i32 %x) {\r\ninit:\r\n %#range_0_%x = !range i32 %x, i32 0, i32 32\r\n br label %entry\r\n\r\nentry:\r\n br i1 %cond, label %for.body, label %else\r\n\r\nelse:\r\n %call1 = call i8 @callee()\r\n br label %exit\r\n\r\nfor.body:\r\n %call2 = call i8 @callee()\r\n %ext = zext i8 %call2 to i32\r\n %cond2 = icmp samesign ugt i32 %#range_0_%x, %ext\r\n br i1 %cond2, label %for.body, label %exit\r\n\r\nexit:\r\n %res = phi i8 [ %call1, %else ], [ %call2, %for.body ]\r\n ret i8 %res\r\n}\r\n=>\r\ndeclare i8 @callee()\r\n\r\ndefine i8 @test(i1 %cond, i32 %x) {\r\ninit:\r\n %#range_0_%x = !range i32 %x, i32 0, i32 32\r\n br label %entry\r\n\r\nentry:\r\n br i1 %cond, label %for.body.preheader, label %else\r\n\r\nelse:\r\n %call1 = call i8 @callee()\r\n br label %exit\r\n\r\nfor.body.preheader:\r\n %#0 = trunc i32 %#range_0_%x to i8\r\n br label %for.body\r\n\r\nfor.body:\r\n %call2 = call i8 @callee()\r\n %cond2 = icmp samesign ugt i8 %#0, %call2\r\n br i1 %cond2, label %for.body, label %exit.loopexit\r\n\r\nexit.loopexit:\r\n %call2.lcssa = phi i8 [ %call2, %for.body ]\r\n br label %exit\r\n\r\nexit:\r\n %res = phi i8 [ %call1, %else ], [ %call2.lcssa, %exit.loopexit ]\r\n ret i8 %res\r\n}\r\nTransformation doesn't verify!\r\n\r\nERROR: Source is more defined than target\r\n\r\nExample:\r\ni1 %cond = #x1 (1)\r\ni32 %x = #x00000000 (0)\r\n\r\nSource:\r\ni32 %#range_0_%x = #x00000000 (0)\r\n >> Jump to %entry\r\n >> Jump to %for.body\r\ni8 %call2 = #x80 (128, -128)\r\ni32 %ext = #x00000080 (128)\r\ni1 %cond2 = #x0 (0)\r\n >> Jump to %exit\r\ni8 %res = #x80 (128, -128)\r\n\r\nSOURCE MEMORY STATE\r\n===================\r\nNON-LOCAL BLOCKS:\r\nBlock 0 >\tsize: 0\talign: 1\talloc type: 0\talive: false\taddress: 0\r\nBlock 1 >\tsize: 4\talign: 1\talloc type: 0\talive: true\taddress: 1\r\n\r\nTarget:\r\ni32 %#range_0_%x = #x00000000 (0)\r\n >> Jump to %entry\r\n >> Jump to %for.body.preheader\r\ni8 %#0 = #x00 (0)\r\n >> Jump to %for.body\r\ni8 %call2 = #x80 (128, -128)\r\ni1 %cond2 = poison\r\nUB triggered on br\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```",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:transforms"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
Cannot find a good commit
| null |
139202
|
https://github.com/llvm/llvm-project/issues/139202
|
miscompilation
|
8bd35ca41253ea36fff78d5acf59956a30b6555b
| 2025-05-09T03:49:41
|
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "c807395011a027caae9ac196edfac328fb90443a",
"components": [
"LoopAccessAnalysis",
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": [
[
853,
863
]
],
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": [
[
1541,
1551
],
[
1570,
1576
],
[
1585,
1591
],
[
1594,
1603
],
[
1616,
1629
],
[
1654,
1660
]
],
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
1584,
1590
],
[
2216,
2222
],
[
3619,
3627
],
[
5368,
5374
],
[
5442,
5448
],
[
5540,
5547
],
[
5868,
5874
],
[
5894,
5900
],
[
5921,
5931
],
[
6051,
6059
],
[
6061,
6069
],
[
6081,
6089
],
[
6122,
6128
],
[
6165,
6174
],
[
6427,
6434
],
[
6441,
6450
],
[
6494,
6503
],
[
7007,
7013
],
[
7999,
8005
],
[
8027,
8040
],
[
8046,
8052
],
[
8130,
8144
],
[
8154,
8160
],
[
8176,
8186
],
[
8191,
8206
],
[
8231,
8240
],
[
8249,
8255
],
[
8259,
8265
],
[
8267,
8273
],
[
8280,
8288
],
[
8291,
8298
],
[
8454,
8481
],
[
8698,
8709
],
[
9299,
9308
],
[
10751,
10757
],
[
11950,
11956
],
[
18270,
18281
],
[
21133,
21150
],
[
21155,
21161
],
[
21171,
21177
],
[
21204,
21210
],
[
21505,
21511
]
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": [
"llvm::getPointersDiff",
"llvm::getPtrStride",
"llvm::isConsecutiveAccess",
"llvm::sortPtrAccesses"
],
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::canFormVector",
"BoUpSLP::canMapToVector",
"BoUpSLP::canVectorizeLoads",
"BoUpSLP::collectUserStores",
"BoUpSLP::findReusedOrderedScalars",
"BoUpSLP::getScalarsVectorizationState",
"BoUpSLP::transformNodes",
"BoUpSLP::tryToVectorizeGatheredLoads",
"BoUpSLP::vectorizeTree",
"SLPVectorizerPass::vectorizeStores",
"buildCompressMask",
"clearVectorizedStores",
"clusterSortPtrAccesses",
"combineOrders",
"fixupOrderingIndices",
"gatherPossiblyVectorizableLoads",
"getPointerDiff",
"getShallowScore",
"getStores",
"insertOrLookup",
"isMaskedLoadCompress",
"isStridedLoad",
"rebase"
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit c807395011a027caae9ac196edfac328fb90443a
Author: Ramkumar Ramachandra <ramkumar.ramachandra@codasip.com>
Date: Thu May 15 10:08:05 2025 +0100
[LAA/SLP] Don't truncate APInt in getPointersDiff (#139941)
Change getPointersDiff to return an std::optional<int64_t>, and fill
this value with using APInt::trySExtValue. This simple change requires
changes to other functions in LAA, and major changes in SLPVectorizer
changing types from 32-bit to 64-bit.
Fixes #139202.
diff --git a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
index f715e0ec8dbb..fea2ede8b5ab 100644
--- a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
+++ b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
@@ -853,11 +853,10 @@ getPtrStride(PredicatedScalarEvolution &PSE, Type *AccessTy, Value *Ptr,
/// is a simple API that does not depend on the analysis pass.
/// \param StrictCheck Ensure that the calculated distance matches the
/// type-based one after all the bitcasts removal in the provided pointers.
-std::optional<int> getPointersDiff(Type *ElemTyA, Value *PtrA, Type *ElemTyB,
- Value *PtrB, const DataLayout &DL,
- ScalarEvolution &SE,
- bool StrictCheck = false,
- bool CheckType = true);
+std::optional<int64_t>
+getPointersDiff(Type *ElemTyA, Value *PtrA, Type *ElemTyB, Value *PtrB,
+ const DataLayout &DL, ScalarEvolution &SE,
+ bool StrictCheck = false, bool CheckType = true);
/// Attempt to sort the pointers in \p VL and return the sorted indices
/// in \p SortedIndices, if reordering is required.
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index af1a3c593c51..ab407e945bc5 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -1541,11 +1541,11 @@ llvm::getPtrStride(PredicatedScalarEvolution &PSE, Type *AccessTy, Value *Ptr,
return std::nullopt;
}
-std::optional<int> llvm::getPointersDiff(Type *ElemTyA, Value *PtrA,
- Type *ElemTyB, Value *PtrB,
- const DataLayout &DL,
- ScalarEvolution &SE, bool StrictCheck,
- bool CheckType) {
+std::optional<int64_t> llvm::getPointersDiff(Type *ElemTyA, Value *PtrA,
+ Type *ElemTyB, Value *PtrB,
+ const DataLayout &DL,
+ ScalarEvolution &SE,
+ bool StrictCheck, bool CheckType) {
assert(PtrA && PtrB && "Expected non-nullptr pointers.");
// Make sure that A and B are different pointers.
@@ -1570,7 +1570,7 @@ std::optional<int> llvm::getPointersDiff(Type *ElemTyA, Value *PtrA,
const Value *PtrB1 = PtrB->stripAndAccumulateConstantOffsets(
DL, OffsetB, /*AllowNonInbounds=*/true);
- int Val;
+ std::optional<int64_t> Val;
if (PtrA1 == PtrB1) {
// Retrieve the address space again as pointer stripping now tracks through
// `addrspacecast`.
@@ -1585,7 +1585,7 @@ std::optional<int> llvm::getPointersDiff(Type *ElemTyA, Value *PtrA,
OffsetB = OffsetB.sextOrTrunc(IdxWidth);
OffsetB -= OffsetA;
- Val = OffsetB.getSExtValue();
+ Val = OffsetB.trySExtValue();
} else {
// Otherwise compute the distance with SCEV between the base pointers.
const SCEV *PtrSCEVA = SE.getSCEV(PtrA);
@@ -1594,10 +1594,14 @@ std::optional<int> llvm::getPointersDiff(Type *ElemTyA, Value *PtrA,
SE.computeConstantDifference(PtrSCEVB, PtrSCEVA);
if (!Diff)
return std::nullopt;
- Val = Diff->getSExtValue();
+ Val = Diff->trySExtValue();
}
- int Size = DL.getTypeStoreSize(ElemTyA);
- int Dist = Val / Size;
+
+ if (!Val)
+ return std::nullopt;
+
+ int64_t Size = DL.getTypeStoreSize(ElemTyA);
+ int64_t Dist = *Val / Size;
// Ensure that the calculated distance matches the type-based one after all
// the bitcasts removal in the provided pointers.
@@ -1616,14 +1620,15 @@ bool llvm::sortPtrAccesses(ArrayRef<Value *> VL, Type *ElemTy,
// first pointer in the array.
Value *Ptr0 = VL[0];
- using DistOrdPair = std::pair<int64_t, int>;
+ using DistOrdPair = std::pair<int64_t, unsigned>;
auto Compare = llvm::less_first();
std::set<DistOrdPair, decltype(Compare)> Offsets(Compare);
Offsets.emplace(0, 0);
bool IsConsecutive = true;
for (auto [Idx, Ptr] : drop_begin(enumerate(VL))) {
- std::optional<int> Diff = getPointersDiff(ElemTy, Ptr0, ElemTy, Ptr, DL, SE,
- /*StrictCheck=*/true);
+ std::optional<int64_t> Diff =
+ getPointersDiff(ElemTy, Ptr0, ElemTy, Ptr, DL, SE,
+ /*StrictCheck=*/true);
if (!Diff)
return false;
@@ -1654,7 +1659,7 @@ bool llvm::isConsecutiveAccess(Value *A, Value *B, const DataLayout &DL,
return false;
Type *ElemTyA = getLoadStoreType(A);
Type *ElemTyB = getLoadStoreType(B);
- std::optional<int> Diff =
+ std::optional<int64_t> Diff =
getPointersDiff(ElemTyA, PtrA, ElemTyB, PtrB, DL, SE,
/*StrictCheck=*/true, CheckType);
return Diff && *Diff == 1;
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index d8cf6b82a197..eb339282fdae 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -1584,7 +1584,7 @@ static void addMask(SmallVectorImpl<int> &Mask, ArrayRef<int> SubMask,
/// before: 6 9 5 4 9 2 1 0
/// after: 6 3 5 4 7 2 1 0
static void fixupOrderingIndices(MutableArrayRef<unsigned> Order) {
- const unsigned Sz = Order.size();
+ const size_t Sz = Order.size();
SmallBitVector UnusedIndices(Sz, /*t=*/true);
SmallBitVector MaskedIndices(Sz);
for (unsigned I = 0; I < Sz; ++I) {
@@ -2216,7 +2216,7 @@ public:
!LI2->isSimple())
return CheckSameEntryOrFail();
- std::optional<int> Dist = getPointersDiff(
+ std::optional<int64_t> Dist = getPointersDiff(
LI1->getType(), LI1->getPointerOperand(), LI2->getType(),
LI2->getPointerOperand(), DL, SE, /*StrictCheck=*/true);
if (!Dist || *Dist == 0) {
@@ -3619,9 +3619,10 @@ private:
/// vector loads/masked gathers instead of regular gathers. Later these loads
/// are reshufled to build final gathered nodes.
void tryToVectorizeGatheredLoads(
- const SmallMapVector<std::tuple<BasicBlock *, Value *, Type *>,
- SmallVector<SmallVector<std::pair<LoadInst *, int>>>,
- 8> &GatheredLoads);
+ const SmallMapVector<
+ std::tuple<BasicBlock *, Value *, Type *>,
+ SmallVector<SmallVector<std::pair<LoadInst *, int64_t>>>, 8>
+ &GatheredLoads);
/// Helper for `findExternalStoreUsersReorderIndices()`. It iterates over the
/// users of \p TE and collects the stores. It returns the map from the store
@@ -5368,7 +5369,7 @@ BoUpSLP::findReusedOrderedScalars(const BoUpSLP::TreeEntry &TE,
// patterns.
SmallVector<Value *> GatheredScalars(TE.Scalars.begin(), TE.Scalars.end());
Type *ScalarTy = GatheredScalars.front()->getType();
- int NumScalars = GatheredScalars.size();
+ size_t NumScalars = GatheredScalars.size();
if (!isValidElementType(ScalarTy))
return std::nullopt;
auto *VecTy = getWidenedType(ScalarTy, NumScalars);
@@ -5442,7 +5443,7 @@ BoUpSLP::findReusedOrderedScalars(const BoUpSLP::TreeEntry &TE,
unsigned Limit = getNumElems(CurrentOrder.size(), PartSz, I);
MutableArrayRef<unsigned> Slice = CurrentOrder.slice(I * PartSz, Limit);
// Shuffle of at least 2 vectors - ignore.
- if (any_of(Slice, [&](int I) { return I != NumScalars; })) {
+ if (any_of(Slice, [&](unsigned I) { return I != NumScalars; })) {
std::fill(Slice.begin(), Slice.end(), NumScalars);
ShuffledSubMasks.set(I);
continue;
@@ -5540,8 +5541,8 @@ BoUpSLP::findReusedOrderedScalars(const BoUpSLP::TreeEntry &TE,
return std::max(Entries[I].front()->getVectorFactor(),
Entries[I].back()->getVectorFactor());
});
- int NumUndefs =
- count_if(CurrentOrder, [&](int Idx) { return Idx == NumScalars; });
+ unsigned NumUndefs =
+ count_if(CurrentOrder, [&](unsigned Idx) { return Idx == NumScalars; });
if (ShuffledSubMasks.all() || (NumScalars > 2 && NumUndefs >= NumScalars / 2))
return std::nullopt;
return std::move(CurrentOrder);
@@ -5868,7 +5869,11 @@ static bool buildCompressMask(ArrayRef<Value *> PointerOps,
Value *Ptr0 = Order.empty() ? PointerOps.front() : PointerOps[Order.front()];
for (unsigned I : seq<unsigned>(1, Sz)) {
Value *Ptr = Order.empty() ? PointerOps[I] : PointerOps[Order[I]];
- unsigned Pos = *getPointersDiff(ScalarTy, Ptr0, ScalarTy, Ptr, DL, SE);
+ std::optional<int64_t> OptPos =
+ getPointersDiff(ScalarTy, Ptr0, ScalarTy, Ptr, DL, SE);
+ if (!OptPos || OptPos > std::numeric_limits<unsigned>::max())
+ return false;
+ unsigned Pos = static_cast<unsigned>(*OptPos);
CompressMask[I] = Pos;
if (!Stride)
continue;
@@ -5894,7 +5899,7 @@ static bool isMaskedLoadCompress(
VectorType *&LoadVecTy) {
InterleaveFactor = 0;
Type *ScalarTy = VL.front()->getType();
- const unsigned Sz = VL.size();
+ const size_t Sz = VL.size();
auto *VecTy = getWidenedType(ScalarTy, Sz);
constexpr TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
SmallVector<int> Mask;
@@ -5921,11 +5926,11 @@ static bool isMaskedLoadCompress(
Ptr0 = PointerOps[Order.front()];
PtrN = PointerOps[Order.back()];
}
- std::optional<int> Diff =
+ std::optional<int64_t> Diff =
getPointersDiff(ScalarTy, Ptr0, ScalarTy, PtrN, DL, SE);
if (!Diff)
return false;
- const unsigned MaxRegSize =
+ const size_t MaxRegSize =
TTI.getRegisterBitWidth(TargetTransformInfo::RGK_FixedWidthVector)
.getFixedValue();
// Check for very large distances between elements.
@@ -6051,9 +6056,10 @@ static bool isStridedLoad(ArrayRef<Value *> VL, ArrayRef<Value *> PointerOps,
ArrayRef<unsigned> Order,
const TargetTransformInfo &TTI, const DataLayout &DL,
ScalarEvolution &SE,
- const bool IsAnyPointerUsedOutGraph, const int Diff) {
- const unsigned Sz = VL.size();
- const unsigned AbsoluteDiff = std::abs(Diff);
+ const bool IsAnyPointerUsedOutGraph,
+ const int64_t Diff) {
+ const size_t Sz = VL.size();
+ const uint64_t AbsoluteDiff = std::abs(Diff);
Type *ScalarTy = VL.front()->getType();
auto *VecTy = getWidenedType(ScalarTy, Sz);
if (IsAnyPointerUsedOutGraph ||
@@ -6061,9 +6067,9 @@ static bool isStridedLoad(ArrayRef<Value *> VL, ArrayRef<Value *> PointerOps,
(Sz > MinProfitableStridedLoads ||
(AbsoluteDiff <= MaxProfitableLoadStride * Sz &&
AbsoluteDiff % Sz == 0 && has_single_bit(AbsoluteDiff / Sz)))) ||
- Diff == -(static_cast<int>(Sz) - 1)) {
- int Stride = Diff / static_cast<int>(Sz - 1);
- if (Diff != Stride * static_cast<int>(Sz - 1))
+ Diff == -(static_cast<int64_t>(Sz) - 1)) {
+ int64_t Stride = Diff / static_cast<int64_t>(Sz - 1);
+ if (Diff != Stride * static_cast<int64_t>(Sz - 1))
return false;
Align Alignment =
cast<LoadInst>(Order.empty() ? VL.front() : VL[Order.front()])
@@ -6081,9 +6087,9 @@ static bool isStridedLoad(ArrayRef<Value *> VL, ArrayRef<Value *> PointerOps,
}
// Iterate through all pointers and check if all distances are
// unique multiple of Dist.
- SmallSet<int, 4> Dists;
+ SmallSet<int64_t, 4> Dists;
for (Value *Ptr : PointerOps) {
- int Dist = 0;
+ int64_t Dist = 0;
if (Ptr == PtrN)
Dist = Diff;
else if (Ptr != Ptr0)
@@ -6122,7 +6128,7 @@ BoUpSLP::canVectorizeLoads(ArrayRef<Value *> VL, const Value *VL0,
// Make sure all loads in the bundle are simple - we can't vectorize
// atomic or volatile loads.
PointerOps.clear();
- const unsigned Sz = VL.size();
+ const size_t Sz = VL.size();
PointerOps.resize(Sz);
auto *POIter = PointerOps.begin();
for (Value *V : VL) {
@@ -6165,10 +6171,10 @@ BoUpSLP::canVectorizeLoads(ArrayRef<Value *> VL, const Value *VL0,
Ptr0 = PointerOps[Order.front()];
PtrN = PointerOps[Order.back()];
}
- std::optional<int> Diff =
+ std::optional<int64_t> Diff =
getPointersDiff(ScalarTy, Ptr0, ScalarTy, PtrN, *DL, *SE);
// Check that the sorted loads are consecutive.
- if (static_cast<unsigned>(*Diff) == Sz - 1)
+ if (static_cast<uint64_t>(*Diff) == Sz - 1)
return LoadsState::Vectorize;
if (isMaskedLoadCompress(VL, PointerOps, Order, *TTI, *DL, *SE, *AC, *DT,
*TLI, [&](Value *V) {
@@ -6427,8 +6433,9 @@ static bool clusterSortPtrAccesses(ArrayRef<Value *> VL,
// Map from bases to a vector of (Ptr, Offset, OrigIdx), which we insert each
// Ptr into, sort and return the sorted indices with values next to one
// another.
- SmallMapVector<std::pair<BasicBlock *, Value *>,
- SmallVector<SmallVector<std::tuple<Value *, int, unsigned>>>, 8>
+ SmallMapVector<
+ std::pair<BasicBlock *, Value *>,
+ SmallVector<SmallVector<std::tuple<Value *, int64_t, unsigned>>>, 8>
Bases;
Bases
.try_emplace(std::make_pair(
@@ -6441,10 +6448,10 @@ static bool clusterSortPtrAccesses(ArrayRef<Value *> VL,
getUnderlyingObject(Ptr, RecursionMaxDepth));
bool Found = any_of(Bases.try_emplace(Key).first->second,
[&, &Cnt = Cnt, &Ptr = Ptr](auto &Base) {
- std::optional<int> Diff = getPointersDiff(
- ElemTy, std::get<0>(Base.front()), ElemTy,
- Ptr, DL, SE,
- /*StrictCheck=*/true);
+ std::optional<int64_t> Diff =
+ getPointersDiff(ElemTy, std::get<0>(Base.front()),
+ ElemTy, Ptr, DL, SE,
+ /*StrictCheck=*/true);
if (!Diff)
return false;
@@ -6494,10 +6501,11 @@ static bool clusterSortPtrAccesses(ArrayRef<Value *> VL,
for (auto &Vec : Base.second) {
if (Vec.size() > 1) {
stable_sort(Vec, llvm::less_second());
- int InitialOffset = std::get<1>(Vec[0]);
+ int64_t InitialOffset = std::get<1>(Vec[0]);
bool AnyConsecutive =
all_of(enumerate(Vec), [InitialOffset](const auto &P) {
- return std::get<1>(P.value()) == int(P.index()) + InitialOffset;
+ return std::get<1>(P.value()) ==
+ int64_t(P.index()) + InitialOffset;
});
// Fill SortedIndices array only if it looks worth-while to sort the
// ptrs.
@@ -7007,7 +7015,7 @@ static void combineOrders(MutableArrayRef<unsigned> Order,
ArrayRef<unsigned> SecondaryOrder) {
assert((SecondaryOrder.empty() || Order.size() == SecondaryOrder.size()) &&
"Expected same size of orders");
- unsigned Sz = Order.size();
+ size_t Sz = Order.size();
SmallBitVector UsedIndices(Sz);
for (unsigned Idx : seq<unsigned>(0, Sz)) {
if (Order[Idx] != Sz)
@@ -7999,7 +8007,7 @@ BoUpSLP::collectUserStores(const BoUpSLP::TreeEntry *TE) const {
if (StoresVec.size() > Lane)
continue;
if (!StoresVec.empty()) {
- std::optional<int> Diff = getPointersDiff(
+ std::optional<int64_t> Diff = getPointersDiff(
SI->getValueOperand()->getType(), SI->getPointerOperand(),
SI->getValueOperand()->getType(),
StoresVec.front()->getPointerOperand(), *DL, *SE,
@@ -8027,14 +8035,14 @@ bool BoUpSLP::canFormVector(ArrayRef<StoreInst *> StoresVec,
// To avoid calling getPointersDiff() while sorting we create a vector of
// pairs {store, offset from first} and sort this instead.
- SmallVector<std::pair<int, unsigned>> StoreOffsetVec;
+ SmallVector<std::pair<int64_t, unsigned>> StoreOffsetVec;
StoreInst *S0 = StoresVec[0];
StoreOffsetVec.emplace_back(0, 0);
Type *S0Ty = S0->getValueOperand()->getType();
Value *S0Ptr = S0->getPointerOperand();
for (unsigned Idx : seq<unsigned>(1, StoresVec.size())) {
StoreInst *SI = StoresVec[Idx];
- std::optional<int> Diff =
+ std::optional<int64_t> Diff =
getPointersDiff(S0Ty, S0Ptr, SI->getValueOperand()->getType(),
SI->getPointerOperand(), *DL, *SE,
/*StrictCheck=*/true);
@@ -8046,7 +8054,7 @@ bool BoUpSLP::canFormVector(ArrayRef<StoreInst *> StoresVec,
return false;
sort(StoreOffsetVec, llvm::less_first());
unsigned Idx = 0;
- int PrevDist = 0;
+ int64_t PrevDist = 0;
for (const auto &P : StoreOffsetVec) {
if (Idx > 0 && P.first != PrevDist + 1)
return false;
@@ -8130,15 +8138,15 @@ void BoUpSLP::buildTree(ArrayRef<Value *> Roots) {
static void gatherPossiblyVectorizableLoads(
const BoUpSLP &R, ArrayRef<Value *> VL, const DataLayout &DL,
ScalarEvolution &SE, const TargetTransformInfo &TTI,
- SmallVectorImpl<SmallVector<std::pair<LoadInst *, int>>> &GatheredLoads,
+ SmallVectorImpl<SmallVector<std::pair<LoadInst *, int64_t>>> &GatheredLoads,
bool AddNew = true) {
if (VL.empty())
return;
Type *ScalarTy = getValueType(VL.front());
if (!isValidElementType(ScalarTy))
return;
- SmallVector<SmallVector<std::pair<LoadInst *, int>>> ClusteredLoads;
- SmallVector<DenseMap<int, LoadInst *>> ClusteredDistToLoad;
+ SmallVector<SmallVector<std::pair<LoadInst *, int64_t>>> ClusteredLoads;
+ SmallVector<DenseMap<int64_t, LoadInst *>> ClusteredDistToLoad;
for (Value *V : VL) {
auto *LI = dyn_cast<LoadInst>(V);
if (!LI)
@@ -8154,7 +8162,7 @@ static void gatherPossiblyVectorizableLoads(
RecursionMaxDepth) &&
"Expected loads with the same type, same parent and same "
"underlying pointer.");
- std::optional<int> Dist = getPointersDiff(
+ std::optional<int64_t> Dist = getPointersDiff(
LI->getType(), LI->getPointerOperand(), Data.front().first->getType(),
Data.front().first->getPointerOperand(), DL, SE,
/*StrictCheck=*/true);
@@ -8176,11 +8184,11 @@ static void gatherPossiblyVectorizableLoads(
}
}
auto FindMatchingLoads =
- [&](ArrayRef<std::pair<LoadInst *, int>> Loads,
- SmallVectorImpl<SmallVector<std::pair<LoadInst *, int>>>
+ [&](ArrayRef<std::pair<LoadInst *, int64_t>> Loads,
+ SmallVectorImpl<SmallVector<std::pair<LoadInst *, int64_t>>>
&GatheredLoads,
SetVector<unsigned> &ToAdd, SetVector<unsigned> &Repeated,
- int &Offset, unsigned &Start) {
+ int64_t &Offset, unsigned &Start) {
if (Loads.empty())
return GatheredLoads.end();
LoadInst *LI = Loads.front().first;
@@ -8191,16 +8199,16 @@ static void gatherPossiblyVectorizableLoads(
if (LI->getParent() != Data.front().first->getParent() ||
LI->getType() != Data.front().first->getType())
continue;
- std::optional<int> Dist =
+ std::optional<int64_t> Dist =
getPointersDiff(LI->getType(), LI->getPointerOperand(),
Data.front().first->getType(),
Data.front().first->getPointerOperand(), DL, SE,
/*StrictCheck=*/true);
if (!Dist)
continue;
- SmallSet<int, 4> DataDists;
+ SmallSet<int64_t, 4> DataDists;
SmallPtrSet<LoadInst *, 4> DataLoads;
- for (std::pair<LoadInst *, int> P : Data) {
+ for (std::pair<LoadInst *, int64_t> P : Data) {
DataDists.insert(P.second);
DataLoads.insert(P.first);
}
@@ -8231,10 +8239,10 @@ static void gatherPossiblyVectorizableLoads(
ToAdd.clear();
return GatheredLoads.end();
};
- for (ArrayRef<std::pair<LoadInst *, int>> Data : ClusteredLoads) {
+ for (ArrayRef<std::pair<LoadInst *, int64_t>> Data : ClusteredLoads) {
unsigned Start = 0;
SetVector<unsigned> ToAdd, LocalToAdd, Repeated;
- int Offset = 0;
+ int64_t Offset = 0;
auto *It = FindMatchingLoads(Data, GatheredLoads, LocalToAdd, Repeated,
Offset, Start);
while (It != GatheredLoads.end()) {
@@ -8249,7 +8257,7 @@ static void gatherPossiblyVectorizableLoads(
return !ToAdd.contains(Idx) && !Repeated.contains(Idx);
})) {
auto AddNewLoads =
- [&](SmallVectorImpl<std::pair<LoadInst *, int>> &Loads) {
+ [&](SmallVectorImpl<std::pair<LoadInst *, int64_t>> &Loads) {
for (unsigned Idx : seq<unsigned>(Data.size())) {
if (ToAdd.contains(Idx) || Repeated.contains(Idx))
continue;
@@ -8259,7 +8267,7 @@ static void gatherPossiblyVectorizableLoads(
if (!AddNew) {
LoadInst *LI = Data.front().first;
It = find_if(
- GatheredLoads, [&](ArrayRef<std::pair<LoadInst *, int>> PD) {
+ GatheredLoads, [&](ArrayRef<std::pair<LoadInst *, int64_t>> PD) {
return PD.front().first->getParent() == LI->getParent() &&
PD.front().first->getType() == LI->getType();
});
@@ -8267,7 +8275,7 @@ static void gatherPossiblyVectorizableLoads(
AddNewLoads(*It);
It = std::find_if(
std::next(It), GatheredLoads.end(),
- [&](ArrayRef<std::pair<LoadInst *, int>> PD) {
+ [&](ArrayRef<std::pair<LoadInst *, int64_t>> PD) {
return PD.front().first->getParent() == LI->getParent() &&
PD.front().first->getType() == LI->getType();
});
@@ -8280,9 +8288,10 @@ static void gatherPossiblyVectorizableLoads(
}
void BoUpSLP::tryToVectorizeGatheredLoads(
- const SmallMapVector<std::tuple<BasicBlock *, Value *, Type *>,
- SmallVector<SmallVector<std::pair<LoadInst *, int>>>,
- 8> &GatheredLoads) {
+ const SmallMapVector<
+ std::tuple<BasicBlock *, Value *, Type *>,
+ SmallVector<SmallVector<std::pair<LoadInst *, int64_t>>>, 8>
+ &GatheredLoads) {
GatheredLoadsEntriesFirst = VectorizableTree.size();
SmallVector<SmallPtrSet<const Value *, 4>> LoadSetsToVectorize(
@@ -8291,8 +8300,8 @@ void BoUpSLP::tryToVectorizeGatheredLoads(
Set.insert_range(VectorizableTree[Idx]->Scalars);
// Sort loads by distance.
- auto LoadSorter = [](const std::pair<LoadInst *, int> &L1,
- const std::pair<LoadInst *, int> &L2) {
+ auto LoadSorter = [](const std::pair<LoadInst *, int64_t> &L1,
+ const std::pair<LoadInst *, int64_t> &L2) {
return L1.second > L2.second;
};
@@ -8454,28 +8463,30 @@ void BoUpSLP::tryToVectorizeGatheredLoads(
};
auto ProcessGatheredLoads =
[&, &TTI = *TTI](
- ArrayRef<SmallVector<std::pair<LoadInst *, int>>> GatheredLoads,
+ ArrayRef<SmallVector<std::pair<LoadInst *, int64_t>>> GatheredLoads,
bool Final = false) {
SmallVector<LoadInst *> NonVectorized;
- for (ArrayRef<std::pair<LoadInst *, int>> LoadsDists : GatheredLoads) {
+ for (ArrayRef<std::pair<LoadInst *, int64_t>> LoadsDists :
+ GatheredLoads) {
if (LoadsDists.size() <= 1) {
NonVectorized.push_back(LoadsDists.back().first);
continue;
}
- SmallVector<std::pair<LoadInst *, int>> LocalLoadsDists(LoadsDists);
+ SmallVector<std::pair<LoadInst *, int64_t>> LocalLoadsDists(
+ LoadsDists);
SmallVector<LoadInst *> OriginalLoads(make_first_range(LoadsDists));
stable_sort(LocalLoadsDists, LoadSorter);
SmallVector<LoadInst *> Loads;
unsigned MaxConsecutiveDistance = 0;
unsigned CurrentConsecutiveDist = 1;
- int LastDist = LocalLoadsDists.front().second;
+ int64_t LastDist = LocalLoadsDists.front().second;
bool AllowMaskedGather = IsMaskedGatherSupported(OriginalLoads);
- for (const std::pair<LoadInst *, int> &L : LocalLoadsDists) {
+ for (const std::pair<LoadInst *, int64_t> &L : LocalLoadsDists) {
if (isVectorized(L.first))
continue;
assert(LastDist >= L.second &&
"Expected first distance always not less than second");
- if (static_cast<unsigned>(LastDist - L.second) ==
+ if (static_cast<uint64_t>(LastDist - L.second) ==
CurrentConsecutiveDist) {
++CurrentConsecutiveDist;
MaxConsecutiveDistance =
@@ -8698,12 +8709,12 @@ void BoUpSLP::tryToVectorizeGatheredLoads(
if (!Ref.empty() && !NonVectorized.empty() &&
std::accumulate(
Ref.begin(), Ref.end(), 0u,
- [](unsigned S,
- ArrayRef<std::pair<LoadInst *, int>> LoadsDists) -> unsigned {
- return S + LoadsDists.size();
- }) != NonVectorized.size() &&
+ [](unsigned S, ArrayRef<std::pair<LoadInst *, int64_t>> LoadsDists)
+ -> unsigned { return S + LoadsDists.size(); }) !=
+ NonVectorized.size() &&
IsMaskedGatherSupported(NonVectorized)) {
- SmallVector<SmallVector<std::pair<LoadInst *, int>>> FinalGatheredLoads;
+ SmallVector<SmallVector<std::pair<LoadInst *, int64_t>>>
+ FinalGatheredLoads;
for (LoadInst *LI : NonVectorized) {
// Reinsert non-vectorized loads to other list of loads with the same
// base pointers.
@@ -9299,10 +9310,10 @@ BoUpSLP::TreeEntry::EntryState BoUpSLP::getScalarsVectorizationState(
Ptr0 = PointerOps[CurrentOrder.front()];
PtrN = PointerOps[CurrentOrder.back()];
}
- std::optional<int> Dist =
+ std::optional<int64_t> Dist =
getPointersDiff(ScalarTy, Ptr0, ScalarTy, PtrN, *DL, *SE);
// Check that the sorted pointer operands are consecutive.
- if (static_cast<unsigned>(*Dist) == VL.size() - 1)
+ if (static_cast<uint64_t>(*Dist) == VL.size() - 1)
return TreeEntry::Vectorize;
}
@@ -10751,7 +10762,7 @@ unsigned BoUpSLP::canMapToVector(Type *T) const {
if (!isValidElementType(EltTy))
return 0;
- uint64_t VTSize = DL->getTypeStoreSizeInBits(getWidenedType(EltTy, N));
+ size_t VTSize = DL->getTypeStoreSizeInBits(getWidenedType(EltTy, N));
if (VTSize < MinVecRegSize || VTSize > MaxVecRegSize ||
VTSize != DL->getTypeStoreSizeInBits(T))
return 0;
@@ -11950,7 +11961,7 @@ void BoUpSLP::transformNodes() {
// A list of loads to be gathered during the vectorization process. We can
// try to vectorize them at the end, if profitable.
SmallMapVector<std::tuple<BasicBlock *, Value *, Type *>,
- SmallVector<SmallVector<std::pair<LoadInst *, int>>>, 8>
+ SmallVector<SmallVector<std::pair<LoadInst *, int64_t>>>, 8>
GatheredLoads;
for (std::unique_ptr<TreeEntry> &TE : VectorizableTree) {
@@ -18270,12 +18281,13 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) {
Value *Ptr0 = cast<LoadInst>(E->Scalars.front())->getPointerOperand();
Value *PtrN = cast<LoadInst>(E->Scalars.back())->getPointerOperand();
PO = IsReverseOrder ? PtrN : Ptr0;
- std::optional<int> Diff = getPointersDiff(
+ std::optional<int64_t> Diff = getPointersDiff(
VL0->getType(), Ptr0, VL0->getType(), PtrN, *DL, *SE);
Type *StrideTy = DL->getIndexType(PO->getType());
Value *StrideVal;
if (Diff) {
- int Stride = *Diff / (static_cast<int>(E->Scalars.size()) - 1);
+ int64_t Stride =
+ *Diff / (static_cast<int64_t>(E->Scalars.size()) - 1);
StrideVal =
ConstantInt::get(StrideTy, (IsReverseOrder ? -1 : 1) * Stride *
DL->getTypeAllocSize(ScalarTy));
@@ -21133,18 +21145,18 @@ public:
/// \p PtrDist.
/// Does nothing if there is already a store with that \p PtrDist.
/// \returns The previously associated Instruction index, or std::nullopt
- std::optional<unsigned> insertOrLookup(unsigned InstrIdx, int PtrDist) {
+ std::optional<unsigned> insertOrLookup(unsigned InstrIdx, int64_t PtrDist) {
auto [It, Inserted] = Instrs.emplace(PtrDist, InstrIdx);
- return Inserted ? std::nullopt : std::optional<unsigned>(It->second);
+ return Inserted ? std::nullopt : std::make_optional(It->second);
}
- using DistToInstMap = std::map<int, unsigned>;
+ using DistToInstMap = std::map<int64_t, unsigned>;
const DistToInstMap &getStores() const { return Instrs; }
/// If \p SI is related to this group of stores, return the distance of its
/// pointer operand to the one the group's BaseInstr.
- std::optional<int> getPointerDiff(StoreInst &SI, const DataLayout &DL,
- ScalarEvolution &SE) const {
+ std::optional<int64_t> getPointerDiff(StoreInst &SI, const DataLayout &DL,
+ ScalarEvolution &SE) const {
StoreInst &BaseStore = *AllStores[BaseInstrIdx];
return getPointersDiff(
BaseStore.getValueOperand()->getType(), BaseStore.getPointerOperand(),
@@ -21155,7 +21167,7 @@ public:
/// Recompute the pointer distances to be based on \p NewBaseInstIdx.
/// Stores whose index is less than \p MinSafeIdx will be dropped.
void rebase(unsigned MinSafeIdx, unsigned NewBaseInstIdx,
- int DistFromCurBase) {
+ int64_t DistFromCurBase) {
DistToInstMap PrevSet = std::move(Instrs);
reset(NewBaseInstIdx);
@@ -21171,7 +21183,7 @@ public:
/// Remove all stores that have been vectorized from this group.
void clearVectorizedStores(const BoUpSLP::ValueSet &VectorizedStores) {
DistToInstMap::reverse_iterator LastVectorizedStore = find_if(
- reverse(Instrs), [&](const std::pair<int, unsigned> &DistAndIdx) {
+ reverse(Instrs), [&](const std::pair<int64_t, unsigned> &DistAndIdx) {
return VectorizedStores.contains(AllStores[DistAndIdx.second]);
});
@@ -21204,7 +21216,7 @@ bool SLPVectorizerPass::vectorizeStores(
bool Changed = false;
auto TryToVectorize = [&](const RelatedStoreInsts::DistToInstMap &StoreSeq) {
- int PrevDist = -1;
+ int64_t PrevDist = -1;
BoUpSLP::ValueList Operands;
// Collect the chain into a list.
for (auto [Idx, Data] : enumerate(StoreSeq)) {
@@ -21505,7 +21517,7 @@ bool SLPVectorizerPass::vectorizeStores(
// dependencies and no need to waste compile time to try to vectorize them.
// - Try to vectorize the sequence {1, {1, 0}, {3, 2}}.
auto FillStoresSet = [&](unsigned Idx, StoreInst *SI) {
- std::optional<int> PtrDist;
+ std::optional<int64_t> PtrDist;
auto *RelatedStores = find_if(
SortedStores, [&PtrDist, SI, this](const RelatedStoreInsts &StoreSeq) {
PtrDist = StoreSeq.getPointerDiff(*SI, *DL, *SE);
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/long-pointer-distance.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-grtev4-linux-gnu < %s -mattr=+avx"
],
"tests": [
{
"test_name": "test",
"test_body": "define void @test(ptr %this) {\nentry:\n store i64 1, ptr %this, align 8\n %b = getelementptr i8, ptr %this, i64 8\n store i64 2, ptr %b, align 8\n %c = getelementptr i8, ptr %this, i64 4294967312\n store i64 3, ptr %c, align 8\n %d = getelementptr i8, ptr %this, i64 4294967320\n store i64 4, ptr %d, align 8\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[SLPV] Pointer offsets truncated to 32-bits, resulting in wrong code",
"body": "Consider:\n\n```\n$ cat t.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\"\ntarget triple = \"x86_64-grtev4-linux-gnu\"\n\ndefine void @_ZN12_GLOBAL__N_111LargeObjectILm4294967296EEC2Em(ptr %this) #0 {\nentry:\n store i64 1, ptr %this, align 8\n %b = getelementptr i8, ptr %this, i64 8\n store i64 2, ptr %b, align 8\n %c = getelementptr i8, ptr %this, i64 u0x100000010\n store i64 3, ptr %c, align 8\n %d = getelementptr i8, ptr %this, i64 u0x100000018\n store i64 4, ptr %d, align 8\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+aes,+avx,+cmov,+crc32,+cx16,+cx8,+fxsr,+mmx,+pclmul,+popcnt,+prfchw,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave\" }\n\n$ opt -passes=slp-vectorizer t.ll -S -o -\n; ModuleID = 't.ll'\nsource_filename = \"t.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\"\ntarget triple = \"x86_64-grtev4-linux-gnu\"\n\ndefine void @_ZN12_GLOBAL__N_111LargeObjectILm4294967296EEC2Em(ptr %this) #0 {\nentry:\n store <4 x i64> <i64 1, i64 2, i64 3, i64 4>, ptr %this, align 8\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+aes,+avx,+cmov,+crc32,+cx16,+cx8,+fxsr,+mmx,+pclmul,+popcnt,+prfchw,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave\" }\n```\n\nClearly, somewhere inside SLPV, the GEP offsets here are truncated from 64-bits to 32. To quickly check SLPV with static analysis, I did this:\n\n```\n$ ninja opt # build everything once\n$ touch ../llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n$ CCC_OVERRIDE_OPTIONS='+-Wshorten-64-to-32' ninja opt | tee slpv-truncations.txt\n...\n```\n\nUnfortunately, there are 733 hits:\n```\n$ grep warning: slpv-truncations.txt | wc -l\n 733\n```\n\nThis is not a recent regression, it goes back to LLVM 14 and earlier: https://godbolt.org/z/9baE551T7 LLVM 14 is just as far back as the IR is parseable out of the box.\n\nI think the next move here would be to do a global search & replace of getZExtValue with some variant that asserts when the result is wider than 32-bits, or to focus only on the warnings that include getZExtValue in the warning text snippet.",
"author": "rnk",
"labels": [
"miscompilation",
"llvm:SLPVectorizer",
"llvm:analysis"
],
"comments": [
{
"author": "alexey-bataev",
"body": "LoopAccessAnalysis.cpp, getPointersDiff() returns distance -16 for pointers %b and %d, there is an implicit cast from int64_t to int, which looses the info\nhttps://github.com/llvm/llvm-project/blob/9eeae5a5de41b22d31d9037be2acc45dd7af4192/llvm/lib/Analysis/LoopAccessAnalysis.cpp#L1598\nhttps://github.com/llvm/llvm-project/blob/9eeae5a5de41b22d31d9037be2acc45dd7af4192/llvm/lib/Analysis/LoopAccessAnalysis.cpp#L1589\n"
}
]
}
| true
|
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
|
Cannot find a good commit
| null |
174622
|
https://github.com/llvm/llvm-project/issues/174622
|
crash
|
c6db8f4229d70169949430185e156fb2e6e4150e
| 2026-01-06T16:57:34
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "2f7e218017db69454ea84e1849fcb9a11b1f7fef",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": [
[
82,
87
],
[
140,
145
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": [
"vputils::getSCEVExprForVPValue",
"vputils::isHeaderMask"
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 2f7e218017db69454ea84e1849fcb9a11b1f7fef
Author: Florian Hahn <flo@fhahn.com>
Date: Sun Jan 11 20:51:12 2026 +0000
[VPlan] Add missing sext(sub) SCEV fold to getSCEVExprForVPValue.
SCEV has a manual fold when doing SCEV construction from IR, that is not
integrated in the regular SCEV construction functions. Mirror the
behavior in getSCEVExprForVPValue, to match results when constructing
SCEVs from IR.
Fixes https://github.com/llvm/llvm-project/issues/174622.
diff --git a/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp b/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
index ae36df06bb81..09b77297a151 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
@@ -82,6 +82,61 @@ bool vputils::isHeaderMask(const VPValue *V, const VPlan &Plan) {
B == Plan.getBackedgeTakenCount();
}
+/// Returns true if \p R propagates poison from any operand to its result.
+static bool propagatesPoisonFromRecipeOp(const VPRecipeBase *R) {
+ return TypeSwitch<const VPRecipeBase *, bool>(R)
+ .Case<VPWidenGEPRecipe, VPWidenCastRecipe>(
+ [](const VPRecipeBase *) { return true; })
+ .Case<VPReplicateRecipe>([](const VPReplicateRecipe *Rep) {
+ // GEP and casts propagate poison from all operands.
+ unsigned Opcode = Rep->getOpcode();
+ return Opcode == Instruction::GetElementPtr ||
+ Instruction::isCast(Opcode);
+ })
+ .Default([](const VPRecipeBase *) { return false; });
+}
+
+/// Returns true if \p V being poison is guaranteed to trigger UB because it
+/// propagates to the address of a memory recipe.
+static bool poisonGuaranteesUB(const VPValue *V) {
+ SmallPtrSet<const VPValue *, 8> Visited;
+ SmallVector<const VPValue *, 16> Worklist;
+
+ Worklist.push_back(V);
+
+ while (!Worklist.empty()) {
+ const VPValue *Current = Worklist.pop_back_val();
+ if (!Visited.insert(Current).second)
+ continue;
+
+ for (VPUser *U : Current->users()) {
+ // Check if Current is used as an address operand for load/store.
+ if (auto *MemR = dyn_cast<VPWidenMemoryRecipe>(U)) {
+ if (MemR->getAddr() == Current)
+ return true;
+ continue;
+ }
+ if (auto *Rep = dyn_cast<VPReplicateRecipe>(U)) {
+ unsigned Opcode = Rep->getOpcode();
+ if ((Opcode == Instruction::Load && Rep->getOperand(0) == Current) ||
+ (Opcode == Instruction::Store && Rep->getOperand(1) == Current))
+ return true;
+ }
+
+ // Check if poison propagates through this recipe to any of its users.
+ auto *R = cast<VPRecipeBase>(U);
+ for (const VPValue *Op : R->operands()) {
+ if (Op == Current && propagatesPoisonFromRecipeOp(R)) {
+ Worklist.push_back(R->getVPSingleValue());
+ break;
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
const SCEV *vputils::getSCEVExprForVPValue(const VPValue *V,
PredicatedScalarEvolution &PSE,
const Loop *L) {
@@ -140,6 +195,20 @@ const SCEV *vputils::getSCEVExprForVPValue(const VPValue *V,
if (match(V, m_SExt(m_VPValue(LHSVal)))) {
const VPlan *Plan = V->getDefiningRecipe()->getParent()->getPlan();
Type *DestTy = VPTypeAnalysis(*Plan).inferScalarType(V);
+
+ // Mirror SCEV's createSCEV handling for sext(sub nsw): push sign extension
+ // onto the operands before computing the subtraction.
+ VPValue *SubLHS, *SubRHS;
+ auto *SubR = dyn_cast<VPRecipeWithIRFlags>(LHSVal);
+ if (match(LHSVal, m_Sub(m_VPValue(SubLHS), m_VPValue(SubRHS))) && SubR &&
+ SubR->hasNoSignedWrap() && poisonGuaranteesUB(LHSVal)) {
+ const SCEV *V1 = getSCEVExprForVPValue(SubLHS, PSE, L);
+ const SCEV *V2 = getSCEVExprForVPValue(SubRHS, PSE, L);
+ if (!isa<SCEVCouldNotCompute>(V1) && !isa<SCEVCouldNotCompute>(V2))
+ return SE.getMinusSCEV(SE.getSignExtendExpr(V1, DestTy),
+ SE.getSignExtendExpr(V2, DestTy), SCEV::FlagNSW);
+ }
+
return CreateSCEV({LHSVal}, [&](ArrayRef<const SCEV *> Ops) {
return SE.getSignExtendExpr(Ops[0], DestTy);
});
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/induction-costs.ll",
"commands": [
"opt -p loop-vectorize -mtriple=arm64-apple-macosx -S %s"
],
"tests": [
{
"test_name": "sext_sub_nsw_for_address",
"test_body": "target datalayout = \"e-m:o-i64:64-i128:128-n32:64-S128\"\n\ndefine void @sext_sub_nsw_for_address(ptr %base, i64 %n, ptr %src) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %count = phi i64 [ %n, %entry ], [ %count.next, %loop ]\n %iv.i32 = phi i32 [ 0, %entry ], [ %iv.i32.next, %loop ]\n %gep.1 = getelementptr double, ptr %src, i64 %iv\n %gep.2 = getelementptr i8, ptr %gep.1, i64 -8\n store double 0.000000e+00, ptr %gep.2, align 8\n %neg = sub nsw i32 0, %iv.i32\n %neg.ext = sext i32 %neg to i64\n %gep.3 = getelementptr double, ptr %base, i64 %neg.ext\n %l = load double, ptr %gep.3, align 8\n store double %l, ptr %gep.1, align 8\n %iv.i32.next = add i32 %iv.i32, 2\n %iv.next = add i64 %iv, 2\n %count.next = add i64 %count, -1\n %ec = icmp sgt i64 %count, 0\n br i1 %ec, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { \"target-cpu\"=\"neoverse-v2\" }\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[LV]VPlan cost model and legacy cost model disagreed",
"body": "https://godbolt.org/z/Gr8nEMWK9\n\nLooks like it started crashing after `Fri Dec 26 13:38:14 2025 | LLVM | 60e5b86052ca1103499e87ee32c8228c71b6c753 | [VPlan] Support extends and truncs in getSCEVExprForVPValue. (NFCI)`\n@fhahn ",
"author": "alexey-bataev",
"labels": [
"vectorizers",
"crash-on-valid"
],
"comments": [
{
"author": "alexey-bataev",
"body": "Ping"
},
{
"author": "fhahn",
"body": "Thanks will take a look"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null | null |
117157
|
https://github.com/llvm/llvm-project/issues/117157
|
crash
|
d0246fe1e79c6ea06b6b72f66a71a96a3342aa42
| 2024-11-21T13:15:24
|
[
"llvm/test/Transforms/LICM"
] |
{
"fix_commit": "d1408667de830da8817c24cb9788da6caae551c7",
"components": [
"MemorySSAUpdater"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": [
[
411,
427
],
[
504,
514
]
],
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": [
"MemorySSAUpdater::fixupDefs",
"MemorySSAUpdater::insertDef"
],
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit d1408667de830da8817c24cb9788da6caae551c7
Author: Nikita Popov <npopov@redhat.com>
Date: Thu Sep 4 10:23:29 2025 +0200
[MemorySSA] Don't create phi nodes in fixupDefs() (#156021)
The general flow when inserting MemoryDefs is:
* Insert the def and set it's defining access (may insert phis)
* Insert IDF phis
* Update defining access for defs after the new one (fixupDefs)
* Rename uses if requested
fixupDefs() uses getPreviousDef() which can create new MemoryPHIs, but
for which we're not going to insert IDF phis, so the required dominance
property may not hold.
I believe this is a leftover from a time before the "Insert IDF phis"
step existed. Now that step should already ensure that all necessary
MemoryPhis have been inserted, and we only need to update them.
The fixupDefs() implementation was also returning after updating a
single access, which is not right.
Fixes https://github.com/llvm/llvm-project/issues/47875.
Fixes https://github.com/llvm/llvm-project/issues/117157.
Fixes https://github.com/llvm/llvm-project/issues/152998.
Fixes https://github.com/llvm/llvm-project/issues/155161.
Fixes https://github.com/llvm/llvm-project/issues/155184.
diff --git a/llvm/lib/Analysis/MemorySSAUpdater.cpp b/llvm/lib/Analysis/MemorySSAUpdater.cpp
index ecfecb03c375..bb3e679219ae 100644
--- a/llvm/lib/Analysis/MemorySSAUpdater.cpp
+++ b/llvm/lib/Analysis/MemorySSAUpdater.cpp
@@ -411,17 +411,11 @@ void MemorySSAUpdater::insertDef(MemoryDef *MD, bool RenameUses) {
FixupList.push_back(MD);
}
- // Remember the index where we stopped inserting new phis above, since the
- // fixupDefs call in the loop below may insert more, that are already minimal.
+ // Update defining access of following defs.
unsigned NewPhiIndexEnd = InsertedPHIs.size();
-
- while (!FixupList.empty()) {
- unsigned StartingPHISize = InsertedPHIs.size();
- fixupDefs(FixupList);
- FixupList.clear();
- // Put any new phis on the fixup list, and process them
- FixupList.append(InsertedPHIs.begin() + StartingPHISize, InsertedPHIs.end());
- }
+ fixupDefs(FixupList);
+ assert(NewPhiIndexEnd == InsertedPHIs.size() &&
+ "Should not insert new phis during fixupDefs()");
// Optimize potentially non-minimal phis added in this method.
unsigned NewPhiSize = NewPhiIndexEnd - NewPhiIndex;
@@ -504,11 +498,8 @@ void MemorySSAUpdater::fixupDefs(const SmallVectorImpl<WeakVH> &Vars) {
assert(MSSA->dominates(NewDef, FirstDef) &&
"Should have dominated the new access");
- // This may insert new phi nodes, because we are not guaranteed the
- // block we are processing has a single pred, and depending where the
- // store was inserted, it may require phi nodes below it.
- cast<MemoryDef>(FirstDef)->setDefiningAccess(getPreviousDef(FirstDef));
- return;
+ cast<MemoryDef>(FirstDef)->setDefiningAccess(NewDef);
+ continue;
}
// We didn't find a def, so we must continue.
for (const auto *S : successors(FixupBlock)) {
|
[
{
"file": "llvm/test/Transforms/LICM/pr117157.ll",
"commands": [
"opt -S -passes=licm -verify-memoryssa < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @test(ptr %p) {\n;\nentry:\n br label %loop0\n\nloop0: ; preds = %loop0.latch, %entry\n br label %loop1\n\nloop1: ; preds = %loop1, %loop0\n %dec10 = phi i64 [ 0, %loop0 ], [ 1, %loop1 ]\n store i64 %dec10, ptr %p\n br i1 false, label %loop1.exit, label %loop1\n\nloop1.exit: ; preds = %loop1\n switch i32 0, label %loop0.latch [\n i32 0, label %loop0.latch\n i32 2, label %loop3.preheader\n i32 1, label %loop2\n ]\n\nloop2: ; preds = %loop2.latch, %loop1.exit\n br i1 false, label %loop0.latch, label %loop3.preheader\n\nloop3.preheader: ; preds = %loop1.exit, %loop2\n br label %loop3\n\nloop3: ; preds = %loop3.preheader, %loop3\n switch i32 0, label %exit [\n i32 0, label %loop3\n i32 1, label %loop2.latch\n ]\n\nloop2.latch: ; preds = %loop3\n br label %loop2\n\nloop0.latch: ; preds = %loop2, %loop1.exit, %loop1.exit\n store i64 0, ptr %p\n br label %loop0\n\nexit: ; preds = %loop3\n store i64 1, ptr %p\n ret void\n}",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[clang] Crash at O1: Assertion `MSSA->dominates(NewDef, FirstDef) && \"Should have dominated the new access\"' failed",
"body": "When I compiled this code with -O1, it crashed:\n\n```c\nint a, b, c, d;\nlong e, f;\nlong *g;\nchar h;\nstatic long i[];\nvoid j() {\n while (1) {\n if (a == 0)\n break;\n if (a == 1) {\n if (b == 0)\n break;\n } else if (a == 2)\n if (c)\n break;\n else\n a;\n }\n}\nvoid k() {\n for (; d; e++) {\n h = 2;\n for (; h; h++) {\n *g || (i[1] &= 0);\n --f;\n }\n j();\n }\n}\n```\n\nCompiler Explorer: https://godbolt.org/z/fGf7hjTxe\n\nCrash is\n\n```\nclang: /root/llvm-project/llvm/lib/Analysis/MemorySSAUpdater.cpp:504: void llvm::MemorySSAUpdater::fixupDefs(const llvm::SmallVectorImpl<llvm::WeakVH>&): Assertion `MSSA->dominates(NewDef, FirstDef) && \"Should have dominated the new access\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\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 -O1 -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<interleave-forced-only;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>,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O1>,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-mssa(licm<allowspeculation>)\" on function \"k\"\n #0 0x0000000003bf59c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3bf59c8)\n #1 0x0000000003bf36cc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3bf36cc)\n #2 0x0000000003b40db8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0\n #3 0x0000751620442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #4 0x00007516204969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #5 0x0000751620442476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #6 0x00007516204287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #7 0x000075162042871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #8 0x0000751620439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #9 0x0000000002bf1b11 llvm::MemorySSAUpdater::fixupDefs(llvm::SmallVectorImpl<llvm::WeakVH> const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x2bf1b11)\n#10 0x0000000002bf205b llvm::MemorySSAUpdater::insertDef(llvm::MemoryDef*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x2bf205b)\n#11 0x00000000039fa897 (anonymous namespace)::LoopPromoter::doExtraRewritesBeforeFinalDeletion() LICM.cpp:0:0\n#12 0x0000000003d8281e llvm::LoadAndStorePromoter::run(llvm::SmallVectorImpl<llvm::Instruction*> const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3d8281e)\n#13 0x00000000039f8dae llvm::promoteLoopAccessesToScalars(llvm::SmallSetVector<llvm::Value*, 8u> const&, llvm::SmallVectorImpl<llvm::BasicBlock*>&, llvm::SmallVectorImpl<llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>, false, false>>&, llvm::SmallVectorImpl<llvm::MemoryAccess*>&, llvm::PredIteratorCache&, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::TargetLibraryInfo const*, llvm::TargetTransformInfo*, llvm::Loop*, llvm::MemorySSAUpdater&, llvm::ICFLoopSafetyInfo*, llvm::OptimizationRemarkEmitter*, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x39f8dae)\n#14 0x0000000003a06a36 (anonymous namespace)::LoopInvariantCodeMotion::runOnLoop(llvm::Loop*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::TargetLibraryInfo*, llvm::TargetTransformInfo*, llvm::ScalarEvolution*, llvm::MemorySSA*, llvm::OptimizationRemarkEmitter*, bool) (.part.0) LICM.cpp:0:0\n#15 0x0000000003a075f8 llvm::LICMPass::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3a075f8)\n#16 0x00000000052606ee llvm::detail::PassModel<llvm::Loop, llvm::LICMPass, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x52606ee)\n#17 0x0000000003a0fd93 llvm::FunctionToLoopPassAdaptor::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3a0fd93)\n#18 0x00000000010ee88e llvm::detail::PassModel<llvm::Function, llvm::FunctionToLoopPassAdaptor, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x10ee88e)\n#19 0x00000000035a6b68 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x35a6b68)\n#20 0x00000000010eee9e 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+0x10eee9e)\n#21 0x00000000035a558e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x35a558e)\n#22 0x00000000010ee54e 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+0x10ee54e)\n#23 0x00000000035a4fc0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x35a4fc0)\n#24 0x0000000003ea6cd3 (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 0x0000000003eaa4e5 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+0x3eaa4e5)\n#26 0x00000000045780ae clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45780ae)\n#27 0x00000000065135cc clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x65135cc)\n#28 0x0000000004578488 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4578488)\n#29 0x0000000004832ba9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4832ba9)\n#30 0x00000000047b2a9e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x47b2a9e)\n#31 0x000000000491d8ee clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x491d8ee)\n#32 0x0000000000ca9677 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xca9677)\n#33 0x0000000000ca123a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#34 0x00000000045bb689 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 0x0000000003b41264 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3b41264)\n#36 0x00000000045bbc7f 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 0x0000000004581f6d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4581f6d)\n#38 0x000000000458305d 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+0x458305d)\n#39 0x000000000458a415 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x458a415)\n#40 0x0000000000ca64e3 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xca64e3)\n#41 0x0000000000b7d0f4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xb7d0f4)\n#42 0x0000751620429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#43 0x0000751620429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#44 0x0000000000ca0cee _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xca0cee)\n```",
"author": "cardigan1008",
"labels": [
"loopoptim",
"crash-on-valid"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Reproducer: https://godbolt.org/z/T33hbvach\r\n```\r\n; bin/opt -passes=licm test.ll -S\r\ndefine void @k(ptr %p) {\r\nentry:\r\n br label %for.cond1.preheader\r\n\r\nfor.cond1.preheader: ; preds = %j.exit, %entry\r\n br label %for.body3\r\n\r\nfor.body3: ; preds = %for.body3, %for.cond1.preheader\r\n %dec10 = phi i64 [ 0, %for.cond1.preheader ], [ 1, %for.body3 ]\r\n store i64 %dec10, ptr %p, align 8\r\n br i1 false, label %for.end, label %for.body3\r\n\r\nfor.end: ; preds = %for.body3\r\n switch i32 0, label %j.exit [\r\n i32 0, label %j.exit\r\n i32 2, label %if.end12.preheader.i\r\n i32 1, label %if.then2.i\r\n ]\r\n\r\nif.then2.i: ; preds = %if.end12.preheader.i, %for.end\r\n br i1 false, label %j.exit, label %if.end12.preheader.i\r\n\r\nif.end12.preheader.i: ; preds = %if.end12.preheader.i, %if.then2.i, %for.end\r\n switch i32 0, label %if.end12.preheader.i.split [\r\n i32 0, label %if.end12.preheader.i\r\n i32 1, label %if.then2.i\r\n ]\r\n\r\nif.end12.preheader.i.split: ; preds = %if.end12.preheader.i\r\n store i8 0, ptr %p, align 1\r\n ret void\r\n\r\nj.exit: ; preds = %if.then2.i, %for.end, %for.end\r\n store i64 0, ptr %p, align 8\r\n br label %for.cond1.preheader\r\n}\r\n\r\n```"
},
{
"author": "nikic",
"body": "Cleaned up the naming a bit:\n```llvm\ndefine void @test(ptr %p) {\nentry:\n br label %loop0\n\nloop0: ; preds = %loop0.latch, %entry\n br label %loop1\n\nloop1: ; preds = %loop1, %loop0\n %dec10 = phi i64 [ 0, %loop0 ], [ 1, %loop1 ]\n store i64 %dec10, ptr %p\n br i1 false, label %loop1.exit, label %loop1\n\nloop1.exit: ; preds = %loop1\n switch i32 0, label %loop0.latch [\n i32 0, label %loop0.latch\n i32 2, label %loop3.preheader\n i32 1, label %loop2\n ]\n\nloop2: ; preds = %loop2.latch, %loop1.exit\n br i1 false, label %loop0.latch, label %loop3.preheader\n\nloop3.preheader: ; preds = %loop1.exit, %loop2\n br label %loop3\n\nloop3: ; preds = %loop3.preheader, %loop3\n switch i32 0, label %exit [\n i32 0, label %loop3\n i32 1, label %loop2.latch\n ]\n\nloop2.latch: ; preds = %loop3\n br label %loop2\n\nloop0.latch: ; preds = %loop2, %loop1.exit, %loop1.exit\n store i64 0, ptr %p\n br label %loop0\n\nexit: ; preds = %loop3\n store i64 1, ptr %p\n ret void\n}\n```\n\nInitial observations:\n\n * Store is inserted into loop1.exit\n * No MemoryPhis are created for defining access\n * IDF is loop0, which already has MemoryPhi. So the fixup list only contains the new MemoryDef.\n\nThe first fixupDefs call produces:\n```llvm\ndefine void @test(ptr %p) {\nentry:\n br label %loop0\n\nloop0: ; preds = %loop0.latch, %entry\n; 4 = MemoryPhi({entry,liveOnEntry},{loop0.latch,2})\n br label %loop1\n\nloop1: ; preds = %loop1, %loop0\n; 5 = MemoryPhi({loop0,4},{loop1,1})\n %dec10 = phi i64 [ 0, %loop0 ], [ 1, %loop1 ]\n; 1 = MemoryDef(5)\n store i64 %dec10, ptr %p, align 4\n br i1 false, label %loop1.exit, label %loop1\n\nloop1.exit: ; preds = %loop1\n %dec10.lcssa = phi i64 [ %dec10, %loop1 ]\n; 6 = MemoryDef(1)\n store i64 %dec10.lcssa, ptr %p, align 4\n switch i32 0, label %loop0.latch [\n i32 0, label %loop0.latch\n i32 2, label %loop3.preheader\n i32 1, label %loop2\n ]\n\nloop2: ; preds = %loop2.latch, %loop1.exit\n; 8 = MemoryPhi({loop2.latch,9},{loop1.exit,6})\n br i1 false, label %loop0.latch, label %loop3.preheader\n\nloop3.preheader: ; preds = %loop2, %loop1.exit\n; 9 = MemoryPhi({loop2,8},{loop1.exit,6})\n br label %loop3\n\nloop3: ; preds = %loop3, %loop3.preheader\n switch i32 0, label %exit [\n i32 0, label %loop3\n i32 1, label %loop2.latch\n ]\n\nloop2.latch: ; preds = %loop3\n br label %loop2\n\nloop0.latch: ; preds = %loop2, %loop1.exit, %loop1.exit\n; 2 = MemoryDef(1)\n store i64 0, ptr %p, align 4\n br label %loop0\n\nexit: ; preds = %loop3\n; 3 = MemoryDef(9)\n store i64 1, ptr %p, align 4\n ret void\n}\n```\nThe phis are inserted when process the store in exit. And then the next fixupDefs() call asserts when processing the store in loop0.latch.\n\nThe non-dominating access is `8 = MemoryPhi({loop2.latch,9},{loop1.exit,6})`.\n\nI guess at this point the assumption is that we have already inserted all the necessary IDF phis, but it may not happen if we insert new phis during fixupDefs."
},
{
"author": "nikic",
"body": "Something I don't get in the fixupDefs implementation is why this returns after updating a single def: https://github.com/llvm/llvm-project/blob/7f1185058279afeb2c88243edc031f06e27cc21b/llvm/lib/Analysis/MemorySSAUpdater.cpp#L511 That doesn't look correct.\n\nFor this test case, just replacing `return` with `continue` results in a different assert though, as phis are expected to be handled separately."
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
|
Cannot find a good commit
| null |
155738
|
https://github.com/llvm/llvm-project/issues/155738
|
crash
|
78b45b489559cd44437af4eac6c10188eb0cec3c
| 2025-08-28T03:01:57
|
[
"llvm/test/Transforms/FunctionSpecialization"
] |
{
"fix_commit": "0ace96cca79c03c668b260dd01996e3d693e3f4f",
"components": [
"SCCP"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": [
[
330,
341
]
],
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": [
"runIPSCCP"
],
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 0ace96cca79c03c668b260dd01996e3d693e3f4f
Author: XChy <xxs_chy@outlook.com>
Date: Thu Aug 28 19:13:27 2025 +0800
[SCCP][FuncSpec] Poison unreachable constant global variable user (#155753)
Fixes #155738.
The original assumption "we already replaced its users with a constant"
for the global variable becomes incorrect after #154668. The users in
the dead function are not simplified, in fact.
This patch poisons all the unsimplified constant global variable users.
diff --git a/llvm/lib/Transforms/IPO/SCCP.cpp b/llvm/lib/Transforms/IPO/SCCP.cpp
index e98a70f228ad..f4961faf7ad1 100644
--- a/llvm/lib/Transforms/IPO/SCCP.cpp
+++ b/llvm/lib/Transforms/IPO/SCCP.cpp
@@ -330,12 +330,15 @@ static bool runIPSCCP(
LLVM_DEBUG(dbgs() << "Found that GV '" << GV->getName()
<< "' is constant!\n");
for (User *U : make_early_inc_range(GV->users())) {
- // We can remove LoadInst here, because we already replaced its users
- // with a constant.
+ // We can remove LoadInst here. The LoadInsts in dead functions marked by
+ // FuncSpec are not simplified to constants, thus poison them.
assert((isa<StoreInst>(U) || isa<LoadInst>(U)) &&
"Only Store|Load Instruction can be user of GlobalVariable at "
"reaching here.");
- cast<Instruction>(U)->eraseFromParent();
+ Instruction *I = cast<Instruction>(U);
+ if (isa<LoadInst>(I))
+ I->replaceAllUsesWith(PoisonValue::get(I->getType()));
+ I->eraseFromParent();
}
// Try to create a debug constant expression for the global variable
|
[
{
"file": "llvm/test/Transforms/FunctionSpecialization/dead-gv-load.ll",
"commands": [
"opt -passes=ipsccp --funcspec-min-function-size=1 -S < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n@gv = internal global ptr null\n\ndefine i8 @caller() {\n;\nentry:\n %call1 = call i8 @callee(i32 1)\n %call2 = call i8 @callee(i32 0)\n ret i8 %call2\n}\n\ndefine internal i8 @callee(i32 %arg) {\nentry:\n %useless = icmp ne i32 %arg, 0\n br label %loop\n\nloop: ; preds = %loop, %entry\n br label %loop\n\ndead_bb: ; No predecessors!\n %l1 = load ptr, ptr @gv, align 8\n %l2 = load ptr, ptr %l1, align 8\n ret i8 0\n}",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[IPSCCP] Use still stuck around after Def is destroyed",
"body": "Reproducer:\n```\n; bin/opt -passes=ipsccp --funcspec-min-function-size=1 reduced.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@g_315 = internal global ptr null\n\ndefine i8 @func_123() {\nentry:\n %call2 = call i8 @func_152(i32 1)\n %call2991 = call i8 @func_152(i32 0)\n ret i8 %call2991\n}\n\ndefine internal i8 @func_152(i32 %p_153) {\nentry:\n %tobool268 = icmp ne i32 %p_153, 0\n br label %cleanup424\n\ncleanup424: ; preds = %cleanup424, %entry\n br label %cleanup424\n\nfor.end453: ; No predecessors!\n %0 = load ptr, ptr @g_315, align 8\n %1 = load ptr, ptr %0, align 8\n ret i8 0\n}\n```\n```\nWhile deleting: ptr %\nUse still stuck around after Def is destroyed: %0 = load ptr, ptr <badref>, align 8\nUses remain when a value is destroyed!\nUNREACHABLE executed at /home/dtcxzyw/WorkSpace/Projects/compilers/llvm-project/llvm/lib/IR/Value.cpp:102!\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=ipsccp --funcspec-min-function-size=1 reduced.ll -S\n1. Running pass \"ipsccp\" on module \"reduced.ll\"\n #0 0x000078deeee306f2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.22.0git+0x2306f2)\n #1 0x000078deeee2ccbf llvm::sys::RunSignalHandlers() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.22.0git+0x22ccbf)\n #2 0x000078deeee2ce0c SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #3 0x000078deee845330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)\n #4 0x000078deee89eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #5 0x000078deee89eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #6 0x000078deee89eb2c pthread_kill ./nptl/pthread_kill.c:89:10\n #7 0x000078deee84527e raise ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x000078deee8288ff abort ./stdlib/abort.c:81:7\n #9 0x000078deeed2a33e (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.22.0git+0x12a33e)\n#10 0x000078dee6761699 llvm::Value::~Value() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.22.0git+0x361699)\n#11 0x000078dee6761882 llvm::Value::deleteValue() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.22.0git+0x361882)\n#12 0x000078dee667ffce llvm::Instruction::eraseFromParent() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.22.0git+0x27ffce)\n#13 0x000078dee97c0d45 runIPSCCP(llvm::Module&, llvm::DataLayout const&, llvm::AnalysisManager<llvm::Function>*, std::function<llvm::TargetLibraryInfo const& (llvm::Function&)>, std::function<llvm::TargetTransformInfo& (llvm::Function&)>, std::function<llvm::AssumptionCache& (llvm::Function&)>, std::function<llvm::DominatorTree& (llvm::Function&)>, std::function<llvm::BlockFrequencyInfo& (llvm::Function&)>, bool) SCCP.cpp:0:0\n#14 0x000078dee97c122b llvm::IPSCCPPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMipo.so.22.0git+0x3c122b)\n#15 0x000078dee9aec7f5 llvm::detail::PassModel<llvm::Module, llvm::IPSCCPPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMPasses.so.22.0git+0xec7f5)\n#16 0x000078dee6724ddd llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.22.0git+0x324ddd)\n#17 0x000078deef124185 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.22.0git+0x2d185)\n#18 0x000078deef12f5ea optMain (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.22.0git+0x385ea)\n#19 0x000078deee82a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3\n#20 0x000078deee82a28b call_init ./csu/../csu/libc-start.c:128:20\n#21 0x000078deee82a28b __libc_start_main ./csu/../csu/libc-start.c:347:5\n#22 0x0000641d94919095 _start (bin/opt+0x1095)\nAborted (core dumped)\n```\nllvm version: 3c94613ae98fd9e9846fa77268b59d884b35cf60\n\nReverting 6bd844812385dd5cb65e08fe9561be9f91ace876 solves the issue. cc @XChy \n",
"author": "dtcxzyw",
"labels": [
"ipo",
"crash-on-valid",
"generated by fuzzer"
],
"comments": [
{
"author": "XChy",
"body": "The assumption is incorrect after https://github.com/llvm/llvm-project/commit/6bd844812385dd5cb65e08fe9561be9f91ace876:\nhttps://github.com/llvm/llvm-project/blob/5a9f1039c7732920dd1f4374074fdf09b58184ea/llvm/lib/Transforms/IPO/SCCP.cpp#L332-L339\nThe users in the dead functions are not replaced."
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
6bd844812385dd5cb65e08fe9561be9f91ace876
| null |
77468
|
https://github.com/llvm/llvm-project/issues/77468
|
crash
|
39b2104b4a4e0990eddc763eab99b28e8deab953
| 2024-01-09T13:19:28
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "59d6f033a25d161e494457e8bb6e30375eb7f40f",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
[
895,
901
],
[
948,
953
],
[
979,
995
]
],
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
"VPlanTransforms::truncateToMinimalBitwidths"
],
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 59d6f033a25d161e494457e8bb6e30375eb7f40f
Author: Florian Hahn <flo@fhahn.com>
Date: Fri Jan 12 13:14:13 2024 +0000
[VPlan] Support narrowing widened loads in truncateToMinimimalBitwidths.
MinBWs may also contain widened load instructions, handle them by only
narrowing their result.
Fixes https://github.com/llvm/llvm-project/issues/77468
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 5c430620a2dc..b3694e74a385 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -895,7 +895,10 @@ void VPlanTransforms::truncateToMinimalBitwidths(
vp_depth_first_deep(Plan.getVectorLoopRegion()))) {
for (VPRecipeBase &R : make_early_inc_range(*VPBB)) {
if (!isa<VPWidenRecipe, VPWidenCastRecipe, VPReplicateRecipe,
- VPWidenSelectRecipe>(&R))
+ VPWidenSelectRecipe, VPWidenMemoryInstructionRecipe>(&R))
+ continue;
+ if (isa<VPWidenMemoryInstructionRecipe>(&R) &&
+ cast<VPWidenMemoryInstructionRecipe>(&R)->isStore())
continue;
VPValue *ResultVPV = R.getVPSingleValue();
@@ -948,6 +951,23 @@ void VPlanTransforms::truncateToMinimalBitwidths(
auto *NewResTy = IntegerType::get(Ctx, NewResSizeInBits);
+ // Any wrapping introduced by shrinking this operation shouldn't be
+ // considered undefined behavior. So, we can't unconditionally copy
+ // arithmetic wrapping flags to VPW.
+ 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 (isa<VPWidenMemoryInstructionRecipe>(&R)) {
+ assert(!cast<VPWidenMemoryInstructionRecipe>(&R)->isStore() && "stores cannot be narrowed");
+ continue;
+ }
+
// Shrink operands by introducing truncates as needed.
unsigned StartIdx = isa<VPWidenSelectRecipe>(&R) ? 1 : 0;
for (unsigned Idx = StartIdx; Idx != R.getNumOperands(); ++Idx) {
@@ -979,17 +999,6 @@ void VPlanTransforms::truncateToMinimalBitwidths(
}
}
- // Any wrapping introduced by shrinking this operation shouldn't be
- // considered undefined behavior. So, we can't unconditionally copy
- // arithmetic wrapping flags to VPW.
- 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);
}
}
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/trunc-loads-p16.ll",
"commands": [
"opt -p loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -S %s"
],
"tests": [
{
"test_name": "pr77468",
"test_body": "target datalayout = \"p:16:16\"\n\ndefine void @pr77468(ptr noalias %src, ptr noalias %dst, i1 %x) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i16 [ 0, %entry ], [ %iv.next, %loop ]\n %gep.src = getelementptr i32, ptr %src, i16 %iv\n %l = load i32, ptr %gep.src, align 1\n %x.ext = zext i1 %x to i32\n %and = and i32 %x.ext, %l\n %gep.dst = getelementptr i16, ptr %dst, i16 %iv\n %t = trunc i32 %and to i16\n store i16 %t, ptr %gep.dst, align 2\n %iv.next = add i16 %iv, 1\n %exitcond.not = icmp eq i16 %iv.next, 100\n br i1 %exitcond.not, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "Assertion `MinBWs.size() == NumProcessedRecipes && \"some entries in MinBWs haven't been processed\"' failed. for opt -passes=loop-vectorize",
"body": "llvm commit: c1ed45a271145\r\nReproduce with: ```opt -passes=\"loop-vectorize\" bbi-90681_2.ll -S -o /dev/null -mtriple=x86_64```\r\nResult:\r\n```\r\nopt: ../lib/Transforms/Vectorize/VPlanTransforms.cpp:997: static void llvm::VPlanTransforms::truncateToMinimalBitwidths(llvm::VPlan &, const MapVector<llvm::Instruction *, uint64_t> &, 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.\r\nStack dump:\r\n0.\tProgram arguments: ../../main-github/llvm/build-all/bin/opt -passes=loop-vectorize bbi-90681_2.ll -S -o /dev/null -mtriple=x86_64\r\n #0 0x0000563bdd2b15d7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (../../main-github/llvm/build-all/bin/opt+0x63c95d7)\r\n #1 0x0000563bdd2af12e llvm::sys::RunSignalHandlers() (../../main-github/llvm/build-all/bin/opt+0x63c712e)\r\n #2 0x0000563bdd2b1c9f SignalHandler(int) (../../main-github/llvm/build-all/bin/opt+0x63c9c9f)\r\n #3 0x00007f87a7de7630 __restore_rt (/lib64/libpthread.so.0+0xf630)\r\n #4 0x00007f87a552e387 raise (/lib64/libc.so.6+0x36387)\r\n #5 0x00007f87a552fa78 abort (/lib64/libc.so.6+0x37a78)\r\n #6 0x00007f87a55271a6 __assert_fail_base (/lib64/libc.so.6+0x2f1a6)\r\n #7 0x00007f87a5527252 (/lib64/libc.so.6+0x2f252)\r\n #8 0x0000563bdd584d86 (../../main-github/llvm/build-all/bin/opt+0x669cd86)\r\n #9 0x0000563bdd50f875 llvm::LoopVectorizationPlanner::buildVPlansWithVPRecipes(llvm::ElementCount, llvm::ElementCount) (../../main-github/llvm/build-all/bin/opt+0x6627875)\r\n#10 0x0000563bdd50eeec llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (../../main-github/llvm/build-all/bin/opt+0x6626eec)\r\n#11 0x0000563bdd522bc9 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (../../main-github/llvm/build-all/bin/opt+0x663abc9)\r\n#12 0x0000563bdd5289b3 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*) (../../main-github/llvm/build-all/bin/opt+0x66409b3)\r\n#13 0x0000563bdd529318 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x6641318)\r\n#14 0x0000563bdd4cafad llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x65e2fad)\r\n#15 0x0000563bdcce36d4 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x5dfb6d4)\r\n#16 0x0000563bdb09c87d llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x41b487d)\r\n#17 0x0000563bdcce7abe llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x5dffabe)\r\n#18 0x0000563bdb09c61d llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x41b461d)\r\n#19 0x0000563bdcce27f6 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x5dfa7f6)\r\n#20 0x0000563bdabb7143 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (../../main-github/llvm/build-all/bin/opt+0x3ccf143)\r\n#21 0x0000563bdabc5844 main (../../main-github/llvm/build-all/bin/opt+0x3cdd844)\r\n#22 0x00007f87a551a555 __libc_start_main (/lib64/libc.so.6+0x22555)\r\n#23 0x0000563bdabb12e9 _start (../../main-github/llvm/build-all/bin/opt+0x3cc92e9)\r\nAbort (core dumped)\r\n```\r\n[bbi-90681_2.ll.gz](https://github.com/llvm/llvm-project/files/13874170/bbi-90681_2.ll.gz)\r\n",
"author": "mikaelholmen",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "mikaelholmen",
"body": "This starts happening with 70535f5e609f747c28\r\n```\r\n[VPlan] Replace IR based truncateToMinimalBitwidths with VPlan version.\r\n```\r\nPing @fhahn \r\n"
},
{
"author": "mikaelholmen",
"body": "Thanks!"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
70535f5e609f747c28cfef699eefb84581b0aac0
| null |
129242
|
https://github.com/llvm/llvm-project/issues/129242
|
crash
|
5faa5f848a35de13196f2f516f51aa970da942b4
| 2025-02-28T13:35:26
|
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "a36a67c79afaa1fdd0dbe0440ec852fd4eb3a532",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
11425,
11435
]
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::getEntryCost"
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit a36a67c79afaa1fdd0dbe0440ec852fd4eb3a532
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Fri Feb 28 13:15:46 2025 -0800
[SLP]Fix the analysis of the user buildvector nodes for minbitwidth
If the user node is a buildvector/gather node and it has no internal
instructions state, need to check properly for this state and check the
type of the node itself, not its operands.
Fixes #129242
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 4a68e0ee5989..4f3fd6d53909 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -11425,11 +11425,14 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
E->Idx != 0 &&
(E->getOpcode() != Instruction::Load || E->UserTreeIndex)) {
const EdgeInfo &EI = E->UserTreeIndex;
- if (EI.UserTE->getOpcode() != Instruction::Select ||
+ if (!EI.UserTE->hasState() ||
+ EI.UserTE->getOpcode() != Instruction::Select ||
EI.EdgeIdx != 0) {
auto UserBWIt = MinBWs.find(EI.UserTE);
Type *UserScalarTy =
- EI.UserTE->getOperand(EI.EdgeIdx).front()->getType();
+ EI.UserTE->isGather()
+ ? EI.UserTE->Scalars.front()->getType()
+ : EI.UserTE->getOperand(EI.EdgeIdx).front()->getType();
if (UserBWIt != MinBWs.end())
UserScalarTy = IntegerType::get(ScalarTy->getContext(),
UserBWIt->second.first);
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/user-buildvector-with-minbiwidth.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine i32 @test(i8 %0, i32 %conv2, i1 %cmp.i, i64 %shl.i) {\n;\nentry:\n %conv21 = sext i8 %0 to i32\n %conv7 = zext i32 %conv2 to i64\n %cond.i = shl i64 %conv7, %shl.i\n %1 = and i64 %cond.i, 4294967295\n %.not = icmp eq i64 %1, 1\n %conv7.1 = zext i32 %conv2 to i64\n %cond.i.1 = shl i64 %conv7.1, %shl.i\n %2 = and i64 %cond.i.1, 4294967295\n %.not.1 = icmp eq i64 %2, 1\n %sub.2 = or i32 %conv21, 1\n %cond.2 = select i1 %cmp.i, i32 %sub.2, i32 0\n %conv7.2 = zext i32 %cond.2 to i64\n %cmp.i.2 = icmp slt i32 %cond.2, 1\n %shl.i.2 = zext i1 %cmp.i.2 to i64\n %cond.i.2 = shl i64 %conv7.2, %shl.i.2\n %3 = and i64 %cond.i.2, 4294967295\n %.not.2 = icmp eq i64 %3, 1\n %sub.3 = or i32 %conv21, 1\n %cond.3 = select i1 %cmp.i, i32 %sub.3, i32 0\n %conv7.3 = zext i32 %cond.3 to i64\n %cmp.i.3 = icmp slt i32 %cond.3, 1\n %shl.i.3 = zext i1 %cmp.i.3 to i64\n %cond.i.3 = shl i64 %conv7.3, %shl.i.3\n %4 = and i64 %cond.i.3, 4294967295\n %.not.3 = icmp eq i64 %4, 1\n %sub.4 = or i32 %conv21, 1\n %cond.4 = select i1 %cmp.i, i32 %sub.4, i32 0\n %conv7.4 = zext i32 %cond.4 to i64\n %cmp.i.4 = icmp slt i32 %cond.4, 1\n %shl.i.4 = zext i1 %cmp.i.4 to i64\n %cond.i.4 = shl i64 %conv7.4, %shl.i.4\n %5 = and i64 %cond.i.4, 4294967295\n %.not.4 = icmp eq i64 %5, 1\n %sub.5 = or i32 %conv21, 1\n %cond.5 = select i1 %cmp.i, i32 %sub.5, i32 0\n %conv7.5 = zext i32 %cond.5 to i64\n %cmp.i.5 = icmp slt i32 %cond.5, 1\n %shl.i.5 = zext i1 %cmp.i.5 to i64\n %cond.i.5 = shl i64 %conv7.5, %shl.i.5\n %6 = and i64 %cond.i.5, 4294967295\n %.not.5 = icmp eq i64 %6, 1\n %sub.6 = or i32 %conv21, 1\n %cond.6 = select i1 %cmp.i, i32 %sub.6, i32 0\n %conv7.6 = zext i32 %cond.6 to i64\n %cmp.i.6 = icmp slt i32 %cond.6, 1\n %shl.i.6 = zext i1 %cmp.i.6 to i64\n %cond.i.6 = shl i64 %conv7.6, %shl.i.6\n %7 = and i64 %cond.i.6, 4294967295\n %.not.6 = icmp eq i64 %7, 1\n %sub.7 = or i32 %conv21, 1\n %cond.7 = select i1 %cmp.i, i32 %sub.7, i32 0\n %conv7.7 = zext i32 %cond.7 to i64\n %cmp.i.7 = icmp slt i32 %cond.7, 1\n %shl.i.7 = zext i1 %cmp.i.7 to i64\n %cond.i.7 = shl i64 %conv7.7, %shl.i.7\n %8 = and i64 %cond.i.7, 4294967295\n %.not.7 = icmp eq i64 %8, 1\n %sub.8 = or i32 %conv21, 1\n %cond.8 = select i1 %cmp.i, i32 %sub.8, i32 0\n %conv7.8 = zext i32 %cond.8 to i64\n %cmp.i.8 = icmp slt i32 %cond.8, 1\n %shl.i.8 = zext i1 %cmp.i.8 to i64\n %cond.i.8 = shl i64 %conv7.8, %shl.i.8\n %9 = and i64 %cond.i.8, 4294967295\n %.not.8 = icmp eq i64 %9, 1\n %sub.9 = or i32 %conv21, 1\n %cond.9 = select i1 %cmp.i, i32 %sub.9, i32 0\n %conv7.9 = zext i32 %cond.9 to i64\n %cmp.i.9 = icmp slt i32 %cond.9, 1\n %shl.i.9 = zext i1 %cmp.i.9 to i64\n %cond.i.9 = shl i64 %conv7.9, %shl.i.9\n %10 = and i64 %cond.i.9, 4294967295\n %.not.9 = icmp eq i64 %10, 1\n br label %while.body\n\nwhile.body:\n br i1 %.not, label %for.inc, label %if.then10\n\nif.then10:\n br label %for.inc\n\nfor.inc:\n br i1 %.not.1, label %for.inc.1, label %if.then10.1\n\nif.then10.1:\n br label %for.inc.1\n\nfor.inc.1:\n br i1 %.not.2, label %for.inc.2, label %if.then10.2\n\nif.then10.2:\n br label %for.inc.2\n\nfor.inc.2:\n br i1 %.not.3, label %for.inc.3, label %if.then10.3\n\nif.then10.3:\n br label %for.inc.3\n\nfor.inc.3:\n br i1 %.not.4, label %for.inc.4, label %if.then10.4\n\nif.then10.4:\n br label %for.inc.4\n\nfor.inc.4:\n br i1 %.not.5, label %for.inc.5, label %if.then10.5\n\nif.then10.5:\n br label %for.inc.5\n\nfor.inc.5:\n br i1 %.not.6, label %for.inc.6, label %if.then10.6\n\nif.then10.6:\n br label %for.inc.6\n\nfor.inc.6:\n br i1 %.not.7, label %for.inc.7, label %if.then10.7\n\nif.then10.7:\n br label %for.inc.7\n\nfor.inc.7:\n br i1 %.not.8, label %for.inc.8, label %if.then10.8\n\nif.then10.8:\n br label %for.inc.8\n\nfor.inc.8:\n br i1 %.not.9, label %while.body, label %if.then10.9\n\nif.then10.9:\n br label %while.body\n}",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "clang crashes on valid code at -O{2,3} on x86_64-linux-gnu: Assertion `valid() && \"InstructionsState is invalid.\"' failed",
"body": "It appears to be a recent regression as it doesn't reproduce with 19.1.0 and earlier.\n\nCompiler Explorer: https://godbolt.org/z/8KTq9hGv9\n\n```\n[516] % clangtk -v\nclang version 21.0.0git (https://github.com/llvm/llvm-project.git d0edd931bcc328b9502289d346f2b2219341f853)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\nBuild config: +assertions\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\nCandidate multilib: .;@m64\nSelected multilib: .;@m64\n[517] % \n[517] % clangtk -O2 -w small.c\nclang-21: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:821: llvm::Instruction* {anonymous}::InstructionsState::getMainOp() const: Assertion `valid() && \"InstructionsState is invalid.\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\nStack dump:\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-21 -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/20250227-clangtk-m64-O3-build-235136/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20250227-clangtk-m64-O3-build-235136/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/21 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/21/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 -w -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-933a0f.o -x c small.c\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 \"small.c\"\n4.\tRunning pass \"slp-vectorizer\" on function \"main\"\n #0 0x00005597e9b142df llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x455e2df)\n #1 0x00005597e9b11ab4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007fa06c8aa420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\n #3 0x00007fa06c2e100b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\n #4 0x00007fa06c2c0859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\n #5 0x00007fa06c2c0729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\n #6 0x00007fa06c2c0729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\n #7 0x00007fa06c2d1fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\n #8 0x00005597eb591745 (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5fdb745)\n #9 0x00005597eb62a4e5 llvm::slpvectorizer::BoUpSLP::getEntryCost(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallPtrSetImpl<llvm::Value*>&)::'lambda0'(llvm::function_ref<llvm::InstructionCost (unsigned int)>, llvm::function_ref<llvm::InstructionCost (llvm::InstructionCost)>)::operator()(llvm::function_ref<llvm::InstructionCost (unsigned int)>, llvm::function_ref<llvm::InstructionCost (llvm::InstructionCost)>) const SLPVectorizer.cpp:0:0\n#10 0x00005597eb633034 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-21+0x607d034)\n#11 0x00005597eb668741 llvm::slpvectorizer::BoUpSLP::getTreeCost(llvm::ArrayRef<llvm::Value*>) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60b2741)\n#12 0x00005597eb672691 llvm::SLPVectorizerPass::tryToVectorizeList(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60bc691)\n#13 0x00005597eb676e5e bool llvm::SLPVectorizerPass::vectorizeCmpInsts<std::reverse_iterator<llvm::CmpInst* const*>>(llvm::iterator_range<std::reverse_iterator<llvm::CmpInst* const*>>, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60c0e5e)\n#14 0x00005597eb6773db llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&)::'lambda3'(bool)::operator()(bool) const SLPVectorizer.cpp:0:0\n#15 0x00005597eb67ac20 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60c4c20)\n#16 0x00005597eb681396 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\n#17 0x00005597eb681ef3 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60cbef3)\n#18 0x00005597eb104166 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-21+0x5b4e166)\n#19 0x00005597e948caf9 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x3ed6af9)\n#20 0x00005597e6d6c406 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-21+0x17b6406)\n#21 0x00005597e948b362 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x3ed5362)\n#22 0x00005597e6d6a4b6 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-21+0x17b44b6)\n#23 0x00005597e948ad81 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x3ed4d81)\n#24 0x00005597e9ddb283 (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 0x00005597e9ddf573 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*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x4829573)\n#26 0x00005597ea51bba0 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x4f65ba0)\n#27 0x00005597ebe39acc clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x6883acc)\n#28 0x00005597ea51bfc8 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x4f65fc8)\n#29 0x00005597ea7f2779 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x523c779)\n#30 0x00005597ea77325e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x51bd25e)\n#31 0x00005597ea8e7626 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5331626)\n#32 0x00005597e68fefb7 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x1348fb7)\n#33 0x00005597e68f66ea ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#34 0x00005597e68fa97a clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x134497a)\n#35 0x00005597e67edccb main (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x1237ccb)\n#36 0x00007fa06c2c2083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\n#37 0x00005597e68f617e _start (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x134017e)\nclangtk: error: unable to execute command: Aborted\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\nclang version 21.0.0git (https://github.com/llvm/llvm-project.git d0edd931bcc328b9502289d346f2b2219341f853)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\nBuild config: +assertions\nclangtk: note: diagnostic msg: \n********************\n\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\nPreprocessed source(s) and associated run script(s) are located at:\nclangtk: note: diagnostic msg: /tmp/small-fd80bc.c\nclangtk: note: diagnostic msg: /tmp/small-fd80bc.sh\nclangtk: note: diagnostic msg: \n\n********************\n[518] % \n[518] % cat small.c\nint a[1], g;\nchar b, c;\nvolatile int d;\nlong e, f;\nlong h(long i) { return i > 1 ? i : i << 1; }\nint main() {\n if (g)\n while (1) {\n b = 0;\n for (; b < 10; b++) {\n e = c & b ? 0 : c - b;\n f = h(e);\n g = (a != 0) % (unsigned)f;\n if (g)\n d;\n }\n }\n return 0;\n}\n```\n\n",
"author": "zhendongsu",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
894935cb5146fd2ac6334cc8b11e6d6e0e264fe6
| null |
165382
|
https://github.com/llvm/llvm-project/issues/165382
|
miscompilation
|
242ebcf13e037df08725150ad39ae156bb0ab1b0
| 2025-10-28T12:47:56
|
[
"llvm/test/Analysis/HashRecognize",
"llvm/test/Transforms/LoopIdiom"
] |
{
"fix_commit": "3bc9b28fe5bc3775229ceb6e498747970606d7d5",
"components": [
"HashRecognize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": [
[
468,
475
]
],
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": [
"HashRecognize::recognizeCRC"
],
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 3bc9b28fe5bc3775229ceb6e498747970606d7d5
Author: Ramkumar Ramachandra <ramkumar.ramachandra@codasip.com>
Date: Wed Oct 29 21:50:12 2025 +0000
[HashRecognize] Forbid optz when data.next has exit-block user (#165574)
The CRC optimization relies on stripping the auxiliary data completely,
and should hence be forbidden when it has a user in the exit-block.
Forbid this case, fixing a miscompile.
Fixes #165382.
diff --git a/llvm/lib/Analysis/HashRecognize.cpp b/llvm/lib/Analysis/HashRecognize.cpp
index 4529123508a7..8974ce5734b1 100644
--- a/llvm/lib/Analysis/HashRecognize.cpp
+++ b/llvm/lib/Analysis/HashRecognize.cpp
@@ -468,8 +468,11 @@ std::variant<PolynomialInfo, StringRef> HashRecognize::recognizeCRC() const {
// Ensure that the PHIs have exactly two uses:
// the bit-shift, and the XOR (or a cast feeding into the XOR).
+ // Also ensure that the SimpleRecurrence's evolution doesn't have stray
+ // users.
if (!ConditionalRecurrence.Phi->hasNUses(2) ||
- !SimpleRecurrence.Phi->hasNUses(2))
+ !SimpleRecurrence.Phi->hasNUses(2) ||
+ SimpleRecurrence.BO->getUniqueUndroppableUser() != SimpleRecurrence.Phi)
return "Recurrences have stray uses";
// Check that the SelectInst ConditionalRecurrence.Step is conditional on
|
[
{
"file": "llvm/test/Analysis/HashRecognize/cyclic-redundancy-check.ll",
"commands": [
"opt -passes='print<hash-recognize>' -disable-output %s 2>&1"
],
"tests": [
{
"test_name": "not.crc.crc.phi.outside.user",
"test_body": "define i16 @not.crc.crc.phi.outside.user(i16 %crc.init, i16 %data.init) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %crc = phi i16 [ %crc.init, %entry ], [ %crc.next, %loop ]\n %data = phi i16 [ %data.init, %entry ], [ %data.next, %loop ]\n %xor.crc.data = xor i16 %data, %crc\n %crc.shl = shl i16 %crc, 1\n %crc.xor = xor i16 %crc.shl, 3\n %check.sb = icmp slt i16 %xor.crc.data, 0\n %crc.next = select i1 %check.sb, i16 %crc.xor, i16 %crc.shl\n %data.next = shl i16 %data, 1\n %iv.next = add nuw nsw i32 %iv, 1\n %exit.cond = icmp samesign ult i32 %iv, 7\n br i1 %exit.cond, label %loop, label %exit\n\nexit: ; preds = %loop\n %ret = xor i16 %crc, %crc.next\n ret i16 %ret\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "not.crc.data.phi.outside.user",
"test_body": "define i16 @not.crc.data.phi.outside.user(i16 %crc.init, i16 %data.init) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %crc = phi i16 [ %crc.init, %entry ], [ %crc.next, %loop ]\n %data = phi i16 [ %data.init, %entry ], [ %data.next, %loop ]\n %xor.crc.data = xor i16 %data, %crc\n %crc.shl = shl i16 %crc, 1\n %crc.xor = xor i16 %crc.shl, 3\n %check.sb = icmp slt i16 %xor.crc.data, 0\n %crc.next = select i1 %check.sb, i16 %crc.xor, i16 %crc.shl\n %data.next = shl i16 %data, 1\n %iv.next = add nuw nsw i32 %iv, 1\n %exit.cond = icmp samesign ult i32 %iv, 7\n br i1 %exit.cond, label %loop, label %exit\n\nexit: ; preds = %loop\n %ret = xor i16 %data, %crc.next\n ret i16 %ret\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "not.crc.data.next.outside.user",
"test_body": "define i16 @not.crc.data.next.outside.user(i16 %crc.init, i16 %data.init) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %crc = phi i16 [ %crc.init, %entry ], [ %crc.next, %loop ]\n %data = phi i16 [ %data.init, %entry ], [ %data.next, %loop ]\n %xor.crc.data = xor i16 %data, %crc\n %crc.shl = shl i16 %crc, 1\n %crc.xor = xor i16 %crc.shl, 3\n %check.sb = icmp slt i16 %xor.crc.data, 0\n %crc.next = select i1 %check.sb, i16 %crc.xor, i16 %crc.shl\n %data.next = shl i16 %data, 1\n %iv.next = add nuw nsw i32 %iv, 1\n %exit.cond = icmp samesign ult i32 %iv, 7\n br i1 %exit.cond, label %loop, label %exit\n\nexit: ; preds = %loop\n %ret = xor i16 %data.next, %crc.next\n ret i16 %ret\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopIdiom/cyclic-redundancy-check.ll",
"commands": [
"opt -passes=loop-idiom -S %s"
],
"tests": [
{
"test_name": "not.crc.data.next.outside.user",
"test_body": "define i16 @not.crc.data.next.outside.user(i16 %crc.init, i16 %data.init) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %crc = phi i16 [ %crc.init, %entry ], [ %crc.next, %loop ]\n %data = phi i16 [ %data.init, %entry ], [ %data.next, %loop ]\n %xor.crc.data = xor i16 %data, %crc\n %crc.shl = shl i16 %crc, 1\n %crc.xor = xor i16 %crc.shl, 3\n %check.sb = icmp slt i16 %xor.crc.data, 0\n %crc.next = select i1 %check.sb, i16 %crc.xor, i16 %crc.shl\n %data.next = shl i16 %data, 1\n %iv.next = add nuw nsw i32 %iv, 1\n %exit.cond = icmp samesign ult i32 %iv, 7\n br i1 %exit.cond, label %loop, label %exit\n\nexit: ; preds = %loop\n %ret = xor i16 %data.next, %crc.next\n ret i16 %ret\n}\n",
"additional_args": "-src-unroll=8 -tgt-unroll=8",
"lli_expected_out": null
}
]
}
] |
{
"title": "[HashRecognize] Miscompile due to data evolution with an outside user: poison generated",
"body": "This program returns 0 at -O0/s and 139 at -O1/2/3\n\n```\nint a, b;\nshort c, e;\nlong d[56];\nint main() {\n a = 0;\n for (; a < 6; a++) {\n b = 0;\n for (; b < 8; b++) {\n if ((e ^ c) & 32768)\n e = e << 1 ^ 3;\n else\n e <<= 1;\n c <<= 1;\n }\n d[b + c - a] = 0;\n }\n}\n```\n\nCompiler Explorer: https://godbolt.org/z/fxjj1o4Yf",
"author": "iamanonymouscs",
"labels": [
"miscompilation",
"llvm:analysis"
],
"comments": [
{
"author": "antoniofrighetto",
"body": "Partially reduced IR until it matches the output of clang 21.1.0:\n```llvm\n@a = global i32 0, align 4\n@b = global i32 0, align 4\n@e = global i16 0, align 2\n@c = global i16 0, align 2\n@d = global [56 x i64] zeroinitializer, align 16\n\ndefine i32 @main() {\nentry:\n %e.promoted29 = load i16, ptr @e, align 2\n %c.promoted31 = load i16, ptr @c, align 2\n br label %for.cond1.preheader\n\nfor.cond1.preheader: ; preds = %entry, %for.end\n %storemerge35 = phi i32 [ 0, %entry ], [ %inc16, %for.end ]\n %storemerge2023.lcssa3034 = phi i16 [ %e.promoted29, %entry ], [ %storemerge20, %for.end ]\n %shl1224.lcssa3233 = phi i16 [ %c.promoted31, %entry ], [ %shl12, %for.end ]\n br label %for.body3\n\nfor.body3: ; preds = %for.cond1.preheader, %for.body3\n %storemerge1827 = phi i32 [ 0, %for.cond1.preheader ], [ %inc, %for.body3 ]\n %storemerge202326 = phi i16 [ %storemerge2023.lcssa3034, %for.cond1.preheader ], [ %storemerge20, %for.body3 ]\n %shl122425 = phi i16 [ %shl1224.lcssa3233, %for.cond1.preheader ], [ %shl12, %for.body3 ]\n %xor19 = xor i16 %shl122425, %storemerge202326\n %shl9 = shl i16 %storemerge202326, 1\n %xor6 = xor i16 %shl9, 3\n %tobool.not21 = icmp slt i16 %xor19, 0\n %storemerge20 = select i1 %tobool.not21, i16 %xor6, i16 %shl9\n %shl12 = shl i16 %shl122425, 1\n %inc = add nuw nsw i32 %storemerge1827, 1\n %cmp2 = icmp samesign ult i32 %storemerge1827, 7\n br i1 %cmp2, label %for.body3, label %for.end\n\nfor.end: ; preds = %for.body3\n %conv14 = sext i16 %shl12 to i32\n %add = sub nsw i32 %inc, %storemerge35\n %sub = add i32 %add, %conv14\n %idxprom = sext i32 %sub to i64\n %arrayidx = getelementptr inbounds i64, ptr @d, i64 %idxprom\n store i64 0, ptr %arrayidx, align 8\n %inc16 = add nuw nsw i32 %storemerge35, 1\n %cmp = icmp samesign ult i32 %storemerge35, 5\n br i1 %cmp, label %for.cond1.preheader, label %for.end17\n\nfor.end17: ; preds = %for.end\n store i32 %inc16, ptr @a, align 4\n store i32 %inc, ptr @b, align 4\n store i16 %storemerge20, ptr @e, align 2\n store i16 %shl12, ptr @c, align 2\n ret i32 0\n}\n```\nRunning `./bin/opt -passes=\"loop(loop-idiom,indvars)\" test.ll -o test.opt.ll && ./bin/clang test.opt.ll && ./a.out` leads to the segfault.\n\nParticularly, it seems like LoopIdiomRecognize, as part of the CRC transform achieved via recent HashRecognize analysis, moved the loop `for.body3` into a sequence of instructions, where the table lookup looks as follows:\n```llvm\n %tbl.ptradd = getelementptr inbounds i16, ptr @.crctable, i64 %indexer.ext\n %tbl.ld = load i16, ptr %tbl.ptradd, align 2\n %crc.be.shift = shl i16 %crc, 8\n %crc.next = xor i16 %crc.be.shift, %tbl.ld\n %shl12 = shl i16 poison, 1\n```\npoison in `%shl12` is subsequently propagated and finally used to index `@d` global variable. cc/ @artagnon, @fhahn"
},
{
"author": "artagnon",
"body": "Thanks, will look into this along with @pfusik in the morning."
},
{
"author": "artagnon",
"body": "Further reduced:\n\n```llvm\ndefine i16 @crc.data.next.outside.user(i16 %crc.init, i16 %data.init) {\nentry:\n br label %loop\n\nloop:\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %crc = phi i16 [ %crc.init, %entry ], [ %crc.next, %loop ]\n %data = phi i16 [ %data.init, %entry ], [ %data.next, %loop ]\n %xor.crc.data = xor i16 %data, %crc\n %crc.shl = shl i16 %crc, 1\n %crc.xor = xor i16 %crc.shl, 3\n %check.sb = icmp slt i16 %xor.crc.data, 0\n %crc.next = select i1 %check.sb, i16 %crc.xor, i16 %crc.shl\n %data.next = shl i16 %data, 1\n %iv.next = add nuw nsw i32 %iv, 1\n %exit.cond = icmp samesign ult i32 %iv, 7\n br i1 %exit.cond, label %loop, label %exit\n\nexit:\n %ret = xor i16 %data.next, %crc.next\n ret i16 %ret\n}\n```\n\nThe diff between `opt -passes=loop(loop-idiom)` with and without `-disable-loop-idiom-hashrecognize` is:\n\n```diff\ndiff --git a/main.li.ll b/reduced.li.ll\nindex b342d46..d84cbd2 100644\n--- a/main.li.ll\n+++ b/reduced.li.ll\n@@ -1,26 +1,33 @@\n ; ModuleID = 'reduced.ll'\n source_filename = \"reduced.ll\"\n\n+@.crctable = private constant [256 x i16] [i16 0, i16 3, i16 6, i16 5, i16 12, i16 15, i16 10, i16 9, i16 24, i16 27, i16 30, i16 29, i16 20, i16 23, i16 18, i16 17, i16 48, i16 51, i16 54, i16 53, i16 60, i16 63, i16 58, i16 57, i16 40, i16 43, i16 46, i16 45, i16 36, i16 39, i16 34, i16 33, i16 96, i16 99, i16 102, i16 101, i16 108, i16 111, i16 106, i16 105, i16 120, i16 123, i16 126, i16 125, i16 116, i16 119, i16 114, i16 113, i16 80, i16 83, i16 86, i16 85, i16 92, i16 95, i16 90, i16 89, i16 72, i16 75, i16 78, i16 77, i16 68, i16 71, i16 66, i16 65, i16 192, i16 195, i16 198, i16 197, i16 204, i16 207, i16 202, i16 201, i16 216, i16 219, i16 222, i16 221, i16 212, i16 215, i16 210, i16 209, i16 240, i16 243, i16 246, i16 245, i16 252, i16 255, i16 250, i16 249, i16 232, i16 235, i16 238, i16 237, i16 228, i16 231, i16 226, i16 225, i16 160, i16 163, i16 166, i16 165, i16 172, i16 175, i16 170, i16 169, i16 184, i16 187, i16 190, i16 189, i16 180, i16 183, i16 178, i16 177, i16 144, i16 147, i16 150, i16 149, i16 156, i16 159, i16 154, i16 153, i16 136, i16 139, i16 142, i16 141, i16 132, i16 135, i16 130, i16 129, i16 384, i16 387, i16 390, i16 389, i16 396, i16 399, i16 394, i16 393, i16 408, i16 411, i16 414, i16 413, i16 404, i16 407, i16 402, i16 401, i16 432, i16 435, i16 438, i16 437, i16 444, i16 447, i16 442, i16 441, i16 424, i16 427, i16 430, i16 429, i16 420, i16 423, i16 418, i16 417, i16 480, i16 483, i16 486, i16 485, i16 492, i16 495, i16 490, i16 489, i16 504, i16 507, i16 510, i16 509, i16 500, i16 503, i16 498, i16 497, i16 464, i16 467, i16 470, i16 469, i16 476, i16 479, i16 474, i16 473, i16 456, i16 459, i16 462, i16 461, i16 452, i16 455, i16 450, i16 449, i16 320, i16 323, i16 326, i16 325, i16 332, i16 335, i16 330, i16 329, i16 344, i16 347, i16 350, i16 349, i16 340, i16 343, i16 338, i16 337, i16 368, i16 371, i16 374, i16 373, i16 380, i16 383, i16 378, i16 377, i16 360, i16 363, i16 366, i16 365, i16 356, i16 359, i16 354, i16 353, i16 288, i16 291, i16 294, i16 293, i16 300, i16 303, i16 298, i16 297, i16 312, i16 315, i16 318, i16 317, i16 308, i16 311, i16 306, i16 305, i16 272, i16 275, i16 278, i16 277, i16 284, i16 287, i16 282, i16 281, i16 264, i16 267, i16 270, i16 269, i16 260, i16 263, i16 258, i16 257]\n+\n define i16 @crc.data.next.outside.user(i16 %crc.init, i16 %data.init) {\n entry:\n br label %loop\n\n loop: ; preds = %loop, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n- %crc = phi i16 [ %crc.init, %entry ], [ %crc.next, %loop ]\n- %data = phi i16 [ %data.init, %entry ], [ %data.next, %loop ]\n- %xor.crc.data = xor i16 %data, %crc\n- %crc.shl = shl i16 %crc, 1\n- %crc.xor = xor i16 %crc.shl, 3\n- %check.sb = icmp slt i16 %xor.crc.data, 0\n- %crc.next = select i1 %check.sb, i16 %crc.xor, i16 %crc.shl\n- %data.next = shl i16 %data, 1\n+ %crc2 = phi i16 [ %crc.init, %entry ], [ %crc.next3, %loop ]\n+ %iv.bits = shl i32 %iv, 3\n+ %iv.indexer = trunc i32 %iv.bits to i16\n+ %data.indexer = shl i16 %data.init, %iv.indexer\n+ %crc.data.indexer = xor i16 %data.indexer, %crc2\n+ %indexer.hi = lshr i16 %crc.data.indexer, 8\n+ %indexer.hi.lo.byte = trunc i16 %indexer.hi to i8\n+ %indexer.ext = zext i8 %indexer.hi.lo.byte to i64\n+ %tbl.ptradd = getelementptr inbounds i16, ptr @.crctable, i64 %indexer.ext\n+ %tbl.ld = load i16, ptr %tbl.ptradd, align 2\n+ %crc.be.shift = shl i16 %crc2, 8\n+ %crc.next3 = xor i16 %crc.be.shift, %tbl.ld\n+ %data.next = shl i16 poison, 1\n %iv.next = add nuw nsw i32 %iv, 1\n- %exit.cond = icmp samesign ult i32 %iv, 7\n- br i1 %exit.cond, label %loop, label %exit\n+ %exit.cond1 = icmp ne i32 %iv, 0\n+ br i1 %exit.cond1, label %loop, label %exit\n\n exit: ; preds = %loop\n- %crc.next.lcssa = phi i16 [ %crc.next, %loop ]\n+ %crc.next.lcssa = phi i16 [ %crc.next3, %loop ]\n %data.next.lcssa = phi i16 [ %data.next, %loop ]\n %ret = xor i16 %data.next.lcssa, %crc.next.lcssa\n ret i16 %ret\n```\n\nThe issue is that data.next has a user outside the loop, and hence CRC optimization is not possible for this example, as the optimization would strip the data PHI entirely. Will post a fix soon."
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null | null |
128838
|
https://github.com/llvm/llvm-project/issues/128838
|
crash
|
9c65e6ac115a7d8566c874537791125c3ace7c1a
| 2025-02-26T07:25:33
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "62994c3291239f3d11f958d002319b2bd6eddbc9",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
[
7691,
7701
]
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
[
2180,
2186
],
[
2189,
2206
],
[
2210,
2219
]
],
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": [
[
189,
196
]
],
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"LoopVectorizationPlanner::executePlan"
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
"VPlanTransforms::handleUncountableEarlyExit",
"VPlanTransforms::materializeLiveInBroadcasts"
],
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 62994c3291239f3d11f958d002319b2bd6eddbc9
Author: Florian Hahn <flo@fhahn.com>
Date: Wed Mar 12 22:03:18 2025 +0000
[VPlan] Also introduce explicit broadcasts for values from entry VPBB.
Update and generalize materializeBroadcasts to also introduce explicit
broadcasts for VPValues defined in the Plans Entry block.
This fixes a crash when trying to insert the broadcasts generated by
VPTransformState::get after the generating instruction, which isn't
possible after invoke instructions.
Fixes https://github.com/llvm/llvm-project/issues/128838.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index bab2c6efd403..02bacde3f60a 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7691,11 +7691,11 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
((VectorizingEpilogue && ExpandedSCEVs) ||
(!VectorizingEpilogue && !ExpandedSCEVs)) &&
"expanded SCEVs to reuse can only be used during epilogue vectorization");
- VPlanTransforms::materializeLiveInBroadcasts(BestVPlan);
// TODO: Move to VPlan transform stage once the transition to the VPlan-based
// cost model is complete for better cost estimates.
VPlanTransforms::runPass(VPlanTransforms::unrollByUF, BestVPlan, BestUF,
OrigLoop->getHeader()->getContext());
+ VPlanTransforms::materializeBroadcasts(BestVPlan);
VPlanTransforms::optimizeForVFAndUF(BestVPlan, BestVF, BestUF, PSE);
VPlanTransforms::simplifyRecipes(BestVPlan, *Legal->getWidestInductionType());
VPlanTransforms::removeDeadRecipes(BestVPlan);
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index ecf52673480e..f23795f87d46 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -2180,7 +2180,7 @@ void VPlanTransforms::handleUncountableEarlyExit(
LatchExitingBranch->eraseFromParent();
}
-void VPlanTransforms::materializeLiveInBroadcasts(VPlan &Plan) {
+void VPlanTransforms::materializeBroadcasts(VPlan &Plan) {
if (Plan.hasScalarVFOnly())
return;
@@ -2189,18 +2189,25 @@ void VPlanTransforms::materializeLiveInBroadcasts(VPlan &Plan) {
VPDT.recalculate(Plan);
#endif
+ SmallVector<VPValue *> VPValues;
+ append_range(VPValues, Plan.getLiveIns());
+ for (VPRecipeBase &R : *Plan.getEntry())
+ append_range(VPValues, R.definedValues());
+
auto *VectorPreheader = Plan.getVectorPreheader();
- for (VPValue *LiveIn : Plan.getLiveIns()) {
- if (all_of(LiveIn->users(),
- [LiveIn](VPUser *U) { return U->usesScalars(LiveIn); }) ||
- !LiveIn->getLiveInIRValue() ||
- isa<Constant>(LiveIn->getLiveInIRValue()))
+ for (VPValue *VPV : VPValues) {
+ if (all_of(VPV->users(),
+ [VPV](VPUser *U) { return U->usesScalars(VPV); }) ||
+ (VPV->isLiveIn() &&
+ (!VPV->getLiveInIRValue() || isa<Constant>(VPV->getLiveInIRValue()))))
continue;
// Add explicit broadcast at the insert point that dominates all users.
VPBasicBlock *HoistBlock = VectorPreheader;
VPBasicBlock::iterator HoistPoint = VectorPreheader->end();
- for (VPUser *User : LiveIn->users()) {
+ for (VPUser *User : VPV->users()) {
+ if (User->usesScalars(VPV))
+ continue;
if (cast<VPRecipeBase>(User)->getParent() == VectorPreheader)
HoistPoint = HoistBlock->begin();
else
@@ -2210,10 +2217,10 @@ void VPlanTransforms::materializeLiveInBroadcasts(VPlan &Plan) {
}
VPBuilder Builder(cast<VPBasicBlock>(HoistBlock), HoistPoint);
- auto *Broadcast = Builder.createNaryOp(VPInstruction::Broadcast, {LiveIn});
- LiveIn->replaceUsesWithIf(
- Broadcast, [LiveIn, Broadcast](VPUser &U, unsigned Idx) {
- return Broadcast != &U && !U.usesScalars(LiveIn);
- });
+ auto *Broadcast = Builder.createNaryOp(VPInstruction::Broadcast, {VPV});
+ VPV->replaceUsesWithIf(Broadcast,
+ [VPV, Broadcast](VPUser &U, unsigned Idx) {
+ return Broadcast != &U && !U.usesScalars(VPV);
+ });
}
}
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.h b/llvm/lib/Transforms/Vectorize/VPlanTransforms.h
index 8a9a81e00fe2..2ec07eea1ecc 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.h
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.h
@@ -189,8 +189,8 @@ struct VPlanTransforms {
optimizeInductionExitUsers(VPlan &Plan,
DenseMap<VPValue *, VPValue *> &EndValues);
- /// Add explicit broadcasts for live-ins used as vectors.
- static void materializeLiveInBroadcasts(VPlan &Plan);
+ /// Add explicit broadcasts for live-ins and VPValues defined in \p Plan's entry block if they are used as vectors.
+ static void materializeBroadcasts(VPlan &Plan);
};
} // namespace llvm
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/RISCV/illegal-type.ll",
"commands": [
"opt < %s -passes=loop-vectorize -mattr=+v -force-vector-width=4 -scalable-vectorization=on -S 2>&1"
],
"tests": [
{
"test_name": "uniform_store_i1",
"test_body": "target triple = \"riscv64-linux-gnu\"\n\ndefine void @uniform_store_i1(ptr noalias %dst, ptr noalias %start, i64 %N) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %first.sroa = phi ptr [ %incdec.ptr, %for.body ], [ %start, %entry ]\n %iv = phi i64 [ %iv.next, %for.body ], [ 0, %entry ]\n %iv.next = add i64 %iv, 1\n %incdec.ptr = getelementptr inbounds i64, ptr %first.sroa, i64 1\n %cmp.not = icmp eq ptr %incdec.ptr, %start\n store i1 %cmp.not, ptr %dst, align 1\n %cmp = icmp ult i64 %iv, %N\n br i1 %cmp, label %for.body, label %end, !llvm.loop !0\n\nend: ; preds = %for.body\n ret void\n}\n\n!0 = distinct !{!0, !1}\n!1 = !{!\"llvm.loop.vectorize.scalable.enable\", i1 true}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/X86/epilog-vectorization-inductions.ll",
"commands": [
"opt -passes=loop-vectorize -mcpu=znver2 -S %s"
],
"tests": [
{
"test_name": "test_induction_step_needs_expansion",
"test_body": "target triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @test_induction_step_needs_expansion(ptr noalias %j, ptr %k, i64 %l, i16 %off) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %p.09 = phi i16 [ 0, %entry ], [ %add, %loop ]\n %add = sub i16 %p.09, %off\n %arrayidx3 = getelementptr inbounds i16, ptr %k, i64 %iv\n store i16 %add, ptr %arrayidx3, align 2\n %iv.next = add nuw nsw i64 %iv, 1\n %ec = icmp eq i64 %iv.next, %l\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/X86/induction-step.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-width=4 -S %s"
],
"tests": [
{
"test_name": "wide_add_induction_step_live_in",
"test_body": "target triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i16 @wide_add_induction_step_live_in(ptr %dst, i64 %N, i16 %off) {\nentry:\n %o.1 = add i16 %off, 2\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.2 = phi i16 [ 0, %entry ], [ %add, %loop ]\n %add = add i16 %iv.2, %o.1\n %gep.dst = getelementptr inbounds i16, ptr %dst, i64 %iv\n store i16 %add, ptr %gep.dst, align 2\n %iv.next = add nuw nsw i64 %iv, 1\n %ec = icmp eq i64 %iv.next, %N\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i16 %add\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "wide_sub_induction_step_live_in",
"test_body": "target triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i16 @wide_sub_induction_step_live_in(ptr %dst, i64 %N, i16 %off) {\nentry:\n %o.1 = add i16 %off, 2\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.2 = phi i16 [ 0, %entry ], [ %sub, %loop ]\n %sub = sub i16 %iv.2, %o.1\n %gep.dst = getelementptr inbounds i16, ptr %dst, i64 %iv\n store i16 %sub, ptr %gep.dst, align 2\n %iv.next = add nuw nsw i64 %iv, 1\n %ec = icmp eq i64 %iv.next, %N\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i16 %sub\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/expand-scev-after-invoke.ll",
"commands": [
"opt -p loop-vectorize -force-vector-width=4 -force-vector-interleave=2 -S %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndeclare i32 @foo()\n\n; Test case for https://github.com/llvm/llvm-project/issues/128838. Make sure\n; we do not crash when expanding %step.\ndefine void @test(ptr %dst) personality ptr null {\n;\nentry:\n %step = invoke i32 @foo()\n to label %loop unwind label %lpad\n\nloop:\n %iv.1 = phi i64 [ 0, %entry ], [ %add, %loop ]\n %iv.2 = phi i32 [ 0, %entry ], [ %iv.2.next, %loop ]\n %add = add i64 %iv.1, 1\n %gep = getelementptr inbounds i32, ptr %dst, i64 %iv.1\n store i32 %iv.2, ptr %gep, align 8\n %iv.2.next = add i32 %iv.2, %step\n %ec = icmp ult i64 %iv.1, 161\n br i1 %ec, label %loop, label %exit\n\nexit:\n ret void\n\nlpad:\n %landingpad = landingpad { ptr, i32 }\n cleanup\n ret void\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_loop1_fast_FMF",
"test_body": "@fp_inc = external global float, align 4\n\ndefine void @fp_iv_loop1_fast_FMF(float %init, ptr noalias captures(none) %A, i32 %N) {\nentry:\n %cmp4 = icmp sgt i32 %N, 0\n br i1 %cmp4, label %for.body.lr.ph, label %for.end\n\nfor.body.lr.ph: ; preds = %entry\n %fpinc = 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 %x.05 = phi float [ %init, %for.body.lr.ph ], [ %add, %for.body ]\n %arrayidx = getelementptr inbounds float, ptr %A, i64 %indvars.iv\n store float %x.05, ptr %arrayidx, align 4\n %add = fsub fast float %x.05, %fpinc\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
},
{
"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
},
{
"test_name": "fp_iv_loop1_reassoc_FMF",
"test_body": "@fp_inc = external global float, align 4\n\ndefine void @fp_iv_loop1_reassoc_FMF(float %init, ptr noalias captures(none) %A, i32 %N) {\nentry:\n %cmp4 = icmp sgt i32 %N, 0\n br i1 %cmp4, label %for.body.lr.ph, label %for.end\n\nfor.body.lr.ph: ; preds = %entry\n %fpinc = 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 %x.05 = phi float [ %init, %for.body.lr.ph ], [ %add, %for.body ]\n %arrayidx = getelementptr inbounds float, ptr %A, i64 %indvars.iv\n store float %x.05, ptr %arrayidx, align 4\n %add = fsub reassoc float %x.05, %fpinc\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
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/induction-step.ll",
"commands": [
"opt < %s -passes=loop-vectorize -force-vector-interleave=1 -force-vector-width=8 -S"
],
"tests": [
{
"test_name": "wide_add_induction_step_live_in",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine void @wide_add_induction_step_live_in(ptr %dst, i64 %N, i16 %off) {\nentry:\n %o.1 = add i16 %off, 2\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.2 = phi i16 [ 0, %entry ], [ %add, %loop ]\n %add = add i16 %iv.2, %o.1\n %gep.dst = getelementptr inbounds i16, ptr %dst, i64 %iv\n store i16 %add, ptr %gep.dst, align 2\n %iv.next = add nuw nsw i64 %iv, 1\n %ec = icmp eq i64 %iv.next, %N\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/induction.ll",
"commands": [
"opt < %s -passes=loop-vectorize -force-vector-interleave=1 -force-vector-width=2 -force-widen-divrem-via-safe-divisor=0 -S",
"opt < %s -passes=loop-vectorize,instcombine -force-vector-interleave=1 -force-vector-width=2 -force-widen-divrem-via-safe-divisor=0 -S",
"opt < %s -passes=loop-vectorize,instcombine -force-vector-interleave=2 -force-vector-width=2 -force-widen-divrem-via-safe-divisor=0 -S",
"opt < %s -passes=loop-vectorize -force-vector-interleave=2 -force-vector-width=2 -force-widen-divrem-via-safe-divisor=0 -S",
"opt < %s -passes=loop-vectorize,instcombine -force-vector-interleave=2 -force-vector-width=4 -force-widen-divrem-via-safe-divisor=0 -enable-interleaved-mem-accesses -S"
],
"tests": [
{
"test_name": "test_optimized_cast_induction_feeding_first_order_recurrence",
"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\ndefine void @test_optimized_cast_induction_feeding_first_order_recurrence(i64 %n, i32 %step, ptr %ptr) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %for = phi i32 [ 0, %entry ], [ %iv.2.conv, %loop ]\n %iv.1 = phi i64 [ 0, %entry ], [ %iv.1.next, %loop ]\n %iv.2 = phi i32 [ 0, %entry ], [ %iv.2.next, %loop ]\n %iv.2.ext = shl i32 %iv.2, 24\n %iv.2.conv = ashr exact i32 %iv.2.ext, 24\n %gep = getelementptr inbounds i32, ptr %ptr, i64 %iv.1\n store i32 %for, ptr %gep, align 4\n %iv.2.next = add nsw i32 %iv.2.conv, %step\n %iv.1.next = add nuw nsw i64 %iv.1, 1\n %exitcond = icmp eq i64 %iv.1.next, %n\n br i1 %exitcond, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "Assertion `!NodePtr->isKnownSentinel()' 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 void @wombat() gc \"statepoint-example\" personality ptr null {\nbb:\n %invoke = invoke i32 null(ptr addrspace(1) null, i32 0, i32 0, i32 0)\n to label %bb1 unwind label %bb5\n\nbb1: ; preds = %bb1, %bb\n %phi = phi i64 [ %add, %bb1 ], [ 0, %bb ]\n %phi2 = phi i32 [ %add3, %bb1 ], [ 0, %bb ]\n %add = add i64 %phi, 1\n %sitofp = sitofp i32 %phi2 to double\n store double %sitofp, ptr addrspace(1) null, align 8\n %add3 = add i32 %phi2, %invoke\n %icmp = icmp ult i64 %phi, 161\n br i1 %icmp, label %bb1, label %bb4\n\nbb4: ; preds = %bb1\n ret void\n\nbb5: ; preds = %bb\n %landingpad = landingpad { ptr, i32 }\n cleanup\n ret void\n}\n```\nReproducer: https://godbolt.org/z/3do96adnn\n\nStack dump:\n```\nopt: /root/llvm-project/llvm/include/llvm/ADT/ilist_iterator.h:322: llvm::ilist_iterator_w_bits<OptionsT, IsReverse, IsConst>::reference llvm::ilist_iterator_w_bits<OptionsT, IsReverse, IsConst>::operator*() const [with OptionsT = llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>; bool IsReverse = false; bool IsConst = false; llvm::ilist_iterator_w_bits<OptionsT, IsReverse, IsConst>::reference = llvm::Instruction&]: Assertion `!NodePtr->isKnownSentinel()' failed.\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=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 0x0000000005452b98 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5452b98)\n #1 0x0000000005450554 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007b16e6242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007b16e62969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007b16e6242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007b16e62287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x00007b16e622871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x00007b16e6239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x00000000044f6c23 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x44f6c23)\n #9 0x000000000450ebb3 llvm::VPTransformState::get(llvm::VPValue*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x450ebb3)\n#10 0x0000000004543138 llvm::VPInstruction::generate(llvm::VPTransformState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4543138)\n#11 0x0000000004544ba4 llvm::VPInstruction::execute(llvm::VPTransformState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4544ba4)\n#12 0x00000000044f82e7 llvm::VPBasicBlock::executeRecipes(llvm::VPTransformState*, llvm::BasicBlock*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x44f82e7)\n#13 0x00000000045038f9 llvm::VPIRBasicBlock::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x45038f9)\n#14 0x0000000004510249 llvm::VPlan::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4510249)\n#15 0x00000000043cccce llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool, llvm::DenseMap<llvm::SCEV const*, llvm::Value*, llvm::DenseMapInfo<llvm::SCEV const*, void>, llvm::detail::DenseMapPair<llvm::SCEV const*, llvm::Value*>> const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43cccce)\n#16 0x00000000043e15d8 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43e15d8)\n#17 0x00000000043e2f49 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43e2f49)\n#18 0x00000000043e35c3 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43e35c3)\n#19 0x000000000318aaae 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+0x318aaae)\n#20 0x000000000524cd90 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x524cd90)\n#21 0x0000000000e6f54e 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+0xe6f54e)\n#22 0x000000000524b6ab llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x524b6ab)\n#23 0x0000000000e6e83e 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+0xe6e83e)\n#24 0x000000000524b0b0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x524b0b0)\n#25 0x0000000000935a3a 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+0x935a3a)\n#26 0x00000000009290ac optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9290ac)\n#27 0x00007b16e6229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#28 0x00007b16e6229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#29 0x0000000000920985 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x920985)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```",
"author": "TatyanaDoubts",
"labels": [
"vectorizers",
"crash-on-valid"
],
"comments": [
{
"author": "fhahn",
"body": "looking "
}
]
}
| true
|
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
|
Timeout
| null |
98665
|
https://github.com/llvm/llvm-project/issues/98665
|
crash
|
662c6fc74c1ae7fdefd27524dfaeb7f3e9a1f553
| 2024-07-12T17:30:32
|
[
"llvm/test/Transforms/EarlyCSE"
] |
{
"fix_commit": "34bfed63313d1340378fc1be931253333db8c36c",
"components": [
"ConstantFold"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": [
[
2754,
2780
]
],
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": [
"ConstantFoldIntrinsicCall2"
],
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 34bfed63313d1340378fc1be931253333db8c36c
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Mon Jul 15 13:00:25 2024 +0800
[ConstantFold] Fix result type when folding powi.f16 (#98681)
Fixes #98665.
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 962880f68f07..6c52091cd5d7 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -2754,27 +2754,28 @@ static Constant *ConstantFoldIntrinsicCall2(Intrinsic::ID IntrinsicID, Type *Ty,
((Mask & fcPosInf) && Op1V.isPosInfinity());
return ConstantInt::get(Ty, Result);
}
+ case Intrinsic::powi: {
+ int Exp = static_cast<int>(Op2C->getSExtValue());
+ switch (Ty->getTypeID()) {
+ case Type::HalfTyID:
+ case Type::FloatTyID: {
+ APFloat Res(std::pow(Op1V.convertToFloat(), Exp));
+ if (Ty->isHalfTy()) {
+ bool Unused;
+ Res.convert(APFloat::IEEEhalf(), APFloat::rmNearestTiesToEven,
+ &Unused);
+ }
+ return ConstantFP::get(Ty->getContext(), Res);
+ }
+ case Type::DoubleTyID:
+ return ConstantFP::get(Ty, std::pow(Op1V.convertToDouble(), Exp));
+ default:
+ return nullptr;
+ }
+ }
default:
break;
}
-
- if (!Ty->isHalfTy() && !Ty->isFloatTy() && !Ty->isDoubleTy())
- return nullptr;
- if (IntrinsicID == Intrinsic::powi && Ty->isHalfTy())
- return ConstantFP::get(
- Ty->getContext(),
- APFloat((float)std::pow((float)Op1V.convertToDouble(),
- (int)Op2C->getZExtValue())));
- if (IntrinsicID == Intrinsic::powi && Ty->isFloatTy())
- return ConstantFP::get(
- Ty->getContext(),
- APFloat((float)std::pow((float)Op1V.convertToDouble(),
- (int)Op2C->getZExtValue())));
- if (IntrinsicID == Intrinsic::powi && Ty->isDoubleTy())
- return ConstantFP::get(
- Ty->getContext(),
- APFloat((double)std::pow(Op1V.convertToDouble(),
- (int)Op2C->getZExtValue())));
}
return nullptr;
}
|
[
{
"file": "llvm/test/Transforms/EarlyCSE/math-2.ll",
"commands": [
"opt -passes=early-cse -earlycse-debug-hash -S -o - %s"
],
"tests": [
{
"test_name": "i_powi",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare double @llvm.powi.f64.i32(double, i32) #0\n\ndefine double @i_powi() {\n %res = tail call fast double @llvm.powi.f64.i32(double 1.000000e+00, i32 2)\n ret double %res\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "pr98665",
"test_body": "define half @pr98665() {\n %x = call half @llvm.powi.f16.i32(half 0xH3C00, i32 1)\n ret half %x\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare half @llvm.powi.f16.i32(half, i32) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "Misoptimization: `EarlyCSEPass` uses replaces `powi.f16` with `float` result",
"body": "It looks like EarlyCSEPass is transformin the following:\r\n\r\n```llvm\r\n %_6 = alloca [48 x i8], align 8\r\n %_3 = alloca [2 x i8], align 2\r\n %0 = call half @llvm.powi.f16.i32(half 0xH3C00, i32 1) ; 0xH3C00 = 1.0f16\r\n store half %0, ptr %_3, align 2\r\n %1 = load half, ptr %_3, align 2\r\n %_4 = fcmp oeq half %1, 0xH3C00\r\n br i1 %_4, label %bb1, label %bb2\r\n```\r\n\r\nInto this:\r\n\r\n```llvm\r\n %_6 = alloca [48 x i8], align 8\r\n %_3 = alloca [2 x i8], align 2\r\n store float 1.000000e+00, ptr %_3, align 2\r\n %0 = load half, ptr %_3, align 2\r\n %_4 = fcmp oeq half %0, 0xH3C00\r\n br i1 %_4, label %bb1, label %bb2\r\n```\r\n\r\nAnd later InstCombine folds further into:\r\n\r\n```llvm\r\n %_6 = alloca [48 x i8], align 8\r\n %_3 = alloca [2 x i8], align 2\r\n store float 1.000000e+00, ptr %_3, align 2\r\n br i1 false, label %bb1, label %bb2\r\n```\r\n\r\nEarlyCSE seems to be doing an incorrect transformation: the result of `powi.f16(1.0, 1)` should be `half` 1.0 (0x3c00), but it is returning `float` 1.0 (0x3f800000). This is incorrect and an OOB write.\r\n\r\nThis comes from the following rust code, which asserts only when optimizations are enabled:\r\n\r\n```rust\r\n#![feature(f16)]\r\n#![allow(unused)]\r\n\r\n#[inline(never)]\r\npub fn check_pow(a: f16) {\r\n assert_eq!(1.0f16.powi(1), 1.0);\r\n}\r\n\r\npub fn main() {\r\n check_pow(1.0);\r\n println!(\"finished\");\r\n}\r\n```\r\n\r\nLink to compiler explorer: https://rust.godbolt.org/z/zsbzzxGvj\r\n\r\nI'm not sure how to reduce to a llc example since the passes appear different. I have been testing on aarch64 since x86 has other f16 ABI bugs, but I don't think this is limited to aarch64.",
"author": "tgross35",
"labels": [
"miscompilation",
"llvm:analysis"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Reproducer: https://godbolt.org/z/jhM834G3z\r\n```\r\ndefine half @test() {\r\n %x = call half @llvm.powi.f16.i32(half 0xH3C00, i32 1)\r\n ret half %x\r\n}\r\n```\r\n```\r\nopt: /root/llvm-project/llvm/lib/IR/Value.cpp:507: void llvm::Value::doRAUW(llvm::Value*, llvm::Value::ReplaceMetadataUses): Assertion `New->getType() == getType() && \"replaceAllUses of value with new value of different type!\"' 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=early-cse <source>\r\n1.\tRunning pass \"function(early-cse<>)\" on module \"<source>\"\r\n2.\tRunning pass \"early-cse<>\" on function \"test\"\r\n #0 0x0000000004e9b948 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e9b948)\r\n #1 0x0000000004e990bc SignalHandler(int) Signals.cpp:0:0\r\n #2 0x000078ad4b442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x000078ad4b4969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x000078ad4b442476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x000078ad4b4287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x000078ad4b42871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x000078ad4b439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x0000000004cce094 llvm::Value::doRAUW(llvm::Value*, llvm::Value::ReplaceMetadataUses) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4cce094)\r\n #9 0x0000000003ae3b58 (anonymous namespace)::EarlyCSE::processNode(llvm::DomTreeNodeBase<llvm::BasicBlock>*) EarlyCSE.cpp:0:0\r\n#10 0x0000000003ae5a85 (anonymous namespace)::EarlyCSE::run() EarlyCSE.cpp:0:0\r\n#11 0x0000000003ae81f8 llvm::EarlyCSEPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3ae81f8)\r\n#12 0x0000000002ac11be llvm::detail::PassModel<llvm::Function, llvm::EarlyCSEPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2ac11be)\r\n#13 0x0000000004c9f2d8 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4c9f2d8)\r\n#14 0x0000000000dc9bee 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+0xdc9bee)\r\n#15 0x0000000004c9dd46 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4c9dd46)\r\n#16 0x0000000000dca1fe 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+0xdca1fe)\r\n#17 0x0000000004c9bf10 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4c9bf10)\r\n#18 0x00000000008db1d2 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+0x8db1d2)\r\n#19 0x00000000008ce0fc optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8ce0fc)\r\n#20 0x000078ad4b429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#21 0x000078ad4b429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#22 0x00000000008c556e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8c556e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```\r\n\r\nThere is a bug in constant folding.\r\n\r\n"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
Cannot find a good commit
| null |
89516
|
https://github.com/llvm/llvm-project/issues/89516
|
miscompilation
|
18bb175428f520aaa4a5e388bd3b680a1a7c60c0
| 2024-04-20T22:58:16
|
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "6309440c218778db027306826993e484eab2be17",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": [
[
2720,
2726
]
],
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": [
"foldSelectWithSRem"
],
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 6309440c218778db027306826993e484eab2be17
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Sun Apr 21 22:41:32 2024 +0800
[InstCombine] Fix unexpected overwriting in `foldSelectWithSRem` (#89539)
Fixes #89516
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index 0262af28068b..73600206a55c 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -2720,7 +2720,7 @@ static Instruction *foldSelectWithSRem(SelectInst &SI, InstCombinerImpl &IC,
// %cnd = icmp slt i32 %rem, 0
// %add = add i32 %rem, %n
// %sel = select i1 %cnd, i32 %add, i32 %rem
- if (match(TrueVal, m_Add(m_Value(RemRes), m_Value(Remainder))) &&
+ if (match(TrueVal, m_Add(m_Specific(RemRes), m_Value(Remainder))) &&
match(RemRes, m_SRem(m_Value(Op), m_Specific(Remainder))) &&
IC.isKnownToBeAPowerOfTwo(Remainder, /*OrZero*/ true) &&
FalseVal == RemRes)
|
[
{
"file": "llvm/test/Transforms/InstCombine/select-divrem.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "rem_euclid_pow2_false_arm_folded",
"test_body": "define i32 @rem_euclid_pow2_false_arm_folded(i32 %n) {\n %rem = srem i32 %n, 2\n %nonneg = icmp sge i32 %rem, 0\n %res = select i1 %nonneg, i32 %rem, i32 1\n ret i32 %res\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "pr89516",
"test_body": "define i8 @pr89516(i8 %n, i8 %x) {\n %cond = icmp slt i8 %x, 0\n %pow2 = shl nuw i8 1, %n\n %srem = srem i8 1, %pow2\n %add = add nuw i8 %srem, %pow2\n %res = select i1 %cond, i8 %add, i8 %srem\n ret i8 %res\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "miscompile of vanilla integer code by InstCombine",
"body": "https://alive2.llvm.org/ce/z/jRfVLr\r\n\r\nthis function:\r\n```llvm\r\ndefine i8 @f(i8 %0, i8 %1) {\r\n %3 = icmp slt i8 %1, 0\r\n %4 = shl i8 1, %0\r\n %5 = srem i8 1, %4\r\n %6 = add i8 %5, %4\r\n %7 = select i1 %3, i8 %6, i8 %5\r\n ret i8 %7\r\n}\r\n```\r\nis getting mis-optimized to:\r\n```llvm\r\ndefine i8 @f(i8 %0, i8 %1) {\r\n %3 = icmp ne i8 %0, 0\r\n %4 = zext i1 %3 to i8\r\n ret i8 %4\r\n}\r\n```\r\nhere I'll just give Alive's work:\r\n```\r\nExample:\r\ni8 %#0 = #x00 (0)\r\ni8 %#1 = #xff (255, -1)\r\n\r\nSource:\r\ni1 %#3 = #x1 (1)\r\ni8 %#4 = #x01 (1)\r\ni8 %#5 = #x00 (0)\r\ni8 %#6 = #x01 (1)\r\ni8 %#7 = #x01 (1)\r\n\r\nTarget:\r\ni1 %#3 = #x0 (0)\r\ni8 %#4 = #x00 (0)\r\nSource value: #x01 (1)\r\nTarget value: #x00 (0)\r\n```\r\n\r\ncc @nunoplopes @hatsunespica",
"author": "regehr",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
211692137af45fcf6d6b14582e004a746f9e5b2e
| null |
134115
|
https://github.com/llvm/llvm-project/issues/134115
|
crash
|
6388a7acf7e31fdc7b9c168bd6ce0f4d25c98cd0
| 2025-04-02T17:01:09
|
[
"llvm/test/Transforms/FunctionAttrs"
] |
{
"fix_commit": "0547e84181ff10b24d6363bbfc97f168fe245397",
"components": [
"FunctionAttrs"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": [
[
661,
668
]
],
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": [
"getArgumentAccessInfo"
],
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 0547e84181ff10b24d6363bbfc97f168fe245397
Author: Arthur Eubanks <aeubanks@google.com>
Date: Wed Apr 23 15:56:24 2025 -0700
[FunctionAttrs] Bail if initializes range overflows 64-bit signed int (#137053)
Otherwise the range doesn't make sense since we interpret it as signed.
Fixes #134115
diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
index bbfed2ac2c09..74e8a849803d 100644
--- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -661,8 +661,13 @@ ArgumentAccessInfo getArgumentAccessInfo(const Instruction *I,
auto TypeSize = DL.getTypeStoreSize(Ty);
if (!TypeSize.isScalable() && Offset) {
int64_t Size = TypeSize.getFixedValue();
- return ConstantRange(APInt(64, *Offset, true),
- APInt(64, *Offset + Size, true));
+ APInt Low(64, *Offset, true);
+ bool Overflow;
+ APInt High = Low.sadd_ov(APInt(64, Size, true), Overflow);
+ // Bail if the range overflows signed 64-bit int.
+ if (Overflow)
+ return std::nullopt;
+ return ConstantRange(Low, High);
}
return std::nullopt;
};
|
[
{
"file": "llvm/test/Transforms/FunctionAttrs/initializes.ll",
"commands": [
"opt -passes=function-attrs -S < %s"
],
"tests": [
{
"test_name": "memset_offset_1_size_0",
"test_body": "define void @memset_offset_1_size_0(ptr %dst, ptr %src) {\n %dst.1 = getelementptr inbounds i8, ptr %dst, i64 1\n call void @llvm.memmove.p0.p0.i64(ptr %dst.1, ptr %src, i64 0, i1 false)\n ret void\n}\n\n; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)\ndeclare void @llvm.memmove.p0.p0.i64(ptr writeonly captures(none), ptr readonly captures(none), i64, i1 immarg) #0\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "range_overflows_signed_64_bit_int",
"test_body": "define void @range_overflows_signed_64_bit_int(ptr %arg) {\n %getelementptr = getelementptr i8, ptr %arg, i64 9223372036854775804\n store i32 0, ptr %getelementptr, align 4\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "FunctionAttrs: Assertion `isOrder edRanges(RangesRef)' failed.",
"body": "```\n$ cat /tmp/f.ll\ndefine i32 @f(ptr %arg, ptr %arg2) {\n store ptr %arg, ptr %arg2\n %getelementptr = getelementptr float, ptr %arg, i64 2305843009213693951\n %load = load i32, ptr %getelementptr, align 4\n ret i32 %load\n}\n$ opt -p function-attrs /tmp/f.ll -disable-output\nopt: ../../llvm/include/llvm/IR/ConstantRangeList.h:36: llvm::ConstantRangeList::ConstantRangeList(ArrayRef<ConstantRange>): Assertion `isOrder\nedRanges(RangesRef)' failed.\n```",
"author": "aeubanks",
"labels": [
"ipo",
"crash"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
Cannot find a good commit
| null |
109468
|
https://github.com/llvm/llvm-project/issues/109468
|
crash
|
51039101cf32591782ef564a108db71150a3b7c3
| 2024-09-20T20:22:11
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "a068b974b199b0e7350da2d9506adc7df3995ce3",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": [
[
2709,
2714
],
[
2787,
2792
]
],
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": [
[
2267,
2272
],
[
2363,
2368
]
],
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": [
"VPWidenLoadEVLRecipe::execute",
"VPWidenLoadEVLRecipe::print",
"VPWidenStoreEVLRecipe::execute",
"VPWidenStoreEVLRecipe::print"
],
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit a068b974b199b0e7350da2d9506adc7df3995ce3
Author: Elvis Wang <elvis.wang@sifive.com>
Date: Thu Sep 26 07:10:25 2024 +0800
[VPlan] Implement VPWidenLoad/StoreEVLRecipe::computeCost(). (#109644)
Currently the EVL recipes transfer the tail masking to the EVL.
But in the legacy cost model, the mask exist and will calculate the
instruction cost of the mask.
To fix the difference between the VPlan-based cost model and the legacy
cost model, we always calculate the instruction cost for the mask in the
EVL recipes.
Note that we should remove the mask cost in the EVL recipes when we
don't need to compare to the legacy cost model.
This patch also fixes #109468.
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index bbcfaf9e19cd..23a24ce293ef 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -2709,6 +2709,10 @@ struct VPWidenLoadEVLRecipe final : public VPWidenMemoryRecipe, public VPValue {
/// Generate the wide load or gather.
void execute(VPTransformState &State) override;
+ /// Return the cost of this VPWidenLoadEVLRecipe.
+ InstructionCost computeCost(ElementCount VF,
+ VPCostContext &Ctx) const override;
+
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
/// Print the recipe.
void print(raw_ostream &O, const Twine &Indent,
@@ -2787,6 +2791,10 @@ struct VPWidenStoreEVLRecipe final : public VPWidenMemoryRecipe {
/// Generate the wide store or scatter.
void execute(VPTransformState &State) override;
+ /// Return the cost of this VPWidenStoreEVLRecipe.
+ InstructionCost computeCost(ElementCount VF,
+ VPCostContext &Ctx) const override;
+
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
/// Print the recipe.
void print(raw_ostream &O, const Twine &Indent,
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index dacba152611c..9a0aefb898e5 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -2267,6 +2267,31 @@ void VPWidenLoadEVLRecipe::execute(VPTransformState &State) {
State.set(this, Res);
}
+InstructionCost VPWidenLoadEVLRecipe::computeCost(ElementCount VF,
+ VPCostContext &Ctx) const {
+ if (!Consecutive || IsMasked)
+ return VPWidenMemoryRecipe::computeCost(VF, Ctx);
+
+ // We need to use the getMaskedMemoryOpCost() instead of getMemoryOpCost()
+ // here because the EVL recipes using EVL to replace the tail mask. But in the
+ // legacy model, it will always calculate the cost of mask.
+ // TODO: Using getMemoryOpCost() instead of getMaskedMemoryOpCost when we
+ // don't need to compare to the legacy cost model.
+ Type *Ty = ToVectorTy(getLoadStoreType(&Ingredient), VF);
+ const Align Alignment =
+ getLoadStoreAlignment(const_cast<Instruction *>(&Ingredient));
+ unsigned AS =
+ getLoadStoreAddressSpace(const_cast<Instruction *>(&Ingredient));
+ TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
+ InstructionCost Cost = Ctx.TTI.getMaskedMemoryOpCost(
+ Ingredient.getOpcode(), Ty, Alignment, AS, CostKind);
+ if (!Reverse)
+ return Cost;
+
+ return Cost + Ctx.TTI.getShuffleCost(TargetTransformInfo::SK_Reverse,
+ cast<VectorType>(Ty), {}, CostKind, 0);
+}
+
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void VPWidenLoadEVLRecipe::print(raw_ostream &O, const Twine &Indent,
VPSlotTracker &SlotTracker) const {
@@ -2363,6 +2388,31 @@ void VPWidenStoreEVLRecipe::execute(VPTransformState &State) {
State.addMetadata(NewSI, SI);
}
+InstructionCost VPWidenStoreEVLRecipe::computeCost(ElementCount VF,
+ VPCostContext &Ctx) const {
+ if (!Consecutive || IsMasked)
+ return VPWidenMemoryRecipe::computeCost(VF, Ctx);
+
+ // We need to use the getMaskedMemoryOpCost() instead of getMemoryOpCost()
+ // here because the EVL recipes using EVL to replace the tail mask. But in the
+ // legacy model, it will always calculate the cost of mask.
+ // TODO: Using getMemoryOpCost() instead of getMaskedMemoryOpCost when we
+ // don't need to compare to the legacy cost model.
+ Type *Ty = ToVectorTy(getLoadStoreType(&Ingredient), VF);
+ const Align Alignment =
+ getLoadStoreAlignment(const_cast<Instruction *>(&Ingredient));
+ unsigned AS =
+ getLoadStoreAddressSpace(const_cast<Instruction *>(&Ingredient));
+ TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
+ InstructionCost Cost = Ctx.TTI.getMaskedMemoryOpCost(
+ Ingredient.getOpcode(), Ty, Alignment, AS, CostKind);
+ if (!Reverse)
+ return Cost;
+
+ return Cost + Ctx.TTI.getShuffleCost(TargetTransformInfo::SK_Reverse,
+ cast<VectorType>(Ty), {}, CostKind, 0);
+}
+
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void VPWidenStoreEVLRecipe::print(raw_ostream &O, const Twine &Indent,
VPSlotTracker &SlotTracker) const {
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/RISCV/vectorize-force-tail-with-evl-uniform-store.ll",
"commands": [
"opt < %s --prefer-predicate-over-epilogue=predicate-dont-vectorize --passes=loop-vectorize -mcpu=sifive-p470 -mattr=+v,+f -force-tail-folding-style=data-with-evl -S"
],
"tests": [
{
"test_name": "lshift_significand",
"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 @lshift_significand(i32 %n, ptr nocapture writeonly %dst) {\nentry:\n %cmp1.peel = icmp eq i32 %n, 0\n %spec.select = select i1 %cmp1.peel, i64 2, i64 0\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ %spec.select, %entry ], [ %iv.next, %loop ]\n %0 = sub nuw nsw i64 1, %iv\n %arrayidx13 = getelementptr i64, ptr %dst, i64 %0\n store i64 0, ptr %arrayidx13, align 8\n %iv.next = add nuw nsw i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 3\n br i1 %exitcond.not, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[LV][VPlan] Crash due to disagreements on the VPlan cost v.s. legacy cost model",
"body": "Given this input:\r\n``` llvm\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 @lshift_significand(i32 %n, ptr %0) {\r\nentry:\r\n br label %for.cond\r\n\r\nfor.cond: ; preds = %for.cond, %entry\r\n %i.0 = phi i32 [ 0, %entry ], [ 2, %for.cond ]\r\n %add = or i32 %n, %i.0\r\n %cmp1 = icmp eq i32 %add, 0\r\n br i1 %cmp1, label %for.cond, label %for.cond7\r\n\r\nfor.cond7: ; preds = %for.body9, %for.cond\r\n %i.1 = phi i32 [ %i.0, %for.cond ], [ %inc15, %for.body9 ]\r\n %cmp8 = icmp ult i32 %i.1, 3\r\n br i1 %cmp8, label %for.body9, label %for.end16\r\n\r\nfor.body9: ; preds = %for.cond7\r\n %sub11 = sub nuw i32 1, %i.1\r\n %idxprom12 = zext i32 %sub11 to i64\r\n %arrayidx13 = getelementptr [3 x i64], ptr %0, i64 0, i64 %idxprom12\r\n store i64 0, ptr %arrayidx13, align 8\r\n %inc15 = add i32 %i.1, 1\r\n br label %for.cond7\r\n\r\nfor.end16: ; preds = %for.cond7\r\n ret void\r\n}\r\n```\r\nAnd this command:\r\n``` bash\r\nopt -mcpu=sifive-p470 -O3 -prefer-predicate-over-epilogue=predicate-dont-vectorize -force-tail-folding-style=data-with-evl input.ll -disable-output\r\n```\r\nWe'll get the following assertion:\r\n```\r\nllvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7386: 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\n```\r\n\r\n\r\nPreliminary investigation shows that this is caused by the disagreement on (reverse) widen store's cost. First, this is the trace for VPlan's cost model:\r\n```\r\nLV: Scalar loop costs: 4.\r\nCost of 1 for VF vscale x 1: induction instruction %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1\r\nCost of 0 for VF vscale x 1: induction instruction %indvars.iv = phi i64 [ %spec.select, %entry ], [ %indvars.iv.next, %for.body9 ]\r\nCost of 1 for VF vscale x 1: exit condition instruction %exitcond.not = icmp eq i64 %indvars.iv.next, 3\r\nCost of 0 for VF vscale x 1: EMIT vp<%4> = CANONICAL-INDUCTION ir<0>, vp<%12>\r\nCost of 0 for VF vscale x 1: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI vp<%5> = phi ir<0>, vp<%11>\r\nCost of 0 for VF vscale x 1: EMIT vp<%6> = EXPLICIT-VECTOR-LENGTH vp<%5>, vp<%3>\r\nCost of 0 for VF vscale x 1: vp<%7> = DERIVED-IV ir<%spec.select> + vp<%5> * ir<1>\r\nCost of 0 for VF vscale x 1: vp<%8> = SCALAR-STEPS vp<%7>, ir<1>\r\nCost of 1 for VF vscale x 1: CLONE ir<%1> = sub nuw nsw ir<1>, vp<%8>\r\nCost of 0 for VF vscale x 1: CLONE ir<%arrayidx13> = getelementptr ir<%0>, ir<0>, ir<%1>\r\nCost of 0 for VF vscale x 1: vp<%9> = vector-pointer (reverse) ir<%arrayidx13>\r\nCost of 8 for VF vscale x 1: WIDEN vp.store vp<%9>, ir<0>, vp<%6>\r\nCost of 0 for VF vscale x 1: SCALAR-CAST vp<%10> = zext vp<%6> to i64\r\nCost of 0 for VF vscale x 1: EMIT vp<%11> = add vp<%10>, vp<%5>\r\nCost of 0 for VF vscale x 1: EMIT vp<%12> = add vp<%4>, vp<%0>\r\nCost of 0 for VF vscale x 1: EMIT branch-on-count vp<%12>, vp<%1>\r\nCost of 0 for VF vscale x 1: vector loop backedge\r\nCost for VF vscale x 1: 11\r\nCost of 1 for VF vscale x 2: induction instruction %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1\r\nCost of 0 for VF vscale x 2: induction instruction %indvars.iv = phi i64 [ %spec.select, %entry ], [ %indvars.iv.next, %for.body9 ]\r\nCost of 1 for VF vscale x 2: exit condition instruction %exitcond.not = icmp eq i64 %indvars.iv.next, 3\r\nCost of 0 for VF vscale x 2: EMIT vp<%4> = CANONICAL-INDUCTION ir<0>, vp<%12>\r\nCost of 0 for VF vscale x 2: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI vp<%5> = phi ir<0>, vp<%11>\r\nCost of 0 for VF vscale x 2: EMIT vp<%6> = EXPLICIT-VECTOR-LENGTH vp<%5>, vp<%3>\r\nCost of 0 for VF vscale x 2: vp<%7> = DERIVED-IV ir<%spec.select> + vp<%5> * ir<1>\r\nCost of 0 for VF vscale x 2: vp<%8> = SCALAR-STEPS vp<%7>, ir<1>\r\nCost of 1 for VF vscale x 2: CLONE ir<%1> = sub nuw nsw ir<1>, vp<%8>\r\nCost of 0 for VF vscale x 2: CLONE ir<%arrayidx13> = getelementptr ir<%0>, ir<0>, ir<%1>\r\nCost of 0 for VF vscale x 2: vp<%9> = vector-pointer (reverse) ir<%arrayidx13>\r\nCost of 14 for VF vscale x 2: WIDEN vp.store vp<%9>, ir<0>, vp<%6>\r\nCost of 0 for VF vscale x 2: SCALAR-CAST vp<%10> = zext vp<%6> to i64\r\nCost of 0 for VF vscale x 2: EMIT vp<%11> = add vp<%10>, vp<%5>\r\nCost of 0 for VF vscale x 2: EMIT vp<%12> = add vp<%4>, vp<%0>\r\nCost of 0 for VF vscale x 2: EMIT branch-on-count vp<%12>, vp<%1>\r\nCost of 0 for VF vscale x 2: vector loop backedge\r\nCost for VF vscale x 2: 17\r\n```\r\nWith VPlan's cost model, we will eventually choose scalar loop, because when VF=vscale x 1, the final cost is `ceil(11 / 2) = 6`; when VF=vscale x 2, the final cost is `ceil(17 / 4) = 5`. Both of them are larger than the scalar cost, 4.\r\n\r\nWhile with the legacy cost model:\r\n```\r\nLV: Found an estimated cost of 0 for VF 1 For instruction: %indvars.iv = phi i64 [ %spec.select, %entry ], [ %indvars.iv.next, %for.body9 ]\r\nLV: Found an estimated cost of 1 for VF 1 For instruction: %1 = sub nuw nsw i64 1, %indvars.iv\r\nLV: Found an estimated cost of 0 for VF 1 For instruction: %arrayidx13 = getelementptr [3 x i64], ptr %0, i64 0, i64 %1\r\nLV: Found an estimated cost of 1 for VF 1 For instruction: store i64 0, ptr %arrayidx13, align 8\r\nLV: Found an estimated cost of 1 for VF 1 For instruction: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1\r\nLV: Found an estimated cost of 1 for VF 1 For instruction: %exitcond.not = icmp eq i64 %indvars.iv.next, 3\r\nLV: Found an estimated cost of 0 for VF 1 For instruction: br i1 %exitcond.not, label %for.end16, label %for.body9\r\nLV: Scalar loop costs: 4.\r\nLV: Found an estimated cost of 0 for VF vscale x 1 For instruction: %indvars.iv = phi i64 [ %spec.select, %entry ], [ %indvars.iv.next, %for.body9 ]\r\nLV: Found an estimated cost of 1 for VF vscale x 1 For instruction: %1 = sub nuw nsw i64 1, %indvars.iv\r\nLV: Found an estimated cost of 0 for VF vscale x 1 For instruction: %arrayidx13 = getelementptr [3 x i64], ptr %0, i64 0, i64 %1\r\nLV: Found an estimated cost of 7 for VF vscale x 1 For instruction: store i64 0, ptr %arrayidx13, align 8\r\nLV: Found an estimated cost of 1 for VF vscale x 1 For instruction: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1\r\nLV: Found an estimated cost of 1 for VF vscale x 1 For instruction: %exitcond.not = icmp eq i64 %indvars.iv.next, 3\r\nLV: Found an estimated cost of 0 for VF vscale x 1 For instruction: br i1 %exitcond.not, label %for.end16, label %for.body9\r\nLV: Vector loop of width vscale x 1 costs: 5 (assuming a minimum vscale of 2).\r\nLV: Found an estimated cost of 0 for VF vscale x 2 For instruction: %indvars.iv = phi i64 [ %spec.select, %entry ], [ %indvars.iv.next, %for.body9 ]\r\nLV: Found an estimated cost of 1 for VF vscale x 2 For instruction: %1 = sub nuw nsw i64 1, %indvars.iv\r\nLV: Found an estimated cost of 0 for VF vscale x 2 For instruction: %arrayidx13 = getelementptr [3 x i64], ptr %0, i64 0, i64 %1\r\nLV: Found an estimated cost of 13 for VF vscale x 2 For instruction: store i64 0, ptr %arrayidx13, align 8\r\nLV: Found an estimated cost of 1 for VF vscale x 2 For instruction: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1\r\nLV: Found an estimated cost of 1 for VF vscale x 2 For instruction: %exitcond.not = icmp eq i64 %indvars.iv.next, 3\r\nLV: Found an estimated cost of 0 for VF vscale x 2 For instruction: br i1 %exitcond.not, label %for.end16, label %for.body9\r\nLV: Vector loop of width vscale x 2 costs: 4 (assuming a minimum vscale of 2).\r\nLV: Selecting VF: vscale x 2.\r\n```\r\nWe will eventually choose VF=vscale x 2.\r\n\r\nThe key difference is the cost of `store i64 0, ptr %arrayidx13, align 8` v.s. cost of `WIDEN vp.store vp<%9>, ir<0>, vp<%6>`, where the latter is larger than the former by 1.\r\n\r\nIn both cases (the store instruction in VPlan cost model v.s. legacy cost model) their costs are computed by the base cost of store + the cost of shuffle due to being reverse store. I used debugger to confirm that they used the same shuffle cost, which means that for some reason, VPlan's cost model yield a slightly higher cost for store than that in the legacy cost model.\r\n",
"author": "mshockwave",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "ElvisWang123",
"body": "It seems that the legacy cost model using `getMaskedMemoryOpCost` to query the instruction cost. But in the VPlan-based cost model using `getMemoryOpCost`. \r\n\r\nIn this case, the mask in the `VPWidenStoreEVLRecipe` is false since it is using the EVL recipe.\r\nThe legacy cost model will not check the tail folding type so it will using `getMaskedMemoryOpCost` instead of `getMemoryOpCost` . And the `MaskedMemoryCost` is slightly smaller than non-mask version."
},
{
"author": "ElvisWang123",
"body": "Open a PR to fix this issue. #109644 \r\n\r\nWe remove the shuffle cost when the value stored by reversed vector is loop invariant."
},
{
"author": "mshockwave",
"body": "CC @fhahn "
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
|
ed220e15718498d0f854f1044ddcbfee00739aa7
| null |
178245
|
https://github.com/llvm/llvm-project/issues/178245
|
miscompilation
|
ff79d7d1bf0415e52ad542b059c55f0e92b3bad6
| 2026-01-27T16:11:49
|
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "909041e4802c4b9a2223ca04099f35bf1dbbd460",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": [
[
3049,
3055
]
],
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": [
"InstCombinerImpl::visitCallInst"
],
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 909041e4802c4b9a2223ca04099f35bf1dbbd460
Author: Matt Arsenault <Matthew.Arsenault@amd.com>
Date: Tue Jan 27 18:21:44 2026 +0100
InstCombine: Check one use before trying to simplify copysign sign (#178251)
Fixes #178245
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index c34231a74c78..fbf69d871dfc 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -3049,7 +3049,8 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
Type *SignEltTy = Sign->getType()->getScalarType();
Value *CastSrc;
- if (match(Sign, m_ElementWiseBitCast(m_OneUse(m_Value(CastSrc)))) &&
+ if (match(Sign,
+ m_OneUse(m_ElementWiseBitCast(m_OneUse(m_Value(CastSrc))))) &&
CastSrc->getType()->isIntOrIntVectorTy() &&
APFloat::hasSignBitInMSB(SignEltTy->getFltSemantics())) {
KnownBits Known(SignEltTy->getPrimitiveSizeInBits());
|
[
{
"file": "llvm/test/Transforms/InstCombine/copysign.ll",
"commands": [
"opt -S -passes=instcombine<no-verify-fixpoint> < %s"
],
"tests": [
{
"test_name": "issue178245",
"test_body": "; bin/opt -passes=\"instcombine<no-verify-fixpoint>\" test.ll -S\ndefine i32 @src(i32 %i.0.i.i) {\nentry:\n %conv102.i.i = sext i32 %i.0.i.i to i64\n %add.i128.i.i = add i64 %conv102.i.i, 1177359834\n %tobool104.i.i = icmp ne i64 %add.i128.i.i, 0\n %conv108.i.i = zext i1 %tobool104.i.i to i16\n %mul.i.i.i = mul i16 -5, %conv108.i.i\n %conv111.i.i = sext i16 %mul.i.i.i to i32\n %0 = bitcast i32 %conv111.i.i to float\n %1 = fcmp uno float %0, 0.000000e+00\n %2 = call float @llvm.copysign.f32(float 0.000000e+00, float %0)\n %3 = select i1 %1, float 0.000000e+00, float %2\n %4 = bitcast float %3 to i32\n ret i32 %4\n}",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[InstCombine] Miscompilation at O1",
"body": "Reproducer: https://alive2.llvm.org/ce/z/BPpLg_\n```llvm\n; bin/opt -passes=\"instcombine<no-verify-fixpoint>\" test.ll -S\ndefine i32 @src(i32 %i.0.i.i) {\nentry:\n %conv102.i.i = sext i32 %i.0.i.i to i64\n %add.i128.i.i = add i64 %conv102.i.i, 1177359834\n %tobool104.i.i = icmp ne i64 %add.i128.i.i, 0\n %conv108.i.i = zext i1 %tobool104.i.i to i16\n %mul.i.i.i = mul i16 -5, %conv108.i.i\n %conv111.i.i = sext i16 %mul.i.i.i to i32\n %0 = bitcast i32 %conv111.i.i to float\n %1 = fcmp uno float %0, 0.000000e+00\n %2 = call float @llvm.copysign.f32(float 0.000000e+00, float %0)\n %3 = select i1 %1, float 0.000000e+00, float %2\n %4 = bitcast float %3 to i32\n ret i32 %4\n}\n```\nOutput:\n```llvm\ndefine i32 @src(i32 %i.0.i.i) {\nentry:\n %tobool104.i.i.not = icmp eq i32 %i.0.i.i, -1177359834\n %conv111.i.i = select i1 %tobool104.i.i.not, i32 0, i32 -1177359834\n %0 = bitcast i32 %conv111.i.i to float\n %1 = fcmp uno float %0, 0.000000e+00\n %2 = call float @llvm.copysign.f32(float 0.000000e+00, float %0)\n %3 = select i1 %1, float 0.000000e+00, float %2\n %4 = bitcast float %3 to i32\n ret i32 %4\n}\n```\n```\nTransformation doesn't verify!\n\nERROR: Value mismatch\n\nExample:\ni32 %i.0.i.i = #x00000000 (0)\n\nSource:\ni64 %conv102.i.i = #x0000000000000000 (0)\ni64 %add.i128.i.i = #x00000000462d15da (1177359834)\ni1 %tobool104.i.i = #x1 (1)\ni16 %conv108.i.i = #x0001 (1)\ni16 %mul.i.i.i = #xfffb (65531, -5)\ni32 %conv111.i.i = #xfffffffb (4294967291, -5)\nfloat %#0 = #xfffffffb (QNaN)\ni1 %#1 = #x1 (1)\nfloat %#2 = #x80000000 (-0.0)\nfloat %#3 = #x00000000 (+0.0)\ni32 %#4 = #x00000000 (0)\n\nTarget:\ni1 %tobool104.i.i.not = #x0 (0)\ni32 %conv111.i.i = #xb9d2ea26 (3117607462, -1177359834)\nfloat %#0 = #xb9d2ea26 (-0.000402287754?)\ni1 %#1 = #x0 (0)\nfloat %#2 = #x80000000 (-0.0)\nfloat %#3 = #x80000000 (-0.0)\ni32 %#4 = #x80000000 (2147483648, -2147483648)\nSource value: #x00000000 (0)\nTarget value: #x80000000 (2147483648, -2147483648)\n```\nllvm version: 94e21bcec061c1691cd0d5382e3c6f420e0386c4\nLooks like it is triggered by https://github.com/llvm/llvm-project/pull/177942. cc @arsenm",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:instcombine",
"floating-point",
"generated by fuzzer"
],
"comments": [
{
"author": "arsenm",
"body": "[Reduced](https://alive2.llvm.org/ce/z/Xsp_n_)\n\nThe only thing that seems to have changed is the negative constant on the select?"
},
{
"author": "dtcxzyw",
"body": "> The only thing that seems to have changed is the negative constant on the select?\n\nYeah. We cannot do it as `%i` has multiple users."
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null | null |
165359
|
https://github.com/llvm/llvm-project/issues/165359
|
crash
|
6a0ba8b7a4176bbc78f4dcff4f21bae1e2097d67
| 2025-10-28T08:46:02
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "a04c6b5512bf091b4eec6c4f7dbfaaf44b290906",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
[
4018,
4023
]
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"LoopVectorizationPlanner::emitInvalidCostRemarks"
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit a04c6b5512bf091b4eec6c4f7dbfaaf44b290906
Author: Ryan Buchner <buchner.ryan@gmail.com>
Date: Thu Nov 13 08:12:40 2025 -0800
[LV] Update LoopVectorizationPlanner::emitInvalidCostRemarks to handle reduction plans (#165913)
The TypeSwitch for extracting the Opcode now handles the `VPReductionRecipe` case.
Fixes #165359.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 835b0995cc4f..f4629d22002d 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -4018,6 +4018,9 @@ void LoopVectorizationPlanner::emitInvalidCostRemarks(
.Case<VPInterleaveRecipe>([](const VPInterleaveRecipe *R) {
return R->getStoredValues().empty() ? Instruction::Load
: Instruction::Store;
+ })
+ .Case<VPReductionRecipe>([](const auto *R) {
+ return RecurrenceDescriptor::getOpcode(R->getRecurrenceKind());
});
// If the next recipe is different, or if there are no other pairs,
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/bug165359.ll",
"commands": [
"opt < %s -passes=loop-vectorize -S -pass-remarks-analysis=loop-vectorize -disable-output"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n\ntarget triple = \"aarch64-unknown-linux-gnu\"\n\ndefine double @reduce_fail(i64 %loop_count, double %d0, ptr %ptr1) #0 {\nentry:\n %d1 = load double, ptr %ptr1\n br label %loop\n\nloop:\n %acc0 = phi double [ %fadd0, %loop ], [ %d0, %entry ]\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %fadd0 = fadd double %acc0, %d1\n %iv.next = add nsw nuw i64 %iv, 1\n %exit_cond = icmp eq i64 %iv.next, %loop_count\n br i1 %exit_cond, label %loopexit, label %loop\n\nloopexit:\n ret double %fadd0\n}\n\nattributes #0 = { \"target-features\"=\"+sve\" }",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[LV][SVE] Crashed when optimization remarks are enabled: \"Fell off the end of a type-switch\"",
"body": "Some Fortran benchmarks (e.g., SPEC2017 and NPB) fail to compile when optimization remarks are enabled.\nThe following is a reproducer.\n\n```\n$ cat repro.f90\nsubroutine repro(iter, v, sum)\n implicit none\n\n integer iter, i, m\n double precision v(5), sum(5)\n\n do i = 1, iter\n do m = 1, 5\n sum(m) = sum(m) + v(m)\n end do\n end do\nend subroutine\n$ flang -O2 -march=armv8-a+sve repro.f90 -Rpass=vector\nFell off the end of a type-switch\nUNREACHABLE executed at /path/to/llvm-project/llvm/include/llvm/ADT/TypeSwitch.h:126!\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.\nStack dump:\n0. Program arguments: /path/to/build/bin/flang -fc1 -triple aarch64-unknown-linux-gnu -emit-obj -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu generic -target-feature +outline-atomics -target-feature +v8a -target-feature +fp-armv8 -target-feature +fullfp16 -target-feature +neon -target-feature +sve -vectorize-loops -vectorize-slp -Rpass=vector -resource-dir /path/to/build/lib/clang/22 -mframe-pointer=non-leaf -O2 -o /tmp/repro-737c08.o -x f95 repro.f90\n1. Running pass \"function<eager-inv>(drop-unnecessary-assumes,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-arithmetic;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;switch-to-arithmetic;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 \"FIRModule\"\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"repro_\"\n #0 0x0000ffff71b64710 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/path/to/build/lib/libLLVM.so.22.0git+0xa8f710)\n #1 0x0000ffff71b61c9c llvm::sys::RunSignalHandlers() (/path/to/build/lib/libLLVM.so.22.0git+0xa8cc9c)\n #2 0x0000ffff71b61df4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #3 0x0000ffff86f6d7f0 (linux-vdso.so.1+0x7f0)\n #4 0x0000ffff70cb37b8 __pthread_kill_implementation /usr/src/debug/glibc-2.34-168.el9_6.23.aarch64/nptl/pthread_kill.c:44:76\n #5 0x0000ffff70c6bb3c gsignal /usr/src/debug/glibc-2.34-168.el9_6.23.aarch64/signal/../sysdeps/posix/raise.c:27:6\n #6 0x0000ffff70c58074 abort /usr/src/debug/glibc-2.34-168.el9_6.23.aarch64/stdlib/abort.c:81:7\n #7 0x0000ffff71a7694c (/path/to/build/lib/libLLVM.so.22.0git+0x9a194c)\n #8 0x0000ffff736ff774 llvm::LoopVectorizationPlanner::emitInvalidCostRemarks(llvm::OptimizationRemarkEmitter*) (/path/to/build/lib/libLLVM.so.22.0git+0x262a774)\n #9 0x0000ffff73708cf8 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/path/to/build/lib/libLLVM.so.22.0git+0x2633cf8)\n#10 0x0000ffff7370b27c llvm::LoopVectorizePass::runImpl(llvm::Function&) (/path/to/build/lib/libLLVM.so.22.0git+0x263627c)\n#11 0x0000ffff7370b80c llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/path/to/build/lib/libLLVM.so.22.0git+0x263680c)\n :\n#28 0x000000000081c2b0 _start (/path/to/build/bin/flang+0x81c2b0)\nflang-22: error: unable to execute command: Aborted (core dumped)\nflang-22: error: flang frontend command failed due to signal (use -v to see invocation)\nflang version 22.0.0git (https://github.com/llvm/llvm-project.git c8f5c602c897d2345c1cfd8d886c1325598dbdc6)\nTarget: aarch64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /path/to/build/bin\nBuild config: +assertions\n```\n\nThe input IR: https://godbolt.org/z/z1P6Wxj7d",
"author": "yus3710-fj",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "bababuck",
"body": "Don't see anyone working on this, will take a look."
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null | null |
98838
|
https://github.com/llvm/llvm-project/issues/98838
|
miscompilation
|
9ba9e480fa4ef1f37a2b6b51603ac8e446cca5ff
| 2024-07-14T21:26:59
|
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "beccecaacde405a3b50891c67594eccbcd1c8b08",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
14201,
14209
]
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::vectorizeTree"
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit beccecaacde405a3b50891c67594eccbcd1c8b08
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Mon Jul 15 07:03:22 2024 -0700
[SLP]Fix PR98838: do no replace condition of select-based logical op by poison.
If the reduction operation is a select-based logical op, the condition
should be replaced by the poison, better to replace by the non-poisoning
constant to prevent poison propagation in the vector code.
Fixes https://github.com/llvm/llvm-project/issues/98838
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 5c2fc0b9320e..74a16d3fbcad 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -14201,9 +14201,23 @@ Value *BoUpSLP::vectorizeTree(
for (Instruction *I : RemovedInsts) {
if (getTreeEntry(I)->Idx != 0)
continue;
+ SmallVector<SelectInst *> LogicalOpSelects;
I->replaceUsesWithIf(PoisonValue::get(I->getType()), [&](Use &U) {
+ // Do not replace condition of the logical op in form select <cond>.
+ bool IsPoisoningLogicalOp = isa<SelectInst>(U.getUser()) &&
+ (match(U.getUser(), m_LogicalAnd()) ||
+ match(U.getUser(), m_LogicalOr())) &&
+ U.getOperandNo() == 0;
+ if (IsPoisoningLogicalOp) {
+ LogicalOpSelects.push_back(cast<SelectInst>(U.getUser()));
+ return false;
+ }
return UserIgnoreList->contains(U.getUser());
});
+ // Replace conditions of the poisoning logical ops with the non-poison
+ // constant value.
+ for (SelectInst *SI : LogicalOpSelects)
+ SI->setCondition(Constant::getNullValue(SI->getCondition()->getType()));
}
}
// Retain to-be-deleted instructions for some debug-info bookkeeping and alias
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/select-reduction-op.ll",
"commands": [
"opt -S --passes=slp-vectorizer < %s"
],
"tests": [
{
"test_name": "src",
"test_body": "define i1 @src(i1 %cmp4.118.i) {\n %cmp4.118.i.not = xor i1 %cmp4.118.i, true\n %brmerge = select i1 %cmp4.118.i.not, i1 true, i1 poison\n %.not = xor i1 poison, true\n %brmerge2 = select i1 %brmerge, i1 true, i1 %.not\n %.not3 = xor i1 poison, true\n %brmerge4 = select i1 %brmerge2, i1 true, i1 %.not3\n %.not5 = xor i1 poison, true\n %brmerge6 = select i1 %brmerge4, i1 true, i1 %.not5\n %.not7 = xor i1 poison, true\n %brmerge8 = select i1 %brmerge6, i1 true, i1 %.not7\n ret i1 %brmerge8\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "wrong code at -O3 on x86_64-linux-gnu",
"body": "It appears to be a recent regression as it doesn't reproduce with 18.1.0 and earlier. \r\n\r\nCompiler Explorer: https://godbolt.org/z/fzsqjEPWW\r\n\r\n```\r\n[562] % clangtk -v\r\nclang version 19.0.0git (https://github.com/llvm/llvm-project.git 52139d8f9a4e3f595ca552393d62ba06b0bc082c)\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[563] % \r\n[563] % clangtk -O2 -w small.c\r\n[564] % ./a.out\r\n0\r\n[565] % clangtk -O3 -w small.c\r\n[566] % ./a.out\r\n[567] % \r\n[567] % cat small.c\r\nint printf(const char *, ...);\r\nint a, b, e, g;\r\nvolatile int c;\r\nstatic int d[1] = {1}, f;\r\nint h() {\r\n for (b = 0; b < 4; b++) {\r\n for (e = 0; e < 4; e++)\r\n while (b) {\r\n if (c > 0 && d[1])\r\n break;\r\n return f;\r\n }\r\n }\r\n return 0;\r\n}\r\nvoid i() {\r\n int *j[1];\r\n j[g] = &d[0];\r\n}\r\nint main() {\r\n h();\r\n printf(\"%d\\n\", a);\r\n return 0;\r\n}\r\n```\r\n\r\n",
"author": "zhendongsu",
"labels": [
"miscompilation",
"llvm:SLPVectorizer",
"confirmed"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Reproducer: https://alive2.llvm.org/ce/z/Whfr_a\r\n```\r\n; bin/opt -passes=slp-vectorizer -S test.ll\r\ndefine i1 @src(i1 %cmp4.118.i) {\r\n %cmp4.118.i.not = xor i1 %cmp4.118.i, true\r\n %brmerge = select i1 %cmp4.118.i.not, i1 true, i1 poison\r\n %.not = xor i1 poison, true\r\n %brmerge2 = select i1 %brmerge, i1 true, i1 %.not\r\n %.not3 = xor i1 poison, true\r\n %brmerge4 = select i1 %brmerge2, i1 true, i1 %.not3\r\n %.not5 = xor i1 poison, true\r\n %brmerge6 = select i1 %brmerge4, i1 true, i1 %.not5\r\n %.not7 = xor i1 poison, true\r\n %brmerge8 = select i1 %brmerge6, i1 true, i1 %.not7\r\n ret i1 %brmerge8\r\n}\r\n```\r\n```\r\ndefine i1 @tgt(i1 %cmp4.118.i) {\r\n %1 = insertelement <4 x i1> <i1 poison, i1 true, i1 true, i1 true>, i1 %cmp4.118.i, i32 0\r\n %2 = xor <4 x i1> %1, <i1 true, i1 poison, i1 poison, i1 poison>\r\n %.not7 = xor i1 poison, true\r\n %3 = freeze <4 x i1> %2\r\n %4 = call i1 @llvm.vector.reduce.or.v4i1(<4 x i1> %3)\r\n %op.rdx = select i1 %4, i1 true, i1 %.not7\r\n %op.rdx1 = select i1 poison, i1 true, i1 %op.rdx\r\n ret i1 %op.rdx1\r\n}\r\n```\r\ncc @alexey-bataev "
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
385118644ccabe27a634804c7db60734746c170f
| null |
87798
|
https://github.com/llvm/llvm-project/issues/87798
|
crash
|
49ef12a08c4c7d7ae4765929e72fe2320a12b08c
| 2024-04-05T16:02:46
|
[
"llvm/test/Analysis/ScalarEvolution"
] |
{
"fix_commit": "54a9f0007cb4f19d2e9df30405c5027229f5def0",
"components": [
"ScalarEvolution"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": [
[
928,
938
]
],
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": [
"BinomialCoefficient"
],
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 54a9f0007cb4f19d2e9df30405c5027229f5def0
Author: annamthomas <anna@azul.com>
Date: Wed Apr 10 09:02:23 2024 -0400
[SCEV] Fix BinomialCoefficient Iteration to fit in W bits (#88010)
BinomialCoefficient computes the value of W-bit IV at iteration It of a loop. When W is 1, we can call multiplicative inverse on 0 which triggers an assert since 1b76120.
Since the arithmetic is supposed to wrap if It or K does not fit in W bits, do the truncation into W bits after we do the shift.
Fixes #87798
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index e030b9fc7dac..9fcce797f559 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -928,11 +928,9 @@ static const SCEV *BinomialCoefficient(const SCEV *It, unsigned K,
APInt OddFactorial(W, 1);
unsigned T = 1;
for (unsigned i = 3; i <= K; ++i) {
- APInt Mult(W, i);
- unsigned TwoFactors = Mult.countr_zero();
+ unsigned TwoFactors = countr_zero(i);
T += TwoFactors;
- Mult.lshrInPlace(TwoFactors);
- OddFactorial *= Mult;
+ OddFactorial *= (i >> TwoFactors);
}
// We need at least W + T bits for the multiplication step
|
[
{
"file": "llvm/test/Analysis/ScalarEvolution/pr87798.ll",
"commands": [
"opt -disable-output -passes='print<scalar-evolution>' -verify-scev < %s 2>&1"
],
"tests": [
{
"test_name": "pr87798",
"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-ni:1-p2:32:8:8:32-ni:2\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i32 @pr87798() {\nbb:\n br label %bb1\n\nbb1: ; preds = %bb1, %bb\n %phi = phi i32 [ 0, %bb ], [ %add4, %bb1 ]\n %phi2 = phi i32 [ 0, %bb ], [ %add, %bb1 ]\n %phi3 = phi i32 [ 0, %bb ], [ %add5, %bb1 ]\n %add = add i32 %phi2, %phi3\n %mul = mul i32 %phi2, %phi3\n %add4 = add i32 %mul, %phi\n %and = and i32 %phi, 1\n %add5 = add i32 %phi3, 1\n br i1 true, label %preheader, label %bb1\n\npreheader: ; preds = %bb1\n %phi9 = phi i32 [ %and, %bb1 ]\n br label %loop\n\nloop: ; preds = %loop, %preheader\n br label %loop\n\nbb7: ; No predecessors!\n %zext = zext i32 %phi9 to i64\n ret i32 0\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "Assertion failure: \"multiplicative inverse is only defined for odd numbers\" exposed through usage in SCEV",
"body": "With this change [1b76120](https://github.com/llvm/llvm-project/commit/1b761205f2686516cebadbcbc37f798197d9c482) landed in https://github.com/llvm/llvm-project/pull/87610, we started seeing an assertion failure on the introduced API.\r\n\r\nThis change caused an assertion failure in usage of multiplicativeInverse in SCEV's BinomialCoefficient algorithm (which was also updated by the change to use this overloaded API). The `oddFactorial` in this algorithm becomes 0 and the assertion in newly introduced API gets triggered. Note that the old API for multiplicativeInverse (which passed in the explicit modulo) returned 0 when the input was also 0, and probably hid this bug in SCEV. \r\n\r\nHere's a minimal reproducer for trunk:\r\n```\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 i32 @\"static jint Test.iMeth(jlong, jint, jint)2272037699586\"() {\r\nbci_0:\r\n br label %bci_71.preheader\r\n\r\nbci_71.preheader: ; preds = %bci_71.preheader, %bci_0\r\n %local_9_242 = phi i32 [ 0, %bci_0 ], [ %1, %bci_71.preheader ]\r\n %local_7_241 = phi i32 [ 0, %bci_0 ], [ %0, %bci_71.preheader ]\r\n %local_4_239 = phi i32 [ 0, %bci_0 ], [ %3, %bci_71.preheader ]\r\n %0 = add i32 %local_7_241, %local_4_239\r\n %.neg14 = mul i32 %local_7_241, %local_4_239\r\n %1 = add i32 %.neg14, %local_9_242\r\n %2 = and i32 %local_9_242, 1\r\n %3 = add i32 %local_4_239, 1\r\n br i1 true, label %bci_10.i38.preheader, label %bci_71.preheader\r\n\r\nbci_10.i38: ; preds = %bci_10.i38.preheader, %bci_10.i38\r\n br label %bci_10.i38\r\n\r\n\"static jlong FuzzerUtils.checkSum(jobject)2306397437964.exit\": ; No predecessors!\r\n %4 = zext i32 %.lcssa596 to i64\r\n ret i32 0\r\n\r\nbci_10.i38.preheader: ; preds = %bci_71.preheader\r\n %.lcssa596 = phi i32 [ %2, %bci_71.preheader ]\r\n br label %bci_10.i38\r\n}\r\n```\r\n\r\nopt -passes=indvars reduced.ll produces:\r\n```\r\nopt: /root/llvm-project/llvm/lib/Support/APInt.cpp:1245: llvm::APInt llvm::APInt::multiplicativeInverse() const: Assertion `(*this)[0] && \"multiplicative inverse is only defined for odd numbers!\"' 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=indvars <source>\r\n #0 0x0000000004cfc568 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4cfc568)\r\n #1 0x0000000004cf9cbc SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007f7209e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x00007f7209e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x00007f7209e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x00007f7209e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00007f7209e2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x00007f7209e39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x0000000004bf9eff llvm::APInt::multiplicativeInverse() const (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4bf9eff)\r\n #9 0x000000000443a4b5 llvm::SCEVAddRecExpr::evaluateAtIteration(llvm::ArrayRef<llvm::SCEV const*>, llvm::SCEV const*, llvm::ScalarEvolution&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x443a4b5)\r\n#10 0x000000000443cb4f llvm::ScalarEvolution::computeSCEVAtScope(llvm::SCEV const*, llvm::Loop const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x443cb4f)\r\n#11 0x000000000443cfee llvm::ScalarEvolution::getSCEVAtScope(llvm::SCEV const*, llvm::Loop const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x443cfee)\r\n#12 0x000000000443c525 llvm::ScalarEvolution::computeSCEVAtScope(llvm::SCEV const*, llvm::Loop const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x443c525)\r\n#13 0x000000000443cfee llvm::ScalarEvolution::getSCEVAtScope(llvm::SCEV const*, llvm::Loop const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x443cfee)\r\n#14 0x000000000404eca0 llvm::rewriteLoopExitValues(llvm::Loop*, llvm::LoopInfo*, llvm::TargetLibraryInfo*, llvm::ScalarEvolution*, llvm::TargetTransformInfo const*, llvm::SCEVExpander&, llvm::DominatorTree*, llvm::ReplaceExitVal, llvm::SmallVector<llvm::WeakTrackingVH, 16u>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x404eca0)\r\n#15 0x0000000003a10fd8 (anonymous namespace)::IndVarSimplify::run(llvm::Loop*) IndVarSimplify.cpp:0:0\r\n#16 0x0000000003a11c1a llvm::IndVarSimplifyPass::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3a11c1a)\r\n#17 0x00000000029ffd4e llvm::detail::PassModel<llvm::Loop, llvm::IndVarSimplifyPass, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x29ffd4e)\r\n#18 0x0000000003aaef56 std::optional<llvm::PreservedAnalyses> llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::runSinglePass<llvm::Loop, std::unique_ptr<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, std::default_delete<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>>>>(llvm::Loop&, std::unique_ptr<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, std::default_delete<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>>>&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&, llvm::PassInstrumentation&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3aaef56)\r\n#19 0x0000000003aaf1ee llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::runWithoutLoopNestPasses(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3aaf1ee)\r\n#20 0x0000000003ab05d9 llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3ab05d9)\r\n...\r\n```",
"author": "annamthomas",
"labels": [
"llvm:SCEV",
"crash"
],
"comments": [
{
"author": "topperc",
"body": "CC @jayfoad "
},
{
"author": "annamthomas",
"body": "I think the old API (multiplicativeInverse when modulo provided) was hiding this bug since multiplicative inverse shouldn't be asked for 0.\r\nAlso, the reason the `oddFactorial` becomes 0 here is because of this:\r\n```\r\n// Calculate K! / 2^T and T; we divide out the factors of two before\r\n // multiplying for calculating K! / 2^T to avoid overflow.\r\n // Other overflow doesn't matter because we only care about the bottom\r\n // W bits of the result.\r\n APInt OddFactorial(W, 1);\r\n unsigned T = 1;\r\n for (unsigned i = 3; i <= K; ++i) {\r\n APInt Mult(W, i);\r\n unsigned TwoFactors = Mult.countr_zero();\r\n T += TwoFactors;\r\n Mult.lshrInPlace(TwoFactors);\r\n OddFactorial *= Mult; \r\n }\r\n ```\r\n\r\nHere, W is one (bit width = 1 and I believe this is the bug) and we are trying to represent Mult=4 in one bit. That makes `Mult` 0 and hence `OddFactorial` 0.\r\n\r\nOne thing we can obviously do is in the newly introduced API, explicitly check if the APInt is 0 and return 0 (this makes behaviour same as the old API).\r\nBut I think this is hiding the bug. "
},
{
"author": "jayfoad",
"body": "Suggestion:\r\n```diff\r\ndiff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp\r\nindex e030b9fc7dac..3f8c390614ff 100644\r\n--- a/llvm/lib/Analysis/ScalarEvolution.cpp\r\n+++ b/llvm/lib/Analysis/ScalarEvolution.cpp\r\n@@ -928,11 +928,9 @@ static const SCEV *BinomialCoefficient(const SCEV *It, unsigned K,\r\n APInt OddFactorial(W, 1);\r\n unsigned T = 1;\r\n for (unsigned i = 3; i <= K; ++i) {\r\n- APInt Mult(W, i);\r\n- unsigned TwoFactors = Mult.countr_zero();\r\n+ unsigned TwoFactors = countr_zero(i);\r\n T += TwoFactors;\r\n- Mult.lshrInPlace(TwoFactors);\r\n- OddFactorial *= Mult;\r\n+ OddFactorial *= i >> TwoFactors;\r\n }\r\n \r\n // We need at least W + T bits for the multiplication step\r\n```"
},
{
"author": "annamthomas",
"body": "yes, that would probably work as well (since we avoid representing Mult in W bit width), but how can the bitWidth of the SCEV result`W` be 1 in the first place? "
},
{
"author": "jayfoad",
"body": "> yes, that would probably work as well (since we avoid representing Mult in W bit width), but how can the bitWidth of the SCEV result`W` be 1 in the first place?\r\n\r\nNo idea! I have only looked at `BinomialCoefficient` itself, not at its callers. I assume it is supposed to work for any W > 0 and K > 0. At least I don't see it mentioned that K has to be representable in W bits, or anything like that."
},
{
"author": "efriedma-quic",
"body": "The function is supposed to compute `BC(It, K) mod 2^W`, i.e. the binomial coefficient truncated to fit into a W-bit integer. This is useful for computing the value of a W-bit induction variable at iteration \"It\" of a loop. There isn't any expectation that \"It\" or \"K\" fit losslessly into \"W\": the arithmetic is supposed to wrap.\r\n\r\nGiven the way the function works, truncating \"i\" after the shift looks like the right solution."
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
1b761205f2686516cebadbcbc37f798197d9c482
| null |
162374
|
https://github.com/llvm/llvm-project/issues/162374
|
crash
|
ab71b7793a0480f820c62c0bbc69e6c8e7434c2a
| 2025-10-07T21:25:00
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "4bf5ab4f9d483c6cefbbd8d04774cea5571dce45",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
[
8774,
8786
]
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
[
1026,
1031
],
[
1041,
1058
],
[
1098,
1104
],
[
2206,
2225
]
],
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": [
[
322,
328
]
],
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"LoopVectorizationPlanner::adjustRecipesForReductions"
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
"VPlanTransforms::truncateToMinimalBitwidths",
"simplifyRecipe"
],
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": [
"createScalarIVSteps",
"createWidenCast"
],
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 4bf5ab4f9d483c6cefbbd8d04774cea5571dce45
Author: Florian Hahn <flo@fhahn.com>
Date: Sun Oct 12 14:00:22 2025 +0100
[VPlan] Set flags when constructing truncs using VPWidenCastRecipe.
VPWidenCastRecipes with Trunc opcodes where missing the correct OpType
for IR flags. Update createWidenCast to set the correct flags for
truncs, and use it consistenly.
Fixes https://github.com/llvm/llvm-project/issues/162374.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h b/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
index 456fa4c85853..7651ba16b35c 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
@@ -322,7 +322,11 @@ public:
VPWidenCastRecipe *createWidenCast(Instruction::CastOps Opcode, VPValue *Op,
Type *ResultTy) {
- return tryInsertInstruction(new VPWidenCastRecipe(Opcode, Op, ResultTy));
+ VPIRFlags Flags;
+ if (Opcode == Instruction::Trunc)
+ Flags = VPIRFlags::TruncFlagsTy(false, false);
+ return tryInsertInstruction(
+ new VPWidenCastRecipe(Opcode, Op, ResultTy, Flags));
}
VPScalarIVStepsRecipe *
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 50136a8ecae5..b96d29e63546 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -8774,13 +8774,19 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
assert(!RecurrenceDescriptor::isMinMaxRecurrenceKind(RecurrenceKind) &&
"Unexpected truncated min-max recurrence!");
Type *RdxTy = RdxDesc.getRecurrenceType();
- auto *Trunc =
- new VPWidenCastRecipe(Instruction::Trunc, NewExitingVPV, RdxTy);
+ VPWidenCastRecipe *Trunc;
Instruction::CastOps ExtendOpc =
RdxDesc.isSigned() ? Instruction::SExt : Instruction::ZExt;
- auto *Extnd = new VPWidenCastRecipe(ExtendOpc, Trunc, PhiTy);
- Trunc->insertAfter(NewExitingVPV->getDefiningRecipe());
- Extnd->insertAfter(Trunc);
+ VPWidenCastRecipe *Extnd;
+ {
+ VPBuilder::InsertPointGuard Guard(Builder);
+ Builder.setInsertPoint(
+ NewExitingVPV->getDefiningRecipe()->getParent(),
+ std::next(NewExitingVPV->getDefiningRecipe()->getIterator()));
+ Trunc =
+ Builder.createWidenCast(Instruction::Trunc, NewExitingVPV, RdxTy);
+ Extnd = Builder.createWidenCast(ExtendOpc, Trunc, PhiTy);
+ }
if (PhiR->getOperand(1) == NewExitingVPV)
PhiR->setOperand(1, Extnd->getVPSingleValue());
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 7563cd719b19..9bb88205009c 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -1026,6 +1026,7 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
PredPHI->replaceAllUsesWith(Op);
}
+ VPBuilder Builder(Def);
VPValue *A;
if (match(Def, m_Trunc(m_ZExtOrSExt(m_VPValue(A))))) {
Type *TruncTy = TypeInfo.inferScalarType(Def);
@@ -1041,18 +1042,16 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
unsigned ExtOpcode = match(R.getOperand(0), m_SExt(m_VPValue()))
? Instruction::SExt
: Instruction::ZExt;
- auto *VPC =
- new VPWidenCastRecipe(Instruction::CastOps(ExtOpcode), A, TruncTy);
+ auto *Ext = Builder.createWidenCast(Instruction::CastOps(ExtOpcode), A,
+ TruncTy);
if (auto *UnderlyingExt = R.getOperand(0)->getUnderlyingValue()) {
// UnderlyingExt has distinct return type, used to retain legacy cost.
- VPC->setUnderlyingValue(UnderlyingExt);
+ Ext->setUnderlyingValue(UnderlyingExt);
}
- VPC->insertBefore(&R);
- Def->replaceAllUsesWith(VPC);
+ Def->replaceAllUsesWith(Ext);
} else if (ATy->getScalarSizeInBits() > TruncTy->getScalarSizeInBits()) {
- auto *VPC = new VPWidenCastRecipe(Instruction::Trunc, A, TruncTy);
- VPC->insertBefore(&R);
- Def->replaceAllUsesWith(VPC);
+ auto *Trunc = Builder.createWidenCast(Instruction::Trunc, A, TruncTy);
+ Def->replaceAllUsesWith(Trunc);
}
}
#ifndef NDEBUG
@@ -1098,7 +1097,6 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
return Def->replaceAllUsesWith(Def->getOperand(1));
// (x && y) || (x && z) -> x && (y || z)
- VPBuilder Builder(Def);
if (match(Def, m_c_BinaryOr(m_LogicalAnd(m_VPValue(X), m_VPValue(Y)),
m_LogicalAnd(m_Deferred(X), m_VPValue(Z)))) &&
// Simplify only if one of the operands has one use to avoid creating an
@@ -2206,20 +2204,20 @@ void VPlanTransforms::truncateToMinimalBitwidths(
continue;
assert(OpSizeInBits > NewResSizeInBits && "nothing to truncate");
auto [ProcessedIter, IterIsEmpty] = ProcessedTruncs.try_emplace(Op);
- VPWidenCastRecipe *NewOp =
- IterIsEmpty
- ? new VPWidenCastRecipe(Instruction::Trunc, Op, NewResTy,
- VPIRFlags::TruncFlagsTy(false, false))
- : ProcessedIter->second;
- R.setOperand(Idx, NewOp);
- if (!IterIsEmpty)
+ if (!IterIsEmpty) {
+ R.setOperand(Idx, ProcessedIter->second);
continue;
- ProcessedIter->second = NewOp;
- if (!Op->isLiveIn()) {
- NewOp->insertBefore(&R);
- } else {
- PH->appendRecipe(NewOp);
}
+
+ VPBuilder Builder;
+ if (Op->isLiveIn())
+ Builder.setInsertPoint(PH);
+ else
+ Builder.setInsertPoint(&R);
+ VPWidenCastRecipe *NewOp =
+ Builder.createWidenCast(Instruction::Trunc, Op, NewResTy);
+ ProcessedIter->second = NewOp;
+ R.setOperand(Idx, NewOp);
}
}
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/RISCV/truncate-to-minimal-bitwidth-evl-crash.ll",
"commands": [
"opt -passes=loop-vectorize -prefer-predicate-over-epilogue=predicate-else-scalar-epilogue -mtriple=riscv64 -mattr=+v -S %s"
],
"tests": [
{
"test_name": "truncate_i16_to_i8_cse",
"test_body": "define void @truncate_i16_to_i8_cse(ptr noalias %src, ptr noalias %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %count = phi i32 [ 0, %entry ], [ %count.next, %loop ]\n %val = load i16, ptr %src, align 2\n %val.zext = zext i16 %val to i64\n %val.trunc.zext = trunc i64 %val.zext to i8\n store i8 %val.trunc.zext, ptr null, align 1\n %val.trunc = trunc i16 %val to i8\n store i8 %val.trunc, ptr %dst, align 1\n %count.next = add i32 %count, 1\n %exitcond = icmp eq i32 %count.next, 0\n %iv.next = add i64 %iv, 1\n br i1 %exitcond, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[LoopVectorize] Assertion `OpType == Other.OpType && \"OpType must match\"' failed.",
"body": "Testcase:\n```llvm ir\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @init(ptr %arrayidx2.i, ptr %arrayidx13.i) #0 {\nentry:\n br label %for.body.i\n\nfor.body.i: ; preds = %for.body.i, %entry\n %indvars.iv.i1 = phi i64 [ 0, %entry ], [ %indvars.iv.next.i, %for.body.i ]\n %n.023.i = phi i32 [ 0, %entry ], [ %inc.i, %for.body.i ]\n %0 = load i16, ptr %arrayidx2.i, align 2\n %conv3.i = zext i16 %0 to i64\n %conv4.i = trunc i64 %conv3.i to i8\n store i8 %conv4.i, ptr null, align 1\n %conv11.i = trunc i16 %0 to i8\n store i8 %conv11.i, ptr %arrayidx13.i, align 1\n %inc.i = add i32 %n.023.i, 1\n %tobool.not.i = icmp eq i32 %inc.i, 0\n %indvars.iv.next.i = add i64 %indvars.iv.i1, 1\n br i1 %tobool.not.i, label %c.exit.loopexit, label %for.body.i\n\nc.exit.loopexit: ; preds = %for.body.i\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+v\" }\n```\n\nCommands/backtrace:\n```\n$ /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt --passes=loop-vectorize reduced.ll\nWARNING: You're attempting to print out a bitcode file.\nThis is inadvisable as it may cause display problems. If\nyou REALLY want to taste LLVM bitcode first-hand, you\ncan force output with the `-f' option.\n\nopt: /scratch/ewlu/daily-upstream-build/llvm/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp:404: void llvm::VPIRFlags::intersectFlags(const llvm::VPIRFlags&): Assertion `OpType == Other.OpType && \"OpType must match\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.\nStack dump:\n0. Program arguments: /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt --passes=loop-vectorize reduced.ll\n1. Running pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"reduced.ll\"\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"init\"\n #0 0x00005c399f7f0072 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x342a072)\n #1 0x00005c399f7ecd6f llvm::sys::RunSignalHandlers() (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x3426d6f)\n #2 0x00005c399f7ecebc SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #3 0x00007e76d1245330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)\n #4 0x00007e76d129eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #5 0x00007e76d129eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #6 0x00007e76d129eb2c pthread_kill ./nptl/pthread_kill.c:89:10\n #7 0x00007e76d124527e raise ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x00007e76d12288ff abort ./stdlib/abort.c:81:7\n #9 0x00007e76d122881b _nl_load_domain ./intl/loadmsgcat.c:1177:9\n#10 0x00007e76d123b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)\n#11 0x00005c399d5a1cbc (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x11dbcbc)\n#12 0x00005c399d5f4f66 llvm::VPlanTransforms::cse(llvm::VPlan&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x122ef66)\n#13 0x00005c399d3d02ef llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x100a2ef)\n#14 0x00005c399d3edb79 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x1027b79)\n#15 0x00005c399d3f00e1 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x102a0e1)\n#16 0x00005c399d3f06f6 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x102a6f6)\n#17 0x00005c399cc79fd5 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x8b3fd5)\n#18 0x00005c399f5c5cf5 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x31ffcf5)\n#19 0x00005c399cc7c805 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x8b6805)\n#20 0x00005c399f5c43f1 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x31fe3f1)\n#21 0x00005c399c905fb5 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x53ffb5)\n#22 0x00005c399f5c4bdd llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x31febdd)\n#23 0x00005c399c911eeb llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x54beeb)\n#24 0x00005c399c90418d optMain (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x53e18d)\n#25 0x00007e76d122a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3\n#26 0x00007e76d122a28b call_init ./csu/../csu/libc-start.c:128:20\n#27 0x00007e76d122a28b __libc_start_main ./csu/../csu/libc-start.c:347:5\n#28 0x00005c399c8fa0b5 _start (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x5340b5)\nAborted\n```\n\nGodbolt: https://godbolt.org/z/ns6hTYcbK\n\nFound via fuzzer (C program before reduction).",
"author": "ewlu",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true
|
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
|
c3e76b27709f93c9e945caa29dae596b581289e2
| null |
88849
|
https://github.com/llvm/llvm-project/issues/88849
|
crash
|
6b98ab95f0d36705b5a1fc1e755c992ba2329c89
| 2024-04-16T07:36:13
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "b8741cc185e89a95c9161218084f7c8b5578cf96",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": [
[
254,
259
]
],
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": [
"VPTransformState::get"
],
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit b8741cc185e89a95c9161218084f7c8b5578cf96
Author: Florian Hahn <flo@fhahn.com>
Date: Fri Jul 19 10:33:07 2024 +0100
[VPlan] Relax assertion retrieving a scalar from VPTransformState::get.
The current assertion VPTransformState::get when retrieving a single
scalar only does not account for cases where a def has multiple users,
some demanding all scalar lanes, some demanding only a single scalar.
For an example, see the modified test case. Relax the assertion by also
allowing requesting scalar lanes only when the Def doesn't have only its
first lane used.
Fixes https://github.com/llvm/llvm-project/issues/88849.
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index 83a035fb4df8..58de6256900f 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -254,6 +254,7 @@ Value *VPTransformState::get(VPValue *Def, const VPIteration &Instance) {
Value *VPTransformState::get(VPValue *Def, unsigned Part, bool NeedsScalar) {
if (NeedsScalar) {
assert((VF.isScalar() || Def->isLiveIn() || hasVectorValue(Def, Part) ||
+ !vputils::onlyFirstLaneUsed(Def) ||
(hasScalarValue(Def, VPIteration(Part, 0)) &&
Data.PerPartScalars[Def][Part].size() == 1)) &&
"Trying to access a single scalar per part but has multiple scalars "
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/SystemZ/scalar-steps-with-users-demanding-all-lanes-and-first-lane-only.ll",
"commands": [
"opt -p loop-vectorize -mtriple=s390x-unknown-linux -mcpu=z16 -S %s"
],
"tests": [
{
"test_name": "test_scalar_iv_steps_used_by_replicate_and_first_lane_only_vpinst",
"test_body": "target datalayout = \"E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64\"\n\n@src = external global [8 x i32], align 4\n\ndefine void @test_scalar_iv_steps_used_by_replicate_and_first_lane_only_vpinst(ptr noalias %dst, ptr noalias %src.1) {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %mul.iv = mul nsw i64 %iv, 4\n %gep.src.1 = getelementptr inbounds i8, ptr %src.1, i64 %mul.iv\n %l.1 = load i8, ptr %gep.src.1, align 1\n %c = icmp eq i8 %l.1, 0\n br i1 %c, label %then, label %loop.latch\n\nthen: ; preds = %loop.header\n %iv.or = or disjoint i64 %iv, 4\n %gep.src = getelementptr inbounds [8 x i32], ptr @src, i64 0, i64 %iv.or\n %l.2 = load i32, ptr %gep.src, align 4\n store i32 %l.2, ptr %dst, align 4\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n %iv.next = add nuw nsw i64 %iv, 1\n %ec = icmp eq i64 %iv.next, 4\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "LoopVectorizer asserts: Assertion `(VF.isScalar() || Def->isLiveIn() || (hasScalarValue(Def, VPIteration(Part, 0)) && Data.PerPartScalars[Def][Part].size() == 1)) && \"Trying to access a single scalar per part but has multiple scalars \" \"per part.",
"body": "[tc_crash35_aftercreduce.ll.tar.gz](https://github.com/llvm/llvm-project/files/14988465/tc_crash35_aftercreduce.ll.tar.gz)\r\n\r\nopt -mtriple=s390x-unknown-linux -mcpu=z16 -O3 tc_crash35_aftercreduce.ll -o /dev/null\r\n\r\nVPlan.cpp:253: llvm::Value* llvm::VPTransformState::get(llvm::VPValue*, unsigned int, bool): Assertion `(VF.isScalar() || Def->isLiveIn() || (hasScalarValue(Def, VPIteration(Part, 0)) && Data.PerPartScalars[Def][Part].size() == 1)) && \"Trying to access a single scalar per part but has multiple scalars \" \"per part.\"' failed.\r\n\r\n@fhahn ",
"author": "JonPsson1",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "fhahn",
"body": "Should be fixed now, sorry for the delay @JonPsson1 !"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
d9a685a9dd589486e882b722e513ee7b8c84870c
| null |
91127
|
https://github.com/llvm/llvm-project/issues/91127
|
miscompilation
|
30367cb5982dfdab2655401f020711311e7d78b9
| 2024-05-05T15:35:24
|
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "d3dad7a74be50d90754bf5c072e1a2330e92712c",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": [
[
1510,
1515
]
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": [
"InstCombinerImpl::foldICmpTruncWithTruncOrExt"
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit d3dad7a74be50d90754bf5c072e1a2330e92712c
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Mon May 6 16:30:07 2024 +0800
[InstCombine] Fix miscompilation caused by #90436 (#91133)
Proof: https://alive2.llvm.org/ce/z/iRnJ4i
Fixes https://github.com/llvm/llvm-project/issues/91127.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index c60a290ce72e..7092fb5e509b 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -1510,6 +1510,7 @@ InstCombinerImpl::foldICmpTruncWithTruncOrExt(ICmpInst &Cmp,
std::swap(X, Y);
Pred = Cmp.getSwappedPredicate(Pred);
}
+ YIsSExt = !(NoWrapFlags & TruncInst::NoUnsignedWrap);
}
// Try to match icmp (trunc nuw X), (zext Y)
else if (!Cmp.isSigned() &&
|
[
{
"file": "llvm/test/Transforms/InstCombine/icmp-of-trunc-ext.ll",
"commands": [
"opt -S -passes=instcombine < %s"
],
"tests": [
{
"test_name": "trunc_equality_both_sext",
"test_body": "define i1 @trunc_equality_both_sext(i32 %x, i8 %y) {\n %xt = trunc nuw nsw i32 %x to i16\n %ye = sext i8 %y to i16\n %c = icmp ne i16 %xt, %ye\n ret i1 %c\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "test_slt_nuw",
"test_body": "define i1 @test_slt_nuw(i32 %x, i16 %y) {\n %conv1 = trunc nuw nsw i32 %x to i8\n %conv2 = trunc nuw nsw i16 %y to i8\n %cond = icmp slt i8 %conv1, %conv2\n ret i1 %cond\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "test_slt",
"test_body": "define i1 @test_slt(i32 %x, i16 %y) {\n %conv1 = trunc nsw i32 %x to i8\n %conv2 = trunc nsw i16 %y to i8\n %cond = icmp slt i8 %conv1, %conv2\n ret i1 %cond\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "test_ult_nuw",
"test_body": "define i1 @test_ult_nuw(i32 %x, i16 %y) {\n %conv1 = trunc nuw nsw i32 %x to i8\n %conv2 = trunc nuw nsw i16 %y to i8\n %cond = icmp ult i8 %conv1, %conv2\n ret i1 %cond\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "test_ult",
"test_body": "define i1 @test_ult(i32 %x, i16 %y) {\n %conv1 = trunc nsw i32 %x to i8\n %conv2 = trunc nsw i16 %y to i8\n %cond = icmp ult i8 %conv1, %conv2\n ret i1 %cond\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "test_eq1",
"test_body": "define i1 @test_eq1(i32 %x, i16 %y) {\n %conv1 = trunc nsw i32 %x to i8\n %conv2 = trunc nsw i16 %y to i8\n %cond = icmp eq i8 %conv1, %conv2\n ret i1 %cond\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "test_eq2",
"test_body": "define i1 @test_eq2(i32 %x, i16 %y) {\n %conv1 = trunc nsw i32 %x to i8\n %conv2 = trunc nsw i16 %y to i8\n %cond = icmp eq i8 %conv2, %conv1\n ret i1 %cond\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[InstCombine] Miscompilation which converts `icmp eq (trunc nsw i64 X), (trunc nsw i32 Y)` into `icmp eq (zext i32 Y), X`",
"body": "Reduced test case: https://alive2.llvm.org/ce/z/MLgA5x\r\n```\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 i32 @src() {\r\nentry:\r\n br label %for.cond\r\n\r\nfor.cond: ; preds = %if.end, %entry\r\n %storemerge = phi i32 [ 3, %entry ], [ %dec, %if.end ]\r\n %h = phi i32 [ 1, %entry ], [ %hres, %if.end ]\r\n %e = phi i32 [ 0, %entry ], [ -1, %if.end ]\r\n %tobool.not = icmp eq i32 %storemerge, 0\r\n br i1 %tobool.not, label %for.end9, label %for.body\r\n\r\nfor.body: ; preds = %for.cond\r\n %cmp = icmp eq i32 %h, 5\r\n %conv1 = zext i1 %cmp to i64\r\n %conv2 = sext i32 %e to i64\r\n %cond.i = call i64 @llvm.umax.i64(i64 %conv1, i64 %conv2)\r\n %conv3 = trunc nsw i64 %cond.i to i16\r\n %conv4 = trunc nsw i32 %e to i16\r\n %sub.i = sub i16 %conv3, %conv4\r\n %tobool6.not = icmp eq i16 %sub.i, 0\r\n br i1 %tobool6.not, label %if.end, label %if.then\r\n\r\nif.then: ; preds = %for.body\r\n br label %if.end\r\n\r\nif.end: ; preds = %if.then, %for.body\r\n %hres = phi i32 [ 0, %if.then ], [ %h, %for.body ]\r\n %dec = add nsw i32 %storemerge, -1\r\n br label %for.cond\r\n\r\nfor.end9: ; preds = %for.cond\r\n ret i32 %h\r\n}\r\n\r\ndefine i32 @tgt() {\r\nentry:\r\n br label %for.cond\r\n\r\nfor.cond: ; preds = %if.end, %entry\r\n %storemerge = phi i32 [ 3, %entry ], [ %dec, %if.end ]\r\n %h = phi i32 [ 1, %entry ], [ %hres, %if.end ]\r\n %e = phi i32 [ 0, %entry ], [ -1, %if.end ]\r\n %tobool.not = icmp eq i32 %storemerge, 0\r\n br i1 %tobool.not, label %for.end9, label %for.body\r\n\r\nfor.body: ; preds = %for.cond\r\n %cmp = icmp eq i32 %h, 5\r\n %conv1 = zext i1 %cmp to i64\r\n %conv2 = sext i32 %e to i64\r\n %cond.i = call i64 @llvm.umax.i64(i64 %conv1, i64 %conv2)\r\n %0 = zext i32 %e to i64\r\n %tobool6.not = icmp eq i64 %cond.i, %0\r\n br i1 %tobool6.not, label %if.end, label %if.then\r\n\r\nif.then: ; preds = %for.body\r\n br label %if.end\r\n\r\nif.end: ; preds = %if.then, %for.body\r\n %hres = phi i32 [ 0, %if.then ], [ %h, %for.body ]\r\n %dec = add nsw i32 %storemerge, -1\r\n br label %for.cond\r\n\r\nfor.end9: ; preds = %for.cond\r\n ret i32 %h\r\n}\r\n```\r\n\r\nllvm version: de9b386f84b58ad0ffc12e221bc6d9161ca5b62d",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Reduced test case: https://alive2.llvm.org/ce/z/ndR8PQ\r\n```\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 i1 @src(i64 %x, i32 %y) {\r\n %conv1 = trunc nsw i64 %x to i16\r\n %conv2 = trunc nsw i32 %y to i16\r\n %cond = icmp eq i16 %conv1, %conv2\r\n ret i1 %cond\r\n}\r\n\r\ndefine i1 @tgt(i64 %x, i32 %y) {\r\n %1 = zext i32 %y to i64\r\n %cond = icmp eq i64 %1, %x\r\n ret i1 %cond\r\n}\r\n```\r\n\r\nIt should be caused by https://github.com/llvm/llvm-project/pull/90436.\r\n\r\nI will post a fix later. cc @nikic\r\n"
},
{
"author": "dtcxzyw",
"body": "POC without DataLayout:\r\n```\r\ndefine i1 @test_eq(i32 %x, i16 %y) {\r\n %conv1 = trunc nsw i32 %x to i8\r\n %conv2 = trunc nsw i16 %y to i8\r\n %cond = icmp eq i8 %conv1, %conv2\r\n ret i1 %cond\r\n}\r\n\r\ndefine i1 @test_ult(i32 %x, i16 %y) {\r\n %conv1 = trunc nsw i32 %x to i8\r\n %conv2 = trunc nsw i16 %y to i8\r\n %cond = icmp ult i8 %conv1, %conv2\r\n ret i1 %cond\r\n}\r\n\r\ndefine i1 @test_slt(i32 %x, i16 %y) {\r\n %conv1 = trunc nsw i32 %x to i8\r\n %conv2 = trunc nsw i16 %y to i8\r\n %cond = icmp slt i8 %conv1, %conv2\r\n ret i1 %cond\r\n}\r\n```"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
b0eeacb20379f6d80079793b8461f56c240e6570
| null |
131488
|
https://github.com/llvm/llvm-project/issues/131488
|
crash
|
c71318a9bf168d30bf3ccd59eaa826e93b283d4b
| 2025-03-16T03:37:21
|
[
"llvm/test/Transforms/GlobalOpt"
] |
{
"fix_commit": "cc052667b4b2f3bed12db68da876626e14f231f8",
"components": [
"GlobalOpt"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": [
[
2551,
2557
]
],
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": [
"OptimizeNonTrivialIFuncs"
],
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit cc052667b4b2f3bed12db68da876626e14f231f8
Author: Justin Riddell <arghnews@hotmail.co.uk>
Date: Wed Sep 10 03:32:52 2025 +0100
[GlobalOpt] Fix unreachable ifunc globalopt crash (#157332) (#157593)
Also fixes (#131488)
Unreachable case is triggering `Callees.empty()` assert. Since this was
[originally
](https://github.com/llvm/llvm-project/pull/87939/commits/02bd5a7013c558f1e5220fc89bafa68f40276549#diff-06aba0dac2a263dc14297a15655291d5506b760f54a736385bcf3208f83df843R2524)
a `continue` anyway, have applied that as a fix and added a test case.
Please let me know if there's a better way.
Not sure who/how to get folks to review, tagging a few people (apologies
if you're not the right person/this is the wrong way to do it, please
let me know what to do in future if so)
@labrinea @dtcxzyw @nikic @fhahn
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index d7edd1288309..f88d51f443bc 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -2551,7 +2551,8 @@ static bool OptimizeNonTrivialIFuncs(
}))
continue;
- assert(!Callees.empty() && "Expecting successful collection of versions");
+ if (Callees.empty())
+ continue;
LLVM_DEBUG(dbgs() << "Statically resolving calls to function "
<< Resolver->getName() << "\n");
|
[
{
"file": "llvm/test/Transforms/GlobalOpt/resolve-indirect-ifunc.ll",
"commands": [
"opt --passes=globalopt -o - -S < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine ptr @f1() {\n;\n unreachable\n}\n\n@i1 = ifunc void(), ptr @f1",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "clang-21 crashed with ifunc attribute at O2 and above. Assertion `!Callees.empty() && \"Expecting successful collection of versions\"' failed.",
"body": "clang-21 crashed with `ifunc` attribute at `O2` and above.\n\nCompiler explorer: https://godbolt.org/z/hbh1odEE6\n\n```\n$cat mutant.c\nvoid a() __attribute__((ifunc(\"resolve_do_it_right_at_runtime\")));\nvoid *resolve_do_it_right_at_runtime() {\n for (;;)\n a();\n}\n```\n\n```\n$clang-21 -O2 mutant.c\nclang: /root/llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp:2722: bool OptimizeNonTrivialIFuncs(llvm::Module&, llvm::function_ref<llvm::TargetTransformInfo&(llvm::Function&)>): Assertion `!Callees.empty() && \"Expecting successful collection of versions\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\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 <source>\n1.\t<eof> parser at end of file\n2.\tOptimizer\n3.\tRunning pass \"globalopt\" on module \"<source>\"\n #0 0x0000000003e828c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e828c8)\n #1 0x0000000003e80554 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e80554)\n #2 0x0000000003dc53e8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0\n #3 0x000071370b642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #4 0x000071370b6969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #5 0x000071370b642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #6 0x000071370b6287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #7 0x000071370b62871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #8 0x000071370b639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #9 0x00000000057199d2 OptimizeNonTrivialIFuncs(llvm::Module&, llvm::function_ref<llvm::TargetTransformInfo& (llvm::Function&)>) (.constprop.0) GlobalOpt.cpp:0:0\n#10 0x000000000572109e optimizeGlobalsInModule(llvm::Module&, llvm::DataLayout const&, llvm::function_ref<llvm::TargetLibraryInfo& (llvm::Function&)>, llvm::function_ref<llvm::TargetTransformInfo& (llvm::Function&)>, llvm::function_ref<llvm::BlockFrequencyInfo& (llvm::Function&)>, llvm::function_ref<llvm::DominatorTree& (llvm::Function&)>, llvm::function_ref<void (llvm::Function&)>, llvm::function_ref<void (llvm::Function&)>) (.constprop.0) GlobalOpt.cpp:0:0\n#11 0x0000000005721d5f llvm::GlobalOptPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5721d5f)\n#12 0x0000000005554c6e llvm::detail::PassModel<llvm::Module, llvm::GlobalOptPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5554c6e)\n#13 0x0000000003821f90 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3821f90)\n#14 0x0000000004134d24 (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#15 0x000000000413856b 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+0x413856b)\n#16 0x000000000483dd90 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x483dd90)\n#17 0x000000000649d5ec clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x649d5ec)\n#18 0x000000000483e198 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x483e198)\n#19 0x0000000004b0dc75 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4b0dc75)\n#20 0x0000000004a8fdbe clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4a8fdbe)\n#21 0x0000000004bfd99e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4bfd99e)\n#22 0x0000000000d4f95f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd4f95f)\n#23 0x0000000000d4711a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#24 0x00000000048866f9 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#25 0x0000000003dc5884 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dc5884)\n#26 0x0000000004886d0f 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#27 0x000000000484977d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x484977d)\n#28 0x000000000484a80e 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+0x484a80e)\n#29 0x0000000004851ee5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4851ee5)\n#30 0x0000000000d4c758 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd4c758)\n#31 0x0000000000c13f14 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc13f14)\n#32 0x000071370b629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#33 0x000071370b629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#34 0x0000000000d46bc5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd46bc5)\nclang: error: clang frontend command failed with exit code 134 (use -v to see invocation)\nCompiler returned: 134\n```",
"author": "iamanonymouscs",
"labels": [
"ipo",
"crash"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
831527a5ef63d24d056afc92509caf5ceb1d3682
| null |
122691
|
https://github.com/llvm/llvm-project/issues/122691
|
crash
|
26e13091ea5ac3a53d11b50265a506f88129d6ff
| 2025-01-13T11:28:13
|
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "092d6283838dea79670750b9415955c5f0cb5178",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
8091,
8096
],
[
17818,
17824
]
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::buildTree_rec",
"BoUpSLP::collectValuesToDemote"
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 092d6283838dea79670750b9415955c5f0cb5178
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Mon Jan 13 09:02:56 2025 -0800
[SLP]Check for div/rem instructions before extending with poisons
Need to check if the instructions can be safely extended with poison
before actually doing this to avoid incorrect transformations.
Fixes #122691
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index df46c69ff3ab..4b0ed5b30179 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -8091,6 +8091,13 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
NonUniqueValueVL.append(
PWSz - UniqueValues.size(),
PoisonValue::get(UniqueValues.front()->getType()));
+ // Check that extended with poisons operations are still valid for
+ // vectorization (div/rem are not allowed).
+ if (!getSameOpcode(NonUniqueValueVL, *TLI).valid()) {
+ LLVM_DEBUG(dbgs() << "SLP: Scalar used twice in bundle.\n");
+ newTreeEntry(VL, std::nullopt /*not vectorized*/, S, UserTreeIdx);
+ return false;
+ }
VL = NonUniqueValueVL;
}
return true;
@@ -17818,7 +17825,7 @@ bool BoUpSLP::collectValuesToDemote(
};
if (E.isGather() || !Visited.insert(&E).second ||
any_of(E.Scalars, [&](Value *V) {
- return all_of(V->users(), [&](User *U) {
+ return !isa<PoisonValue>(V) && all_of(V->users(), [&](User *U) {
return isa<InsertElementInst>(U) && !getTreeEntry(U);
});
}))
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/div-possibly-extended-with-poisons.ll",
"commands": [
"opt -S -O2 < %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\n@g_3 = internal unnamed_addr global i64 0\n@g_127 = external local_unnamed_addr global [3 x i32]\n@g_211 = external local_unnamed_addr global i32\n\ndefine i8 @func_125() {\nentry:\n %call42 = call ptr @func_178()\n ret i8 0\n}\n\ndefine ptr @func_178() {\nentry:\n %0 = load i32, ptr @g_211, align 4\n %tobool158.not = icmp eq i32 %0, 0\n br i1 %tobool158.not, label %for.inc434, label %for.cond166.preheader\n\nfor.cond166.preheader: ; preds = %entry\n br label %for.cond166\n\nfor.cond166: ; preds = %for.cond166.preheader, %for.cond166\n %1 = phi i64 [ %2, %for.cond166 ], [ poison, %for.cond166.preheader ]\n %2 = phi i64 [ %inc255, %for.cond166 ], [ 0, %for.cond166.preheader ]\n %cmp167 = icmp samesign ult i64 %2, 61\n %inc255 = add nuw nsw i64 %2, 1\n br i1 %cmp167, label %for.cond166, label %for.inc434.loopexit\n\nfor.inc434.loopexit: ; preds = %for.cond166\n %.lcssa = phi i64 [ %1, %for.cond166 ]\n store i64 %.lcssa, ptr @g_3, align 8\n br label %for.inc434\n\nfor.inc434: ; preds = %for.inc434.loopexit, %entry\n store i32 1, ptr @g_211, align 4\n %3 = load i64, ptr @g_3, align 8\n %conv.i = trunc nuw nsw i64 %3 to i32\n %4 = load i32, ptr @g_127, align 4\n %and.i = and i32 %4, %conv.i\n %cmp.i = icmp eq i32 %and.i, 0\n %conv8.i = sext i32 %and.i to i64\n %sext = shl i64 %3, 32\n %conv9.i = ashr exact i64 %sext, 32\n %g_211.promoted5 = load i32, ptr @g_211, align 4\n br label %for.body447\n\nfor.body447: ; preds = %for.inc434, %cleanup552\n %p_181.addr.08 = phi i64 [ -13, %for.inc434 ], [ %conv564, %cleanup552 ]\n %and14.i1.lcssa67 = phi i32 [ %g_211.promoted5, %for.inc434 ], [ %and14.i.lcssa, %cleanup552 ]\n br label %if.then489\n\nif.then489: ; preds = %for.body447, %safe_div_func_int64_t_s_s.exit\n %l_317.03 = phi i32 [ 2, %for.body447 ], [ %sub, %safe_div_func_int64_t_s_s.exit ]\n %and14.i12 = phi i32 [ %and14.i1.lcssa67, %for.body447 ], [ %and14.i, %safe_div_func_int64_t_s_s.exit ]\n br i1 %cmp.i, label %safe_div_func_int64_t_s_s.exit, label %lor.lhs.false.i\n\nlor.lhs.false.i: ; preds = %if.then489\n %div.i = sdiv i64 %conv8.i, %conv9.i\n %5 = trunc i64 %div.i to i16\n br label %safe_div_func_int64_t_s_s.exit\n\nsafe_div_func_int64_t_s_s.exit: ; preds = %lor.lhs.false.i, %if.then489\n %cond.i = phi i16 [ %5, %lor.lhs.false.i ], [ 0, %if.then489 ]\n %call12.i = tail call i16 @llvm.bswap.i16(i16 %cond.i)\n %conv13.i = zext i16 %call12.i to i32\n %and14.i = and i32 %and14.i12, %conv13.i\n %call26.i = load volatile ptr, ptr null, align 8\n %sub = add nsw i32 %l_317.03, -1\n %cmp482 = icmp sgt i32 %l_317.03, 0\n br i1 %cmp482, label %if.then489, label %cleanup552\n\ncleanup552: ; preds = %safe_div_func_int64_t_s_s.exit\n %and14.i.lcssa = phi i32 [ %and14.i, %safe_div_func_int64_t_s_s.exit ]\n %add.i = add nsw i64 %p_181.addr.08, 7\n %conv564 = and i64 %add.i, 255\n %6 = and i64 %p_181.addr.08, 255\n %cmp445.not = icmp eq i64 %6, 22\n br i1 %cmp445.not, label %for.end565, label %for.body447\n\nfor.end565: ; preds = %cleanup552\n %and14.i.lcssa.lcssa = phi i32 [ %and14.i.lcssa, %cleanup552 ]\n store i32 %conv.i, ptr getelementptr inbounds nuw (i8, ptr @g_127, i64 8), align 4\n store i32 %and14.i.lcssa.lcssa, ptr @g_211, align 4\n ret ptr null\n}\n\ndefine ptr @func_183(i64 %p_185) {\nentry:\n %call = call i64 @builtin_uaddl_overflow(i64 %p_185, i64 0)\n unreachable\n}\n\ndefine i64 @builtin_uaddl_overflow(i64 %x, i64 %y) {\nentry:\n %0 = call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %x, i64 %y)\n %1 = extractvalue { i64, i1 } %0, 1\n %conv = zext i1 %1 to i64\n ret i64 %conv\n}",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[SLPVectorizer] Assertion `isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"' failed.",
"body": "Reproducer: https://godbolt.org/z/68MKbnE4W\n```\n; bin/opt -O2 reduced.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@g_3 = internal unnamed_addr global i64 0\n@g_127 = external local_unnamed_addr global [3 x i32]\n@g_211 = external local_unnamed_addr global i32\n\ndefine i8 @func_125() {\nentry:\n %call42 = call ptr @func_178()\n ret i8 0\n}\n\ndefine ptr @func_178() {\nentry:\n %0 = load i32, ptr @g_211, align 4\n %tobool158.not = icmp eq i32 %0, 0\n br i1 %tobool158.not, label %for.inc434, label %for.cond166.preheader\n\nfor.cond166.preheader: ; preds = %entry\n br label %for.cond166\n\nfor.cond166: ; preds = %for.cond166.preheader, %for.cond166\n %1 = phi i64 [ %2, %for.cond166 ], [ poison, %for.cond166.preheader ]\n %2 = phi i64 [ %inc255, %for.cond166 ], [ 0, %for.cond166.preheader ]\n %cmp167 = icmp samesign ult i64 %2, 61\n %inc255 = add nuw nsw i64 %2, 1\n br i1 %cmp167, label %for.cond166, label %for.inc434.loopexit\n\nfor.inc434.loopexit: ; preds = %for.cond166\n %.lcssa = phi i64 [ %1, %for.cond166 ]\n store i64 %.lcssa, ptr @g_3, align 8\n br label %for.inc434\n\nfor.inc434: ; preds = %for.inc434.loopexit, %entry\n store i32 1, ptr @g_211, align 4\n %3 = load i64, ptr @g_3, align 8\n %conv.i = trunc nuw nsw i64 %3 to i32\n %4 = load i32, ptr @g_127, align 4\n %and.i = and i32 %4, %conv.i\n %cmp.i = icmp eq i32 %and.i, 0\n %conv8.i = sext i32 %and.i to i64\n %sext = shl i64 %3, 32\n %conv9.i = ashr exact i64 %sext, 32\n %g_211.promoted5 = load i32, ptr @g_211, align 4\n br label %for.body447\n\nfor.body447: ; preds = %for.inc434, %cleanup552\n %p_181.addr.08 = phi i64 [ -13, %for.inc434 ], [ %conv564, %cleanup552 ]\n %and14.i1.lcssa67 = phi i32 [ %g_211.promoted5, %for.inc434 ], [ %and14.i.lcssa, %cleanup552 ]\n br label %if.then489\n\nif.then489: ; preds = %for.body447, %safe_div_func_int64_t_s_s.exit\n %l_317.03 = phi i32 [ 2, %for.body447 ], [ %sub, %safe_div_func_int64_t_s_s.exit ]\n %and14.i12 = phi i32 [ %and14.i1.lcssa67, %for.body447 ], [ %and14.i, %safe_div_func_int64_t_s_s.exit ]\n br i1 %cmp.i, label %safe_div_func_int64_t_s_s.exit, label %lor.lhs.false.i\n\nlor.lhs.false.i: ; preds = %if.then489\n %div.i = sdiv i64 %conv8.i, %conv9.i\n %5 = trunc i64 %div.i to i16\n br label %safe_div_func_int64_t_s_s.exit\n\nsafe_div_func_int64_t_s_s.exit: ; preds = %lor.lhs.false.i, %if.then489\n %cond.i = phi i16 [ %5, %lor.lhs.false.i ], [ 0, %if.then489 ]\n %call12.i = tail call i16 @llvm.bswap.i16(i16 %cond.i)\n %conv13.i = zext i16 %call12.i to i32\n %and14.i = and i32 %and14.i12, %conv13.i\n %call26.i = load volatile ptr, ptr null, align 8\n %sub = add nsw i32 %l_317.03, -1\n %cmp482 = icmp sgt i32 %l_317.03, 0\n br i1 %cmp482, label %if.then489, label %cleanup552\n\ncleanup552: ; preds = %safe_div_func_int64_t_s_s.exit\n %and14.i.lcssa = phi i32 [ %and14.i, %safe_div_func_int64_t_s_s.exit ]\n %add.i = add nsw i64 %p_181.addr.08, 7\n %conv564 = and i64 %add.i, 255\n %6 = and i64 %p_181.addr.08, 255\n %cmp445.not = icmp eq i64 %6, 22\n br i1 %cmp445.not, label %for.end565, label %for.body447\n\nfor.end565: ; preds = %cleanup552\n %and14.i.lcssa.lcssa = phi i32 [ %and14.i.lcssa, %cleanup552 ]\n store i32 %conv.i, ptr getelementptr inbounds nuw (i8, ptr @g_127, i64 8), align 4\n store i32 %and14.i.lcssa.lcssa, ptr @g_211, align 4\n ret ptr null\n}\n\ndefine ptr @func_183(i64 %p_185) {\nentry:\n %call = call i64 @builtin_uaddl_overflow(i64 %p_185, i64 0)\n unreachable\n}\n\ndefine i64 @builtin_uaddl_overflow(i64 %x, i64 %y) {\nentry:\n %0 = call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %x, i64 %y)\n %1 = extractvalue { i64, i1 } %0, 1\n %conv = zext i1 %1 to i64\n ret i64 %conv\n}\n```\n```\nopt: /root/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From*) [with To = llvm::Instruction; From = llvm::Value]: Assertion `isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"' failed.\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 -O2 <source>\n1.\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>\"\n2.\tRunning pass \"slp-vectorizer\" on function \"func_125\"\n #0 0x00000000052803a8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x52803a8)\n #1 0x000000000527ddac SignalHandler(int) Signals.cpp:0:0\n #2 0x0000776446c42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x0000776446c969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x0000776446c42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x0000776446c287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x0000776446c2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x0000776446c39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x0000000000b6a41a (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xb6a41a)\n #9 0x0000000004253c98 llvm::slpvectorizer::BoUpSLP::collectValuesToDemote(llvm::slpvectorizer::BoUpSLP::TreeEntry const&, bool, unsigned int&, llvm::SmallVectorImpl<unsigned int>&, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, void>>&, llvm::SmallDenseSet<unsigned int, 8u, llvm::DenseMapInfo<unsigned int, void>> const&, unsigned int&, bool&, bool) const::'lambda10'(unsigned int, unsigned int)::operator()(unsigned int, unsigned int) const::'lambda'(llvm::Value*)::operator()(llvm::Value*) const SLPVectorizer.cpp:0:0\n#10 0x0000000004253f67 bool llvm::function_ref<bool (unsigned int, unsigned int)>::callback_fn<llvm::slpvectorizer::BoUpSLP::collectValuesToDemote(llvm::slpvectorizer::BoUpSLP::TreeEntry const&, bool, unsigned int&, llvm::SmallVectorImpl<unsigned int>&, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, void>>&, llvm::SmallDenseSet<unsigned int, 8u, llvm::DenseMapInfo<unsigned int, void>> const&, unsigned int&, bool&, bool) const::'lambda10'(unsigned int, unsigned int)>(long, unsigned int, unsigned int) SLPVectorizer.cpp:0:0\n#11 0x00000000042e2312 llvm::slpvectorizer::BoUpSLP::collectValuesToDemote(llvm::slpvectorizer::BoUpSLP::TreeEntry const&, bool, unsigned int&, llvm::SmallVectorImpl<unsigned int>&, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, void>>&, llvm::SmallDenseSet<unsigned int, 8u, llvm::DenseMapInfo<unsigned int, void>> const&, unsigned int&, bool&, bool) const::'lambda6'(unsigned int&, llvm::ArrayRef<llvm::slpvectorizer::BoUpSLP::TreeEntry const*>, llvm::function_ref<bool (unsigned int, unsigned int)>)::operator()(unsigned int&, llvm::ArrayRef<llvm::slpvectorizer::BoUpSLP::TreeEntry const*>, llvm::function_ref<bool (unsigned int, unsigned int)>) const SLPVectorizer.cpp:0:0\n#12 0x00000000042deacb llvm::slpvectorizer::BoUpSLP::collectValuesToDemote(llvm::slpvectorizer::BoUpSLP::TreeEntry const&, bool, unsigned int&, llvm::SmallVectorImpl<unsigned int>&, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, void>>&, llvm::SmallDenseSet<unsigned int, 8u, llvm::DenseMapInfo<unsigned int, void>> const&, unsigned int&, bool&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x42deacb)\n#13 0x00000000042df8a0 llvm::slpvectorizer::BoUpSLP::computeMinimumValueSizes()::'lambda0'(llvm::slpvectorizer::BoUpSLP::TreeEntry const&, bool, bool, unsigned int, unsigned int, bool, bool)::operator()(llvm::slpvectorizer::BoUpSLP::TreeEntry const&, bool, bool, unsigned int, unsigned int, bool, bool) const SLPVectorizer.cpp:0:0\n#14 0x00000000042e03d0 llvm::slpvectorizer::BoUpSLP::computeMinimumValueSizes() (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x42e03d0)\n#15 0x000000000431e02d (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&, llvm::AssumptionCache*) SLPVectorizer.cpp:0:0\n#16 0x000000000432015d llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x432015d)\n#17 0x000000000432494b llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (.constprop.0) SLPVectorizer.cpp:0:0\n#18 0x000000000432904f llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x432904f)\n#19 0x000000000432fa86 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\n#20 0x00000000043305bb llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43305bb)\n#21 0x0000000003036f1e 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+0x3036f1e)\n#22 0x000000000507d7f0 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x507d7f0)\n#23 0x0000000000e7023e 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+0xe7023e)\n#24 0x000000000507c10b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x507c10b)\n#25 0x0000000000e6f8ce 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+0xe6f8ce)\n#26 0x000000000507bb10 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x507bb10)\n#27 0x000000000094448a 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+0x94448a)\n#28 0x0000000000936a29 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x936a29)\n#29 0x0000776446c29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#30 0x0000776446c29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#31 0x000000000092e305 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x92e305)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```\n\nllvm version: 7e01a322f850e86be9eefde8ae5a30e532d22cfa\nI am working to provide a single-pass reproducer.\n",
"author": "dtcxzyw",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Missing poison check: https://github.com/llvm/llvm-project/blob/6c5941b09fca487efc5000c82bbce6054bf36a7c/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp#L18000\n"
},
{
"author": "dtcxzyw",
"body": "> I am working to provide a single-pass reproducer.\n\nIt is weird that the single-pass reproducer doesn't work even with `--preserve-ll-uselistorder`.\n"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
|
Cannot find a good commit
| 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/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
1143,
1151
]
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"addMask"
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 57bbdbd7ae3698a274edd4dd6ef1b53d9129e552
Author: Alexey Bataev <a.bataev@outlook.com>
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
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
b8703369daf777706196ff914c0376c27adde3cf
| null |
137196
|
https://github.com/llvm/llvm-project/issues/137196
|
miscompilation
|
be7cf63b4a402ebc5b1dacc6579a693c92e1328e
| 2025-04-24T15:32:53
|
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "1f69d6354a4b088bda5ee62c31411a75eead8b0c",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": [
[
1959,
1967
],
[
1985,
1991
],
[
2013,
2025
]
],
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": [
"InstCombinerImpl::SimplifyDemandedUseFPClass",
"getFPClassConstant"
],
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 1f69d6354a4b088bda5ee62c31411a75eead8b0c
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Mon Apr 28 17:01:43 2025 +0800
[InstCombine] Preserve the sign bit of NaN in `SimplifyDemandedUseFPClass` (#137287)
Alive2: https://alive2.llvm.org/ce/z/uiUzEf
Closes https://github.com/llvm/llvm-project/issues/137196.
Note: To avoid regression in
`ret_nofpclass_nopositives_copysign_nnan_flag`, the second commit takes
FMF into account.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index 2c8939b5a051..a48854a191ca 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -1959,9 +1959,11 @@ static Constant *getFPClassConstant(Type *Ty, FPClassTest Mask) {
}
}
-Value *InstCombinerImpl::SimplifyDemandedUseFPClass(
- Value *V, const FPClassTest DemandedMask, KnownFPClass &Known,
- unsigned Depth, Instruction *CxtI) {
+Value *InstCombinerImpl::SimplifyDemandedUseFPClass(Value *V,
+ FPClassTest DemandedMask,
+ KnownFPClass &Known,
+ unsigned Depth,
+ Instruction *CxtI) {
assert(Depth <= MaxAnalysisRecursionDepth && "Limit Search Depth");
Type *VTy = V->getType();
@@ -1985,7 +1987,12 @@ Value *InstCombinerImpl::SimplifyDemandedUseFPClass(
if (!I->hasOneUse())
return nullptr;
- // TODO: Should account for nofpclass/FastMathFlags on current instruction
+ if (auto *FPOp = dyn_cast<FPMathOperator>(I)) {
+ if (FPOp->hasNoNaNs())
+ DemandedMask &= ~fcNan;
+ if (FPOp->hasNoInfs())
+ DemandedMask &= ~fcInf;
+ }
switch (I->getOpcode()) {
case Instruction::FNeg: {
if (SimplifyDemandedFPClass(I, 0, llvm::fneg(DemandedMask), Known,
@@ -2013,13 +2020,13 @@ Value *InstCombinerImpl::SimplifyDemandedUseFPClass(
if (SimplifyDemandedFPClass(I, 0, DemandedMaskAnySign, Known, Depth + 1))
return I;
- if ((DemandedMask & fcPositive) == fcNone) {
+ if ((DemandedMask & fcNegative) == DemandedMask) {
// Roundabout way of replacing with fneg(fabs)
I->setOperand(1, ConstantFP::get(VTy, -1.0));
return I;
}
- if ((DemandedMask & fcNegative) == fcNone) {
+ if ((DemandedMask & fcPositive) == DemandedMask) {
// Roundabout way of replacing with fabs
I->setOperand(1, ConstantFP::getZero(VTy));
return I;
|
[
{
"file": "llvm/test/Transforms/InstCombine/simplify-demanded-fpclass.ll",
"commands": [
"opt -S -passes=instcombine < %s"
],
"tests": [
{
"test_name": "ret_nofpclass_nopositives_copysign",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.copysign.f32(float, float) #0\n\ndefine nofpclass(pinf pzero psub pnorm) float @ret_nofpclass_nopositives_copysign(float %x, float %unknown.sign) {\n %copysign = call float @llvm.copysign.f32(float %x, float %unknown.sign)\n ret float %copysign\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "ret_nofpclass_no_negatives__copysign_unknown_select_pinf_rhs",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.copysign.f32(float, float) #0\n\ndefine nofpclass(ninf nzero nsub nnorm) float @ret_nofpclass_no_negatives__copysign_unknown_select_pinf_rhs(i1 %cond, float %x, float %unknown.sign) {\n %select = select i1 %cond, float %x, float 0x7FF0000000000000\n %copysign = call float @llvm.copysign.f32(float %select, float %unknown.sign)\n ret float %copysign\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "ret_nofpclass_nonegatives_copysign",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.copysign.f32(float, float) #0\n\ndefine nofpclass(ninf nzero nsub nnorm) float @ret_nofpclass_nonegatives_copysign(float %x, float %unknown.sign) {\n %copysign = call float @llvm.copysign.f32(float %x, float %unknown.sign)\n ret float %copysign\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "ret_nofpclass_no_negatives_noinf__copysign_unknown_select_pinf_rhs",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.copysign.f32(float, float) #0\n\ndefine nofpclass(inf nzero nsub nnorm) float @ret_nofpclass_no_negatives_noinf__copysign_unknown_select_pinf_rhs(i1 %cond, float %x, float %unknown.sign) {\n %select = select i1 %cond, float %x, float 0x7FF0000000000000\n %copysign = call float @llvm.copysign.f32(float %select, float %unknown.sign)\n ret float %copysign\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "ret_nofpclass_no_positives_noinf__copysign_unknown_select_pinf_rhs",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.copysign.f32(float, float) #0\n\ndefine nofpclass(inf pzero psub pnorm) float @ret_nofpclass_no_positives_noinf__copysign_unknown_select_pinf_rhs(i1 %cond, float %x, float %unknown.sign) {\n %select = select i1 %cond, float %x, float 0x7FF0000000000000\n %copysign = call float @llvm.copysign.f32(float %select, float %unknown.sign)\n ret float %copysign\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "ret_nofpclass_nopositives_nonan_copysign",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.copysign.f32(float, float) #0\n\ndefine nofpclass(nan pinf pzero psub pnorm) float @ret_nofpclass_nopositives_nonan_copysign(float %x, float %unknown.sign) {\n %copysign = call float @llvm.copysign.f32(float %x, float %unknown.sign)\n ret float %copysign\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "ret_nofpclass_no_positives__copysign_unknown_select_pinf_rhs",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.copysign.f32(float, float) #0\n\ndefine nofpclass(pinf pzero psub pnorm) float @ret_nofpclass_no_positives__copysign_unknown_select_pinf_rhs(i1 %cond, float %x, float %unknown.sign) {\n %select = select i1 %cond, float %x, float 0x7FF0000000000000\n %copysign = call float @llvm.copysign.f32(float %select, float %unknown.sign)\n ret float %copysign\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "ret_nofpclass_nopositive_finites_copysign_nnan_ninf_flag",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.copysign.f32(float, float) #0\n\ndefine nofpclass(pzero psub pnorm) float @ret_nofpclass_nopositive_finites_copysign_nnan_ninf_flag(float %x, float %unknown.sign) {\n %copysign = call nnan ninf float @llvm.copysign.f32(float %x, float %unknown.sign)\n ret float %copysign\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "copysign not preserving sign bit of a NaN",
"body": "we're optimizing this:\n```llvm\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.copysign.f32(float, float) #0\n\ndefine nofpclass(ninf nzero nsub nnorm) float @f(float %0) {\n %2 = call float @llvm.copysign.f32(float 0x7FF8000000000000, float %0)\n ret float %2\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n```\n\nto:\n```llvm\n; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)\ndefine noundef nofpclass(ninf nzero nsub nnorm) float @f(float %0) local_unnamed_addr #0 {\n ret float 0x7FF8000000000000\n}\n\nattributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }\n```\n\nAlive complains that the optimized code will flip the sign bit of a NaN, while the unoptimized code preserved it as required by LangRef's specification of the copysign semantics:\n> The returned value is completely identical to the first operand except for the sign bit; in particular, if the input is a NaN, then the quiet/signaling bit and payload are perfectly preserved.\n\nIf any of the individual flags in `nofpclass(ninf nzero nsub nnorm)` are removed, then we don't do this transformation. Am I missing something here where these flags, together, mean that it's legal to flip the sign of a NaN? Obviously the transformation is just fine when `nofpclass(nan)` is there\n\nhttps://alive2.llvm.org/ce/z/ja96Yf\n\ncc @dtcxzyw @nunoplopes ",
"author": "regehr",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
|
9dd2c59312bfae3526cee5e836a6b67b2e9b4989
| null |
121110
|
https://github.com/llvm/llvm-project/issues/121110
|
miscompilation
|
f68dbbbd57dd0947730300d1e827ad16c2dfffb5
| 2024-12-25T13:57:11
|
[
"llvm/test/Transforms/VectorCombine"
] |
{
"fix_commit": "f2f02b21cd581057e3c9b4a7a27e0014eeb9ba15",
"components": [
"VectorCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [
[
1669,
1675
],
[
1677,
1684
],
[
1727,
1740
],
[
1750,
1759
]
],
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [
"VectorCombine::foldShuffleOfBinops"
],
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit f2f02b21cd581057e3c9b4a7a27e0014eeb9ba15
Author: Simon Pilgrim <llvm-dev@redking.me.uk>
Date: Sat Dec 28 09:21:22 2024 +0000
[VectorCombine] foldShuffleOfBinops - only accept exact matching cmp predicates
m_SpecificCmp allowed equivalent predicate+flags which don't necessarily work after being folded from "shuffle (cmpop), (cmpop)" into "cmpop (shuffle), (shuffle)"
Fixes #121110
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index ecbc13d489eb..2460ccc61d84 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -1669,7 +1669,8 @@ bool VectorCombine::foldShuffleOfBinops(Instruction &I) {
Value *X, *Y, *Z, *W;
bool IsCommutative = false;
- CmpPredicate Pred = CmpInst::BAD_ICMP_PREDICATE;
+ CmpPredicate PredLHS = CmpInst::BAD_ICMP_PREDICATE;
+ CmpPredicate PredRHS = CmpInst::BAD_ICMP_PREDICATE;
if (match(LHS, m_BinOp(m_Value(X), m_Value(Y))) &&
match(RHS, m_BinOp(m_Value(Z), m_Value(W)))) {
auto *BO = cast<BinaryOperator>(LHS);
@@ -1677,8 +1678,9 @@ bool VectorCombine::foldShuffleOfBinops(Instruction &I) {
if (llvm::is_contained(OldMask, PoisonMaskElem) && BO->isIntDivRem())
return false;
IsCommutative = BinaryOperator::isCommutative(BO->getOpcode());
- } else if (match(LHS, m_Cmp(Pred, m_Value(X), m_Value(Y))) &&
- match(RHS, m_SpecificCmp(Pred, m_Value(Z), m_Value(W)))) {
+ } else if (match(LHS, m_Cmp(PredLHS, m_Value(X), m_Value(Y))) &&
+ match(RHS, m_Cmp(PredRHS, m_Value(Z), m_Value(W))) &&
+ (CmpInst::Predicate)PredLHS == (CmpInst::Predicate)PredRHS) {
IsCommutative = cast<CmpInst>(LHS)->isCommutative();
} else
return false;
@@ -1727,14 +1729,14 @@ bool VectorCombine::foldShuffleOfBinops(Instruction &I) {
TTI.getShuffleCost(SK0, BinOpTy, NewMask0, CostKind, 0, nullptr, {X, Z}) +
TTI.getShuffleCost(SK1, BinOpTy, NewMask1, CostKind, 0, nullptr, {Y, W});
- if (Pred == CmpInst::BAD_ICMP_PREDICATE) {
+ if (PredLHS == CmpInst::BAD_ICMP_PREDICATE) {
NewCost +=
TTI.getArithmeticInstrCost(LHS->getOpcode(), ShuffleDstTy, CostKind);
} else {
auto *ShuffleCmpTy =
FixedVectorType::get(BinOpTy->getElementType(), ShuffleDstTy);
NewCost += TTI.getCmpSelInstrCost(LHS->getOpcode(), ShuffleCmpTy,
- ShuffleDstTy, Pred, CostKind);
+ ShuffleDstTy, PredLHS, CostKind);
}
LLVM_DEBUG(dbgs() << "Found a shuffle feeding two binops: " << I
@@ -1750,10 +1752,10 @@ bool VectorCombine::foldShuffleOfBinops(Instruction &I) {
Value *Shuf0 = Builder.CreateShuffleVector(X, Z, NewMask0);
Value *Shuf1 = Builder.CreateShuffleVector(Y, W, NewMask1);
- Value *NewBO = Pred == CmpInst::BAD_ICMP_PREDICATE
+ Value *NewBO = PredLHS == CmpInst::BAD_ICMP_PREDICATE
? Builder.CreateBinOp(
cast<BinaryOperator>(LHS)->getOpcode(), Shuf0, Shuf1)
- : Builder.CreateCmp(Pred, Shuf0, Shuf1);
+ : Builder.CreateCmp(PredLHS, Shuf0, Shuf1);
// Intersect flags from the old binops.
if (auto *NewInst = dyn_cast<Instruction>(NewBO)) {
|
[
{
"file": "llvm/test/Transforms/VectorCombine/X86/shuffle-of-cmps.ll",
"commands": [
"opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=sse2",
"opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=sse4.2",
"opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=avx2",
"opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=avx512vl"
],
"tests": [
{
"test_name": "shuf_icmp_ugt_v4i32_use",
"test_body": "declare void @use(<4 x i1>)\n\ndefine <4 x i32> @shuf_icmp_ugt_v4i32_use(<4 x i32> %x, <4 x i32> %y, <4 x i32> %z, <4 x i32> %w) {\n %c0 = icmp ugt <4 x i32> %x, %y\n %c1 = icmp ugt <4 x i32> %z, %w\n call void @use(<4 x i1> %c0)\n %s = shufflevector <4 x i1> %c0, <4 x i1> %c1, <4 x i32> <i32 1, i32 3, i32 5, i32 7>\n %r = sext <4 x i1> %s to <4 x i32>\n ret <4 x i32> %r\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "PR121110",
"test_body": "define <2 x i1> @PR121110() {\n %ugt = icmp samesign ugt <2 x i32> zeroinitializer, zeroinitializer\n %sgt = icmp sgt <2 x i32> zeroinitializer, <i32 6, i32 -4>\n %res = shufflevector <2 x i1> %ugt, <2 x i1> %sgt, <2 x i32> <i32 0, i32 3>\n ret <2 x i1> %res\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[clang] Miscompilation at -Os",
"body": "This code prints 9 at `-Os` and 0 at `-O0/1/2/3`:\n\n```c\nint printf(const char *, ...);\nchar a = 9, c, d;\nint b, e;\nunsigned short f;\nchar *g = &a;\nvoid h(int i) {\n for (; b; b++)\n c &= 0 <= i;\n}\nstatic short j(unsigned long i) {\n int k;\n for (; e + d + 4 > 0;) {\n k = i + 49;\n h(k + i - 52 + i);\n *g = 0;\n return 0;\n }\n return 0;\n}\nint main() {\n j(6 < (unsigned short)(f - 7) + f);\n printf(\"%d\\n\", a);\n}\n```\n\nCompiler Explorer: https://godbolt.org/z/Mo5TEKh8r\n\nBisected to https://github.com/llvm/llvm-project/commit/5287299f8809ae927a0acafb179c4b37ce9ff21d, which was committed by @RKSimon ",
"author": "cardigan1008",
"labels": [
"miscompilation",
"vectorizers"
],
"comments": [
{
"author": "RKSimon",
"body": "I'm not convinced the patch is responsible, it's more likely exposed something else. I'll take a look after the Christmas break."
},
{
"author": "dtcxzyw",
"body": "Reproducer: https://alive2.llvm.org/ce/z/jdkwFh\n```\n; bin/opt -passes=vector-combine test.ll -S\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine <2 x i1> @src() {\nentry:\n %0 = icmp samesign ugt <2 x i32> zeroinitializer, zeroinitializer\n %1 = icmp sgt <2 x i32> zeroinitializer, <i32 6, i32 -4>\n %2 = shufflevector <2 x i1> %0, <2 x i1> %1, <2 x i32> <i32 0, i32 3>\n ret <2 x i1> %2\n}\n```\n```\ndefine <2 x i1> @tgt() {\nentry:\n ret <2 x i1> zeroinitializer\n}\n```\n```\n\n----------------------------------------\ndefine <2 x i1> @src() {\nentry:\n %#0 = icmp samesign ugt <2 x i32> { 0, 0 }, { 0, 0 }\n %#1 = icmp sgt <2 x i32> { 0, 0 }, { 6, 4294967292 }\n %#2 = shufflevector <2 x i1> %#0, <2 x i1> %#1, 0, 3\n ret <2 x i1> %#2\n}\n=>\ndefine <2 x i1> @tgt() {\nentry:\n ret <2 x i1> { 0, 0 }\n}\nTransformation doesn't verify!\n\nERROR: Value mismatch\n\nExample:\n\nSource:\n<2 x i1> %#0 = < #x0 (0), #x0 (0) >\n<2 x i1> %#1 = < #x0 (0), #x1 (1) >\n<2 x i1> %#2 = < #x0 (0), #x1 (1) >\n\nTarget:\nSource value: < #x0 (0), #x1 (1) >\nTarget value: < #x0 (0), #x0 (0) >\n```\n"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
8217c2eaef2f93427735a45c45c7fd91178e2ed8
| null |
113794
|
https://github.com/llvm/llvm-project/issues/113794
|
crash
|
21895a84cf466f0a0632cfca0175f7e617a6dd5a
| 2024-10-27T05:55:32
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "17bad1a9da228ade0c0b9b020ee99769b188d9b3",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
[
6389,
6397
]
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"LoopVectorizationCostModel::getInstructionCost",
"LoopVectorizationCostModel::shouldConsiderInvariant"
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 17bad1a9da228ade0c0b9b020ee99769b188d9b3
Author: Florian Hahn <flo@fhahn.com>
Date: Fri Nov 1 20:51:25 2024 +0000
[LV] Bail out on header phis in shouldConsiderInvariant.
This fixes an infinite recursion in rare cases.
Fixes https://github.com/llvm/llvm-project/issues/113794.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 659b4c30a58a..1c64bd2982d7 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -6389,9 +6389,11 @@ bool LoopVectorizationCostModel::shouldConsiderInvariant(Value *Op) {
return false;
// Consider Op invariant, if it or its operands aren't predicated
// instruction in the loop. In that case, it is not trivially hoistable.
- return !isa<Instruction>(Op) || !TheLoop->contains(cast<Instruction>(Op)) ||
- (!isPredicatedInst(cast<Instruction>(Op)) &&
- all_of(cast<Instruction>(Op)->operands(),
+ auto *OpI = dyn_cast<Instruction>(Op);
+ return !OpI || !TheLoop->contains(OpI) ||
+ (!isPredicatedInst(OpI) &&
+ (!isa<PHINode>(OpI) || OpI->getParent() != TheLoop->getHeader()) &&
+ all_of(OpI->operands(),
[this](Value *Op) { return shouldConsiderInvariant(Op); }));
}
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/phi-cost.ll",
"commands": [
"opt < %s -passes='function(loop-vectorize,instcombine)' -force-vector-width=2 -force-vector-interleave=1 -debug-only=loop-vectorize -disable-output -print-after=instcombine 2>&1"
],
"tests": [
{
"test_name": "red_phi_0",
"test_body": "target datalayout = \"e-m:e-i64:64-i128:128-n32:64-S128\"\n\ndefine i32 @red_phi_0(i32 %start, ptr %src) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %red = phi i32 [ %start, %entry ], [ %red.next, %loop ]\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %red.next = add i32 0, %red\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 100\n br i1 %exitcond.not, label %exit, label %loop\n\nexit: ; preds = %loop\n %res = phi i32 [ %red.next, %loop ]\n ret i32 %res\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "phi_three_incoming_values",
"test_body": "target datalayout = \"e-m:e-i64:64-i128:128-n32:64-S128\"\n\ndefine void @phi_three_incoming_values(ptr noalias %a, ptr noalias %b, i64 %n) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %if.end, %entry\n %i = phi i64 [ %i.next, %if.end ], [ 0, %entry ]\n %tmp0 = getelementptr inbounds i32, ptr %a, i64 %i\n %tmp1 = load i32, ptr %tmp0, align 4\n %tmp2 = getelementptr inbounds i32, ptr %b, i64 %i\n %tmp3 = load i32, ptr %tmp2, align 4\n %tmp4 = icmp sgt i32 %tmp1, %tmp3\n br i1 %tmp4, label %if.then, label %if.end\n\nif.then: ; preds = %for.body\n %tmp5 = icmp sgt i32 %tmp1, 19\n br i1 %tmp5, label %if.end, label %if.else\n\nif.else: ; preds = %if.then\n %tmp6 = icmp slt i32 %tmp3, 4\n %tmp7 = select i1 %tmp6, i32 4, i32 5\n br label %if.end\n\nif.end: ; preds = %if.else, %if.then, %for.body\n %tmp8 = phi i32 [ 9, %for.body ], [ 3, %if.then ], [ %tmp7, %if.else ]\n store i32 %tmp8, ptr %tmp0, align 4\n %i.next = add i64 %i, 1\n %cond = icmp eq i64 %i, %n\n br i1 %cond, label %for.end, label %for.body\n\nfor.end: ; preds = %if.end\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "phi_two_incoming_values",
"test_body": "target datalayout = \"e-m:e-i64:64-i128:128-n32:64-S128\"\n\ndefine void @phi_two_incoming_values(ptr noalias %a, ptr noalias %b, i64 %n) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %if.end, %entry\n %i = phi i64 [ %i.next, %if.end ], [ 0, %entry ]\n %tmp0 = getelementptr inbounds i32, ptr %a, i64 %i\n %tmp1 = load i32, ptr %tmp0, align 4\n %tmp2 = getelementptr inbounds i32, ptr %b, i64 %i\n %tmp3 = icmp sgt i32 %tmp1, 0\n br i1 %tmp3, label %if.then, label %if.end\n\nif.then: ; preds = %for.body\n %tmp4 = add i32 %tmp1, 1\n br label %if.end\n\nif.end: ; preds = %if.then, %for.body\n %tmp5 = phi i32 [ %tmp1, %for.body ], [ %tmp4, %if.then ]\n store i32 %tmp5, ptr %tmp2, align 4\n %i.next = add i64 %i, 1\n %cond = icmp eq i64 %i, %n\n br i1 %cond, label %for.end, label %for.body\n\nfor.end: ; preds = %if.end\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[clang] Segmentation fault in loop vectorization cost model during optimization pass",
"body": "When I compiled this code with -O2 flag, it crashed:\r\n\r\n```c\r\n#include <stdint.h>\r\n#define UNDEFINED(x) ((x), 0)\r\nlong b;\r\nstatic int64_t j = 1;\r\nstatic int64_t *k = &j;\r\nstatic int64_t **l = &k;\r\nint64_t m;\r\nstatic uint64_t n;\r\nint16_t ***o;\r\nstatic int64_t ***p = &l;\r\nuint64_t **q;\r\n\r\nuint16_t\r\nsafe_mod_func_uint16_t_u_u(uint16_t ui1, uint16_t ui2)\r\n{\r\n return \r\n#ifndef UNSAFE\r\n (ui2 == 0) ? \r\n (UNDEFINED(ui1)) : \r\n#endif\r\n (ui1 % ui2);\r\n}\r\n\r\nint64_t\r\nsafe_mod_func_int64_t_s_s(int64_t si1, int64_t si2)\r\n{\r\n return \r\n#ifndef UNSAFE\r\n ((si2 == 0) || ((si1 == INT64_MIN) && (si2 == (-1)))) ? \r\n (UNDEFINED(si1)) : \r\n#endif\r\n (si1 % si2);\r\n}\r\n\r\nint a(int, int, int, int, int) {}\r\nlong c(int d, int *e) {\r\n switch (d) {\r\n case 9:\r\n return b;\r\n case 8:\r\n return *e;\r\n }\r\n}\r\nlong f(int g, long, int h) {\r\n long i = c(g, &h);\r\n return i;\r\n}\r\nint32_t r() { int32_t *s[] = {&k, &m}; }\r\nint32_t t(int32_t *aa) {\r\n uint64_t ab = 2599693332;\r\n uint8_t ac = 142;\r\n for (; n <= 4; n++)\r\n *aa = (safe_mod_func_uint16_t_u_u(\r\n safe_mod_func_int64_t_s_s(a(0, 0, 0, 0, **l + 20) + **l, **q),\r\n ***o |= f(**l, 0, ***p)),\r\n **l + ac + ab - -1695273821 + *aa);\r\n}\r\n```\r\n\r\nThe crash is: clang: error: unable to execute command: Segmentation fault (core dumped)\r\nclang: error: clang frontend command failed due to signal (use -v to see invocation)\r\nCompiler returned: 254\r\n\r\nDetails can be found here: https://godbolt.org/z/3h9j7W6dG",
"author": "cardigan1008",
"labels": [
"regression",
"vectorizers",
"crash"
],
"comments": [
{
"author": "shafik",
"body": "This looks like a clang trunk regression: https://godbolt.org/z/MoKeds3ev"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
|
9de327c94d0c995803b6485fb28ac4cad1e53bbe
| null |
126085
|
https://github.com/llvm/llvm-project/issues/126085
|
crash
|
6575154b6eca80097d77db69ce1ee60c72854ee6
| 2025-02-06T15:41:55
|
[
"llvm/test/Transforms/VectorCombine"
] |
{
"fix_commit": "eb2b453eb73dfe0b8cf516dfb4d568c0b858d1fa",
"components": [
"VectorCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [
[
3210,
3216
]
],
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [
"VectorCombine::foldInsExtVectorToShuffle"
],
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit eb2b453eb73dfe0b8cf516dfb4d568c0b858d1fa
Author: Simon Pilgrim <llvm-dev@redking.me.uk>
Date: Thu Feb 6 16:40:48 2025 +0000
[VectorCombine] foldInsExtVectorToShuffle - ensure we call getShuffleCost with the input operand type, not the result
Typo in #121216
Fixes #126085
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index 4f46b621c8a7..746742e14d08 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -3210,7 +3210,7 @@ bool VectorCombine::foldInsExtVectorToShuffle(Instruction &I) {
ExtToVecMask[0] = ExtIdx;
// Add cost for expanding or narrowing
NewCost = TTI.getShuffleCost(TargetTransformInfo::SK_PermuteSingleSrc,
- DstVecTy, ExtToVecMask, CostKind);
+ SrcVecTy, ExtToVecMask, CostKind);
NewCost += TTI.getShuffleCost(SK, DstVecTy, Mask, CostKind);
}
|
[
{
"file": "llvm/test/Transforms/VectorCombine/X86/pr126085.ll",
"commands": [
"opt < %s -passes=vector-combine -S -mtriple=x86_64--"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine i32 @test(ptr %a0) {\n;\n %load = load <16 x i8>, ptr %a0, align 1\n %shuf = shufflevector <16 x i8> %load, <16 x i8> poison, <4 x i32> <i32 0, i32 poison, i32 poison, i32 poison>\n %elt = extractelement <16 x i8> %load, i64 11\n %ins = insertelement <4 x i8> %shuf, i8 %elt, i64 1\n %res = bitcast <4 x i8> %ins to i32\n ret i32 %res\n}",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[VectorCombine] Assertion `I >= 0 && I < (NumOpElts * 2) && \"Out-of-bounds shuffle mask element\"' failed.",
"body": "Reproducer:\n```\n; bin/opt -passes=vector-combine reduced.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 i32 @test(ptr readonly captures(none) dereferenceable(16) %0) {\n %2 = load <16 x i8>, ptr %0, align 1\n %.sroa.01.2.vec.insert = shufflevector <16 x i8> %2, <16 x i8> poison, <4 x i32> <i32 0, i32 poison, i32 poison, i32 poison>\n %3 = extractelement <16 x i8> %2, i64 11\n %.sroa.01.3.vec.insert = insertelement <4 x i8> %.sroa.01.2.vec.insert, i8 %3, i64 1\n %4 = bitcast <4 x i8> %.sroa.01.3.vec.insert to i32\n ret i32 %4\n}\n```\n```\nopt: /home/dtcxzyw/WorkSpace/Projects/compilers/llvm-project/llvm/lib/IR/Instructions.cpp:1890: bool isSingleSourceMaskImpl(llvm::ArrayRef<int>, int): Assertion `I >= 0 && I < (NumOpElts * 2) && \"Out-of-bounds shuffle mask element\"' 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=vector-combine reduced.ll -S\n1. Running pass \"function(vector-combine)\" on module \"reduced.ll\"\n2. Running pass \"vector-combine\" on function \"test\"\n #0 0x00007f4379a17152 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.21.0git+0x217152)\n #1 0x00007f4379a1403f llvm::sys::RunSignalHandlers() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.21.0git+0x21403f)\n #2 0x00007f4379a1417c SignalHandler(int) Signals.cpp:0:0\n #3 0x00007f4379442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #4 0x00007f43794969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #5 0x00007f43794969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #6 0x00007f43794969fc pthread_kill ./nptl/pthread_kill.c:89:10\n #7 0x00007f4379442476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x00007f43794287f3 abort ./stdlib/abort.c:81:7\n #9 0x00007f437942871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\n#10 0x00007f4379439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n#11 0x00007f4370e71a16 isSingleSourceMaskImpl(llvm::ArrayRef<int>, int) Instructions.cpp:0:0\n#12 0x00007f4370e7c3dc llvm::ShuffleVectorInst::isReverseMask(llvm::ArrayRef<int>, int) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.21.0git+0x27c3dc)\n#13 0x00007f43788933f2 llvm::X86TTIImpl::getShuffleCost(llvm::TargetTransformInfo::ShuffleKind, llvm::VectorType*, llvm::ArrayRef<int>, llvm::TargetTransformInfo::TargetCostKind, int, llvm::VectorType*, llvm::ArrayRef<llvm::Value const*>, llvm::Instruction const*) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.21.0git+0x4933f2)\n#14 0x00007f43716ddf0c llvm::TargetTransformInfo::getShuffleCost(llvm::TargetTransformInfo::ShuffleKind, llvm::VectorType*, llvm::ArrayRef<int>, llvm::TargetTransformInfo::TargetCostKind, int, llvm::VectorType*, llvm::ArrayRef<llvm::Value const*>, llvm::Instruction const*) const (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMAnalysis.so.21.0git+0x4ddf0c)\n#15 0x00007f437224f6e7 (anonymous namespace)::VectorCombine::foldInsExtVectorToShuffle(llvm::Instruction&) VectorCombine.cpp:0:0\n#16 0x00007f4372256116 (anonymous namespace)::VectorCombine::run()::'lambda'(llvm::Instruction&)::operator()(llvm::Instruction&) const VectorCombine.cpp:0:0\n#17 0x00007f437225787f llvm::VectorCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.21.0git+0x25787f)\n#18 0x00007f4373f225c5 llvm::detail::PassModel<llvm::Function, llvm::VectorCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMPasses.so.21.0git+0x1225c5)\n#19 0x00007f4370f10cad llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.21.0git+0x310cad)\n#20 0x00007f43784dc235 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/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.21.0git+0xdc235)\n#21 0x00007f4370f0ee75 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.21.0git+0x30ee75)\n#22 0x00007f43784dcbf5 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.21.0git+0xdcbf5)\n#23 0x00007f4370f0fb2a llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.21.0git+0x30fb2a)\n#24 0x00007f4379ba3dc6 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/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.21.0git+0x2fdc6)\n#25 0x00007f4379baf5c2 optMain (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.21.0git+0x3b5c2)\n#26 0x00007f4379429d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\n#27 0x00007f4379429e40 call_init ./csu/../csu/libc-start.c:128:20\n#28 0x00007f4379429e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\n#29 0x00006293bc5a5095 _start (bin/opt+0x1095)\nAborted (core dumped)\n```\n\nTriggered by https://github.com/llvm/llvm-project/pull/121216. cc @ParkHanbum @RKSimon \nReported by https://github.com/dtcxzyw/llvm-opt-benchmark/issues/2093\n\n",
"author": "dtcxzyw",
"labels": [
"crash-on-valid",
"llvm:transforms"
],
"comments": [
{
"author": "RKSimon",
"body": "Found the problem - fix incoming"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
8c1dbac304d2f3d9e9685c1f4fd8b3e133360893
| 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/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
9840,
9852
]
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"computeExtractCost"
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit b65b2b4ab60763515694c740935989f908a03312
Author: Alexey Bataev <a.bataev@outlook.com>
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
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
4b1b51ac52445f2308174287c721ad7f60a8053b
| null |
120823
|
https://github.com/llvm/llvm-project/issues/120823
|
miscompilation
|
9d0a5d4620a2aa5dc01b150e5ebe7613238cae1c
| 2024-12-21T05:25:23
|
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "030829a7e53fad0eab9b87b5dd49427e9fb13303",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
15483,
15488
]
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::vectorizeTree"
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 030829a7e53fad0eab9b87b5dd49427e9fb13303
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Mon Dec 23 16:53:37 2024 -0800
[SLP]Drop samesign flag if the vector node has reduced bitwidth
If the operands of the icmp instructions has reduced bitwidth after
MinBitwidth analysis, need to drop samesign flag to preserve correctness
of the transformation.
Fixes #120823
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index d22379429d00..b5d68c075b98 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -15483,6 +15483,8 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
CmpInst::Predicate P0 = cast<CmpInst>(VL0)->getPredicate();
Value *V = Builder.CreateCmp(P0, L, R);
propagateIRFlags(V, E->Scalars, VL0);
+ if (auto *ICmp = dyn_cast<ICmpInst>(V); ICmp && It == MinBWs.end())
+ ICmp->setSameSign(/*B=*/false);
// Do not cast for cmps.
VecTy = cast<FixedVectorType>(V->getType());
V = FinalShuffle(V, E);
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/buildvector-schedule-for-subvector.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-99999 < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define i1 @test() {\nentry:\n %and.i1698.1.i = zext i16 0 to i32\n %and19.i1699.2.i = and i32 %and.i1698.1.i, 0\n %and.i1698.2.i = zext i16 0 to i32\n %cmp25.i1700.2.i2 = icmp samesign uge i32 %and19.i1699.2.i, %and.i1698.1.i\n %and19.i1699.11841.i = and i32 %and.i1698.2.i, 0\n %cmp25.i1700.11842.i3 = icmp samesign uge i32 %and19.i1699.11841.i, %and.i1698.2.i\n %and.i1698.1.1.i = zext i16 0 to i32\n %and19.i1699.2.1.i = and i32 %and.i1698.1.1.i, 0\n %0 = add i16 1, 0\n %and.i1698.2.1.i = zext i16 %0 to i32\n %cmp25.i1700.2.1.i4 = icmp samesign uge i32 %and19.i1699.2.1.i, %and.i1698.1.1.i\n %and19.i1699.21846.i = and i32 %and.i1698.2.1.i, 0\n %cmp25.i1700.21847.i = icmp samesign uge i32 %and19.i1699.21846.i, %and.i1698.2.1.i\n ret i1 %cmp25.i1700.21847.i\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[SLPVectorizer] `samesign` flags should be dropped after narrowing down the width of operands",
"body": "Reproducer: https://alive2.llvm.org/ce/z/AvBhy9\n```\n; bin/opt -passes=slp-vectorizer test.ll -S\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i1 @test() {\nentry:\n %and.i1698.1.i = zext i16 0 to i32\n %and19.i1699.2.i = and i32 %and.i1698.1.i, 0\n %and.i1698.2.i = zext i16 0 to i32\n %cmp25.i1700.2.i2 = icmp samesign uge i32 %and19.i1699.2.i, %and.i1698.1.i\n %and19.i1699.11841.i = and i32 %and.i1698.2.i, 0\n %cmp25.i1700.11842.i3 = icmp samesign uge i32 %and19.i1699.11841.i, %and.i1698.2.i\n %and.i1698.1.1.i = zext i16 0 to i32\n %and19.i1699.2.1.i = and i32 %and.i1698.1.1.i, 0\n %0 = add i16 1, 0\n %and.i1698.2.1.i = zext i16 %0 to i32\n %cmp25.i1700.2.1.i4 = icmp samesign uge i32 %and19.i1699.2.1.i, %and.i1698.1.1.i\n %and19.i1699.21846.i = and i32 %and.i1698.2.1.i, 0\n %cmp25.i1700.21847.i = icmp samesign uge i32 %and19.i1699.21846.i, %and.i1698.2.1.i\n ret i1 %cmp25.i1700.21847.i\n}\n```\n```\ndefine i1 @test() {\nentry:\n %0 = add i16 1, 0\n %1 = insertelement <4 x i16> <i16 poison, i16 0, i16 0, i16 0>, i16 %0, i32 0\n %2 = trunc <4 x i16> %1 to <4 x i1>\n %3 = and <4 x i1> %2, zeroinitializer\n %4 = icmp samesign uge <4 x i1> %3, %2\n %5 = extractelement <4 x i1> %4, i32 0\n ret i1 %5\n}\n```\n```\n\n----------------------------------------\ndefine i1 @src() {\nentry:\n %#0 = add i16 1, 0\n %and.i1698.2.1.i = zext i16 %#0 to i32\n %and19.i1699.21846.i = and i32 %and.i1698.2.1.i, 0\n %cmp25.i1700.21847.i = icmp samesign uge i32 %and19.i1699.21846.i, %and.i1698.2.1.i\n ret i1 %cmp25.i1700.21847.i\n}\n=>\ndefine i1 @src() {\nentry:\n %#0 = add i16 1, 0\n %#1 = insertelement <4 x i16> { poison, 0, 0, 0 }, i16 %#0, i32 0\n %#2 = trunc <4 x i16> %#1 to <4 x i1>\n %#3 = and <4 x i1> %#2, { 0, 0, 0, 0 }\n %#4 = icmp samesign uge <4 x i1> %#3, %#2\n %#5 = extractelement <4 x i1> %#4, i32 0\n ret i1 %#5\n}\nTransformation doesn't verify!\n\nERROR: Target is more poisonous than source\n\nExample:\n\nSource:\ni16 %#0 = #x0001 (1)\ni32 %and.i1698.2.1.i = #x00000001 (1)\ni32 %and19.i1699.21846.i = #x00000000 (0)\ni1 %cmp25.i1700.21847.i = #x0 (0)\n\nTarget:\ni16 %#0 = #x0001 (1)\n<4 x i16> %#1 = < #x0001 (1), #x0000 (0), #x0000 (0), #x0000 (0) >\n<4 x i1> %#2 = < #x1 (1), #x0 (0), #x0 (0), #x0 (0) >\n<4 x i1> %#3 = < #x0 (0), #x0 (0), #x0 (0), #x0 (0) >\n<4 x i1> %#4 = < poison, #x1 (1), #x1 (1), #x1 (1) >\ni1 %#5 = poison\nSource value: #x0 (0)\nTarget value: poison\n\nSummary:\n 0 correct transformations\n 1 incorrect transformations\n 0 failed-to-prove transformations\n 0 Alive2 errors\n```\n",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:SLPVectorizer"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
Cannot find a good commit
| null |
153289
|
https://github.com/llvm/llvm-project/issues/153289
|
crash
|
0f6d3ad0feb42fbe36e1878fe9ffff67195c50d2
| 2025-08-12T20:46:33
|
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "dd5ba694bde6c92259c518b9eb2888163a812433",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
5689,
5695
],
[
20727,
20741
],
[
20748,
20755
],
[
20783,
20789
],
[
21048,
21056
],
[
21293,
21298
]
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::BlockScheduling::calculateDependencies",
"BoUpSLP::BlockScheduling::initScheduleData",
"BoUpSLP::BlockScheduling::tryScheduleBundle"
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit dd5ba694bde6c92259c518b9eb2888163a812433
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Wed Aug 13 05:57:07 2025 -0700
[SLP]Recalculate deps for potential control-dependent schedule data
After clearing the dependencies in copyable data, need to recalculate
dependencies for the original ScheduleData, if it can be marked as
control dependent.
Fixes #153289
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 98011174bd70..a3cb4d138789 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -5689,7 +5689,8 @@ private:
/// Updates the dependency information of a bundle and of all instructions/
/// bundles which depend on the original bundle.
void calculateDependencies(ScheduleBundle &Bundle, bool InsertInReadyList,
- BoUpSLP *SLP);
+ BoUpSLP *SLP,
+ ArrayRef<ScheduleData *> ControlDeps = {});
/// Sets all instruction in the scheduling region to un-scheduled.
void resetSchedule();
@@ -20727,15 +20728,21 @@ BoUpSLP::BlockScheduling::tryScheduleBundle(ArrayRef<Value *> VL, BoUpSLP *SLP,
LLVM_DEBUG(dbgs() << "SLP: bundle: " << *S.getMainOp() << "\n");
auto TryScheduleBundleImpl = [=](bool ReSchedule, ScheduleBundle &Bundle) {
- // Clear deps or reculate the region, if the memory instruction is a
- // copyable. It may have memory deps, which must be reaculated.
+ // Clear deps or recalculate the region, if the memory instruction is a
+ // copyable. It may have memory deps, which must be recalculated.
+ SmallVector<ScheduleData *> ControlDependentMembers;
auto CheckIfNeedToClearDeps = [&](ScheduleBundle &Bundle) {
SmallDenseMap<std::pair<Instruction *, Value *>, unsigned> UserOpToNumOps;
for (ScheduleEntity *SE : Bundle.getBundle()) {
if (ScheduleCopyableData *SD = dyn_cast<ScheduleCopyableData>(SE)) {
if (ScheduleData *BundleMember = getScheduleData(SD->getInst());
- BundleMember && BundleMember->hasValidDependencies())
+ BundleMember && BundleMember->hasValidDependencies()) {
BundleMember->clearDirectDependencies();
+ if (RegionHasStackSave ||
+ !isGuaranteedToTransferExecutionToSuccessor(
+ BundleMember->getInst()))
+ ControlDependentMembers.push_back(BundleMember);
+ }
continue;
}
auto *SD = cast<ScheduleData>(SE);
@@ -20748,8 +20755,12 @@ BoUpSLP::BlockScheduling::tryScheduleBundle(ArrayRef<Value *> VL, BoUpSLP *SLP,
if (auto *Op = dyn_cast<Instruction>(U.get());
Op && areAllOperandsReplacedByCopyableData(SD->getInst(), Op,
*SLP, NumOps)) {
- if (ScheduleData *OpSD = getScheduleData(Op))
+ if (ScheduleData *OpSD = getScheduleData(Op)) {
OpSD->clearDirectDependencies();
+ if (RegionHasStackSave ||
+ !isGuaranteedToTransferExecutionToSuccessor(OpSD->getInst()))
+ ControlDependentMembers.push_back(OpSD);
+ }
}
}
}
@@ -20783,7 +20794,8 @@ BoUpSLP::BlockScheduling::tryScheduleBundle(ArrayRef<Value *> VL, BoUpSLP *SLP,
CheckIfNeedToClearDeps(Bundle);
LLVM_DEBUG(dbgs() << "SLP: try schedule bundle " << Bundle << " in block "
<< BB->getName() << "\n");
- calculateDependencies(Bundle, /*InsertInReadyList=*/!ReSchedule, SLP);
+ calculateDependencies(Bundle, /*InsertInReadyList=*/!ReSchedule, SLP,
+ ControlDependentMembers);
}
if (ReSchedule) {
@@ -21048,9 +21060,9 @@ void BoUpSLP::BlockScheduling::initScheduleData(Instruction *FromI,
}
}
-void BoUpSLP::BlockScheduling::calculateDependencies(ScheduleBundle &Bundle,
- bool InsertInReadyList,
- BoUpSLP *SLP) {
+void BoUpSLP::BlockScheduling::calculateDependencies(
+ ScheduleBundle &Bundle, bool InsertInReadyList, BoUpSLP *SLP,
+ ArrayRef<ScheduleData *> ControlDeps) {
SmallVector<ScheduleEntity *> WorkList;
auto ProcessNode = [&](ScheduleEntity *SE) {
if (auto *CD = dyn_cast<ScheduleCopyableData>(SE)) {
@@ -21293,6 +21305,7 @@ void BoUpSLP::BlockScheduling::calculateDependencies(ScheduleBundle &Bundle,
};
WorkList.push_back(Bundle.getBundle().front());
+ WorkList.append(ControlDeps.begin(), ControlDeps.end());
SmallPtrSet<ScheduleBundle *, 16> Visited;
while (!WorkList.empty()) {
ScheduleEntity *SD = WorkList.pop_back_val();
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/control-dependent-schedule.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, i32 %1) {\n;\nentry:\n %k = alloca [4 x i32], align 16\n %add1 = add i32 %0, %1\n %sub2 = add i32 %add1, -1\n %call = tail call i32 (ptr, ...) @printf(ptr null, i32 %add1)\n %add2 = add i32 %1, -1\n %sub3 = add i32 %add2, %call\n %add4 = add i32 %sub3, %0\n store i32 %add4, ptr %k, align 16\n %arrayinit.element = getelementptr i8, ptr %k, i64 4\n store i32 0, ptr %arrayinit.element, align 4\n %arrayinit.element5 = getelementptr i8, ptr %k, i64 8\n %add7 = add i32 %add2, %sub2\n %sub8 = add i32 %add7, %0\n store i32 %sub8, ptr %arrayinit.element5, align 8\n %arrayinit.element9 = getelementptr i8, ptr %k, i64 12\n %add13 = add i32 %1, 1\n %add10 = add i32 %add13, %0\n %add11 = add i32 %add10, %add1\n %add12 = add i32 %add11, %0\n store i32 %add12, ptr %arrayinit.element9, align 4\n %call15 = call i32 (ptr, ...) @printf(ptr null, ptr %k)\n ret i32 %call15\n}\n\ndeclare i32 @printf(ptr, ...)",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "clang crashes at -O{s,2,3} on x86_64-linux-gnu: Assertion `hasValidDependencies() && \"increment of unscheduled deps would be meaningless\"' failed",
"body": "Compiler Explorer: https://godbolt.org/z/xWvWKe3fj\n\nNote:\n- fails: trunk\n- works: 20.1.0 and earlier (so a recent regression)\n\n```\n[569] % clangtk -v\nclang version 22.0.0git (https://github.com/llvm/llvm-project.git 44f41f55b4df5ec490df0d69e046b2d1a58acaeb)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /local/home/suz/suz-local/software/local/clang-trunk/bin\nBuild config: +assertions\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12\nCandidate multilib: .;@m64\nSelected multilib: .;@m64\nFound CUDA installation: /usr/local/cuda, version 12.1\n[570] % \n[570] % clangtk -O3 small.c\nclang-22: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:4773: int llvm::slpvectorizer::BoUpSLP::ScheduleData::incrementUnscheduledDeps(int): Assertion `hasValidDependencies() && \"increment of unscheduled deps would be meaningless\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\nStack dump:\n0.\tProgram arguments: /local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22 -cc1 -triple x86_64-unknown-linux-gnu -O3 -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/bug138/red1 -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/bug138/red1 -resource-dir /local/home/suz/suz-local/software/local/clang-trunk/lib/clang/22 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/home/suz/suz-local/software/local/clang-trunk/lib/clang/22/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -ferror-limit 19 -fmessage-length=130 -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-6dbb88.o -x c small.c\n1.\t<eof> parser at end of file\n2.\tOptimizer\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-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<O3>,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\"\n4.\tRunning pass \"slp-vectorizer\" on function \"main\"\n #0 0x0000563336e85430 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4263430)\n #1 0x0000563336e820df llvm::sys::RunSignalHandlers() (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x42600df)\n #2 0x0000563336e82232 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #3 0x00007f2abf190520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #4 0x00007f2abf1e49fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #5 0x00007f2abf1e49fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #6 0x00007f2abf1e49fc pthread_kill ./nptl/pthread_kill.c:89:10\n #7 0x00007f2abf190476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x00007f2abf1767f3 abort ./stdlib/abort.c:81:7\n #9 0x00007f2abf17671b _nl_load_domain ./intl/loadmsgcat.c:1177:9\n#10 0x00007f2abf187e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n#11 0x0000563338a0edf4 auto void llvm::slpvectorizer::BoUpSLP::BlockScheduling::schedule<llvm::SetVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, 0u>, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, void>>, 0u>>(llvm::slpvectorizer::BoUpSLP const&, (anonymous namespace)::InstructionsState const&, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SetVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, 0u>, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, void>>, 0u>&)::'lambda'(llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::ArrayRef<llvm::slpvectorizer::BoUpSLP::ScheduleBundle*>)::operator()(llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::ArrayRef<llvm::slpvectorizer::BoUpSLP::ScheduleBundle*>) const::'lambda'(llvm::SetVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, 0u>, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, void>>, 0u>*, bool)::operator()<llvm::slpvectorizer::BoUpSLP::ScheduleData>(llvm::SetVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, 0u>, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, void>>, 0u>*, bool) const SLPVectorizer.cpp:0:0\n#12 0x0000563338a11f92 void llvm::slpvectorizer::BoUpSLP::BlockScheduling::schedule<llvm::SetVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, 0u>, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, void>>, 0u>>(llvm::slpvectorizer::BoUpSLP const&, (anonymous namespace)::InstructionsState const&, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SetVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, 0u>, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, void>>, 0u>&)::'lambda'(llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::ArrayRef<llvm::slpvectorizer::BoUpSLP::ScheduleBundle*>)::operator()(llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::ArrayRef<llvm::slpvectorizer::BoUpSLP::ScheduleBundle*>) const SLPVectorizer.cpp:0:0\n#13 0x0000563338a12def llvm::slpvectorizer::BoUpSLP::BlockScheduling::tryScheduleBundle(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP*, (anonymous namespace)::InstructionsState const&, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&)::'lambda0'(bool, llvm::slpvectorizer::BoUpSLP::ScheduleBundle&)::operator()(bool, llvm::slpvectorizer::BoUpSLP::ScheduleBundle&) const SLPVectorizer.cpp:0:0\n#14 0x0000563338a14217 llvm::slpvectorizer::BoUpSLP::BlockScheduling::tryScheduleBundle(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP*, (anonymous namespace)::InstructionsState const&, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&) SLPVectorizer.cpp:0:0\n#15 0x0000563338a15cbe llvm::slpvectorizer::BoUpSLP::buildTreeRec(llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, unsigned int) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5df3cbe)\n#16 0x0000563338a17ed9 llvm::slpvectorizer::BoUpSLP::buildTreeRec(llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, unsigned int) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5df5ed9)\n#17 0x0000563338a17ed9 llvm::slpvectorizer::BoUpSLP::buildTreeRec(llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, unsigned int) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5df5ed9)\n#18 0x0000563338a17237 llvm::slpvectorizer::BoUpSLP::buildTreeRec(llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, unsigned int) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5df5237)\n#19 0x0000563338a1a360 llvm::slpvectorizer::BoUpSLP::buildTree(llvm::ArrayRef<llvm::Value*>) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5df8360)\n#20 0x0000563338a5c1ba llvm::SLPVectorizerPass::vectorizeStoreChain(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, unsigned int, unsigned int, unsigned int&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5e3a1ba)\n#21 0x0000563338a5e014 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::map<long, unsigned int, std::less<long>, std::allocator<std::pair<long const, unsigned int>>> const&)::operator()(std::map<long, unsigned int, std::less<long>, std::allocator<std::pair<long const, unsigned int>>> const&) const SLPVectorizer.cpp:0:0\n#22 0x0000563338a5ff00 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>>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5e3df00)\n#23 0x0000563338a6081b llvm::SLPVectorizerPass::vectorizeStoreChains(llvm::slpvectorizer::BoUpSLP&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5e3e81b)\n#24 0x0000563338a61d95 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\n#25 0x0000563338a62981 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5e40981)\n#26 0x0000563337f6caf6 llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x534aaf6)\n#27 0x00005633367c6e57 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3ba4e57)\n#28 0x0000563333f1b836 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/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x12f9836)\n#29 0x00005633367c7379 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3ba5379)\n#30 0x0000563333f1bf26 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x12f9f26)\n#31 0x00005633367c5194 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3ba3194)\n#32 0x000056333712bd13 (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#33 0x00005633371302b3 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*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x450e2b3)\n#34 0x000056333782a05f clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4c0805f)\n#35 0x000056333928da0c clang::ParseAST(clang::Sema&, bool, bool) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x666ba0c)\n#36 0x0000563337b47b59 clang::FrontendAction::Execute() (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4f25b59)\n#37 0x0000563337ac34c5 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4ea14c5)\n#38 0x0000563337c38628 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5016628)\n#39 0x0000563333a9bd58 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xe79d58)\n#40 0x0000563333a9235a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#41 0x0000563333a96e14 clang_main(int, char**, llvm::ToolContext const&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xe74e14)\n#42 0x000056333396306b main (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xd4106b)\n#43 0x00007f2abf177d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\n#44 0x00007f2abf177e40 call_init ./csu/../csu/libc-start.c:128:20\n#45 0x00007f2abf177e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\n#46 0x0000563333a91a85 _start (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xe6fa85)\nclangtk: error: unable to execute command: Aborted\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\nclang version 22.0.0git (https://github.com/llvm/llvm-project.git 44f41f55b4df5ec490df0d69e046b2d1a58acaeb)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /local/home/suz/suz-local/software/local/clang-trunk/bin\nBuild config: +assertions\nclangtk: note: diagnostic msg: \n********************\n\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\nPreprocessed source(s) and associated run script(s) are located at:\nclangtk: note: diagnostic msg: /tmp/small-859782.c\nclangtk: note: diagnostic msg: /tmp/small-859782.sh\nclangtk: note: diagnostic msg: \n\n********************\n[571] % \n[571] % cat small.c\nint printf(const char *, ...);\nint a, b, d, g, c, f;\nint main() {\n int h, i, j;\n i = c;\n for (int e = 0; e < 1; e++)\n if (a)\n b = e;\n j = d + i - 1;\n g = printf(\"%d\", j);\n h = j + 3;\n int k[] = {g + i - 1 + j, 0, f + j + i - 1, h + j + i + c};\n if (a)\n printf(\"%p\", (void *)k);\n return 0;\n}\n```",
"author": "zhendongsu",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
|
2d7b55a028139dde58a994a65895841190dfde96
| null |
148052
|
https://github.com/llvm/llvm-project/issues/148052
|
crash
|
65787728b72a2b1f1bfdefd15d32ec0a69f2b941
| 2025-07-10T20:24:08
|
[
"llvm/test/Transforms/SimplifyCFG"
] |
{
"fix_commit": "43561ad204329667954d5ce1e632e09335f0ab12",
"components": [
"BasicBlockUtils"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": [
[
58,
63
],
[
75,
81
]
],
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": [
"llvm::detachDeadBlocks"
],
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 43561ad204329667954d5ce1e632e09335f0ab12
Author: Gábor Spaits <gaborspaits1@gmail.com>
Date: Thu Sep 11 22:52:16 2025 +0200
[BasicBlockUtils] Handle funclets when detaching EH pad blocks (#157363)
Fixes #148052 .
When removing EH Pad blocks, the value defined by them becomes poison. These poison values are then used by `catchret` and `cleanupret`, which is invalid. This commit replaces those unreachable `catchret` and `cleanupret` instructions with `unreachable`.
diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
index cad0b4c12b54..d2391e166f94 100644
--- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -58,6 +58,19 @@ static cl::opt<unsigned> MaxDeoptOrUnreachableSuccessorCheckDepth(
"is followed by a block that either has a terminating "
"deoptimizing call or is terminated with an unreachable"));
+static void replaceFuncletPadsRetWithUnreachable(Instruction &I) {
+ assert(isa<FuncletPadInst>(I) && "Instruction must be a funclet pad!");
+ for (User *User : make_early_inc_range(I.users())) {
+ Instruction *ReturnInstr = dyn_cast<Instruction>(User);
+ if (isa<CatchReturnInst>(ReturnInstr) ||
+ isa<CleanupReturnInst>(ReturnInstr)) {
+ BasicBlock *ReturnInstrBB = ReturnInstr->getParent();
+ ReturnInstr->eraseFromParent();
+ new UnreachableInst(ReturnInstrBB->getContext(), ReturnInstrBB);
+ }
+ }
+}
+
void llvm::detachDeadBlocks(
ArrayRef<BasicBlock *> BBs,
SmallVectorImpl<DominatorTree::UpdateType> *Updates,
@@ -75,7 +88,36 @@ void llvm::detachDeadBlocks(
// Zap all the instructions in the block.
while (!BB->empty()) {
Instruction &I = BB->back();
- // If this instruction is used, replace uses with an arbitrary value.
+ // Exception handling funclets need to be explicitly addressed.
+ // These funclets must begin with cleanuppad or catchpad and end with
+ // cleanupred or catchret. The return instructions can be in different
+ // basic blocks than the pad instruction. If we would only delete the
+ // first block, the we would have possible cleanupret and catchret
+ // instructions with poison arguments, which wouldn't be valid.
+ if (isa<FuncletPadInst>(I))
+ replaceFuncletPadsRetWithUnreachable(I);
+
+ // Catchswitch instructions have handlers, that must be catchpads and
+ // an unwind label, that is either a catchpad or catchswitch.
+ if (CatchSwitchInst *CSI = dyn_cast<CatchSwitchInst>(&I)) {
+ // Iterating over the handlers and the unwind basic block and processing
+ // catchpads. If the unwind label is a catchswitch, we just replace the
+ // label with poison later on.
+ for (unsigned I = 0; I < CSI->getNumSuccessors(); I++) {
+ BasicBlock *SucBlock = CSI->getSuccessor(I);
+ Instruction &SucFstInst = *(SucBlock->getFirstNonPHIIt());
+ if (isa<FuncletPadInst>(SucFstInst)) {
+ replaceFuncletPadsRetWithUnreachable(SucFstInst);
+ // There may be catchswitch instructions using the catchpad.
+ // Just replace those with poison.
+ if (!SucFstInst.use_empty())
+ SucFstInst.replaceAllUsesWith(
+ PoisonValue::get(SucFstInst.getType()));
+ SucFstInst.eraseFromParent();
+ }
+ }
+ }
+
// Because control flow can't get here, we don't care what we replace the
// value with. Note that since this block is unreachable, and all values
// contained within it must dominate their uses, that all uses will
|
[
{
"file": "llvm/test/Transforms/SimplifyCFG/unreachable-multi-basic-block-funclet.ll",
"commands": [
"opt -passes=simplifycfg -S < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n; cleanuppad/cleanupret\n\ndefine void @unreachable_cleanuppad_linear(i64 %shapes.1) personality ptr null {\n;\nstart:\n %_7 = icmp ult i64 0, %shapes.1\n ret void\n\nfunclet:\n %cleanuppad = cleanuppad within none []\n br label %funclet_end\n\nfunclet_end:\n cleanupret from %cleanuppad unwind to caller\n}\n\ndefine void @unreachable_cleanuppad_multiple_predecessors(i64 %shapes.1) personality ptr null {\n;\nstart:\n %_7 = icmp ult i64 0, %shapes.1\n ret void\n\nfunclet:\n %cleanuppad = cleanuppad within none []\n switch i64 %shapes.1, label %otherwise [ i64 0, label %one\n i64 1, label %two\n i64 42, label %three ]\none:\n br label %funclet_end\n\ntwo:\n br label %funclet_end\n\nthree:\n br label %funclet_end\n\notherwise:\n br label %funclet_end\n\nfunclet_end:\n cleanupret from %cleanuppad unwind to caller\n}\n\n; catchpad/catchret\n\ndefine void @unreachable_catchpad_linear(i64 %shapes.1) personality ptr null {\n;\nstart:\n %_7 = icmp ult i64 0, %shapes.1\n ret void\n\ndispatch:\n %cs = catchswitch within none [label %funclet] unwind to caller\n\nfunclet:\n %cleanuppad = catchpad within %cs []\n br label %funclet_end\n\n\nfunclet_end:\n catchret from %cleanuppad to label %unreachable\n\nunreachable:\n unreachable\n}\n\ndefine void @unreachable_catchpad_multiple_predecessors(i64 %shapes.1) personality ptr null {\n;\nstart:\n %_7 = icmp ult i64 0, %shapes.1\n ret void\n\ndispatch:\n %cs = catchswitch within none [label %funclet] unwind to caller\n\nfunclet:\n %cleanuppad = catchpad within %cs []\n switch i64 %shapes.1, label %otherwise [ i64 0, label %one\n i64 1, label %two\n i64 42, label %three ]\none:\n br label %funclet_end\n\ntwo:\n br label %funclet_end\n\nthree:\n br label %funclet_end\n\notherwise:\n br label %funclet_end\n\nfunclet_end:\n catchret from %cleanuppad to label %unreachable\n\nunreachable:\n unreachable\n}\n\n; Issue reproducer\n\ndefine void @gh148052(i64 %shapes.1) personality ptr null {\n;\nstart:\n %_7 = icmp ult i64 0, %shapes.1\n br i1 %_7, label %bb1, label %panic\n\nbb1:\n %_11 = icmp ult i64 0, %shapes.1\n br i1 %_11, label %bb3, label %panic1\n\npanic:\n unreachable\n\nbb3:\n ret void\n\npanic1:\n invoke void @func(i64 0, i64 0, ptr null)\n to label %unreachable unwind label %funclet_bb14\n\nfunclet_bb14:\n %cleanuppad = cleanuppad within none []\n br label %bb13\n\nunreachable:\n unreachable\n\nbb10:\n cleanupret from %cleanuppad5 unwind to caller\n\nfunclet_bb10:\n %cleanuppad5 = cleanuppad within none []\n br label %bb10\n\nbb13:\n cleanupret from %cleanuppad unwind label %funclet_bb10\n}\n\ndeclare void @func(i64, i64, ptr)",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "Bug in SimplifyCFG causes ICE",
"body": "This minimal Rust code causes a failure when the `simplifycfg` pass is enabled:\n\n```rust\npub fn repro_func(shapes: &mut [ShapeInfo<ReproShape>]) {\n repro_generic::<ReproShape>(shapes);\n}\n\n#[derive(Clone)]\npub struct ShapeInfo<S> {\n pub shape: S,\n}\n\n#[derive(Default, Copy, Clone)]\npub enum ReproShape {\n #[default]\n A = 0,\n B = 1,\n}\n\npub(crate) fn repro_generic<S: Default + Clone>(shapes: &mut [ShapeInfo<S>]) {\n shapes[0] = shapes[1].clone();\n shapes[1].shape = Default::default();\n}\n```\n\nWhen this is compiled with these Rust args:\n\n```\nrustc \\\n--emit=llvm-ir \\\n--crate-name=repro \\\n--edition=2021 \\\nrepro.rs \\\n--crate-type=lib \\\n--out-dir=out \\\n--target=x86_64-pc-windows-msvc \\\n-Cno-prepopulate-passes\n```\n\nit produces `repro.ll`. Rust normally enables `simplifycfg` by default, so I've disabled all passes in this repro. You can manually reproduce the problem by running `opt --passes=simplifycfg repro.ll`.\n\nI tried to attach `repro.ll`, but GitHub rejects `*.ll` files. I'll create a repro PR.\n",
"author": "sivadeilra",
"labels": [
"crash",
"llvm:transforms"
],
"comments": [
{
"author": "sivadeilra",
"body": "I've created #148053 with an integration test that shows the bug.\n\nTagging @spaits, @andjo403 for help, since I see recent commits to this code.\n\n"
},
{
"author": "spaits",
"body": "Hi. Could you please tell what rustc version you use?"
},
{
"author": "sivadeilra",
"body": "I used 1.88.0 to generate the LLVM IR. I haven't tested earlier versions, but I'm guessing it repros with earlier versions, as long as you're generating IR and then optimizing with with LLVM at HEAD."
},
{
"author": "sivadeilra",
"body": "I just checked with Rust 1.82.0, and the same problem occurs."
},
{
"author": "efriedma-quic",
"body": "Reduced using `llvm-reduce -skip-delta-passes=simplify-cfg,ir-passes`:\n\n```\ndefine void @_RINvCs3LQYlzOoal9_5repro13repro_genericNtB2_10ReproShapeEB2_(i64 %shapes.1) personality ptr null {\nstart:\n %_7 = icmp ult i64 0, %shapes.1\n br i1 %_7, label %bb1, label %panic\n\nbb1: ; preds = %start\n %_11 = icmp ult i64 0, %shapes.1\n br i1 %_11, label %bb3, label %panic1\n\npanic: ; preds = %start\n unreachable\n\nbb3: ; preds = %bb1\n ret void\n\npanic1: ; preds = %bb1\n invoke void @_RNvNtCshEuXqvZjEXJ_4core9panicking18panic_bounds_check(i64 0, i64 0, ptr null)\n to label %unreachable unwind label %funclet_bb14\n\nfunclet_bb14: ; preds = %panic1\n %cleanuppad = cleanuppad within none []\n br label %bb13\n\nunreachable: ; preds = %panic1\n unreachable\n\nbb10: ; preds = %funclet_bb10\n cleanupret from %cleanuppad5 unwind to caller\n\nfunclet_bb10: ; preds = %bb13\n %cleanuppad5 = cleanuppad within none []\n br label %bb10\n\nbb13: ; preds = %funclet_bb14\n cleanupret from %cleanuppad unwind label %funclet_bb10\n}\n\ndeclare void @_RNvNtCshEuXqvZjEXJ_4core9panicking18panic_bounds_check(i64, i64, ptr)\n```"
},
{
"author": "sivadeilra",
"body": "Call stack:\n\n```text\n0:000> knL 20\n # Call Site\n00 opt!HandleAbort+0xc\n01 opt!raise+0x221\n02 opt!abort+0x18\n03 opt!common_assert_to_stderr_direct+0xd3\n04 opt!common_assert_to_stderr<wchar_t>+0x18\n05 opt!common_assert+0x56\n06 opt!_wassert+0x72\n07 opt!llvm::cast<llvm::CleanupPadInst,llvm::Use>+0x40\n08 opt!llvm::CleanupReturnInst::getCleanupPad+0x1c\n09 opt!llvm::removeUnwindEdge+0x118\n0a opt!removeEmptyCleanup+0x6ac\n0b opt!`anonymous namespace'::SimplifyCFGOpt::simplifyCleanupReturn+0x5d\n0c opt!`anonymous namespace'::SimplifyCFGOpt::simplifyOnce+0x57d\n0d opt!`anonymous namespace'::SimplifyCFGOpt::run+0x35\n0e opt!llvm::simplifyCFG+0xbc\n0f opt!iterativelySimplifyCFG+0x3a9\n10 opt!simplifyFunctionCFGImpl+0x16a\n11 opt!simplifyFunctionCFG+0x91\n12 opt!llvm::SimplifyCFGPass::run+0xcf\n13 opt!llvm::detail::PassModel<llvm::Function,llvm::SimplifyCFGPass,llvm::AnalysisManager<llvm::Function> >::run+0x40\n14 opt!llvm::PassManager<llvm::Function,llvm::AnalysisManager<llvm::Function> >::run+0x1e2\n15 opt!llvm::detail::PassModel<llvm::Function,llvm::PassManager<llvm::Function,llvm::AnalysisManager<llvm::Function> >,llvm::AnalysisManager<llvm::Function> >::run+0x40\n16 opt!llvm::ModuleToFunctionPassAdaptor::run+0x1ae\n17 opt!llvm::detail::PassModel<llvm::Module,llvm::ModuleToFunctionPassAdaptor,llvm::AnalysisManager<llvm::Module> >::run+0x40\n18 opt!llvm::PassManager<llvm::Module,llvm::AnalysisManager<llvm::Module> >::run+0x1e2\n19 opt!llvm::runPassPipeline+0x1ef5\n```\n\nAssertion failure:\n\n```text\nAssertion failed: isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\", file D:\\rust\\src\\llvm-project\\llvm\\include\\llvm/Support/Casting.h, line 566\n```\n"
},
{
"author": "spaits",
"body": "Here is the reproducer in godbolt:\nhttps://godbolt.org/z/njT5ET3dj"
},
{
"author": "hstk30-hw",
"body": "the `%cleanuppad` is optimize to `posion`\n\n```\ncleanupret from posion unwind label %funclet_bb10`\n```\n\nCast from `posion` to `CleanupPadInst` failed"
},
{
"author": "spaits",
"body": "It seems that the seond attempt causes crashes on the buildbot builds: https://lab.llvm.org/buildbot/#/builders/55/builds/17295\n\nI have reverted the fix again. I will give it another go later this week."
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
Cannot find a good commit
| null |
77064
|
https://github.com/llvm/llvm-project/issues/77064
|
crash
|
255f95a40377677dd762df5a1aa65bcbb4f75c79
| 2024-01-05T09:28:42
|
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "a001e9718fd974859f2797a9f9ed7bf87d364e4f",
"components": [
"SimplifyLibCalls"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": [
[
3735,
3760
]
],
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": [
"LibCallSimplifier::optimizeCall"
],
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit a001e9718fd974859f2797a9f9ed7bf87d364e4f
Author: Nikita Popov <npopov@redhat.com>
Date: Fri Jan 5 10:41:44 2024 +0100
[SimplifyLibCalls] Don't try to manually reprocess calls
The current code for reprocessing the result of fortified libcall
simplifications is not correct, because we might simplify to an
argument of the original call, and if that is again a libcall,
mistakenly think that this is actually the simplification result.
Instead of trying to fix this, simply remove the code entirely,
because InstCombine nowadays correctly handles reprocessing of
SimplifyLibCall results.
Fixes https://github.com/llvm/llvm-project/issues/77064.
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index 760a626c8b6f..a7cd68e860e4 100644
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -3735,26 +3735,8 @@ Value *LibCallSimplifier::optimizeCall(CallInst *CI, IRBuilderBase &Builder) {
// Also try to simplify calls to fortified library functions.
if (Value *SimplifiedFortifiedCI =
- FortifiedSimplifier.optimizeCall(CI, Builder)) {
- // Try to further simplify the result.
- CallInst *SimplifiedCI = dyn_cast<CallInst>(SimplifiedFortifiedCI);
- if (SimplifiedCI && SimplifiedCI->getCalledFunction()) {
- // Ensure that SimplifiedCI's uses are complete, since some calls have
- // their uses analyzed.
- replaceAllUsesWith(CI, SimplifiedCI);
-
- // Set insertion point to SimplifiedCI to guarantee we reach all uses
- // we might replace later on.
- IRBuilderBase::InsertPointGuard Guard(Builder);
- Builder.SetInsertPoint(SimplifiedCI);
- if (Value *V = optimizeStringMemoryLibCall(SimplifiedCI, Builder)) {
- // If we were able to further simplify, remove the now redundant call.
- substituteInParent(SimplifiedCI, V);
- return V;
- }
- }
+ FortifiedSimplifier.optimizeCall(CI, Builder))
return SimplifiedFortifiedCI;
- }
// Then check for known library functions.
if (TLI->getLibFunc(*Callee, Func) && isLibFuncEmittable(M, TLI, Func)) {
|
[
{
"file": "llvm/test/Transforms/InstCombine/pr77064.ll",
"commands": [
"opt -S -passes=instcombine < %s"
],
"tests": [
{
"test_name": "main",
"test_body": "define void @main(ptr %ptr) {\n %opendir = call fastcc ptr @opendir(ptr %ptr)\n %memset = call ptr @__memset_chk(ptr %opendir, i32 0, i64 596, i64 -1)\n ret void\n}\n\ndeclare ptr @__memset_chk(ptr, i32, i64, i64)\n\ndeclare fastcc ptr @opendir(ptr)\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[SimplifyLibCalls] Calling convention assertion fails",
"body": "```llvm\r\n; RUN: opt -S -passes=instcombine\r\ndefine void @main(ptr %ptr) {\r\n %opendir = call fastcc ptr @opendir(ptr %ptr)\r\n %memset = call ptr @__memset_chk(ptr %opendir, i32 0, i64 596, i64 -1)\r\n ret void\r\n}\r\n\r\ndeclare ptr @__memset_chk(ptr, i32, i64, i64)\r\n\r\ndeclare fastcc ptr @opendir(ptr)\r\n```\r\n\r\n> opt: /home/npopov/repos/llvm-project/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:3488: Value *llvm::LibCallSimplifier::optimizeStringMemoryLibCall(CallInst *, IRBuilderBase &): Assertion `(ignoreCallingConv(Func) || TargetLibraryInfoImpl::isCallingConvCCompatible(CI)) && \"Optimizing string/memory libcall would change the calling convention\"' failed.\r\n\r\nEncountered when building openjpeg2.",
"author": "nikic",
"labels": [
"llvm:crash",
"llvm:instcombine"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
Cannot find a good commit
| null |
160792
|
https://github.com/llvm/llvm-project/issues/160792
|
crash
|
ca55c07337d59aa65a19284f7b1307d16b2b0a44
| 2025-09-25T23:12:56
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "ae7b15f2e29cea642ca847a4f0ae91d2d793f6ad",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": [
[
3174,
3179
],
[
3221,
3229
],
[
3274,
3282
]
],
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": [
[
1777,
1782
]
],
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": [
"VPReplicateRecipe::computeCost"
],
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": [
"VPCostContext::getScalarizationOverhead"
],
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit ae7b15f2e29cea642ca847a4f0ae91d2d793f6ad
Author: Florian Hahn <flo@fhahn.com>
Date: Sat Oct 11 19:01:27 2025 +0100
[VPlan] Return invalid for scalable VF in VPReplicateRecipe::computeCost
Replication is currently not supported for scalable VFs. Make sure
VPReplicateRecipe::computeCost returns an invalid cost early, for
scalable VFs if the recipe is not a single-scalar.
Note that this moves the existing invalid-costs.ll out of the AArch64
subdirectory, as it does not use a target triple.
Fixes https://github.com/llvm/llvm-project/issues/160792.
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index 2555ebe2ad89..1fea068bfafd 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -1777,6 +1777,9 @@ InstructionCost VPCostContext::getScalarizationOverhead(
if (VF.isScalar())
return 0;
+ assert(!VF.isScalable() &&
+ "Scalarization overhead not supported for scalable vectors");
+
InstructionCost ScalarizationCost = 0;
// Compute the cost of scalarizing the result if needed.
if (!ResultTy->isVoidTy()) {
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index 600ff8ac33fe..8e9167729278 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -3174,6 +3174,9 @@ InstructionCost VPReplicateRecipe::computeCost(ElementCount VF,
// transform, avoid computing their cost multiple times for now.
Ctx.SkipCostComputation.insert(UI);
+ if (VF.isScalable() && !isSingleScalar())
+ return InstructionCost::getInvalid();
+
switch (UI->getOpcode()) {
case Instruction::GetElementPtr:
// We mark this instruction as zero-cost because the cost of GEPs in
@@ -3221,9 +3224,6 @@ InstructionCost VPReplicateRecipe::computeCost(ElementCount VF,
return ScalarCallCost;
}
- if (VF.isScalable())
- return InstructionCost::getInvalid();
-
return ScalarCallCost * VF.getFixedValue() +
Ctx.getScalarizationOverhead(ResultTy, ArgOps, VF);
}
@@ -3274,9 +3274,6 @@ InstructionCost VPReplicateRecipe::computeCost(ElementCount VF,
}
case Instruction::Load:
case Instruction::Store: {
- if (VF.isScalable() && !isSingleScalar())
- return InstructionCost::getInvalid();
-
// TODO: See getMemInstScalarizationCost for how to handle replicating and
// predicated cases.
const VPRegionBlock *ParentRegion = getParent()->getParent();
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/invalid-costs.ll",
"commands": [
"opt -passes=\"loop-vectorize\" -pass-remarks-output=/dev/null -S %s"
],
"tests": [
{
"test_name": "replicate_sdiv_conditional",
"test_body": "target triple = \"arm64-apple-macosx\"\n\ndefine void @replicate_sdiv_conditional(ptr noalias %a, ptr noalias %b, ptr noalias %c) #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 %gep.c = getelementptr inbounds i32, ptr %c, i64 %iv\n %val.c = load i32, ptr %gep.c, align 4\n %cmp = icmp slt i32 %val.c, 0\n br i1 %cmp, label %if.then, label %loop.latch\n\nif.then: ; preds = %loop.header\n %gep.b = getelementptr inbounds i32, ptr %b, i64 %iv\n %val.b = load i32, ptr %gep.b, align 4\n %sext = sext i32 %val.b to i64\n %shr = ashr i32 %val.b, 1\n %add = add i32 %shr, %val.c\n %conv = sext i32 %add to i64\n %div = sdiv i64 %conv, %sext\n %trunc = trunc i64 %div to i32\n br label %loop.latch\n\nloop.latch: ; preds = %if.then, %loop.header\n %result = phi i32 [ %trunc, %if.then ], [ %val.c, %loop.header ]\n %gep.a = getelementptr inbounds i32, ptr %a, i64 %iv\n store i32 %result, ptr %gep.a, align 4\n %iv.next = add nuw nsw i64 %iv, 1\n %exit = icmp eq i64 %iv.next, 64\n br i1 %exit, label %for.end, label %loop.header\n\nfor.end: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-cpu\"=\"neoverse-512tvb\" }\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/invalid-costs.ll",
"commands": [
"opt -passes=\"loop-vectorize\" -pass-remarks-output=/dev/null -S %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n; REMARKS: the cost-model indicates that vectorization is not beneficial\n\n; Test for https://github.com/llvm/llvm-project/issues/116375.\ndefine void @test_i24_load_for(ptr noalias %src, ptr %dst) {\n;\nentry:\n br label %loop\n\nloop:\n %iv = phi i16 [ 0, %entry ], [ %iv.next, %loop ]\n %for = phi i24 [ 0, %entry ], [ %for.next, %loop ]\n %iv.next = add i16 %iv, 1\n %gep.src = getelementptr inbounds i24, ptr %src, i16 %iv\n %for.next = load i24, ptr %gep.src, align 1\n %gep.dst = getelementptr inbounds i24, ptr %dst, i16 %iv\n store i24 %for, ptr %gep.dst\n %ec = icmp eq i16 %iv.next, 1000\n br i1 %ec, label %exit, label %loop\n\nexit:\n ret void\n}",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "Assertion \"Request for a fixed element count on a scalable object\" failed, vectorizer crashing with -Rpass=loop-vectorize",
"body": "Ran into a crash recently with the vectorizer while trying to build something. Note that this crash only happens if -Rpass=loop-vectorize is enabled.\n\nReproducer: https://godbolt.org/z/Ms47v6Eea\nNote: using the x86 trunk for the assertions build since there doesn't seem to one for armv8-a.\n\nCan't seem to reproduce it while giving the resulting IR into llc to produce assembly.\n\nSeems to be associated with commit 1858532c48cf5d93aa82966110fe1cada6ab6ba8 (tag: @fhahn ).\n\nSource C code used to produce the issue:\n\n```\nvoid foo(int *a, int *b, int *c) {\n int i;\n int temp;\n int *ptr = a;\n\n long qval;\n\n for (i = 0; i < 64; i++) {\n qval = b[i];\n temp = c[i];\n if (temp < 0) {\n temp += qval >> 1;\n temp /= qval;\n }\n ptr[i] = temp;\n }\n}\n\nint main(int argc, char **argv) {\n int a[] = {5, 3, 4, 5, 6, 7, 6};\n int b[] = {0, 1, 2, 3, 4, 5, 6};\n int c[] = {1, 2, 3, 4, 5, 6, 7};\n foo(a, b, c);\n return 0;\n}\n```\n`clang -march=armv8-a+sve -O3 -Rpass=loop-vectorize test.c -o test.s`",
"author": "namikukr-qc",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true
|
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
|
de7e3a589525179f3b02b84b194aac6cf581425c
| null |
160396
|
https://github.com/llvm/llvm-project/issues/160396
|
crash
|
2f5d5a3f748391f85cfa33702a247d42549f7b9d
| 2025-09-23T21:07:51
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "70a26da63992142ba2221f1034048ea883cdcb3d",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
[
2195,
2201
],
[
3566,
3578
]
],
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": [
[
705,
710
],
[
1494,
1502
],
[
1504,
1514
]
],
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": [
[
2016,
2028
]
],
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
"VPlanTransforms::truncateToMinimalBitwidths",
"tryToMatchAndCreateMulAccumulateReduction"
],
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": [
"VPIRFlags::flagsValidForOpcode"
],
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": [
"VPIRFlags",
"VPWidenCastRecipe",
"clone"
],
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 70a26da63992142ba2221f1034048ea883cdcb3d
Author: Florian Hahn <flo@fhahn.com>
Date: Thu Sep 25 09:00:45 2025 +0100
[VPlan] Set correct flags when creating and cloning VPWidenCastRecipe.
Make sure that we set the correct wrap flags when creating new
VPWidenCastRecipes for truncs and preserve the flags from the recipe
directly when cloning, to make sure they are not dropped.
Fixes https://github.com/llvm/llvm-project/issues/160396
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index e64cefde81e3..0822511150e9 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -705,6 +705,9 @@ public:
VPIRFlags(WrapFlagsTy WrapFlags)
: OpType(OperationType::OverflowingBinOp), WrapFlags(WrapFlags) {}
+ VPIRFlags(TruncFlagsTy TruncFlags)
+ : OpType(OperationType::Trunc), TruncFlags(TruncFlags) {}
+
VPIRFlags(FastMathFlags FMFs) : OpType(OperationType::FPMathOp), FMFs(FMFs) {}
VPIRFlags(DisjointFlagsTy DisjointFlags)
@@ -1494,9 +1497,10 @@ public:
VPWidenCastRecipe(Instruction::CastOps Opcode, VPValue *Op, Type *ResultTy,
const VPIRFlags &Flags = {},
+ const VPIRMetadata &Metadata = {},
DebugLoc DL = DebugLoc::getUnknown())
: VPRecipeWithIRFlags(VPDef::VPWidenCastSC, Op, Flags, DL),
- VPIRMetadata(), Opcode(Opcode), ResultTy(ResultTy) {
+ VPIRMetadata(Metadata), Opcode(Opcode), ResultTy(ResultTy) {
assert(flagsValidForOpcode(Opcode) &&
"Set flags not supported for the provided opcode");
}
@@ -1504,11 +1508,11 @@ public:
~VPWidenCastRecipe() override = default;
VPWidenCastRecipe *clone() override {
+ auto *New = new VPWidenCastRecipe(Opcode, getOperand(0), ResultTy, *this,
+ *this, getDebugLoc());
if (auto *UV = getUnderlyingValue())
- return new VPWidenCastRecipe(Opcode, getOperand(0), ResultTy,
- *cast<CastInst>(UV));
-
- return new VPWidenCastRecipe(Opcode, getOperand(0), ResultTy);
+ New->setUnderlyingValue(UV);
+ return New;
}
VP_CLASSOF_IMPL(VPDef::VPWidenCastSC)
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index aa3de3613b68..deb64bfc7506 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -2016,13 +2016,13 @@ bool VPIRFlags::flagsValidForOpcode(unsigned Opcode) const {
return Opcode == Instruction::FAdd || Opcode == Instruction::FMul ||
Opcode == Instruction::FSub || Opcode == Instruction::FNeg ||
Opcode == Instruction::FDiv || Opcode == Instruction::FRem ||
+ Opcode == Instruction::FPExt || Opcode == Instruction::FPTrunc ||
Opcode == Instruction::FCmp || Opcode == Instruction::Select ||
Opcode == VPInstruction::WideIVStep ||
Opcode == VPInstruction::ReductionStartVector ||
Opcode == VPInstruction::ComputeReductionResult;
case OperationType::NonNegOp:
- return Opcode == Instruction::ZExt;
- break;
+ return Opcode == Instruction::ZExt || Opcode == Instruction::UIToFP;
case OperationType::Cmp:
return Opcode == Instruction::FCmp || Opcode == Instruction::ICmp;
case OperationType::Other:
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 84f02059743c..58fab8f222d2 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -2195,7 +2195,8 @@ void VPlanTransforms::truncateToMinimalBitwidths(
auto [ProcessedIter, IterIsEmpty] = ProcessedTruncs.try_emplace(Op);
VPWidenCastRecipe *NewOp =
IterIsEmpty
- ? new VPWidenCastRecipe(Instruction::Trunc, Op, NewResTy)
+ ? new VPWidenCastRecipe(Instruction::Trunc, Op, NewResTy,
+ VPIRFlags::TruncFlagsTy(false, false))
: ProcessedIter->second;
R.setOperand(Idx, NewOp);
if (!IterIsEmpty)
@@ -3566,13 +3567,13 @@ tryToMatchAndCreateMulAccumulateReduction(VPReductionRecipe *Red,
Mul, Ext0, Ext1, Ext)) {
auto *NewExt0 = new VPWidenCastRecipe(
Ext0->getOpcode(), Ext0->getOperand(0), Ext->getResultType(), *Ext0,
- Ext0->getDebugLoc());
+ *Ext0, Ext0->getDebugLoc());
NewExt0->insertBefore(Ext0);
VPWidenCastRecipe *NewExt1 = NewExt0;
if (Ext0 != Ext1) {
NewExt1 = new VPWidenCastRecipe(Ext1->getOpcode(), Ext1->getOperand(0),
- Ext->getResultType(), *Ext1,
+ Ext->getResultType(), *Ext1, *Ext1,
Ext1->getDebugLoc());
NewExt1->insertBefore(Ext1);
}
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/cse-casts.ll",
"commands": [
"opt -p loop-vectorize -force-vector-width=4 -force-vector-interleave=2 -S %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine i8 @preserve_flags_when_cloning_trunc(i8 %start, ptr noalias %src, ptr noalias %dst) {\n;\nentry:\n br label %loop\n\nloop:\n %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]\n %red = phi i8 [ %red.next, %loop ], [ %start, %entry ]\n %l = load i32, ptr %src, align 4\n %cmp = icmp ne i32 %l, 0\n %cmp.ext = zext i1 %cmp to i64\n %cmp.trunc = trunc i64 %cmp.ext to i16\n %gep.dst = getelementptr i16, ptr %dst, i64 %iv\n store i16 %cmp.trunc, ptr %gep.dst, align 2\n %red.next = mul i8 %red, 3\n %iv.next = add i64 %iv, 1\n %ec = icmp ult i64 %iv, 416\n br i1 %ec, label %loop, label %exit\n\nexit:\n ret i8 %red.next\n}\n\n\ndefine void @preserve_flags_narrowing_extends_and_truncs(ptr noalias %A, ptr noalias %B, ptr noalias %C) {\n;\nentry:\n br label %loop\n\nloop:\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep.A = getelementptr inbounds i8, ptr %A, i64 %iv\n %l = load i8, ptr %gep.A\n %l.ext = zext i8 %l to i64\n %gep.C = getelementptr inbounds i8, ptr %C, i64 %iv\n store i64 %l.ext, ptr %gep.C\n %gep.B = getelementptr inbounds i8, ptr %B, i64 %iv\n %l.1 = load i8, ptr %gep.B, align 1\n %masked = and i8 %l.1, 1\n %l.1.trunc = trunc i8 %l.1 to i1\n %sel.0 = select i1 %l.1.trunc, float 1.000000e+00, float 0.000000e+00\n %masked.trunc = trunc i8 %masked to i1\n %sel.1 = select i1 %masked.trunc, float 3.000000e+00, float %sel.0\n %bc = bitcast float %sel.1 to i32\n %bc.trunc = trunc i32 %bc to i8\n store i8 %bc.trunc, ptr %gep.B, align 1\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv, 1\n br i1 %ec, label %exit, label %loop\n\nexit:\n ret void\n}",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[LoopVectorize] Assertion `OpType == Other.OpType && \"OpType must match\"' failed.",
"body": "Testcase:\n```llvm ir\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine i8 @c() #0 {\nentry:\n br label %for.cond1.preheader.us\n\nfor.cond1.preheader.us: ; preds = %for.cond1.preheader.us, %entry\n %indvars.iv = phi i64 [ %indvars.iv.next, %for.cond1.preheader.us ], [ 0, %entry ]\n %.us-phi4748.us = phi i8 [ %mul.us54, %for.cond1.preheader.us ], [ 0, %entry ]\n %arrayidx12.us = getelementptr [6 x [6 x i16]], ptr null, i64 %indvars.iv\n %0 = load i32, ptr null, align 4\n %tobool9.us52 = icmp ne i32 %0, 0\n %1 = zext i1 %tobool9.us52 to i64\n %conv11.us53 = trunc i64 %1 to i16\n store i16 %conv11.us53, ptr %arrayidx12.us, align 2\n %mul.us54 = mul i8 %.us-phi4748.us, 0\n %indvars.iv.next = add i64 %indvars.iv, 1\n %cmp.us = icmp ult i64 %indvars.iv, 416\n br i1 %cmp.us, label %for.cond1.preheader.us, label %for.cond.cleanup.sink.split.loopexit81\n\nfor.cond.cleanup.sink.split.loopexit81: ; preds = %for.cond1.preheader.us\n ret i8 %mul.us54\n}\n\nattributes #0 = { \"target-features\"=\"+v\" }\n```\nCommands/backtrace:\n```\n$ /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt --passes=loop-vectorize reduced.ll\nWARNING: You're attempting to print out a bitcode file.\nThis is inadvisable as it may cause display problems. If\nyou REALLY want to taste LLVM bitcode first-hand, you\ncan force output with the `-f' option.\n\nopt: /scratch/ewlu/daily-upstream-build/llvm/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp:396: void llvm::VPIRFlags::intersectFlags(const llvm::VPIRFlags&): Assertion `OpType == Other.OpType && \"OpType must match\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.\nStack dump:\n0. Program arguments: /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt --passes=loop-vectorize reduced.ll\n1. Running pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"reduced.ll\"\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"c\"\n #0 0x0000588c53884c12 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x33ffc12)\n #1 0x0000588c5388190f llvm::sys::RunSignalHandlers() (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x33fc90f)\n #2 0x0000588c53881a5c SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #3 0x0000750611645330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)\n #4 0x000075061169eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #5 0x000075061169eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #6 0x000075061169eb2c pthread_kill ./nptl/pthread_kill.c:89:10\n #7 0x000075061164527e raise ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x00007506116288ff abort ./stdlib/abort.c:81:7\n #9 0x000075061162881b _nl_load_domain ./intl/loadmsgcat.c:1177:9\n#10 0x000075061163b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)\n#11 0x0000588c51656fcc (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x11d1fcc)\n#12 0x0000588c516a53e6 llvm::VPlanTransforms::cse(llvm::VPlan&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x12203e6)\n#13 0x0000588c5148525a llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x100025a)\n#14 0x0000588c514a3d58 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x101ed58)\n#15 0x0000588c514a6601 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x1021601)\n#16 0x0000588c514a6c16 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x1021c16)\n#17 0x0000588c50d36865 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x8b1865)\n#18 0x0000588c53664155 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x31df155)\n#19 0x0000588c50d39095 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x8b4095)\n#20 0x0000588c53662741 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x31dd741)\n#21 0x0000588c509c3515 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x53e515)\n#22 0x0000588c53662f2d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x31ddf2d)\n#23 0x0000588c509cf599 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x54a599)\n#24 0x0000588c509c16ed optMain (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x53c6ed)\n#25 0x000075061162a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3\n#26 0x000075061162a28b call_init ./csu/../csu/libc-start.c:128:20\n#27 0x000075061162a28b __libc_start_main ./csu/../csu/libc-start.c:347:5\n#28 0x0000588c509b7615 _start (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x532615)\nAborted\n```\n\nGodbolt: https://godbolt.org/z/qn5rr7xn9\n\nFound via fuzzer",
"author": "ewlu",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true
|
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
|
c3e76b27709f93c9e945caa29dae596b581289e2
| 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/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
[
7521,
7526
]
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"LoopVectorizationPlanner::computeBestVF"
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 144bdf3eb7128518ed162c5a168e3ec90922cd9e
Author: Florian Hahn <flo@fhahn.com>
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
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
1d9b3222f3de7bad4ef27b7e4d7798f840097380
| null |
89669
|
https://github.com/llvm/llvm-project/issues/89669
|
miscompilation
|
d97cdd7d088b11b45038112a5f7fe5cbf60a6461
| 2024-04-22T21:27:36
|
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "a1b1c4a6d1d52916c5d885170a5f54632d579cdc",
"components": [
"InstCombine",
"ValueTracking"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": [
[
131,
137
]
],
"llvm/lib/Analysis/ValueTracking.cpp": [
[
8042,
8058
]
],
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": [
[
320,
326
]
],
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": [
"llvm::isKnownNegation",
"matchMinMax"
],
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": [
"Negator::visitImpl"
],
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit a1b1c4a6d1d52916c5d885170a5f54632d579cdc
Author: Nikita Popov <npopov@redhat.com>
Date: Wed Apr 24 10:56:26 2024 +0900
[InstCombine] Fix miscompile in negation of select (#89698)
Swapping the operands of a select is not valid if one hand is more
poisonous that the other, because the negation zero contains poison
elements.
Fix this by adding an extra parameter to isKnownNegation() to forbid
poison elements.
I've implemented this using manual checks to avoid needing four variants
for the NeedsNSW/AllowPoison combinations. Maybe there is a better way
to do this...
Fixes https://github.com/llvm/llvm-project/issues/89669.
diff --git a/llvm/include/llvm/Analysis/ValueTracking.h b/llvm/include/llvm/Analysis/ValueTracking.h
index a2fa8f6064e1..571e44cdac26 100644
--- a/llvm/include/llvm/Analysis/ValueTracking.h
+++ b/llvm/include/llvm/Analysis/ValueTracking.h
@@ -131,7 +131,8 @@ bool isKnownNonZero(const Value *V, const SimplifyQuery &Q, unsigned Depth = 0);
/// Currently can recoginze Value pair:
/// 1: <X, Y> if X = sub (0, Y) or Y = sub (0, X)
/// 2: <X, Y> if X = sub (A, B) and Y = sub (B, A)
-bool isKnownNegation(const Value *X, const Value *Y, bool NeedNSW = false);
+bool isKnownNegation(const Value *X, const Value *Y, bool NeedNSW = false,
+ bool AllowPoison = true);
/// Returns true if the give value is known to be non-negative.
bool isKnownNonNegative(const Value *V, const SimplifyQuery &SQ,
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 21e3f8a4cc52..7501f78ca23b 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -8042,17 +8042,27 @@ static SelectPatternResult matchMinMax(CmpInst::Predicate Pred,
return {SPF_UNKNOWN, SPNB_NA, false};
}
-bool llvm::isKnownNegation(const Value *X, const Value *Y, bool NeedNSW) {
+bool llvm::isKnownNegation(const Value *X, const Value *Y, bool NeedNSW,
+ bool AllowPoison) {
assert(X && Y && "Invalid operand");
- // X = sub (0, Y) || X = sub nsw (0, Y)
- if ((!NeedNSW && match(X, m_Sub(m_ZeroInt(), m_Specific(Y)))) ||
- (NeedNSW && match(X, m_NSWNeg(m_Specific(Y)))))
+ auto IsNegationOf = [&](const Value *X, const Value *Y) {
+ if (!match(X, m_Neg(m_Specific(Y))))
+ return false;
+
+ auto *BO = cast<BinaryOperator>(X);
+ if (NeedNSW && !BO->hasNoSignedWrap())
+ return false;
+
+ auto *Zero = cast<Constant>(BO->getOperand(0));
+ if (!AllowPoison && !Zero->isNullValue())
+ return false;
+
return true;
+ };
- // Y = sub (0, X) || Y = sub nsw (0, X)
- if ((!NeedNSW && match(Y, m_Sub(m_ZeroInt(), m_Specific(X)))) ||
- (NeedNSW && match(Y, m_NSWNeg(m_Specific(X)))))
+ // X = -Y or Y = -X
+ if (IsNegationOf(X, Y) || IsNegationOf(Y, X))
return true;
// X = sub (A, B), Y = sub (B, A) || X = sub nsw (A, B), Y = sub nsw (B, A)
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp b/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp
index d697f361dec0..ed2a98ba4ae4 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp
@@ -320,7 +320,8 @@ std::array<Value *, 2> Negator::getSortedOperandsOfBinOp(Instruction *I) {
return NegatedPHI;
}
case Instruction::Select: {
- if (isKnownNegation(I->getOperand(1), I->getOperand(2))) {
+ if (isKnownNegation(I->getOperand(1), I->getOperand(2), /*NeedNSW=*/false,
+ /*AllowPoison=*/false)) {
// Of one hand of select is known to be negation of another hand,
// just swap the hands around.
auto *NewSelect = cast<SelectInst>(I->clone());
|
[
{
"file": "llvm/test/Transforms/InstCombine/sub-of-negatible.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "negate_select_of_negation_poison",
"test_body": "define <2 x i32> @negate_select_of_negation_poison(<2 x i1> %c, <2 x i32> %x) {\n %neg = sub <2 x i32> <i32 0, i32 poison>, %x\n %sel = select <2 x i1> %c, <2 x i32> %neg, <2 x i32> %x\n %neg2 = sub <2 x i32> zeroinitializer, %sel\n ret <2 x i32> %neg2\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "dont_negate_ordinary_select",
"test_body": "define i8 @dont_negate_ordinary_select(i8 %x, i8 %y, i8 %z, i1 %c) {\n %t0 = select i1 %c, i8 %x, i8 %y\n %t1 = sub i8 %z, %t0\n ret i8 %t1\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "miscompile of vector double-negation + select by InstCombine",
"body": "https://alive2.llvm.org/ce/z/N1RVAr\r\n\r\nthis:\r\n```llvm\r\ndefine <4 x i32> @f(<4 x i32> %0) {\r\n %2 = sub <4 x i32> zeroinitializer, %0\r\n %3 = select <4 x i1> <i1 false, i1 true, i1 poison, i1 poison>, <4 x i32> %2, <4 x i32> %0\r\n %4 = sub <4 x i32> zeroinitializer, %3\r\n ret <4 x i32> %4\r\n}\r\n```\r\nis being optimized to:\r\n```llvm\r\ndefine <4 x i32> @f(<4 x i32> %0) {\r\n ret <4 x i32> %0\r\n}\r\n```\r\nhere's Alive's work explaining why this is wrong:\r\n```\r\nERROR: Value mismatch\r\n\r\nExample:\r\n<4 x i32> %#0 = < #x00000001 (1), poison, poison, poison >\r\n\r\nSource:\r\n<4 x i32> %#2 = < #xffffffff (4294967295, -1), poison, poison, poison >\r\n<4 x i32> %#3 = < #x00000001 (1), poison, poison, poison >\r\n<4 x i32> %#4 = < #xffffffff (4294967295, -1), poison, poison, poison >\r\n\r\nTarget:\r\nSource value: < #xffffffff (4294967295, -1), poison, poison, poison >\r\nTarget value: < #x00000001 (1), poison, poison, poison >\r\n```\r\n\r\ncc @nunoplopes @hatsunespica\r\n\r\n",
"author": "regehr",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": [
{
"author": "topperc",
"body": "I think the problem is this code in Negator::visitImpl.\r\n\r\n```\r\n case Instruction::Select: {\r\n if (isKnownNegation(I->getOperand(1), I->getOperand(2))) { \r\n // Of one hand of select is known to be negation of another hand, \r\n // just swap the hands around. \r\n auto *NewSelect = cast<SelectInst>(I->clone()); \r\n // Just swap the operands of the select. \r\n NewSelect->swapValues(); \r\n // Don't swap prof metadata, we didn't change the branch behavior. \r\n NewSelect->setName(I->getName() + \".neg\"); \r\n Builder.Insert(NewSelect); \r\n return NewSelect; \r\n } \r\n```\r\n\r\nThe IR at the time of that code running was\r\n```\r\n%2 = sub <4 x i32> <i32 poison, i32 0, i32 0, i32 0>, %0\r\n%3 = select <4 x i1> <i1 false, i1 true, i1 poison, i1 poison>, <4 x i32> %2, <4 x i32> %0\r\n%4 = sub <4 x i32> zeroinitializer, %3\r\n```\r\n\r\nSo operand element 0 of %2 is poison. This occurred because element 0 isn't selected so SimplifiedDemandedVectorElts replaced with poison.\r\n\r\nOnce Negator swaps the operands, now element 1 of %2 is never selected so we end up with `sub <4 x i32> poison, %0`\r\n\r\nIt doesn't look like swapping the operands of the select is poison safe.\r\n\r\nCC @nikic "
},
{
"author": "nikic",
"body": "Yeah, that analysis sounds right to me. With that in mind, a more direct test case would be:\r\n```llvm\r\ndefine <2 x i32> @f(<2 x i1> %c, <2 x i32> %x) {\r\n %neg = sub <2 x i32> <i32 0, i32 poison>, %x\r\n %sel = select <2 x i1> %c, <2 x i32> %neg, <2 x i32> %x\r\n %neg2 = sub <2 x i32> zeroinitializer, %sel\r\n ret <2 x i32> %neg2\r\n}\r\n```"
},
{
"author": "regehr",
"body": "off topic but do we want an llvm-reduce pass that shrinks vectors? and maybe also shrinks lane sizes? if so I could work on that sort of thing this summer"
},
{
"author": "XChy",
"body": "> off topic but do we want an llvm-reduce pass that shrinks vectors? and maybe also shrinks lane sizes? if so I could work on that sort of thing this summer\r\n\r\nSounds great to me. I think some SLPVectorizer testcases that involve 16 or even 32 lanes should be further reduced."
}
]
}
| true
|
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
|
Cannot find a good commit
| null |
157314
|
https://github.com/llvm/llvm-project/issues/157314
|
crash
|
9fe1f29541109ac10e1399deb85da0507135f836
| 2025-09-06T20:54:43
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "b4dbb1cdc46bfe41244f4313582ce3270f5fe845",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
[
2012,
2018
],
[
2089,
2094
]
],
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
"getOpcodeOrIntrinsicID",
"isEqual"
],
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit b4dbb1cdc46bfe41244f4313582ce3270f5fe845
Author: Florian Hahn <flo@fhahn.com>
Date: Mon Oct 20 11:53:47 2025 +0100
[VPlan] Be more careful with CSE in replicate regions. (#162110)
Recipes in replicate regions implicitly depend on the region's
predicate. Limit CSE to recipes in the same block, when either recipe is
in a replicate region.
This allows handling VPPredInstPHIRecipe during CSE. If we perform CSE
on recipes inside a replicate region, we may end up with 2
VPPredInstPHIRecipes sharing the same operand. This is incompatible with
current VPPredInstPHIRecipe codegen, which re-sets the current value of
its operand in VPTransformState. This can cause crashes in the added
test cases.
Note that this patch only modifies ::isEqual to check for replicating
regions and not getHash, as CSE across replicating regions should be
uncommon.
Fixes https://github.com/llvm/llvm-project/issues/157314.
Fixes https://github.com/llvm/llvm-project/issues/161974.
PR: https://github.com/llvm/llvm-project/pull/162110
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 64bbe630e317..e060e7081042 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -2012,7 +2012,7 @@ struct VPCSEDenseMapInfo : public DenseMapInfo<VPSingleDefRecipe *> {
.Case<VPWidenIntrinsicRecipe>([](auto *I) {
return std::make_pair(true, I->getVectorIntrinsicID());
})
- .Case<VPVectorPointerRecipe>([](auto *I) {
+ .Case<VPVectorPointerRecipe, VPPredInstPHIRecipe>([](auto *I) {
// For recipes that do not directly map to LLVM IR instructions,
// assign opcodes after the last VPInstruction opcode (which is also
// after the last IR Instruction opcode), based on the VPDefID.
@@ -2089,6 +2089,15 @@ struct VPCSEDenseMapInfo : public DenseMapInfo<VPSingleDefRecipe *> {
LFlags->getPredicate() !=
cast<VPRecipeWithIRFlags>(R)->getPredicate())
return false;
+ // Recipes in replicate regions implicitly depend on predicate. If either
+ // recipe is in a replicate region, only consider them equal if both have
+ // the same parent.
+ const VPRegionBlock *RegionL = L->getParent()->getParent();
+ const VPRegionBlock *RegionR = R->getParent()->getParent();
+ if (((RegionL && RegionL->isReplicator()) ||
+ (RegionR && RegionR->isReplicator())) &&
+ L->getParent() != R->getParent())
+ return false;
const VPlan *Plan = L->getParent()->getPlan();
VPTypeAnalysis TypeInfo(*Plan);
return TypeInfo.inferScalarType(L) == TypeInfo.inferScalarType(R);
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/cse-replicate-regions.ll",
"commands": [
"opt -p loop-vectorize -force-vector-width=2 -force-widen-divrem-via-safe-divisor=false -S %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @multiple_vppredinstphi_with_same_predicate(ptr %A, i32 %d) {\n;\nentry:\n br label %loop.header\n\nloop.header:\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %gep.A = getelementptr inbounds i32, ptr %A, i32 %iv\n %l = load i32, ptr %gep.A\n %c = icmp sgt i32 %l, 0\n br i1 %c, label %then, label %loop.latch\n\nthen:\n %div.0 = sdiv i32 -10, %d\n %div.1 = sdiv i32 -10, %d\n %add = add i32 %div.1, %div.0\n br label %loop.latch\n\nloop.latch:\n %merge = phi i32 [ %add, %then ], [ 0, %loop.header ]\n store i32 %merge, ptr %gep.A\n %iv.next = add i32 %iv, 1\n %ec = icmp eq i32 %iv.next, 100\n br i1 %ec, label %exit, label %loop.header\n\nexit:\n ret void\n}\n\ndefine void @multiple_vppredinstphi_with_different_predicate(ptr %A, i32 %d) {\n;\nentry:\n br label %loop.header\n\nloop.header:\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %gep.A = getelementptr inbounds i32, ptr %A, i32 %iv\n %l = load i32, ptr %gep.A\n %c.0 = icmp sgt i32 %l, 0\n br i1 %c.0, label %then.0, label %continue\n\nthen.0:\n %div.0 = sdiv i32 -10, %d\n br label %continue\n\ncontinue:\n %merge.0 = phi i32 [ %div.0, %then.0 ], [ 0, %loop.header ]\n %c.1 = icmp sgt i32 %l, 20\n br i1 %c.1, label %then.1, label %loop.latch\n\nthen.1:\n %div.1 = sdiv i32 -10, %d\n br label %loop.latch\n\nloop.latch:\n %merge.1 = phi i32 [ %div.1, %then.1 ], [ 0, %continue ]\n %add = add i32 %merge.0, %merge.1\n store i32 %add, ptr %gep.A\n %iv.next = add i32 %iv, 1\n %ec = icmp eq i32 %iv.next, 100\n br i1 %ec, label %exit, label %loop.header\n\nexit:\n ret void\n}",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[LoopVectorize] Assertion `isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"' failed.",
"body": "Reproducer: https://godbolt.org/z/Wqj66T1xq\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 i32 @main(ptr %p) {\nentry:\n %conv518.i.i = trunc i32 8 to i8\n %conv517.i.i = and i8 0, 0\n br label %for.cond418.preheader.i.i\n\nfor.cond418.preheader.i.i: ; preds = %for.inc781.3.i.i, %entry\n %storemerge982.i.i = phi i32 [ 0, %entry ], [ %inc802.i.i, %for.inc781.3.i.i ]\n br i1 false, label %for.inc781.3.i.i, label %safe_mod_func_int8_t_s_s.exit925.i.i\n\nsafe_mod_func_int8_t_s_s.exit925.i.i: ; preds = %for.cond418.preheader.i.i\n %rem16.i923945.i.i = srem i8 %conv517.i.i, %conv518.i.i\n %rem16.i923945.1.i.i = srem i8 %conv517.i.i, %conv518.i.i\n %0 = or i8 %rem16.i923945.i.i, %rem16.i923945.1.i.i\n %.not4006 = icmp eq i8 %0, 0\n br i1 %.not4006, label %for.inc781.3.i.i, label %1\n\n1: ; preds = %safe_mod_func_int8_t_s_s.exit925.i.i\n store i16 0, ptr %p, align 2\n br label %for.inc781.3.i.i\n\nfor.inc781.3.i.i: ; preds = %1, %safe_mod_func_int8_t_s_s.exit925.i.i, %for.cond418.preheader.i.i\n %inc802.i.i = add i32 %storemerge982.i.i, 1\n %cmp31.not.i.i = icmp eq i32 %storemerge982.i.i, 1\n br i1 %cmp31.not.i.i, label %if.then.i, label %for.cond418.preheader.i.i\n\nif.then.i: ; preds = %for.inc781.3.i.i\n ret i32 0\n}\n\n```\n```\nopt: /root/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From*) [with To = llvm::InsertElementInst; From = llvm::Value]: Assertion `isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"' failed.\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=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 \"main\"\n #0 0x00000000057a4688 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x57a4688)\n #1 0x00000000057a1534 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007fe33d442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007fe33d4969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007fe33d442476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007fe33d4287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x00007fe33d42871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x00007fe33d439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x00000000036de712 llvm::VPPredInstPHIRecipe::execute(llvm::VPTransformState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x36de712)\n #9 0x00000000036846a3 llvm::VPBasicBlock::executeRecipes(llvm::VPTransformState*, llvm::BasicBlock*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x36846a3)\n#10 0x000000000369a3be llvm::VPBasicBlock::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x369a3be)\n#11 0x000000000368e1e1 llvm::VPRegionBlock::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x368e1e1)\n#12 0x00000000036a0219 llvm::VPlan::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x36a0219)\n#13 0x0000000003512c88 llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3512c88)\n#14 0x0000000003532d63 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3532d63)\n#15 0x0000000003534da0 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3534da0)\n#16 0x000000000353544d llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x353544d)\n#17 0x0000000002e2b1ee 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+0x2e2b1ee)\n#18 0x00000000055904d1 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x55904d1)\n#19 0x0000000000ee0cbe 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+0xee0cbe)\n#20 0x000000000558ea3a llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x558ea3a)\n#21 0x000000000096d5ae 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+0x96d5ae)\n#22 0x000000000558e3f1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x558e3f1)\n#23 0x00000000009778a8 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9778a8)\n#24 0x000000000096b917 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x96b917)\n#25 0x00007fe33d429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#26 0x00007fe33d429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#27 0x0000000000962a35 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x962a35)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```",
"author": "dtcxzyw",
"labels": [
"vectorizers",
"crash-on-valid",
"generated by fuzzer"
],
"comments": [
{
"author": "AbhinavMir",
"body": "I'd like to investigate this issue. I can reproduce the crash locally and will start debugging.\n\nEdit: I was able to reproduce, seems like I can come up with a solution!"
},
{
"author": "dtcxzyw",
"body": "@AbhinavMir I am not an expert on LoopVectorize. You can ask for help from @fhahn :)"
},
{
"author": "fhahn",
"body": "@AbhinavMir yes feel free to reach out. Did you manage to come up with a fix?"
},
{
"author": "AbhinavMir",
"body": "@fhahn Hi, yes! I did come up with one! Was just busy, sending in a fix!"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
|
d8fd51148069bdea95974b3877abc31bcf5bf5ab
| null |
165252
|
https://github.com/llvm/llvm-project/issues/165252
|
crash
|
c03d0fe672b2506d22d101cb7704996f4ffda3e4
| 2025-10-27T13:57:20
|
[
"llvm/test/Transforms/UnifyLoopExits"
] |
{
"fix_commit": "2c7cf896be28febcd2f9af1b0dfdb5dfc6b97583",
"components": [
"ControlFlowUtils",
"UnifyLoopExits"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": [
[
299,
304
]
],
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": [
[
154,
161
]
],
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": [
"ControlFlowHub::finalize"
],
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": [
"unifyLoopExits"
],
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 2c7cf896be28febcd2f9af1b0dfdb5dfc6b97583
Author: Miguel Saldivar <saldivarcher@gmail.com>
Date: Sun Jan 25 16:31:28 2026 -0800
[llvm][UnifyLoopExits] Avoid optimization if no exit block is found (#165343)
If there is not an exit block, we should not try unify the loops.
Instead we should just return.
Fixes #165252
diff --git a/llvm/lib/Transforms/Utils/ControlFlowUtils.cpp b/llvm/lib/Transforms/Utils/ControlFlowUtils.cpp
index f728e9f18af5..8de83cc3700c 100644
--- a/llvm/lib/Transforms/Utils/ControlFlowUtils.cpp
+++ b/llvm/lib/Transforms/Utils/ControlFlowUtils.cpp
@@ -299,6 +299,8 @@ std::pair<BasicBlock *, bool> ControlFlowHub::finalize(
Outgoing.insert(Succ1);
}
+ assert(Outgoing.size() && "No outgoing edges");
+
if (Outgoing.size() < 2)
return {Outgoing.front(), false};
diff --git a/llvm/lib/Transforms/Utils/UnifyLoopExits.cpp b/llvm/lib/Transforms/Utils/UnifyLoopExits.cpp
index e86ab13094b1..21baf4ec1d03 100644
--- a/llvm/lib/Transforms/Utils/UnifyLoopExits.cpp
+++ b/llvm/lib/Transforms/Utils/UnifyLoopExits.cpp
@@ -154,8 +154,13 @@ static bool unifyLoopExits(DominatorTree &DT, LoopInfo &LI, Loop *L) {
SmallVector<BasicBlock *, 8> ExitingBlocks;
L->getExitingBlocks(ExitingBlocks);
+ // No exit blocks, so nothing to do. Just return.
+ if (ExitingBlocks.empty())
+ return false;
+
DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Eager);
SmallVector<BasicBlock *, 8> CallBrTargetBlocksToFix;
+
// Redirect exiting edges through a control flow hub.
ControlFlowHub CHub;
bool Changed = false;
|
[
{
"file": "llvm/test/Transforms/UnifyLoopExits/no-exit-blocks.ll",
"commands": [
"opt -passes=unify-loop-exits %s -S 2>&1"
],
"tests": [
{
"test_name": "<module>",
"test_body": "; Based from this issue: https://github.com/llvm/llvm-project/issues/165252\n\ndefine void @test() {\nentry:\n br i1 true, label %end, label %Loop\n\nLoop:\n %V = phi i32 [0, %entry], [%V1, %Loop]\n %V1 = add i32 %V, 1\n br label %Loop\n\nend:\n ret void\n}",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "unify-loop-exits pass: Assertion `!empty() && \"Cannot call front() on empty SetVector!\"' failed.",
"body": "Reproducer:\nhttps://godbolt.org/z/GET14Pbb8\n\nBacktrace:\n```console\nopt: /root/llvm-project/llvm/include/llvm/ADT/SetVector.h:132: const value_type& llvm::SetVector<T, Vector, Set, N>::front() const [with T = llvm::BasicBlock*; Vector = llvm::SmallVector<llvm::BasicBlock*, 0>; Set = llvm::DenseSet<llvm::BasicBlock*, llvm::DenseMapInfo<llvm::BasicBlock*, void> >; unsigned int N = 0; llvm::SetVector<T, Vector, Set, N>::value_type = llvm::BasicBlock*]: Assertion `!empty() && \"Cannot call front() on empty SetVector!\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=unify-loop-exits <source>\n1.\tRunning pass \"function(unify-loop-exits)\" on module \"<source>\"\n2.\tRunning pass \"unify-loop-exits\" on function \"test\"\n #0 0x0000000005975828 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5975828)\n #1 0x00000000059726d4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007d1723c42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007d1723c969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007d1723c42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007d1723c287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x00007d1723c2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x00007d1723c39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x0000000004c99174 llvm::ControlFlowHub::finalize(llvm::DomTreeUpdater*, llvm::SmallVectorImpl<llvm::BasicBlock*>&, llvm::StringRef, std::optional<unsigned int>) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4c99174)\n #9 0x0000000004c81693 unifyLoopExits(llvm::DominatorTree&, llvm::LoopInfo&, llvm::Loop*) UnifyLoopExits.cpp:0:0\n#10 0x0000000004c83a12 runImpl(llvm::LoopInfo&, llvm::DominatorTree&) UnifyLoopExits.cpp:0:0\n#11 0x0000000004c83f79 llvm::UnifyLoopExitsPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4c83f79)\n#12 0x0000000000efc39e llvm::detail::PassModel<llvm::Function, llvm::UnifyLoopExitsPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xefc39e)\n#13 0x000000000574f081 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x574f081)\n#14 0x0000000000efc57e 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+0xefc57e)\n#15 0x000000000574d6fa llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x574d6fa)\n#16 0x000000000097bade 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+0x97bade)\n#17 0x000000000574d0b1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x574d0b1)\n#18 0x0000000000985c7a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x985c7a)\n#19 0x0000000000979ef1 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x979ef1)\n#20 0x00007d1723c29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#21 0x00007d1723c29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#22 0x0000000000971305 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x971305)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```",
"author": "k-arrows",
"labels": [
"crash",
"llvm:transforms"
],
"comments": []
}
| true
|
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
| null | null |
137797
|
https://github.com/llvm/llvm-project/issues/137797
|
crash
|
368fbc21631a16b66a2a5609271c467a025a08b9
| 2025-04-29T12:24:21
|
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "3aecbbcbf675bc4472dafff18d29f21457323f28",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
15245,
15250
]
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::isGatherShuffledSingleRegisterEntry"
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 3aecbbcbf675bc4472dafff18d29f21457323f28
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Tue May 6 06:40:54 2025 -0700
[SLP]Do not match nodes if schedulability of parent nodes is different
If one user node is non-schedulable and another one is schedulable, such
nodes should be considered matched. The selection of the actual insert
point in this case differs and the insert points may match, which may
cause a compiler crash because of the broken def-use chain.
Fixes #137797
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 4d183bb42f0e..a6ae26f2f0e1 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -15245,6 +15245,11 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
continue;
}
+ if (!TEUseEI.UserTE->isGather() && !UserPHI &&
+ doesNotNeedToSchedule(TEUseEI.UserTE->Scalars) !=
+ doesNotNeedToSchedule(UseEI.UserTE->Scalars) &&
+ is_contained(UseEI.UserTE->Scalars, TEInsertPt))
+ continue;
// Check if the user node of the TE comes after user node of TEPtr,
// otherwise TEPtr depends on TE.
if ((TEInsertBlock != InsertPt->getParent() ||
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/matched-bv-schedulable.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s -slp-threshold=-99999"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @test() {\n;\nbb:\n br i1 false, label %bb1, label %bb5\n\nbb1:\n %phi = phi i32 [ %or4, %bb1 ], [ 0, %bb ]\n %phi2 = phi i32 [ %add, %bb1 ], [ 0, %bb ]\n %add = add i32 1, 0\n %or = or i32 0, %phi2\n %or3 = or i32 %or, 0\n %mul = mul i32 0, 0\n %or4 = or i32 %phi, %mul\n br i1 false, label %bb1, label %bb5\n\nbb5:\n %phi6 = phi i32 [ 0, %bb ], [ %or4, %bb1 ]\n %phi7 = phi i32 [ 0, %bb ], [ %or, %bb1 ]\n ret void\n}",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "Instruction does not dominate all uses! LLVM ERROR: Broken module found, compilation aborted!",
"body": "To reproduce run opt with the test below using -passes=slp-vectorizer -slp-threshold=-99999:\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 i1 false, label %bb1, label %bb5\n\nbb1: ; preds = %bb1, %bb\n %phi = phi i32 [ %or4, %bb1 ], [ 0, %bb ]\n %phi2 = phi i32 [ %add, %bb1 ], [ 0, %bb ]\n %add = add i32 1, 0\n %or = or i32 0, %phi2\n %or3 = or i32 %or, 0\n %mul = mul i32 0, 0\n %or4 = or i32 %phi, %mul\n br i1 false, label %bb1, label %bb5\n\nbb5: ; preds = %bb1, %bb\n %phi6 = phi i32 [ 0, %bb ], [ %or4, %bb1 ]\n %phi7 = phi i32 [ 0, %bb ], [ %or, %bb1 ]\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/YbPKn761h\nStack dump:\n```\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer -slp-threshold=-99999 <source>\n1.\tRunning pass \"verify\" on module \"<source>\"\n #0 0x00000000055242e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x55242e8)\n #1 0x0000000005521c74 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x000073e542242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x000073e5422969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x000073e542242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x000073e5422287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x000000000080a091 llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0\n #7 0x00000000054600e8 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x54600e8)\n #8 0x000000000535c8d8 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x535c8d8)\n #9 0x000000000093ee6e 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+0x93ee6e)\n#10 0x000000000531b5a0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x531b5a0)\n#11 0x00000000009492ba 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+0x9492ba)\n#12 0x000000000093ca8c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x93ca8c)\n#13 0x000073e542229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#14 0x000073e542229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#15 0x00000000009346c5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9346c5)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```\n",
"author": "TatyanaDoubts",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
123993fd974629ca0a094918db4c21ad1c2624d0
| null |
79742
|
https://github.com/llvm/llvm-project/issues/79742
|
crash
|
a9689c6029e3078e09e43a4efb2b2ced98e9020f
| 2024-01-28T09:40:40
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "17fb3e82f6c950267bb01cc2fd2a84b0d9e9d0d8",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
[
1031,
1037
],
[
1040,
1047
]
],
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
"VPlanTransforms::truncateToMinimalBitwidths"
],
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 17fb3e82f6c950267bb01cc2fd2a84b0d9e9d0d8
Author: Florian Hahn <flo@fhahn.com>
Date: Tue Apr 23 11:50:25 2024 +0100
[VPlan] Skip extending ICmp results in trunateToMinimalBitwidth.
Results of icmp don't need extending after truncating their operands, as
the result will always be i1. Skip them during extending.
Fixes https://github.com/llvm/llvm-project/issues/79742
Fixes https://github.com/llvm/llvm-project/issues/85185
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 007dc3f89b3f..9580dc4a27f6 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -1031,7 +1031,9 @@ void VPlanTransforms::truncateToMinimalBitwidths(
if (auto *VPW = dyn_cast<VPRecipeWithIRFlags>(&R))
VPW->dropPoisonGeneratingFlags();
- if (OldResSizeInBits != NewResSizeInBits) {
+ using namespace llvm::VPlanPatternMatch;
+ if (OldResSizeInBits != NewResSizeInBits &&
+ !match(&R, m_Binary<Instruction::ICmp>(m_VPValue(), m_VPValue()))) {
// Extend result to original width.
auto *Ext =
new VPWidenCastRecipe(Instruction::ZExt, ResultVPV, OldResTy);
@@ -1040,8 +1042,9 @@ void VPlanTransforms::truncateToMinimalBitwidths(
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.");
+ assert(
+ match(&R, m_Binary<Instruction::ICmp>(m_VPValue(), m_VPValue())) &&
+ "Only ICmps should not need extending the result.");
assert(!isa<VPWidenStoreRecipe>(&R) && "stores cannot be narrowed");
if (isa<VPWidenLoadRecipe>(&R))
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/trunc-extended-icmps.ll",
"commands": [
"opt -p loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -S %s"
],
"tests": [
{
"test_name": "test_icmp_and_op_zext",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine i32 @test_icmp_and_op_zext(ptr %dst, i64 %a) {\nentry:\n %and = and i64 %a, 7304878031173690989\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i16 [ 1, %entry ], [ %iv.next, %loop ]\n %c = icmp ne i64 %and, 0\n %c.ext = zext i1 %c to i64\n %or = or i64 %and, %c.ext\n %or.trunc = trunc i64 %or to i8\n %gep = getelementptr i8, ptr %dst, i16 %iv\n store i8 %or.trunc, ptr %gep, align 1\n %iv.next = add i16 %iv, 1\n %ec = icmp eq i16 %iv.next, 1000\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i32 0\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "ext_cmp",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine void @ext_cmp(ptr %src.1, ptr %src.2, ptr noalias %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep.src.1 = getelementptr inbounds i16, ptr %src.1, i64 %iv\n %i2 = load i16, ptr %gep.src.1, align 2\n %i3 = sext i16 %i2 to i32\n %c.1 = icmp sgt i32 0, %i3\n %gep.src.2 = getelementptr inbounds i8, ptr %src.2, i64 %iv\n %i4 = load i8, ptr %gep.src.2, align 2\n %i5 = zext i8 %i4 to i32\n %i6 = select i1 %c.1, i32 0, i32 %i5\n %i7 = and i32 %i6, 0\n %i8 = trunc nuw nsw i32 %i7 to i16\n %gep.dst = getelementptr inbounds i16, ptr %dst, i64 %iv\n store i16 %i8, ptr %gep.dst, align 2\n %iv.next = add nsw i64 %iv, 1\n %ec = icmp eq i64 %iv.next, 1000\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "test_icmp_constant_op_zext",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine i32 @test_icmp_constant_op_zext(ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i16 [ 1, %entry ], [ %iv.next, %loop ]\n %c = icmp ne i64 7304878031173690989, 0\n %c.ext = zext i1 %c to i64\n %or = or i64 7304878031173690989, %c.ext\n %or.trunc = trunc i64 %or to i8\n %gep = getelementptr i8, ptr %dst, i16 %iv\n store i8 %or.trunc, ptr %gep, align 1\n %iv.next = add i16 %iv, 1\n %ec = icmp eq i16 %iv.next, 1000\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i32 0\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "llvm crash on loop-vectorize: Assertion `OldResSizeInBits > NewResSizeInBits && \"Nothing to shrink?\"' failed.",
"body": "llvm crashes on the following IR.\r\n\r\nBisected to 822c749aec69ace75bd3923a4c850e2fd2e34fb1, which was committed by @fhahn \r\n\r\nCompiler explorer: https://godbolt.org/z/rWj9dhvPo\r\n\r\n```llvm\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine void @i(i64 %0) {\r\nentry:\r\n %conv = sext i16 1 to i32\r\n br label %for.body\r\n\r\nfor.body: ; preds = %for.body, %entry\r\n %1 = phi i32 [ 0, %entry ], [ %inc, %for.body ]\r\n %tobool.not.i = icmp eq i64 %0, 0\r\n %..i = select i1 %tobool.not.i, i32 0, i32 0\r\n %cmp = icmp eq i32 %..i, 0\r\n %conv1 = zext i1 %tobool.not.i to i32\r\n %or = or i32 %conv1, %conv\r\n %cmp2 = icmp slt i32 %or, 7\r\n %conv4 = zext i1 %cmp2 to i64\r\n store i64 %conv4, ptr null, align 8\r\n %inc = add i32 %1, 1\r\n %tobool.not = icmp eq i32 %inc, 0\r\n br i1 %tobool.not, label %for.cond.for.end_crit_edge, label %for.body\r\n\r\nfor.cond.for.end_crit_edge: ; preds = %for.body\r\n ret void\r\n}\r\n```\r\n\r\n```console\r\n% opt -passes=loop-vectorize reduced.ll\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: /zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/opt -disable-output -passes=loop-vectorize reduced.ll\r\n #0 0x00007f5302fedeff llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/../lib/libLLVM-18git.so+0x902eff)\r\n #1 0x00007f5302feb654 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007f5302300090 (/lib/x86_64-linux-gnu/libc.so.6+0x43090)\r\n #3 0x00007f5304a458f0 llvm::InnerLoopVectorizer::truncateToMinimalBitwidths(llvm::VPTransformState&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/../lib/libLLVM-18git.so+0x235a8f0)\r\n #4 0x00007f5304a49d95 llvm::InnerLoopVectorizer::fixVectorizedLoop(llvm::VPTransformState&, llvm::VPlan&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/../lib/libLLVM-18git.so+0x235ed95)\r\n #5 0x00007f5304a4abb1 llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool, llvm::DenseMap<llvm::SCEV const*, llvm::Value*, llvm::DenseMapInfo<llvm::SCEV const*, void>, llvm::detail::DenseMapPair<llvm::SCEV const*, llvm::Value*>>*) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/../lib/libLLVM-18git.so+0x235fbb1)\r\n #6 0x00007f5304a4d564 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/../lib/libLLVM-18git.so+0x2362564)\r\n #7 0x00007f5304a4fbdd 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*) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/../lib/libLLVM-18git.so+0x2364bdd)\r\n #8 0x00007f5304a50e20 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/../lib/libLLVM-18git.so+0x2365e20)\r\n #9 0x00007f5305e0d916 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/../lib/libLLVM-18git.so+0x3722916)\r\n#10 0x00007f53031fd3fd llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/../lib/libLLVM-18git.so+0xb123fd)\r\n#11 0x00007f5305e069f6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/../lib/libLLVM-18git.so+0x371b9f6)\r\n#12 0x00007f53031fbc8d llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/../lib/libLLVM-18git.so+0xb10c8d)\r\n#13 0x00007f5305e0d696 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/../lib/libLLVM-18git.so+0x3722696)\r\n#14 0x00007f53031f9c0d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/../lib/libLLVM-18git.so+0xb0ec0d)\r\n#15 0x0000555c5281fcb5 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/opt+0x25cb5)\r\n#16 0x0000555c52813876 main (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/opt+0x19876)\r\n#17 0x00007f53022e1083 __libc_start_main /build/glibc-wuryBv/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#18 0x0000555c5281451e _start (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/opt+0x1a51e)\r\n[1] 1975861 segmentation fault -disable-output -passes=loop-vectorize reduced.ll\r\n```\r\n\r\n\r\nThis IR is reduced from \r\n```C\r\nlong a, b;\r\nint c, d, f;\r\nstatic long *e = &b;\r\nstatic short g = 5;\r\nint h() {\r\n if (a)\r\n return 0;\r\n return 5;\r\n}\r\nvoid i() {\r\n int j;\r\n long **k = &e;\r\n for (; d; d++) {\r\n j = h();\r\n *e = 6 >= (g | (j + c == 0));\r\n }\r\n j = &k || 1;\r\n short *l[6];\r\n l[f] = &g;\r\n}\r\nint main() {}\r\n```",
"author": "shao-hua-li",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
Cannot find a good commit
| null |
141017
|
https://github.com/llvm/llvm-project/issues/141017
|
miscompilation
|
b3fd2ea88875e58c66dd67870ff822cedf2570cf
| 2025-05-22T07:55:25
|
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "1984c7539ebeb2697233f8163a051a2ce0d4fa50",
"components": [
"ValueTracking"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": [
[
889,
895
]
],
"llvm/lib/Analysis/ValueTracking.cpp": [
[
8898,
8916
]
],
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": [
"llvm::matchDecomposedSelectPattern",
"llvm::matchSelectPattern"
],
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 1984c7539ebeb2697233f8163a051a2ce0d4fa50
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Mon Jun 2 18:21:14 2025 +0800
[ValueTracking] Do not use FMF from fcmp (#142266)
This patch introduces an FMF parameter for
`matchDecomposedSelectPattern` to pass FMF flags from select, instead of
fcmp.
Closes https://github.com/llvm/llvm-project/issues/137998.
Closes https://github.com/llvm/llvm-project/issues/141017.
diff --git a/llvm/include/llvm/Analysis/ValueTracking.h b/llvm/include/llvm/Analysis/ValueTracking.h
index d81c3f10bba9..feb7a1fa2cb3 100644
--- a/llvm/include/llvm/Analysis/ValueTracking.h
+++ b/llvm/include/llvm/Analysis/ValueTracking.h
@@ -889,7 +889,8 @@ inline SelectPatternResult matchSelectPattern(const Value *V, const Value *&LHS,
/// predicate and given values as its true/false operands would match.
LLVM_ABI SelectPatternResult matchDecomposedSelectPattern(
CmpInst *CmpI, Value *TrueVal, Value *FalseVal, Value *&LHS, Value *&RHS,
- Instruction::CastOps *CastOp = nullptr, unsigned Depth = 0);
+ FastMathFlags FMF = FastMathFlags(), Instruction::CastOps *CastOp = nullptr,
+ unsigned Depth = 0);
/// Determine the pattern for predicate `X Pred Y ? X : Y`.
LLVM_ABI SelectPatternResult getSelectPattern(
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 3d8bb6249eaf..7f30cd73d57c 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -8898,19 +8898,20 @@ SelectPatternResult llvm::matchSelectPattern(Value *V, Value *&LHS, Value *&RHS,
Value *TrueVal = SI->getTrueValue();
Value *FalseVal = SI->getFalseValue();
- return llvm::matchDecomposedSelectPattern(CmpI, TrueVal, FalseVal, LHS, RHS,
- CastOp, Depth);
+ return llvm::matchDecomposedSelectPattern(
+ CmpI, TrueVal, FalseVal, LHS, RHS,
+ isa<FPMathOperator>(SI) ? SI->getFastMathFlags() : FastMathFlags(),
+ CastOp, Depth);
}
SelectPatternResult llvm::matchDecomposedSelectPattern(
CmpInst *CmpI, Value *TrueVal, Value *FalseVal, Value *&LHS, Value *&RHS,
- Instruction::CastOps *CastOp, unsigned Depth) {
+ FastMathFlags FMF, Instruction::CastOps *CastOp, unsigned Depth) {
CmpInst::Predicate Pred = CmpI->getPredicate();
Value *CmpLHS = CmpI->getOperand(0);
Value *CmpRHS = CmpI->getOperand(1);
- FastMathFlags FMF;
- if (isa<FPMathOperator>(CmpI))
- FMF = CmpI->getFastMathFlags();
+ if (isa<FPMathOperator>(CmpI) && CmpI->hasNoNaNs())
+ FMF.setNoNaNs();
// Bail out early.
if (CmpI->isEquality())
|
[
{
"file": "llvm/test/Transforms/InstCombine/unordered-fcmp-select.ll",
"commands": [
"opt -S -passes=instcombine < %s"
],
"tests": [
{
"test_name": "pr141017_select_nsz",
"test_body": "define float @pr141017_select_nsz(float %x) {\n %cmp = fcmp olt float %x, 0.000000e+00\n %sel = select nsz i1 %cmp, float -0.000000e+00, float %x\n ret float %sel\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "pr141017",
"test_body": "define float @pr141017(float %x) {\n %cmp = fcmp nsz olt float %x, 0.000000e+00\n %sel = select i1 %cmp, float -0.000000e+00, float %x\n ret float %sel\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "select_min_uge_2_use_cmp",
"test_body": "declare void @foo(i1)\n\ndefine float @select_min_uge_2_use_cmp(float %a, float %b) {\n %cmp = fcmp ninf uge float %a, %b\n call void @foo(i1 %cmp)\n %sel = select nsz i1 %cmp, float %b, float %a\n ret float %sel\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[InstCombine] Miscompilation `select (fcmp nsz olt X, 0.0), -0.0, X -> select (fcmp nsz ole X, -0.0), -0.0, X`",
"body": "Reproducer: https://alive2.llvm.org/ce/z/Uydp8F\n```\ndefine float @src(float %x) {\n %cmp = fcmp nsz olt float %x, 0.0\n %sel = select i1 %cmp, float -0.0, float %x\n ret float %sel\n}\n\ndefine float @tgt(float %x) {\n %.inv = fcmp nsz ole float %x, -0.000000e+00\n %sel1 = select i1 %.inv, float -0.000000e+00, float %x\n ret float %sel1\n}\n```\n```\nTransformation doesn't verify!\n\nERROR: Target's return value is more undefined\n\nExample:\nfloat %x = #x00000000 (+0.0)\n\nSource:\ni1 %cmp = #x0 (0)\nfloat %sel = #x00000000 (+0.0)\n\nTarget:\ni1 %.inv = #x1 (1)\nfloat %sel1 = #x00000000 (+0.0)\nSource value: #x00000000 (+0.0)\nTarget value: #x00000000 (+0.0)\n```\n",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"floating-point",
"llvm:analysis"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
|
Cannot find a good commit
| null |
160671
|
https://github.com/llvm/llvm-project/issues/160671
|
crash
|
d77d3a78472410128f6d0b9f71bd36fb26b72feb
| 2025-09-25T09:27:43
|
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "57947ace14ebfadba46a99aa80589e021c757037",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
17519,
17525
],
[
19119,
19125
]
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::getLastInstructionInBundle",
"BoUpSLP::vectorizeTree"
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 57947ace14ebfadba46a99aa80589e021c757037
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Thu Sep 25 13:38:27 2025 -0700
[SLP]Correctly set the insert point for insertlements with copyable arguments
Need to find the last insertelement instruction in the list for the
copyable arguments, otherwise wrong def-use chain may be built
Fixes #160671
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 1814d9a6811c..065622efc7ec 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -17519,7 +17519,9 @@ Instruction &BoUpSLP::getLastInstructionInBundle(const TreeEntry *E) {
return !isa<GetElementPtrInst>(V) && isa<Instruction>(V);
})) ||
all_of(E->Scalars, [&](Value *V) {
- return isa<PoisonValue>(V) || E->isCopyableElement(V) ||
+ return isa<PoisonValue>(V) ||
+ (E->Idx == 0 && isa<InsertElementInst>(V)) ||
+ E->isCopyableElement(V) ||
(!isVectorLikeInstWithConstOps(V) && isUsedOutsideBlock(V));
}))
Res = FindLastInst();
@@ -19119,7 +19121,12 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) {
}
case Instruction::InsertElement: {
assert(E->ReuseShuffleIndices.empty() && "All inserts should be unique");
- Builder.SetInsertPoint(cast<Instruction>(E->Scalars.back()));
+ if (const TreeEntry *OpE = getOperandEntry(E, 1);
+ OpE && !OpE->isGather() && OpE->hasState() &&
+ !OpE->hasCopyableElements())
+ Builder.SetInsertPoint(cast<Instruction>(E->Scalars.back()));
+ else
+ setInsertPointAfterBundle(E);
Value *V = vectorizeOperand(E, 1);
ArrayRef<Value *> Op = E->getOperand(1);
Type *ScalarTy = Op.front()->getType();
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/insertelement-with-copyable-args.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-99999 < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine i64 @test(i32 %arg) {\n;\nbb:\n %freeze = freeze i32 0\n br i1 false, label %bb1, label %bb1\n\nbb1:\n %load = load i32, ptr addrspace(1) null, align 4\n %0 = insertelement <4 x i32> <i32 0, i32 poison, i32 poison, i32 0>, i32 %freeze, i32 2\n %1 = insertelement <4 x i32> <i32 0, i32 0, i32 0, i32 poison>, i32 %arg, i32 3\n %add = add i32 %freeze, 0\n %2 = insertelement <2 x i32> poison, i32 %freeze, i32 0\n %3 = shufflevector <2 x i32> %2, <2 x i32> poison, <2 x i32> zeroinitializer\n %4 = add <2 x i32> %3, zeroinitializer\n %5 = insertelement <2 x i32> poison, i32 %arg, i32 0\n %6 = insertelement <2 x i32> %5, i32 %load, i32 1\n %7 = icmp ult <2 x i32> %4, %6\n %8 = extractelement <2 x i1> %7, i32 0\n %and = and i1 %8, false\n %9 = insertelement <4 x i32> %0, i32 %add, i32 1\n %10 = icmp eq <4 x i32> %9, %1\n %11 = icmp ult <4 x i32> %9, %1\n %12 = shufflevector <4 x i1> %10, <4 x i1> %11, <4 x i32> <i32 0, i32 5, i32 6, i32 7>\n br i1 false, label %bb11, label %bb12\n\nbb11:\n %zext = zext i32 %add to i64\n ret i64 0\n\nbb12:\n %zext13 = zext i32 %add to i64\n ret i64 0\n}",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "Instruction does not dominate all uses! LLVM ERROR: Broken module found, compilation aborted!",
"body": "To reproduce run opt with the test below, using `-passes=slp-vectorizer -slp-threshold=-99999 `\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 i64 @wombat(i32 %arg) #0 gc \"statepoint-example\" {\nbb:\n %freeze = freeze i32 0\n br i1 false, label %bb1, label %bb1\n\nbb1: ; preds = %bb, %bb\n %load = load i32, ptr addrspace(1) null, align 4\n %icmp = icmp eq i32 0, 0\n %icmp2 = icmp ult i32 0, 0\n %add = add i32 %freeze, 0\n %icmp3 = icmp ult i32 %add, 0\n %icmp4 = icmp ugt i32 0, 0\n %icmp5 = icmp ult i32 %freeze, 0\n %icmp6 = icmp ult i32 0, 0\n %icmp7 = icmp ult i32 %add, %arg\n %and = and i1 %icmp7, false\n %icmp8 = icmp ugt i32 0, 0\n %icmp9 = icmp ugt i32 %arg, 0\n %icmp10 = icmp ult i32 %freeze, %load\n br i1 false, label %bb11, label %bb12\n\nbb11: ; preds = %bb1\n %zext = zext i32 %add to i64\n ret i64 0\n\nbb12: ; preds = %bb1\n %zext13 = zext i32 %add to i64\n ret i64 0\n}\n\nattributes #0 = { \"target-features\"=\"+prfchw,-cldemote,+avx,+aes,+sahf,+pclmul,-xop,+crc32,-amx-fp8,+xsaves,-avx512fp16,-usermsr,-sm4,-egpr,+sse4.1,-avx10.1,-avx512ifma,+xsave,+sse4.2,-tsxldtrk,-sm3,-ptwrite,-widekl,-movrs,-invpcid,+64bit,+xsavec,-avx512vpopcntdq,+cmov,-avx512vp2intersect,-avx512cd,+movbe,-avxvnniint8,-ccmp,-amx-int8,-kl,-sha512,-avxvnni,-rtm,+adx,+avx2,-hreset,-movdiri,-serialize,-vpclmulqdq,-avx512vl,-uintr,-cf,+clflushopt,-raoint,-cmpccxadd,+bmi,-amx-tile,+sse,-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,-avxneconvert,-tbm,-pconfig,-amx-complex,+ssse3,+cx16,-avx10.2,+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\" }\n```\nReproducer: https://godbolt.org/z/nY8fvjv8f\n\nStack dump:\n```\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer -slp-threshold=-99999 <source>\n1.\tRunning pass \"verify\" on module \"<source>\"\n #0 0x00000000058da2e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x58da2e8)\n #1 0x00000000058d7194 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007cfd67242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007cfd672969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007cfd67242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007cfd672287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x000000000082fa8d llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0\n #7 0x00000000058112c1 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x58112c1)\n #8 0x0000000005701d78 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5701d78)\n #9 0x000000000097292e 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+0x97292e)\n#10 0x00000000056bf8e1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x56bf8e1)\n#11 0x000000000097cb18 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x97cb18)\n#12 0x0000000000970cb7 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x970cb7)\n#13 0x00007cfd67229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#14 0x00007cfd67229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#15 0x0000000000967dc5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x967dc5)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```",
"author": "TatyanaDoubts",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
|
898bba311f180ed54de33dc09e7071c279a4942a
| null |
126304
|
https://github.com/llvm/llvm-project/issues/126304
|
crash
|
fcbf04e40e66014f455a38b59993be865bc6cdfd
| 2025-02-07T20:48:01
|
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "10844fb9b0b78695243391e091e17ec29295872a",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
5596,
5601
],
[
5626,
5632
]
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::getReorderingData"
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 10844fb9b0b78695243391e091e17ec29295872a
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Tue Feb 11 13:23:55 2025 -0800
[SLP]Fix attempt to build the reorder mask for non-adjusted reuse mask
When building the reorder for non-single use reuse mask, need to check
if the size of the mask is multiple of the number of unique scalars.
Otherwise, the compiler may crash when trying to reorder nodes.
Fixes #126304
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index e1c08077126d..fb1054ee30aa 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -5596,6 +5596,8 @@ BoUpSLP::getReorderingData(const TreeEntry &TE, bool TopToBottom) {
::getNumberOfParts(*TTI, getWidenedType(TE.Scalars.front()->getType(),
2 * TE.getVectorFactor())) == 1)
return std::nullopt;
+ if (TE.ReuseShuffleIndices.size() % Sz != 0)
+ return std::nullopt;
if (!ShuffleVectorInst::isOneUseSingleSourceMask(TE.ReuseShuffleIndices,
Sz)) {
SmallVector<int> ReorderMask(Sz, PoisonMaskElem);
@@ -5626,7 +5628,7 @@ BoUpSLP::getReorderingData(const TreeEntry &TE, bool TopToBottom) {
UsedVals.set(Val);
for (unsigned K = 0; K < NumParts; ++K) {
unsigned Idx = Val + Sz * K;
- if (Idx < VF)
+ if (Idx < VF && I + K < VF)
ResOrder[Idx] = I + K;
}
}
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/SystemZ/reuse-non-power-of-2-reorder.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=systemz -mcpu=z15 < %s -slp-threshold=-100"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @test(i32 %0, i64 %1, i32 %2, i32 %3, ptr %4) {\n;\n %6 = trunc i64 %1 to i32\n %7 = xor i32 %6, 1\n %8 = xor i32 %6, 1\n %9 = or i32 %7, %8\n %10 = xor i32 %6, 1\n %11 = or i32 %9, %10\n %12 = xor i32 %6, 1\n %13 = or i32 %11, %12\n %14 = xor i32 %6, 1\n %15 = or i32 %13, %14\n %16 = xor i32 %6, 1\n %17 = or i32 %15, %16\n %18 = xor i32 %6, 1\n %19 = or i32 %17, %18\n %20 = xor i32 %6, 1\n %21 = or i32 %19, %20\n %22 = trunc i64 %1 to i32\n %23 = xor i32 %22, 1\n %24 = or i32 %23, %21\n %25 = xor i32 %22, 1\n %26 = or i32 %24, %25\n %27 = xor i32 %22, 1\n %28 = or i32 %26, %27\n %29 = xor i32 %22, 1\n %30 = or i32 %28, %29\n %31 = xor i32 %22, 1\n %32 = or i32 %30, %31\n %33 = xor i32 %22, 1\n %34 = or i32 %32, %33\n %35 = xor i32 %22, 1\n %36 = or i32 %34, %35\n %37 = xor i32 %22, 1\n %38 = or i32 %36, %37\n %39 = trunc i64 %1 to i32\n %40 = xor i32 %39, 1\n %41 = or i32 %40, %38\n %42 = xor i32 %39, 1\n %43 = or i32 %41, %42\n %44 = xor i32 %39, 1\n %45 = or i32 %43, %44\n %46 = xor i32 %39, 1\n %47 = or i32 %45, %46\n %48 = xor i32 %39, 1\n %49 = or i32 %47, %48\n %50 = xor i32 %39, 1\n %51 = or i32 %49, %50\n %52 = xor i32 %39, 1\n %53 = or i32 %51, %52\n %54 = xor i32 %39, 1\n %55 = or i32 %53, %54\n %56 = trunc i64 %1 to i32\n %57 = xor i32 %56, 1\n %58 = or i32 %57, %55\n %59 = xor i32 %56, 1\n %60 = or i32 %58, %59\n %61 = xor i32 %56, 1\n %62 = or i32 %60, %61\n %63 = xor i32 %56, 1\n %64 = or i32 %62, %63\n %65 = xor i32 %56, 1\n %66 = or i32 %64, %65\n %67 = xor i32 %56, 1\n %68 = or i32 %66, %67\n %69 = xor i32 %56, 1\n %70 = or i32 %68, %69\n %71 = xor i32 %56, 1\n %72 = or i32 %70, %71\n %73 = trunc i64 %1 to i32\n %74 = xor i32 %73, 1\n %75 = or i32 %74, %72\n %76 = xor i32 %73, 1\n %77 = or i32 %75, %76\n %78 = xor i32 %73, 1\n %79 = or i32 %77, %78\n %80 = xor i32 %73, 1\n %81 = or i32 %79, %80\n %82 = xor i32 %73, 1\n %83 = or i32 %81, %82\n %84 = xor i32 %73, 1\n %85 = or i32 %83, %84\n %86 = xor i32 %73, 1\n %87 = or i32 %85, %86\n %88 = xor i32 %0, %73\n %89 = or i32 %87, %88\n %90 = xor i32 %0, %2\n %91 = or i32 %90, %89\n %92 = xor i32 %0, %2\n %93 = or i32 %91, %92\n %94 = xor i32 %0, %2\n %95 = or i32 %93, %94\n %96 = xor i32 %0, %2\n %97 = or i32 %95, %96\n %98 = trunc i64 %1 to i32\n %99 = xor i32 %98, 1\n %100 = xor i32 %98, 1\n %101 = or i32 %99, %100\n %102 = xor i32 %98, 1\n %103 = or i32 %101, %102\n %104 = xor i32 %98, 1\n %105 = or i32 %103, %104\n %106 = xor i32 %98, 1\n %107 = or i32 %105, %106\n %108 = xor i32 %98, 1\n %109 = or i32 %107, %108\n %110 = xor i32 %98, 1\n %111 = or i32 %109, %110\n %112 = xor i32 %0, %98\n %113 = or i32 %111, %112\n %114 = xor i32 %0, %3\n %115 = or i32 %113, %114\n %116 = xor i32 %0, %3\n %117 = or i32 %115, %116\n %118 = xor i32 %0, %3\n %119 = or i32 %117, %118\n %120 = xor i32 %0, %3\n %121 = or i32 %119, %120\n %122 = xor i32 %0, %3\n %123 = or i32 %121, %122\n %124 = xor i32 %0, %3\n %125 = or i32 %123, %124\n %126 = xor i32 %0, %3\n %127 = or i32 %125, %126\n %128 = xor i32 %0, %3\n %129 = or i32 %127, %128\n %130 = or i32 %129, %97\n store i32 %130, ptr %4, align 4\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[SLP] llvm::BitVector::set(unsigned int): Assertion `Idx < Size && \"access in bound\"' failed.",
"body": "[crash41.tar.gz](https://github.com/user-attachments/files/18712696/crash41.tar.gz)\n\nclang -O3 -march=z15 crash41.i -o a.out -w -mllvm -inline-threshold=450\n\nllvm/include/llvm/ADT/BitVector.h:358: llvm::BitVector& llvm::BitVector::set(unsigned int): Assertion `Idx < Size && \"access in bound\"' failed.\n\n#11 0x000002aa03b45768 llvm::SLPVectorizerPass::vectorizeHorReduction\n\n@alexey-bataev \n",
"author": "JonPsson1",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
5deb4ef9ab1144542d748f71235b029bed06dd26
| null |
91369
|
https://github.com/llvm/llvm-project/issues/91369
|
miscompilation
|
9a28814f59e8f52cc63ae3d17023cee8348d9b53
| 2024-05-07T18:12:26
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "082c81ae4ab9db6bb0acd52098288223dd58501a",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
[
8841,
8848
]
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes"
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 082c81ae4ab9db6bb0acd52098288223dd58501a
Author: Florian Hahn <flo@fhahn.com>
Date: Tue May 7 21:31:40 2024 +0100
[LV] Properly extend versioned constant strides.
We only version unknown strides to 1. If the original type is i1, then
the sign of the extension matters. Properly extend the stride value
before replacing it.
Fixes https://github.com/llvm/llvm-project/issues/91369.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 3be0102bea3e..261933966b74 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -8841,8 +8841,10 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
VPValue *StrideVPV = Plan->getLiveIn(U);
if (!StrideVPV)
continue;
- VPValue *CI = Plan->getOrAddLiveIn(ConstantInt::get(
- U->getType(), ScevStride->getAPInt().getSExtValue()));
+ unsigned BW = U->getType()->getScalarSizeInBits();
+ APInt C = isa<SExtInst>(U) ? ScevStride->getAPInt().sext(BW)
+ : ScevStride->getAPInt().zext(BW);
+ VPValue *CI = Plan->getOrAddLiveIn(ConstantInt::get(U->getType(), C));
StrideVPV->replaceAllUsesWith(CI);
}
}
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/version-stride-with-integer-casts.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-width=4 -S %s"
],
"tests": [
{
"test_name": "zext_of_i1_stride",
"test_body": "target datalayout = \"p:8:8:8\"\n\n; Function Attrs: mustprogress\ndefine void @zext_of_i1_stride(i1 %g, ptr %dst) #0 {\nentry:\n %g.16 = zext i1 %g to i16\n %g.64 = zext i1 %g to i64\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep = getelementptr inbounds i16, ptr %dst, i64 %iv\n store i16 %g.16, ptr %gep, align 2\n %iv.next = add nuw nsw i64 %iv, %g.64\n %cmp = icmp ult i64 %iv.next, 16\n br i1 %cmp, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { mustprogress }\n",
"additional_args": "-src-unroll=32 -tgt-unroll=32",
"lli_expected_out": null
}
]
}
] |
{
"title": "[LoopVectorize] Sign-extension miscompile",
"body": "C Testcase:\r\n```c\r\nlong a, d;\r\nshort b[20];\r\nshort c[20];\r\n_Bool e[20];\r\nint f(_Bool g) {\r\n for (long h = 0; h < 16; h += g)\r\n b[h] = (short) g;\r\n for (int i = 0; i < 12; i++)\r\n for (int j = d; j; j++)\r\n c[i] = (short) a < e[i];\r\n return (int) b[0];\r\n}\r\nint main() {\r\n __builtin_printf(\"%X\\n\", f(1));\r\n}\r\n```\r\nGodbolt: https://godbolt.org/z/3E8frs1Me\r\n\r\nWith loop-vectorize: `FFFFFFFF`\r\nWithout loop-vectorize: `1`\r\n\r\nReduced LLVM IR:\r\n```llvm ir\r\n; ModuleID = 'red.ll'\r\nsource_filename = \"red.c\"\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\n@b = global [20 x i16] zeroinitializer, align 2\r\n@.str = constant [4 x i8] c\"%X\\0A\\00\"\r\n\r\n; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) uwtable vscale_range(2,1024)\r\ndefine i32 @f(i1 %g) #0 {\r\nentry:\r\n %conv = zext i1 %g to i16\r\n %zext.g.i64 = zext i1 %g to i64\r\n br label %for.body\r\n\r\nfor.cond3.preheader: ; preds = %for.body\r\n %0 = load i64, ptr @b, align 2\r\n %zero = and i64 %0, 0\r\n %true = icmp eq i64 %zero, 0\r\n %2 = load i16, ptr @b, align 2\r\n %conv26 = sext i16 %2 to i32\r\n ret i32 %conv26\r\n\r\nfor.body: ; preds = %for.body, %entry\r\n %phi.0 = phi i64 [ 0, %entry ], [ %add, %for.body ]\r\n %idx.0 = getelementptr inbounds [20 x i16], ptr @b, i64 0, i64 %phi.0\r\n store i16 %conv, ptr %idx.0, align 2\r\n %add = add nuw nsw i64 %phi.0, %zext.g.i64\r\n %cmp = icmp ult i64 %add, 16\r\n br i1 %cmp, label %for.body, label %for.cond3.preheader, !llvm.loop !0\r\n}\r\n\r\n; Function Attrs: nofree nounwind uwtable vscale_range(2,1024)\r\ndefine noundef signext i32 @main() #1 {\r\nentry:\r\n %call = tail call signext i32 @f(i1 noundef zeroext true)\r\n %call1 = tail call signext i32 (ptr, ...) @printf(ptr noundef nonnull @.str, i32 noundef signext %call) #3\r\n ret i32 0\r\n}\r\n\r\n; Function Attrs: nofree nounwind\r\ndeclare noundef signext i32 @printf(ptr nocapture noundef readonly, ...) #2\r\n\r\nattributes #0 = { nofree norecurse nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) uwtable vscale_range(2,1024) \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"generic-rv64\" \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-e,-experimental-smmpm,-experimental-smnpm,-experimental-ssnpm,-experimental-sspm,-experimental-ssqosid,-experimental-supm,-experimental-zaamo,-experimental-zabha,-experimental-zalasr,-experimental-zalrsc,-experimental-zfbfmin,-experimental-zicfilp,-experimental-zicfiss,-experimental-ztso,-experimental-zvfbfmin,-experimental-zvfbfwma,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smepmp,-smstateen,-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,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-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,-zmmul,-zvbb,-zvbc,-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\nattributes #1 = { nofree nounwind uwtable vscale_range(2,1024) \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"generic-rv64\" \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-e,-experimental-smmpm,-experimental-smnpm,-experimental-ssnpm,-experimental-sspm,-experimental-ssqosid,-experimental-supm,-experimental-zaamo,-experimental-zabha,-experimental-zalasr,-experimental-zalrsc,-experimental-zfbfmin,-experimental-zicfilp,-experimental-zicfiss,-experimental-ztso,-experimental-zvfbfmin,-experimental-zvfbfwma,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smepmp,-smstateen,-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,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-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,-zmmul,-zvbb,-zvbc,-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\nattributes #2 = { nofree nounwind \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"generic-rv64\" \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-e,-experimental-smmpm,-experimental-smnpm,-experimental-ssnpm,-experimental-sspm,-experimental-ssqosid,-experimental-supm,-experimental-zaamo,-experimental-zabha,-experimental-zalasr,-experimental-zalrsc,-experimental-zfbfmin,-experimental-zicfilp,-experimental-zicfiss,-experimental-ztso,-experimental-zvfbfmin,-experimental-zvfbfwma,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smepmp,-smstateen,-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,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-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,-zmmul,-zvbb,-zvbc,-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\nattributes #3 = { nounwind }\r\n\r\n!0 = distinct !{!0, !1}\r\n!1 = !{!\"llvm.loop.mustprogress\"}\r\n```\r\nLoopVectorize pass.\r\n\r\nLooks like a sext/zext related issue.",
"author": "patrick-rivos",
"labels": [
"miscompilation",
"vectorizers"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
9ee8e38cdcc6925a4127d44a0360dc8de23dfb5f
| null |
161524
|
https://github.com/llvm/llvm-project/issues/161524
|
miscompilation
|
42ab473f518c5f180455c674cbaba70a0b2634b7
| 2025-10-01T14:10:51
|
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "57a9f79336abebbdfffd52270bb615f7189758d2",
"components": [
"ValueTracking"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": [
[
7651,
7675
]
],
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": [
"isGuaranteedNotToBeUndefOrPoison"
],
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 57a9f79336abebbdfffd52270bb615f7189758d2
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Thu Oct 2 01:11:51 2025 +0800
[ValueTracking] Take PHI's poison-generating flags into account (#161530)
ninf/nnan in the phi node may produce poison values. They should be
considered in `isGuaranteedNotToBeUndefOrPoison`.
Closes https://github.com/llvm/llvm-project/issues/161524.
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 6f11b250cf21..09a8fbea065a 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -7651,25 +7651,26 @@ static bool isGuaranteedNotToBeUndefOrPoison(
return true;
}
- if (const auto *PN = dyn_cast<PHINode>(V)) {
- unsigned Num = PN->getNumIncomingValues();
- bool IsWellDefined = true;
- for (unsigned i = 0; i < Num; ++i) {
- if (PN == PN->getIncomingValue(i))
- continue;
- auto *TI = PN->getIncomingBlock(i)->getTerminator();
- if (!isGuaranteedNotToBeUndefOrPoison(PN->getIncomingValue(i), AC, TI,
- DT, Depth + 1, Kind)) {
- IsWellDefined = false;
- break;
+ if (!::canCreateUndefOrPoison(Opr, Kind,
+ /*ConsiderFlagsAndMetadata=*/true)) {
+ if (const auto *PN = dyn_cast<PHINode>(V)) {
+ unsigned Num = PN->getNumIncomingValues();
+ bool IsWellDefined = true;
+ for (unsigned i = 0; i < Num; ++i) {
+ if (PN == PN->getIncomingValue(i))
+ continue;
+ auto *TI = PN->getIncomingBlock(i)->getTerminator();
+ if (!isGuaranteedNotToBeUndefOrPoison(PN->getIncomingValue(i), AC, TI,
+ DT, Depth + 1, Kind)) {
+ IsWellDefined = false;
+ break;
+ }
}
- }
- if (IsWellDefined)
+ if (IsWellDefined)
+ return true;
+ } else if (all_of(Opr->operands(), OpCheck))
return true;
- } else if (!::canCreateUndefOrPoison(Opr, Kind,
- /*ConsiderFlagsAndMetadata*/ true) &&
- all_of(Opr->operands(), OpCheck))
- return true;
+ }
}
if (auto *I = dyn_cast<LoadInst>(V))
|
[
{
"file": "llvm/test/Transforms/InstCombine/freeze-phi.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "pr161524",
"test_body": "define float @pr161524(float noundef %arg) {\nentry:\n %cond = tail call i1 @llvm.is.fpclass.f32(float %arg, i32 144)\n br i1 %cond, label %if.then, label %if.exit\n\nif.then: ; preds = %entry\n %fadd = fadd float %arg, 1.000000e+00\n br label %if.exit\n\nif.exit: ; preds = %if.then, %entry\n %ret = phi ninf float [ %fadd, %if.then ], [ %arg, %entry ]\n %ret.fr = freeze float %ret\n ret float %ret.fr\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i1 @llvm.is.fpclass.f32(float, i32 immarg) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[InstCombine] Freeze is incorrectly dropped",
"body": "Reproducer: https://alive2.llvm.org/ce/z/xyfr4N\n```\n; bin/opt -passes=instcombine test.ll -S\ndefine float @test(float %arg) {\nentry:\n %cond = tail call i1 @llvm.is.fpclass.f32(float %arg, i32 144)\n %0 = freeze i1 %cond\n br i1 %0, label %if.then, label %if.exit\n\nif.then: ; preds = %entry\n %fadd = fadd float %arg, 1.0\n br label %if.exit\n\nif.exit: ; preds = %if.then, %entry\n %ret = phi ninf float [ %fadd, %if.then ], [ %arg, %entry ]\n %1 = freeze float %ret\n ret float %1\n}\n```\n```\n=>\ndefine float @test(float %arg) {\nentry:\n %arg.fr = freeze float %arg\n %cond = is.fpclass float %arg.fr, i32 144\n br i1 %cond, label %if.then, label %if.exit\n\nif.then:\n %fadd = fadd float %arg.fr, 1.000000\n br label %if.exit\n\nif.exit:\n %ret = phi ninf float [ %fadd, %if.then ], [ %arg.fr, %entry ]\n ret float %ret\n}\nTransformation doesn't verify!\n\nERROR: Target is more poisonous than source\n\nExample:\nfloat %arg = #xff800000 (-oo)\n\nSource:\ni1 %cond = #x0 (0)\ni1 %#0 = #x0 (0)\n >> Jump to %if.exit\nfloat %ret = poison\nfloat %#1 = #x00000003 (0.000000000000?)\n\nTarget:\nfloat %arg.fr = #xff800000 (-oo)\ni1 %cond = #x0 (0)\n >> Jump to %if.exit\nfloat %ret = poison\nSource value: #x00000003 (0.000000000000?)\nTarget value: poison\n```",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:analysis",
"generated by fuzzer"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
Cannot find a good commit
| null |
156849
|
https://github.com/llvm/llvm-project/issues/156849
|
miscompilation
|
85dbe18beef4537dcdfaf9a009b1dd3dbdab608b
| 2025-09-04T10:35:34
|
[
"llvm/test/Transforms/LoopDistribute",
"llvm/test/Transforms/LoopVectorize",
"llvm/test/Transforms/LoopVersioning"
] |
{
"fix_commit": "f8972c8280d28660aaff888c093a9e01b9ee71e6",
"components": [
"ScalarEvolution"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": [
[
2187,
2194
]
],
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": [
"SCEVExpander::generateOverflowCheck"
],
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit f8972c8280d28660aaff888c093a9e01b9ee71e6
Author: Florian Hahn <flo@fhahn.com>
Date: Fri Sep 5 16:13:11 2025 +0100
[SCEVExp] Fix early exit in ComputeEndCheck. (#156910)
ComputeEndCheck incorrectly returned false for unsigned predicates
starting at zero and a positive step.
The AddRec could still wrap if Step * trunc ExitCount wraps or trunc
ExitCount strips leading 1s.
Fixes https://github.com/llvm/llvm-project/issues/156849.
PR: https://github.com/llvm/llvm-project/pull/156910
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index 3e3d51bffff3..7c12dac73f3d 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -2187,8 +2187,15 @@ Value *SCEVExpander::generateOverflowCheck(const SCEVAddRecExpr *AR,
// negative. If Step is known to be positive or negative, only create
// either 1. or 2.
auto ComputeEndCheck = [&]() -> Value * {
- // Checking <u 0 is always false.
- if (!Signed && Start->isZero() && SE.isKnownPositive(Step))
+ // Checking <u 0 is always false, if (Step * trunc ExitCount) does not wrap.
+ // TODO: Predicates that can be proven true/false should be discarded when
+ // the predicates are created, not late during expansion.
+ if (!Signed && Start->isZero() && SE.isKnownPositive(Step) &&
+ DstBits < SrcBits &&
+ ExitCount == SE.getZeroExtendExpr(SE.getTruncateExpr(ExitCount, ARTy),
+ ExitCount->getType()) &&
+ SE.willNotOverflow(Instruction::Mul, Signed, Step,
+ SE.getTruncateExpr(ExitCount, ARTy)))
return ConstantInt::getFalse(Loc->getContext());
// Get the backedge taken count and truncate or extended to the AR type.
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/interleaved-accesses-requiring-scev-predicates.ll",
"commands": [
"opt -S -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -enable-interleaved-mem-accesses=true %s"
],
"tests": [
{
"test_name": "wrap_predicate_for_interleave_group_wraps_for_known_trip_count",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine void @wrap_predicate_for_interleave_group_wraps_for_known_trip_count(ptr noalias %x, ptr noalias %out) {\nstart:\n br label %loop\n\nloop: ; preds = %loop, %start\n %iv = phi i64 [ 0, %start ], [ %iv.next, %loop ]\n %iv.next = add nuw nsw i64 %iv, 1\n %iv.mul5 = mul nuw nsw i64 %iv, 5\n %iv.mul5.masked = and i64 %iv.mul5, 15\n %gep = getelementptr inbounds nuw i32, ptr %x, i64 %iv.mul5.masked\n %v = load i32, ptr %gep, align 4\n %out.i = getelementptr inbounds nuw i32, ptr %out, i64 %iv\n store i32 %v, ptr %out.i, align 4\n %exitcond.not = icmp eq i64 %iv.next, 16\n br i1 %exitcond.not, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"additional_args": "-src-unroll=16 -tgt-unroll=16",
"lli_expected_out": null
}
]
}
] |
{
"title": "[LoopVectorize] Miscompile with masked IV",
"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\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n; out[i] = x[(i * 5) & 16]\ndefine void @test(ptr noalias %x, ptr noalias %out) {\nstart:\n br label %loop\n\nloop:\n %iv = phi i64 [ 0, %start ], [ %iv.next, %loop ]\n %iv.next = add nuw nsw i64 %iv, 1\n %iv.mul5 = mul nuw nsw i64 %iv, 5\n %iv.mul5.masked = and i64 %iv.mul5, 15\n %gep = getelementptr inbounds nuw i32, ptr %x, i64 %iv.mul5.masked\n %v = load i32, ptr %gep, align 4\n %out.i = getelementptr inbounds nuw i32, ptr %out, i64 %iv\n store i32 %v, ptr %out.i, align 4\n %exitcond.not = icmp eq i64 %iv.next, 16\n br i1 %exitcond.not, label %exit, label %loop\n\nexit:\n ret void\n}\n```\nProduces:\n```llvm\ndefine void @test(ptr noalias %x, ptr noalias %out) {\nstart:\n br i1 false, label %scalar.ph, label %vector.ph\n\nvector.ph:\n br label %vector.body\n\nvector.body:\n %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]\n %0 = mul nuw nsw i64 %index, 5\n %1 = and i64 %0, 15\n %2 = getelementptr inbounds nuw i32, ptr %x, i64 %1\n %wide.vec = load <20 x i32>, ptr %2, align 4\n %strided.vec = shufflevector <20 x i32> %wide.vec, <20 x i32> poison, <4 x i32> <i32 0, i32 5, i32 10, i32 15>\n %3 = getelementptr inbounds nuw i32, ptr %out, i64 %index\n store <4 x i32> %strided.vec, ptr %3, align 4\n %index.next = add nuw i64 %index, 4\n %4 = icmp eq i64 %index.next, 12\n br i1 %4, label %middle.block, label %vector.body\n\nmiddle.block:\n br label %scalar.ph\n\nscalar.ph:\n %bc.resume.val = phi i64 [ 12, %middle.block ], [ 0, %start ]\n br label %loop\n\nloop:\n %iv = phi i64 [ %bc.resume.val, %scalar.ph ], [ %iv.next, %loop ]\n %iv.next = add nuw nsw i64 %iv, 1\n %iv.mul5 = mul nuw nsw i64 %iv, 5\n %iv.mul5.masked = and i64 %iv.mul5, 15\n %gep = getelementptr inbounds nuw i32, ptr %x, i64 %iv.mul5.masked\n %v = load i32, ptr %gep, align 4\n %out.i = getelementptr inbounds nuw i32, ptr %out, i64 %iv\n store i32 %v, ptr %out.i, align 4\n %exitcond.not = icmp eq i64 %iv.next, 16\n br i1 %exitcond.not, label %exit, label %loop\n\nexit:\n ret void\n}\n```\n\nWhat's happening here with the load and shufflevector doesn't really make sense. It seems like the masking on the IV ended up being ignored?",
"author": "nikic",
"labels": [
"miscompilation",
"release:backport",
"release:cherry-pick-failed",
"llvm:SCEV"
],
"comments": [
{
"author": "nikic",
"body": "cc @fhahn "
},
{
"author": "fhahn",
"body": "Looks like an SCEVExpander issue, will share a fix soon"
},
{
"author": "nikic",
"body": "Backport PR: https://github.com/llvm/llvm-project/pull/157410"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
Cannot find a good commit
| null |
175229
|
https://github.com/llvm/llvm-project/issues/175229
|
crash
|
12cccb96de36bdef7bbdd7b77543a9063f7c0ecc
| 2026-01-09T19:45:23
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "d620ea7657814943748e2368004fad2be44c7272",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
[
7286,
7292
]
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"findRecipe"
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit d620ea7657814943748e2368004fad2be44c7272
Author: Florian Hahn <flo@fhahn.com>
Date: Sun Jan 11 11:19:30 2026 +0000
[LV] Handle live-ins in findRecipe.
Skip live-ins in findRecipe to prevent a crash for cases with degenerate
reductions (where the backedge value is a live-in). Such reductions
should be removed, but this requires further changes.
Fixes https://github.com/llvm/llvm-project/issues/175229.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 95fbfddffb29..cdc6ecfa21bc 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7286,7 +7286,9 @@ static VPRecipeBase *findRecipe(VPValue *Start, PredT Pred) {
for (unsigned I = 0; I != Worklist.size(); ++I) {
VPValue *Cur = Worklist[I];
auto *R = Cur->getDefiningRecipe();
- if (Pred(R))
+ // TODO: Skip live-ins once no degenerate reductions (ones with constant
+ // backedge values) are generated.
+ if (R && Pred(R))
return R;
for (VPUser *U : Cur->users()) {
for (VPValue *V : cast<VPRecipeBase>(U)->definedValues())
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/epilog-vectorization-reductions.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-width=4 -enable-epilogue-vectorization -epilogue-vectorization-force-VF=4 -S %s"
],
"tests": [
{
"test_name": "reduction_with_const_or",
"test_body": "define i1 @reduction_with_const_or(ptr %A, i8 %n) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %or.red = phi i1 [ false, %entry ], [ %or.next, %loop ]\n %iv = phi i8 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.ext = zext i8 %iv to i64\n %gep = getelementptr inbounds i64, ptr %A, i64 %iv.ext\n store i64 %iv.ext, ptr %gep, align 8\n %or.next = or i1 %or.red, true\n %iv.next = add i8 %iv, 1\n %exitcond = icmp eq i8 %iv, %n\n br i1 %exitcond, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i1 %or.next\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[LoopVectorizePass] Assertion `detail::isPresent(Val) && \"dyn_cast on a non-existent value\"' failed.",
"body": "Very recent regression. Not bisected yet.\n\nhttps://godbolt.org/z/eMaroco7z\n\n```\ntarget triple = \"x86_64-unknown-unknown\"\n\ndefine i1 @_Z1nv(i8 %0) {\nentry:\n br label %for.body4\n\nfor.cond.cleanup.loopexit: ; preds = %for.body4\n ret i1 %tobool8\n\nfor.body4: ; preds = %for.body4, %entry\n %h.028 = phi i1 [ %tobool8, %for.body4 ], [ false, %entry ]\n %i.027 = phi i8 [ %inc, %for.body4 ], [ 0, %entry ]\n %tobool8 = or i1 %h.028, true\n %inc = add i8 %i.027, 1\n %exitcond.not = icmp eq i8 %i.027, %0\n br i1 %exitcond.not, label %for.cond.cleanup.loopexit, label %for.body4\n\n; uselistorder directives\n uselistorder i1 %tobool8, { 1, 0 }\n}\n```\n\n```\nopt: /root/llvm-project/llvm/include/llvm/Support/Casting.h:656: decltype(auto) llvm::dyn_cast(From*) [with To = llvm::VPInstruction; From = llvm::VPRecipeBase]: Assertion `detail::isPresent(Val) && \"dyn_cast on a non-existent value\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.\nStack dump:\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 \"_Z1nv\"\n #0 0x0000000005a74d58 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5a74d58)\n #1 0x0000000005a71c04 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007def0e042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007def0e0969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007def0e042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007def0e0287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x00007def0e02871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x00007def0e039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x00000000037526f4 preparePlanForEpilogueVectorLoop(llvm::VPlan&, llvm::Loop*, llvm::DenseMap<llvm::SCEV const*, llvm::Value*, llvm::DenseMapInfo<llvm::SCEV const*, void>, llvm::detail::DenseMapPair<llvm::SCEV const*, llvm::Value*>> const&, llvm::EpilogueLoopVectorizationInfo&, llvm::LoopVectorizationCostModel&, llvm::ScalarEvolution&) LoopVectorize.cpp:0:0\n #9 0x000000000375aefa llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x375aefa)\n#10 0x000000000375bd20 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x375bd20)\n#11 0x000000000375c4ad llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x375c4ad)\n#12 0x000000000303396e 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+0x303396e)\n#13 0x000000000584ee81 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x584ee81)\n#14 0x0000000000f1e11e 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+0xf1e11e)\n#15 0x000000000584d43a llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x584d43a)\n#16 0x000000000097f47e 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+0x97f47e)\n#17 0x000000000584cdf1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x584cdf1)\n#18 0x0000000000989730 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x989730)\n#19 0x000000000097d658 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x97d658)\n#20 0x00007def0e029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#21 0x00007def0e029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#22 0x0000000000974055 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x974055)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```\n",
"author": "gregbedwell",
"labels": [
"vectorizers",
"crash-on-valid"
],
"comments": [
{
"author": "gregbedwell",
"body": "Bisects to 4998280c3f112facece8a7ce10f2788c800b7cba"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null | null |
180361
|
https://github.com/llvm/llvm-project/issues/180361
|
crash
|
39622a7739b85aa8cd1d5169028b6c8fd1e0bcaa
| 2026-02-07T18:16:54
|
[
"llvm/test/Transforms/DeadStoreElimination"
] |
{
"fix_commit": "ec059d81aafedb253a02d6f490ad9b9747611038",
"components": [
"DeadStoreElimination"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": [
[
1227,
1233
]
],
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": [
"isInvisibleToCallerAfterRet"
],
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit ec059d81aafedb253a02d6f490ad9b9747611038
Author: Aiden Grossman <aidengrossman@google.com>
Date: Sat Feb 7 11:43:56 2026 -0800
[DSE] Handle variable offsets with sized dead_on_return (#180364)
With a sized dead_on_return, we need to not eliminate stores if there
are to a pointer with a variable offset from the underlying object
marked dead_on_return. This manifested as an assertion failure as
BaseValue/V ended up not being equal. It's possible we could do a range
analysis to try and prove the variable offset stays within bounds, but
this case seems to come up relatively rarely (only reproducible with a
UBSan build of LLVM) and is probably not worth the compile time.
Fixes #180361.
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 582ec1dbcec9..e056f0c1f639 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1227,7 +1227,11 @@ struct DSEState {
int64_t ValueOffset;
[[maybe_unused]] const Value *BaseValue =
GetPointerBaseWithConstantOffset(Ptr, ValueOffset, DL);
- assert(BaseValue == V);
+ // If we are not able to find a constant offset from the UO, we have to
+ // pessimistically assume that the store writes to memory out of the
+ // dead_on_return bounds.
+ if (BaseValue != V)
+ return false;
// This store is only invisible after return if we are in bounds of the
// range marked dead.
if (StoreSize.hasValue() &&
|
[
{
"file": "llvm/test/Transforms/DeadStoreElimination/simple.ll",
"commands": [
"opt -passes=dse -S < %s"
],
"tests": [
{
"test_name": "test_dead_on_return_variable_offset",
"test_body": "\ndefine void @test_dead_on_return_variable_offset(ptr dead_on_return(4) %p, i64 %offset) {\n %p1 = getelementptr i8, ptr %p, i64 %offset\n store i32 0, ptr %p1\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[DSE] Assertion failure with clang using sized dead_on_return",
"body": "We hit an assertion failure in DSE from the following minimized test case:\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-linux-gnu\"\n\n; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)\ndeclare void @llvm.memset.p0.i64(ptr writeonly captures(none), i8, i64, i1 immarg) #0\n\ndefine void @_ZN4llvm19LegacyLegalizerInfoD2Ev(ptr dead_on_return(90056) %this, i64 %arraydestroy.elementPast.add) {\nentry:\n %arraydestroy.element.ptr = getelementptr i8, ptr %this, i64 %arraydestroy.elementPast.add\n tail call void @llvm.memset.p0.i64(ptr %arraydestroy.element.ptr, i8 0, i64 0, i1 false)\n ret void\n}\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\n```\nwith the following command line:\n```\nopt -passes=\"dse\" -disable-output <input path>\n```\n\nStack trace looks like the following:\n```\nopt: /home/gha/llvm-project/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:1230: bool (anonymous namespace)::DSEState::isInvisibleToCallerAfterRet(const Value *, const Value *, const LocationSize): Assertion `BaseValue == V' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.\nStack dump:\n0. Program arguments: ./bin/opt -passes=dse ./reduced.ll\n1. Running pass \"function(dse)\" on module \"./reduced.ll\"\n2. Running pass \"dse\" on function \"_ZN4llvm19LegacyLegalizerInfoD2Ev\"\n #0 0x000055cf10cb8868 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (./bin/opt+0x4af8868)\n #1 0x000055cf10cb5fa5 llvm::sys::RunSignalHandlers() (./bin/opt+0x4af5fa5)\n #2 0x000055cf10cb9631 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #3 0x00007f4e67768330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)\n #4 0x00007f4e677c1b2c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9eb2c)\n #5 0x00007f4e6776827e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)\n #6 0x00007f4e6774b8ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)\n #7 0x00007f4e6774b81b (/lib/x86_64-linux-gnu/libc.so.6+0x2881b)\n #8 0x00007f4e6775e517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)\n #9 0x000055cf0fb4221a (anonymous namespace)::DSEState::isInvisibleToCallerAfterRet(llvm::Value const*, llvm::Value const*, llvm::LocationSize) DeadStoreElimination.cpp:0:0\n#10 0x000055cf0fb3768c eliminateDeadStores(llvm::Function&, llvm::AAResults&, llvm::MemorySSA&, llvm::DominatorTree&, llvm::PostDominatorTree&, llvm::TargetLibraryInfo const&, llvm::LoopInfo const&) DeadStoreElimination.cpp:0:0\n#11 0x000055cf0fb34215 llvm::DSEPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (./bin/opt+0x3974215)\n#12 0x000055cf0e754bed llvm::detail::PassModel<llvm::Function, llvm::DSEPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (./bin/opt+0x2594bed)\n#13 0x000055cf10a79c37 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (./bin/opt+0x48b9c37)\n#14 0x000055cf0ce6ce2d llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (./bin/opt+0xcace2d)\n#15 0x000055cf10a7dc71 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (./bin/opt+0x48bdc71)\n#16 0x000055cf0c97cc0d llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (./bin/opt+0x7bcc0d)\n#17 0x000055cf10a78d07 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (./bin/opt+0x48b8d07)\n#18 0x000055cf0c974872 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (./bin/opt+0x7b4872)\n#19 0x000055cf0c96770d optMain (./bin/opt+0x7a770d)\n#20 0x00007f4e6774d1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)\n#21 0x00007f4e6774d28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)\n#22 0x000055cf0c960a05 _start (./bin/opt+0x7a0a05)\nAborted (core dumped)\n```",
"author": "boomanaiden154",
"labels": [
"crash",
"llvm:transforms"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null | null |
87856
|
https://github.com/llvm/llvm-project/issues/87856
|
crash
|
b17d44558ba4c30a3005089b334f68593d6a9c7c
| 2024-04-06T02:19:05
|
[
"llvm/test/Transforms/Attributor"
] |
{
"fix_commit": "2d61692d4b75b7d92b44bfafb1011c1723955151",
"components": [
"Attributor"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": [
[
5899,
5908
]
],
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": [
"AANoCaptureImpl::updateImpl"
],
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 2d61692d4b75b7d92b44bfafb1011c1723955151
Author: Matt Arsenault <Matthew.Arsenault@amd.com>
Date: Thu May 23 19:31:33 2024 +0200
Attributor: Do not assume function context in AANoCapture (#91462)
If the calling function has the null_pointer_is_valid attribute, somehow
a null constant reaches here. I'm not sure why exactly, it doesn't
happen for other types of constants.
Fixes #87856
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 41b66aafe7d3..1b3bf3c732ed 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -5690,6 +5690,9 @@ bool AANoCapture::isImpliedByIR(Attributor &A, const IRPosition &IRP,
return V.use_empty();
// You cannot "capture" null in the default address space.
+ //
+ // FIXME: This should use NullPointerIsDefined to account for the function
+ // attribute.
if (isa<UndefValue>(V) || (isa<ConstantPointerNull>(V) &&
V.getType()->getPointerAddressSpace() == 0)) {
return true;
@@ -5899,10 +5902,13 @@ ChangeStatus AANoCaptureImpl::updateImpl(Attributor &A) {
const Function *F =
isArgumentPosition() ? IRP.getAssociatedFunction() : IRP.getAnchorScope();
- assert(F && "Expected a function!");
- const IRPosition &FnPos = IRPosition::function(*F);
+
+ // TODO: Is the checkForAllUses below useful for constants?
+ if (!F)
+ return indicatePessimisticFixpoint();
AANoCapture::StateType T;
+ const IRPosition &FnPos = IRPosition::function(*F);
// Readonly means we cannot capture through memory.
bool IsKnown;
|
[
{
"file": "llvm/test/Transforms/Attributor/issue87856.ll",
"commands": [
"opt -S -passes=attributor < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @null_ptr_is_valid_call_with_null() #0 {\n;\n call void @store_as0(ptr null)\n ret void\n}\n\ndefine void @null_ptr_is_valid_call_with_undef() #0 {\n;\n call void @store_as0(ptr undef)\n ret void\n}\n\ndefine void @store_as0(ptr %0) {\n;\n store i16 0, ptr %0, align 2\n ret void\n}\n\ndefine void @call_store_as1() {\n;\n call void @store_as1(ptr addrspace(1) null)\n ret void\n}\n\ndefine void @store_as1(ptr addrspace(1) %arg) {\n;\n store i16 0, ptr addrspace(1) %arg, align 2\n ret void\n}\n\nattributes #0 = { null_pointer_is_valid }\n;.\n;.",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[attributor] Crash on `null_pointer_is_valid` function",
"body": "With\r\n\r\n```\r\ntarget datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"aarch64-none-linux-android28\"\r\n\r\n; Function Attrs: null_pointer_is_valid\r\ndefine i64 @foo() #0 {\r\n call fastcc void @bar(ptr null)\r\n ret i64 0\r\n}\r\n\r\ndefine fastcc void @bar(ptr %0) {\r\n store i16 0, ptr %0, align 2\r\n ret void\r\n}\r\n\r\nattributes #0 = { null_pointer_is_valid }\r\n```\r\n\r\nand running\r\n\r\n```\r\nopt -passes=attributor file.ll\r\n```\r\n\r\nwe crash with\r\n\r\n```\r\nopt: llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp:5901: virtual ChangeStatus (anonymous namespace)::AANoCaptureImpl::updateImpl(Attributor &): Assertion `F && \"Expected a function!\"' 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: opt -passes=attributor reduced.ll\r\n #0 0x000000000165bf38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (llvm-project/build/Release/bin/opt+0x165bf38)\r\n #1 0x0000000001659a40 llvm::sys::RunSignalHandlers() (llvm-project/build/Release/bin/opt+0x1659a40)\r\n #2 0x000000000165c938 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007f3ec923e6f0 __restore_rt (/lib64/libc.so.6+0x3e6f0)\r\n #4 0x00007f3ec928b94c __pthread_kill_implementation (/lib64/libc.so.6+0x8b94c)\r\n #5 0x00007f3ec923e646 gsignal (/lib64/libc.so.6+0x3e646)\r\n #6 0x00007f3ec92287f3 abort (/lib64/libc.so.6+0x287f3)\r\n #7 0x00007f3ec922871b _nl_load_domain.cold (/lib64/libc.so.6+0x2871b)\r\n #8 0x00007f3ec9237386 (/lib64/libc.so.6+0x37386)\r\n #9 0x0000000002f2a65b (anonymous namespace)::AANoCaptureImpl::updateImpl(llvm::Attributor&) AttributorAttributes.cpp:0:0\r\n#10 0x0000000002ec8492 llvm::AbstractAttribute::update(llvm::Attributor&) (llvm-project/build/Release/bin/opt+0x2ec8492)\r\n#11 0x0000000002ed3b83 llvm::Attributor::updateAA(llvm::AbstractAttribute&) (llvm-project/build/Release/bin/opt+0x2ed3b83)\r\n#12 0x0000000002eec289 llvm::AANoCapture const* llvm::Attributor::getOrCreateAAFor<llvm::AANoCapture>(llvm::IRPosition, llvm::AbstractAttribute const*, llvm::DepClassTy, bool, bool) Attributor.cpp:0:0\r\n#13 0x0000000002f1ab57 (anonymous namespace)::AANoAliasCallSiteArgument::updateImpl(llvm::Attributor&) AttributorAttributes.cpp:0:0\r\n#14 0x0000000002ec8492 llvm::AbstractAttribute::update(llvm::Attributor&) (llvm-project/build/Release/bin/opt+0x2ec8492)\r\n#15 0x0000000002ed3b83 llvm::Attributor::updateAA(llvm::AbstractAttribute&) (llvm-project/build/Release/bin/opt+0x2ed3b83)\r\n#16 0x0000000002efba19 llvm::AANoAlias const* llvm::Attributor::getOrCreateAAFor<llvm::AANoAlias>(llvm::IRPosition, llvm::AbstractAttribute const*, llvm::DepClassTy, bool, bool) Attributor.cpp:0:0\r\n#17 0x0000000002ede880 void llvm::Attributor::checkAndQueryIRAttr<(llvm::Attribute::AttrKind)20, llvm::AANoAlias>(llvm::IRPosition const&, llvm::AttributeSet) (llvm-project/build/Release/bin/opt+0x2ede880)\r\n#18 0x0000000002edd545 llvm::Attributor::identifyDefaultAbstractAttributes(llvm::Function&) (llvm-project/build/Release/bin/opt+0x2edd545)\r\n#19 0x0000000002ee0800 runAttributorOnFunctions(llvm::InformationCache&, llvm::SetVector<llvm::Function*, llvm::SmallVector<llvm::Function*, 0u>, llvm::DenseSet<llvm::Function*, llvm::DenseMapInfo<llvm::Function*, void>>, 0u>&, llvm::AnalysisGetter&, llvm::CallGraphUpdater&, bool, bool) Attributor.cpp:0:0\r\n#20 0x0000000002edfc41 llvm::AttributorPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (llvm-project/build/Release/bin/opt+0x2edfc41)\r\n#21 0x0000000002b6fcdd llvm::detail::PassModel<llvm::Module, llvm::AttributorPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) PassBuilderPipelines.cpp:0:0\r\n#22 0x0000000001853e56 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (llvm-project/build/Release/bin/opt+0x1853e56)\r\n#23 0x0000000002afaa4b 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) (llvm-project/build/Release/bin/opt+0x2afaa4b)\r\n#24 0x0000000001622f36 optMain (llvm-project/build/Release/bin/opt+0x1622f36)\r\n```",
"author": "lanza",
"labels": [
"crash-on-valid",
"llvm::Attributor"
],
"comments": [
{
"author": "lanza",
"body": "https://github.com/llvm/llvm-project/blob/0f52f4ddd909eb38f2a691ffed8469263fe5f635/llvm/lib/Transforms/IPO/AttributorAttributes.cpp#L5901"
},
{
"author": "dtcxzyw",
"body": "cc @arsenm "
},
{
"author": "arsenm",
"body": "Just returning on the null function seems to work, but I don't understand exactly why it reaches here. AANoCapture::isImpliedByIR is incorrectly reimplementing NullPointerIsDefined but fixing that doesn't seem to help any "
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
ebec3dd1bf516ada75f685e65cd344838f8ee4c5
| null |
91078
|
https://github.com/llvm/llvm-project/issues/91078
|
crash
|
d5ca2e46ca97758de6edb9f071f2114205380d87
| 2024-05-04T18:39:13
|
[
"llvm/test/Transforms/VectorCombine"
] |
{
"fix_commit": "d145f40963f15e94c4aefcc406a365fbe779e934",
"components": [
"VectorCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [
[
1755,
1764
]
],
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [
"VectorCombine::foldShuffleToIdentity"
],
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit d145f40963f15e94c4aefcc406a365fbe779e934
Author: David Green <david.green@arm.com>
Date: Sun May 5 10:47:11 2024 +0100
[VectorCombine] shuffleToIdentity - guard against call instructions.
The shuffleToIdentity fold needs to be a bit more careful about the difference
between call instructions and intrinsics. The second can be handled, but the
first should result in bailing out. This patch also adds some extra intrinsic
tests from #91000.
Fixes #91078
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index 04d2ff594bf5..bbb70134870a 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -1755,10 +1755,13 @@ bool VectorCombine::foldShuffleToIdentity(Instruction &I) {
return false;
if (IL.first->getValueID() != Item[0].first->getValueID())
return false;
+ if (isa<CallInst>(IL.first) && !isa<IntrinsicInst>(IL.first))
+ return false;
auto *II = dyn_cast<IntrinsicInst>(IL.first);
return !II ||
- II->getIntrinsicID() ==
- cast<IntrinsicInst>(Item[0].first)->getIntrinsicID();
+ (isa<IntrinsicInst>(Item[0].first) &&
+ II->getIntrinsicID() ==
+ cast<IntrinsicInst>(Item[0].first)->getIntrinsicID());
}))
return false;
|
[
{
"file": "llvm/test/Transforms/VectorCombine/AArch64/shuffletoidentity.ll",
"commands": [
"opt -passes=vector-combine -S %s"
],
"tests": [
{
"test_name": "callinst",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x half> @callinst(<8 x half> %a) {\n %ab = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = call <4 x half> @othercall(<4 x half> %at)\n %abb = call <4 x half> @llvm.fabs.v4f16(<4 x half> %ab)\n %r = shufflevector <4 x half> %abt, <4 x half> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x half> %r\n}\n\ndeclare <4 x half> @othercall(<4 x half>)\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x half> @llvm.fabs.v4f16(<4 x half>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "callinst2",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x half> @callinst2(<8 x half> %a) {\n %ab = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = call <4 x half> @llvm.fabs.v4f16(<4 x half> %at)\n %abb = call <4 x half> @othercall(<4 x half> %ab)\n %r = shufflevector <4 x half> %abt, <4 x half> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x half> %r\n}\n\ndeclare <4 x half> @othercall(<4 x half>)\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x half> @llvm.fabs.v4f16(<4 x half>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "lrint",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i32> @lrint(<8 x half> %a) {\n %ab = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = call <4 x i32> @llvm.lrint.v4i32.v4f16(<4 x half> %at)\n %abb = call <4 x i32> @llvm.lrint.v4i32.v4f16(<4 x half> %ab)\n %r = shufflevector <4 x i32> %abt, <4 x i32> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i32> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x i32> @llvm.lrint.v4i32.v4f16(<4 x half>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "abs_different",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i8> @abs_different(<8 x i8> %a) {\n %ab = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = call <4 x i8> @llvm.abs.v4i8(<4 x i8> %at, i1 true)\n %abb = call <4 x i8> @llvm.abs.v4i8(<4 x i8> %ab, i1 false)\n %r = shufflevector <4 x i8> %abt, <4 x i8> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i8> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x i8> @llvm.abs.v4i8(<4 x i8>, i1 immarg) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "powi",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x half> @powi(<8 x half> %a) {\n %ab = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = call <4 x half> @llvm.powi.v4f16.i32(<4 x half> %at, i32 10)\n %abb = call <4 x half> @llvm.powi.v4f16.i32(<4 x half> %ab, i32 10)\n %r = shufflevector <4 x half> %abt, <4 x half> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x half> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x half> @llvm.powi.v4f16.i32(<4 x half>, i32) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "abs",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i8> @abs(<8 x i8> %a) {\n %ab = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = call <4 x i8> @llvm.abs.v4i8(<4 x i8> %at, i1 false)\n %abb = call <4 x i8> @llvm.abs.v4i8(<4 x i8> %ab, i1 false)\n %r = shufflevector <4 x i8> %abt, <4 x i8> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i8> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x i8> @llvm.abs.v4i8(<4 x i8>, i1 immarg) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "A/F: isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\" after commit a4d1026",
"body": "A few of our internal tests started hitting an assertion failure which I bisected back to commit a4d10266d20bfe5930dfed77e17832af341ed66e. \r\n\r\nConsider the following code:\r\n```c++\r\ntemplate <typename a> a b(a);\r\ntypedef float c __attribute__((__vector_size__(32)));\r\ntypedef float __attribute__((ext_vector_type(8))) d;\r\ntypedef float __attribute__((ext_vector_type(4))) e;\r\nc f;\r\n#define g(h) (b(h))\r\nd i;\r\nvoid j() {\r\n c k = __builtin_ia32_rsqrtps256(f);\r\n d l(k);\r\n d m g(i);\r\n volatile e n = __builtin_shufflevector(l, m, 15, 2, 0, 1);\r\n}\r\n```\r\nWhen compiled with optimizations and `-mavx` it hits an assertion failure:\r\n```\r\n$ ~/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang -c -O2 -mavx repro2.cpp \r\nclang: /home/dyung/src/upstream/llvm_clean_git/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From*) [with To = llvm::IntrinsicInst; From = llvm::Value]: Assertion `isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"' 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/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang -c -O2 -mavx repro2.cpp\r\n1. <eof> parser at end of file\r\n2. Optimizer\r\n #0 0x0000557d533cfe2f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x4055e2f)\r\n #1 0x0000557d533cd96c llvm::sys::CleanupOnSignal(unsigned long) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x405396c)\r\n #2 0x0000557d5331a4e8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0\r\n #3 0x00007f0ccbb8b420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #4 0x00007f0ccb65800b raise /build/glibc-e2p3jK/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #5 0x00007f0ccb637859 abort /build/glibc-e2p3jK/glibc-2.31/stdlib/abort.c:81:7\r\n #6 0x00007f0ccb637729 get_sysdep_segment_value /build/glibc-e2p3jK/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #7 0x00007f0ccb637729 _nl_load_domain /build/glibc-e2p3jK/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #8 0x00007f0ccb648fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #9 0x0000557d54cd0f88 (anonymous namespace)::VectorCombine::foldShuffleToIdentity(llvm::Instruction&)::'lambda3'(std::pair<llvm::Value*, int>)::operator()(std::pair<llvm::Value*, int>) const (.isra.0) VectorCombine.cpp:0:0\r\n#10 0x0000557d54cdac11 (anonymous namespace)::VectorCombine::foldShuffleToIdentity(llvm::Instruction&) VectorCombine.cpp:0:0\r\n#11 0x0000557d54ce56f1 (anonymous namespace)::VectorCombine::run()::'lambda'(llvm::Instruction&)::operator()(llvm::Instruction&) const (.isra.0) VectorCombine.cpp:0:0\r\n#12 0x0000557d54ce695d llvm::VectorCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x596c95d)\r\n#13 0x0000557d547ca386 llvm::detail::PassModel<llvm::Function, llvm::VectorCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x5450386)\r\n#14 0x0000557d50a03b4c 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/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x1689b4c)\r\n#15 0x0000557d52d96d0d llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x3a1cd0d)\r\n#16 0x0000557d509e66d6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x166c6d6)\r\n#17 0x0000557d52d94b9d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x3a1ab9d)\r\n#18 0x0000557d5366aa28 (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 0x0000557d5366dd85 (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#20 0x0000557d5366e449 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/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x42f4449)\r\n#21 0x0000557d53cc97ca clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x494f7ca)\r\n#22 0x0000557d55a3f65c clang::ParseAST(clang::Sema&, bool, bool) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x66c565c)\r\n#23 0x0000557d53cc8278 clang::CodeGenAction::ExecuteAction() (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x494e278)\r\n#24 0x0000557d53f56729 clang::FrontendAction::Execute() (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x4bdc729)\r\n#25 0x0000557d53edc48e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x4b6248e)\r\n#26 0x0000557d54040e86 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x4cc6e86)\r\n#27 0x0000557d505e1bbc cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x1267bbc)\r\n#28 0x0000557d505dacca ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#29 0x0000557d53d0d8ed 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#30 0x0000557d5331a9f0 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x3fa09f0)\r\n#31 0x0000557d53d0df0f 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#32 0x0000557d53cd2a4c clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x4958a4c)\r\n#33 0x0000557d53cd34dd clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x49594dd)\r\n#34 0x0000557d53cdb8f5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x49618f5)\r\n#35 0x0000557d505defab clang_main(int, char**, llvm::ToolContext const&) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x1264fab)\r\n#36 0x0000557d504db96b main (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x116196b)\r\n#37 0x00007f0ccb639083 __libc_start_main /build/glibc-e2p3jK/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#38 0x0000557d505da79e _start (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x126079e)\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 a4d10266d20bfe5930dfed77e17832af341ed66e)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin\r\nBuild config: +assertions\r\n```",
"author": "dyung",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
a4d10266d20bfe5930dfed77e17832af341ed66e
| null |
118850
|
https://github.com/llvm/llvm-project/issues/118850
|
crash
|
9ad22cf0ee9eb686ea9fd76fd9cc41f4c006ccbc
| 2024-12-05T18:11:28
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "4f7f71b7bccdc38f37b82981e8fa9ceb536a7016",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": [
[
168,
174
]
],
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": [
"UnrollState::unrollWidenInductionByUF"
],
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 4f7f71b7bccdc38f37b82981e8fa9ceb536a7016
Author: Florian Hahn <flo@fhahn.com>
Date: Fri Dec 6 16:28:47 2024 +0000
[VPlan] Compare APInt instead of getSExtValue to fix crash in unroll.
getSExtValue assumes the result fits in 64 bits, but this may not be the
case for indcutions with wider types. Instead, directly perform the
compare on the APInt for the ConstantInt.
Fixes https://github.com/llvm/llvm-project/issues/118850.
diff --git a/llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp b/llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp
index f653269713b3..ff6c9295ee20 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp
@@ -168,7 +168,7 @@ void UnrollState::unrollWidenInductionByUF(
auto *ConstStep = ScalarStep->isLiveIn()
? dyn_cast<ConstantInt>(ScalarStep->getLiveInIRValue())
: nullptr;
- if (!ConstStep || ConstStep->getZExtValue() != 1) {
+ if (!ConstStep || ConstStep->getValue() != 1) {
if (TypeInfo.inferScalarType(ScalarStep) != IVTy) {
ScalarStep =
Builder.createWidenCast(Instruction::Trunc, ScalarStep, IVTy);
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/interleave-with-i65-induction.ll",
"commands": [
"opt -p loop-vectorize -force-vector-width=4 -force-vector-interleave=2 -S %s"
],
"tests": [
{
"test_name": "i65_induction_with_negative_step",
"test_body": "define void @i65_induction_with_negative_step(ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.i65 = phi i65 [ 0, %entry ], [ %iv.i65.next, %loop ]\n %for = phi i64 [ 0, %entry ], [ %trunc, %loop ]\n %trunc = trunc i65 %iv.i65 to i64\n %gep = getelementptr inbounds i64, ptr %dst, i64 %trunc\n store i64 %for, ptr %gep, align 8\n %iv.next = add i64 %iv, 1\n %icmp = icmp eq i64 %iv.next, 1000\n %iv.i65.next = add i65 %iv.i65, -1\n br i1 %icmp, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "Assertion `getActiveBits() <= 64 && \"Too many bits for uint64_t\"' failed.",
"body": "To reproduce run the test below with -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-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32-ni:1-p2:32:8:8:32-ni:2\"\ntarget triple = \"aarch64-none-linux-gnu\"\n\ndefine double @wombat() gc \"statepoint-example\" {\nbb:\n br label %bb2\n\nbb1: ; preds = %bb2\n ret double 0.000000e+00\n\nbb2: ; preds = %bb2, %bb\n %phi = phi i64 [ 0, %bb ], [ %add, %bb2 ]\n %phi3 = phi i65 [ 0, %bb ], [ %add5, %bb2 ]\n %phi4 = phi i64 [ 0, %bb ], [ %trunc, %bb2 ]\n %trunc = trunc i65 %phi3 to i64\n store i64 0, ptr addrspace(1) null, align 8\n %add = add i64 %phi, 1\n %icmp = icmp ugt i64 %add, 0\n %add5 = add i65 %phi3, -1\n br i1 %icmp, label %bb2, label %bb1\n}\n```\nReproducer: https://godbolt.org/z/cjEcv8b4Y\n\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 0x00000000051b3748 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x51b3748)\n #1 0x00000000051b113c SignalHandler(int) Signals.cpp:0:0\n #2 0x000071a06ec42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x000071a06ec969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x000071a06ec42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x000071a06ec287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x000071a06ec2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x000071a06ec39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x0000000000b2d8a9 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xb2d8a9)\n #9 0x0000000004308ae6 (anonymous namespace)::UnrollState::unrollBlock(llvm::VPBlockBase*) VPlanUnroll.cpp:0:0\n#10 0x000000000430788c (anonymous namespace)::UnrollState::unrollBlock(llvm::VPBlockBase*) VPlanUnroll.cpp:0:0\n#11 0x0000000004309060 llvm::VPlanTransforms::unrollByUF(llvm::VPlan&, unsigned int, llvm::LLVMContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4309060)\n#12 0x0000000004176b76 llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool, llvm::DenseMap<llvm::SCEV const*, llvm::Value*, llvm::DenseMapInfo<llvm::SCEV const*, void>, llvm::detail::DenseMapPair<llvm::SCEV const*, llvm::Value*>> const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4176b76)\n#13 0x000000000418cb6f llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x418cb6f)\n#14 0x000000000418ebd9 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x418ebd9)\n#15 0x000000000418f213 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x418f213)\n#16 0x0000000002fcba8e 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+0x2fcba8e)\n#17 0x0000000004fb2700 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4fb2700)\n#18 0x0000000000e33a9e 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+0xe33a9e)\n#19 0x0000000004fb101b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4fb101b)\n#20 0x0000000000e3312e 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+0xe3312e)\n#21 0x0000000004fb0a20 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4fb0a20)\n#22 0x0000000000910a1a 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+0x910a1a)\n#23 0x0000000000903099 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x903099)\n#24 0x000071a06ec29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#25 0x000071a06ec29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#26 0x00000000008fa97e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8fa97e)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```\n",
"author": "TatyanaDoubts",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "huang-me",
"body": "Hi @TatyanaDoubts, \nHow did you get the IR snippet? \nThe IR you provided is weird. I'll have to check where i65 constant 0 in `%phi3 = phi i65 [ 0, %bb ], [ %add5, %bb2 ]` come from since it seems it's the origin of the problem."
},
{
"author": "fhahn",
"body": "I suspect this was found via a fuzzer, thanks for sharing the test case!"
},
{
"author": "TatyanaDoubts",
"body": "Hi @huang-me, @fhahn, yes this crash was found by the fuzzer generated test. "
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
8ec406757cb92f352888a3d4092397f2b5a7d1d9
| null |
137582
|
https://github.com/llvm/llvm-project/issues/137582
|
miscompilation
|
4075a3698a3fdda3a77ce2456e3bfefbc0f0c56e
| 2025-04-28T05:48:58
|
[
"llvm/test/Transforms/CorrelatedValuePropagation"
] |
{
"fix_commit": "830cf36bd4c491ef28d9bba74737e324639bb4cd",
"components": [
"IR",
"LazyValueInfo",
"ValueTracking"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": [
[
546,
569
],
[
586,
592
]
],
"llvm/lib/Analysis/ValueTracking.cpp": [
[
7201,
7220
],
[
7287,
7293
]
],
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": [
[
585,
590
]
],
"llvm/lib/Analysis/LazyValueInfo.cpp": [
[
1701,
1707
]
],
"llvm/lib/IR/Instruction.cpp": [
[
532,
539
],
[
554,
559
]
],
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": [
"llvm::isNotCrossLaneOperation",
"llvm::isSafeToSpeculativelyExecuteWithOpcode"
],
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": [
"isSafeToSpeculativelyExecuteWithVariableReplaced"
],
"llvm/lib/Analysis/LazyValueInfo.cpp": [
"LazyValueInfoImpl::getValueAtUse"
],
"llvm/lib/IR/Instruction.cpp": [
"Instruction::dropUBImplyingAttrsAndMetadata",
"Instruction::dropUBImplyingAttrsAndUnknownMetadata",
"Instruction::isExact"
],
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 830cf36bd4c491ef28d9bba74737e324639bb4cd
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Wed Apr 30 11:53:38 2025 +0800
[LVI][ValueTracking] Take UB-implying attributes into account in `isSafeToSpeculativelyExecute` (#137604)
Closes https://github.com/llvm/llvm-project/issues/137582.
In the original case, LVI uses the edge information in `%entry ->
%if.end` to get a more precise result. However, since the call to `smin`
has an `noundef` return attribute, an immediate UB will be triggered
after optimization.
Currently, `isSafeToSpeculativelyExecuteWithOpcode(%min)` returns true
because
https://github.com/llvm/llvm-project/commit/6a288c1e32351d4be3b7630841af078fa1c3bb8b
only checks whether the function is speculatable. However, it is not
enough in this case.
This patch takes UB-implying attributes into account if
`IgnoreUBImplyingAttrs` is set to false. If it is set to true, the
caller is responsible for correctly propagating UB-implying attributes.
diff --git a/llvm/include/llvm/Analysis/ValueTracking.h b/llvm/include/llvm/Analysis/ValueTracking.h
index f927838c843a..61dbb07e7128 100644
--- a/llvm/include/llvm/Analysis/ValueTracking.h
+++ b/llvm/include/llvm/Analysis/ValueTracking.h
@@ -539,6 +539,12 @@ bool isNotCrossLaneOperation(const Instruction *I);
/// move the instruction as long as the correct dominance relationships for
/// the operands and users hold.
///
+/// If \p UseVariableInfo is true, the information from non-constant operands
+/// will be taken into account.
+///
+/// If \p IgnoreUBImplyingAttrs is true, UB-implying attributes will be ignored.
+/// The caller is responsible for correctly propagating them after hoisting.
+///
/// This method can return true for instructions that read memory;
/// for such instructions, moving them may change the resulting value.
bool isSafeToSpeculativelyExecute(const Instruction *I,
@@ -546,24 +552,28 @@ bool isSafeToSpeculativelyExecute(const Instruction *I,
AssumptionCache *AC = nullptr,
const DominatorTree *DT = nullptr,
const TargetLibraryInfo *TLI = nullptr,
- bool UseVariableInfo = true);
+ bool UseVariableInfo = true,
+ bool IgnoreUBImplyingAttrs = true);
inline bool isSafeToSpeculativelyExecute(const Instruction *I,
BasicBlock::iterator CtxI,
AssumptionCache *AC = nullptr,
const DominatorTree *DT = nullptr,
const TargetLibraryInfo *TLI = nullptr,
- bool UseVariableInfo = true) {
+ bool UseVariableInfo = true,
+ bool IgnoreUBImplyingAttrs = true) {
// Take an iterator, and unwrap it into an Instruction *.
- return isSafeToSpeculativelyExecute(I, &*CtxI, AC, DT, TLI, UseVariableInfo);
+ return isSafeToSpeculativelyExecute(I, &*CtxI, AC, DT, TLI, UseVariableInfo,
+ IgnoreUBImplyingAttrs);
}
/// Don't use information from its non-constant operands. This helper is used
/// when its operands are going to be replaced.
-inline bool
-isSafeToSpeculativelyExecuteWithVariableReplaced(const Instruction *I) {
+inline bool isSafeToSpeculativelyExecuteWithVariableReplaced(
+ const Instruction *I, bool IgnoreUBImplyingAttrs = true) {
return isSafeToSpeculativelyExecute(I, nullptr, nullptr, nullptr, nullptr,
- /*UseVariableInfo=*/false);
+ /*UseVariableInfo=*/false,
+ IgnoreUBImplyingAttrs);
}
/// This returns the same result as isSafeToSpeculativelyExecute if Opcode is
@@ -586,7 +596,8 @@ isSafeToSpeculativelyExecuteWithVariableReplaced(const Instruction *I) {
bool isSafeToSpeculativelyExecuteWithOpcode(
unsigned Opcode, const Instruction *Inst, const Instruction *CtxI = nullptr,
AssumptionCache *AC = nullptr, const DominatorTree *DT = nullptr,
- const TargetLibraryInfo *TLI = nullptr, bool UseVariableInfo = true);
+ const TargetLibraryInfo *TLI = nullptr, bool UseVariableInfo = true,
+ bool IgnoreUBImplyingAttrs = true);
/// Returns true if the result or effects of the given instructions \p I
/// depend values not reachable through the def use graph.
diff --git a/llvm/include/llvm/IR/Instruction.h b/llvm/include/llvm/IR/Instruction.h
index 900384432d75..d8069b2fb02a 100644
--- a/llvm/include/llvm/IR/Instruction.h
+++ b/llvm/include/llvm/IR/Instruction.h
@@ -585,6 +585,10 @@ public:
/// This should be used when speculating instructions.
void dropUBImplyingAttrsAndMetadata();
+ /// Return true if this instruction has UB-implying attributes
+ /// that can cause immediate undefined behavior.
+ bool hasUBImplyingAttrs() const LLVM_READONLY;
+
/// Determine whether the exact flag is set.
bool isExact() const LLVM_READONLY;
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp
index e49e004a48a5..2a562484fc37 100644
--- a/llvm/lib/Analysis/LazyValueInfo.cpp
+++ b/llvm/lib/Analysis/LazyValueInfo.cpp
@@ -1701,7 +1701,8 @@ ValueLatticeElement LazyValueInfoImpl::getValueAtUse(const Use &U) {
// of a cycle, we might end up reasoning about values from different cycle
// iterations (PR60629).
if (!CurrI->hasOneUse() ||
- !isSafeToSpeculativelyExecuteWithVariableReplaced(CurrI))
+ !isSafeToSpeculativelyExecuteWithVariableReplaced(
+ CurrI, /*IgnoreUBImplyingAttrs=*/false))
break;
CurrU = &*CurrI->use_begin();
}
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 1d3f8b7207a6..256e77b40a97 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -7201,20 +7201,19 @@ bool llvm::isNotCrossLaneOperation(const Instruction *I) {
!isa<CallBase, BitCastInst, ExtractElementInst>(I);
}
-bool llvm::isSafeToSpeculativelyExecute(const Instruction *Inst,
- const Instruction *CtxI,
- AssumptionCache *AC,
- const DominatorTree *DT,
- const TargetLibraryInfo *TLI,
- bool UseVariableInfo) {
+bool llvm::isSafeToSpeculativelyExecute(
+ const Instruction *Inst, const Instruction *CtxI, AssumptionCache *AC,
+ const DominatorTree *DT, const TargetLibraryInfo *TLI, bool UseVariableInfo,
+ bool IgnoreUBImplyingAttrs) {
return isSafeToSpeculativelyExecuteWithOpcode(Inst->getOpcode(), Inst, CtxI,
- AC, DT, TLI, UseVariableInfo);
+ AC, DT, TLI, UseVariableInfo,
+ IgnoreUBImplyingAttrs);
}
bool llvm::isSafeToSpeculativelyExecuteWithOpcode(
unsigned Opcode, const Instruction *Inst, const Instruction *CtxI,
AssumptionCache *AC, const DominatorTree *DT, const TargetLibraryInfo *TLI,
- bool UseVariableInfo) {
+ bool UseVariableInfo, bool IgnoreUBImplyingAttrs) {
#ifndef NDEBUG
if (Inst->getOpcode() != Opcode) {
// Check that the operands are actually compatible with the Opcode override.
@@ -7287,7 +7286,11 @@ bool llvm::isSafeToSpeculativelyExecuteWithOpcode(
// The called function could have undefined behavior or side-effects, even
// if marked readnone nounwind.
- return Callee && Callee->isSpeculatable();
+ if (!Callee || !Callee->isSpeculatable())
+ return false;
+ // Since the operands may be changed after hoisting, undefined behavior may
+ // be triggered by some UB-implying attributes.
+ return IgnoreUBImplyingAttrs || !CI->hasUBImplyingAttrs();
}
case Instruction::VAArg:
case Instruction::Alloca:
diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp
index e55a4b41e4d0..6f858110fb8c 100644
--- a/llvm/lib/IR/Instruction.cpp
+++ b/llvm/lib/IR/Instruction.cpp
@@ -532,8 +532,8 @@ void Instruction::dropUBImplyingAttrsAndUnknownMetadata(
if (!CB)
return;
// For call instructions, we also need to drop parameter and return attributes
- // that are can cause UB if the call is moved to a location where the
- // attribute is not valid.
+ // that can cause UB if the call is moved to a location where the attribute is
+ // not valid.
AttributeList AL = CB->getAttributes();
if (AL.isEmpty())
return;
@@ -554,6 +554,20 @@ void Instruction::dropUBImplyingAttrsAndMetadata() {
dropUBImplyingAttrsAndUnknownMetadata(KnownIDs);
}
+bool Instruction::hasUBImplyingAttrs() const {
+ auto *CB = dyn_cast<CallBase>(this);
+ if (!CB)
+ return false;
+ // For call instructions, we also need to check parameter and return
+ // attributes that can cause UB.
+ for (unsigned ArgNo = 0; ArgNo < CB->arg_size(); ArgNo++)
+ if (CB->isPassingUndefUB(ArgNo))
+ return true;
+ return CB->hasRetAttr(Attribute::NoUndef) ||
+ CB->hasRetAttr(Attribute::Dereferenceable) ||
+ CB->hasRetAttr(Attribute::DereferenceableOrNull);
+}
+
bool Instruction::isExact() const {
return cast<PossiblyExactOperator>(this)->isExact();
}
|
[
{
"file": "llvm/test/Transforms/CorrelatedValuePropagation/pr137582.ll",
"commands": [
"opt < %s -passes=correlated-propagation -S"
],
"tests": [
{
"test_name": "test",
"test_body": "define i8 @test(i16 %x) {\nentry:\n %or = or i16 %x, 1\n %conv = trunc i16 %or to i8\n %min = call noundef i8 @llvm.smin.i8(i8 %conv, i8 0)\n %cond = icmp eq i16 %x, 0\n br i1 %cond, label %if.end, label %if.then\n\nif.then: ; preds = %entry\n br label %if.end\n\nif.end: ; preds = %if.then, %entry\n %res = phi i8 [ %min, %entry ], [ 0, %if.then ]\n ret i8 %res\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i8 @llvm.smin.i8(i8, i8) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[CVP] Miscompilation at -O3",
"body": "Reproducer: https://alive2.llvm.org/ce/z/x4KrLX\n```\n\n----------------------------------------\ndefine i8 @func_124(i16 %.promoted) {\nentry:\n %inc20.i = or i16 %.promoted, 1\n %conv.i.i = trunc i16 %inc20.i to i8\n %narrow.i.i.i = smin i8 %conv.i.i, 0\n assume_welldefined i8 %narrow.i.i.i\n %tobool.not.i46 = icmp eq i16 %.promoted, 0\n br i1 %tobool.not.i46, label %func_127.exit, label %land.rhs.i47\n\nland.rhs.i47:\n br label %func_127.exit\n\nfunc_127.exit:\n %conv5.i.i.pn.in = phi i8 [ %narrow.i.i.i, %entry ], [ 0, %land.rhs.i47 ]\n ret i8 %conv5.i.i.pn.in\n}\n=>\ndefine i8 @func_124(i16 %.promoted) {\nentry:\n %inc20.i = or i16 %.promoted, 1\n %conv.i.i = trunc nsw nuw i16 %inc20.i to i8\n %narrow.i.i.i = smin i8 %conv.i.i, 0\n assume_welldefined i8 %narrow.i.i.i\n %tobool.not.i46 = icmp eq i16 %.promoted, 0\n br i1 %tobool.not.i46, label %func_127.exit, label %land.rhs.i47\n\nland.rhs.i47:\n br label %func_127.exit\n\nfunc_127.exit:\n %conv5.i.i.pn.in = phi i8 [ %narrow.i.i.i, %entry ], [ 0, %land.rhs.i47 ]\n %#range_0_%conv5.i.i.pn.in = !range i8 %conv5.i.i.pn.in, i8 128, i8 1\n ret i8 %#range_0_%conv5.i.i.pn.in\n}\nTransformation doesn't verify!\n\nERROR: Source is more defined than target\n\nExample:\ni16 %.promoted = #x0080 (128)\n\nSource:\ni16 %inc20.i = #x0081 (129)\ni8 %conv.i.i = #x81 (129, -127)\ni8 %narrow.i.i.i = #x81 (129, -127)\ni1 %tobool.not.i46 = #x0 (0)\n >> Jump to %land.rhs.i47\n >> Jump to %func_127.exit\ni8 %conv5.i.i.pn.in = #x00 (0)\n\nTarget:\ni16 %inc20.i = #x0081 (129)\ni8 %conv.i.i = poison\ni8 %narrow.i.i.i = poison\nvoid = UB triggered!\n\n\nSummary:\n 0 correct transformations\n 1 incorrect transformations\n 0 failed-to-prove transformations\n 0 Alive2 errors\n```\n",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:analysis",
"generated by fuzzer"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Related code: https://github.com/llvm/llvm-project/blob/60b3a5b7e7db40ec74d3c4839a3fae8b73d98851/llvm/lib/Analysis/LazyValueInfo.cpp#L1694-L1705"
}
]
}
| true
|
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
|
b9666cf2034e103ef28280fae61f43fae7e28192
| null |
135800
|
https://github.com/llvm/llvm-project/issues/135800
|
crash
|
a1d52fcdca8bda4fe8c6652b2de83f408f4ad4f2
| 2025-04-15T15:58:08
|
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "2271f0bebd48c9ed8b16b500886a819c4f269a6a",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
9575,
9580
]
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::canBuildSplitNode"
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 2271f0bebd48c9ed8b16b500886a819c4f269a6a
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Tue Apr 15 13:02:32 2025 -0700
[SLP]Check for perfect/shuffled match for the split node
If the potential split node is a perfect/shuffled match of another split
node, need to skip creation of the another split node with the same
scalars, it should be a buildvector.
Fixes #135800
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 253933a2438c..234cd340ebc1 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -9575,6 +9575,24 @@ bool BoUpSLP::canBuildSplitNode(ArrayRef<Value *> VL,
!SplitAlternateInstructions)
return false;
+ // Check if this is a duplicate of another split entry.
+ LLVM_DEBUG(dbgs() << "SLP: \tChecking bundle: " << *LocalState.getMainOp()
+ << ".\n");
+ for (TreeEntry *E : getSplitTreeEntries(LocalState.getMainOp())) {
+ if (E->isSame(VL)) {
+ LLVM_DEBUG(dbgs() << "SLP: Perfect diamond merge at "
+ << *LocalState.getMainOp() << ".\n");
+ return false;
+ }
+ SmallPtrSet<Value *, 8> Values(llvm::from_range, E->Scalars);
+ if (all_of(VL, [&](Value *V) {
+ return isa<PoisonValue>(V) || Values.contains(V);
+ })) {
+ LLVM_DEBUG(dbgs() << "SLP: Gathering due to full overlap.\n");
+ return false;
+ }
+ }
+
ReorderIndices.assign(VL.size(), VL.size());
SmallBitVector Op1Indices(VL.size());
for (auto [Idx, V] : enumerate(VL)) {
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/split-node-full-match.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @test(double %0) {\n;\n.thread:\n %1 = call double null(ptr null, ptr null, ptr null)\n %2 = call double null(ptr null, ptr null, ptr null)\n br i1 false, label %3, label %5\n\n3:\n %4 = call double null(ptr null, ptr null, ptr null)\n br label %5\n\n5:\n %.1226 = phi double [ %4, %3 ], [ 0.000000e+00, %.thread ]\n %.1222 = phi double [ 0.000000e+00, %3 ], [ 0.000000e+00, %.thread ]\n %.1218 = phi double [ %0, %3 ], [ 0.000000e+00, %.thread ]\n %.1216 = phi double [ 0.000000e+00, %3 ], [ 0.000000e+00, %.thread ]\n br i1 false, label %.lr.ph272.preheader, label %._crit_edge\n\n.lr.ph272.preheader:\n br i1 false, label %._crit_edge, label %6\n\n6:\n %7 = fdiv double 0.000000e+00, 0.000000e+00\n %8 = fsub double 0.000000e+00, %7\n %9 = fdiv double 0.000000e+00, 0.000000e+00\n %10 = fsub double 0.000000e+00, %9\n br i1 false, label %11, label %._crit_edge\n\n11:\n br label %._crit_edge\n\n._crit_edge:\n %.2227.lcssa = phi double [ %.1226, %5 ], [ 0.000000e+00, %11 ], [ %.1226, %6 ], [ %.1226, %.lr.ph272.preheader ]\n %.2223.lcssa = phi double [ %.1222, %5 ], [ 0.000000e+00, %11 ], [ %.1222, %6 ], [ %.1222, %.lr.ph272.preheader ]\n %.2219.lcssa = phi double [ %.1218, %5 ], [ 0.000000e+00, %11 ], [ %.1218, %6 ], [ %.1218, %.lr.ph272.preheader ]\n %.2.lcssa = phi double [ %.1216, %5 ], [ %0, %11 ], [ %.1216, %6 ], [ %.1216, %.lr.ph272.preheader ]\n %.0213.lcssa = phi double [ %2, %5 ], [ 0.000000e+00, %11 ], [ %10, %6 ], [ %2, %.lr.ph272.preheader ]\n %.0211.lcssa = phi double [ %1, %5 ], [ 0.000000e+00, %11 ], [ %8, %6 ], [ %1, %.lr.ph272.preheader ]\n ret void\n}",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/split-node-no-reorder-copy.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-sie-ps5 -mcpu=znver2 < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define i1 @test(ptr %0, ptr %1, <2 x float> %2, <2 x float> %3, <2 x float> %4) {\n %6 = load float, ptr %1, align 4\n %7 = load float, ptr %0, align 4\n %8 = fmul float %6, %6\n %9 = fmul float %7, %7\n %10 = fmul float %7, %7\n %11 = fmul float %7, %7\n %12 = fmul float %7, %7\n %13 = fmul float %7, %7\n %14 = load float, ptr %0, align 4\n %15 = fmul float %14, %14\n %16 = fmul float %14, %14\n %17 = extractelement <2 x float> %2, i64 0\n %18 = extractelement <2 x float> %2, i64 0\n %19 = fmul float %17, %17\n %20 = fmul float %18, %18\n %21 = extractelement <2 x float> %3, i64 0\n %22 = extractelement <2 x float> %2, i64 0\n %23 = fmul float %21, %21\n %24 = fmul float %22, %22\n %25 = extractelement <2 x float> %2, i64 0\n %26 = extractelement <2 x float> %2, i64 0\n %27 = fmul float %25, %25\n %28 = fmul float %26, %26\n %29 = extractelement <2 x float> %2, i64 0\n %30 = extractelement <2 x float> %4, i64 0\n %31 = fmul float %29, %29\n %32 = fmul float %30, %30\n %33 = fadd reassoc nsz float %8, %9\n %34 = fadd reassoc nsz float %33, %10\n %35 = fadd reassoc nsz float %34, %11\n %36 = fadd reassoc nsz float %35, %12\n %37 = fadd reassoc nsz float %36, %13\n %38 = fadd reassoc nsz float %37, %15\n %39 = fadd reassoc nsz float %38, %16\n %40 = fadd reassoc nsz float %39, %19\n %41 = fadd reassoc nsz float %40, %20\n %42 = fadd reassoc nsz float %41, %23\n %43 = fadd reassoc nsz float %42, %24\n %44 = fadd reassoc nsz float %43, %27\n %45 = fadd reassoc nsz float %44, %28\n %46 = fadd reassoc nsz float %45, %31\n %47 = fadd reassoc nsz float %46, %32\n %48 = call float @foo(float %47)\n ret i1 false\n}\n\ndeclare float @foo(float)\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[slp] ICE: Instruction does not dominate all uses!",
"body": "First showed up in 04c38981a9ce3e6225669c0e41cab947e3e7989f, last known good commit was 0283bb3afcc5dc521f6b2e7d541a830a9546ed80.\n\nCommits in this range with SLP in the subject line:\n```\n$ g log 0283bb3afcc5dc521f6b2e7d541a830a9546ed80^1..04c38981a9ce3e6225669c0e41cab947e3e7989f|grep -i slp\n'61d04f1aac96 Thu Apr 10 16:05:01 2025 -0400 [SLP][NFC]Extract preliminary checks from buildTree_rec, NFC'\n'aaaa2a325bd1 Thu Apr 10 12:06:38 2025 -0400 [SLP]Support vectorization of previously vectorized scalars in split nodes'\n'4ea57b3481c0 Thu Apr 10 08:30:43 2025 -0700 [SLP]Fix detection of matching splat vector'\n'396e2ef3b7f4 Thu Apr 10 08:20:28 2025 -0700 [SLP][NFC]Add a test with incorrect identity match for less-defined splat'\n'a693f23ef2fc Thu Apr 10 23:07:45 2025 +0800 [SLP][REVEC] Fix CompressVectorize does not expand mask when REVEC is enabled. (#135174)'\n'd02a704ec952 Thu Apr 10 18:54:45 2025 +0800 [SLP][REVEC] Make getExtractWithExtendCost support FixedVectorType as Dst. (#134822)'\n```\n\n```\n$ opt -passes=slp-vectorizer reduced.ll -disable-output\nInstruction does not dominate all uses!\n %15 = call <6 x double> @llvm.vector.insert.v6f64.v2f64(<6 x double> %14, <2 x double> %13, i64 4)\n %9 = shufflevector <6 x double> %15, <6 x double> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>\nInstruction does not dominate all uses!\n %13 = insertelement <2 x double> %12, double %1, i32 1\n %11 = call <6 x double> @llvm.vector.insert.v6f64.v2f64(<6 x double> %10, <2 x double> %13, i64 4)\nLLVM ERROR: Broken module found, compilation aborted!\n```\n\n```\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 @foo(double %0) {\n.thread:\n %1 = call double null(ptr null, ptr null, ptr null)\n %2 = call double null(ptr null, ptr null, ptr null)\n br i1 false, label %3, label %5\n\n3: ; preds = %.thread\n %4 = call double null(ptr null, ptr null, ptr null)\n br label %5\n\n5: ; preds = %3, %.thread\n %.1226 = phi double [ %4, %3 ], [ 0.000000e+00, %.thread ]\n %.1222 = phi double [ 0.000000e+00, %3 ], [ 0.000000e+00, %.thread ]\n %.1218 = phi double [ %0, %3 ], [ 0.000000e+00, %.thread ]\n %.1216 = phi double [ 0.000000e+00, %3 ], [ 0.000000e+00, %.thread ]\n br i1 false, label %.lr.ph272.preheader, label %._crit_edge\n\n.lr.ph272.preheader: ; preds = %5\n br i1 false, label %._crit_edge, label %6\n\n6: ; preds = %.lr.ph272.preheader\n %7 = fdiv double 0.000000e+00, 0.000000e+00\n %8 = fsub double 0.000000e+00, %7\n %9 = fdiv double 0.000000e+00, 0.000000e+00\n %10 = fsub double 0.000000e+00, %9\n br i1 false, label %11, label %._crit_edge\n\n11: ; preds = %6\n br label %._crit_edge\n\n._crit_edge: ; preds = %11, %6, %.lr.ph272.preheader, %5\n %.2227.lcssa = phi double [ %.1226, %5 ], [ 0.000000e+00, %11 ], [ %.1226, %6 ], [ %.1226, %.lr.ph272.preheader ]\n %.2223.lcssa = phi double [ %.1222, %5 ], [ 0.000000e+00, %11 ], [ %.1222, %6 ], [ %.1222, %.lr.ph272.preheader ]\n %.2219.lcssa = phi double [ %.1218, %5 ], [ 0.000000e+00, %11 ], [ %.1218, %6 ], [ %.1218, %.lr.ph272.preheader ]\n %.2.lcssa = phi double [ %.1216, %5 ], [ %0, %11 ], [ %.1216, %6 ], [ %.1216, %.lr.ph272.preheader ]\n %.0213.lcssa = phi double [ %2, %5 ], [ 0.000000e+00, %11 ], [ %10, %6 ], [ %2, %.lr.ph272.preheader ]\n %.0211.lcssa = phi double [ %1, %5 ], [ 0.000000e+00, %11 ], [ %8, %6 ], [ %1, %.lr.ph272.preheader ]\n ret void\n}\n```",
"author": "ashermancinelli",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
aaaa2a325bd1abb8c87e0171384fd2c42da5e38a
| null |
162530
|
https://github.com/llvm/llvm-project/issues/162530
|
crash
|
c940bfd7e6218c01c6a517e8d6afc8067e933ffd
| 2025-10-08T18:41:41
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "3ad5765e2341b53bff480b7992b1ed428dc603d6",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
[
7933,
7938
],
[
8116,
8126
],
[
8154,
8162
]
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"VPRecipeBuilder::collectScaledReductions",
"VPRecipeBuilder::getScaledReductions",
"VPRecipeBuilder::tryToCreatePartialReduction",
"VPRecipeBuilder::tryToCreateWidenRecipe"
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 3ad5765e2341b53bff480b7992b1ed428dc603d6
Author: Florian Hahn <flo@fhahn.com>
Date: Thu Nov 6 21:45:57 2025 +0000
[LV] Check all users of partial reductions in chain have same scale. (#162822)
Check that all partial reductions in a chain are only used by other
partial reductions with the same scale factor. Otherwise we end up
creating users of scaled reductions where the types of the other
operands don't match.
A similar issue was addressed in
https://github.com/llvm/llvm-project/pull/158603, but misses the chained
cases.
Fixes https://github.com/llvm/llvm-project/issues/162530.
PR: https://github.com/llvm/llvm-project/pull/162822
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 906fa2f857c2..b7224a33f47b 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7933,6 +7933,26 @@ void VPRecipeBuilder::collectScaledReductions(VFRange &Range) {
(!Chain.ExtendB || ExtendIsOnlyUsedByPartialReductions(Chain.ExtendB)))
ScaledReductionMap.try_emplace(Chain.Reduction, Pair.second);
}
+
+ // Check that all partial reductions in a chain are only used by other
+ // partial reductions with the same scale factor. Otherwise we end up creating
+ // users of scaled reductions where the types of the other operands don't
+ // match.
+ for (const auto &[Chain, Scale] : PartialReductionChains) {
+ auto AllUsersPartialRdx = [ScaleVal = Scale, this](const User *U) {
+ auto *UI = cast<Instruction>(U);
+ if (isa<PHINode>(UI) && UI->getParent() == OrigLoop->getHeader()) {
+ return all_of(UI->users(), [ScaleVal, this](const User *U) {
+ auto *UI = cast<Instruction>(U);
+ return ScaledReductionMap.lookup_or(UI, 0) == ScaleVal;
+ });
+ }
+ return ScaledReductionMap.lookup_or(UI, 0) == ScaleVal ||
+ !OrigLoop->contains(UI->getParent());
+ };
+ if (!all_of(Chain.Reduction->users(), AllUsersPartialRdx))
+ ScaledReductionMap.erase(Chain.Reduction);
+ }
}
bool VPRecipeBuilder::getScaledReductions(
@@ -8116,11 +8136,8 @@ VPRecipeBase *VPRecipeBuilder::tryToCreateWidenRecipe(VPSingleDefRecipe *R,
if (isa<LoadInst>(Instr) || isa<StoreInst>(Instr))
return tryToWidenMemory(Instr, Operands, Range);
- if (std::optional<unsigned> ScaleFactor = getScalingForReduction(Instr)) {
- if (auto PartialRed =
- tryToCreatePartialReduction(Instr, Operands, ScaleFactor.value()))
- return PartialRed;
- }
+ if (std::optional<unsigned> ScaleFactor = getScalingForReduction(Instr))
+ return tryToCreatePartialReduction(Instr, Operands, ScaleFactor.value());
if (!shouldWiden(Instr, Range))
return nullptr;
@@ -8154,9 +8171,9 @@ VPRecipeBuilder::tryToCreatePartialReduction(Instruction *Reduction,
isa<VPPartialReductionRecipe>(BinOpRecipe))
std::swap(BinOp, Accumulator);
- if (ScaleFactor !=
- vputils::getVFScaleFactor(Accumulator->getDefiningRecipe()))
- return nullptr;
+ assert(ScaleFactor ==
+ vputils::getVFScaleFactor(Accumulator->getDefiningRecipe()) &&
+ "all accumulators in chain must have same scale factor");
unsigned ReductionOpcode = Reduction->getOpcode();
if (ReductionOpcode == Instruction::Sub) {
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-incomplete-chains.ll",
"commands": [
"opt --mattr=+neon,+dotprod -passes=loop-vectorize -force-vector-interleave=1 -enable-epilogue-vectorization=false -S %s"
],
"tests": [
{
"test_name": "test_incomplete_chain_without_mul",
"test_body": "target triple = \"arm64-apple-macosx\"\n\ndefine i16 @test_incomplete_chain_without_mul(ptr noalias %dst, ptr %A, ptr %B) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %red = phi i16 [ 0, %entry ], [ %red.next, %loop ]\n %l.a = load i8, ptr %A, align 1\n %a.ext = zext i8 %l.a to i16\n store i16 %a.ext, ptr %dst, align 2\n %l.b = load i8, ptr %B, align 1\n %b.ext = zext i8 %l.b to i16\n %add = add i16 %red, %b.ext\n %add.1 = add i16 %add, %a.ext\n %red.next = add i16 %add.1, %b.ext\n %iv.next = add i64 %iv, 1\n %ec = icmp ult i64 %iv, 1024\n br i1 %ec, label %loop, label %exit\n\nexit: ; preds = %loop\n ret i16 %red.next\n}\n\nattributes #0 = { \"target-cpu\"=\"grace\" }\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[LV] operands with different vscale types",
"body": "Compiling this reproducer:\n\n```\nshort a;\nextern short b[];\nvoid c(bool d[][1][1]) {\n#pragma clang loop vectorize_predicate(enable)\n for (short e = 0; e < 858; e += 3) {\n b[e] = d[0644][e][1];\n for (char f = 0; f < 21; f++)\n a += d[0644][e][f];\n }\n}\n```\n\nwith `-O2 -mcpu=grace` results in:\n\n```\n #4 0x000000000518a9aa llvm::SelectionDAG::isConstantIntBuildVectorOrConstantInt(llvm::SDValue, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x518a9aa)\n #5 0x000000000518ab8b llvm::SelectionDAG::canonicalizeCommutativeBinop(unsigned int, llvm::SDValue&, llvm::SDValue&) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x518ab8b)\n #6 0x00000000051ad64d llvm::SelectionDAG::getNode(unsigned int, llvm::SDLoc const&, llvm::EVT, llvm::SDValue, llvm::SDValue, llvm::SDNodeFlags) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x51ad64d)\n #7 0x000000000533de2e llvm::DAGTypeLegalizer::PromoteIntRes_SimpleIntBinOp(llvm::SDNode*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x533de2e)\n #8 0x000000000535821b llvm::DAGTypeLegalizer::PromoteIntegerResult(llvm::SDNode*, unsigned int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x535821b)\n #9 0x00000000052771da llvm::DAGTypeLegalizer::run() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x52771da)\n#10 0x0000000005277821 llvm::SelectionDAG::LegalizeTypes() \n```\n\nSee also: https://godbolt.org/z/vz87Koh4q\n\nI've tried creating an IR reproducer, but ran into some troubles that might be hint what is going on: `%20` is a`8 x i16`, which is used in an add in `%26` and mixed with a `4 x i16` operand:\n\n```\n ...\n %20 = zext nneg <vscale x 8 x i8> %19 to <vscale x 8 x i16>\n %21 = getelementptr inbounds nuw i16, ptr @b, <vscale x 8 x i64> %15\n tail call void @llvm.masked.scatter.nxv8i16.nxv8p0(<vscale x 8 x i16> %20, <vscale x 8 x ptr> %21, i32 2, <vscale x 8 x i1> %14)\n %22 = tail call <vscale x 8 x i8> @llvm.masked.gather.nxv8i8.nxv8p0(<vscale x 8 x ptr> %17, i32 1, <vscale x 8 x i1> %14, <vscale x 8 x i8> poison)\n %23 = zext nneg <vscale x 8 x i8> %22 to <vscale x 8 x i16>\n %24 = select <vscale x 8 x i1> %14, <vscale x 8 x i16> %23, <vscale x 8 x i16> zeroinitializer\n %25 = tail call <vscale x 4 x i16> @llvm.vector.partial.reduce.add.nxv4i16.nxv8i16(<vscale x 4 x i16> %16, <vscale x 8 x i16> %24)\n %26 = add <vscale x 4 x i16> %25, <vscale x 8 x i16> %20\n...\n```\n\n",
"author": "sjoerdmeijer",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "sjoerdmeijer",
"body": "CC: @paulwalker-arm , @david-arm , @sdesmalen-arm , @fhahn "
},
{
"author": "topperc",
"body": "An assertions build fails earlier in IRBuilder https://godbolt.org/z/zadvTnne8"
},
{
"author": "sdesmalen-arm",
"body": "@SamTebbs33 it seems the result from the partial reduction here is a `<vscale x 4 x i16>`, whereas the use (an `add`) of this value assumes a `<vscale x 8 x i16>`. Can you investigate?"
},
{
"author": "fhahn",
"body": "IR reproducer: https://llvm.godbolt.org/z/Mz5xe8vK1"
},
{
"author": "fhahn",
"body": "@sjoerdmeijer you might want to use `-Xclang -llvm-verify-each` if you are not building with assertions. This makes it a bit easier to pin-point which pass creates invalid IR."
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null | null |
131360
|
https://github.com/llvm/llvm-project/issues/131360
|
crash
|
dccc0a836c20914549fa375905615db49d2f813b
| 2025-03-14T17:22:16
|
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "fbf0276b6a7a7a4508c373cf87fc349569652659",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
6665,
6670
]
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::reorderBottomToTop"
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit fbf0276b6a7a7a4508c373cf87fc349569652659
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Fri Mar 14 14:07:01 2025 -0700
[SLP] Reorder reuses mask, if it is not empty, for subvector operands
If the subvector operands has reuses mask, need to reorder the mask, not
the scalars, to prevent compiler crash due to mask/scalars size
mismatch.
Fixes #131360
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 708dda9bd7f8..d450336cbc3c 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -6665,6 +6665,8 @@ void BoUpSLP::reorderBottomToTop(bool IgnoreReorder) {
// Clear ordering of the operand.
if (!OpTE.ReorderIndices.empty()) {
OpTE.ReorderIndices.clear();
+ } else if (!OpTE.ReuseShuffleIndices.empty()) {
+ reorderReuses(OpTE.ReuseShuffleIndices, Mask);
} else {
assert(OpTE.isGather() && "Expected only gather/buildvector node.");
reorderScalars(OpTE.Scalars, Mask);
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/reorder-reused-subvector.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-100 < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @test(i32 %j.6, i32 %m.4, i8 %v.5, ptr %a, i1 %tobool14.not) {\n;\nentry:\n br label %n\n\nentry.o_crit_edge:\n br label %o\n\nn:\n %i.0 = phi i32 [ 0, %entry ], [ 1, %if.end18 ]\n %j.0 = phi i32 [ 0, %entry ], [ %j.6, %if.end18 ]\n %m.0 = phi i32 [ 0, %entry ], [ %m.4, %if.end18 ]\n %l.0 = phi i8 [ 0, %entry ], [ %l.4, %if.end18 ]\n %u.0 = phi i32 [ 0, %entry ], [ %u.5, %if.end18 ]\n store i32 %j.0, ptr %a, align 4\n %cmp.not.not = icmp eq i8 %l.0, 0\n br i1 %cmp.not.not, label %o.sink.split, label %p\n\np:\n %0 = phi i32 [ %r.3, %if.end18 ], [ 0, %n ]\n %i.1 = phi i32 [ %s.3, %if.end18 ], [ 1, %n ]\n %j.1 = phi i32 [ %j.65, %if.end18 ], [ %j.0, %n ]\n %k.1 = phi i32 [ %t.3, %if.end18 ], [ %i.0, %n ]\n %m.1 = phi i32 [ %m.46, %if.end18 ], [ %m.0, %n ]\n %l.1 = phi i8 [ 1, %if.end18 ], [ 0, %n ]\n %s.1 = phi i32 [ %s.3, %if.end18 ], [ 0, %n ]\n %t.1 = phi i32 [ %t.3, %if.end18 ], [ 0, %n ]\n %u.12 = phi i32 [ %u.5, %if.end18 ], [ 0, %n ]\n %v.1 = phi i8 [ 0, %if.end18 ], [ %v.5, %n ]\n %tobool4.not = icmp eq i32 %m.1, 0\n %spec.select = select i1 %tobool4.not, i32 %j.1, i32 0\n %tobool7.not = icmp eq i32 %0, 0\n br i1 %tobool7.not, label %o.sink.split, label %q\n\no.sink.split:\n %spec.select.sink = phi i32 [ %j.0, %n ], [ %spec.select, %p ]\n %i.3.ph = phi i32 [ 0, %n ], [ %i.1, %p ]\n %k.3.ph = phi i32 [ %i.0, %n ], [ %k.1, %p ]\n %m.3.ph = phi i32 [ %m.0, %n ], [ 0, %p ]\n %l.3.ph = phi i8 [ 0, %n ], [ %l.1, %p ]\n %u.3.ph = phi i32 [ %u.0, %n ], [ 1, %p ]\n %conv10 = zext i32 %spec.select.sink to i64\n %call11 = tail call i32 (ptr, ...) @printf(ptr null, i64 %conv10)\n br label %o\n\no:\n %j.4 = phi i32 [ 0, %entry.o_crit_edge ], [ %spec.select.sink, %o.sink.split ]\n %k.3 = phi i32 [ 0, %entry.o_crit_edge ], [ %k.3.ph, %o.sink.split ]\n %m.3 = phi i32 [ 0, %entry.o_crit_edge ], [ %m.3.ph, %o.sink.split ]\n %u.3 = phi i32 [ 0, %entry.o_crit_edge ], [ %u.3.ph, %o.sink.split ]\n %sub = sub i32 0, %j.6\n %div = sdiv i32 %sub, %i.3.ph\n %sub13 = sub i32 0, %div\n br i1 %tobool14.not, label %if.end18, label %q\n\nq:\n %s.2 = phi i32 [ %s.1, %p ], [ 0, %o ]\n %t.2 = phi i32 [ %t.1, %p ], [ %k.3, %o ]\n %u.4 = phi i32 [ %u.12, %p ], [ 0, %o ]\n %v.44 = phi i8 [ %v.1, %p ], [ 0, %o ]\n %conv17 = sext i8 %v.44 to i32\n %rem = mul i32 %u.4, %conv17\n br label %if.end18\n\nif.end18:\n %j.65 = phi i32 [ 0, %q ], [ %j.4, %o ]\n %m.46 = phi i32 [ %rem, %q ], [ %m.3, %o ]\n %l.4 = phi i8 [ 0, %q ], [ %l.3.ph, %o ]\n %r.3 = phi i32 [ 0, %q ], [ %k.3, %o ]\n %s.3 = phi i32 [ %s.2, %q ], [ %sub, %o ]\n %t.3 = phi i32 [ %t.2, %q ], [ %sub13, %o ]\n %u.5 = phi i32 [ 0, %q ], [ %u.3, %o ]\n br i1 %tobool14.not, label %n, label %p\n\n}\ndeclare i32 @printf(ptr, ...)",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "clang crashes at -O{s,2,3} on x86_64-linux-gnu: Assertion `idx < size()' failed",
"body": "It appears to be a recent regression as it doesn't reproduce with 20.1.0. \n\nCompiler Explorer: https://godbolt.org/z/31z58Pqnf\n\n```\n[507] % clangtk -v\nclang version 21.0.0git (https://github.com/llvm/llvm-project.git da3ee9763266f9adedaac1b1b3162d14f951fc55)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\nBuild config: +assertions\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\nCandidate multilib: .;@m64\nSelected multilib: .;@m64\n[508] % \n[508] % clangtk -Os small.c\nclang-21: /local/suz-local/software/clangbuild/llvm-project/llvm/include/llvm/ADT/SmallVector.h:291: T& llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::operator[](llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::size_type) [with T = llvm::Value*; <template-parameter-1-2> = void; llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::reference = llvm::Value*&; llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::size_type = long unsigned int]: Assertion `idx < size()' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\nStack dump:\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-21 -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/20250314-clangtk-m64-O3-build-143933/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20250314-clangtk-m64-O3-build-143933/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/21 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/21/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-fb79f4.o -x c small.c\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 \"small.c\"\n4.\tRunning pass \"slp-vectorizer\" on function \"g\"\n #0 0x0000559c00edefcf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x4577fcf)\n #1 0x0000559c00edc7a4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007f26a38b4420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\n #3 0x00007f26a32eb00b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\n #4 0x00007f26a32ca859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\n #5 0x00007f26a32ca729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\n #6 0x00007f26a32ca729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\n #7 0x00007f26a32dbfd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\n #8 0x0000559c0296f55e llvm::reorderScalars(llvm::SmallVectorImpl<llvm::Value*>&, llvm::ArrayRef<int>) SLPVectorizer.cpp:0:0\n #9 0x0000559c02a36719 llvm::slpvectorizer::BoUpSLP::reorderBottomToTop(bool) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60cf719)\n#10 0x0000559c02a41c60 llvm::SLPVectorizerPass::tryToVectorizeList(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60dac60)\n#11 0x0000559c02a4712d bool tryToVectorizeSequence<llvm::Value>(llvm::SmallVectorImpl<llvm::Value*>&, llvm::function_ref<bool (llvm::Value*, llvm::Value*)>, llvm::function_ref<bool (llvm::Value*, llvm::Value*)>, llvm::function_ref<bool (llvm::ArrayRef<llvm::Value*>, bool)>, bool, llvm::slpvectorizer::BoUpSLP&) (.constprop.0) SLPVectorizer.cpp:0:0\n#12 0x0000559c02a48b21 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60e1b21)\n#13 0x0000559c02a50b66 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\n#14 0x0000559c02a51733 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60ea733)\n#15 0x0000559c024c7cf6 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-21+0x5b60cf6)\n#16 0x0000559c0084f7c9 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x3ee87c9)\n#17 0x0000559bfe1397a6 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-21+0x17d27a6)\n#18 0x0000559c0084e032 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x3ee7032)\n#19 0x0000559bfe1373b6 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-21+0x17d03b6)\n#20 0x0000559c0084da51 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x3ee6a51)\n#21 0x0000559c0119ce4a (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#22 0x0000559c011a08a1 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*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x48398a1)\n#23 0x0000559c018e0d91 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x4f79d91)\n#24 0x0000559c0326e6dc clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x69076dc)\n#25 0x0000559c018e11b8 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x4f7a1b8)\n#26 0x0000559c01bb7bc9 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5250bc9)\n#27 0x0000559c01b38ece clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x51d1ece)\n#28 0x0000559c01cac996 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5345996)\n#29 0x0000559bfdccc9ed cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x13659ed)\n#30 0x0000559bfdcc415a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#31 0x0000559bfdcc83c7 clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x13613c7)\n#32 0x0000559bfdbad0db main (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x12460db)\n#33 0x00007f26a32cc083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\n#34 0x0000559bfdcc3bee _start (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x135cbee)\nclangtk: error: unable to execute command: Aborted\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\nclang version 21.0.0git (https://github.com/llvm/llvm-project.git da3ee9763266f9adedaac1b1b3162d14f951fc55)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\nBuild config: +assertions\nclangtk: note: diagnostic msg: \n********************\n\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\nPreprocessed source(s) and associated run script(s) are located at:\nclangtk: note: diagnostic msg: /tmp/small-d812eb.c\nclangtk: note: diagnostic msg: /tmp/small-d812eb.sh\nclangtk: note: diagnostic msg: \n\n********************\n[509] % \n[509] % cat small.c\nint printf(const char *, ...);\nint a, b, c, d, e, f;\nvoid g() {\n int i = 1, j = 0, k = 0, m;\n char l = 1;\n if (d)\n n : {\n a = j;\n if (e >= l) {\n printf(\"%ld\", (long) j);\n goto o;\n }\n p:\n if (m)\n j = 1;\n if (b)\n goto q;\n printf(\"%ld\", (long) j);\n }\n o : ;\n int r = k, s = -f, t = -(s / i);\n if (c) {\n t = k;\n int u = a;\n char v = u;\n q:\n m = u % v;\n l = 0;\n }\n i = s;\n k = t;\n b = r;\n if (a)\n goto p;\n goto n;\n}\n```\n",
"author": "zhendongsu",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
9d37e61fc77d3d6de891c30630f1c0227522031d
| 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/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.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/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::vectorizeTree",
"tryToReduce"
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 1e3536ef3141d6429f3616af624b81b6d6ab2959
Author: Alexey Bataev <a.bataev@outlook.com>
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
|
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
|
b10ecfa914dd1bc2013584917d0505ba5f15f75c
| null |
177124
|
https://github.com/llvm/llvm-project/issues/177124
|
crash
|
795d940254aa357cb5095ad776c04e72ced08b9d
| 2026-01-21T09:20:08
|
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "d64d3735ab06cd1304fb383543312c355c45eeb8",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
19965,
19972
],
[
19976,
19988
]
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::vectorizeTree"
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit d64d3735ab06cd1304fb383543312c355c45eeb8
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Wed Jan 21 09:10:46 2026 -0800
[SLP]Correctly handle vector nodes, coming from same incoming blocks in PHI nodes
If multiple nodes are generated from same PHI node for the same block,
still need to vectorize vector nodes, even if the value for the incoming block was already emitted.
Fixes #177124
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index f696d2021457..22b8ea481f2c 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -19965,8 +19965,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) {
// PHINodes may have multiple entries from the same block. We want to
// visit every block once.
- SmallPtrSet<BasicBlock *, 4> VisitedBBs;
-
+ SmallDenseMap<BasicBlock *, unsigned, 4> VisitedBBs;
for (unsigned I : seq<unsigned>(PH->getNumIncomingValues())) {
BasicBlock *IBB = PH->getIncomingBlock(I);
@@ -19976,13 +19975,17 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) {
return NewPhi;
}
- if (!VisitedBBs.insert(IBB).second) {
- Value *VecOp = NewPhi->getIncomingValueForBlock(IBB);
- NewPhi->addIncoming(VecOp, IBB);
+ auto Res = VisitedBBs.try_emplace(IBB, I);
+ if (!Res.second) {
TreeEntry *OpTE = getOperandEntry(E, I);
- assert(!OpTE->VectorizedValue && "Expected no vectorized value.");
- OpTE->VectorizedValue = VecOp;
- continue;
+ if (OpTE->isGather() || DeletedNodes.contains(OpTE) ||
+ TransformedToGatherNodes.contains(OpTE)) {
+ Value *VecOp = NewPhi->getIncomingValue(Res.first->getSecond());
+ NewPhi->addIncoming(VecOp, IBB);
+ assert(!OpTE->VectorizedValue && "Expected no vectorized value.");
+ OpTE->VectorizedValue = VecOp;
+ continue;
+ }
}
Builder.SetInsertPoint(IBB->getTerminator());
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/phi-multi-same-nodes.ll",
"commands": [
"opt -passes=slp-vectorizer -S -slp-threshold=-99999 -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @test() {\n;\nbb:\n %ashr = ashr i32 0, 0\n %add = add i32 0, 0\n switch i32 0, label %bb1 [\n i32 -4, label %bb4\n i32 -1, label %bb4\n i32 1, label %bb4\n i32 2, label %bb4\n i32 5, label %bb4\n i32 7, label %bb4\n i32 8, label %bb4\n i32 11, label %bb4\n i32 13, label %bb4\n i32 21, label %bb4\n i32 17, label %bb4\n i32 19, label %bb4\n ]\n\nbb1:\n %add2 = add i32 0, 0\n %ashr3 = ashr i32 %add2, 1\n %xor = xor i32 0, 0\n %or = or i32 %xor, %ashr\n switch i32 0, label %bb4 [\n i32 -4, label %bb4\n i32 -1, label %bb4\n i32 1, label %bb4\n i32 2, label %bb4\n i32 5, label %bb4\n i32 7, label %bb4\n i32 8, label %bb4\n i32 11, label %bb4\n i32 13, label %bb4\n i32 21, label %bb4\n i32 17, label %bb4\n i32 19, label %bb4\n ]\n\nbb4:\n %phi = phi i32 [ %ashr3, %bb1 ], [ %ashr3, %bb1 ], [ %ashr3, %bb1 ], [ %ashr3, %bb1 ], [ %ashr3, %bb1 ], [ %ashr3, %bb1 ], [ %ashr3, %bb1 ], [ %ashr3, %bb1 ], [ %ashr3, %bb1 ], [ %ashr3, %bb1 ], [ %ashr3, %bb1 ], [ %ashr, %bb ], [ %ashr, %bb ], [ %ashr, %bb ], [ %ashr, %bb ], [ %ashr, %bb ], [ %ashr, %bb ], [ %ashr, %bb ], [ %ashr, %bb ], [ %ashr, %bb ], [ %ashr, %bb ], [ %ashr, %bb ], [ %ashr, %bb ], [ %ashr3, %bb1 ], [ %ashr3, %bb1 ]\n %phi5 = phi i32 [ %or, %bb1 ], [ %or, %bb1 ], [ %or, %bb1 ], [ %or, %bb1 ], [ %or, %bb1 ], [ %or, %bb1 ], [ %or, %bb1 ], [ %or, %bb1 ], [ %or, %bb1 ], [ %or, %bb1 ], [ %or, %bb1 ], [ %add, %bb ], [ %add, %bb ], [ %add, %bb ], [ %add, %bb ], [ %add, %bb ], [ %add, %bb ], [ %add, %bb ], [ %add, %bb ], [ %add, %bb ], [ %add, %bb ], [ %add, %bb ], [ %add, %bb ], [ %or, %bb1 ], [ %or, %bb1 ]\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "Assertion `!contains(New, this) && \"this->replaceAllUsesWith(expr(this)) is NOT valid!\"' failed.",
"body": "To reproduce run opt with the test below, -passes=slp-vectorizer -slp-threshold=-99999\n\n[reduced-stripped.ll.zip](https://github.com/user-attachments/files/24762079/reduced-stripped.ll.zip)\n\nReproducer: https://godbolt.org/z/Ys1hj3M6K\n\nStack dump:\n```\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer -slp-threshold=-99999 <source>\n1.\tRunning pass \"function(slp-vectorizer)\" on module \"<source>\"\n2.\tRunning pass \"slp-vectorizer\" on function \"wombat\"\n #0 0x0000000005a91978 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5a91978)\n #1 0x0000000005a8e854 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x0000751bd4242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x0000751bd42969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x0000751bd4242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x0000751bd42287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x0000751bd422871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x0000751bd4239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x000000000583d2a6 llvm::Value::doRAUW(llvm::Value*, llvm::Value::ReplaceMetadataUses) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x583d2a6)\n #9 0x0000000003854ef1 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::SmallDenseSet<llvm::Value*, 4u, llvm::DenseMapInfo<llvm::Value*, void>> const&, llvm::Instruction*, llvm::ArrayRef<std::tuple<llvm::Value*, unsigned int, bool>>) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3854ef1)\n#10 0x0000000003858ca4 llvm::slpvectorizer::BoUpSLP::vectorizeTree() (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3858ca4)\n#11 0x0000000003879873 llvm::SLPVectorizerPass::tryToVectorizeList(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3879873)\n#12 0x000000000387e13c bool tryToVectorizeSequence<llvm::Value>(llvm::SmallVectorImpl<llvm::Value*>&, llvm::function_ref<bool (llvm::Value*, llvm::Value*)>, llvm::function_ref<bool (llvm::ArrayRef<llvm::Value*>, llvm::Value*)>, llvm::function_ref<bool (llvm::ArrayRef<llvm::Value*>, bool)>, bool, llvm::slpvectorizer::BoUpSLP&) (.constprop.0) SLPVectorizer.cpp:0:0\n#13 0x000000000387f3cc llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x387f3cc)\n#14 0x0000000003887306 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\n#15 0x0000000003887e5b llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3887e5b)\n#16 0x000000000302d3ce 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+0x302d3ce)\n#17 0x0000000005805671 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5805671)\n#18 0x0000000000f0620e 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+0xf0620e)\n#19 0x0000000005803c2a llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5803c2a)\n#20 0x000000000096300e 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+0x96300e)\n#21 0x00000000058035e1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x58035e1)\n#22 0x000000000096d1ca llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x96d1ca)\n#23 0x0000000000961278 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x961278)\n#24 0x0000751bd4229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#25 0x0000751bd4229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#26 0x0000000000957ef5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x957ef5)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```",
"author": "TatyanaDoubts",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null | null |
111934
|
https://github.com/llvm/llvm-project/issues/111934
|
miscompilation
|
f74f568b29885c3fa63c44e33f91f3bb7281138e
| 2024-10-11T03:29:55
|
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "6a65e98fa7901dc1de91172d065fafb16ce89d77",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": [
[
955,
963
],
[
971,
977
],
[
980,
986
],
[
3375,
3381
]
],
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": [
"InstCombinerImpl::foldAndOrOfICmps",
"foldIsPowerOf2"
],
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 6a65e98fa7901dc1de91172d065fafb16ce89d77
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Fri Oct 11 18:19:21 2024 +0800
[InstCombine] Drop range attributes in `foldIsPowerOf2` (#111946)
Fixes https://github.com/llvm/llvm-project/issues/111934.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index 688601a8ffa5..964616a4eb35 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -955,9 +955,11 @@ static Value *foldIsPowerOf2OrZero(ICmpInst *Cmp0, ICmpInst *Cmp1, bool IsAnd,
}
/// Reduce a pair of compares that check if a value has exactly 1 bit set.
-/// Also used for logical and/or, must be poison safe.
+/// Also used for logical and/or, must be poison safe if range attributes are
+/// dropped.
static Value *foldIsPowerOf2(ICmpInst *Cmp0, ICmpInst *Cmp1, bool JoinedByAnd,
- InstCombiner::BuilderTy &Builder) {
+ InstCombiner::BuilderTy &Builder,
+ InstCombinerImpl &IC) {
// Handle 'and' / 'or' commutation: make the equality check the first operand.
if (JoinedByAnd && Cmp1->getPredicate() == ICmpInst::ICMP_NE)
std::swap(Cmp0, Cmp1);
@@ -971,7 +973,10 @@ static Value *foldIsPowerOf2(ICmpInst *Cmp0, ICmpInst *Cmp1, bool JoinedByAnd,
match(Cmp1, m_SpecificICmp(ICmpInst::ICMP_ULT,
m_Intrinsic<Intrinsic::ctpop>(m_Specific(X)),
m_SpecificInt(2)))) {
- Value *CtPop = Cmp1->getOperand(0);
+ auto *CtPop = cast<Instruction>(Cmp1->getOperand(0));
+ // Drop range attributes and re-infer them in the next iteration.
+ CtPop->dropPoisonGeneratingAnnotations();
+ IC.addToWorklist(CtPop);
return Builder.CreateICmpEQ(CtPop, ConstantInt::get(CtPop->getType(), 1));
}
// (X == 0) || (ctpop(X) u> 1) --> ctpop(X) != 1
@@ -980,7 +985,10 @@ static Value *foldIsPowerOf2(ICmpInst *Cmp0, ICmpInst *Cmp1, bool JoinedByAnd,
match(Cmp1, m_SpecificICmp(ICmpInst::ICMP_UGT,
m_Intrinsic<Intrinsic::ctpop>(m_Specific(X)),
m_SpecificInt(1)))) {
- Value *CtPop = Cmp1->getOperand(0);
+ auto *CtPop = cast<Instruction>(Cmp1->getOperand(0));
+ // Drop range attributes and re-infer them in the next iteration.
+ CtPop->dropPoisonGeneratingAnnotations();
+ IC.addToWorklist(CtPop);
return Builder.CreateICmpNE(CtPop, ConstantInt::get(CtPop->getType(), 1));
}
return nullptr;
@@ -3375,7 +3383,7 @@ Value *InstCombinerImpl::foldAndOrOfICmps(ICmpInst *LHS, ICmpInst *RHS,
if (Value *V = foldSignedTruncationCheck(LHS, RHS, I, Builder))
return V;
- if (Value *V = foldIsPowerOf2(LHS, RHS, IsAnd, Builder))
+ if (Value *V = foldIsPowerOf2(LHS, RHS, IsAnd, Builder, *this))
return V;
if (Value *V = foldPowerOf2AndShiftedMask(LHS, RHS, IsAnd, Builder))
|
[
{
"file": "llvm/test/Transforms/InstCombine/ispow2.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "has_single_bit",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @has_single_bit(i32 %x) {\nentry:\n %cmp1 = icmp ne i32 %x, 0\n %popcnt = call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %x)\n %cmp2 = icmp ult i32 %popcnt, 2\n %sel = select i1 %cmp1, i1 %cmp2, i1 false\n ret i1 %sel\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "has_single_bit_inv",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @has_single_bit_inv(i32 %x) {\nentry:\n %cmp1 = icmp eq i32 %x, 0\n %popcnt = call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %x)\n %cmp2 = icmp ugt i32 %popcnt, 1\n %sel = select i1 %cmp1, i1 true, i1 %cmp2\n ret i1 %sel\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "not_pow2_or_z_known_bits_fail_wrong_cmp",
"test_body": "define <2 x i1> @not_pow2_or_z_known_bits_fail_wrong_cmp(<2 x i32> %xin) {\n %x = or <2 x i32> %xin, splat (i32 64)\n %cnt = call <2 x i32> @llvm.ctpop.v2i32(<2 x i32> %x)\n %r = icmp ugt <2 x i32> %cnt, splat (i32 2)\n ret <2 x i1> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <2 x i32> @llvm.ctpop.v2i32(<2 x i32>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[InstCombine] poison-generating attributes are not dropped when folding logical and/or of icmps",
"body": "Reproducer: https://alive2.llvm.org/ce/z/rSUfvo\r\n```\r\ndefine i1 @src(i32 noundef %Value) {\r\nentry:\r\n %cmp.not = icmp eq i32 %Value, 0\r\n %0 = call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %Value)\r\n %cmp1 = icmp ult i32 %0, 2\r\n %1 = select i1 %cmp.not, i1 false, i1 %cmp1\r\n ret i1 %1\r\n}\r\n\r\ndefine i1 @tgt(i32 noundef %Value) {\r\nentry:\r\n %0 = call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %Value)\r\n %1 = icmp eq i32 %0, 1\r\n ret i1 %1\r\n}\r\n```\r\nWhen `%Value == 0`, `@src` returns `false` but `@tgt` returns `poison`.\r\nThis miscompilation was triggered after https://github.com/llvm/llvm-project/pull/111284 was landed.\r\n",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
|
Cannot find a good commit
| null |
102597
|
https://github.com/llvm/llvm-project/issues/102597
|
miscompilation
|
513c3726ebc0a324f7e5a11d25617bb9557324d6
| 2024-08-09T11:02:59
|
[
"llvm/test/Transforms/IndVarSimplify"
] |
{
"fix_commit": "3512bcc2e9ab06b0ae2cab78744550b515e54184",
"components": [
"ScalarEvolution"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": [
[
11961,
11969
]
],
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": [
"ScalarEvolution::computeConstantDifference"
],
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 3512bcc2e9ab06b0ae2cab78744550b515e54184
Author: Nikita Popov <npopov@redhat.com>
Date: Mon Aug 12 15:18:32 2024 +0200
[SCEV] Fix incorrect extension in computeConstantDifference()
The Mul factor was zero-extended here, resulting in incorrect
results for integers larger than 64-bit.
As we currently only multiply by 1 or -1, just split this into
two cases -- there's no need for a full multiplication here.
Fixes https://github.com/llvm/llvm-project/issues/102597.
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 9ecdcbe2c5de..318a9d773dc2 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -11961,9 +11961,14 @@ ScalarEvolution::computeConstantDifference(const SCEV *More, const SCEV *Less) {
SmallDenseMap<const SCEV *, int, 8> Multiplicity;
APInt Diff(BW, 0);
auto Add = [&](const SCEV *S, int Mul) {
- if (auto *C = dyn_cast<SCEVConstant>(S))
- Diff += C->getAPInt() * Mul;
- else
+ if (auto *C = dyn_cast<SCEVConstant>(S)) {
+ if (Mul == 1) {
+ Diff += C->getAPInt();
+ } else {
+ assert(Mul == -1);
+ Diff -= C->getAPInt();
+ }
+ } else
Multiplicity[S] += Mul;
};
auto Decompose = [&](const SCEV *S, int Mul) {
|
[
{
"file": "llvm/test/Transforms/IndVarSimplify/pr102597.ll",
"commands": [
"opt -S -passes=indvars < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define void @test() {\nentry:\n br label %loop\n\nloop: ; preds = %loop.latch, %entry\n %iv = phi i128 [ 3, %entry ], [ %iv.dec, %loop.latch ]\n %tobool = icmp ne i128 %iv, 0\n br i1 %tobool, label %loop.latch, label %if\n\nif: ; preds = %loop\n call void @foo()\n br label %loop.latch\n\nloop.latch: ; preds = %if, %loop\n %iv.dec = add nsw i128 %iv, -1\n %cmp = icmp sgt i128 %iv, 0\n br i1 %cmp, label %loop, label %exit\n\nexit: ; preds = %loop.latch\n ret void\n}\n\ndeclare void @foo()\n",
"additional_args": "-src-unroll=4 -tgt-unroll=4",
"lli_expected_out": null
}
]
}
] |
{
"title": "[SCEV] WRONG code ",
"body": "```\r\nint printf(const char *, ...);\r\n__int128 a = 3, c;\r\nchar b;\r\nint main() {\r\n c = 3;\r\n for (; c >= 0; c--) {\r\n b = 0;\r\n for (; b <= 3; b++) {\r\n if (c)\r\n break;\r\n a = 0;\r\n }\r\n }\r\n printf(\"%d\\n\", (int)a);\r\n}\r\n\r\n```\r\n\r\nclang -march=z15 -O1 wrong0.i -o a.out\r\n\r\nThis program should print '0' as 'a' is set to zero inside the loop. It now prints '3' instead. A bisect leads to a recent commit: 79af689 \" [SCEV] Handle more adds in computeConstantDifference() (#101339)\".\r\n\r\nSeems like IndVarSimplify has gone wrong with an i128:\r\nGOOD <> BROKEN\r\n```\r\n; *** IR Dump After IndVarSimplifyPass on loo ; *** IR Dump After IndVarSimplifyPass on loo\r\n\r\n; Preheader: ; Preheader:\r\nentry: entry:\r\n br label %for.cond1.preheader br label %for.cond1.preheader\r\n\r\n; Loop: ; Loop:\r\nfor.cond1.preheader: for.cond1.preheader: \r\n %storemerge11 = phi i128 [ 3, %entry ], [ % %storemerge11 = phi i128 [ 3, %entry ], [ %\r\n %tobool = icmp ne i128 %storemerge11, 0 | br i1 true, label %for.inc5, label %if.end.\r\n br i1 %tobool, label %for.inc5, label %if.e <\r\n\r\nif.end.lr.ph: if.end.lr.ph: \r\n store i128 0, ptr @a, align 8, !tbaa !4 store i128 0, ptr @a, align 8, !tbaa !4\r\n br label %if.end br label %if.end\r\n\r\nif.end: if.end: \r\n %storemerge89 = phi i8 [ 0, %if.end.lr.ph ] %storemerge89 = phi i8 [ 0, %if.end.lr.ph ]\r\n %inc = add nuw nsw i8 %storemerge89, 1 %inc = add nuw nsw i8 %storemerge89, 1\r\n %cmp2 = icmp ugt i8 %storemerge89, 2 %cmp2 = icmp ugt i8 %storemerge89, 2\r\n %or.cond = or i1 %tobool, %cmp2 | %or.cond = or i1 true, %cmp2\r\n br i1 %or.cond, label %for.inc5.loopexit, l br i1 %or.cond, label %for.inc5.loopexit, l\r\n\r\nfor.inc5: for.inc5: \r\n %storemerge8.lcssa = phi i8 [ 0, %for.cond1 %storemerge8.lcssa = phi i8 [ 0, %for.cond1\r\n %dec = add nsw i128 %storemerge11, -1 %dec = add nsw i128 %storemerge11, -1\r\n %cmp = icmp ugt i128 %storemerge11, 0 %cmp = icmp ugt i128 %storemerge11, 0\r\n br i1 %cmp, label %for.cond1.preheader, lab br i1 %cmp, label %for.cond1.preheader, lab\r\n\r\nfor.inc5.loopexit: for.inc5.loopexit: \r\n %inc.lcssa = phi i8 [ %inc, %if.end ] %inc.lcssa = phi i8 [ %inc, %if.end ]\r\n br label %for.inc5 br label %for.inc5\r\n\r\n; Exit blocks ; Exit blocks\r\nfor.end6: for.end6: \r\n %storemerge8.lcssa.lcssa = phi i8 [ %storem %storemerge8.lcssa.lcssa = phi i8 [ %storem\r\n store i128 -1, ptr @c, align 8, !tbaa !4 store i128 -1, ptr @c, align 8, !tbaa !4\r\n store i8 %storemerge8.lcssa.lcssa, ptr @b, store i8 %storemerge8.lcssa.lcssa, ptr @b, \r\n %0 = load i128, ptr @a, align 8, !tbaa !4 %0 = load i128, ptr @a, align 8, !tbaa !4\r\n %conv7 = trunc i128 %0 to i32 %conv7 = trunc i128 %0 to i32\r\n %call = call signext i32 (ptr, ...) @printf %call = call signext i32 (ptr, ...) @printf\r\n ret i32 0 ret i32 0\r\n\r\n```",
"author": "JonPsson1",
"labels": [
"miscompilation",
"llvm:SCEV"
],
"comments": [
{
"author": "nikic",
"body": "Classic mistake: https://github.com/llvm/llvm-project/blob/2f8f58dd17a11934e8c8ec212b6474f76fb18e61/llvm/lib/Analysis/ScalarEvolution.cpp#L11967 This `* Mul` doesn't do what I wanted it to do :)\r\n\r\nI should really pick up https://github.com/llvm/llvm-project/pull/80309 again to prevent this kind of mistake in the first place."
},
{
"author": "JonPsson1",
"body": "Is this commit self-contained in the sense that I could revert it on my testing machines? Or will you revert / fix soon?"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
79af6892f8eee1d0fb96c243716c8b03936751c9
| null |
159406
|
https://github.com/llvm/llvm-project/issues/159406
|
crash
|
3e0c58be49c81931daf285c0973db5fb763e51e4
| 2025-09-17T17:14:39
|
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "8c41859a21a4d0cfda164cc58f4a5336dbcd30d1",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
20804,
20815
]
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::BlockScheduling::tryScheduleBundle"
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 8c41859a21a4d0cfda164cc58f4a5336dbcd30d1
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Thu Sep 18 06:20:43 2025 -0700
[SLP]Clear the operands deps of non-schedulable nodes, if previously all operands were copyable
If all operands of the non-schedulable nodes were previously only
copyables, need to clear the dependencies of the original schedule data
for such copyable operands and recalculate them to correctly handle
number of dependecies.
Fixes #159406
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 0c94a1d593ce..6ac9018df641 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -20804,12 +20804,45 @@ BoUpSLP::BlockScheduling::tryScheduleBundle(ArrayRef<Value *> VL, BoUpSLP *SLP,
const EdgeInfo &EI) {
// No need to schedule PHIs, insertelement, extractelement and extractvalue
// instructions.
- bool HasCopyables = S.areInstructionsWithCopyableElements();
if (isa<PHINode>(S.getMainOp()) ||
- isVectorLikeInstWithConstOps(S.getMainOp()) ||
- (!HasCopyables && doesNotNeedToSchedule(VL)) ||
- all_of(VL, [&](Value *V) { return S.isNonSchedulable(V); }))
+ isVectorLikeInstWithConstOps(S.getMainOp()))
+ return nullptr;
+ bool HasCopyables = S.areInstructionsWithCopyableElements();
+ if (((!HasCopyables && doesNotNeedToSchedule(VL)) ||
+ all_of(VL, [&](Value *V) { return S.isNonSchedulable(V); }))) {
+ // If all operands were replaced by copyables, the operands of this node
+ // might be not, so need to recalculate dependencies for schedule data,
+ // replaced by copyable schedule data.
+ SmallVector<ScheduleData *> ControlDependentMembers;
+ for (Value *V : VL) {
+ auto *I = dyn_cast<Instruction>(V);
+ if (!I || (HasCopyables && S.isCopyableElement(V)))
+ continue;
+ SmallDenseMap<std::pair<Instruction *, Value *>, unsigned> UserOpToNumOps;
+ for (const Use &U : I->operands()) {
+ unsigned &NumOps =
+ UserOpToNumOps.try_emplace(std::make_pair(I, U.get()), 0)
+ .first->getSecond();
+ ++NumOps;
+ if (auto *Op = dyn_cast<Instruction>(U.get());
+ Op && areAllOperandsReplacedByCopyableData(I, Op, *SLP, NumOps)) {
+ if (ScheduleData *OpSD = getScheduleData(Op);
+ OpSD && OpSD->hasValidDependencies()) {
+ OpSD->clearDirectDependencies();
+ if (RegionHasStackSave ||
+ !isGuaranteedToTransferExecutionToSuccessor(OpSD->getInst()))
+ ControlDependentMembers.push_back(OpSD);
+ }
+ }
+ }
+ }
+ if (!ControlDependentMembers.empty()) {
+ ScheduleBundle Invalid = ScheduleBundle::invalid();
+ calculateDependencies(Invalid, /*InsertInReadyList=*/true, SLP,
+ ControlDependentMembers);
+ }
return nullptr;
+ }
// Initialize the instruction bundle.
Instruction *OldScheduleEnd = ScheduleEnd;
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/non-sched-inst-has-copyable-before.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-cros-linux-gnu < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n%struct.fe = type { [5 x i64] }\n\ndefine i32 @test(i64 %0, i128 %1, i1 %2) {\n;\n %4 = alloca %struct.fe, align 8\n %5 = getelementptr inbounds nuw i8, ptr %4, i64 16\n %6 = getelementptr inbounds nuw i8, ptr %4, i64 24\n %7 = getelementptr inbounds nuw i8, ptr %4, i64 32\n %8 = getelementptr inbounds nuw i8, ptr %4, i64 8\n br label %9\n\n9:\n %10 = phi i64 [ undef, %3 ], [ %29, %9 ]\n %11 = phi i64 [ undef, %3 ], [ %26, %9 ]\n %12 = phi i64 [ undef, %3 ], [ %23, %9 ]\n %13 = phi i64 [ undef, %3 ], [ %20, %9 ]\n %14 = phi i64 [ undef, %3 ], [ %17, %9 ]\n %.sroa.14.0 = phi i64 [ undef, %3 ], [ %52, %9 ]\n %.sroa.11.0 = phi i64 [ undef, %3 ], [ %50, %9 ]\n %.sroa.8.0 = phi i64 [ undef, %3 ], [ %57, %9 ]\n %.sroa.4.0 = phi i64 [ undef, %3 ], [ %56, %9 ]\n %.sroa.0.0 = phi i64 [ undef, %3 ], [ %54, %9 ]\n %15 = xor i64 %.sroa.0.0, %14\n %16 = and i64 %15, %0\n %17 = xor i64 %16, 1\n store i64 %17, ptr %4, align 8\n %18 = xor i64 %.sroa.4.0, %13\n %19 = and i64 %18, %0\n %20 = xor i64 %19, 1\n store i64 %20, ptr %8, align 8\n %21 = xor i64 %.sroa.8.0, %12\n %22 = and i64 %21, %0\n %23 = xor i64 %22, 1\n store i64 %23, ptr %5, align 8\n %24 = xor i64 %.sroa.11.0, %11\n %25 = and i64 %24, %0\n %26 = xor i64 %25, 1\n store i64 %26, ptr %6, align 8\n %27 = xor i64 %.sroa.14.0, %10\n %28 = and i64 %27, %0\n %29 = xor i64 %28, 1\n store i64 %29, ptr %7, align 8\n %30 = load i64, ptr null, align 4294967296\n %31 = or i64 %19, 1\n %32 = or i64 %16, 1\n %33 = add i64 %17, 1\n %34 = mul i64 %29, 19\n %35 = zext i64 %34 to i128\n %36 = mul i64 %26, 19\n %37 = zext i64 %36 to i128\n %38 = mul i64 %23, 19\n %39 = zext i64 %38 to i128\n %40 = mul nuw nsw i128 %39, 24\n %41 = zext i64 %32 to i128\n %42 = mul nuw i128 %37, %41\n %43 = zext i64 %31 to i128\n %44 = mul nuw i128 %35, %43\n %45 = zext i64 %33 to i128\n %46 = mul i128 %1, %45\n %47 = add i128 %40, %46\n %48 = add i128 %47, %42\n %49 = add i128 %48, %44\n %50 = and i64 %29, 1\n %51 = trunc i128 %49 to i64\n %52 = and i64 %30, 1\n %53 = add i64 %51, 1\n %54 = and i64 %53, 1\n %55 = lshr i64 %53, 1\n %56 = and i64 %19, 1\n %57 = or i64 %55, 1\n br i1 %2, label %58, label %9\n\n58:\n call void @g(ptr nonnull %4)\n ret i32 0\n}\n\ndeclare void @g(ptr)\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[SLPVectorizer] Crash after 57cae2b6a275a8eb3bc8935973263ed84535fb81",
"body": "```\n$ cat /tmp/a.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\"\ntarget triple = \"x86_64-cros-linux-gnu\"\n \n%struct.fe = type { [5 x i64] }\n \ndefine i32 @f(i64 %0, i128 %1, i1 %2) {\n %4 = alloca %struct.fe, align 8\n %5 = getelementptr inbounds nuw i8, ptr %4, i64 16\n %6 = getelementptr inbounds nuw i8, ptr %4, i64 24\n %7 = getelementptr inbounds nuw i8, ptr %4, i64 32\n %8 = getelementptr inbounds nuw i8, ptr %4, i64 8\n br label %9 \n\n9: ; preds = %9, %3\n %10 = phi i64 [ undef, %3 ], [ %29, %9 ]\n %11 = phi i64 [ undef, %3 ], [ %26, %9 ]\n %12 = phi i64 [ undef, %3 ], [ %23, %9 ]\n %13 = phi i64 [ undef, %3 ], [ %20, %9 ]\n %14 = phi i64 [ undef, %3 ], [ %17, %9 ]\n %.sroa.14.0 = phi i64 [ undef, %3 ], [ %52, %9 ]\n %.sroa.11.0 = phi i64 [ undef, %3 ], [ %50, %9 ]\n %.sroa.8.0 = phi i64 [ undef, %3 ], [ %57, %9 ]\n %.sroa.4.0 = phi i64 [ undef, %3 ], [ %56, %9 ]\n %.sroa.0.0 = phi i64 [ undef, %3 ], [ %54, %9 ]\n %15 = xor i64 %.sroa.0.0, %14\n %16 = and i64 %15, %0\n %17 = xor i64 %16, 1\n store i64 %17, ptr %4, align 8\n %18 = xor i64 %.sroa.4.0, %13\n %19 = and i64 %18, %0\n %20 = xor i64 %19, 1\n store i64 %20, ptr %8, align 8\n %21 = xor i64 %.sroa.8.0, %12\n %22 = and i64 %21, %0\n %23 = xor i64 %22, 1\n store i64 %23, ptr %5, align 8\n %24 = xor i64 %.sroa.11.0, %11\n %25 = and i64 %24, %0\n %26 = xor i64 %25, 1\n store i64 %26, ptr %6, align 8\n %27 = xor i64 %.sroa.14.0, %10\n %28 = and i64 %27, %0\n %29 = xor i64 %28, 1\n store i64 %29, ptr %7, align 8\n %30 = load i64, ptr null, align 4294967296\n %31 = or i64 %19, 1\n %32 = or i64 %16, 1\n %33 = add i64 %17, 1\n %34 = mul i64 %29, 19\n %35 = zext i64 %34 to i128\n %36 = mul i64 %26, 19\n %37 = zext i64 %36 to i128\n %38 = mul i64 %23, 19\n %39 = zext i64 %38 to i128\n %40 = mul nuw nsw i128 %39, 24\n %41 = zext i64 %32 to i128\n %42 = mul nuw i128 %37, %41\n %43 = zext i64 %31 to i128\n %44 = mul nuw i128 %35, %43\n %45 = zext i64 %33 to i128\n %46 = mul i128 %1, %45\n %47 = add i128 %40, %46\n %48 = add i128 %47, %42\n %49 = add i128 %48, %44\n %50 = and i64 %29, 1\n %51 = trunc i128 %49 to i64\n %52 = and i64 %30, 1\n %53 = add i64 %51, 1\n %54 = and i64 %53, 1\n %55 = lshr i64 %53, 1\n %56 = and i64 %19, 1\n %57 = or i64 %55, 1\n br i1 %2, label %58, label %9\n\n58: ; preds = %9\n call void @g(ptr nonnull %4)\n ret i32 0\n}\n\ndeclare void @g(ptr)\n\n$ opt -p slp-vectorizer -disable-output /tmp/a.ll\nopt: ../../llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:20859: auto llvm::slpvectorizer::BoUpSLP::BlockScheduling::tryScheduleBundle(ArrayRef<Value *>, BoUpSLP *, const InstructionsState &, const EdgeInfo &)::(anonymous class)::operator()(bool, ScheduleBundle &) const: Assertion `Picked->isReady() && \"m\nust be ready to schedule\"' failed. \n```\n\n@alexey-bataev ",
"author": "aeubanks",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": [
{
"author": "nico",
"body": "linkify 57cae2b6a275a8eb3bc8935973263ed84535fb81\n\nref #147366"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
fd93dc5ac515557f30c9a569c73f6ebfd9b3039b
| null |
117518
|
https://github.com/llvm/llvm-project/issues/117518
|
crash
|
3de21477c49172081e502b47d608e729915f0914
| 2024-11-25T05:31:23
|
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "f953b5eb72df77fc301aac210eab31c6270ff771",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
10875,
10883
],
[
14372,
14378
]
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"finalize"
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit f953b5eb72df77fc301aac210eab31c6270ff771
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Mon Nov 25 08:29:22 2024 -0800
[SLP]Relax assertion about subvectors mask size
SubVectorsMask might be less than CommonMask, if the vectors with larger
number of elements are permuted or reused elements are used. Need to
consider this when estimation/building the vector to avoid compiler
crash
Fixes #117518
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 73218f377a06..34b80c1e3608 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -10875,9 +10875,10 @@ public:
CommonMask[Idx] = Idx;
// Add subvectors permutation cost.
if (!SubVectorsMask.empty()) {
- assert(SubVectorsMask.size() == CommonMask.size() &&
+ assert(SubVectorsMask.size() <= CommonMask.size() &&
"Expected same size of masks for subvectors and common mask.");
- SmallVector<int> SVMask(SubVectorsMask.begin(), SubVectorsMask.end());
+ SmallVector<int> SVMask(CommonMask.size(), PoisonMaskElem);
+ copy(SubVectorsMask, SVMask.begin());
for (auto [I1, I2] : zip(SVMask, CommonMask)) {
if (I2 != PoisonMaskElem) {
assert(I1 == PoisonMaskElem && "Expected unused subvectors mask");
@@ -14372,7 +14373,8 @@ public:
if (SubVectorsMask.empty()) {
Vec = CreateSubVectors(Vec, CommonMask);
} else {
- SmallVector<int> SVMask(SubVectorsMask.begin(), SubVectorsMask.end());
+ SmallVector<int> SVMask(CommonMask.size(), PoisonMaskElem);
+ copy(SubVectorsMask, SVMask.begin());
for (auto [I1, I2] : zip(SVMask, CommonMask)) {
if (I2 != PoisonMaskElem) {
assert(I1 == PoisonMaskElem && "Expected unused subvectors mask");
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/non-power-of-2-subvectors-insert.ll",
"commands": [
"opt -S --passes=slp-vectorizer -slp-threshold=-300 -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @test() {\n;\n %xor108.i.i.i = xor i64 0, 1\n %conv115.i.i.i = trunc i64 %xor108.i.i.i to i16\n %add.i.i.i.i = or i16 %conv115.i.i.i, 0\n %add.i.frozen.i.i.i = freeze i16 %add.i.i.i.i\n %.cmp.not.i.i.i = icmp eq i16 %add.i.frozen.i.i.i, 0\n %cond.i1002.1.i.i.i = lshr i64 0, 0\n %conv115.1.i.i.i = trunc i64 %cond.i1002.1.i.i.i to i16\n %add.i.1.i.i.i = or i16 %conv115.1.i.i.i, 0\n %add.i.frozen.1.i.i.i = freeze i16 %add.i.1.i.i.i\n %.cmp.not.1.i.i.i = icmp eq i16 %add.i.frozen.1.i.i.i, 0\n %cond.i1002.2.i.i.i = lshr i64 %xor108.i.i.i, 0\n %conv115.2.i.i.i = trunc i64 %cond.i1002.2.i.i.i to i16\n %add.i.2.i.i.i = or i16 %conv115.2.i.i.i, 0\n %add.i.frozen.2.i.i.i = freeze i16 %add.i.2.i.i.i\n %.cmp.not.2.i.i.i = icmp eq i16 %add.i.frozen.2.i.i.i, 0\n %cond.i1002.3.i.i.i = lshr i64 0, 0\n %conv115.3.i.i.i = trunc i64 %cond.i1002.3.i.i.i to i16\n %add.i.3.i.i.i = or i16 %conv115.3.i.i.i, 0\n %add.i.frozen.3.i.i.i = freeze i16 %add.i.3.i.i.i\n %.cmp.not.3.i.i.i = icmp eq i16 %add.i.frozen.3.i.i.i, 0\n %conv115.i.i.i.1 = trunc i64 %xor108.i.i.i to i16\n %add.i.i.i.i.1 = or i16 %conv115.i.i.i.1, 0\n %add.i.frozen.i.i.i.1 = freeze i16 %add.i.i.i.i.1\n %.cmp.not.i.i.i.1 = icmp eq i16 %add.i.frozen.i.i.i.1, 0\n %cond.i1002.1.i.i.i.1 = lshr i64 0, 0\n %conv115.1.i.i.i.1 = trunc i64 %cond.i1002.1.i.i.i.1 to i16\n %add.i.1.i.i.i.1 = or i16 %conv115.1.i.i.i.1, 0\n %add.i.frozen.1.i.i.i.1 = freeze i16 %add.i.1.i.i.i.1\n %.cmp.not.1.i.i.i.1 = icmp eq i16 %add.i.frozen.1.i.i.i.1, 0\n %cond.i1002.2.i.i.i.1 = lshr i64 0, 0\n %conv115.2.i.i.i.1 = trunc i64 %cond.i1002.2.i.i.i.1 to i16\n %add.i.2.i.i.i.1 = or i16 %conv115.2.i.i.i.1, 0\n %add.i.frozen.2.i.i.i.1 = freeze i16 %add.i.2.i.i.i.1\n %.cmp.not.2.i.i.i.1 = icmp eq i16 %add.i.frozen.2.i.i.i.1, 0\n %cond.i1002.3.i.i.i.1 = lshr i64 0, 0\n %conv115.3.i.i.i.1 = trunc i64 %cond.i1002.3.i.i.i.1 to i16\n %add.i.3.i.i.i.1 = or i16 %conv115.3.i.i.i.1, 0\n %add.i.frozen.3.i.i.i.1 = freeze i16 %add.i.3.i.i.i.1\n %.cmp.not.3.i.i.i.1 = icmp eq i16 %add.i.frozen.3.i.i.i.1, 0\n %conv115.i.i.i.2 = trunc i64 %xor108.i.i.i to i16\n %add.i.i.i.i.2 = or i16 %conv115.i.i.i.2, 0\n %add.i.frozen.i.i.i.2 = freeze i16 %add.i.i.i.i.2\n %.cmp.not.i.i.i.2 = icmp eq i16 %add.i.frozen.i.i.i.2, 0\n %cond.i1002.1.i.i.i.2 = lshr i64 0, 0\n %conv115.1.i.i.i.2 = trunc i64 %cond.i1002.1.i.i.i.2 to i16\n %add.i.1.i.i.i.2 = or i16 %conv115.1.i.i.i.2, 0\n %add.i.frozen.1.i.i.i.2 = freeze i16 %add.i.1.i.i.i.2\n %.cmp.not.1.i.i.i.2 = icmp eq i16 %add.i.frozen.1.i.i.i.2, 0\n %cond.i1002.2.i.i.i.2 = lshr i64 0, 0\n %conv115.2.i.i.i.2 = trunc i64 %cond.i1002.2.i.i.i.2 to i16\n %add.i.2.i.i.i.2 = or i16 %conv115.2.i.i.i.2, 0\n %add.i.frozen.2.i.i.i.2 = freeze i16 %add.i.2.i.i.i.2\n %.cmp.not.2.i.i.i.2 = icmp eq i16 %add.i.frozen.2.i.i.i.2, 0\n %cond.i1002.3.i.i.i.2 = lshr i64 0, 0\n %conv115.3.i.i.i.2 = trunc i64 %cond.i1002.3.i.i.i.2 to i16\n %add.i.3.i.i.i.2 = or i16 %conv115.3.i.i.i.2, 0\n %add.i.frozen.3.i.i.i.2 = freeze i16 %add.i.3.i.i.i.2\n %.cmp.not.3.i.i.i.2 = icmp eq i16 %add.i.frozen.3.i.i.i.2, 0\n %conv115.i.i.i.3 = trunc i64 %xor108.i.i.i to i16\n %add.i.i.i.i.3 = or i16 %conv115.i.i.i.3, 0\n %add.i.frozen.i.i.i.3 = freeze i16 %add.i.i.i.i.3\n %.cmp.not.i.i.i.3 = icmp eq i16 %add.i.frozen.i.i.i.3, 0\n %cond.i1002.1.i.i.i.3 = lshr i64 0, 0\n %conv115.1.i.i.i.3 = trunc i64 %cond.i1002.1.i.i.i.3 to i16\n %add.i.1.i.i.i.3 = or i16 %conv115.1.i.i.i.3, 0\n %add.i.frozen.1.i.i.i.3 = freeze i16 %add.i.1.i.i.i.3\n %.cmp.not.1.i.i.i.3 = icmp eq i16 %add.i.frozen.1.i.i.i.3, 0\n %cond.i1002.2.i.i.i.3 = lshr i64 0, 0\n %conv115.2.i.i.i.3 = trunc i64 %cond.i1002.2.i.i.i.3 to i16\n %add.i.2.i.i.i.3 = or i16 %conv115.2.i.i.i.3, 0\n %add.i.frozen.2.i.i.i.3 = freeze i16 %add.i.2.i.i.i.3\n %.cmp.not.2.i.i.i.3 = icmp eq i16 %add.i.frozen.2.i.i.i.3, 0\n %cond.i1002.3.i.i.i.3 = lshr i64 0, 0\n %conv115.3.i.i.i.3 = trunc i64 %cond.i1002.3.i.i.i.3 to i16\n %add.i.3.i.i.i.3 = or i16 %conv115.3.i.i.i.3, 0\n %add.i.frozen.3.i.i.i.3 = freeze i16 %add.i.3.i.i.i.3\n %.cmp.not.3.i.i.i.3 = icmp eq i16 %add.i.frozen.3.i.i.i.3, 0\n ret void\n}",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[SLPVectorizer] Assertion `SubVectorsMask.size() == CommonMask.size() && \"Expected same size of masks for subvectors and common mask.\"' failed.",
"body": "Reproducer: https://godbolt.org/z/chKcKacPK\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 void @test() {\r\n %xor108.i.i.i = xor i64 0, 1\r\n %conv115.i.i.i = trunc i64 %xor108.i.i.i to i16\r\n %add.i.i.i.i = or i16 %conv115.i.i.i, 0\r\n %add.i.frozen.i.i.i = freeze i16 %add.i.i.i.i\r\n %.cmp.not.i.i.i = icmp eq i16 %add.i.frozen.i.i.i, 0\r\n %cond.i1002.1.i.i.i = lshr i64 0, 0\r\n %conv115.1.i.i.i = trunc i64 %cond.i1002.1.i.i.i to i16\r\n %add.i.1.i.i.i = or i16 %conv115.1.i.i.i, 0\r\n %add.i.frozen.1.i.i.i = freeze i16 %add.i.1.i.i.i\r\n %.cmp.not.1.i.i.i = icmp eq i16 %add.i.frozen.1.i.i.i, 0\r\n %cond.i1002.2.i.i.i = lshr i64 %xor108.i.i.i, 0\r\n %conv115.2.i.i.i = trunc i64 %cond.i1002.2.i.i.i to i16\r\n %add.i.2.i.i.i = or i16 %conv115.2.i.i.i, 0\r\n %add.i.frozen.2.i.i.i = freeze i16 %add.i.2.i.i.i\r\n %.cmp.not.2.i.i.i = icmp eq i16 %add.i.frozen.2.i.i.i, 0\r\n %cond.i1002.3.i.i.i = lshr i64 0, 0\r\n %conv115.3.i.i.i = trunc i64 %cond.i1002.3.i.i.i to i16\r\n %add.i.3.i.i.i = or i16 %conv115.3.i.i.i, 0\r\n %add.i.frozen.3.i.i.i = freeze i16 %add.i.3.i.i.i\r\n %.cmp.not.3.i.i.i = icmp eq i16 %add.i.frozen.3.i.i.i, 0\r\n %conv115.i.i.i.1 = trunc i64 %xor108.i.i.i to i16\r\n %add.i.i.i.i.1 = or i16 %conv115.i.i.i.1, 0\r\n %add.i.frozen.i.i.i.1 = freeze i16 %add.i.i.i.i.1\r\n %.cmp.not.i.i.i.1 = icmp eq i16 %add.i.frozen.i.i.i.1, 0\r\n %cond.i1002.1.i.i.i.1 = lshr i64 0, 0\r\n %conv115.1.i.i.i.1 = trunc i64 %cond.i1002.1.i.i.i.1 to i16\r\n %add.i.1.i.i.i.1 = or i16 %conv115.1.i.i.i.1, 0\r\n %add.i.frozen.1.i.i.i.1 = freeze i16 %add.i.1.i.i.i.1\r\n %.cmp.not.1.i.i.i.1 = icmp eq i16 %add.i.frozen.1.i.i.i.1, 0\r\n %cond.i1002.2.i.i.i.1 = lshr i64 0, 0\r\n %conv115.2.i.i.i.1 = trunc i64 %cond.i1002.2.i.i.i.1 to i16\r\n %add.i.2.i.i.i.1 = or i16 %conv115.2.i.i.i.1, 0\r\n %add.i.frozen.2.i.i.i.1 = freeze i16 %add.i.2.i.i.i.1\r\n %.cmp.not.2.i.i.i.1 = icmp eq i16 %add.i.frozen.2.i.i.i.1, 0\r\n %cond.i1002.3.i.i.i.1 = lshr i64 0, 0\r\n %conv115.3.i.i.i.1 = trunc i64 %cond.i1002.3.i.i.i.1 to i16\r\n %add.i.3.i.i.i.1 = or i16 %conv115.3.i.i.i.1, 0\r\n %add.i.frozen.3.i.i.i.1 = freeze i16 %add.i.3.i.i.i.1\r\n %.cmp.not.3.i.i.i.1 = icmp eq i16 %add.i.frozen.3.i.i.i.1, 0\r\n %conv115.i.i.i.2 = trunc i64 %xor108.i.i.i to i16\r\n %add.i.i.i.i.2 = or i16 %conv115.i.i.i.2, 0\r\n %add.i.frozen.i.i.i.2 = freeze i16 %add.i.i.i.i.2\r\n %.cmp.not.i.i.i.2 = icmp eq i16 %add.i.frozen.i.i.i.2, 0\r\n %cond.i1002.1.i.i.i.2 = lshr i64 0, 0\r\n %conv115.1.i.i.i.2 = trunc i64 %cond.i1002.1.i.i.i.2 to i16\r\n %add.i.1.i.i.i.2 = or i16 %conv115.1.i.i.i.2, 0\r\n %add.i.frozen.1.i.i.i.2 = freeze i16 %add.i.1.i.i.i.2\r\n %.cmp.not.1.i.i.i.2 = icmp eq i16 %add.i.frozen.1.i.i.i.2, 0\r\n %cond.i1002.2.i.i.i.2 = lshr i64 0, 0\r\n %conv115.2.i.i.i.2 = trunc i64 %cond.i1002.2.i.i.i.2 to i16\r\n %add.i.2.i.i.i.2 = or i16 %conv115.2.i.i.i.2, 0\r\n %add.i.frozen.2.i.i.i.2 = freeze i16 %add.i.2.i.i.i.2\r\n %.cmp.not.2.i.i.i.2 = icmp eq i16 %add.i.frozen.2.i.i.i.2, 0\r\n %cond.i1002.3.i.i.i.2 = lshr i64 0, 0\r\n %conv115.3.i.i.i.2 = trunc i64 %cond.i1002.3.i.i.i.2 to i16\r\n %add.i.3.i.i.i.2 = or i16 %conv115.3.i.i.i.2, 0\r\n %add.i.frozen.3.i.i.i.2 = freeze i16 %add.i.3.i.i.i.2\r\n %.cmp.not.3.i.i.i.2 = icmp eq i16 %add.i.frozen.3.i.i.i.2, 0\r\n %conv115.i.i.i.3 = trunc i64 %xor108.i.i.i to i16\r\n %add.i.i.i.i.3 = or i16 %conv115.i.i.i.3, 0\r\n %add.i.frozen.i.i.i.3 = freeze i16 %add.i.i.i.i.3\r\n %.cmp.not.i.i.i.3 = icmp eq i16 %add.i.frozen.i.i.i.3, 0\r\n %cond.i1002.1.i.i.i.3 = lshr i64 0, 0\r\n %conv115.1.i.i.i.3 = trunc i64 %cond.i1002.1.i.i.i.3 to i16\r\n %add.i.1.i.i.i.3 = or i16 %conv115.1.i.i.i.3, 0\r\n %add.i.frozen.1.i.i.i.3 = freeze i16 %add.i.1.i.i.i.3\r\n %.cmp.not.1.i.i.i.3 = icmp eq i16 %add.i.frozen.1.i.i.i.3, 0\r\n %cond.i1002.2.i.i.i.3 = lshr i64 0, 0\r\n %conv115.2.i.i.i.3 = trunc i64 %cond.i1002.2.i.i.i.3 to i16\r\n %add.i.2.i.i.i.3 = or i16 %conv115.2.i.i.i.3, 0\r\n %add.i.frozen.2.i.i.i.3 = freeze i16 %add.i.2.i.i.i.3\r\n %.cmp.not.2.i.i.i.3 = icmp eq i16 %add.i.frozen.2.i.i.i.3, 0\r\n %cond.i1002.3.i.i.i.3 = lshr i64 0, 0\r\n %conv115.3.i.i.i.3 = trunc i64 %cond.i1002.3.i.i.i.3 to i16\r\n %add.i.3.i.i.i.3 = or i16 %conv115.3.i.i.i.3, 0\r\n %add.i.frozen.3.i.i.i.3 = freeze i16 %add.i.3.i.i.i.3\r\n %.cmp.not.3.i.i.i.3 = icmp eq i16 %add.i.frozen.3.i.i.i.3, 0\r\n ret void\r\n}\r\n```\r\n```\r\nopt: /root/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:10880: llvm::InstructionCost llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator::finalize(llvm::ArrayRef<int>, llvm::ArrayRef<std::pair<const llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int> >, llvm::ArrayRef<int>, unsigned int, llvm::function_ref<void(llvm::Value*&, llvm::SmallVectorImpl<int>&)>): Assertion `SubVectorsMask.size() == CommonMask.size() && \"Expected same size of masks for subvectors and common 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 0x00007ac42d642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x00007ac42d6969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x00007ac42d642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x00007ac42d6287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00007ac42d62871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x00007ac42d639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x00000000041e9132 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+0x41e9132)\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 0x000000000426d57c llvm::SLPVectorizerPass::tryToVectorizeList(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x426d57c)\r\n#13 0x000000000427168f bool llvm::SLPVectorizerPass::vectorizeCmpInsts<std::reverse_iterator<llvm::CmpInst* const*>>(llvm::iterator_range<std::reverse_iterator<llvm::CmpInst* const*>>, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x427168f)\r\n#14 0x0000000004271fdb llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&)::'lambda3'(bool)::operator()(bool) const SLPVectorizer.cpp:0:0\r\n#15 0x0000000004275785 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4275785)\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 0x00007ac42d629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#27 0x00007ac42d629e40 __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
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
b8703369daf777706196ff914c0376c27adde3cf
| null |
174045
|
https://github.com/llvm/llvm-project/issues/174045
|
miscompilation
|
1171e30cb01c00a048ec0d82f20e57213842f505
| 2025-12-31T00:32:28
|
[
"llvm/test/Transforms/GVN",
"llvm/test/Transforms/InstSimplify"
] |
{
"fix_commit": "a3c9b72651178e7903c9c4db791b676ab91442a9",
"components": [
"Loads"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": [
[
835,
841
],
[
847,
853
],
[
866,
872
]
],
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": [
"isPointerAlwaysReplaceable",
"llvm::canReplacePointersIfEqual",
"llvm::canReplacePointersInUseIfEqual"
],
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit a3c9b72651178e7903c9c4db791b676ab91442a9
Author: hanbeom <kese111@gmail.com>
Date: Thu Jan 8 09:30:11 2026 +0900
[IR] Fix canReplacePointersIfEqual to properly validate vector pointers (#174142)
Previously, `canReplacePointersIfEqual` unconditionally returned
`true` for vectors of pointers (e.g., `<2 x ptr>`) because it only
checked for scalar pointer types.
This resulted in a failure to perform appropriate verification for
these types. This patch fixes the logic to ensure they are properly
validated.
Fixes https://github.com/llvm/llvm-project/issues/174045
diff --git a/llvm/lib/Analysis/Loads.cpp b/llvm/lib/Analysis/Loads.cpp
index 73f40f13a262..2e855f918c91 100644
--- a/llvm/lib/Analysis/Loads.cpp
+++ b/llvm/lib/Analysis/Loads.cpp
@@ -835,7 +835,7 @@ static bool isPointerAlwaysReplaceable(const Value *From, const Value *To,
// optimizations.
if (isa<ConstantPointerNull>(To))
return true;
- if (isa<Constant>(To) &&
+ if (isa<Constant>(To) && To->getType()->isPointerTy() &&
isDereferenceablePointer(To, Type::getInt8Ty(To->getContext()), DL))
return true;
return getUnderlyingObjectAggressive(From) ==
@@ -847,7 +847,7 @@ bool llvm::canReplacePointersInUseIfEqual(const Use &U, const Value *To,
Type *Ty = To->getType();
assert(U->getType() == Ty && "values must have matching types");
// Not a pointer, just return true.
- if (!Ty->isPointerTy())
+ if (!Ty->isPtrOrPtrVectorTy())
return true;
// Do not perform replacements in lifetime intrinsic arguments.
@@ -866,7 +866,7 @@ bool llvm::canReplacePointersIfEqual(const Value *From, const Value *To,
const DataLayout &DL) {
assert(From->getType() == To->getType() && "values must have matching types");
// Not a pointer, just return true.
- if (!From->getType()->isPointerTy())
+ if (!From->getType()->isPtrOrPtrVectorTy())
return true;
return isPointerAlwaysReplaceable(From, To, DL);
|
[
{
"file": "llvm/test/Transforms/GVN/condprop.ll",
"commands": [
"opt < %s -passes=gvn -S"
],
"tests": [
{
"test_name": "select_same_obj",
"test_body": "define void @select_same_obj(i1 %c, ptr %p, i64 %x) {\nentry:\n %p2 = getelementptr i8, ptr %p, i64 %x\n %p3 = select i1 %c, ptr %p, ptr %p2\n %cmp = icmp eq ptr %p, %p3\n br i1 %cmp, label %if, label %exit\n\nif: ; preds = %entry\n call void @use_ptr(ptr %p)\n call void @use_ptr(ptr %p3)\n ret void\n\nexit: ; preds = %entry\n ret void\n}\n\ndeclare void @use_ptr(ptr)\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "select_vector_eq",
"test_body": "define <2 x ptr> @select_vector_eq(<2 x ptr> %a, <2 x ptr> %b) {\n %cmp = icmp eq <2 x ptr> %a, %b\n %sel = select <2 x i1> %cmp, <2 x ptr> %a, <2 x ptr> %b\n ret <2 x ptr> %sel\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/InstSimplify/select-icmp.ll",
"commands": [
"opt < %s -passes=instsimplify -S"
],
"tests": [
{
"test_name": "ptr_eq_replace_same_underlying_object",
"test_body": "define ptr @ptr_eq_replace_same_underlying_object(ptr %st, i64 %i, i64 %j) {\n %a = getelementptr inbounds i8, ptr %st, i64 %i\n %b = getelementptr inbounds i8, ptr %st, i64 %j\n %cmp = icmp eq ptr %a, %b\n %sel = select i1 %cmp, ptr %a, ptr %b\n ret ptr %sel\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "icmp_ptr_eq_replace",
"test_body": "define ptr @icmp_ptr_eq_replace(ptr %a, ptr %b) {\n %cmp = icmp eq ptr %a, %b\n %sel = select i1 %cmp, ptr %a, ptr %b\n ret ptr %sel\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "ptr_eq_replace_vector_constant",
"test_body": "define <2 x ptr> @ptr_eq_replace_vector_constant(<2 x ptr> %a) {\n %cmp = icmp eq <2 x ptr> %a, <ptr inttoptr (i64 42 to ptr), ptr inttoptr (i64 88 to ptr)>\n %sel = select <2 x i1> %cmp, <2 x ptr> %a, <2 x ptr> <ptr inttoptr (i64 42 to ptr), ptr inttoptr (i64 88 to ptr)>\n ret <2 x ptr> %sel\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "icmp_vector_ptr_eq_replace",
"test_body": "define <2 x ptr> @icmp_vector_ptr_eq_replace(<2 x ptr> %a, <2 x ptr> %b) {\n %cmp = icmp eq <2 x ptr> %a, %b\n %sel = select <2 x i1> %cmp, <2 x ptr> %a, <2 x ptr> %b\n ret <2 x ptr> %sel\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "icmp_ptr_eq_replace_null",
"test_body": "define ptr @icmp_ptr_eq_replace_null(ptr %a) {\n %cmp = icmp eq ptr %a, null\n %sel = select i1 %cmp, ptr null, ptr %a\n ret ptr %sel\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "ptr_eq_replace_constant",
"test_body": "define ptr @ptr_eq_replace_constant(ptr %a) {\n %cmp = icmp eq ptr %a, inttoptr (i64 42 to ptr)\n %sel = select i1 %cmp, ptr inttoptr (i64 42 to ptr), ptr %a\n ret ptr %sel\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[InstSimplify] Folds vector pointer `select (icmp eq <N x ptr>)` to operand and loses provenance",
"body": "Instsimplify can fold:\n\n```llvm\n%cmp = icmp eq <2 x ptr> %a, %b\n%sel = select <2 x i1> %cmp, <2 x ptr> %a, %b\n```\n\nto `ret <2 x ptr> %b`, which is not always valid for pointers. Even if `%a[0]` and `%b[0]` have the same address , they might have different provenance, so selecting `%a[0]` is not equivalent to returning `%b[0]`.\n\nAlive2 proof: https://alive2.llvm.org/ce/z/JxDjAx\n\nExposed from https://github.com/llvm/llvm-project/commit/1af627b592dd15bbe58136f902ced46251fc344d, cc @dtcxzyw ",
"author": "cardigan1008",
"labels": [
"miscompilation",
"llvm:analysis"
],
"comments": [
{
"author": "nikic",
"body": "In https://github.com/llvm/llvm-project/blob/393783fff844d8919a090f74e641d78c50bcc7f4/llvm/lib/Analysis/Loads.cpp#L845-L873 we should replace the pointer checks with pointer or vector of pointer checks."
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null | null |
106641
|
https://github.com/llvm/llvm-project/issues/106641
|
crash
|
c8568f09577e9332d15edf98beb5376dc8d0672e
| 2024-08-29T23:08:58
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "f0e34f381866b82a26241f7e9aa5964f0dd11ebd",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
[
7147,
7153
],
[
7250,
7259
],
[
7284,
7299
],
[
7364,
7371
]
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"LoopVectorizationPlanner::computeBestVF",
"LoopVectorizationPlanner::precomputeCosts",
"planContainsAdditionalSimplifications"
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit f0e34f381866b82a26241f7e9aa5964f0dd11ebd
Author: Florian Hahn <flo@fhahn.com>
Date: Fri Aug 30 11:29:29 2024 +0100
[VPlan] Don't skip optimizable truncs in planContainsAdditionalSimps.
A optimizable cast can also be removed by VPlan simplifications. Remove
the restriction from planContainsAdditionalSimplifications, as this
causes it to miss relevant simplifications, triggering false positives
for the cost decision verification.
Also adds debug output for printing additional cost-precomputations.
Fixes https://github.com/llvm/llvm-project/issues/106641.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 6babfd1eee91..fa05b8dd2242 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7147,7 +7147,12 @@ LoopVectorizationPlanner::precomputeCosts(VPlan &Plan, ElementCount VF,
if (!OrigLoop->contains(CondI) ||
!CostCtx.SkipCostComputation.insert(CondI).second)
continue;
- Cost += CostCtx.getLegacyCost(CondI, VF);
+ InstructionCost CondICost = CostCtx.getLegacyCost(CondI, VF);
+ LLVM_DEBUG({
+ dbgs() << "Cost of " << CondICost << " for VF " << VF
+ << ": exit condition instruction " << *CondI << "\n";
+ });
+ Cost += CondICost;
for (Value *Op : CondI->operands()) {
auto *OpI = dyn_cast<Instruction>(Op);
if (!OpI || any_of(OpI->users(), [&ExitInstrs, this](User *U) {
@@ -7250,10 +7255,9 @@ InstructionCost LoopVectorizationPlanner::cost(VPlan &Plan,
/// 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) {
+static bool planContainsAdditionalSimplifications(VPlan &Plan,
+ VPCostContext &CostCtx,
+ Loop *TheLoop) {
// First collect all instructions for the recipes in Plan.
auto GetInstructionForCost = [](const VPRecipeBase *R) -> Instruction * {
if (auto *S = dyn_cast<VPSingleDefRecipe>(R))
@@ -7284,16 +7288,13 @@ planContainsAdditionalSimplifications(VPlan &Plan, ElementCount VF,
// 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);
- });
- });
+ return any_of(TheLoop->blocks(), [&SeenInstrs, &CostCtx](BasicBlock *BB) {
+ return any_of(*BB, [&SeenInstrs, &CostCtx](Instruction &I) {
+ if (isa<PHINode>(&I))
+ return false;
+ return !SeenInstrs.contains(&I) && !CostCtx.skipCostComputation(&I, true);
+ });
+ });
}
#endif
@@ -7364,8 +7365,7 @@ VectorizationFactor LoopVectorizationPlanner::computeBestVF() {
precomputeCosts(BestPlan, BestFactor.Width, CostCtx);
assert((BestFactor.Width == LegacyVF.Width ||
planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width),
- BestFactor.Width, CostCtx,
- OrigLoop, CM)) &&
+ CostCtx, OrigLoop)) &&
" 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/truncate-to-minimal-bitwidth-cost.ll",
"commands": [
"opt -p loop-vectorize -mattr=+v -S %s"
],
"tests": [
{
"test_name": "truncate_to_i1_used_by_branch",
"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 @truncate_to_i1_used_by_branch(i8 %x, ptr %dst) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %f.039 = phi i8 [ 0, %entry ], [ %add, %loop.latch ]\n %0 = or i8 23, %x\n %extract.t = trunc i8 %0 to i1\n br i1 %extract.t, label %then, label %loop.latch\n\nthen: ; preds = %loop.header\n store i8 0, ptr %dst, align 1\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n %add = add i8 %f.039, 1\n %conv = sext i8 %f.039 to i32\n %cmp = icmp slt i32 %conv, 1\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,+zvl256b\" }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "test_pr98413_sext_removed",
"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_pr98413_sext_removed(ptr %src, ptr noalias %dst, i64 %x) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep.src = getelementptr inbounds i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep.src, align 8\n %ext.l = sext i16 %l to i64\n %and = and i64 %x, %ext.l\n %trunc.and = trunc i64 %and to i8\n %gep.dst = getelementptr inbounds i8, ptr %dst, i64 %iv\n store i8 %trunc.and, ptr %gep.dst, align 1\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv, 96\n br i1 %exitcond.not, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "test_pr98413_zext_removed",
"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_pr98413_zext_removed(ptr %src, ptr noalias %dst, i64 %x) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep.src = getelementptr inbounds i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep.src, align 8\n %ext.l = zext i16 %l to i64\n %and = and i64 %x, %ext.l\n %trunc.and = trunc i64 %and to i8\n %gep.dst = getelementptr inbounds i8, ptr %dst, i64 %iv\n store i8 %trunc.and, ptr %gep.dst, align 1\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv, 96\n br i1 %exitcond.not, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[VPlan] Assertion \" VPlan cost model and legacy cost model disagreed\"' failed.",
"body": "Tested using c4906588ce47de33d59bcd95f3e82ce2c3e61c23\r\n\r\nTestcase:\r\n```c\r\n_Bool a;\r\nchar b;\r\nunsigned char c;\r\nvoid d(_Bool e[][6]) {\r\n for (signed char f = 0; f < c; f += 3)\r\n for (_Bool g = ({\r\n __typeof__(0) h = e[1][2];\r\n e[f][f] > h ?: h;\r\n });\r\n g; g = b)\r\n for (_Bool i = 0; i < (0 >= 0); i = 1)\r\n a = 0;\r\n}\r\n```\r\nhttps://godbolt.org/z/Eab8s5e1K\r\n\r\nReduced LLVM IR 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 void @d() #0 {\r\nentry:\r\n br label %for.body\r\n\r\nfor.cond.cleanup.loopexit: ; preds = %for.cond.cleanup14\r\n ret void\r\n\r\nfor.body: ; preds = %for.cond.cleanup14, %entry\r\n %f.039 = phi i8 [ %add, %for.cond.cleanup14 ], [ 0, %entry ]\r\n %0 = or i8 0, 0\r\n %extract.t = trunc i8 %0 to i1\r\n br i1 %extract.t, label %for.body22.lr.ph, label %for.cond.cleanup14\r\n\r\nfor.body22.lr.ph: ; preds = %for.body\r\n store i8 0, ptr null, align 1\r\n br label %for.cond.cleanup14\r\n\r\nfor.cond.cleanup14: ; preds = %for.body22.lr.ph, %for.body\r\n %add = add i8 %f.039, 1\r\n %conv = sext i8 %f.039 to i32\r\n %cmp = icmp slt i32 %conv, 1\r\n br i1 %cmp, label %for.body, label %for.cond.cleanup.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,+zvl256b,+zvl32b,+zvl64b,-b,-e,-experimental-smctr,-experimental-smmpm,-experimental-smnpm,-experimental-ssctr,-experimental-ssnpm,-experimental-sspm,-experimental-supm,-experimental-zacas,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-experimental-zvbc32e,-experimental-zvkgs,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssqosid,-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:7365: 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.\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 \"d\"\r\n #0 0x000064cd5b412560 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x301e560)\r\n #1 0x000064cd5b40f96f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x301b96f)\r\n #2 0x000064cd5b40fac5 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x000072ec5a042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x000072ec5a0969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x000072ec5a0969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x000072ec5a0969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x000072ec5a042476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x000072ec5a0287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x000072ec5a02871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x000072ec5a039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x000064cd5a3dd109 llvm::LoopVectorizationPlanner::computeBestVF() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1fe9109)\r\n#12 0x000064cd5a3f3ccb llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1fffccb)\r\n#13 0x000064cd5a3f6ce1 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2002ce1)\r\n#14 0x000064cd5a3f7357 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2003357)\r\n#15 0x000064cd592541b6 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+0xe601b6)\r\n#16 0x000064cd5b21d41f 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+0x2e2941f)\r\n#17 0x000064cd59257346 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+0xe63346)\r\n#18 0x000064cd5b21c19b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e2819b)\r\n#19 0x000064cd592535e6 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+0xe5f5e6)\r\n#20 0x000064cd5b21a1dd 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+0x2e261dd)\r\n#21 0x000064cd58a7c106 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+0x688106)\r\n#22 0x000064cd58a6de91 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x679e91)\r\n#23 0x000072ec5a029d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#24 0x000072ec5a029e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#25 0x000072ec5a029e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#26 0x000064cd58a64245 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x670245)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\nhttps://godbolt.org/z/EzdEYKW7c\r\n\r\nFound via fuzzer\r\n\r\nRelated/prior issue: #106417\r\n\r\ncc @fhahn",
"author": "patrick-rivos",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
|
4e04286d61edfb56338ca3a6d0735c5384508b00
| null |
82230
|
https://github.com/llvm/llvm-project/issues/82230
|
crash
|
769c22f25b81b74e4da7871d4e552584605caef1
| 2024-02-19T09:37:19
|
[
"llvm/test/DebugInfo"
] |
{
"fix_commit": "5b342e6041f8567a39354ae3c5346cf74b3bb84f",
"components": [
"IR"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": [
[
293,
299
],
[
4886,
4893
]
],
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": [
"DPValue::print",
"PrintCallingConv",
"getModuleFromDPI"
],
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 5b342e6041f8567a39354ae3c5346cf74b3bb84f
Author: Stephen Tozer <stephen.tozer@sony.com>
Date: Mon Feb 19 11:38:04 2024 +0000
[RemoveDIs][DebugInfo] Check for null marker when printing DPValues (#82238)
The function to print DPValues currently tries to incorporate the
function it is part of, which is found through its marker; this means
when we try to print a DPValue with no marker, we dereference a nullptr.
We can print instructions without parents, and so the same should be
true for DPValues; this patch changes DPValue::print to check for a null
marker and avoid dereferencing it.
Fixes issue: https://github.com/llvm/llvm-project/issues/82230
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index 0ae720e8b7ce..d3c64a57f7fd 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -293,7 +293,7 @@ static const Module *getModuleFromDPI(const DPMarker *Marker) {
}
static const Module *getModuleFromDPI(const DPValue *DPV) {
- return getModuleFromDPI(DPV->getMarker());
+ return DPV->getMarker() ? getModuleFromDPI(DPV->getMarker()) : nullptr;
}
static void PrintCallingConv(unsigned cc, raw_ostream &Out) {
@@ -4886,8 +4886,9 @@ void DPValue::print(raw_ostream &ROS, ModuleSlotTracker &MST,
if (F)
MST.incorporateFunction(*F);
};
- incorporateFunction(Marker->getParent() ? Marker->getParent()->getParent()
- : nullptr);
+ incorporateFunction(Marker && Marker->getParent()
+ ? Marker->getParent()->getParent()
+ : nullptr);
AssemblyWriter W(OS, SlotTable, getModuleFromDPI(this), nullptr, IsForDebug);
W.printDPValue(*this);
}
|
[
{
"file": "llvm/test/DebugInfo/dpvalue-print-nocrash.ll",
"commands": [
"opt -passes=\"instcombine\" -debug %s -o /dev/null 2>&1"
],
"tests": [
{
"test_name": "<module>",
"test_body": ";; Tests that we can debug-print DPValues that have no markers attached.\n; REQUIRES: asserts\n\n\ndefine ptr @func_10(i32 %p_11) {\nentry:\n %conv108 = zext i32 %p_11 to i64\n tail call void @llvm.dbg.value(metadata i64 %conv108, metadata !4, metadata !DIExpression()), !dbg !12\n br label %func_29.exit\n\nfunc_29.exit: ; preds = %entry\n store i64 %conv108, ptr null, align 1\n ret ptr null\n}\n\ndeclare void @llvm.dbg.value(metadata, metadata, metadata)\n\n!llvm.dbg.cu = !{!0}\n!llvm.module.flags = !{!3}\n\n!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: \"clang\", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, retainedTypes: !2, globals: !2, splitDebugInlining: false, nameTableKind: None)\n!1 = !DIFile(filename: \"csmith5961503756960.c\", directory: \"/llvm\")\n!2 = !{}\n!3 = !{i32 2, !\"Debug Info Version\", i32 3}\n!4 = !DILocalVariable(name: \"p_31\", arg: 2, scope: !5, file: !1, line: 148, type: !7)\n!5 = distinct !DISubprogram(name: \"func_29\", scope: !1, file: !1, line: 148, type: !6, scopeLine: 149, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)\n!6 = !DISubroutineType(types: !2)\n!7 = !DIDerivedType(tag: DW_TAG_typedef, name: \"uint64_t\", file: !8, line: 60, baseType: !9)\n!8 = !DIFile(filename: \"/foo/_stdint.h\", directory: \"\")\n!9 = !DIDerivedType(tag: DW_TAG_typedef, name: \"__uint64_t\", file: !10, line: 108, baseType: !11)\n!10 = !DIFile(filename: \"/foo/_default_types.h\", directory: \"\")\n!11 = !DIBasicType(name: \"unsigned long long\", size: 64, encoding: DW_ATE_unsigned)\n!12 = !DILocation(line: 0, scope: !5)",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "opt -passes=\"instcombine\" -debug crashes with non-instrinsic debug-info",
"body": "llvm commit: d61864f813e3\r\nReproduce with:\r\n```\r\nopt -passes=\"instcombine\" -debug bbi-92509.ll -o /dev/null\r\n```\r\n[bbi-92509.ll.gz](https://github.com/llvm/llvm-project/files/14329283/bbi-92509.ll.gz)\r\n\r\nResult:\r\n```\r\nINSTCOMBINE ITERATION #1 on func_10\r\nADD: ret ptr null\r\nADD: store i64 %conv108, ptr null, align 1\r\nADD: br label %func_29.exit\r\nADD: %conv108 = zext i32 %p_11 to i64\r\nCLONE: PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: ../../main-github/llvm/build-all/bin/opt -passes=instcombine -debug bbi-92509.ll -o /dev/null\r\n #0 0x000055e12968f4a7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (../../main-github/llvm/build-all/bin/opt+0x3db14a7)\r\n #1 0x000055e12968cf7e llvm::sys::RunSignalHandlers() (../../main-github/llvm/build-all/bin/opt+0x3daef7e)\r\n #2 0x000055e12968fe6f SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007fdf33999630 __restore_rt sigaction.c:0:0\r\n #4 0x000055e12971f8e0 llvm::DPMarker::getParent() const (../../main-github/llvm/build-all/bin/opt+0x3e418e0)\r\n #5 0x000055e129761abf llvm::DPValue::print(llvm::raw_ostream&, bool) const (../../main-github/llvm/build-all/bin/opt+0x3e83abf)\r\n #6 0x000055e12a244957 llvm::InstCombinerImpl::tryToSinkInstructionDPValues(llvm::Instruction*, llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true>, false, false>, llvm::BasicBlock*, llvm::BasicBlock*, llvm::SmallVectorImpl<llvm::DPValue*>&) InstructionCombining.cpp:0:0\r\n #7 0x000055e12a242b0c llvm::InstCombinerImpl::tryToSinkInstruction(llvm::Instruction*, llvm::BasicBlock*) InstructionCombining.cpp:0:0\r\n #8 0x000055e12a2453fc llvm::InstCombinerImpl::run() InstructionCombining.cpp:0:0\r\n #9 0x000055e12a248c79 combineInstructionsOverFunction(llvm::Function&, llvm::InstructionWorklist&, llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::ProfileSummaryInfo*, llvm::LoopInfo*, llvm::InstCombineOptions const&) InstructionCombining.cpp:0:0\r\n#10 0x000055e12a2482ea llvm::InstCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x496a2ea)\r\n#11 0x000055e12a95e5bd llvm::detail::PassModel<llvm::Function, llvm::InstCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) PassBuilderPipelines.cpp:0:0\r\n#12 0x000055e12989a8e4 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x3fbc8e4)\r\n#13 0x000055e12a9644dd llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) PassBuilderPipelines.cpp:0:0\r\n#14 0x000055e12989f9ae llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x3fc19ae)\r\n#15 0x000055e12a95dd9d llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) PassBuilderPipelines.cpp:0:0\r\n#16 0x000055e129899456 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x3fbb456)\r\n#17 0x000055e12a90a42b 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) (../../main-github/llvm/build-all/bin/opt+0x502c42b)\r\n#18 0x000055e129657a28 optMain (../../main-github/llvm/build-all/bin/opt+0x3d79a28)\r\n#19 0x00007fdf310cc555 __libc_start_main (/lib64/libc.so.6+0x22555)\r\n#20 0x000055e129651369 _start (../../main-github/llvm/build-all/bin/opt+0x3d73369)\r\nSegmentation fault (core dumped)\r\n```\r\n\r\nThis starts happening with a93a4ec7dd205\r\n```\r\nReapply \"[DebugInfo][RemoveDIs] Turn on non-instrinsic debug-info by default\"\r\n```\r\n",
"author": "mikaelholmen",
"labels": [
"debuginfo",
"llvm:crash",
"llvm:ir"
],
"comments": [
{
"author": "SLTozer",
"body": "Should be fixed by: [5b342e6](https://github.com/llvm/llvm-project/commit/5b342e6041f8567a39354ae3c5346cf74b3bb84f)"
},
{
"author": "mikaelholmen",
"body": "> Should be fixed by: [5b342e6](https://github.com/llvm/llvm-project/commit/5b342e6041f8567a39354ae3c5346cf74b3bb84f)\r\n\r\nYep, thanks!"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
|
a93a4ec7dd205b965ee5597314bb376520cd736c
| null |
143513
|
https://github.com/llvm/llvm-project/issues/143513
|
crash
|
cf637b7e3554976419a0d672ad4c252137dc34f3
| 2025-06-10T12:05:35
|
[
"llvm/test/Transforms/PhaseOrdering",
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "0108a5908cab5e418c683ef9b6e1810755344b5e",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
12085,
12091
],
[
12130,
12136
],
[
12152,
12159
],
[
12171,
12182
]
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"computeExtractCost"
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 0108a5908cab5e418c683ef9b6e1810755344b5e
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Tue Jun 17 07:55:52 2025 -0700
[SLP]Fix a crash on an subvector size calculation for non-power-of-2 vector
Patch fixes cost estimation for the extractelements from non-power-of-2
vectors, defined as subvector extracts. In this case the subvector size
might be not adjusted to a whole register size, need to get the minimum
between whole vector size and the actual difference to prevent compiler
crash.
Fixes #143513
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index d811e9d77d18..4551a365a696 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -12085,7 +12085,8 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
// FIXME: this must be moved to TTI for better estimation.
unsigned EltsPerVector = getPartNumElems(VL.size(), NumParts);
auto CheckPerRegistersShuffle = [&](MutableArrayRef<int> Mask,
- SmallVectorImpl<unsigned> &Indices)
+ SmallVectorImpl<unsigned> &Indices,
+ SmallVectorImpl<unsigned> &SubVecSizes)
-> std::optional<TTI::ShuffleKind> {
if (NumElts <= EltsPerVector)
return std::nullopt;
@@ -12130,7 +12131,9 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
return std::min(S, I);
}),
EltsPerVector);
- Indices.push_back(OffsetReg1 % NumElts);
+ unsigned Index = OffsetReg1 % NumElts;
+ Indices.push_back(Index);
+ SubVecSizes.push_back(std::min(NumElts - Index, EltsPerVector));
}
Idx = I - OffsetReg1;
}
@@ -12152,8 +12155,9 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
SmallVector<int> SubMask(EltsPerVector, PoisonMaskElem);
copy(MaskSlice, SubMask.begin());
SmallVector<unsigned, 2> Indices;
+ SmallVector<unsigned, 2> SubVecSizes;
std::optional<TTI::ShuffleKind> RegShuffleKind =
- CheckPerRegistersShuffle(SubMask, Indices);
+ CheckPerRegistersShuffle(SubMask, Indices, SubVecSizes);
if (!RegShuffleKind) {
if (*ShuffleKinds[Part] != TTI::SK_PermuteSingleSrc ||
!ShuffleVectorInst::isIdentityMask(
@@ -12171,12 +12175,12 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
}
const unsigned BaseVF = getFullVectorNumberOfElements(
*R.TTI, VL.front()->getType(), alignTo(NumElts, EltsPerVector));
- for (unsigned Idx : Indices) {
- assert((Idx + EltsPerVector) <= BaseVF &&
+ for (const auto [Idx, SubVecSize] : zip(Indices, SubVecSizes)) {
+ assert((Idx + SubVecSize) <= BaseVF &&
"SK_ExtractSubvector index out of range");
Cost += ::getShuffleCost(TTI, TTI::SK_ExtractSubvector,
getWidenedType(ScalarTy, BaseVF), {}, CostKind,
- Idx, getWidenedType(ScalarTy, EltsPerVector));
+ Idx, getWidenedType(ScalarTy, SubVecSize));
}
// Second attempt to check, if just a permute is better estimated than
// subvector extract.
|
[
{
"file": "llvm/test/Transforms/PhaseOrdering/X86/hadd.ll",
"commands": [
"opt < %s -O3 -S -mtriple=x86_64-- -mcpu=x86-64",
"opt < %s -O3 -S -mtriple=x86_64-- -mcpu=x86-64-v2",
"opt < %s -O3 -S -mtriple=x86_64-- -mcpu=x86-64-v3",
"opt < %s -O3 -S -mtriple=x86_64-- -mcpu=x86-64-v4",
"opt < %s -passes=\"default<O3>\" -S -mtriple=x86_64-- -mcpu=x86-64",
"opt < %s -passes=\"default<O3>\" -S -mtriple=x86_64-- -mcpu=x86-64-v2",
"opt < %s -passes=\"default<O3>\" -S -mtriple=x86_64-- -mcpu=x86-64-v3",
"opt < %s -passes=\"default<O3>\" -S -mtriple=x86_64-- -mcpu=x86-64-v4"
],
"tests": [
{
"test_name": "add_v16i16_0123u56789uBCDEF",
"test_body": "define <16 x i16> @add_v16i16_0123u56789uBCDEF(<16 x i16> %a, <16 x i16> %b) {\n %a0 = extractelement <16 x i16> %a, i32 0\n %a1 = extractelement <16 x i16> %a, i32 1\n %a2 = extractelement <16 x i16> %a, i32 2\n %a3 = extractelement <16 x i16> %a, i32 3\n %a4 = extractelement <16 x i16> %a, i32 4\n %a5 = extractelement <16 x i16> %a, i32 5\n %a6 = extractelement <16 x i16> %a, i32 6\n %a7 = extractelement <16 x i16> %a, i32 7\n %a8 = extractelement <16 x i16> %a, i32 8\n %a9 = extractelement <16 x i16> %a, i32 9\n %aA = extractelement <16 x i16> %a, i32 10\n %aB = extractelement <16 x i16> %a, i32 11\n %aC = extractelement <16 x i16> %a, i32 12\n %aD = extractelement <16 x i16> %a, i32 13\n %aE = extractelement <16 x i16> %a, i32 14\n %aF = extractelement <16 x i16> %a, i32 15\n %a01 = add i16 %a0, %a1\n %a23 = add i16 %a2, %a3\n %a45 = add i16 %a4, %a5\n %a67 = add i16 %a6, %a7\n %a89 = add i16 %a8, %a9\n %aAB = add i16 %aA, %aB\n %aCD = add i16 %aC, %aD\n %aEF = add i16 %aE, %aF\n %b0 = extractelement <16 x i16> %b, i32 0\n %b1 = extractelement <16 x i16> %b, i32 1\n %b2 = extractelement <16 x i16> %b, i32 2\n %b3 = extractelement <16 x i16> %b, i32 3\n %b4 = extractelement <16 x i16> %b, i32 4\n %b5 = extractelement <16 x i16> %b, i32 5\n %b6 = extractelement <16 x i16> %b, i32 6\n %b7 = extractelement <16 x i16> %b, i32 7\n %b8 = extractelement <16 x i16> %b, i32 8\n %b9 = extractelement <16 x i16> %b, i32 9\n %bA = extractelement <16 x i16> %b, i32 10\n %bB = extractelement <16 x i16> %b, i32 11\n %bC = extractelement <16 x i16> %b, i32 12\n %bD = extractelement <16 x i16> %b, i32 13\n %bE = extractelement <16 x i16> %b, i32 14\n %bF = extractelement <16 x i16> %b, i32 15\n %b01 = add i16 %b0, %b1\n %b23 = add i16 %b2, %b3\n %b45 = add i16 %b4, %b5\n %b67 = add i16 %b6, %b7\n %b89 = add i16 %b8, %b9\n %bAB = add i16 %bA, %bB\n %bCD = add i16 %bC, %bD\n %bEF = add i16 %bE, %bF\n %hadd0 = insertelement <16 x i16> poison, i16 %a01, i32 0\n %hadd1 = insertelement <16 x i16> %hadd0, i16 %a23, i32 1\n %hadd2 = insertelement <16 x i16> %hadd1, i16 %a45, i32 2\n %hadd3 = insertelement <16 x i16> %hadd2, i16 %a67, i32 3\n %hadd4 = insertelement <16 x i16> %hadd3, i16 %b01, i32 4\n %hadd5 = insertelement <16 x i16> %hadd4, i16 %b23, i32 5\n %hadd6 = insertelement <16 x i16> %hadd5, i16 %b45, i32 6\n %hadd7 = insertelement <16 x i16> %hadd6, i16 %b67, i32 7\n %hadd8 = insertelement <16 x i16> %hadd7, i16 %a89, i32 8\n %hadd9 = insertelement <16 x i16> %hadd8, i16 %aAB, i32 9\n %haddA = insertelement <16 x i16> %hadd9, i16 %aCD, i32 10\n %haddB = insertelement <16 x i16> %haddA, i16 %aEF, i32 11\n %haddC = insertelement <16 x i16> %haddB, i16 %b89, i32 12\n %haddD = insertelement <16 x i16> %haddC, i16 %bAB, i32 13\n %haddE = insertelement <16 x i16> %haddD, i16 %bCD, i32 14\n %haddF = insertelement <16 x i16> %haddE, i16 %bEF, i32 15\n %result = shufflevector <16 x i16> %haddF, <16 x i16> %a, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 poison, i32 5, i32 6, i32 7, i32 8, i32 9, i32 poison, i32 11, i32 12, i32 13, i32 14, i32 15>\n ret <16 x i16> %result\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "add_v16i16_0123456789ABCDEF",
"test_body": "define <16 x i16> @add_v16i16_0123456789ABCDEF(<16 x i16> %a, <16 x i16> %b) {\n %a0 = extractelement <16 x i16> %a, i32 0\n %a1 = extractelement <16 x i16> %a, i32 1\n %a2 = extractelement <16 x i16> %a, i32 2\n %a3 = extractelement <16 x i16> %a, i32 3\n %a4 = extractelement <16 x i16> %a, i32 4\n %a5 = extractelement <16 x i16> %a, i32 5\n %a6 = extractelement <16 x i16> %a, i32 6\n %a7 = extractelement <16 x i16> %a, i32 7\n %a8 = extractelement <16 x i16> %a, i32 8\n %a9 = extractelement <16 x i16> %a, i32 9\n %aA = extractelement <16 x i16> %a, i32 10\n %aB = extractelement <16 x i16> %a, i32 11\n %aC = extractelement <16 x i16> %a, i32 12\n %aD = extractelement <16 x i16> %a, i32 13\n %aE = extractelement <16 x i16> %a, i32 14\n %aF = extractelement <16 x i16> %a, i32 15\n %a01 = add i16 %a0, %a1\n %a23 = add i16 %a2, %a3\n %a45 = add i16 %a4, %a5\n %a67 = add i16 %a6, %a7\n %a89 = add i16 %a8, %a9\n %aAB = add i16 %aA, %aB\n %aCD = add i16 %aC, %aD\n %aEF = add i16 %aE, %aF\n %b0 = extractelement <16 x i16> %b, i32 0\n %b1 = extractelement <16 x i16> %b, i32 1\n %b2 = extractelement <16 x i16> %b, i32 2\n %b3 = extractelement <16 x i16> %b, i32 3\n %b4 = extractelement <16 x i16> %b, i32 4\n %b5 = extractelement <16 x i16> %b, i32 5\n %b6 = extractelement <16 x i16> %b, i32 6\n %b7 = extractelement <16 x i16> %b, i32 7\n %b8 = extractelement <16 x i16> %b, i32 8\n %b9 = extractelement <16 x i16> %b, i32 9\n %bA = extractelement <16 x i16> %b, i32 10\n %bB = extractelement <16 x i16> %b, i32 11\n %bC = extractelement <16 x i16> %b, i32 12\n %bD = extractelement <16 x i16> %b, i32 13\n %bE = extractelement <16 x i16> %b, i32 14\n %bF = extractelement <16 x i16> %b, i32 15\n %b01 = add i16 %b0, %b1\n %b23 = add i16 %b2, %b3\n %b45 = add i16 %b4, %b5\n %b67 = add i16 %b6, %b7\n %b89 = add i16 %b8, %b9\n %bAB = add i16 %bA, %bB\n %bCD = add i16 %bC, %bD\n %bEF = add i16 %bE, %bF\n %hadd0 = insertelement <16 x i16> poison, i16 %a01, i32 0\n %hadd1 = insertelement <16 x i16> %hadd0, i16 %a23, i32 1\n %hadd2 = insertelement <16 x i16> %hadd1, i16 %a45, i32 2\n %hadd3 = insertelement <16 x i16> %hadd2, i16 %a67, i32 3\n %hadd4 = insertelement <16 x i16> %hadd3, i16 %b01, i32 4\n %hadd5 = insertelement <16 x i16> %hadd4, i16 %b23, i32 5\n %hadd6 = insertelement <16 x i16> %hadd5, i16 %b45, i32 6\n %hadd7 = insertelement <16 x i16> %hadd6, i16 %b67, i32 7\n %hadd8 = insertelement <16 x i16> %hadd7, i16 %a89, i32 8\n %hadd9 = insertelement <16 x i16> %hadd8, i16 %aAB, i32 9\n %haddA = insertelement <16 x i16> %hadd9, i16 %aCD, i32 10\n %haddB = insertelement <16 x i16> %haddA, i16 %aEF, i32 11\n %haddC = insertelement <16 x i16> %haddB, i16 %b89, i32 12\n %haddD = insertelement <16 x i16> %haddC, i16 %bAB, i32 13\n %haddE = insertelement <16 x i16> %haddD, i16 %bCD, i32 14\n %haddF = insertelement <16 x i16> %haddE, i16 %bEF, i32 15\n %result = shufflevector <16 x i16> %haddF, <16 x i16> %a, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>\n ret <16 x i16> %result\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/PhaseOrdering/X86/hsub.ll",
"commands": [
"opt < %s -O3 -S -mtriple=x86_64-- -mcpu=x86-64",
"opt < %s -O3 -S -mtriple=x86_64-- -mcpu=x86-64-v2",
"opt < %s -O3 -S -mtriple=x86_64-- -mcpu=x86-64-v3",
"opt < %s -O3 -S -mtriple=x86_64-- -mcpu=x86-64-v4",
"opt < %s -passes=\"default<O3>\" -S -mtriple=x86_64-- -mcpu=x86-64",
"opt < %s -passes=\"default<O3>\" -S -mtriple=x86_64-- -mcpu=x86-64-v2",
"opt < %s -passes=\"default<O3>\" -S -mtriple=x86_64-- -mcpu=x86-64-v3",
"opt < %s -passes=\"default<O3>\" -S -mtriple=x86_64-- -mcpu=x86-64-v4"
],
"tests": [
{
"test_name": "sub_v16i16_0123456789ABCDEF",
"test_body": "define <16 x i16> @sub_v16i16_0123456789ABCDEF(<16 x i16> %a, <16 x i16> %b) {\n %a0 = extractelement <16 x i16> %a, i32 0\n %a1 = extractelement <16 x i16> %a, i32 1\n %a2 = extractelement <16 x i16> %a, i32 2\n %a3 = extractelement <16 x i16> %a, i32 3\n %a4 = extractelement <16 x i16> %a, i32 4\n %a5 = extractelement <16 x i16> %a, i32 5\n %a6 = extractelement <16 x i16> %a, i32 6\n %a7 = extractelement <16 x i16> %a, i32 7\n %a8 = extractelement <16 x i16> %a, i32 8\n %a9 = extractelement <16 x i16> %a, i32 9\n %aA = extractelement <16 x i16> %a, i32 10\n %aB = extractelement <16 x i16> %a, i32 11\n %aC = extractelement <16 x i16> %a, i32 12\n %aD = extractelement <16 x i16> %a, i32 13\n %aE = extractelement <16 x i16> %a, i32 14\n %aF = extractelement <16 x i16> %a, i32 15\n %a01 = sub i16 %a0, %a1\n %a23 = sub i16 %a2, %a3\n %a45 = sub i16 %a4, %a5\n %a67 = sub i16 %a6, %a7\n %a89 = sub i16 %a8, %a9\n %aAB = sub i16 %aA, %aB\n %aCD = sub i16 %aC, %aD\n %aEF = sub i16 %aE, %aF\n %b0 = extractelement <16 x i16> %b, i32 0\n %b1 = extractelement <16 x i16> %b, i32 1\n %b2 = extractelement <16 x i16> %b, i32 2\n %b3 = extractelement <16 x i16> %b, i32 3\n %b4 = extractelement <16 x i16> %b, i32 4\n %b5 = extractelement <16 x i16> %b, i32 5\n %b6 = extractelement <16 x i16> %b, i32 6\n %b7 = extractelement <16 x i16> %b, i32 7\n %b8 = extractelement <16 x i16> %b, i32 8\n %b9 = extractelement <16 x i16> %b, i32 9\n %bA = extractelement <16 x i16> %b, i32 10\n %bB = extractelement <16 x i16> %b, i32 11\n %bC = extractelement <16 x i16> %b, i32 12\n %bD = extractelement <16 x i16> %b, i32 13\n %bE = extractelement <16 x i16> %b, i32 14\n %bF = extractelement <16 x i16> %b, i32 15\n %b01 = sub i16 %b0, %b1\n %b23 = sub i16 %b2, %b3\n %b45 = sub i16 %b4, %b5\n %b67 = sub i16 %b6, %b7\n %b89 = sub i16 %b8, %b9\n %bAB = sub i16 %bA, %bB\n %bCD = sub i16 %bC, %bD\n %bEF = sub i16 %bE, %bF\n %hsub0 = insertelement <16 x i16> poison, i16 %a01, i32 0\n %hsub1 = insertelement <16 x i16> %hsub0, i16 %a23, i32 1\n %hsub2 = insertelement <16 x i16> %hsub1, i16 %a45, i32 2\n %hsub3 = insertelement <16 x i16> %hsub2, i16 %a67, i32 3\n %hsub4 = insertelement <16 x i16> %hsub3, i16 %b01, i32 4\n %hsub5 = insertelement <16 x i16> %hsub4, i16 %b23, i32 5\n %hsub6 = insertelement <16 x i16> %hsub5, i16 %b45, i32 6\n %hsub7 = insertelement <16 x i16> %hsub6, i16 %b67, i32 7\n %hsub8 = insertelement <16 x i16> %hsub7, i16 %a89, i32 8\n %hsub9 = insertelement <16 x i16> %hsub8, i16 %aAB, i32 9\n %hsubA = insertelement <16 x i16> %hsub9, i16 %aCD, i32 10\n %hsubB = insertelement <16 x i16> %hsubA, i16 %aEF, i32 11\n %hsubC = insertelement <16 x i16> %hsubB, i16 %b89, i32 12\n %hsubD = insertelement <16 x i16> %hsubC, i16 %bAB, i32 13\n %hsubE = insertelement <16 x i16> %hsubD, i16 %bCD, i32 14\n %hsubF = insertelement <16 x i16> %hsubE, i16 %bEF, i32 15\n %result = shufflevector <16 x i16> %hsubF, <16 x i16> %a, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>\n ret <16 x i16> %result\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "sub_v16i16_0123u56789uBCDEF",
"test_body": "define <16 x i16> @sub_v16i16_0123u56789uBCDEF(<16 x i16> %a, <16 x i16> %b) {\n %a0 = extractelement <16 x i16> %a, i32 0\n %a1 = extractelement <16 x i16> %a, i32 1\n %a2 = extractelement <16 x i16> %a, i32 2\n %a3 = extractelement <16 x i16> %a, i32 3\n %a4 = extractelement <16 x i16> %a, i32 4\n %a5 = extractelement <16 x i16> %a, i32 5\n %a6 = extractelement <16 x i16> %a, i32 6\n %a7 = extractelement <16 x i16> %a, i32 7\n %a8 = extractelement <16 x i16> %a, i32 8\n %a9 = extractelement <16 x i16> %a, i32 9\n %aA = extractelement <16 x i16> %a, i32 10\n %aB = extractelement <16 x i16> %a, i32 11\n %aC = extractelement <16 x i16> %a, i32 12\n %aD = extractelement <16 x i16> %a, i32 13\n %aE = extractelement <16 x i16> %a, i32 14\n %aF = extractelement <16 x i16> %a, i32 15\n %a01 = sub i16 %a0, %a1\n %a23 = sub i16 %a2, %a3\n %a45 = sub i16 %a4, %a5\n %a67 = sub i16 %a6, %a7\n %a89 = sub i16 %a8, %a9\n %aAB = sub i16 %aA, %aB\n %aCD = sub i16 %aC, %aD\n %aEF = sub i16 %aE, %aF\n %b0 = extractelement <16 x i16> %b, i32 0\n %b1 = extractelement <16 x i16> %b, i32 1\n %b2 = extractelement <16 x i16> %b, i32 2\n %b3 = extractelement <16 x i16> %b, i32 3\n %b4 = extractelement <16 x i16> %b, i32 4\n %b5 = extractelement <16 x i16> %b, i32 5\n %b6 = extractelement <16 x i16> %b, i32 6\n %b7 = extractelement <16 x i16> %b, i32 7\n %b8 = extractelement <16 x i16> %b, i32 8\n %b9 = extractelement <16 x i16> %b, i32 9\n %bA = extractelement <16 x i16> %b, i32 10\n %bB = extractelement <16 x i16> %b, i32 11\n %bC = extractelement <16 x i16> %b, i32 12\n %bD = extractelement <16 x i16> %b, i32 13\n %bE = extractelement <16 x i16> %b, i32 14\n %bF = extractelement <16 x i16> %b, i32 15\n %b01 = sub i16 %b0, %b1\n %b23 = sub i16 %b2, %b3\n %b45 = sub i16 %b4, %b5\n %b67 = sub i16 %b6, %b7\n %b89 = sub i16 %b8, %b9\n %bAB = sub i16 %bA, %bB\n %bCD = sub i16 %bC, %bD\n %bEF = sub i16 %bE, %bF\n %hsub0 = insertelement <16 x i16> poison, i16 %a01, i32 0\n %hsub1 = insertelement <16 x i16> %hsub0, i16 %a23, i32 1\n %hsub2 = insertelement <16 x i16> %hsub1, i16 %a45, i32 2\n %hsub3 = insertelement <16 x i16> %hsub2, i16 %a67, i32 3\n %hsub4 = insertelement <16 x i16> %hsub3, i16 %b01, i32 4\n %hsub5 = insertelement <16 x i16> %hsub4, i16 %b23, i32 5\n %hsub6 = insertelement <16 x i16> %hsub5, i16 %b45, i32 6\n %hsub7 = insertelement <16 x i16> %hsub6, i16 %b67, i32 7\n %hsub8 = insertelement <16 x i16> %hsub7, i16 %a89, i32 8\n %hsub9 = insertelement <16 x i16> %hsub8, i16 %aAB, i32 9\n %hsubA = insertelement <16 x i16> %hsub9, i16 %aCD, i32 10\n %hsubB = insertelement <16 x i16> %hsubA, i16 %aEF, i32 11\n %hsubC = insertelement <16 x i16> %hsubB, i16 %b89, i32 12\n %hsubD = insertelement <16 x i16> %hsubC, i16 %bAB, i32 13\n %hsubE = insertelement <16 x i16> %hsubD, i16 %bCD, i32 14\n %hsubF = insertelement <16 x i16> %hsubE, i16 %bEF, i32 15\n %result = shufflevector <16 x i16> %hsubF, <16 x i16> %a, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 poison, i32 5, i32 6, i32 7, i32 8, i32 9, i32 poison, i32 11, i32 12, i32 13, i32 14, i32 15>\n ret <16 x i16> %result\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/SLPVectorizer/SystemZ/non-power-2-subvector-extract.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=s390x-ibm-linux -mcpu=z13 -slp-max-reg-size=256 -slp-vectorize-hor-store -slp-vectorize-non-power-of-2 < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n@c = external global [1 x [10 x i32]]\n@j.0 = external global i32\n\ndefine void @p() {\n;\nentry:\n %arrayidx12.promoted.5.i = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 200), align 4\n %conv14.5.i = xor i32 %arrayidx12.promoted.5.i, 1\n store i32 %conv14.5.i, ptr getelementptr inbounds nuw (i8, ptr @c, i64 200), align 4\n %arrayidx12.promoted.5.i.1 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 204), align 4\n %conv14.5.i.1 = xor i32 %arrayidx12.promoted.5.i.1, 1\n store i32 %conv14.5.i.1, ptr getelementptr inbounds nuw (i8, ptr @c, i64 204), align 4\n %arrayidx12.promoted.5.i.2 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 208), align 4\n %conv14.5.i.2 = xor i32 %arrayidx12.promoted.5.i.2, 1\n store i32 %conv14.5.i.2, ptr getelementptr inbounds nuw (i8, ptr @c, i64 208), align 4\n %arrayidx12.promoted.1.i.3 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 52), align 4\n %conv14.1.i.3 = xor i32 %arrayidx12.promoted.1.i.3, 1\n store i32 %conv14.1.i.3, ptr getelementptr inbounds nuw (i8, ptr @c, i64 52), align 4\n %arrayidx12.promoted.5.i.3 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 212), align 4\n %conv14.5.i.3 = xor i32 %arrayidx12.promoted.5.i.3, 1\n store i32 %conv14.5.i.3, ptr getelementptr inbounds nuw (i8, ptr @c, i64 212), align 4\n %arrayidx12.promoted.6.i.3 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 252), align 4\n %conv14.6.i.3 = xor i32 %arrayidx12.promoted.6.i.3, 1\n %or.1.5.i.3 = or i32 %arrayidx12.promoted.1.i.3, %arrayidx12.promoted.5.i.3\n store i32 %conv14.6.i.3, ptr getelementptr inbounds nuw (i8, ptr @c, i64 252), align 4\n store i32 %or.1.5.i.3, ptr @j.0, align 4\n %arrayidx12.promoted.1.i.4 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 56), align 4\n %conv14.1.i.4 = xor i32 %arrayidx12.promoted.1.i.4, 1\n store i32 %conv14.1.i.4, ptr getelementptr inbounds nuw (i8, ptr @c, i64 56), align 4\n %arrayidx12.promoted.5.i.4 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 216), align 4\n %conv14.5.i.4 = xor i32 %arrayidx12.promoted.5.i.4, 1\n store i32 %conv14.5.i.4, ptr getelementptr inbounds nuw (i8, ptr @c, i64 216), align 4\n %arrayidx12.promoted.6.i.4 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 256), align 4\n %conv14.6.i.4 = xor i32 %arrayidx12.promoted.6.i.4, 1\n store i32 %conv14.6.i.4, ptr getelementptr inbounds nuw (i8, ptr @c, i64 256), align 4\n %arrayidx12.promoted.1.i.5 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 60), align 4\n %conv14.1.i.5 = xor i32 %arrayidx12.promoted.1.i.5, 1\n store i32 %conv14.1.i.5, ptr getelementptr inbounds nuw (i8, ptr @c, i64 60), align 4\n %arrayidx12.promoted.5.i.5 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 220), align 4\n %conv14.5.i.5 = xor i32 %arrayidx12.promoted.5.i.5, 1\n store i32 %conv14.5.i.5, ptr getelementptr inbounds nuw (i8, ptr @c, i64 220), align 4\n %arrayidx12.promoted.6.i.5 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 260), align 4\n %conv14.6.i.5 = xor i32 %arrayidx12.promoted.6.i.5, 1\n %0 = or i32 %arrayidx12.promoted.6.i.4, %arrayidx12.promoted.1.i.5\n %or.1.5.i.5 = or i32 %0, %arrayidx12.promoted.5.i.5\n %or.1.6.i.5 = or i32 %or.1.5.i.5, %arrayidx12.promoted.6.i.5\n store i32 %conv14.6.i.5, ptr getelementptr inbounds nuw (i8, ptr @c, i64 260), align 4\n store i32 %or.1.6.i.5, ptr @j.0, align 4\n %arrayidx12.promoted.1.i.6 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 64), align 4\n %conv14.1.i.6 = xor i32 %arrayidx12.promoted.1.i.6, 1\n store i32 %conv14.1.i.6, ptr getelementptr inbounds nuw (i8, ptr @c, i64 64), align 4\n %arrayidx12.promoted.5.i.6 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 224), align 4\n %conv14.5.i.6 = xor i32 %arrayidx12.promoted.5.i.6, 1\n store i32 %conv14.5.i.6, ptr getelementptr inbounds nuw (i8, ptr @c, i64 224), align 4\n %arrayidx12.promoted.6.i.6 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 264), align 4\n %conv14.6.i.6 = xor i32 %arrayidx12.promoted.6.i.6, 1\n store i32 %conv14.6.i.6, ptr getelementptr inbounds nuw (i8, ptr @c, i64 264), align 4\n ret void\n}",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "SLP Vectorizer Options trigger Assertion in cost computation on `s390x`",
"body": "While running experiments with `csmith`, i ran into the following example (already reduced with `cvise`):\n```C\nstatic int c[][10];\nshort d;\nlong *e;\nlong f;\nint g, k;\nchar h, i;\nstatic int j[3];\nvoid l();\nstatic int *m() {\n short *n = &d;\n d = 0;\n for (; d <= 2;)\n if (*n)\n ;\n else\n return j;\n return &g;\n}\nvoid p() { l(); }\nvoid l() {\n int *q;\n h = 0;\n for (; h <= 6; h++) {\n int **r = &q;\n *e = 4073709551615;\n *r = m();\n k = 0;\n for (; k <= 6; k++) {\n i = 2;\n for (; i <= 6; i++)\n **r |= c[k][h] ^= f;\n }\n }\n}\n```\n When compiling this with the options\n```\n -O3 \\\n -S \\\n -w \\\n -c \\\n -o a.out \\\n --target=s390x-ibm-linux \\\n -march=z13 \\\n -mllvm -slp-max-reg-size=256 \\\n -mllvm -slp-vectorize-hor-store \\\n -mllvm -slp-vectorize-non-power-of-2 \\\n -mllvm -enable-tbaa=false \\\n```\nThe assertion `(Idx + EltsPerVector) <= BaseVF && \"SK_ExtractSubvector index out of range\"` fails in `llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator::computeExtractCost`. This does not seem to be an issue on X86.\n\n[repro.tar.gz](https://github.com/user-attachments/files/20672338/repro.tar.gz)",
"author": "dominik-steenken",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
Cannot find a good commit
| null |
107569
|
https://github.com/llvm/llvm-project/issues/107569
|
crash
|
b0428870dae980af84e50dfa3ee6ed2165998678
| 2024-09-06T11:56:19
|
[
"llvm/test/Transforms/DeadArgElim"
] |
{
"fix_commit": "5978bb2936d9a71d8e6891c640a36be760b569d3",
"components": [
"DeadArgumentElimination"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": [
[
106,
118
],
[
131,
142
]
],
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": [
[
87,
97
],
[
280,
286
],
[
496,
502
],
[
504,
510
],
[
522,
550
],
[
555,
562
],
[
564,
577
],
[
610,
620
],
[
628,
646
],
[
680,
693
],
[
696,
701
],
[
710,
716
],
[
734,
741
],
[
807,
813
],
[
1109,
1134
],
[
1149,
1156
]
],
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": [
"DeadArgumentEliminationPass::isLive",
"DeadArgumentEliminationPass::markLive",
"DeadArgumentEliminationPass::markValue",
"DeadArgumentEliminationPass::propagateVirtMustcallLiveness",
"DeadArgumentEliminationPass::removeDeadArgumentsFromCallers",
"DeadArgumentEliminationPass::removeDeadStuffFromFunction",
"DeadArgumentEliminationPass::run",
"DeadArgumentEliminationPass::surveyFunction",
"isMustTailCalleeAnalyzable"
],
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 5978bb2936d9a71d8e6891c640a36be760b569d3
Author: u4f3 <ricoafoat@gmail.com>
Date: Thu Apr 10 22:08:09 2025 +0800
[DeadArgElim] fix verifier failure when changing musttail's function signature (#127366)
This commit is for #107569 and #126817.
Stop changing musttail's caller and callee's function signature when
calling convention is not swifttailcc nor tailcc. Verifier makes sure
musttail's caller and callee shares exactly the same signature, see
commit 9ff2eb1 and #54964.
Otherwise just make sure the return type is the same and then process
musttail like usual calls.
close #107569, #126817
diff --git a/llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h b/llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h
index 63e1ad043d49..efa9c4bdc496 100644
--- a/llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h
+++ b/llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h
@@ -106,13 +106,16 @@ public:
UseMap Uses;
using LiveSet = std::set<RetOrArg>;
- using LiveFuncSet = std::set<const Function *>;
+ using FuncSet = std::set<const Function *>;
/// This set contains all values that have been determined to be live.
LiveSet LiveValues;
- /// This set contains all values that are cannot be changed in any way.
- LiveFuncSet LiveFunctions;
+ /// This set contains all functions that cannot be changed in any way.
+ FuncSet FrozenFunctions;
+
+ /// This set contains all functions that cannot change return type;
+ FuncSet FrozenRetTyFunctions;
using UseVector = SmallVector<RetOrArg, 5>;
@@ -131,12 +134,13 @@ private:
void markValue(const RetOrArg &RA, Liveness L,
const UseVector &MaybeLiveUses);
void markLive(const RetOrArg &RA);
- void markLive(const Function &F);
+ void markFrozen(const Function &F);
+ void markRetTyFrozen(const Function &F);
+ bool markFnOrRetTyFrozenOnMusttail(const Function &F);
void propagateLiveness(const RetOrArg &RA);
bool removeDeadStuffFromFunction(Function *F);
bool deleteDeadVarargs(Function &F);
bool removeDeadArgumentsFromCallers(Function &F);
- void propagateVirtMustcallLiveness(const Module &M);
};
} // end namespace llvm
diff --git a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
index ed93b4491c50..2e2687a5ff6e 100644
--- a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -87,11 +87,6 @@ public:
virtual bool shouldHackArguments() const { return false; }
};
-bool isMustTailCalleeAnalyzable(const CallBase &CB) {
- assert(CB.isMustTailCall());
- return CB.getCalledFunction() && !CB.getCalledFunction()->isDeclaration();
-}
-
} // end anonymous namespace
char DAE::ID = 0;
@@ -280,7 +275,7 @@ bool DeadArgumentEliminationPass::removeDeadArgumentsFromCallers(Function &F) {
// they are fully alive (e.g., called indirectly) and except for the fragile
// (variadic) ones. In these cases, we may still be able to improve their
// statically known call sites.
- if ((F.hasLocalLinkage() && !LiveFunctions.count(&F)) &&
+ if ((F.hasLocalLinkage() && !FrozenFunctions.count(&F)) &&
!F.getFunctionType()->isVarArg())
return false;
@@ -496,7 +491,7 @@ void DeadArgumentEliminationPass::surveyFunction(const Function &F) {
// particular register and memory layout.
if (F.getAttributes().hasAttrSomewhere(Attribute::InAlloca) ||
F.getAttributes().hasAttrSomewhere(Attribute::Preallocated)) {
- markLive(F);
+ markFrozen(F);
return;
}
@@ -504,7 +499,7 @@ void DeadArgumentEliminationPass::surveyFunction(const Function &F) {
// otherwise rely on the frame layout in a way that this analysis will not
// see.
if (F.hasFnAttribute(Attribute::Naked)) {
- markLive(F);
+ markFrozen(F);
return;
}
@@ -522,29 +517,17 @@ void DeadArgumentEliminationPass::surveyFunction(const Function &F) {
// MaybeLive. Initialized to a list of RetCount empty lists.
RetUses MaybeLiveRetUses(RetCount);
- bool HasMustTailCalls = false;
for (const BasicBlock &BB : F) {
- // If we have any returns of `musttail` results - the signature can't
- // change
- if (const auto *TC = BB.getTerminatingMustTailCall()) {
- HasMustTailCalls = true;
- // In addition, if the called function is not locally defined (or unknown,
- // if this is an indirect call), we can't change the callsite and thus
- // can't change this function's signature either.
- if (!isMustTailCalleeAnalyzable(*TC)) {
- markLive(F);
+ if (BB.getTerminatingMustTailCall()) {
+ LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - " << F.getName()
+ << " has musttail calls\n");
+ if (markFnOrRetTyFrozenOnMusttail(F))
return;
- }
}
}
- if (HasMustTailCalls) {
- LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - " << F.getName()
- << " has musttail calls\n");
- }
-
if (!F.hasLocalLinkage() && (!ShouldHackArguments || F.isIntrinsic())) {
- markLive(F);
+ markFrozen(F);
return;
}
@@ -555,8 +538,6 @@ void DeadArgumentEliminationPass::surveyFunction(const Function &F) {
// of them turn out to be live.
unsigned NumLiveRetVals = 0;
- bool HasMustTailCallers = false;
-
// Loop all uses of the function.
for (const Use &U : F.uses()) {
// If the function is PASSED IN as an argument, its address has been
@@ -564,14 +545,16 @@ void DeadArgumentEliminationPass::surveyFunction(const Function &F) {
const auto *CB = dyn_cast<CallBase>(U.getUser());
if (!CB || !CB->isCallee(&U) ||
CB->getFunctionType() != F.getFunctionType()) {
- markLive(F);
+ markFrozen(F);
return;
}
- // The number of arguments for `musttail` call must match the number of
- // arguments of the caller
- if (CB->isMustTailCall())
- HasMustTailCallers = true;
+ if (CB->isMustTailCall()) {
+ LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - " << F.getName()
+ << " has musttail callers\n");
+ if (markFnOrRetTyFrozenOnMusttail(F))
+ return;
+ }
// If we end up here, we are looking at a direct call to our function.
@@ -610,11 +593,6 @@ void DeadArgumentEliminationPass::surveyFunction(const Function &F) {
}
}
- if (HasMustTailCallers) {
- LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - " << F.getName()
- << " has musttail callers\n");
- }
-
// Now we've inspected all callers, record the liveness of our return values.
for (unsigned Ri = 0; Ri != RetCount; ++Ri)
markValue(createRet(&F, Ri), RetValLiveness[Ri], MaybeLiveRetUses[Ri]);
@@ -628,19 +606,12 @@ void DeadArgumentEliminationPass::surveyFunction(const Function &F) {
for (Function::const_arg_iterator AI = F.arg_begin(), E = F.arg_end();
AI != E; ++AI, ++ArgI) {
Liveness Result;
- if (F.getFunctionType()->isVarArg() || HasMustTailCallers ||
- HasMustTailCalls) {
+ if (F.getFunctionType()->isVarArg()) {
// Variadic functions will already have a va_arg function expanded inside
// them, making them potentially very sensitive to ABI changes resulting
// from removing arguments entirely, so don't. For example AArch64 handles
// register and stack HFAs very differently, and this is reflected in the
// IR which has already been generated.
- //
- // `musttail` calls to this function restrict argument removal attempts.
- // The signature of the caller must match the signature of the function.
- //
- // `musttail` calls in this function prevents us from changing its
- // signature
Result = Live;
} else {
// See what the effect of this use is (recording any uses that cause
@@ -680,14 +651,30 @@ void DeadArgumentEliminationPass::markValue(const RetOrArg &RA, Liveness L,
}
}
+/// Return true if we freeze the whole function.
+/// If the calling convention is not swifttailcc or tailcc, the caller and
+/// callee of musttail must have exactly the same signature. Otherwise we
+/// only needs to guarantee they have the same return type.
+bool DeadArgumentEliminationPass::markFnOrRetTyFrozenOnMusttail(
+ const Function &F) {
+ if (F.getCallingConv() != CallingConv::SwiftTail ||
+ F.getCallingConv() != CallingConv::Tail) {
+ markFrozen(F);
+ return true;
+ } else {
+ markRetTyFrozen(F);
+ return false;
+ }
+}
+
/// Mark the given Function as alive, meaning that it cannot be changed in any
/// way. Additionally, mark any values that are used as this function's
/// parameters or by its return values (according to Uses) live as well.
-void DeadArgumentEliminationPass::markLive(const Function &F) {
- LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - Intrinsically live fn: "
+void DeadArgumentEliminationPass::markFrozen(const Function &F) {
+ LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - frozen fn: "
<< F.getName() << "\n");
- // Mark the function as live.
- LiveFunctions.insert(&F);
+ // Mark the function as frozen.
+ FrozenFunctions.insert(&F);
// Mark all arguments as live.
for (unsigned ArgI = 0, E = F.arg_size(); ArgI != E; ++ArgI)
propagateLiveness(createArg(&F, ArgI));
@@ -696,6 +683,12 @@ void DeadArgumentEliminationPass::markLive(const Function &F) {
propagateLiveness(createRet(&F, Ri));
}
+void DeadArgumentEliminationPass::markRetTyFrozen(const Function &F) {
+ LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - frozen return type fn: "
+ << F.getName() << "\n");
+ FrozenRetTyFunctions.insert(&F);
+}
+
/// Mark the given return value or argument as live. Additionally, mark any
/// values that are used by this value (according to Uses) live as well.
void DeadArgumentEliminationPass::markLive(const RetOrArg &RA) {
@@ -710,7 +703,7 @@ void DeadArgumentEliminationPass::markLive(const RetOrArg &RA) {
}
bool DeadArgumentEliminationPass::isLive(const RetOrArg &RA) {
- return LiveFunctions.count(RA.F) || LiveValues.count(RA);
+ return FrozenFunctions.count(RA.F) || LiveValues.count(RA);
}
/// Given that RA is a live value, propagate it's liveness to any other values
@@ -734,8 +727,8 @@ void DeadArgumentEliminationPass::propagateLiveness(const RetOrArg &RA) {
/// Transform the function and all the callees of the function to not have these
/// arguments and return values.
bool DeadArgumentEliminationPass::removeDeadStuffFromFunction(Function *F) {
- // Don't modify fully live functions
- if (LiveFunctions.count(F))
+ // Don't modify frozen functions
+ if (FrozenFunctions.count(F))
return false;
// Start by computing a new prototype for the function, which is the same as
@@ -807,7 +800,8 @@ bool DeadArgumentEliminationPass::removeDeadStuffFromFunction(Function *F) {
// performance win, so the second option can just be used always for now.
//
// This should be revisited if 'returned' is ever applied more liberally.
- if (RetTy->isVoidTy() || HasLiveReturnedArg) {
+ if (RetTy->isVoidTy() || HasLiveReturnedArg ||
+ FrozenRetTyFunctions.count(F)) {
NRetTy = RetTy;
} else {
// Look at each of the original return values individually.
@@ -1109,26 +1103,6 @@ bool DeadArgumentEliminationPass::removeDeadStuffFromFunction(Function *F) {
return true;
}
-void DeadArgumentEliminationPass::propagateVirtMustcallLiveness(
- const Module &M) {
- // If a function was marked "live", and it has musttail callers, they in turn
- // can't change either.
- LiveFuncSet NewLiveFuncs(LiveFunctions);
- while (!NewLiveFuncs.empty()) {
- LiveFuncSet Temp;
- for (const auto *F : NewLiveFuncs)
- for (const auto *U : F->users())
- if (const auto *CB = dyn_cast<CallBase>(U))
- if (CB->isMustTailCall())
- if (!LiveFunctions.count(CB->getParent()->getParent()))
- Temp.insert(CB->getParent()->getParent());
- NewLiveFuncs.clear();
- NewLiveFuncs.insert(Temp.begin(), Temp.end());
- for (const auto *F : Temp)
- markLive(*F);
- }
-}
-
PreservedAnalyses DeadArgumentEliminationPass::run(Module &M,
ModuleAnalysisManager &) {
bool Changed = false;
@@ -1149,8 +1123,6 @@ PreservedAnalyses DeadArgumentEliminationPass::run(Module &M,
for (auto &F : M)
surveyFunction(F);
- propagateVirtMustcallLiveness(M);
-
// Now, remove all dead arguments and return values from each function in
// turn. We use make_early_inc_range here because functions will probably get
// removed (i.e. replaced by new ones).
|
[
{
"file": "llvm/test/Transforms/DeadArgElim/musttail-caller.ll",
"commands": [
"opt -passes=deadargelim -S < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define hidden void @test(i32 %a, i32 %b) {\n musttail call void @foo(i32 %a, i32 0)\n ret void\n}\n\ndeclare hidden void @foo(i32, i32)\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "foo",
"test_body": "define hidden void @foo(i32 %a, i32 %b) {\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/DeadArgElim/musttail-verifier.ll",
"commands": [
"opt -passes=deadargelim -S < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "; Testcases comes from PR126817 and PR107569\n; See PR54964 and langref for more information about how llvm deal with musttail currently\n\ndefine i64 @A() {\n;\nentry:\n %v2660 = musttail call i64 @B()\n ret i64 %v2660\n}\n\ndefine internal i64 @B() {\n;\nentry:\n ret i64 0\n}\n\ndefine internal i64 @C() {\n;\nentry:\n %v30543 = musttail call i64 @B()\n ret i64 %v30543\n}\n\n%struct.S = type { double }\n\ndefine internal %struct.S @F38() {\n;\n ret %struct.S { double 0.0 }\n}\n\ndefine internal %struct.S @F36() {\n;\n %1 = alloca %struct.S, align 8\n %3 = musttail call %struct.S @F38()\n ret %struct.S %3\n}\n\ndefine double @foo() {\n;\n %3 = call %struct.S @F36()\n %5 = extractvalue %struct.S %3, 0\n ret double %5\n}",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "DeadArgumentElimination creates invalid code with musttail calls returning structs",
"body": "The DeadArgumentElimination pass creates code which fails the IR verifier when run on this input:\r\n\r\n```test.ll\r\n%struct.S = type { i32 }\r\n\r\ndefine internal %struct.S @F38() {\r\n ret %struct.S { i32 0 }\r\n}\r\n\r\ndefine %struct.S @F36() {\r\n %3 = musttail call %struct.S @F38()\r\n ret %struct.S %3\r\n}\r\n```\r\n\r\n```\r\n$ /work/llvm/build/bin/opt test.ll -passes=deadargelim -S\r\ncannot guarantee tail call due to mismatched return types\r\n %1 = musttail call i32 @F38()\r\nLLVM ERROR: Broken module found, compilation aborted!\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: /work/llvm/build/bin/opt test.ll -passes=deadargelim -S\r\n1. Running pass \"verify\" on module \"test.ll\"\r\n #0 0x000055c16a99ca37 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/work/llvm/build/bin/opt+0x4133a37)\r\n #1 0x000055c16a99a57e llvm::sys::RunSignalHandlers() (/work/llvm/build/bin/opt+0x413157e)\r\n #2 0x000055c16a99d27a SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007f38e3a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007f38e3a969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007f38e3a969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007f38e3a969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x00007f38e3a42476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007f38e3a287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x000055c16a9857a3 llvm::report_fatal_error(llvm::Twine const&, bool) (/work/llvm/build/bin/opt+0x411c7a3)\r\n#10 0x000055c16a9855f6 (/work/llvm/build/bin/opt+0x411c5f6)\r\n#11 0x000055c16afe2d4a (/work/llvm/build/bin/opt+0x4779d4a)\r\n#12 0x000055c16bd1b53d llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) NewPMDriver.cpp:0:0\r\n#13 0x000055c16abad88a llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/work/llvm/build/bin/opt+0x434488a)\r\n#14 0x000055c16bd146eb 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) (/work/llvm/build/bin/opt+0x54ab6eb)\r\n#15 0x000055c16a964609 optMain (/work/llvm/build/bin/opt+0x40fb609)\r\n#16 0x00007f38e3a29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#17 0x00007f38e3a29e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#18 0x00007f38e3a29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#19 0x000055c16a95e0a5 _start (/work/llvm/build/bin/opt+0x40f50a5)\r\nfish: Job 1, '/work/llvm/build/bin/opt test.l…' terminated by signal SIGABRT (Abort)\r\n```\r\n\r\nFound using a fuzzer while testing #102896.",
"author": "ostannard",
"labels": [
"ipo",
"crash-on-valid"
],
"comments": [
{
"author": "ostannard",
"body": "Related case with a different assertion message:\r\n```test2.ll\r\n%struct.S = type { double }\r\n\r\ndefine internal %struct.S @F38() {\r\n ret %struct.S { double 0.0 }\r\n}\r\n\r\ndefine internal %struct.S @F36() {\r\n %1 = alloca %struct.S, align 8\r\n %3 = musttail call %struct.S @F38()\r\n ret %struct.S %3\r\n}\r\n\r\ndefine double @foo() {\r\n %3 = call %struct.S @F36()\r\n %5 = extractvalue %struct.S %3, 0\r\n ret double %5\r\n}\r\n```\r\n\r\n```\r\n$ /work/llvm/build/bin/opt test2.ll -passes=deadargelim -S -print-after-all\r\n; *** IR Dump After DeadArgumentEliminationPass on [module] ***\r\n; ModuleID = 'test2.ll'\r\nsource_filename = \"test2.ll\"\r\n\r\n%struct.S = type { double }\r\n\r\ndefine internal double @F38() {\r\n %oldret = extractvalue %struct.S zeroinitializer, 0\r\n ret double %oldret\r\n}\r\n\r\ndefine internal double @F36() {\r\n %1 = alloca %struct.S, align 8\r\n %2 = musttail call double @F38()\r\n %oldret = insertvalue %struct.S poison, double %2, 0\r\n %oldret1 = extractvalue %struct.S %oldret, 0\r\n ret double %oldret1\r\n}\r\n\r\ndefine double @foo() {\r\n %1 = call double @F36()\r\n %oldret = insertvalue %struct.S poison, double %1, 0\r\n %2 = extractvalue %struct.S %oldret, 0\r\n ret double %2\r\n}\r\nmusttail call must precede a ret with an optional bitcast\r\n %2 = musttail call double @F38()\r\nLLVM ERROR: Broken module found, compilation aborted!\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: /work/llvm/build/bin/opt test2.ll -passes=deadargelim -S -print-after-all\r\n1. Running pass \"verify\" on module \"test2.ll\"\r\n #0 0x000055c5f980ca37 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/work/llvm/build/bin/opt+0x4133a37)\r\n #1 0x000055c5f980a57e llvm::sys::RunSignalHandlers() (/work/llvm/build/bin/opt+0x413157e)\r\n #2 0x000055c5f980d27a SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007faf4da42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007faf4da969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007faf4da969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007faf4da969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x00007faf4da42476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007faf4da287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x000055c5f97f57a3 llvm::report_fatal_error(llvm::Twine const&, bool) (/work/llvm/build/bin/opt+0x411c7a3)\r\n#10 0x000055c5f97f55f6 (/work/llvm/build/bin/opt+0x411c5f6)\r\n#11 0x000055c5f9e52d4a (/work/llvm/build/bin/opt+0x4779d4a)\r\n#12 0x000055c5fab8b53d llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) NewPMDriver.cpp:0:0\r\n#13 0x000055c5f9a1d88a llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/work/llvm/build/bin/opt+0x434488a)\r\n#14 0x000055c5fab846eb 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) (/work/llvm/build/bin/opt+0x54ab6eb)\r\n#15 0x000055c5f97d4609 optMain (/work/llvm/build/bin/opt+0x40fb609)\r\n#16 0x00007faf4da29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#17 0x00007faf4da29e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#18 0x00007faf4da29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#19 0x000055c5f97ce0a5 _start (/work/llvm/build/bin/opt+0x40f50a5)\r\nfish: Job 1, '/work/llvm/build/bin/opt test2.…' terminated by signal SIGABRT (Abort)\r\n```"
},
{
"author": "ParkHanbum",
"body": "we have the test for second case at musttail-invalid.ll\r\n```declare i32 @not_tail_pos_callee()\r\ndefine i32 @not_tail_pos() {\r\n; CHECK: musttail call must precede a ret with an optional bitcast\r\n %v = musttail call i32 @not_tail_pos_callee()\r\n %w = add i32 %v, 1\r\n ret i32 %w\r\n}\r\n```\r\n\r\nbut first case is not. maybe we need to add this into testcase.\r\n\r\nfirst case \r\n```void Verifier::verifyMustTailCall(CallInst &CI) {\r\n Check(!CI.isInlineAsm(), \"cannot use musttail call with inline asm\", &CI);\r\n\r\n Function *F = CI.getParent()->getParent();\r\n FunctionType *CallerTy = F->getFunctionType();\r\n FunctionType *CalleeTy = CI.getFunctionType();\r\n Check(CallerTy->isVarArg() == CalleeTy->isVarArg(),\r\n \"cannot guarantee tail call due to mismatched varargs\", &CI);\r\n Check(isTypeCongruent(CallerTy->getReturnType(), CalleeTy->getReturnType()),\r\n \"cannot guarantee tail call due to mismatched return types\", F, CallerTy->getReturnType(), &CI, CalleeTy->getReturnType());\r\n```\r\n\r\nCallInst: %1 = musttail call i32 @F38()\r\nReturn type of Caller : %struct.S = type { i32 }\r\nReturn type of Callee: i32\r\n\r\nThis is weird. \r\nI couldn't understand why `%struct.S = type { i32 }` is changed to `i32` at `%3 = musttail call %struct.S @F38()`\r\n\r\nbut after change it to `i32` then it works.\r\n```\r\n%struct.S = type { i32 }\r\n\r\ndefine internal %struct.S @F38() {\r\n ret %struct.S { i32 0 }\r\n}\r\n\r\ndefine i32 @F36() {\r\n %3 = musttail call i32 @F38()\r\n ret i32 %3\r\n}\r\n```\r\n```\r\n% bin/opt --passes=deadargelim test.ll -S \r\n; ModuleID = 'test.ll'\r\nsource_filename = \"test.ll\"\r\n\r\n%struct.S = type { i32 }\r\n\r\ndefine internal %struct.S @F38() {\r\n ret %struct.S zeroinitializer\r\n}\r\n\r\ndefine i32 @F36() {\r\n %1 = musttail call i32 @F38()\r\n ret i32 %1\r\n}\r\n\r\n```\r\n\r\nis this normal?"
},
{
"author": "ParkHanbum",
"body": "I found why it causes, maybe.\r\n```\r\nsource_filename = \"test.ll\"\r\n\r\n%struct.S = type { i32 }\r\n\r\ndefine internal i32 @F38() {\r\n %oldret = extractvalue %struct.S zeroinitializer, 0\r\n ret i32 %oldret\r\n}\r\n\r\ndefine %struct.S @F36() {\r\n %1 = musttail call i32 @F38()\r\n %oldret = insertvalue %struct.S poison, i32 %1, 0\r\n ret %struct.S %oldret\r\n}\r\n\r\n```\r\n\r\n"
},
{
"author": "ParkHanbum",
"body": "we create new return type in here\r\n```\r\n// Look at each of the original return values individually.\r\n for (unsigned Ri = 0; Ri != RetCount; ++Ri) {\r\n RetOrArg Ret = createRet(F, Ri);\r\n if (LiveValues.erase(Ret)) {\r\n RetTypes.push_back(getRetComponentType(F, Ri));\r\n NewRetIdxs[Ri] = RetTypes.size() - 1;\r\n } else {\r\n ++NumRetValsEliminated;\r\n LLVM_DEBUG(\r\n dbgs() << \"DeadArgumentEliminationPass - Removing return value \"\r\n << Ri << \" from \" << F->getName() << \"\\n\");\r\n }\r\n \r\n```\r\n\r\nI tested disabling the code that creates the new return type to see if it would make a quick improvement\r\n```\r\nNRetTy = RetTy;\r\n```\r\n\r\nit seems to work\r\n```\r\n; ModuleID = 'test.ll'\r\nsource_filename = \"test.ll\"\r\n\r\n%struct.S = type { i32 }\r\n\r\ndefine internal %struct.S @F38() {\r\n ret %struct.S zeroinitializer\r\n}\r\n\r\ndefine %struct.S @F36() {\r\n %1 = musttail call %struct.S @F38()\r\n ret %struct.S %1\r\n}\r\n\r\n```\r\n\r\nIf this is a defect,\r\n1. do not change return type if it conflict with caller's return type when CB was musttail call.\r\n2. if caller's return type is conflict with new return type then change all of uses type.\r\n\r\nwe can fix it by choosing one of above. IMO\r\nhow do you think?\r\n\r\nplease let me know this issue need to fix or not~\r\n\r\n@dtcxzyw Can you please review this issue?\r\n"
},
{
"author": "dtcxzyw",
"body": "cc @nikic @efriedma-quic "
},
{
"author": "efriedma-quic",
"body": "I'm not sure why we're trying to run DAE on functions where we can't change the signature; why doesn't the current check for musttail callers handle this?"
},
{
"author": "ParkHanbum",
"body": "@efriedma-quic Don't think it needs to be fix?\r\n"
},
{
"author": "efriedma-quic",
"body": "Not sure what you're saying. I'm asking about the structure of the existing code. There are already checks for musttail calls in DeadArgumentElimination, which at first glance should exclude transforming cases like this. Can those checks be extended to also exclude this case?"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
|
Cannot find a good commit
| null |
118725
|
https://github.com/llvm/llvm-project/issues/118725
|
crash
|
e3352904309a539eddcf3ddd9fb11ca2aef29d65
| 2024-12-05T01:14:53
|
[
"llvm/test/Transforms/GlobalOpt"
] |
{
"fix_commit": "5013c81b781eb95af8e429956d63c8f9c16a4647",
"components": [
"Evaluator"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": [
[
125,
133
]
],
"llvm/lib/Transforms/Utils/Evaluator.cpp": [
[
253,
292
],
[
520,
528
],
[
544,
553
]
],
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": [
"setVal"
],
"llvm/lib/Transforms/Utils/Evaluator.cpp": [
"Evaluator::EvaluateBlock",
"Evaluator::castCallResultIfNeeded",
"Evaluator::getFormalParams"
],
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 5013c81b781eb95af8e429956d63c8f9c16a4647
Author: Nikita Popov <npopov@redhat.com>
Date: Thu Dec 12 10:44:52 2024 +0100
[GlobalOpt][Evaluator] Don't evaluate calls with signature mismatch (#119548)
The global ctor evaluator tries to evalute function calls where the call
function type and function type do not match, by performing bitcasts.
This currently causes a crash when calling a void function with non-void
return type.
I've opted to remove this functionality entirely rather than fixing this
specific case. With opaque pointers, there shouldn't be a legitimate use
case for this anymore, as we don't need to look through pointer type
casts. Doing other bitcasts is very iffy because it ignores ABI
considerations. We should at least leave adjusting the signatures to
make them line up to InstCombine (which also does some iffy things, but
is at least somewhat more constrained).
Fixes https://github.com/llvm/llvm-project/issues/118725.
diff --git a/llvm/include/llvm/Transforms/Utils/Evaluator.h b/llvm/include/llvm/Transforms/Utils/Evaluator.h
index 5d53773b5d6b..118037625421 100644
--- a/llvm/include/llvm/Transforms/Utils/Evaluator.h
+++ b/llvm/include/llvm/Transforms/Utils/Evaluator.h
@@ -125,9 +125,6 @@ private:
ValueStack.back()[V] = C;
}
- /// Casts call result to a type of bitcast call expression
- Constant *castCallResultIfNeeded(Type *ReturnType, Constant *RV);
-
/// Given call site return callee and list of its formal arguments
Function *getCalleeWithFormalArgs(CallBase &CB,
SmallVectorImpl<Constant *> &Formals);
diff --git a/llvm/lib/Transforms/Utils/Evaluator.cpp b/llvm/lib/Transforms/Utils/Evaluator.cpp
index cf1a8b4af112..2af447aadce2 100644
--- a/llvm/lib/Transforms/Utils/Evaluator.cpp
+++ b/llvm/lib/Transforms/Utils/Evaluator.cpp
@@ -253,40 +253,17 @@ Evaluator::getCalleeWithFormalArgs(CallBase &CB,
bool Evaluator::getFormalParams(CallBase &CB, Function *F,
SmallVectorImpl<Constant *> &Formals) {
- if (!F)
- return false;
-
auto *FTy = F->getFunctionType();
- if (FTy->getNumParams() > CB.arg_size()) {
- LLVM_DEBUG(dbgs() << "Too few arguments for function.\n");
+ if (FTy != CB.getFunctionType()) {
+ LLVM_DEBUG(dbgs() << "Signature mismatch.\n");
return false;
}
- auto ArgI = CB.arg_begin();
- for (Type *PTy : FTy->params()) {
- auto *ArgC = ConstantFoldLoadThroughBitcast(getVal(*ArgI), PTy, DL);
- if (!ArgC) {
- LLVM_DEBUG(dbgs() << "Can not convert function argument.\n");
- return false;
- }
- Formals.push_back(ArgC);
- ++ArgI;
- }
+ for (Value *Arg : CB.args())
+ Formals.push_back(getVal(Arg));
return true;
}
-/// If call expression contains bitcast then we may need to cast
-/// evaluated return value to a type of the call expression.
-Constant *Evaluator::castCallResultIfNeeded(Type *ReturnType, Constant *RV) {
- if (!RV || RV->getType() == ReturnType)
- return RV;
-
- RV = ConstantFoldLoadThroughBitcast(RV, ReturnType, DL);
- if (!RV)
- LLVM_DEBUG(dbgs() << "Failed to fold bitcast call expr\n");
- return RV;
-}
-
/// Evaluate all instructions in block BB, returning true if successful, false
/// if we can't evaluate it. NewBB returns the next BB that control flows into,
/// or null upon return. StrippedPointerCastsForAliasAnalysis is set to true if
@@ -520,9 +497,7 @@ bool Evaluator::EvaluateBlock(BasicBlock::iterator CurInst, BasicBlock *&NextBB,
if (Callee->isDeclaration()) {
// If this is a function we can constant fold, do it.
if (Constant *C = ConstantFoldCall(&CB, Callee, Formals, TLI)) {
- InstResult = castCallResultIfNeeded(CB.getType(), C);
- if (!InstResult)
- return false;
+ InstResult = C;
LLVM_DEBUG(dbgs() << "Constant folded function call. Result: "
<< *InstResult << "\n");
} else {
@@ -544,10 +519,7 @@ bool Evaluator::EvaluateBlock(BasicBlock::iterator CurInst, BasicBlock *&NextBB,
return false;
}
ValueStack.pop_back();
- InstResult = castCallResultIfNeeded(CB.getType(), RetVal);
- if (RetVal && !InstResult)
- return false;
-
+ InstResult = RetVal;
if (InstResult) {
LLVM_DEBUG(dbgs() << "Successfully evaluated function. Result: "
<< *InstResult << "\n\n");
|
[
{
"file": "llvm/test/Transforms/GlobalOpt/evaluate-ret-void-mismatch.ll",
"commands": [
"opt -S -passes=globalopt < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n; Don't evaluate call with return value type mismatch.\n\n@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @__cxx_global_var_init, ptr null }]\n\ndefine void @__cxa_guard_acquire() {\n;\nentry:\n ret void\n}\n\ndefine void @__cxx_global_var_init() {\n;\n %res = call i32 @__cxa_guard_acquire()\n %tobool.not = icmp eq i32 %res, 0\n ret void\n}",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "SIGSEGV with -flto",
"body": "Static linking with -flto on Arch linux with clang 18.1.8\n\nNot able to get a minimal repro at the moment. Other possibly less common options\n\n \"-std=c++20\",\n \"-nostdlib\",\n \"-nostartfiles\",\n \"-fno-exceptions\",\n \"-fno-rtti\",\n\nProgram terminated with signal SIGSEGV, Segmentation fault.\n#0 0x00007ee06170e69c in llvm::ConstantFoldConstant(llvm::Constant const*, llvm::DataLayout const&, llvm::TargetLibraryInfo const*) () from /usr/lib/libLLVM.so.18.1\n#0 0x00007ee06170e69c in llvm::ConstantFoldConstant(llvm::Constant const*, llvm::DataLayout const&, llvm::TargetLibraryInfo const*) () from /usr/lib/libLLVM.so.18.1\n#1 0x00007ee060abea1a in llvm::Evaluator::EvaluateBlock(llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void, true>, false, false>, llvm::BasicBlock*&, bool&) () from /usr/lib/libLLVM.so.18.1\n#2 0x00007ee060ac14e4 in llvm::Evaluator::EvaluateFunction(llvm::Function*, llvm::Constant*&, llvm::SmallVectorImpl<llvm::Constant*> const&) () from /usr/lib/libLLVM.so.18.1\n#3 0x00007ee061307930 in ?? () from /usr/lib/libLLVM.so.18.1\n#4 0x00007ee061308634 in ?? () from /usr/lib/libLLVM.so.18.1\n#5 0x00007ee060aa7649 in llvm::optimizeGlobalCtorsList(llvm::Module&, llvm::function_ref<bool (unsigned int, llvm::Function*)>) () from /usr/lib/libLLVM.so.18.1\n#6 0x00007ee0613135f9 in llvm::GlobalOptPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) () from /usr/lib/libLLVM.so.18.1\n#7 0x00007ee06411d177 in ?? () from /usr/lib/libLLVM.so.18.1\n#8 0x00007ee05fbd767e in llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) () from /usr/lib/libLLVM.so.18.1\n#9 0x00007ee061a57995 in ?? () from /usr/lib/libLLVM.so.18.1\n#10 0x00007ee061a591ff in llvm::lto::opt(llvm::lto::Config const&, llvm::TargetMachine*, unsigned int, llvm::Module&, bool, llvm::ModuleSummaryIndex*, llvm::ModuleSummaryIndex const*, std::vector<unsigned char, std::allocator<unsigned char> > const&) () from /usr/lib/libLLVM.so.18.1\n#11 0x00007ee061a5a582 in llvm::lto::backend(llvm::lto::Config const&, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream> > > (unsigned int, llvm::Twine const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex&) () from /usr/lib/libLLVM.so.18.1\n#12 0x00007ee061a4ed49 in llvm::lto::LTO::runRegularLTO(std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream> > > (unsigned int, llvm::Twine const&)>) () from /usr/lib/libLLVM.so.18.1\n#13 0x00007ee061a4f241 in llvm::lto::LTO::run(std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream> > > (unsigned int, llvm::Twine const&)>, std::function<llvm::Expected<std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream> > > (unsigned int, llvm::Twine const&)> > (unsigned int, llvm::StringRef, llvm::Twine const&)>) () from /usr/lib/libLLVM.so.18.1\n#14 0x00007ee0678ce067 in ?? () from /usr/bin/../lib/LLVMgold.so\n#15 0x00007ee0678cfd12 in ?? () from /usr/bin/../lib/LLVMgold.so\n#16 0x000056f827567837 in ?? ()\n#17 0x000056f82756f75f in ?? ()\n#18 0x00007ee067a00e08 in ?? () from /usr/lib/libc.so.6\n#19 0x00007ee067a00ecc in __libc_start_main () from /usr/lib/libc.so.6\n#20 0x000056f82756ea65 in ?? ()\n",
"author": "illiminable",
"labels": [
"incomplete",
"crash",
"LTO"
],
"comments": [
{
"author": "EugeneZelenko",
"body": "Could you please try 19 or `main` branch?"
},
{
"author": "illiminable",
"body": "I don't think 19 is packaged for arch yet. I'll see if I can build trunk later in the week.\n\nIs it possible to just to disable this optimizeGlobalCtorsList or all of globalopt. I looked through --hidden-help and could not see an option like this."
},
{
"author": "ms178",
"body": "@illiminable While it is not packaged by Arch yet, you could try the linked toolchain instead and use it via an environment variable which points llvm to the new path: https://mirrors.edge.kernel.org/pub/tools/llvm/"
},
{
"author": "illiminable",
"body": "OK thanks I'll try. FWIW this is the approximate code pattern. And presumably its trying to optimize the fact that there are N unique symbols that \"register\" assigns true to but then never get used.\n\n```\n// Header File\nclass Functor {\n virtual void execImpl() = 0;\n void exec() { execImpl(); }\n };\n \n class Info {\n Functor* fn = nullptr;\n };\n \n class Registry {\n array<Info, 1024> fns;\n int count = 0;\n \n void register(Info&& f) {\n fns[count++] = f;\n }\n \n void exec() {\n for i in 0..count { fns[i].fn->exec(); }\n }\n };\n \n inline Registry reg;\n \n inline bool register(Functor* fn) {\n reg.register({.fn = fn});\n return true;\n }\n \n \n // REPEAT approx 10 each copies of the below in 10 different .cpp TU's\n class _uniquesymbol_ : public Functor {\n void execImpl() override;\n };\n \n // Instance of the derived functor class\n _uniquesymbol_ _uniquesymbol__instance;\n \n // _uniquesymbol__flag is always true and never used. Theres probably a better\n // way to do this?\n const bool _uniquesymbol__flag = register(&_uniquesymbol__instance);\n \n void _uniquesymbol_::execImpl() {\n // do stuff\n }\n \n // END REPEAT\n \n \n // Usage...\n reg.exec();\n``` \n"
},
{
"author": "illiminable",
"body": "@ms178 The toolchain didn't work because it doesn't contain LLVMgold.so\n\nI was able to build from the 19.1.5 branch in debug and can repro. It's only on one target. This is the assert output\n\nld.gold: /mnt/local/src/third_party/github/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:109: static bool llvm::isa_impl_cl<To, const From*>::doit(const From*) [with To = llvm::ConstantVector; From = llvm::Constant]: Assertion `Val && \"isa<> used on a null pointer\"' failed.\n\nAnd a better symbolized stack\n\n#0 0x00007c11cae473f4 in ?? () from /usr/lib/libc.so.6\n#0 0x00007c11cae473f4 in ?? () from /usr/lib/libc.so.6\n#1 0x00007c11cadee120 in raise () from /usr/lib/libc.so.6\n#2 0x00007c11cadd54c3 in abort () from /usr/lib/libc.so.6\n#3 0x00007c11cadd53df in ?? () from /usr/lib/libc.so.6\n#4 0x00007c11cade6177 in __assert_fail () from /usr/lib/libc.so.6\n#5 0x00007c11c329c245 in llvm::isa_impl_cl<llvm::ConstantVector, llvm::Constant const*>::doit (Val=0x0) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:109\n#6 0x00007c11c329bd99 in llvm::isa_impl_wrap<llvm::ConstantVector, llvm::Constant const*, llvm::Constant const*>::doit (Val=@0x7ffd009f71a0: 0x0) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:137\n#7 0x00007c11c329b45b in llvm::isa_impl_wrap<llvm::ConstantVector, llvm::Constant const* const, llvm::Constant const*>::doit (Val=@0x7ffd009f71f0: 0x0) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:129\n#8 0x00007c11c329a6b6 in llvm::CastIsPossible<llvm::ConstantVector, llvm::Constant const*, void>::isPossible (f=@0x7ffd009f71f0: 0x0) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:257\n#9 0x00007c11c5ccd903 in llvm::CastInfo<llvm::ConstantVector, llvm::Constant const* const, void>::isPossible (f=@0x7ffd009f7248: 0x0) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:509\n#10 0x00007c11c5ccd3d8 in llvm::isa<llvm::ConstantVector, llvm::Constant const*> (Val=@0x7ffd009f7248: 0x0) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:549\n#11 0x00007c11c5f8be6e in (anonymous namespace)::ConstantFoldConstantImpl (C=0x0, DL=..., TLI=0x5d4a86076c38, FoldedOps=...) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/Analysis/ConstantFolding.cpp:1078\n#12 0x00007c11c5f8c5d3 in llvm::ConstantFoldConstant (C=0x0, DL=..., TLI=0x5d4a86076c38) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/Analysis/ConstantFolding.cpp:1163\n#13 0x00007c11c5cb7bdc in llvm::Evaluator::EvaluateBlock (this=0x7ffd009f7930, CurInst=..., NextBB=@0x7ffd009f76e0: 0x0, StrippedPointerCastsForAliasAnalysis=@0x7ffd009f76d0: false) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/Transforms/Utils/Evaluator.cpp:610\n#14 0x00007c11c5cb7fd8 in llvm::Evaluator::EvaluateFunction (this=0x7ffd009f7930, F=0x5d4a85ccc618, RetVal=@0x7ffd009f78a8: 0x7ffd009f7ae0, ActualArgs=...) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/Transforms/Utils/Evaluator.cpp:660\n#15 0x00007c11c4f410a8 in EvaluateStaticConstructor (F=0x5d4a85ccc618, DL=..., TLI=0x5d4a86076c38) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp:2080\n#16 0x00007c11c4f42bf7 in operator() (__closure=0x7ffd009f7e90, Priority=65535, F=0x5d4a85ccc618) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp:2524\n#17 0x00007c11c4f43f3b in llvm::function_ref<bool(unsigned int, llvm::Function*)>::callback_fn<optimizeGlobalsInModule(llvm::Module&, const llvm::DataLayout&, llvm::function_ref<llvm::TargetLibraryInfo&(llvm::Function&)>, llvm::function_ref<llvm::TargetTransformInfo&(llvm::Function&)>, llvm::function_ref<llvm::BlockFrequencyInfo&(llvm::Function&)>, llvm::function_ref<llvm::DominatorTree&(llvm::Function&)>, llvm::function_ref<void(llvm::Function&)>, llvm::function_ref<void(llvm::Function&)>)::<lambda(uint32_t, llvm::Function*)> >(intptr_t, unsigned int, llvm::Function *) (callable=140724613906064, params#0=65535, params#1=0x5d4a85ccc618) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45\n#18 0x00007c11c5c95103 in llvm::function_ref<bool(unsigned int, llvm::Function*)>::operator() (this=0x7ffd009f7cc0, params#0=65535, params#1=0x5d4a85ccc618) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68\n#19 0x00007c11c5c92754 in llvm::optimizeGlobalCtorsList (M=..., ShouldRemove=...) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/Transforms/Utils/CtorUtils.cpp:138\n#20 0x00007c11c4f4309c in optimizeGlobalsInModule(llvm::Module &, const llvm::DataLayout &, llvm::function_ref<llvm::TargetLibraryInfo&(llvm::Function&)>, llvm::function_ref<llvm::TargetTransformInfo&(llvm::Function&)>, llvm::function_ref<llvm::BlockFrequencyInfo&(llvm::Function&)>, llvm::function_ref<llvm::DominatorTree&(llvm::Function&)>, llvm::function_ref<void(llvm::Function&)>, llvm::function_ref<void(llvm::Function&)>) (M=..., DL=..., GetTLI=..., GetTTI=..., GetBFI=..., LookupDomTree=..., ChangedCFGCallback=..., DeleteFnCallback=...) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp:2520\n#21 0x00007c11c4f435e0 in llvm::GlobalOptPass::run (this=0x5d4a85c13138, M=..., AM=...) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp:2583\n#22 0x00007c11c4366477 in llvm::detail::PassModel<llvm::Module, llvm::GlobalOptPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (this=0x5d4a85c13130, IR=..., AM=...) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:90\n#23 0x00007c11c6e2f349 in llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (this=0x7ffd009f8300, IR=..., AM=...) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/include/llvm/IR/PassManagerImpl.h:81\n#24 0x00007c11c3934968 in runNewPMPasses (Conf=..., Mod=..., TM=0x5d4a85edf0b0, OptLevel=3, IsThinLTO=false, ExportSummary=0x5d4a85bc6d18, ImportSummary=0x0) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/LTO/LTOBackend.cpp:338\n#25 0x00007c11c3934b94 in llvm::lto::opt (Conf=..., TM=0x5d4a85edf0b0, Task=0, Mod=..., IsThinLTO=false, ExportSummary=0x5d4a85bc6d18, ImportSummary=0x0, CmdArgs=std::vector of length 0, capacity 0) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/LTO/LTOBackend.cpp:363\n#26 0x00007c11c3936054 in llvm::lto::backend (C=..., AddStream=..., ParallelCodeGenParallelismLevel=1, Mod=..., CombinedIndex=...) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/LTO/LTOBackend.cpp:517\n#27 0x00007c11c38e855d in llvm::lto::LTO::runRegularLTO (this=0x5d4a85bc6710, AddStream=...) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/LTO/LTO.cpp:1354\n#28 0x00007c11c38e746b in llvm::lto::LTO::run (this=0x5d4a85bc6710, AddStream=..., Cache=...) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/LTO/LTO.cpp:1186\n#29 0x00007c11c3255536 in runLTO () at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/tools/gold/gold-plugin.cpp:1111\n#30 0x00007c11c3255a0d in allSymbolsReadHook () at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/tools/gold/gold-plugin.cpp:1148\n#31 0x00007c11c3255c19 in all_symbols_read_hook () at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/tools/gold/gold-plugin.cpp:1173\n#32 0x00005d4a6c4d9154 in ?? ()\n#33 0x00005d4a6c5138d0 in ?? ()\n#34 0x00005d4a6c3fc49a in ?? ()\n#35 0x00007c11cadd6e08 in ?? () from /usr/lib/libc.so.6\n#36 0x00007c11cadd6ecc in __libc_start_main () from /usr/lib/libc.so.6\n#37 0x00005d4a6c3ff985 in ?? ()"
},
{
"author": "ms178",
"body": "@illiminable Thanks for letting me know. Unfortunately I am not a developer and cannot help you to debug this problem further."
},
{
"author": "illiminable",
"body": "I debugged a little bit, but I don't fully understand this code.\n\nIn EvaluateBlock the issue is that after the various branches the code falls out to this block at 609 with InstResult still null. All the other branches usually check InstResult and return false. ConstantFoldConstant will assert or crash if the first parameter is null in the call from 610. I also tried just guarding this conditino with !InstResult but that doesn't seem right since it triggers another assert later \"Assertion `R && \"Reference to an uncomputed value!\"'.\n\nhttps://github.com/llvm/llvm-project/blob/llvmorg-19.1.5/llvm/lib/Transforms/Utils/Evaluator.cpp#L610\n\nThe bug only only occurs when the code hits the branch on 556. Strangely the debug log here says both branches of the if are success. I don't know if it's a copy paste error or if maybe the code should just return true after 558, but given the rest of the code this doesn't seem right.\n\nBut returning false in the line 556 branch seems to fix the crash and the resulting program seems to work fine.\n\nhttps://github.com/llvm/llvm-project/blob/llvmorg-19.1.5/llvm/lib/Transforms/Utils/Evaluator.cpp#L556\n\nSomeone who understands the code better should evaluate though.\n"
},
{
"author": "illiminable",
"body": "I used llvm-reduce to reduce the bitcode and when i looked at what was left it was basically __cxa_guard_acquire and I realized that while bootstrapping i defined it with the wrong return type. So since I violated the ABI I guess my fault.\n\nNot sure if there is still an underlying issue here someone wants to fix. ie. would be better to error or ignore than crash. But it seems pretty unlikely someone else will hit at least this specific cause of the problem.\n\nCan probably close if this corner case is not important."
},
{
"author": "nikic",
"body": "Could you please share the reduced bitcode? (Or IR after running it through llvm-dis.)"
},
{
"author": "illiminable",
"body": "[reduced.zip](https://github.com/user-attachments/files/18043521/reduced.zip)\n\nThis is the reduced.bc\n\n"
}
]
}
| true
|
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
|
Cannot find a good commit
| null |
174020
|
https://github.com/llvm/llvm-project/issues/174020
|
crash
|
16ecf40aea105c3cf908b9653d6556e31bbc480a
| 2025-12-30T21:08:26
|
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "55e0b928b5f48678f742ea9a026774e41b484f13",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
14177,
14182
],
[
18614,
18619
]
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"adjustExtracts"
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 55e0b928b5f48678f742ea9a026774e41b484f13
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Wed Dec 31 10:21:42 2025 -0800
[SLP]Consider deleted/gathered nodes, when deciding to erase extractelement
If any user of the extractelement instruction is part of the node to be
deleted/gathered, such extractelements instructions should not be
considered for deletion.
Fixes #174020
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 3d98d470387e..bbcdeea1654f 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -14177,6 +14177,11 @@ public:
ArrayRef<TreeEntry *> VEs = R.getTreeEntries(V);
if (!CheckedExtracts.insert(V).second ||
!R.areAllUsersVectorized(cast<Instruction>(V), &VectorizedVals) ||
+ any_of(VEs,
+ [&](const TreeEntry *TE) {
+ return R.DeletedNodes.contains(TE) ||
+ R.TransformedToGatherNodes.contains(TE);
+ }) ||
(E->UserTreeIndex && E->UserTreeIndex.EdgeIdx == UINT_MAX &&
!R.isVectorized(EE) &&
count_if(E->Scalars, [&](Value *V) { return V == EE; }) !=
@@ -18614,6 +18619,11 @@ public:
any_of(EI->users(), [&](User *U) {
ArrayRef<TreeEntry *> UTEs = R.getTreeEntries(U);
return UTEs.empty() || UTEs.size() > 1 ||
+ any_of(UTEs,
+ [&](const TreeEntry *TE) {
+ return R.DeletedNodes.contains(TE) ||
+ R.TransformedToGatherNodes.contains(TE);
+ }) ||
(isa<GetElementPtrInst>(U) &&
!R.areAllUsersVectorized(cast<Instruction>(U))) ||
(!UTEs.empty() &&
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/deleted-instructions-clear.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -mcpu=znver2 < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @test(i32 %arg, i32 %arg1, i64 %arg2) {\n;\nbb:\n br label %bb3\n\nbb3:\n %phi = phi i64 [ 0, %bb3 ], [ 0, %bb ]\n %phi4 = phi i64 [ %add39, %bb3 ], [ 0, %bb ]\n %or = or i64 %phi, 0\n %trunc = trunc i64 %or to i32\n %or5 = or i64 %phi, 0\n %mul = mul i64 %or, %or5\n %or6 = or i64 0, 0\n %or7 = or i64 0, 0\n %mul8 = mul i64 %or6, %or7\n %shl = shl i32 0, 1\n %or9 = or i64 %phi, 0\n %trunc10 = trunc i64 %or9 to i32\n %or11 = or i32 %trunc10, 0\n %or12 = or i64 %phi, 0\n %mul13 = mul i64 %or9, %or12\n %add = add i64 %mul, %mul8\n %sext = sext i32 %shl to i64\n %add14 = add i64 %add, %sext\n %xor = xor i32 0, %trunc\n %sext15 = sext i32 %xor to i64\n %add16 = add i64 %add14, %sext15\n %shl17 = shl i32 %shl, 0\n %add18 = add i64 1, 0\n %trunc19 = trunc i64 %add18 to i32\n %mul20 = mul i64 0, 0\n %add21 = add i64 %mul13, %add16\n %sext22 = sext i32 %shl17 to i64\n %add23 = add i64 %add21, %sext22\n %xor24 = xor i32 %arg, %trunc10\n %sext25 = sext i32 %xor24 to i64\n %add26 = add i64 %add23, %sext25\n %trunc27 = trunc i64 %arg2 to i32\n %add28 = add i64 %mul20, %add26\n %sext29 = sext i32 %shl to i64\n %add30 = add i64 %add28, %sext29\n %xor31 = xor i32 %arg1, %trunc19\n %sext32 = sext i32 %xor31 to i64\n %add33 = add i64 %add30, %sext32\n %shl34 = shl i32 %arg1, 0\n %sext35 = sext i32 %shl34 to i64\n %add36 = add i64 %add33, %sext35\n %xor37 = xor i32 %arg, %trunc27\n %sext38 = sext i32 %xor37 to i64\n %add39 = add i64 %add36, %sext38\n br i1 false, label %bb40, label %bb3\n\nbb40:\n %phi41 = phi i64 [ %add39, %bb3 ]\n ret void\n}",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "Assertion `I->use_empty() && \"trying to erase instruction with users.\"' failed.",
"body": "To reproduce run opt with the test below (-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(i32 %arg, i32 %arg1, i64 %arg2) #0 gc \"statepoint-example\" {\nbb:\n br label %bb3\n\nbb3: ; preds = %bb3, %bb\n %phi = phi i64 [ 0, %bb3 ], [ 0, %bb ]\n %phi4 = phi i64 [ %add39, %bb3 ], [ 0, %bb ]\n %or = or i64 %phi, 0\n %trunc = trunc i64 %or to i32\n %or5 = or i64 %phi, 0\n %mul = mul i64 %or, %or5\n %or6 = or i64 0, 0\n %or7 = or i64 0, 0\n %mul8 = mul i64 %or6, %or7\n %shl = shl i32 0, 1\n %or9 = or i64 %phi, 0\n %trunc10 = trunc i64 %or9 to i32\n %or11 = or i32 %trunc10, 0\n %or12 = or i64 %phi, 0\n %mul13 = mul i64 %or9, %or12\n %add = add i64 %mul, %mul8\n %sext = sext i32 %shl to i64\n %add14 = add i64 %add, %sext\n %xor = xor i32 0, %trunc\n %sext15 = sext i32 %xor to i64\n %add16 = add i64 %add14, %sext15\n %shl17 = shl i32 %shl, 0\n %add18 = add i64 1, 0\n %trunc19 = trunc i64 %add18 to i32\n %mul20 = mul i64 0, 0\n %add21 = add i64 %mul13, %add16\n %sext22 = sext i32 %shl17 to i64\n %add23 = add i64 %add21, %sext22\n %xor24 = xor i32 %arg, %trunc10\n %sext25 = sext i32 %xor24 to i64\n %add26 = add i64 %add23, %sext25\n %trunc27 = trunc i64 %arg2 to i32\n %add28 = add i64 %mul20, %add26\n %sext29 = sext i32 %shl to i64\n %add30 = add i64 %add28, %sext29\n %xor31 = xor i32 %arg1, %trunc19\n %sext32 = sext i32 %xor31 to i64\n %add33 = add i64 %add30, %sext32\n %shl34 = shl i32 %arg1, 0\n %sext35 = sext i32 %shl34 to i64\n %add36 = add i64 %add33, %sext35\n %xor37 = xor i32 %arg, %trunc27\n %sext38 = sext i32 %xor37 to i64\n %add39 = add i64 %add36, %sext38\n br i1 false, label %bb40, label %bb3\n\nbb40: ; preds = %bb3\n %phi41 = phi i64 [ %add39, %bb3 ]\n ret void\n}\n\nattributes #0 = { \"target-cpu\"=\"znver2\" }\n```\nReproducer: https://godbolt.org/z/fWzdn43sd\n\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 \"function(slp-vectorizer)\" on module \"<source>\"\n2.\tRunning pass \"slp-vectorizer\" on function \"wombat\"\n #0 0x0000000005a65f78 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5a65f78)\n #1 0x0000000005a62e24 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x0000753390242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007533902969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x0000753390242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007533902287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x000075339022871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x0000753390239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x000000000378f07f llvm::slpvectorizer::BoUpSLP::~BoUpSLP() (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x378f07f)\n #9 0x00000000038861d6 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\n#10 0x0000000003886c5b llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3886c5b)\n#11 0x0000000003036a7e 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+0x3036a7e)\n#12 0x0000000005841e31 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5841e31)\n#13 0x0000000000f19f8e 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+0xf19f8e)\n#14 0x00000000058403ea llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x58403ea)\n#15 0x000000000097dfce 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+0x97dfce)\n#16 0x000000000583fda1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x583fda1)\n#17 0x0000000000988280 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x988280)\n#18 0x000000000097c178 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x97c178)\n#19 0x0000753390229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#20 0x0000753390229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#21 0x0000000000972c15 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x972c15)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```",
"author": "TatyanaDoubts",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null | null |
177144
|
https://github.com/llvm/llvm-project/issues/177144
|
crash
|
8e362e10c79a73438a8678dbb1f9be29b3c01cae
| 2026-01-21T11:27:54
|
[
"llvm/test/Transforms/VectorCombine"
] |
{
"fix_commit": "4ec35a0b0e13f15ad38a2fa668004c892a365795",
"components": [
"VectorCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [
[
1655,
1661
]
],
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [
"VectorCombine::foldSelectsFromBitcast"
],
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 4ec35a0b0e13f15ad38a2fa668004c892a365795
Author: Mitch Briles <mitchbriles@gmail.com>
Date: Wed Jan 28 08:13:50 2026 -0700
[VectorCombine] Fix crash when folding select of bitcast (#177183)
Fixes #177144. Nits appreciated.
The fold in question does the following transformation:
Before
```
%bc = bitcast <4 x i32> %src to <16 x i8>
%e0 = extractelement <16 x i8> %bc, i32 0
%s0 = select i1 %cond, i8 %e0, i8 0
%e1 = extractelement <16 x i8> %bc, i32 1
%s1 = select i1 %cond, i8 %e1, i8 0
...
```
After
```
%sel = select i1 %cond, <4 x i32> %src, <4 x i32> zeroinitializer
%bc = bitcast <4 x i32> %sel to <16 x i8>
%e0 = extractelement <16 x i8> %bc, i32 0
%e1 = extractelement <16 x i8> %bc, i32 1
...
```
If every select shares the condition and has 0 in the false branch, the
bitcast can be replaced with a select between the original vector and
`zeroinitializer`, followed by a bitcast. Then each `select(cond,
extelt(...), 0)` can be replaced with `extelt(...)`.
The crash happens when the condition is defined after the original
bitcast, because the bitcast is replaced with the select + bitcast, and
now the select references a condition not yet defined.
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index fbb3b820c4f0..fb6fa247038a 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -1655,7 +1655,13 @@ bool VectorCombine::foldSelectsFromBitcast(Instruction &I) {
}
// Create the vector select and bitcast once for this condition.
- Builder.SetInsertPoint(BC->getNextNode());
+ auto InsertPt = std::next(BC->getIterator());
+
+ if (auto *CondInst = dyn_cast<Instruction>(Cond))
+ if (DT.dominates(BC, CondInst))
+ InsertPt = std::next(CondInst->getIterator());
+
+ Builder.SetInsertPoint(InsertPt);
Value *VecSel =
Builder.CreateSelect(Cond, SrcVec, Constant::getNullValue(SrcVecTy));
Value *NewBC = Builder.CreateBitCast(VecSel, DstVecTy);
|
[
{
"file": "llvm/test/Transforms/VectorCombine/AMDGPU/combine-scalar-selects.ll",
"commands": [
"opt -mtriple=amdgcn-amd-amdhsa -mcpu=gfx942 -passes=vector-combine -S %s",
"opt -mtriple=amdgcn-amd-amdhsa -mcpu=gfx942 -S %s"
],
"tests": [
{
"test_name": "fold_selects_from_bitcast_dominance_multiblock2",
"test_body": "define i8 @fold_selects_from_bitcast_dominance_multiblock2(<4 x i64> %v, i8 %a, i1 %flag) {\nentry:\n %0 = bitcast <4 x i64> %v to <32 x i8>\n br label %first\n\nfirst: ; preds = %entry\n %vecext1 = extractelement <32 x i8> %0, i64 0\n %vecext2 = extractelement <32 x i8> %0, i64 7\n %vecext3 = extractelement <32 x i8> %0, i64 1\n %vecext4 = extractelement <32 x i8> %0, i64 8\n %vecext5 = extractelement <32 x i8> %0, i64 9\n br label %second\n\nsecond: ; preds = %first\n %cond = icmp eq i8 %a, 0\n br i1 %flag, label %then, label %else\n\nthen: ; preds = %second\n %s1 = select i1 %cond, i8 %vecext1, i8 0\n br label %combine\n\nelse: ; preds = %second\n %s2 = select i1 %cond, i8 %vecext2, i8 0\n br label %combine\n\ncombine: ; preds = %else, %then\n %r1 = phi i8 [ %s1, %then ], [ %s2, %else ]\n %s3 = select i1 %cond, i8 %vecext3, i8 0\n %s4 = select i1 %cond, i8 %vecext4, i8 0\n %s5 = select i1 %cond, i8 %vecext5, i8 0\n %r2 = add i8 %r1, %s3\n %r3 = add i8 %r2, %s4\n %r4 = add i8 %r3, %s5\n ret i8 %r4\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "fold_selects_from_bitcast_dominance_multiblock3",
"test_body": "define i8 @fold_selects_from_bitcast_dominance_multiblock3(<4 x i64> %v1, <4 x i64> %v2, i8 %a, i1 %flag1, i1 %flag2, i1 %flag3, i1 %flag4, i1 %cond2) {\nentry:\n %0 = bitcast <4 x i64> %v1 to <32 x i8>\n %1 = bitcast <4 x i64> %v2 to <32 x i8>\n br label %first\n\nfirst: ; preds = %entry\n %vecext00 = extractelement <32 x i8> %0, i64 0\n %vecext02 = extractelement <32 x i8> %0, i64 2\n %vecext04 = extractelement <32 x i8> %0, i64 4\n %vecext06 = extractelement <32 x i8> %0, i64 6\n %vecext08 = extractelement <32 x i8> %0, i64 8\n %vecext11 = extractelement <32 x i8> %1, i64 1\n %vecext13 = extractelement <32 x i8> %1, i64 3\n %vecext15 = extractelement <32 x i8> %1, i64 5\n %vecext17 = extractelement <32 x i8> %1, i64 7\n %vecext19 = extractelement <32 x i8> %1, i64 9\n br label %t0\n\nt0: ; preds = %first\n %cond1 = icmp eq i8 %a, 0\n br i1 %flag1, label %r0, label %t1\n\nt1: ; preds = %t0\n br i1 %flag2, label %r1, label %t2\n\nt2: ; preds = %t1\n br i1 %flag3, label %r2, label %t3\n\nt3: ; preds = %t2\n br i1 %flag4, label %r3, label %r4\n\nr0: ; preds = %t0\n %res0 = select i1 %cond1, i8 %vecext00, i8 0\n %res1 = select i1 %cond2, i8 %vecext11, i8 0\n %res01 = add i8 %res0, %res1\n ret i8 %res01\n\nr1: ; preds = %t1\n %res2 = select i1 %cond1, i8 %vecext02, i8 0\n %res3 = select i1 %cond2, i8 %vecext13, i8 0\n %res23 = add i8 %res2, %res3\n ret i8 %res23\n\nr2: ; preds = %t2\n %res4 = select i1 %cond1, i8 %vecext04, i8 0\n %res5 = select i1 %cond2, i8 %vecext15, i8 0\n %res45 = add i8 %res4, %res5\n ret i8 %res45\n\nr3: ; preds = %t3\n %res6 = select i1 %cond1, i8 %vecext06, i8 0\n %res7 = select i1 %cond2, i8 %vecext17, i8 0\n %res67 = add i8 %res6, %res7\n ret i8 %res67\n\nr4: ; preds = %t3\n %res8 = select i1 %cond1, i8 %vecext08, i8 0\n %res9 = select i1 %cond2, i8 %vecext19, i8 0\n %res89 = add i8 %res8, %res9\n ret i8 %res89\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "fold_selects_from_bitcast_dominance_multiblock1",
"test_body": "define i8 @fold_selects_from_bitcast_dominance_multiblock1(<4 x i32> %src, i8 %a, i1 %flag1, i1 %flag2) {\n %bc = bitcast <4 x i32> %src to <16 x i8>\n %cond = icmp eq i8 %a, 0\n br i1 %flag1, label %first, label %trampoline\n\ntrampoline: ; preds = %0\n br i1 %flag2, label %second, label %third\n\nfirst: ; preds = %0\n %e00 = extractelement <16 x i8> %bc, i32 0\n %s00 = select i1 %cond, i8 %e00, i8 0\n %e01 = extractelement <16 x i8> %bc, i32 2\n %s01 = select i1 %cond, i8 %e01, i8 0\n %s0 = add i8 %s00, %s01\n br label %end\n\nsecond: ; preds = %trampoline\n %e10 = extractelement <16 x i8> %bc, i32 3\n %s10 = select i1 %cond, i8 %e10, i8 0\n %e11 = extractelement <16 x i8> %bc, i32 4\n %s11 = select i1 %cond, i8 %e11, i8 0\n %s1 = add i8 %s10, %s11\n br label %end\n\nthird: ; preds = %trampoline\n %e20 = extractelement <16 x i8> %bc, i32 5\n %s20 = select i1 %cond, i8 %e20, i8 0\n %e21 = extractelement <16 x i8> %bc, i32 6\n %s21 = select i1 %cond, i8 %e21, i8 0\n %s2 = add i8 %s20, %s21\n br label %end\n\nend: ; preds = %third, %second, %first\n %res = phi i8 [ %s0, %first ], [ %s1, %second ], [ %s2, %third ]\n ret i8 %res\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[VectorCombine] LLVM ERROR: Broken module found, compilation aborted!",
"body": "Reproducer: https://godbolt.org/z/nWG51fEc1\nTestcase:\n```llvm\ndefine i8 @backsmith_pure_0() {\nentry:\n %0 = bitcast <4 x i64> splat (i64 1) to <32 x i8>\n %vecext56 = extractelement <32 x i8> %0, i64 0\n %tobool.not = icmp eq i8 0, 0\n %vecext36 = extractelement <32 x i8> %0, i64 0\n %narrow = select i1 %tobool.not, i8 %vecext36, i8 0\n %narrow8 = select i1 %tobool.not, i8 %vecext56, i8 0\n ret i8 %narrow8\n}\n```\n\nDump:\n```\nInstruction does not dominate all uses!\n %tobool.not = icmp eq i8 0, 0\n %0 = select i1 %tobool.not, <4 x i64> splat (i64 1), <4 x i64> zeroinitializer\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 and instructions to reproduce the bug.\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S --passes=vector-combine <source>\n1.\tRunning pass \"verify\" on module \"<source>\"\n #0 0x0000000005a91978 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5a91978)\n #1 0x0000000005a8e854 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x000074e865242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x000074e8652969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x000074e865242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x000074e8652287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x000000000082b993 llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0\n #7 0x00000000059c3d61 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x59c3d61)\n #8 0x0000000005847298 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5847298)\n #9 0x0000000000962fde 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+0x962fde)\n#10 0x00000000058035e1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x58035e1)\n#11 0x000000000096d1ca llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x96d1ca)\n#12 0x0000000000961278 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x961278)\n#13 0x000074e865229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#14 0x000074e865229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#15 0x0000000000957ef5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x957ef5)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```",
"author": "XChy",
"labels": [
"crash-on-valid",
"generated by fuzzer",
"llvm::vectorcombine"
],
"comments": [
{
"author": "RKSimon",
"body": "```\nVECTORCOMBINE on backsmith_pure_0\nVC: Visiting: %0 = bitcast <4 x i64> splat (i64 1) to <32 x i8>\nVC: Replacing: %narrow = select i1 %tobool.not, i8 %vecext36, i8 0\n With: %3 = extractelement <32 x i8> %2, i64 0\nADD: %narrow = extractelement <32 x i8> %2, i64 0\nVC: Erasing: %3 = select i1 %tobool.not, i8 %vecext36, i8 0\nADD: %1 = select i1 %tobool.not, <4 x i64> splat (i64 1), <4 x i64> zeroinitializer\nADD: %narrow8 = select i1 %tobool.not, i8 %vecext56, i8 0\nADD: %tobool.not = icmp eq i8 0, 0\nVC: Erased: %vecext36 = extractelement <32 x i8> %0, i64 0\nVC: Replacing: %narrow8 = select i1 %tobool.not, i8 %vecext56, i8 0\n With: %3 = extractelement <32 x i8> %2, i64 0\nADD: ret i8 %narrow8\nADD: %narrow8 = extractelement <32 x i8> %2, i64 0\nVC: Erasing: %3 = select i1 %tobool.not, i8 %vecext56, i8 0\nVC: Erased: %vecext56 = extractelement <32 x i8> %0, i64 0\nVC: Erased: %0 = bitcast <4 x i64> splat (i64 1) to <32 x i8>\nVectorCombine: folded 2 selects into vector select\nVC: Visiting: %tobool.not = icmp eq i8 0, 0\nVC: Visiting: %narrow = extractelement <32 x i8> %1, i64 0\nVC: Visiting: %narrow8 = extractelement <32 x i8> %1, i64 0\nVC: Visiting: ret i8 %narrow8\nVC: Visiting: %narrow8 = extractelement <32 x i8> %1, i64 0\nVC: Visiting: ret i8 %narrow8\nVC: Visiting: %tobool.not = icmp eq i8 0, 0\nVC: Visiting: %0 = select i1 %tobool.not, <4 x i64> splat (i64 1), <4 x i64> zeroinitializer\nVC: Erasing: %narrow = extractelement <32 x i8> %1, i64 0\nADD: %narrow8 = extractelement <32 x i8> %1, i64 0\nADD: %1 = bitcast <4 x i64> %0 to <32 x i8>\nVC: Visiting: %1 = bitcast <4 x i64> %0 to <32 x i8>\nVC: Visiting: %narrow8 = extractelement <32 x i8> %1, i64 0\nInstruction does not dominate all uses!\n %tobool.not = icmp eq i8 0, 0\n %0 = select i1 %tobool.not, <4 x i64> splat (i64 1), <4 x i64> zeroinitializer\n```"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null | null |
162922
|
https://github.com/llvm/llvm-project/issues/162922
|
crash
|
a61e016565409b6a6620422dd915e591ea75f998
| 2025-10-10T21:14:51
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "0e28c9bc9d64625db8e4a1707720c9eecff069a4",
"components": [
"LoopAccessAnalysis"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": [
[
2982,
2987
]
],
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": [
"LoopAccessInfo::collectStridedAccess"
],
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 0e28c9bc9d64625db8e4a1707720c9eecff069a4
Author: Florian Hahn <flo@fhahn.com>
Date: Mon Oct 27 05:01:16 2025 +0000
[LAA] Skip undef/poison strides in collectStridedAccess.
The map returned by collectStridedAccess is used to replace strides with
their versioned values. This does not work for Undef/Poison, which don't
have use-lists. Don't try to version them, as versioning won't be useful in
practice.
Fixes https://github.com/llvm/llvm-project/issues/162922.
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index 7adb25d0e5e0..e27a9b1c4401 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -2982,6 +2982,10 @@ void LoopAccessInfo::collectStridedAccess(Value *MemAccess) {
if (!StrideExpr)
return;
+ if (auto *Unknown = dyn_cast<SCEVUnknown>(StrideExpr))
+ if (isa<UndefValue>(Unknown->getValue()))
+ return;
+
LLVM_DEBUG(dbgs() << "LAA: Found a strided access that is a candidate for "
"versioning:");
LLVM_DEBUG(dbgs() << " Ptr: " << *Ptr << " Stride: " << *StrideExpr << "\n");
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/version-mem-access.ll",
"commands": [
"opt -passes=loop-vectorize -enable-mem-access-versioning -force-vector-width=2 -force-vector-interleave=1 -S %s"
],
"tests": [
{
"test_name": "stride_undef",
"test_body": "; Function Attrs: mustprogress\ndefine void @stride_undef(ptr %dst) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep.dst = getelementptr i8, ptr %dst, i64 %iv\n store i8 0, ptr %gep.dst, align 1\n %iv.next = add nuw nsw i64 %iv, undef\n %ec = icmp samesign ult i64 %iv, 100\n br i1 %ec, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { mustprogress }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "stride_poison",
"test_body": "; Function Attrs: mustprogress\ndefine void @stride_poison(ptr %dst) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep.dst = getelementptr i8, ptr %dst, i64 %iv\n store i8 0, ptr %gep.dst, align 1\n %iv.next = add nuw nsw i64 %iv, poison\n %ec = icmp samesign ult i64 %iv, 100\n br i1 %ec, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { mustprogress }\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[RISC-V][LoopVectorize] Assertion `hasUseList()' failed.",
"body": "Testcase:\n```llvm ir\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\n@l = external global [25 x i16]\n\ndefine void @init() {\nentry:\n store <4 x i16> splat (i16 1), ptr @l, align 8\n ret void\n}\n\ndefine i32 @main(ptr %0, ptr %1, i64 %indvars.iv2) #0 {\nentry:\n tail call void @init()\n %2 = load i16, ptr getelementptr inbounds nuw (i8, ptr @l, i64 2), align 2\n %tobool.not.i = icmp eq i16 %2, 0\n %3 = load i16, ptr %0, align 2\n br i1 %tobool.not.i, label %for.cond1.preheader.i.preheader, label %common.ret\n\ncommon.ret: ; preds = %for.body4.i.1, %entry\n ret i32 0\n\nfor.cond1.preheader.i.preheader: ; preds = %entry\n %cmp35.i = icmp sgt i16 %3, 1\n %4 = zext i1 %cmp35.i to i64\n br label %for.body4.i\n\nfor.cond.cleanup3.i: ; preds = %for.body4.i\n %cmp35.i.1 = icmp sgt i16 %3, 1\n %5 = zext i1 %cmp35.i.1 to i64\n br label %for.body4.i.1\n\nfor.body4.i.1: ; preds = %for.body4.i.1, %for.cond.cleanup3.i\n %indvars.iv2.1 = phi i64 [ %indvars.iv.next3.1, %for.body4.i.1 ], [ 0, %for.cond.cleanup3.i ]\n %gep57.i.1 = getelementptr [5 x i8], ptr %1, i64 %indvars.iv2.1\n store i8 0, ptr %gep57.i.1, align 1\n %indvars.iv.next3.1 = add nsw i64 %indvars.iv2.1, %5\n %cmp2.i.1 = icmp ult i64 %indvars.iv2.1, 5\n br i1 %cmp2.i.1, label %for.body4.i.1, label %common.ret, !llvm.loop !0\n\nfor.body4.i: ; preds = %for.body4.i, %for.cond1.preheader.i.preheader\n %indvars.iv.next3 = or i64 %indvars.iv2, %4\n %cmp2.i = icmp eq i64 %indvars.iv.next3, 0\n br i1 %cmp2.i, label %for.body4.i, label %for.cond.cleanup3.i\n}\n\nattributes #0 = { \"target-features\"=\"+v\" }\n\n!0 = distinct !{!0, !1}\n!1 = !{!\"llvm.loop.mustprogress\"}\n```\n\nCommands/backtrace:\n```\n$ /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt \"-passes=lto<O3>\" reduced.ll\nWARNING: You're attempting to print out a bitcode file.\nThis is inadvisable as it may cause display problems. If\nyou REALLY want to taste LLVM bitcode first-hand, you\ncan force output with the `-f' option.\n\nopt: /scratch/ewlu/daily-upstream-build/llvm/llvm/include/llvm/IR/Value.h:395: llvm::Value::user_iterator llvm::Value::materialized_user_begin(): Assertion `hasUseList()' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.\nStack dump:\n0. Program arguments: /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt -passes=lto<O3> reduced.ll\n1. Running pass \"function<eager-inv>(loop-mssa(licm<allowspeculation>),gvn<>,memcpyopt,dse,move-auto-init,mldst-motion<no-split-footer-bb>,loop(indvars,loop-deletion,loop-unroll-full),loop-distribute,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-arithmetic;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>,sccp,instcombine<max-iterations=1;no-verify-fixpoint>,bdce,slp-vectorizer,vector-combine,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,jump-threading)\" on module \"reduced.ll\"\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\n #0 0x00005ec33c4aee60 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x35fae60)\n #1 0x00005ec33c4abb7a SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007cce27a45330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)\n #3 0x00007cce27a9eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #4 0x00007cce27a9eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #5 0x00007cce27a9eb2c pthread_kill ./nptl/pthread_kill.c:89:10\n #6 0x00007cce27a4527e raise ./signal/../sysdeps/posix/raise.c:27:6\n #7 0x00007cce27a288ff abort ./stdlib/abort.c:81:7\n #8 0x00007cce27a2881b _nl_load_domain ./intl/loadmsgcat.c:1177:9\n #9 0x00007cce27a3b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)\n#10 0x00005ec33a171ad2 (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x12bdad2)\n#11 0x00005ec339f586c5 llvm::LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(std::unique_ptr<llvm::VPlan, std::default_delete<llvm::VPlan>>, llvm::VFRange&, llvm::LoopVersioning*) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x10a46c5)\n#12 0x00005ec339f58e91 llvm::LoopVectorizationPlanner::buildVPlansWithVPRecipes(llvm::ElementCount, llvm::ElementCount) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x10a4e91)\n#13 0x00005ec339f598b4 llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x10a58b4)\n#14 0x00005ec339f60771 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x10ac771)\n#15 0x00005ec339f63b81 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x10afb81)\n#16 0x00005ec339f6402a llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x10b002a)\n#17 0x00005ec339781b83 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x8cdb83)\n#18 0x00005ec33c27c9e3 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x33c89e3)\n#19 0x00005ec3397843b3 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x8d03b3)\n#20 0x00005ec33c27b4a7 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x33c74a7)\n#21 0x00005ec3393f98d3 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x5458d3)\n#22 0x00005ec33c27ada3 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x33c6da3)\n#23 0x00005ec339404af6 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x550af6)\n#24 0x00005ec3393f7a7a optMain (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x543a7a)\n#25 0x00007cce27a2a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3\n#26 0x00007cce27a2a28b call_init ./csu/../csu/libc-start.c:128:20\n#27 0x00007cce27a2a28b __libc_start_main ./csu/../csu/libc-start.c:347:5\n#28 0x00005ec3393ede15 _start (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x539e15)\nAborted\n```\nGodbolt: https://godbolt.org/z/rxYEjMd3K\n\nFound via fuzzer (C program before reduction).\n",
"author": "ewlu",
"labels": [
"crash",
"llvm:analysis"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
Cannot find a good commit
| null |
115279
|
https://github.com/llvm/llvm-project/issues/115279
|
crash
|
a24f6ce743cc2dd311e35894f386c05d0ead089c
| 2024-11-07T08:44:28
|
[
"llvm/test/Transforms/LoopFusion"
] |
{
"fix_commit": "599c2731b3bbe9add135558377dbee2e1fa24358",
"components": [
"LoopFuse"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": [
[
1702,
1707
]
],
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": [
"performFusion"
],
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 599c2731b3bbe9add135558377dbee2e1fa24358
Author: Alireza Torabian <alireza.torabian@huawei.com>
Date: Thu Jan 22 19:50:21 2026 -0500
[LoopFusion] Forget cached SCEV values after the fusion (#177455)
This patch fixes the issue #115279. After the fusion, some of the cached
SCEV values such as the induction variable may not be valid anymore and
need to be forgotten.
diff --git a/llvm/lib/Transforms/Scalar/LoopFuse.cpp b/llvm/lib/Transforms/Scalar/LoopFuse.cpp
index 9c86b73dfc8d..0deeb557ddab 100644
--- a/llvm/lib/Transforms/Scalar/LoopFuse.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopFuse.cpp
@@ -1702,6 +1702,10 @@ private:
// since merging the latches may affect the dispositions.
SE.forgetBlockAndLoopDispositions();
+ // Forget the cached SCEV values including the induction variable that may
+ // have changed after the fusion.
+ SE.forgetLoop(FC0.L);
+
// Merge the loops.
SmallVector<BasicBlock *, 8> Blocks(FC1.L->blocks());
for (BasicBlock *BB : Blocks) {
|
[
{
"file": "llvm/test/Transforms/LoopFusion/pr115279.ll",
"commands": [
"opt -passes=loop-fusion -disable-output -stats < %s 2>&1"
],
"tests": [
{
"test_name": "<module>",
"test_body": "; REQUIRES: asserts\n; STAT: 1 loop-fusion - Loops fused\n\n; C Code\n;\n;; for (i = 0; i < n; i++)\n;; array2[i] = array1[i] * 2;\n;; for (i = 0; i < n; i++)\n;; if (array1[i] % 2 == 0)\n;; array2[i] = array1[i] * array1[i];\n; Loop fusion should not crash due to incorrect cached SCEV values as now\n; forgetLoop() is used to reset them after the fusion.\n\ndefine dso_local noundef i32 @forget_induction_scev(ptr noalias %array1, ptr noalias %array2) {\nentry:\n br label %for.body\n\nfor.body:\n %indvars.iv54 = phi i64 [ %indvars.iv.next55, %for.body ], [ 0, %entry ]\n %arrayidx6 = getelementptr inbounds i32, ptr %array1, i64 %indvars.iv54\n %0 = load i32, ptr %arrayidx6, align 4\n %mul = shl nsw i32 %0, 1\n %arrayidx8 = getelementptr inbounds i32, ptr %array2, i64 %indvars.iv54\n store i32 %mul, ptr %arrayidx8, align 4\n %indvars.iv.next55 = add nuw nsw i64 %indvars.iv54, 1\n %exitcond57.not = icmp eq i64 %indvars.iv.next55, 1024\n br i1 %exitcond57.not, label %for.body14, label %for.body\n\nfor.body14:\n %indvars.iv58 = phi i64 [ %indvars.iv.next59, %for.inc26 ], [ 0, %for.body ]\n %arrayidx16 = getelementptr inbounds i32, ptr %array1, i64 %indvars.iv58\n %1 = load i32, ptr %arrayidx16, align 4\n %2 = and i32 %1, 1\n %cmp18 = icmp eq i32 %2, 0\n br i1 %cmp18, label %if.then, label %for.inc26\n\nif.then:\n %mul23 = mul nsw i32 %1, %1\n %arrayidx25 = getelementptr inbounds i32, ptr %array2, i64 %indvars.iv58\n store i32 %mul23, ptr %arrayidx25, align 4\n br label %for.inc26\n\nfor.inc26:\n %indvars.iv.next59 = add nuw nsw i64 %indvars.iv58, 1\n %exitcond61.not = icmp eq i64 %indvars.iv.next59, 1024\n br i1 %exitcond61.not, label %for.end28, label %for.body14\n\nfor.end28:\n %arrayidx30 = getelementptr inbounds i8, ptr %array2, i64 4092\n %3 = load i32, ptr %arrayidx30, align 4\n ret i32 %3\n}",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[LoopFusion] Assert \"Fused candidate should be eligible for fusion\"",
"body": "To reproduce: https://compiler-explorer.com/z/oqacnTqoa\r\n```opt -S -passes=loop-fusion -debug-only=loop-fusion ``` crashes on the LLVMIR generated from ```clang -O1``` because of an assertion failure\r\nStack Dump:\r\n```\r\nopt: /root/llvm-project/llvm/lib/Transforms/Scalar/LoopFuse.cpp:1038: bool {anonymous}::LoopFuser::fuseCandidates(): Assertion `FusedCand.isEligibleForFusion(SE) && \"Fused candidate should be eligible for fusion!\"' 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 -S -passes=loop-fusion -debug-only=loop-fusion <source>\r\n1.\tRunning pass \"function(loop-fusion)\" on module \"<source>\"\r\n2.\tRunning pass \"loop-fusion\" on function \"main\"\r\n #0 0x000000000513f3c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x513f3c8)\r\n #1 0x000000000513cdbc SignalHandler(int) Signals.cpp:0:0\r\n #2 0x0000719331442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x00007193314969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x0000719331442476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x00007193314287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x000071933142871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x0000719331439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x0000000003d8fdf8 (anonymous namespace)::LoopFuser::fuseCandidates() LoopFuse.cpp:0:0\r\n #9 0x0000000003d90d61 llvm::LoopFusePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3d90d61)\r\n#10 0x0000000002f9003e llvm::detail::PassModel<llvm::Function, llvm::LoopFusePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2f9003e)\r\n#11 0x0000000004f3cde8 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f3cde8)\r\n#12 0x0000000000e3a56e 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+0xe3a56e)\r\n#13 0x0000000004f3b80e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f3b80e)\r\n#14 0x0000000000e39c7e 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+0xe39c7e)\r\n#15 0x0000000004f3b240 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f3b240)\r\n#16 0x00000000009108ea 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+0x9108ea)\r\n#17 0x000000000090324a optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x90324a)\r\n#18 0x0000719331429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#19 0x0000719331429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#20 0x00000000008facce _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8facce)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```\r\nThe IR\r\n```\r\ndefine dso_local noundef i32 @main() local_unnamed_addr #0 {\r\nentry:\r\n %vla48 = alloca [1024 x i32], align 16\r\n %vla149 = alloca [1024 x i32], align 16\r\n br label %for.body\r\n\r\nfor.body:\r\n %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]\r\n %call = tail call i32 @rand() #2\r\n %rem = srem i32 %call, 100\r\n %add = add nsw i32 %rem, 1\r\n %arrayidx = getelementptr inbounds i32, ptr %vla48, i64 %indvars.iv\r\n store i32 %add, ptr %arrayidx, align 4\r\n %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1\r\n %exitcond.not = icmp eq i64 %indvars.iv.next, 1024\r\n br i1 %exitcond.not, label %for.body4, label %for.body\r\n\r\nfor.body4:\r\n %indvars.iv54 = phi i64 [ %indvars.iv.next55, %for.body4 ], [ 0, %for.body ]\r\n %arrayidx6 = getelementptr inbounds i32, ptr %vla48, i64 %indvars.iv54\r\n %0 = load i32, ptr %arrayidx6, align 4\r\n %mul = shl nsw i32 %0, 1\r\n %arrayidx8 = getelementptr inbounds i32, ptr %vla149, i64 %indvars.iv54\r\n store i32 %mul, ptr %arrayidx8, align 4\r\n %indvars.iv.next55 = add nuw nsw i64 %indvars.iv54, 1\r\n %exitcond57.not = icmp eq i64 %indvars.iv.next55, 1024\r\n br i1 %exitcond57.not, label %for.body14, label %for.body4\r\n\r\nfor.body14:\r\n %indvars.iv58 = phi i64 [ %indvars.iv.next59, %for.inc26 ], [ 0, %for.body4 ]\r\n %arrayidx16 = getelementptr inbounds i32, ptr %vla48, i64 %indvars.iv58\r\n %1 = load i32, ptr %arrayidx16, align 4\r\n %2 = and i32 %1, 1\r\n %cmp18 = icmp eq i32 %2, 0\r\n br i1 %cmp18, label %if.then, label %for.inc26\r\n\r\nif.then:\r\n %mul23 = mul nsw i32 %1, %1\r\n %arrayidx25 = getelementptr inbounds i32, ptr %vla149, i64 %indvars.iv58\r\n store i32 %mul23, ptr %arrayidx25, align 4\r\n br label %for.inc26\r\n\r\nfor.inc26:\r\n %indvars.iv.next59 = add nuw nsw i64 %indvars.iv58, 1\r\n %exitcond61.not = icmp eq i64 %indvars.iv.next59, 1024\r\n br i1 %exitcond61.not, label %for.end28, label %for.body14\r\n\r\nfor.end28:\r\n %arrayidx30 = getelementptr inbounds i8, ptr %vla149, i64 4092\r\n %3 = load i32, ptr %arrayidx30, align 4\r\n ret i32 %3\r\n}\r\n\r\ndeclare i32 @rand() local_unnamed_addr #1\r\n\r\nattributes #0 = { mustprogress norecurse nounwind uwtable \"min-legal-vector-width\"=\"0\" \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"x86-64\" \"target-features\"=\"+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87\" \"tune-cpu\"=\"generic\" }\r\nattributes #1 = { nounwind \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"x86-64\" \"target-features\"=\"+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87\" \"tune-cpu\"=\"generic\" }\r\nattributes #2 = { nounwind }\r\n```\r\n\r\nThis is generated from the cpp program:\r\n```cpp\r\n#include <random>\r\n\r\nint main() {\r\n int n = 1024;\r\n int array1[n];\r\n int array2[n];\r\n int i;\r\n for (i = 0; i < n; i++) {\r\n array1[i] = std::rand() % 100 + 1;\r\n }\r\n for (i = 0; i < n; i++) {\r\n array2[i] = array1[i] * 2;\r\n }\r\n for (i = 0; i < n; i++) {\r\n if (array1[i] % 2 == 0) {\r\n array2[i] = array1[i] * array1[i];\r\n } \r\n }\r\n return array2[n-1];\r\n}\r\n```",
"author": "zitongzhoueric",
"labels": [
"loopoptim",
"crash",
"loop-fusion"
],
"comments": [
{
"author": "kasuga-fj",
"body": "I did a quick check and it looks like the SCEV cache is not invalidated properly. I added `SE.forgetLoop(FC0.L)` after `mergeLatch`, which resolved the problem. But I'm not sure if this is a proper fix, and I don't understand the comment `Note: Need to forget the loops before merging the loop latches, ...` in the code.\nhttps://github.com/llvm/llvm-project/blob/cb4ae35de0b4c19149379f16c7b279d80a669f9d/llvm/lib/Transforms/Scalar/LoopFuse.cpp#L1725-L1737"
},
{
"author": "madhur13490",
"body": "Looking into this."
},
{
"author": "1997alireza",
"body": "The issue is fixed by PR #177455. Close it now."
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null | null |
114901
|
https://github.com/llvm/llvm-project/issues/114901
|
miscompilation
|
a88be11eef59b1722030e1219109ea0b76eebbe5
| 2024-11-05T00:44:52
|
[
"llvm/test/Transforms/VectorCombine"
] |
{
"fix_commit": "05e838f428555bcc4507bd37912da60ea9110ef6",
"components": [
"VectorCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [
[
1032,
1040
],
[
1113,
1120
]
],
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [
"VectorCombine::foldExtractedCmps"
],
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 05e838f428555bcc4507bd37912da60ea9110ef6
Author: Simon Pilgrim <llvm-dev@redking.me.uk>
Date: Tue Nov 5 11:42:20 2024 +0000
[VectorCombine] foldExtractedCmps - disable fold on non-commutative binops
The fold needs to be adjusted to correctly track the LHS/RHS operands, which will take some refactoring, for now just disable the fold in this case.
Fixes #114901
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index 025234c54956..332c52040e21 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -1032,9 +1032,15 @@ bool VectorCombine::scalarizeBinopOrCmp(Instruction &I) {
/// a vector into vector operations followed by extract. Note: The SLP pass
/// may miss this pattern because of implementation problems.
bool VectorCombine::foldExtractedCmps(Instruction &I) {
+ auto *BI = dyn_cast<BinaryOperator>(&I);
+
// We are looking for a scalar binop of booleans.
// binop i1 (cmp Pred I0, C0), (cmp Pred I1, C1)
- if (!I.isBinaryOp() || !I.getType()->isIntegerTy(1))
+ if (!BI || !I.getType()->isIntegerTy(1))
+ return false;
+
+ // TODO: Support non-commutative binary ops.
+ if (!BI->isCommutative())
return false;
// The compare predicates should match, and each compare should have a
@@ -1113,8 +1119,7 @@ bool VectorCombine::foldExtractedCmps(Instruction &I) {
Value *VCmp = Builder.CreateCmp(Pred, X, ConstantVector::get(CmpC));
Value *Shuf = createShiftShuffle(VCmp, ExpensiveIndex, CheapIndex, Builder);
- Value *VecLogic = Builder.CreateBinOp(cast<BinaryOperator>(I).getOpcode(),
- VCmp, Shuf);
+ Value *VecLogic = Builder.CreateBinOp(BI->getOpcode(), VCmp, Shuf);
Value *NewExt = Builder.CreateExtractElement(VecLogic, CheapIndex);
replaceValue(I, *NewExt);
++NumVecCmpBO;
|
[
{
"file": "llvm/test/Transforms/VectorCombine/X86/pr114901.ll",
"commands": [
"opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=sse2",
"opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=avx2"
],
"tests": [
{
"test_name": "PR114901",
"test_body": "define i1 @PR114901(<4 x i32> %a) {\n %e1 = extractelement <4 x i32> %a, i32 1\n %e3 = extractelement <4 x i32> %a, i32 3\n %cmp1 = icmp sgt i32 %e1, -8\n %cmp3 = icmp sgt i32 %e3, 42\n %r = ashr i1 %cmp3, %cmp1\n ret i1 %r\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[VectorCombine] miscompilation",
"body": "Alive2 report: https://alive2.llvm.org/ce/z/YwSTI4\r\n\r\n```llvm\r\n----------------------------------------\r\ndefine i1 @icmp_xor_v4i32.2(<4 x i32> %a) {\r\n#0:\r\n %e1 = extractelement <4 x i32> %a, i32 3\r\n %e2 = extractelement <4 x i32> %a, i32 1\r\n %cmp1 = icmp sgt i32 %e1, 42\r\n %cmp2 = icmp sgt i32 %e2, 4294967288\r\n %#1 = ashr i1 %cmp1, %cmp2\r\n ret i1 %#1\r\n}\r\n=>\r\ndefine i1 @icmp_xor_v4i32.2(<4 x i32> %a) {\r\n#0:\r\n %#1 = icmp sgt <4 x i32> %a, { poison, 4294967288, poison, 42 }\r\n %shift = shufflevector <4 x i1> %#1, <4 x i1> poison, 4294967295, 3, 4294967295, 4294967295\r\n %#2 = ashr <4 x i1> %#1, %shift\r\n %#3 = extractelement <4 x i1> %#2, i64 1\r\n ret i1 %#3\r\n}\r\nTransformation doesn't verify!\r\n\r\nERROR: Target is more poisonous than source\r\n\r\nExample:\r\n<4 x i32> %a = < #x00000000 (0), #xfffffff8 (4294967288, -8), #x00000000 (0), #x0000002b (43) >\r\n\r\nSource:\r\ni32 %e1 = #x0000002b (43)\r\ni32 %e2 = #xfffffff8 (4294967288, -8)\r\ni1 %cmp1 = #x1 (1)\r\ni1 %cmp2 = #x0 (0)\r\ni1 %#1 = #x1 (1)\r\n\r\nTarget:\r\n<4 x i1> %#1 = < poison, #x0 (0), poison, #x1 (1) >\r\n<4 x i1> %shift = < poison, #x1 (1), poison, poison >\r\n<4 x i1> %#2 = < poison, poison, poison, poison >\r\ni1 %#3 = poison\r\nSource value: #x1 (1)\r\nTarget value: poison\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": "bongjunj",
"labels": [
"miscompilation"
],
"comments": [
{
"author": "RKSimon",
"body": "It looks like the ashr operands have been commuted in the fold - will take a look later today"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
Cannot find a good commit
| null |
161492
|
https://github.com/llvm/llvm-project/issues/161492
|
miscompilation
|
c09054866a1ad6c250e6c972d369b9023abb4b3b
| 2025-10-01T08:52:18
|
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "73d9974c91413f5a6dbe6f76f4b73ad226b6276b",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": [
[
5212,
5218
],
[
5225,
5230
]
],
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": [
"InstCombinerImpl::visitFreeze"
],
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 73d9974c91413f5a6dbe6f76f4b73ad226b6276b
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Wed Oct 1 22:02:30 2025 +0800
[InstCombine] Avoid self-replacing in `getUndefReplacement` (#161500)
Self-replacing has a different meaning in InstCombine. It will replace
all uses with poison.
Closes https://github.com/llvm/llvm-project/issues/161492.
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index ff063f929347..5d2d79e42093 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -5212,7 +5212,7 @@ Instruction *InstCombinerImpl::visitFreeze(FreezeInst &I) {
else if (match(U, m_Select(m_Specific(&I), m_Constant(), m_Value())))
V = ConstantInt::getTrue(Ty);
else if (match(U, m_c_Select(m_Specific(&I), m_Value(V)))) {
- if (!isGuaranteedNotToBeUndefOrPoison(V, &AC, &I, &DT))
+ if (V == &I || !isGuaranteedNotToBeUndefOrPoison(V, &AC, &I, &DT))
V = NullValue;
} else if (auto *PHI = dyn_cast<PHINode>(U)) {
if (Value *MaybeV = pickCommonConstantFromPHI(*PHI))
@@ -5225,6 +5225,7 @@ Instruction *InstCombinerImpl::visitFreeze(FreezeInst &I) {
BestValue = NullValue;
}
assert(BestValue && "Must have at least one use");
+ assert(BestValue != &I && "Cannot replace with itself");
return BestValue;
};
|
[
{
"file": "llvm/test/Transforms/InstCombine/freeze.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "pr161492_2",
"test_body": "define i64 @pr161492_2(i1 %cond) {\n %fr = freeze i64 poison\n %ret = select i1 %cond, i64 %fr, i64 %fr\n ret i64 %ret\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "pr161492_1",
"test_body": "define i64 @pr161492_1(i1 %cond) {\n %fr1 = freeze i64 poison\n %fr2 = freeze i64 poison\n %ret = select i1 %cond, i64 %fr1, i64 %fr2\n ret i64 %ret\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "freeze_ptrmask_nonnull",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare ptr @llvm.ptrmask.p0.i64(ptr, i64) #0\n\ndefine ptr @freeze_ptrmask_nonnull(ptr %p, i64 noundef %m) {\n %mask = call nonnull ptr @llvm.ptrmask.p0.i64(ptr %p, i64 %m)\n %fr = freeze ptr %mask\n ret ptr %fr\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[InstCombine] Miscompilation when removing freezes",
"body": "Reproducer: https://alive2.llvm.org/ce/z/3napog\n```\ndefine i64 @src(i1 %cond) {\n %1 = freeze i64 poison\n %2 = freeze i64 poison\n %ret = select i1 %cond, i64 %1, i64 %2\n ret i64 %ret\n}\n\ndefine i64 @tgt(i1 %cond) {\n ret i64 poison\n}\n```\nllvm version: 69586331e868cef99fbcea74a061bd44f57c1904\n",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:instcombine",
"generated by fuzzer"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
Unrelated
| null |
164171
|
https://github.com/llvm/llvm-project/issues/164171
|
crash
|
94647eea7fc0fcdf1c953b8ff6bd6ef9981d7890
| 2025-10-19T18:02:40
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "9fe1f29541109ac10e1399deb85da0507135f836",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": [
[
325,
330
]
],
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": [
"createWidenCast"
],
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 9fe1f29541109ac10e1399deb85da0507135f836
Author: Luke Lau <luke@igalia.com>
Date: Mon Oct 20 18:39:16 2025 +0800
[VPlan] Set flags when constructing zexts using VPWidenCastRecipe (#164198)
createWidenCast doesn't set the flag type, so when we simplify trunc
(zext nneg x) -> zext x we would hit an assertion in CSE that the flag
types don't match with other VPWidenCastRecipes that weren't simplified.
This fixes it the same way trunc flags are handled too.
As an aside I think it should be correct to preserve the nneg flag in
this case since the input operand is still non-negative after the
transform. But that's left to another PR.
Fixes https://github.com/llvm/llvm-project/issues/164171
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h b/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
index 7651ba16b35c..3fed003282f2 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
@@ -325,6 +325,8 @@ public:
VPIRFlags Flags;
if (Opcode == Instruction::Trunc)
Flags = VPIRFlags::TruncFlagsTy(false, false);
+ else if (Opcode == Instruction::ZExt)
+ Flags = VPIRFlags::NonNegFlagsTy(false);
return tryInsertInstruction(
new VPWidenCastRecipe(Opcode, Op, ResultTy, Flags));
}
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/cse-casts.ll",
"commands": [
"opt -p loop-vectorize -force-vector-width=4 -force-vector-interleave=2 -S %s"
],
"tests": [
{
"test_name": "preserve_flags_narrowing_extends_and_truncs",
"test_body": "define void @preserve_flags_narrowing_extends_and_truncs(ptr noalias %A, ptr noalias %B, ptr noalias %C) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep.A = getelementptr inbounds i8, ptr %A, i64 %iv\n %l = load i8, ptr %gep.A, align 1\n %l.ext = zext i8 %l to i64\n %gep.C = getelementptr inbounds i8, ptr %C, i64 %iv\n store i64 %l.ext, ptr %gep.C, align 4\n %gep.B = getelementptr inbounds i8, ptr %B, i64 %iv\n %l.1 = load i8, ptr %gep.B, align 1\n %masked = and i8 %l.1, 1\n %l.1.trunc = trunc i8 %l.1 to i1\n %sel.0 = select i1 %l.1.trunc, float 1.000000e+00, float 0.000000e+00\n %masked.trunc = trunc i8 %masked to i1\n %sel.1 = select i1 %masked.trunc, float 3.000000e+00, float %sel.0\n %bc = bitcast float %sel.1 to i32\n %bc.trunc = trunc i32 %bc to i8\n store i8 %bc.trunc, ptr %gep.B, align 1\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv, 1\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "simplified_cast_preserves_irflag_type",
"test_body": "define void @simplified_cast_preserves_irflag_type(ptr noalias %p, ptr noalias %q, ptr noalias %r) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %x = load i8, ptr %p, align 1\n %x.i32 = zext i8 %x to i32\n %trunc = trunc i32 %x.i32 to i16\n store i16 %trunc, ptr %q, align 2\n %x.i16 = zext i8 %x to i16\n store i16 %x.i16, ptr %r, align 2\n %iv.next = add i64 %iv, 2\n %ec = icmp eq i64 %iv.next, 100\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[LV] Assert \"OpType must match\" in VPIRFlags::intersectFlags",
"body": "This IR:\n\n```\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32\"\ntarget triple = \"aarch64-unknown-linux-gnu\"\n\ndefine void @_Z1hiPA2_bPA2_c(ptr %arrayidx6, ptr %arrayidx20) {\nentry:\n br label %for.body\n\nfor.cond.cleanup.loopexit: ; preds = %for.body\n ret void\n\nfor.body: ; preds = %for.body, %entry\n %indvars.iv1 = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]\n %0 = load i8, ptr %arrayidx6, align 1\n %loadedv = zext i8 %0 to i32\n %conv9 = trunc i32 %loadedv to i16\n store i16 %conv9, ptr null, align 2\n %1 = zext i8 %0 to i16\n store i16 %1, ptr %arrayidx20, align 2\n %indvars.iv.next = add i64 %indvars.iv1, 2\n %tobool.not = icmp eq i64 %indvars.iv.next, 0\n br i1 %tobool.not, label %for.cond.cleanup.loopexit, label %for.body\n}\n```\n\nCompiled with `opt --passes=loop-vectorize -S `will triggers this assert:\n\n```\nopt: /root/llvm-project/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp:404: void llvm::VPIRFlags::intersectFlags(const llvm::VPIRFlags&): Assertion `OpType == Other.OpType && \"OpType must match\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.\nStack dump:\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 \"_Z1hiPA2_bPA2_c\"\n #0 0x0000000005944c48 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5944c48)\n #1 0x0000000005941af4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x0000718d16242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x0000718d162969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x0000718d16242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x0000718d162287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x0000718d1622871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x0000718d16239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x00000000038376c4 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x38376c4)\n #9 0x0000000003888c73 llvm::VPlanTransforms::cse(llvm::VPlan&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3888c73)\n#10 0x000000000367d30e llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x367d30e)\n```\n\nSee also: https://godbolt.org/z/nxzGcccff\n\nCan be triggered from source-code:\n\n```\n#include <algorithm>\nshort a;\nextern short b[];\nint c;\nvoid h(int d, bool e[][2], char f[][2]) {\n#pragma clang loop vectorize_predicate(enable)\n for (int g(d); g; g += 2) {\n a = f[g][g] - e[g][g] - c;\n b[g] = std::max(d ? (unsigned long long)e[g][g] : 0, (unsigned long long)0);\n }\n}\n```",
"author": "sjoerdmeijer",
"labels": [
"vectorizers",
"crash-on-valid"
],
"comments": [
{
"author": "sjoerdmeijer",
"body": "CC: @fhahn "
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
c3e76b27709f93c9e945caa29dae596b581289e2
| null |
97452
|
https://github.com/llvm/llvm-project/issues/97452
|
crash
|
5c204b1d2619cbad7b7ad228b62feae08781a6db
| 2024-07-02T17:49:01
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "2b3b405b09a0d965a4aff1f92958418ddbf1e7f6",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
[
6813,
6818
]
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"LoopVectorizationCostModel::getInstructionCost"
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 2b3b405b09a0d965a4aff1f92958418ddbf1e7f6
Author: Florian Hahn <flo@fhahn.com>
Date: Thu Jul 4 11:44:50 2024 +0100
[LV] Don't vectorize first-order recurrence with VF <vscale x 1 x ..>
The assertion added as part of https://github.com/llvm/llvm-project/pull/93395
surfaced cases where first-order recurrences are vectorized with
<vscale x 1 x ..>. If vscale is 1, then we are unable to extract the
penultimate value (second to last lane). Previously this case got
mis-compiled, trying to extract from an invalid lane (-1)
https://llvm.godbolt.org/z/3adzYYcf9.
Fixes https://github.com/llvm/llvm-project/issues/97452.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index f9c0c66e6e0a..d7b0240fd8a8 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -6813,6 +6813,11 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I, ElementCount VF,
// First-order recurrences are replaced by vector shuffles inside the loop.
if (VF.isVector() && Legal->isFixedOrderRecurrence(Phi)) {
+ // For <vscale x 1 x i64>, if vscale = 1 we are unable to extract the
+ // penultimate value of the recurrence.
+ // TODO: Consider vscale_range info.
+ if (VF.isScalable() && VF.getKnownMinValue() == 1)
+ return InstructionCost::getInvalid();
SmallVector<int> Mask(VF.getKnownMinValue());
std::iota(Mask.begin(), Mask.end(), VF.getKnownMinValue() - 1);
return TTI.getShuffleCost(TargetTransformInfo::SK_Splice,
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/RISCV/first-order-recurrence-scalable-vf1.ll",
"commands": [
"opt -p loop-vectorize -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; Make sure we do not pick <vscale x 1 x i64> as VF for a loop with a\n; first-order recurrence.\ndefine i64 @pr97452_scalable_vf1_for(ptr %src) #0 {\n;\nentry:\n br label %loop\n\nloop:\n %for = phi i64 [ 0, %entry ], [ %l, %loop ]\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.next = add i64 %iv, 1\n %gep = getelementptr inbounds i64, ptr %src, i64 %iv\n %l = load i64, ptr %gep, align 8\n %ec = icmp eq i64 %iv, 22\n br i1 %ec, label %exit, label %loop\n\nexit:\n %res = phi i64 [ %for, %loop ]\n ret i64 %res\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v,+zvl128b,+zvl256b\" }\n;.\n;.",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/first-order-recurrence-scalable-vf1.ll",
"commands": [
"opt -p loop-vectorize -scalable-vectorization=on -force-vector-width=1 -force-target-supports-scalable-vectors=true -S %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\n\ndefine i64 @pr97452_scalable_vf1_for_live_out(ptr %src) {\n;\nentry:\n br label %loop\n\nloop:\n %for = phi i64 [ 0, %entry ], [ %l, %loop ]\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.next = add i64 %iv, 1\n %gep = getelementptr inbounds i64, ptr %src, i64 %iv\n %l = load i64, ptr %gep, align 8\n %ec = icmp eq i64 %iv, 22\n br i1 %ec, label %exit, label %loop\n\nexit:\n %res = phi i64 [ %for, %loop ]\n ret i64 %res\n}\n\n\ndefine void @pr97452_scalable_vf1_for_no_live_out(ptr %src, ptr noalias %dst) {\n;\nentry:\n br label %loop\n\nloop:\n %for = phi i64 [ 0, %entry ], [ %l, %loop ]\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.next = add i64 %iv, 1\n %gep = getelementptr inbounds i64, ptr %src, i64 %iv\n %l = load i64, ptr %gep, align 8\n %gep.dst = getelementptr inbounds i64, ptr %dst, i64 %iv\n store i64 %l, ptr %gep.dst\n %ec = icmp eq i64 %iv, 22\n br i1 %ec, label %exit, label %loop\n\nexit:\n ret void\n}",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[LoopVectorize] Assertion `Offset <= State.VF.getKnownMinValue() && \"invalid offset to extract from\"' failed.",
"body": "Reduced testcase:\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.body\r\n\r\nfor.cond.cleanup: ; preds = %for.body\r\n %.lcssa17 = phi i64 [ %0, %for.body ]\r\n ret i32 0\r\n\r\nfor.body: ; preds = %for.body, %entry\r\n %0 = phi i64 [ 0, %entry ], [ %1, %for.body ]\r\n %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]\r\n %indvars.iv.next = add i64 %indvars.iv, 1\r\n %1 = load i64, ptr null, align 8\r\n %exitcond.not = icmp eq i64 %indvars.iv, 22\r\n br i1 %exitcond.not, label %for.cond.cleanup, label %for.body\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+v,+zvl128b,+zvl256b\" }\r\n```\r\n\r\nCommand/backtrace:\r\n```bash\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize reduced.ll\r\nWARNING: You're attempting to print out a bitcode file.\r\nThis is inadvisable as it may cause display problems. If\r\nyou REALLY want to taste LLVM bitcode first-hand, you\r\ncan force output with the `-f' option.\r\n\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp:569: llvm::Value* llvm::VPInstruction::generatePerPart(llvm::VPTransformState&, unsigned int): Assertion `Offset <= State.VF.getKnownMinValue() && \"invalid offset to extract from\"' 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\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 0x000055972ae01800 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2ed2800)\r\n #1 0x000055972adfec0f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2ecfc0f)\r\n #2 0x000055972adfed65 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x0000728161442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007281614969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007281614969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007281614969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x0000728161442476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007281614287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x000072816142871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x0000728161439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x0000559729f62d80 llvm::VPInstruction::generatePerPart(llvm::VPTransformState&, unsigned int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2033d80)\r\n#12 0x0000559729f63155 llvm::VPInstruction::execute(llvm::VPTransformState&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2034155)\r\n#13 0x0000559729f2de47 llvm::VPBasicBlock::executeRecipes(llvm::VPTransformState*, llvm::BasicBlock*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1ffee47)\r\n#14 0x0000559729f2e141 llvm::VPIRBasicBlock::execute(llvm::VPTransformState*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1fff141)\r\n#15 0x0000559729f30286 llvm::VPlan::execute(llvm::VPTransformState*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2001286)\r\n#16 0x0000559729e2380a llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool, llvm::DenseMap<llvm::SCEV const*, llvm::Value*, llvm::DenseMapInfo<llvm::SCEV const*, void>, llvm::detail::DenseMapPair<llvm::SCEV const*, llvm::Value*>> const*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1ef480a)\r\n#17 0x0000559729e34a7c llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f05a7c)\r\n#18 0x0000559729e36f7e 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-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f07f7e)\r\n#19 0x0000559729e380a0 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f090a0)\r\n#20 0x0000559728cc6dc6 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+0xd97dc6)\r\n#21 0x000055972ac1ce46 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+0x2cede46)\r\n#22 0x0000559728cc9f56 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+0xd9af56)\r\n#23 0x000055972ac1bbcb llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2cecbcb)\r\n#24 0x0000559728cc6526 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+0xd97526)\r\n#25 0x000055972ac19d02 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+0x2cead02)\r\n#26 0x0000559728520136 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+0x5f1136)\r\n#27 0x0000559728511d51 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5e2d51)\r\n#28 0x0000728161429d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#29 0x0000728161429e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#30 0x0000728161429e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#31 0x0000559728507b85 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5d8b85)\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/ojz8sMa1r\r\n\r\nFound via fuzzer",
"author": "patrick-rivos",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "svs-quic",
"body": "Bisected to #93395 \r\ncc: @fhahn "
},
{
"author": "fhahn",
"body": "Thanks for the test case. Should be fixed now. The assertion highlighted a case where we previously miscompiled for the case where VF is <vscale x 1 x ..>; in that case we are unable to extract the penultimate value (second-to-last) if vscale = 1"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
07b330132c0b7fd5b3ada1890840d0dbbd8cdb8e
| null |
155287
|
https://github.com/llvm/llvm-project/issues/155287
|
crash
|
cdb18705fc81018303e1089bbae0a2ae2fd201af
| 2025-08-25T20:29:01
|
[
"llvm/test/Transforms/LoopIdiom"
] |
{
"fix_commit": "b29084f0d80dd4fd66f1421350c87f79c537d071",
"components": [
"ScalarEvolution"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": [
[
1239,
1248
]
],
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": [
"SCEVExpander::tryToReuseLCSSAPhi"
],
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit b29084f0d80dd4fd66f1421350c87f79c537d071
Author: Florian Hahn <flo@fhahn.com>
Date: Tue Aug 26 11:38:39 2025 +0100
[SCEVExp] Check if getPtrToIntExpr resulted in CouldNotCompute.
This fixes a crash trying to use SCEVCouldNotCompute, if getPtrToIntExpr
failed.
Fixes https://github.com/llvm/llvm-project/issues/155287
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index 060ca92e559a..3e3d51bffff3 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -1239,10 +1239,13 @@ Value *SCEVExpander::tryToReuseLCSSAPhi(const SCEVAddRecExpr *S) {
if (!isa<SCEVAddRecExpr>(ExitSCEV))
continue;
Type *PhiTy = PN.getType();
- if (STy->isIntegerTy() && PhiTy->isPointerTy())
+ if (STy->isIntegerTy() && PhiTy->isPointerTy()) {
ExitSCEV = SE.getPtrToIntExpr(ExitSCEV, STy);
- else if (S->getType() != PN.getType())
+ if (isa<SCEVCouldNotCompute>(ExitSCEV))
+ continue;
+ } else if (S->getType() != PN.getType()) {
continue;
+ }
// Check if we can re-use the existing PN, by adjusting it with an expanded
// offset, if the offset is simpler.
|
[
{
"file": "llvm/test/Transforms/LoopIdiom/reuse-lcssa-phi-scev-expansion.ll",
"commands": [
"opt -p loop-idiom -S %s"
],
"tests": [
{
"test_name": "phi_ptr_addressspace_ptrtoint_fail",
"test_body": "target datalayout = \"e-m:e-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\n\ndefine void @phi_ptr_addressspace_ptrtoint_fail(ptr addrspace(1) %arg) {\nbb:\n br label %loop.1\n\nloop.1: ; preds = %loop.1, %bb\n %iv.1 = phi i64 [ 0, %bb ], [ %add5, %loop.1 ]\n %add5 = add i64 %iv.1, 1\n %getelementptr = getelementptr i16, ptr addrspace(1) %arg, i64 %add5\n br i1 false, label %loop.1, label %loop.2.ph\n\nloop.2.ph: ; preds = %loop.1\n %phi = phi ptr addrspace(1) [ %getelementptr, %loop.1 ]\n br label %loop.2.header\n\nloop.2.header: ; preds = %loop.2.latch, %loop.2.ph\n %iv.2 = phi i64 [ %iv.1, %loop.2.ph ], [ %iv.2.next, %loop.2.latch ]\n %grep.arg = getelementptr i32, ptr addrspace(1) %arg, i64 %iv.2\n store i32 0, ptr addrspace(1) %grep.arg, align 4\n %ec = icmp ult i64 %iv.2, 1\n br i1 %ec, label %loop.2.latch, label %exit\n\nloop.2.latch: ; preds = %loop.2.header\n %iv.2.next = add i64 %iv.2, 1\n br label %loop.2.header\n\nexit: ; preds = %loop.2.header\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "Attempt to use a SCEVCouldNotCompute object! UNREACHABLE executed at /root/llvm-project/llvm/lib/Analysis/ScalarEvolution.cpp:412!",
"body": "To reproduce run opt with the test below, -passes=loop-idiom.\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 i32 @wombat(ptr addrspace(1) %arg) gc \"statepoint-example\" {\nbb:\n br label %bb2\n\nbb1: ; preds = %bb2\n %phi = phi ptr addrspace(1) [ %getelementptr, %bb2 ]\n br label %bb7\n\nbb2: ; preds = %bb2, %bb\n %phi3 = phi i64 [ 0, %bb ], [ %add5, %bb2 ]\n %phi4 = phi i64 [ 0, %bb ], [ %add, %bb2 ]\n %add = add i64 %phi4, 1\n %getelementptr = getelementptr i16, ptr addrspace(1) null, i64 %add\n %add5 = add i64 %phi3, 1\n br i1 false, label %bb2, label %bb1\n\nbb6: ; preds = %bb7\n ret i32 0\n\nbb7: ; preds = %bb10, %bb1\n %phi8 = phi i64 [ %phi3, %bb1 ], [ %add11, %bb10 ]\n %getelementptr9 = getelementptr i32, ptr addrspace(1) %arg, i64 %phi8\n store i32 0, ptr addrspace(1) %getelementptr9, align 4\n %icmp = icmp ult i64 %phi8, 1\n br i1 %icmp, label %bb10, label %bb6\n\nbb10: ; preds = %bb7\n %add11 = add i64 %phi8, 1\n br label %bb7\n}\n```\nReproducer: https://godbolt.org/z/qrWxb665W\nStack dump:\n```\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=loop-idiom <source>\n1.\tRunning pass \"function(loop(loop-idiom))\" on module \"<source>\"\n2.\tRunning pass \"loop(loop-idiom)\" on function \"wombat\"\n #0 0x00000000056fda38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x56fda38)\n #1 0x00000000056fa8e4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x000072a056242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x000072a0562969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x000072a056242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x000072a0562287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x0000000005634fda (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5634fda)\n #7 0x0000000004d415be llvm::SCEV::getType() const (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d415be)\n #8 0x0000000004d8c80e llvm::ScalarEvolution::getMinusSCEV(llvm::SCEV const*, llvm::SCEV const*, llvm::SCEV::NoWrapFlags, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d8c80e)\n #9 0x00000000049c63d8 llvm::SCEVExpander::tryToReuseLCSSAPhi(llvm::SCEVAddRecExpr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x49c63d8)\n#10 0x00000000049cb858 llvm::SCEVExpander::visitAddRecExpr(llvm::SCEVAddRecExpr const*) (.part.0) ScalarEvolutionExpander.cpp:0:0\n#11 0x00000000049c5455 llvm::SCEVVisitor<llvm::SCEVExpander, llvm::Value*>::visit(llvm::SCEV const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x49c5455)\n#12 0x00000000049c60fd llvm::SCEVExpander::expand(llvm::SCEV const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x49c60fd)\n#13 0x00000000049cb0f3 llvm::SCEVExpander::expandAddToGEP(llvm::SCEV const*, llvm::Value*, llvm::SCEV::NoWrapFlags) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x49cb0f3)\n#14 0x00000000049cc095 llvm::SCEVExpander::visitAddRecExpr(llvm::SCEVAddRecExpr const*) (.part.0) ScalarEvolutionExpander.cpp:0:0\n#15 0x00000000049c5455 llvm::SCEVVisitor<llvm::SCEVExpander, llvm::Value*>::visit(llvm::SCEV const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x49c5455)\n#16 0x00000000049c60fd llvm::SCEVExpander::expand(llvm::SCEV const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x49c60fd)\n#17 0x00000000049cc928 llvm::SCEVExpander::expandCodeFor(llvm::SCEV const*, llvm::Type*, llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>, false, false>) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x49cc928)\n#18 0x0000000004494e77 (anonymous namespace)::LoopIdiomRecognize::processLoopStridedStore(llvm::Value*, llvm::SCEV const*, llvm::MaybeAlign, llvm::Value*, llvm::Instruction*, llvm::SmallPtrSetImpl<llvm::Instruction*>&, llvm::SCEVAddRecExpr const*, llvm::SCEV const*, bool, bool) LoopIdiomRecognize.cpp:0:0\n#19 0x0000000004498c11 (anonymous namespace)::LoopIdiomRecognize::processLoopStores(llvm::SmallVectorImpl<llvm::StoreInst*>&, llvm::SCEV const*, (anonymous namespace)::LoopIdiomRecognize::ForMemset) LoopIdiomRecognize.cpp:0:0\n#20 0x00000000044997b4 (anonymous namespace)::LoopIdiomRecognize::runOnCountableLoop() LoopIdiomRecognize.cpp:0:0\n#21 0x000000000449b0fd llvm::LoopIdiomRecognizePass::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x449b0fd)\n#22 0x0000000002e085be llvm::detail::PassModel<llvm::Loop, llvm::LoopIdiomRecognizePass, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2e085be)\n#23 0x00000000044c0406 std::optional<llvm::PreservedAnalyses> llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::runSinglePass<llvm::Loop, std::unique_ptr<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, std::default_delete<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>>>>(llvm::Loop&, std::unique_ptr<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, std::default_delete<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>>>&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&, llvm::PassInstrumentation&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x44c0406)\n#24 0x00000000044c05ef llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::runWithoutLoopNestPasses(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x44c05ef)\n#25 0x00000000044c1d54 llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x44c1d54)\n#26 0x00000000044c2860 llvm::FunctionToLoopPassAdaptor::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x44c2860)\n#27 0x0000000000ed957e llvm::detail::PassModel<llvm::Function, llvm::FunctionToLoopPassAdaptor, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xed957e)\n#28 0x00000000054eb6c1 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x54eb6c1)\n#29 0x0000000000ed969e 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+0xed969e)\n#30 0x00000000054ebd0a llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x54ebd0a)\n#31 0x000000000096d56e 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+0x96d56e)\n#32 0x00000000054e9771 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x54e9771)\n#33 0x000000000097780a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x97780a)\n#34 0x000000000096b8d7 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x96b8d7)\n#35 0x000072a056229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#36 0x000072a056229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#37 0x00000000009629f5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9629f5)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```",
"author": "TatyanaDoubts",
"labels": [
"llvm:SCEV",
"crash"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
e21ee41be450f849f5247aafa07d7f4c3941bb9d
| null |
96294
|
https://github.com/llvm/llvm-project/issues/96294
|
crash
|
5262865aac683b72f3e66de7a122e0c455ab6b9b
| 2024-06-21T10:15:21
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "fdb9f96fa2a926425bdf8315048db7623d63547d",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
[
6723,
6736
],
[
6771,
6776
],
[
6781,
6788
]
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"LoopVectorizationCostModel::collectValuesToIgnore"
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit fdb9f96fa2a926425bdf8315048db7623d63547d
Author: Florian Hahn <flo@fhahn.com>
Date: Sun Aug 4 20:54:25 2024 +0100
[LV] Consider earlier stores to invariant reduction address as dead.
For invariant stores to an address of a reduction, only the latest store
will be generated outside the loop. Consider earlier stores as dead.
This fixes a difference between the legacy and VPlan-based cost model.
Fixes https://github.com/llvm/llvm-project/issues/96294.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 40d10395de17..1eca9b10fad5 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -6723,14 +6723,18 @@ void LoopVectorizationCostModel::collectValuesToIgnore() {
return RequiresScalarEpilogue &&
!TheLoop->contains(cast<Instruction>(U)->getParent());
};
+ MapVector<Value *, SmallVector<Value *>> DeadInvariantStoreOps;
for (BasicBlock *BB : TheLoop->blocks())
for (Instruction &I : *BB) {
// Find all stores to invariant variables. Since they are going to sink
// outside the loop we do not need calculate cost for them.
StoreInst *SI;
if ((SI = dyn_cast<StoreInst>(&I)) &&
- Legal->isInvariantAddressOfReduction(SI->getPointerOperand()))
+ Legal->isInvariantAddressOfReduction(SI->getPointerOperand())) {
ValuesToIgnore.insert(&I);
+ auto I = DeadInvariantStoreOps.insert({SI->getPointerOperand(), {}});
+ I.first->second.push_back(SI->getValueOperand());
+ }
if (VecValuesToIgnore.contains(&I) || ValuesToIgnore.contains(&I))
continue;
@@ -6771,6 +6775,10 @@ void LoopVectorizationCostModel::collectValuesToIgnore() {
DeadInterleavePointerOps.append(Op->op_begin(), Op->op_end());
}
+ for (const auto &[_, Ops] : DeadInvariantStoreOps) {
+ for (Value *Op : ArrayRef(Ops).drop_back())
+ DeadOps.push_back(Op);
+ }
// Mark ops that would be trivially dead and are only used by ignored
// instructions as free.
BasicBlock *Header = TheLoop->getHeader();
@@ -6781,8 +6789,8 @@ void LoopVectorizationCostModel::collectValuesToIgnore() {
(isa<PHINode>(Op) && Op->getParent() == Header) ||
!wouldInstructionBeTriviallyDead(Op, TLI) ||
any_of(Op->users(), [this, IsLiveOutDead](User *U) {
- return !VecValuesToIgnore.contains(U) && ValuesToIgnore.contains(U) &&
- !IsLiveOutDead(U);
+ return !VecValuesToIgnore.contains(U) &&
+ !ValuesToIgnore.contains(U) && !IsLiveOutDead(U);
}))
continue;
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/X86/cost-model.ll",
"commands": [
"opt < %s -passes=loop-vectorize -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7-avx -S"
],
"tests": [
{
"test_name": "reduction_store",
"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\"\ntarget triple = \"x86_64-apple-macosx10.8.0\"\n\ndefine void @reduction_store(ptr noalias %src, ptr %dst, i1 %x) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %red = phi i32 [ 0, %entry ], [ %red.next, %loop ]\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %gep.src = getelementptr inbounds i32, ptr %src, i32 %iv\n %l = load i32, ptr %gep.src, align 4\n %l.and = and i32 %l, 3\n store i32 %l.and, ptr %dst, align 4\n %x.ext = zext i1 %x to i64\n %lshr = lshr i64 %x.ext, 12\n %t = trunc i64 %lshr to i32\n %red.next = and i32 %red, %t\n store i32 %red.next, ptr %dst, align 4\n %iv.next = add i32 %iv, 1\n %ec = icmp eq i32 %iv, 29\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { \"target-cpu\"=\"znver3\" }\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10353: bool llvm::LoopVectorizePass::processLoop(llvm::Loop*): Assertion `VF.Width == Width && \"VPlan cost model and legacy cost model disagreed\"' failed.",
"body": "[calcc-0ebd65.c.gz](https://github.com/user-attachments/files/15926158/calcc-0ebd65.c.gz)\r\n[calcc-0ebd65.sh.gz](https://github.com/user-attachments/files/15926159/calcc-0ebd65.sh.gz)\r\n\r\nStack backtrace is \r\n\r\n#11 0x0000000003adfddd llvm::LoopVectorizePass::processLoop(llvm::Loop*) /home/dcb40b/llvm/trunk/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10353:9\r\n#12 0x0000000003ae347f 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*) /home/dcb40b/llvm/trunk/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10446:27\r\n#13 0x0000000003ae4382 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/dcb40b/llvm/trunk/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10486:5\r\n#14 0x00000000034fbd6d llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/dcb40b/llvm/trunk/llvm/include/llvm/IR/PassManagerInternal.h:91:3\r\n#15 0x0000000001ae5b21 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/dcb40b/llvm/trunk/llvm/include/llvm/IR/PassManagerImpl.h:53:18\r\n",
"author": "dcb314",
"labels": [
"vectorizers",
"crash-on-valid"
],
"comments": [
{
"author": "dcb314",
"body": "The crash first seems to occur sometime between git hash fd88089151e66a4cb1d90aaa224e4cb4e7a748f4 from yesterday 20240620\r\nand 225d8fc8eb24fb797154c1ef6dcbe5ba033142da from today,\r\nwhich is 134 commits.\r\n"
},
{
"author": "fhahn",
"body": "Thanks for the report, caused by https://github.com/llvm/llvm-project/pull/92555 which has been reverted for now. I'll add a reduced test based on the reproducer."
},
{
"author": "fhahn",
"body": "https://github.com/llvm/llvm-project/pull/92555 has been recommitted with a fix. Please let me know if you see any other issues!"
},
{
"author": "dcb314",
"body": "It has come back:\r\n\r\nclang: /home/dcb40b/llvm/trunk/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10377: bool llvm::LoopVectorizePass::processLoop(llvm::Loop*): Assertion `VF.Width == Width && \"VPlan cost model and legacy cost model disagreed\"' failed.\r\n\r\n[in-4e39b8.sh.gz](https://github.com/user-attachments/files/16445872/in-4e39b8.sh.gz)\r\n[Uploading in-4e39b8.c.gz…]()\r\n"
},
{
"author": "dcb314",
"body": "Seems to have come back sometime between d99efd53f5103df4db517f499fcdd26cd3b080a3\r\n(dated 20240710) and 4710e0f498cb661ca17c99cb174616102fcad923, dated 20240711.\r\n\r\n"
},
{
"author": "fhahn",
"body": "@dcb314 it looks like there has been an issue with uploading the `.c` file. Could you re-upload it again?"
},
{
"author": "dcb314",
"body": "My apologies for the failed upload.\r\nHere is another try:\r\n\r\n[in-4e39b8.c.gz](https://github.com/user-attachments/files/16455342/in-4e39b8.c.gz)\r\n"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
Invalid order
| null |
123639
|
https://github.com/llvm/llvm-project/issues/123639
|
miscompilation
|
5e4c34a9b67d9ce15d14f83bcea96ccb69de1eae
| 2025-01-20T16:05:11
|
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "7d01a8f2b9ac28ffe73bef4b513d383d3edf34b5",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
13205,
13213
],
[
14497,
14503
]
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::isGatherShuffledSingleRegisterEntry",
"add"
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 7d01a8f2b9ac28ffe73bef4b513d383d3edf34b5
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Mon Jan 20 14:22:20 2025 -0800
[SLP]Fix vector factor for repeated node for bv
When adding a node vector, when it is used already in the shuffle for
buildvector, need to calculate vector factor from all vector, not only
this single vector, to avoid incorrect result. Also, need to increase
stability of the reused entries detection to avoid mismatch in cost
estimation/codegen.
Fixes #123639
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index fc3afed391a0..ad4855d90874 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -13205,9 +13205,12 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
VTE = *MIt;
}
}
- Instruction &LastBundleInst = getLastInstructionInBundle(VTE);
- if (&LastBundleInst == TEInsertPt || !CheckOrdering(&LastBundleInst))
- continue;
+ if (none_of(TE->CombinedEntriesWithIndices,
+ [&](const auto &P) { return P.first == VTE->Idx; })) {
+ Instruction &LastBundleInst = getLastInstructionInBundle(VTE);
+ if (&LastBundleInst == TEInsertPt || !CheckOrdering(&LastBundleInst))
+ continue;
+ }
VToTEs.insert(VTE);
}
if (VToTEs.empty())
@@ -14497,7 +14500,9 @@ public:
break;
}
}
- int VF = getVF(V1);
+ unsigned VF = 0;
+ for (Value *V : InVectors)
+ VF = std::max(VF, getVF(V));
for (unsigned Idx = 0, Sz = CommonMask.size(); Idx < Sz; ++Idx)
if (Mask[Idx] != PoisonMaskElem && CommonMask[Idx] == PoisonMaskElem)
CommonMask[Idx] = Mask[Idx] + (It == InVectors.begin() ? 0 : VF);
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/multi-node-reuse-in-bv.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -mattr=+avx2 < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define i32 @main() {\nentry:\n %.neg15 = sub i32 0, 0\n %0 = trunc i64 1 to i32\n %.neg.1 = sub i32 0, 0\n %.neg15.1 = sub i32 0, %0\n %.neg16.1 = add i32 %.neg.1, %.neg15.1\n %1 = add i32 %.neg16.1, %.neg15\n %2 = trunc i64 0 to i32\n %.neg.2 = sub i32 0, %0\n %.neg15.2 = sub i32 0, %2\n %.neg16.2 = add i32 %.neg.2, %.neg15.2\n %3 = add i32 %.neg16.2, %1\n %4 = trunc i64 0 to i32\n %.neg.3 = sub i32 0, %2\n %.neg15.3 = sub i32 0, %4\n %.neg16.3 = add i32 %.neg.3, %.neg15.3\n %5 = add i32 %.neg16.3, %3\n %6 = trunc i64 0 to i32\n %.neg.4 = sub i32 0, %4\n %.neg15.4 = sub i32 0, %6\n %.neg16.4 = add i32 %.neg.4, %.neg15.4\n %7 = add i32 %.neg16.4, %5\n %.neg.5 = sub i32 0, %6\n %.neg15.5 = sub i32 0, 0\n %.neg16.5 = add i32 %.neg.5, %.neg15.5\n %8 = add i32 %.neg16.5, %7\n %.neg15.6 = sub i32 0, 0\n %.neg16.6 = add i32 0, %.neg15.6\n %9 = add i32 %.neg16.6, %8\n %.neg.7 = sub i32 0, 0\n %.neg15.7 = sub i32 0, 0\n %.neg16.7 = add i32 %.neg.7, %.neg15.7\n %10 = add i32 %.neg16.7, %9\n %11 = trunc i64 0 to i32\n %.neg.8 = sub i32 0, 0\n %.neg15.8 = sub i32 0, %11\n %.neg16.8 = add i32 %.neg.8, %.neg15.8\n %12 = add i32 %.neg16.8, %10\n %13 = trunc i64 0 to i32\n %.neg.9 = sub i32 0, %11\n %.neg15.9 = sub i32 0, %13\n %.neg16.9 = add i32 %.neg.9, %.neg15.9\n %14 = add i32 %.neg16.9, %12\n %15 = trunc i64 0 to i32\n %.neg.10 = sub i32 0, %13\n %.neg15.10 = sub i32 0, %15\n %.neg16.10 = add i32 %.neg.10, %.neg15.10\n %16 = add i32 %.neg16.10, %14\n %17 = trunc i64 0 to i32\n %.neg.11 = sub i32 0, %15\n %.neg15.11 = sub i32 0, %17\n %.neg16.11 = add i32 %.neg.11, %.neg15.11\n %18 = add i32 %.neg16.11, %16\n %19 = trunc i64 0 to i32\n %.neg.12 = sub i32 0, %17\n %.neg15.12 = sub i32 0, %19\n %.neg16.12 = add i32 %.neg.12, %.neg15.12\n %20 = add i32 %.neg16.12, %18\n %.neg.13 = sub i32 0, %19\n %.neg15.13 = sub i32 0, 0\n %.neg16.13 = add i32 %.neg.13, %.neg15.13\n %21 = add i32 %.neg16.13, %20\n %.neg.14 = sub i32 0, 0\n %.neg15.14 = sub i32 0, 0\n %.neg16.14 = add i32 %.neg.14, %.neg15.14\n %22 = add i32 %.neg16.14, %21\n %.neg.15 = sub i32 0, 0\n %.neg15.15 = sub i32 0, 0\n %.neg16.15 = add i32 %.neg.15, %.neg15.15\n %23 = add i32 %.neg16.15, %22\n %.neg.16 = sub i32 0, 0\n %.neg15.16 = sub i32 0, 0\n %.neg16.16 = add i32 %.neg.16, %.neg15.16\n %24 = add i32 %.neg16.16, %23\n %res = xor i32 %24, -2\n ret i32 %res\n}\n",
"additional_args": null,
"lli_expected_out": ""
}
]
}
] |
{
"title": "SLP Vectorizer miscompilation",
"body": "During our local testing, we identified a miscompilation where the SLP Vectorizer appears to be the cause. Here is the reproducer we managed to prepare:\nhttps://godbolt.org/z/9nePcq7Go\n\nThe issue can be demonstrated using the `lli` tool. Unfortunately, I cannot use alive2 due to unknown libcall errors, such as @llvm.vector.insert.v32i32.v16i32 not being recognized by alive2\n\n```\n$ bin/opt -passes=slp-vectorizer -mattr=+avx2 src.ll -S > tgt.ll\n$ bin/lli src.ll\nResult: -256\n$ bin/lli tgt.ll\nResult: -272\n```\n\nThe pseudocode represented by the IR is\n```\nt = 0\nfor (i = 0; i < 16; i++) {\n s -= (t + i)\n t = i\n}\n```\n```\ns -= (1 + 0) + (2 + 1) + (3 + 2) + (4 + 3) + ... + (14 + 15) + (15 + 16)\ns = -256\n```\nThis indicates that the SLP Vectorizer pass produces incorrect IR.\n\nThe issue became reproducible after patch `[SLP] Match poison as instruction with the same opcode` made by @alexey-bataev \nhttps://github.com/llvm/llvm-project/commit/b8703369daf777706196ff914c0376c27adde3cf\n\nI'll provide more details on how the patch affects the issue as soon as I receive them.",
"author": "aleks-tmb",
"labels": [
"miscompilation",
"llvm:SLPVectorizer"
],
"comments": [
{
"author": "alexey-bataev",
"body": "No related directly to this patch, reveals the bug that can be triggered even without patch. I reduced the reproducer, will commit fix soon"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
|
Cannot find a good commit
| null |
164082
|
https://github.com/llvm/llvm-project/issues/164082
|
crash
|
8cd22447af239206daabb42fc63e2824a1f7fb6e
| 2025-10-18T12:59:23
|
[
"llvm/test/Transforms/LoopFusion"
] |
{
"fix_commit": "025e431e7450cada2724b19eb59354a6c020fa4f",
"components": [
"LoopFuse"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": [
[
1796,
1809
],
[
2092,
2105
]
],
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": [
"fuseGuardedLoops",
"performFusion"
],
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 025e431e7450cada2724b19eb59354a6c020fa4f
Author: Alireza Torabian <alireza.torabian@huawei.com>
Date: Tue Nov 4 16:48:39 2025 -0500
[LoopFusion] Forget loop and block dispositions after latch merge (#166233)
Merging the latches of loops may affect the dispositions, so they should
be forgotten after the merge. This patch fixed the crash in loop fusion
[#164082](https://github.com/llvm/llvm-project/issues/164082).
diff --git a/llvm/lib/Transforms/Scalar/LoopFuse.cpp b/llvm/lib/Transforms/Scalar/LoopFuse.cpp
index 19eccb9e1702..9ffa602416b0 100644
--- a/llvm/lib/Transforms/Scalar/LoopFuse.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopFuse.cpp
@@ -1796,14 +1796,16 @@ private:
// mergeLatch may remove the only block in FC1.
SE.forgetLoop(FC1.L);
SE.forgetLoop(FC0.L);
- // Forget block dispositions as well, so that there are no dangling
- // pointers to erased/free'ed blocks.
- SE.forgetBlockAndLoopDispositions();
// Move instructions from FC0.Latch to FC1.Latch.
// Note: mergeLatch requires an updated DT.
mergeLatch(FC0, FC1);
+ // Forget block dispositions as well, so that there are no dangling
+ // pointers to erased/free'ed blocks. It should be done after mergeLatch()
+ // since merging the latches may affect the dispositions.
+ SE.forgetBlockAndLoopDispositions();
+
// Merge the loops.
SmallVector<BasicBlock *, 8> Blocks(FC1.L->blocks());
for (BasicBlock *BB : Blocks) {
@@ -2092,14 +2094,16 @@ private:
// mergeLatch may remove the only block in FC1.
SE.forgetLoop(FC1.L);
SE.forgetLoop(FC0.L);
- // Forget block dispositions as well, so that there are no dangling
- // pointers to erased/free'ed blocks.
- SE.forgetBlockAndLoopDispositions();
// Move instructions from FC0.Latch to FC1.Latch.
// Note: mergeLatch requires an updated DT.
mergeLatch(FC0, FC1);
+ // Forget block dispositions as well, so that there are no dangling
+ // pointers to erased/free'ed blocks. It should be done after mergeLatch()
+ // since merging the latches may affect the dispositions.
+ SE.forgetBlockAndLoopDispositions();
+
// Merge the loops.
SmallVector<BasicBlock *, 8> Blocks(FC1.L->blocks());
for (BasicBlock *BB : Blocks) {
|
[
{
"file": "llvm/test/Transforms/LoopFusion/pr164082.ll",
"commands": [
"opt -passes=loop-fusion -disable-output -stats < %s 2>&1"
],
"tests": [
{
"test_name": "<module>",
"test_body": "; REQUIRES: asserts\n; STAT: 1 loop-fusion - Loops fused\n\n; C Code\n;\n;; for (int i = 0; i < 100; ++i)\n;; Array[i][i] = -i;\n;; for (int row = 0; row < 100; ++row)\n;; for (int col = 0; col < 100; ++col)\n;; if (col != row)\n;; Array[row][col] = row + col;\n;\n; Loop fusion should not crash anymore as now forgetBlockAndLoopDispositions()\n; is trigerred after mergeLatch() during the fusion.\n\ndefine i32 @forget_dispositions() nounwind {\nentry:\n %Array = alloca [100 x [100 x i32]], align 4\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %indvars.iv33 = phi i64 [ 0, %entry ], [ %indvars.iv.next34, %for.body ]\n %0 = trunc i64 %indvars.iv33 to i32\n %sub = sub i32 0, %0\n %arrayidx2 = getelementptr inbounds [100 x [100 x i32]], ptr %Array, i64 0, i64 %indvars.iv33, i64 %indvars.iv33\n store i32 %sub, ptr %arrayidx2, align 4\n %indvars.iv.next34 = add i64 %indvars.iv33, 1\n %lftr.wideiv35 = trunc i64 %indvars.iv.next34 to i32\n %exitcond36 = icmp eq i32 %lftr.wideiv35, 100\n br i1 %exitcond36, label %for.cond6.preheader, label %for.body\n\nfor.cond6.preheader: ; preds = %for.body, %for.inc17\n %indvars.iv29 = phi i64 [ %indvars.iv.next30, %for.inc17 ], [ 0, %for.body ]\n br label %for.body8\n\nfor.body8: ; preds = %for.inc14, %for.cond6.preheader\n %indvars.iv = phi i64 [ 0, %for.cond6.preheader ], [ %indvars.iv.next, %for.inc14 ]\n %1 = trunc i64 %indvars.iv to i32\n %2 = trunc i64 %indvars.iv29 to i32\n %cmp9 = icmp eq i32 %1, %2\n br i1 %cmp9, label %for.inc14, label %if.then\n\nif.then: ; preds = %for.body8\n %3 = add i64 %indvars.iv, %indvars.iv29\n %arrayidx13 = getelementptr inbounds [100 x [100 x i32]], ptr %Array, i64 0, i64 %indvars.iv29, i64 %indvars.iv\n %4 = trunc i64 %3 to i32\n store i32 %4, ptr %arrayidx13, align 4\n br label %for.inc14\n\nfor.inc14: ; preds = %for.body8, %if.then\n %indvars.iv.next = add i64 %indvars.iv, 1\n %lftr.wideiv27 = trunc i64 %indvars.iv.next to i32\n %exitcond28 = icmp eq i32 %lftr.wideiv27, 100\n br i1 %exitcond28, label %for.inc17, label %for.body8\n\nfor.inc17: ; preds = %for.inc14\n %indvars.iv.next30 = add i64 %indvars.iv29, 1\n %lftr.wideiv31 = trunc i64 %indvars.iv.next30 to i32\n %exitcond32 = icmp eq i32 %lftr.wideiv31, 100\n br i1 %exitcond32, label %for.exit, label %for.cond6.preheader\n\nfor.exit: ; preds = %for.inc17\n ret i32 0\n}",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "crashes with assertion failure when running opt -passes=loop-fusion",
"body": "Reproducer:\nhttps://godbolt.org/z/qzjrq4P3z\n\nBacktrace:\n```console\nopt: /root/llvm-project/llvm/include/llvm/Support/GenericLoopInfo.h:135: bool llvm::LoopBase<N, M>::contains(const BlockT*) const [with BlockT = llvm::BasicBlock; LoopT = llvm::Loop]: Assertion `!isInvalid() && \"Loop not in a valid state!\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=loop-fusion <source>\n1.\tRunning pass \"function(loop-fusion)\" on module \"<source>\"\n2.\tRunning pass \"loop-fusion\" on function \"main\"\n #0 0x0000000005954738 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5954738)\n #1 0x00000000059515e4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x000071f9da242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x000071f9da2969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x000071f9da242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x000071f9da2287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x000071f9da22871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x000071f9da239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x0000000004f4c6b3 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f4c6b3)\n #9 0x0000000004f6c4e9 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f6c4e9)\n#10 0x0000000004f6becf llvm::ScalarEvolution::getLoopDisposition(llvm::SCEV const*, llvm::Loop const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f6becf)\n#11 0x0000000004fbe4a4 llvm::ScalarEvolution::verify() const (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4fbe4a4)\n#12 0x0000000004673741 (anonymous namespace)::LoopFuser::performFusion((anonymous namespace)::FusionCandidate const&, (anonymous namespace)::FusionCandidate const&) LoopFuse.cpp:0:0\n#13 0x00000000046789ae (anonymous namespace)::LoopFuser::fuseCandidates() LoopFuse.cpp:0:0\n#14 0x000000000467a501 llvm::LoopFusePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x467a501)\n#15 0x0000000002f8e9de llvm::detail::PassModel<llvm::Function, llvm::LoopFusePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2f8e9de)\n#16 0x000000000572e961 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x572e961)\n#17 0x0000000000ef661e 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+0xef661e)\n#18 0x000000000572ceca llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x572ceca)\n#19 0x0000000000977e0e 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+0x977e0e)\n#20 0x000000000572c881 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x572c881)\n#21 0x0000000000981f1a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x981f1a)\n#22 0x000000000097619e optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x97619e)\n#23 0x000071f9da229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#24 0x000071f9da229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#25 0x000000000096d4f5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x96d4f5)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```",
"author": "k-arrows",
"labels": [
"crash",
"llvm:transforms"
],
"comments": [
{
"author": "k-arrows",
"body": "Comes from llvm/test/CodeGen/PowerPC/ctrloop-sums.ll"
},
{
"author": "dtcxzyw",
"body": "Bisected to https://github.com/llvm/llvm-project/commit/d6072986cd40a3c009d2963a2b33501e047c7dc4\ncc @1997alireza @CongzheUalberta"
},
{
"author": "CongzheUalberta",
"body": "Can you take a look? @1997alireza "
},
{
"author": "1997alireza",
"body": "> Can you take a look? [@1997alireza](https://github.com/1997alireza)\n\nYes, working on it."
},
{
"author": "1997alireza",
"body": "> > Can you take a look? [@1997alireza](https://github.com/1997alireza)\n> \n> Yes, working on it.\n\nFound the solution. Will post a patch to fix it asap.\n"
},
{
"author": "CongzheUalberta",
"body": "Should be fixed with #166233 so closing the issue now.\nIf something related happens down the road we can reopen it."
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null | null |
122558
|
https://github.com/llvm/llvm-project/issues/122558
|
crash
|
25f28ddd69ed2453726c0934ba6feea8ae6f10f8
| 2025-01-11T00:36:48
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "1de3dc7d23dd6b856efad3a3a04f2396328726d7",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
[
4052,
4058
],
[
4064,
4069
]
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"LoopVectorizationCostModel::computeMaxVF"
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 1de3dc7d23dd6b856efad3a3a04f2396328726d7
Author: Florian Hahn <flo@fhahn.com>
Date: Tue Jan 14 22:07:38 2025 +0000
[LV] Bail out early if BTC+1 wraps.
Currently we fail to detect the case where BTC + 1 wraps, i.e. the
vector trip count is 0, In those cases, the minimum iteration count
check will fail, and the vector code will never be executed.
Explicitly check for this condition in computeMaxVF and avoid trying to
vectorize alltogether.
Note that a number of tests needed to be updated, because the vector
loop would never be executed given the input IR.
Fixes https://github.com/llvm/llvm-project/issues/122558.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 744faef19243..fe2fb5e9faae 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -4052,7 +4052,8 @@ LoopVectorizationCostModel::computeMaxVF(ElementCount UserVF, unsigned UserIC) {
return FixedScalableVFPair::getNone();
}
- unsigned TC = PSE.getSE()->getSmallConstantTripCount(TheLoop);
+ ScalarEvolution *SE = PSE.getSE();
+ unsigned TC = SE->getSmallConstantTripCount(TheLoop);
unsigned MaxTC = PSE.getSmallConstantMaxTripCount();
LLVM_DEBUG(dbgs() << "LV: Found trip count: " << TC << '\n');
if (TC != MaxTC)
@@ -4064,6 +4065,22 @@ LoopVectorizationCostModel::computeMaxVF(ElementCount UserVF, unsigned UserIC) {
return FixedScalableVFPair::getNone();
}
+ // If BTC matches the widest induction type and is -1 then the trip count
+ // computation will wrap to 0 and the vector trip count will be 0. Do not try
+ // to vectorize.
+ const SCEV *BTC = SE->getBackedgeTakenCount(TheLoop);
+ if (!isa<SCEVCouldNotCompute>(BTC) &&
+ BTC->getType()->getScalarSizeInBits() >=
+ Legal->getWidestInductionType()->getScalarSizeInBits() &&
+ SE->isKnownPredicate(CmpInst::ICMP_EQ, BTC,
+ SE->getMinusOne(BTC->getType()))) {
+ reportVectorizationFailure(
+ "Trip count computation wrapped",
+ "backedge-taken count is -1, loop trip count wrapped to 0",
+ "TripCountWrapped", ORE, TheLoop);
+ return FixedScalableVFPair::getNone();
+ }
+
switch (ScalarEpilogueStatus) {
case CM_ScalarEpilogueAllowed:
return computeFeasibleMaxVF(MaxTC, UserVF, false);
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-dot-product-epilogue.ll",
"commands": [
"opt -mattr=+dotprod -passes=loop-vectorize -force-vector-interleave=1 -S < %s"
],
"tests": [
{
"test_name": "dotp",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i32 @dotp(ptr %a, ptr %b) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = zext i8 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %accum\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n ret i32 %add\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-dot-product-mixed.ll",
"commands": [
"opt -passes=loop-vectorize -enable-epilogue-vectorization=false -mattr=+i8mm,+dotprod -S < %s",
"opt -passes=loop-vectorize -enable-epilogue-vectorization=false -mattr=+dotprod -S < %s"
],
"tests": [
{
"test_name": "dotp_z_s",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i32 @dotp_z_s(ptr %a, ptr %b) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = sext i8 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %accum\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n ret i32 %add\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "dotp_s_z",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i32 @dotp_s_z(ptr %a, ptr %b) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = sext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = zext i8 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %accum\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n ret i32 %add\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-dot-product-neon.ll",
"commands": [
"opt -passes=loop-vectorize -enable-epilogue-vectorization=false -mattr=+neon,+dotprod -force-vector-interleave=1 -S < %s",
"opt -passes=loop-vectorize -enable-epilogue-vectorization=false -mattr=+neon,+dotprod -S < %s",
"opt -passes=loop-vectorize -enable-epilogue-vectorization=false -mattr=+neon,+dotprod -force-vector-interleave=1 -vectorizer-maximize-bandwidth -S < %s"
],
"tests": [
{
"test_name": "dotp_unrolled",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\ndefine i32 @dotp_unrolled(i32 %num_out, i64 %num_in, ptr %a, ptr %b) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum3 = phi i32 [ 0, %entry ], [ %add.a3, %for.body ]\n %accum2 = phi i32 [ 0, %entry ], [ %add.a2, %for.body ]\n %accum1 = phi i32 [ 0, %entry ], [ %add.a1, %for.body ]\n %accum0 = phi i32 [ 0, %entry ], [ %add.a0, %for.body ]\n %gep.a0 = getelementptr inbounds i8, ptr %a, i64 %iv\n %gep.b0 = getelementptr inbounds i8, ptr %b, i64 %iv\n %offset.1 = or disjoint i64 %iv, 1\n %gep.a1 = getelementptr inbounds i8, ptr %a, i64 %offset.1\n %gep.b1 = getelementptr inbounds i8, ptr %b, i64 %offset.1\n %offset.2 = or disjoint i64 %iv, 2\n %gep.a2 = getelementptr inbounds i8, ptr %a, i64 %offset.2\n %gep.b2 = getelementptr inbounds i8, ptr %b, i64 %offset.2\n %offset.3 = or disjoint i64 %iv, 3\n %gep.a3 = getelementptr inbounds i8, ptr %a, i64 %offset.3\n %gep.b3 = getelementptr inbounds i8, ptr %b, i64 %offset.3\n %load.a0 = load i8, ptr %gep.a0, align 1\n %ext.a0 = sext i8 %load.a0 to i32\n %load.b0 = load i8, ptr %gep.b0, align 1\n %ext.b0 = sext i8 %load.b0 to i32\n %mul.a0 = mul nsw i32 %ext.b0, %ext.a0\n %add.a0 = add nsw i32 %mul.a0, %accum0\n %load.a1 = load i8, ptr %gep.a1, align 1\n %ext.a1 = sext i8 %load.a1 to i32\n %load.b1 = load i8, ptr %gep.b1, align 1\n %ext.b1 = sext i8 %load.b1 to i32\n %mul.a1 = mul nsw i32 %ext.a1, %ext.b1\n %add.a1 = add nsw i32 %mul.a1, %accum1\n %load.a2 = load i8, ptr %gep.a2, align 1\n %ext.a2 = sext i8 %load.a2 to i32\n %load.b2 = load i8, ptr %gep.b2, align 1\n %ext.b2 = sext i8 %load.b2 to i32\n %mul.a2 = mul nsw i32 %ext.a2, %ext.b2\n %add.a2 = add nsw i32 %mul.a2, %accum2\n %load.a3 = load i8, ptr %gep.a3, align 1\n %ext.a3 = sext i8 %load.a3 to i32\n %load.b3 = load i8, ptr %gep.b3, align 1\n %ext.b3 = sext i8 %load.b3 to i32\n %mul.a3 = mul nsw i32 %ext.a3, %ext.b3\n %add.a3 = add nsw i32 %mul.a3, %accum3\n %iv.next = add nuw nsw i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, %num_in\n br i1 %exitcond.not, label %exit, label %for.body\n\nexit: ; preds = %for.body\n %result0 = add nsw i32 %add.a0, %add.a1\n %result1 = add nsw i32 %add.a2, %add.a3\n %result = add nsw i32 %result0, %result1\n ret i32 %result\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "dotp",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\ndefine i32 @dotp(ptr %a, ptr %b) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = zext i8 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %accum\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n ret i32 %add\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "not_dotp_predicated_pragma",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\ndefine i32 @not_dotp_predicated_pragma(i64 %N, ptr %a, ptr %b) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr inbounds i8, ptr %b, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = sext i8 %load.a to i32\n %gep.a2 = getelementptr inbounds i8, ptr %a, i64 %iv\n %load.b = load i8, ptr %gep.a2, align 1\n %ext.b = sext i8 %load.b to i32\n %mul = mul nsw i32 %ext.b, %ext.a\n %add = add nsw i32 %mul, %accum\n %iv.next = add nuw nsw i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, %N\n br i1 %exitcond.not, label %exit, label %for.body, !llvm.loop !0\n\nexit: ; preds = %for.body\n ret i32 %add\n}\n\n!0 = distinct !{!0, !1, !2, !3}\n!1 = !{!\"llvm.loop.mustprogress\"}\n!2 = !{!\"llvm.loop.vectorize.predicate.enable\", i1 true}\n!3 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "not_dotp_not_loop_carried",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\ndefine i32 @not_dotp_not_loop_carried(ptr %a, ptr %b) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %mul, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = zext i8 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %accum\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n ret i32 %add\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "not_dotp_different_types",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\ndefine i32 @not_dotp_different_types(ptr %a, ptr %b) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i16, ptr %gep.b, align 2\n %ext.b = zext i16 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %accum\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n ret i32 %add\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "not_dotp_not_phi",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\ndefine i32 @not_dotp_not_phi(ptr %a, ptr %b) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = zext i8 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %ext.b\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n ret i32 %add\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "not_dotp_extend_user",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\ndefine i32 @not_dotp_extend_user(ptr %a, ptr %b) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = zext i8 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %accum\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n %result = add i32 %add, %ext.b\n ret i32 %result\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "not_dotp_predicated",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\ndefine i32 @not_dotp_predicated(i64 %N, ptr %a, ptr %b) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr inbounds i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = sext i8 %load.a to i32\n %gep.b = getelementptr inbounds i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = sext i8 %load.b to i32\n %mul = mul nsw i32 %ext.b, %ext.a\n %add = add nsw i32 %mul, %accum\n %iv.next = add nuw nsw i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, %N\n br i1 %exitcond.not, label %exit, label %for.body\n\nexit: ; preds = %for.body\n ret i32 %add\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-dot-product.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-interleave=1 -enable-epilogue-vectorization=false -S < %s",
"opt -passes=loop-vectorize -enable-epilogue-vectorization=false -S < %s",
"opt -passes=loop-vectorize -force-vector-interleave=1 -vectorizer-maximize-bandwidth -enable-epilogue-vectorization=false -S < %s"
],
"tests": [
{
"test_name": "not_dotp_not_phi2",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine void @not_dotp_not_phi2(ptr %matrix, i32 %n) #0 {\nentry:\n %cmp = icmp sgt i32 %n, 0\n br i1 %cmp, label %for.preheader, label %exit\n\nfor.preheader: ; preds = %entry\n %load.a = load i8, ptr null, align 1\n %load.a1 = load i8, ptr inttoptr (i64 1 to ptr), align 1\n %a.ext = sext i8 %load.a to i32\n %a.ext1 = sext i8 %load.a1 to i32\n br label %for.body\n\nfor.body: ; preds = %for.body, %for.preheader\n %iv = phi i32 [ %iv.next, %for.body ], [ 0, %for.preheader ]\n %ptr = phi ptr [ %scevgep, %for.body ], [ %matrix, %for.preheader ]\n %accum = phi i32 [ %add.1, %for.body ], [ 0, %for.preheader ]\n %gep.b = getelementptr i8, ptr %ptr, i64 1\n %gep.b1 = getelementptr i8, ptr %ptr, i64 2\n %load.b = load i8, ptr %gep.b, align 1\n %b.ext = sext i8 %load.b to i32\n %mul = mul nsw i32 %a.ext, %b.ext\n %add = add i32 %mul, %accum\n %load.b1 = load i8, ptr %gep.b1, align 1\n %b.ext1 = sext i8 %load.b1 to i32\n %mul.1 = mul nsw i32 %a.ext1, %b.ext1\n %add.1 = add i32 %mul.1, %add\n %scevgep = getelementptr i8, ptr %ptr, i64 16\n %iv.next = add nuw nsw i32 %iv, 1\n %exitcond.not = icmp eq i32 %iv.next, %n\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n %add.1.lcssa = phi i32 [ %add.1, %for.body ]\n %add.float = sitofp i32 %add.1.lcssa to float\n br label %exit\n\nexit: ; preds = %for.exit, %entry\n %result = phi float [ 0.000000e+00, %entry ], [ %add.float, %for.exit ]\n store float %result, ptr %matrix, align 4\n ret void\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "not_dotp_ext_outside_plan2",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i64 @not_dotp_ext_outside_plan2(ptr %a, i16 %b, i64 %n) #0 {\nentry:\n %cmp = icmp eq i64 %n, 0\n br i1 %cmp, label %exit, label %for.ph\n\nfor.ph: ; preds = %entry\n %ext.b = zext i16 %b to i64\n br label %for.body\n\nfor.body: ; preds = %for.body, %for.ph\n %iv = phi i64 [ 0, %for.ph ], [ %iv.next, %for.body ]\n %accum = phi i64 [ 0, %for.ph ], [ %add, %for.body ]\n %gep.a = getelementptr inbounds nuw i16, ptr %a, i64 %iv\n %load.a = load i16, ptr %gep.a, align 2\n %ext.a = zext i16 %load.a to i64\n %mul = mul nuw nsw i64 %ext.b, %ext.a\n %add = add i64 %mul, %accum\n %iv.next = add nuw nsw i64 %iv, 1\n %cmp.1 = icmp eq i64 %iv.next, %n\n br i1 %cmp.1, label %exit, label %for.body\n\nexit: ; preds = %for.body, %entry\n %result = phi i64 [ 0, %entry ], [ %add, %for.body ]\n ret i64 %result\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "dotp_unrolled",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i32 @dotp_unrolled(i32 %num_out, i64 %num_in, ptr %a, ptr %b) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum3 = phi i32 [ 0, %entry ], [ %add.a3, %for.body ]\n %accum2 = phi i32 [ 0, %entry ], [ %add.a2, %for.body ]\n %accum1 = phi i32 [ 0, %entry ], [ %add.a1, %for.body ]\n %accum0 = phi i32 [ 0, %entry ], [ %add.a0, %for.body ]\n %gep.a0 = getelementptr inbounds i8, ptr %a, i64 %iv\n %gep.b0 = getelementptr inbounds i8, ptr %b, i64 %iv\n %offset.1 = or disjoint i64 %iv, 1\n %gep.a1 = getelementptr inbounds i8, ptr %a, i64 %offset.1\n %gep.b1 = getelementptr inbounds i8, ptr %b, i64 %offset.1\n %offset.2 = or disjoint i64 %iv, 2\n %gep.a2 = getelementptr inbounds i8, ptr %a, i64 %offset.2\n %gep.b2 = getelementptr inbounds i8, ptr %b, i64 %offset.2\n %offset.3 = or disjoint i64 %iv, 3\n %gep.a3 = getelementptr inbounds i8, ptr %a, i64 %offset.3\n %gep.b3 = getelementptr inbounds i8, ptr %b, i64 %offset.3\n %load.a0 = load i8, ptr %gep.a0, align 1\n %ext.a0 = sext i8 %load.a0 to i32\n %load.b0 = load i8, ptr %gep.b0, align 1\n %ext.b0 = sext i8 %load.b0 to i32\n %mul.a0 = mul nsw i32 %ext.b0, %ext.a0\n %add.a0 = add nsw i32 %mul.a0, %accum0\n %load.a1 = load i8, ptr %gep.a1, align 1\n %ext.a1 = sext i8 %load.a1 to i32\n %load.b1 = load i8, ptr %gep.b1, align 1\n %ext.b1 = sext i8 %load.b1 to i32\n %mul.a1 = mul nsw i32 %ext.a1, %ext.b1\n %add.a1 = add nsw i32 %mul.a1, %accum1\n %load.a2 = load i8, ptr %gep.a2, align 1\n %ext.a2 = sext i8 %load.a2 to i32\n %load.b2 = load i8, ptr %gep.b2, align 1\n %ext.b2 = sext i8 %load.b2 to i32\n %mul.a2 = mul nsw i32 %ext.a2, %ext.b2\n %add.a2 = add nsw i32 %mul.a2, %accum2\n %load.a3 = load i8, ptr %gep.a3, align 1\n %ext.a3 = sext i8 %load.a3 to i32\n %load.b3 = load i8, ptr %gep.b3, align 1\n %ext.b3 = sext i8 %load.b3 to i32\n %mul.a3 = mul nsw i32 %ext.a3, %ext.b3\n %add.a3 = add nsw i32 %mul.a3, %accum3\n %iv.next = add nuw nsw i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, %num_in\n br i1 %exitcond.not, label %exit, label %for.body\n\nexit: ; preds = %for.body\n %result0 = add nsw i32 %add.a0, %add.a1\n %result1 = add nsw i32 %add.a2, %add.a3\n %result = add nsw i32 %result0, %result1\n ret i32 %result\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "dotp",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i32 @dotp(ptr %a, ptr %b) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = zext i8 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %accum\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n ret i32 %add\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "not_dotp_predicated_pragma",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i32 @not_dotp_predicated_pragma(i64 %N, ptr %a, ptr %b) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr inbounds i8, ptr %b, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = sext i8 %load.a to i32\n %gep.a2 = getelementptr inbounds i8, ptr %a, i64 %iv\n %load.b = load i8, ptr %gep.a2, align 1\n %ext.b = sext i8 %load.b to i32\n %mul = mul nsw i32 %ext.b, %ext.a\n %add = add nsw i32 %mul, %accum\n %iv.next = add nuw nsw i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, %N\n br i1 %exitcond.not, label %exit, label %for.body, !llvm.loop !0\n\nexit: ; preds = %for.body\n ret i32 %add\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n\n!0 = distinct !{!0, !1, !2, !3}\n!1 = !{!\"llvm.loop.mustprogress\"}\n!2 = !{!\"llvm.loop.vectorize.predicate.enable\", i1 true}\n!3 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "dotp_cost_disagreement",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i64 @dotp_cost_disagreement(ptr %a, ptr %b) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i.iv = phi i64 [ 0, %entry ], [ %i.iv.next, %for.body ]\n %sum = phi i64 [ 0, %entry ], [ %add, %for.body ]\n %arrayidx = getelementptr inbounds nuw i8, ptr %a, i64 %i.iv\n %0 = load i8, ptr %arrayidx, align 1\n %conv = zext i8 %0 to i64\n %i.iv.next = add nuw nsw i64 %i.iv, 1\n %arrayidx2 = getelementptr inbounds nuw i8, ptr %b, i64 %i.iv.next\n %1 = load i8, ptr %arrayidx2, align 1\n %conv3 = zext i8 %1 to i64\n %mul = mul nuw nsw i64 %conv3, %conv\n %add = add i64 %sum, %mul\n %exitcond.not = icmp eq i64 %i.iv.next, 16\n br i1 %exitcond.not, label %exit, label %for.body\n\nexit: ; preds = %for.body\n ret i64 %add\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "not_dotp_not_loop_carried",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i32 @not_dotp_not_loop_carried(ptr %a, ptr %b) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %mul, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = zext i8 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %accum\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n ret i32 %add\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "not_dotp_different_types",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i32 @not_dotp_different_types(ptr %a, ptr %b) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i16, ptr %gep.b, align 2\n %ext.b = zext i16 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %accum\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n ret i32 %add\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "not_dotp_not_phi",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i32 @not_dotp_not_phi(ptr %a, ptr %b) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = zext i8 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %ext.b\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n ret i32 %add\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "not_dotp_extend_user",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i32 @not_dotp_extend_user(ptr %a, ptr %b) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = zext i8 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %accum\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n %result = add i32 %add, %ext.b\n ret i32 %result\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "not_dotp_ext_outside_plan",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i64 @not_dotp_ext_outside_plan(ptr %a, i16 %b, i64 %n) #0 {\nentry:\n %cmp = icmp eq i64 %n, 0\n br i1 %cmp, label %exit, label %for.ph\n\nfor.ph: ; preds = %entry\n %ext.b = zext i16 %b to i64\n br label %for.body\n\nfor.body: ; preds = %for.body, %for.ph\n %iv = phi i64 [ 0, %for.ph ], [ %iv.next, %for.body ]\n %accum = phi i64 [ 0, %for.ph ], [ %add, %for.body ]\n %gep.a = getelementptr inbounds nuw i16, ptr %a, i64 %iv\n %load.a = load i16, ptr %gep.a, align 2\n %ext.a = zext i16 %load.a to i64\n %mul = mul nuw nsw i64 %ext.a, %ext.b\n %add = add i64 %mul, %accum\n %iv.next = add nuw nsw i64 %iv, 1\n %cmp.1 = icmp eq i64 %iv.next, %n\n br i1 %cmp.1, label %exit, label %for.body\n\nexit: ; preds = %for.body, %entry\n %result = phi i64 [ 0, %entry ], [ %add, %for.body ]\n ret i64 %result\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "not_dotp_predicated",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i32 @not_dotp_predicated(i64 %N, ptr %a, ptr %b) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr inbounds i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = sext i8 %load.a to i32\n %gep.b = getelementptr inbounds i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = sext i8 %load.b to i32\n %mul = mul nsw i32 %ext.b, %ext.a\n %add = add nsw i32 %mul, %accum\n %iv.next = add nuw nsw i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, %N\n br i1 %exitcond.not, label %exit, label %for.body\n\nexit: ; preds = %for.body\n ret i32 %add\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-no-dotprod.ll",
"commands": [
"opt -passes=loop-vectorize -enable-epilogue-vectorization=false -mattr=+neon -S < %s"
],
"tests": [
{
"test_name": "not_dotp",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\ndefine i32 @not_dotp(ptr %a, ptr %b) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = zext i8 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %accum\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1000\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n ret i32 %add\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/store-costs-sve.ll",
"commands": [
"opt -p loop-vectorize -S %s",
"opt -p loop-vectorize -prefer-predicate-over-epilogue=predicate-else-scalar-epilogue -S %s"
],
"tests": [
{
"test_name": "trunc_store",
"test_body": "target datalayout = \"e-m:o-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"arm64-apple-macosx14.0.0\"\n\n; Function Attrs: vscale_range(1,16)\ndefine void @trunc_store(ptr %dst, ptr %src, i16 %x) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %x.ext = zext i16 %x to i64\n %l = load i64, ptr %src, align 8\n %and = and i64 %l, %x.ext\n %trunc = trunc i64 %and to i8\n %gep = getelementptr i8, ptr %dst, i64 %iv\n store i8 %trunc, ptr %gep, align 1\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv.next, 1000\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/vplan-printing.ll",
"commands": [
"opt -mattr=+neon,+dotprod -passes=loop-vectorize -debug-only=loop-vectorize -force-vector-interleave=1 -disable-output %s 2>&1"
],
"tests": [
{
"test_name": "print_partial_reduction",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\ndefine i32 @print_partial_reduction(ptr %a, ptr %b) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = zext i8 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %accum\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %exit, label %for.body\n\nexit: ; preds = %for.body\n ret i32 %add\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/Hexagon/maximum-vf-crash.ll",
"commands": [
"opt -mtriple=hexagon -hexagon-autohvx -passes=loop-vectorize -S < %s 2>&1"
],
"tests": [
{
"test_name": "f",
"test_body": "target datalayout = \"e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048\"\n\n; Function Attrs: optsize\ndefine i32 @f(ptr %src) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %g.016 = phi i32 [ 0, %entry ], [ %g.1.lcssa, %loop ]\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %0 = load i8, ptr %src, align 1\n %g.1.lcssa = add i32 %g.016, 1\n %iv.next = add nsw i32 %iv, 1\n %exitcond = icmp eq i32 %iv.next, 1000\n br i1 %exitcond, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i32 %g.1.lcssa\n}\n\nattributes #0 = { optsize \"target-features\"=\"+hvx-length128b\" }\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/X86/cost-constant-known-via-scev.ll",
"commands": [
"opt -p loop-vectorize -S %s"
],
"tests": [
{
"test_name": "second_lshr_operand_zero_via_scev",
"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\ndefine i64 @second_lshr_operand_zero_via_scev() {\nentry:\n %ext.0 = sext i8 0 to i32\n br label %loops\n\nloops: ; preds = %loops, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loops ]\n %red = phi i64 [ 0, %entry ], [ %red.next, %loops ]\n %c = icmp eq i64 %iv, 0\n %and = and i64 %iv, 0\n %0 = trunc i64 %iv to i32\n %shr = lshr i32 %0, %ext.0\n %conv.1 = zext i32 %shr to i64\n %red.next.v = select i1 %c, i64 %and, i64 %conv.1\n %red.next = or i64 %red.next.v, %red\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv.next, 1000\n br i1 %ec, label %exit, label %loops\n\nexit: ; preds = %loops\n %res = phi i64 [ %red.next, %loops ]\n ret i64 %res\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/X86/cost-model.ll",
"commands": [
"opt < %s -passes=loop-vectorize -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7-avx -S"
],
"tests": [
{
"test_name": "narrowed_reduction",
"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\"\ntarget triple = \"x86_64-apple-macosx10.8.0\"\n\ndefine i32 @narrowed_reduction(ptr %a, i1 %cmp) #0 {\nentry:\n %conv = zext i1 %cmp to i32\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 1, %entry ], [ %inc, %loop ]\n %or13 = phi i32 [ 0, %entry ], [ %or, %loop ]\n %and = and i32 %or13, 1\n %or = or i32 %and, %conv\n %inc = add i32 %iv, 1\n %ec = icmp eq i32 %iv, 16\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i32 %or\n}\n\nattributes #0 = { \"target-cpu\"=\"penryn\" }\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/X86/drop-poison-generating-flags.ll",
"commands": [
"opt %s -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -S"
],
"tests": [
{
"test_name": "drop_zext_nneg",
"test_body": "target datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-pc-linux-gnu\"\n\n; Function Attrs: noinline nounwind uwtable\ndefine void @drop_zext_nneg(ptr noalias %p, ptr noalias %p1) #0 {\nentry:\n br label %body\n\nbody: ; preds = %else, %entry\n %iv = phi i64 [ %next, %else ], [ 0, %entry ]\n %0 = trunc i64 %iv to i32\n %c = icmp eq i32 %0, 0\n br i1 %c, label %then, label %else\n\nthen: ; preds = %body\n %zext = zext nneg i32 %0 to i64\n %idx1 = getelementptr double, ptr %p, i64 %zext\n %idx2 = getelementptr double, ptr %p, i64 %zext\n %1 = load double, ptr %idx2, align 8\n br label %else\n\nelse: ; preds = %then, %body\n %phi = phi double [ %1, %then ], [ 0.000000e+00, %body ]\n store double %phi, ptr %p1, align 8\n %next = add i64 %iv, 1\n %cmp = icmp eq i64 %next, 1024\n br i1 %cmp, label %exit, label %body\n\nexit: ; preds = %else\n ret void\n}\n\nattributes #0 = { noinline nounwind uwtable \"target-features\"=\"+avx512bw,+avx512cd,+avx512dq,+avx512f,+avx512vl\" }\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/X86/interleave-cost.ll",
"commands": [
"opt -p loop-vectorize -S %s"
],
"tests": [
{
"test_name": "test_free_instructions_feeding_geps_for_interleave_groups",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-apple-macosx10.15.0\"\n\ndefine void @test_free_instructions_feeding_geps_for_interleave_groups(ptr noalias %p.invar, ptr noalias %dst.1, ptr noalias %dst.2) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %l.0 = load float, ptr %p.invar, align 4\n %iv.mul = shl i64 %iv, 2\n %gep.dst.19 = getelementptr float, ptr %dst.1, i64 %iv.mul\n store float %l.0, ptr %gep.dst.19, align 4\n %l.1 = load float, ptr %p.invar, align 4\n %add.1 = or disjoint i64 %iv.mul, 1\n %gep.dst.119 = getelementptr float, ptr %dst.1, i64 %add.1\n store float %l.1, ptr %gep.dst.119, align 4\n %add.2 = or disjoint i64 %iv.mul, 2\n %gep.dst.129 = getelementptr float, ptr %dst.1, i64 %add.2\n store float 0.000000e+00, ptr %gep.dst.129, align 4\n %add.3 = or disjoint i64 %iv.mul, 3\n %gep.dst.140 = getelementptr float, ptr %dst.1, i64 %add.3\n store float 0.000000e+00, ptr %gep.dst.140, align 4\n %l.2 = load float, ptr %p.invar, align 4\n %gep.dst.247 = getelementptr float, ptr %dst.2, i64 %iv.mul\n store float %l.2, ptr %gep.dst.247, align 4\n %gep.dst.255 = getelementptr float, ptr %dst.2, i64 %add.1\n store float 0.000000e+00, ptr %gep.dst.255, align 4\n %gep.dst.265 = getelementptr float, ptr %dst.2, i64 %add.2\n store float 0.000000e+00, ptr %gep.dst.265, align 4\n %gep.dst.276 = getelementptr float, ptr %dst.2, i64 %add.3\n store float 0.000000e+00, ptr %gep.dst.276, align 4\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv.next, 1024\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/X86/replicate-uniform-call.ll",
"commands": [
"opt -p loop-vectorize -S %s"
],
"tests": [
{
"test_name": "smax_call_uniform",
"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\ndefine void @smax_call_uniform(ptr %dst, i64 %x) {\nentry:\n %c = icmp ult i8 -68, -69\n %mul = mul nuw nsw i64 %x, 0\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n br i1 %c, label %loop.latch, label %else\n\nelse: ; preds = %loop.header\n %rem = urem i64 %mul, %x\n %smax = tail call i64 @llvm.smax.i64(i64 %rem, i64 0)\n br label %loop.latch\n\nloop.latch: ; preds = %else, %loop.header\n %p = phi i64 [ 1, %loop.header ], [ %smax, %else ]\n %add = add i64 %p, 1\n %gep = getelementptr i64, ptr %dst, i64 %add\n store i64 0, ptr %gep, align 8\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv.next, 1024\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i64 @llvm.smax.i64(i64, i64) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/epilog-vectorization-vector-trip-count-zero.ll",
"commands": [
"opt -p loop-vectorize -force-vector-width=2 -epilogue-vectorization-force-VF=2 -S %s"
],
"tests": [
{
"test_name": "vector_trip_count_0_as_btc_is_all_1",
"test_body": "target datalayout = \"E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64\"\n\ndefine void @vector_trip_count_0_as_btc_is_all_1(ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.next = add i32 %iv, -1\n %gep = getelementptr inbounds i32, ptr %dst, i32 %iv\n store i32 %iv.next, ptr %gep, align 4\n %ec = icmp eq i32 %iv.next, 0\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/first-order-recurrence-chains.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -S %s"
],
"tests": [
{
"test_name": "test_resinking_required",
"test_body": "define double @test_resinking_required(ptr %p, ptr noalias %a, ptr noalias %b) {\nEntry:\n br label %Loop\n\nLoop: ; preds = %Loop, %Entry\n %for.1 = phi double [ %l1, %Loop ], [ 0.000000e+00, %Entry ]\n %for.2 = phi double [ %l2, %Loop ], [ 0.000000e+00, %Entry ]\n %for.3 = phi double [ %for.2, %Loop ], [ 0.000000e+00, %Entry ]\n %iv = phi i64 [ %iv.next, %Loop ], [ 0, %Entry ]\n %USE_2_FORS = fdiv double %for.3, %for.1\n %div = fdiv double 0.000000e+00, %for.1\n %l1 = load double, ptr %a, align 8\n %iv.next = add nuw nsw i64 %iv, 1\n %l2 = load double, ptr %b, align 8\n store double %div, ptr %p, align 8\n %cond = icmp eq i64 %iv.next, 1000\n br i1 %cond, label %End, label %Loop\n\nEnd: ; preds = %Loop\n %res.1 = fadd double %for.1, %for.2\n %res.2 = fadd double %res.1, %for.3\n ret double %res.2\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/if-pred-stores.ll",
"commands": [
"opt -S -vectorize-num-stores-pred=1 -force-vector-width=1 -force-vector-interleave=2 -passes=loop-vectorize,simplifycfg -verify-loop-info -simplifycfg-require-and-preserve-domtree=1 < %s",
"opt -S -vectorize-num-stores-pred=1 -force-vector-width=1 -force-vector-interleave=2 -passes=loop-vectorize -verify-loop-info < %s",
"opt -S -vectorize-num-stores-pred=1 -force-vector-width=2 -force-vector-interleave=1 -passes=loop-vectorize,simplifycfg -verify-loop-info -simplifycfg-require-and-preserve-domtree=1 < %s"
],
"tests": [
{
"test_name": "minimal_bit_widths_with_aliasing_store",
"test_body": "target datalayout = \"e-m:o-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine void @minimal_bit_widths_with_aliasing_store(i1 %c, ptr %ptr) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.inc, %entry\n %tmp0 = phi i64 [ %tmp6, %for.inc ], [ 0, %entry ]\n %tmp1 = phi i64 [ %tmp7, %for.inc ], [ 1000, %entry ]\n %tmp2 = getelementptr i8, ptr %ptr, i64 %tmp0\n %tmp3 = load i8, ptr %tmp2, align 1\n store i8 0, ptr %tmp2, align 1\n br i1 %c, label %if.then, label %for.inc\n\nif.then: ; preds = %for.body\n %tmp4 = zext i8 %tmp3 to i32\n %tmp5 = trunc i32 %tmp4 to i8\n store i8 %tmp5, ptr %tmp2, align 1\n br label %for.inc\n\nfor.inc: ; preds = %if.then, %for.body\n %tmp6 = add nuw nsw i64 %tmp0, 1\n %tmp7 = add i64 %tmp1, -1\n %tmp8 = icmp eq i64 %tmp7, 0\n br i1 %tmp8, label %for.end, label %for.body\n\nfor.end: ; preds = %for.inc\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/induction.ll",
"commands": [
"opt < %s -passes=loop-vectorize -force-vector-interleave=1 -force-vector-width=2 -force-widen-divrem-via-safe-divisor=0 -S",
"opt < %s -passes=loop-vectorize,instcombine -force-vector-interleave=1 -force-vector-width=2 -force-widen-divrem-via-safe-divisor=0 -S",
"opt < %s -passes=loop-vectorize,instcombine -force-vector-interleave=2 -force-vector-width=2 -force-widen-divrem-via-safe-divisor=0 -S",
"opt < %s -passes=loop-vectorize -force-vector-interleave=2 -force-vector-width=2 -force-widen-divrem-via-safe-divisor=0 -S",
"opt < %s -passes=loop-vectorize,instcombine -force-vector-interleave=2 -force-vector-width=4 -force-widen-divrem-via-safe-divisor=0 -enable-interleaved-mem-accesses -S"
],
"tests": [
{
"test_name": "max_i32_backedgetaken",
"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\ndefine i32 @max_i32_backedgetaken() {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %a.0 = phi i32 [ 1, %entry ], [ %a.0.and, %loop ]\n %b.0 = phi i32 [ 0, %entry ], [ %b.next, %loop ]\n %a.0.and = and i32 %a.0, 4\n %b.next = add i32 %b.0, -1\n %ec = icmp eq i32 %b.next, 0\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i32 %a.0.and\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/interleave-and-scalarize-only.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-width=1 -force-vector-interleave=2 -debug -disable-output %s 2>&1",
"opt -passes=loop-vectorize -force-vector-width=1 -force-vector-interleave=2 -S %s"
],
"tests": [
{
"test_name": "scalarize_ptrtoint",
"test_body": "define void @scalarize_ptrtoint(ptr %src, ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep = getelementptr ptr, ptr %src, i64 %iv\n %l = load ptr, ptr %gep, align 8\n %cast = ptrtoint ptr %l to i64\n %add = add i64 %cast, 10\n %cast.2 = inttoptr i64 %add to ptr\n store ptr %cast.2, ptr %dst, align 8\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv.next, 1024\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/is_fpclass.ll",
"commands": [
"opt < %s -passes=loop-vectorize -force-vector-width=2 -S"
],
"tests": [
{
"test_name": "d",
"test_body": "define void @d() {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %i = phi i64 [ 0, %entry ], [ %i7, %loop ]\n %i3 = load float, ptr null, align 4\n %i4 = getelementptr float, ptr @d, i64 %i\n %i5 = tail call i1 @llvm.is.fpclass.f32(float %i3, i32 0)\n %i6 = select i1 %i5, float 0.000000e+00, float 0.000000e+00\n store float %i6, ptr %i4, align 4\n %i7 = add i64 %i, 1\n %i8 = icmp eq i64 %i7, 128\n br i1 %i8, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i1 @llvm.is.fpclass.f32(float, i32 immarg) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/optimal-epilog-vectorization.ll",
"commands": [
"opt -passes='loop-vectorize' -force-vector-width=4 -enable-epilogue-vectorization -epilogue-vectorization-force-VF=4 -S %s",
"opt -passes='loop-vectorize' -enable-epilogue-vectorization -epilogue-vectorization-force-VF=2 -S %s"
],
"tests": [
{
"test_name": "multiple_ivs_wide",
"test_body": "target datalayout = \"e-m:e-i64:64-n32:64-v128:128:128\"\n\ndefine void @multiple_ivs_wide(ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.2 = phi i32 [ -64, %entry ], [ %iv.2.next, %loop ]\n %iv.next = add i32 %iv, 2\n %iv.2.next = add i32 %iv.2, 2\n %gep = getelementptr inbounds i32, ptr %dst, i32 %iv\n store i32 %iv.2.next, ptr %gep, align 4\n %ec = icmp eq i32 %iv.next, 128\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/runtime-checks-hoist.ll",
"commands": [
"opt < %s -passes='loop-vectorize' -force-vector-interleave=1 -S -force-vector-width=4 -debug-only=loop-accesses,loop-vectorize,loop-utils"
],
"tests": [
{
"test_name": "stride_check_known_via_loop_guard",
"test_body": "target datalayout = \"e-m:e-i64:64-i128:128-n32:64-S128\"\n\ndefine void @stride_check_known_via_loop_guard(ptr %C, ptr %A, i32 %Acols) {\nentry:\n %pre.c = icmp ugt i32 %Acols, 0\n br i1 %pre.c, label %exit, label %outer.header\n\nouter.header: ; preds = %outer.latch, %entry\n %outer.iv = phi i32 [ 0, %entry ], [ %outer.iv.next, %outer.latch ]\n %mul.us = mul i32 %outer.iv, %Acols\n %arrayidx.us = getelementptr double, ptr %A, i32 %mul.us\n br label %inner\n\ninner: ; preds = %inner, %outer.header\n %inner.iv = phi i32 [ 0, %outer.header ], [ %inner.iv.next, %inner ]\n %gep.C = getelementptr inbounds double, ptr %C, i32 %inner.iv\n %l = load double, ptr %arrayidx.us, align 8\n store double %l, ptr %gep.C, align 8\n %inner.iv.next = add i32 %inner.iv, 1\n %inner.c = icmp eq i32 %inner.iv.next, 1000\n br i1 %inner.c, label %outer.latch, label %inner\n\nouter.latch: ; preds = %inner\n %outer.iv.next = add i32 %outer.iv, 1\n %outer.c = icmp ult i32 %outer.iv, 128\n br i1 %outer.c, label %exit, label %outer.header\n\nexit: ; preds = %outer.latch, %entry\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"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": "step_direction_unknown",
"test_body": "define void @step_direction_unknown(i32 %arg, ptr %dst) {\nentry:\n %add = add i32 %arg, 1\n br label %loop\n\nloop: ; preds = %loop, %entry\n %phi = phi i64 [ 0, %entry ], [ %add2, %loop ]\n %trunc = trunc i64 %phi to i32\n %mul = mul i32 %add, %trunc\n %zext = zext i32 %mul to i64\n %getelementptr = getelementptr double, ptr %dst, i64 %zext\n store double 0.000000e+00, ptr %getelementptr, align 8\n %add2 = add i64 %phi, 1\n %icmp = icmp eq i64 %add2, 1024\n br i1 %icmp, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "integer_induction_wraps_scev_predicate_known",
"test_body": "define void @integer_induction_wraps_scev_predicate_known(i32 %x, ptr %call, ptr %start) {\nentry:\n %mul = shl i32 %x, 1\n br label %for.cond\n\nfor.cond: ; preds = %for.cond, %entry\n %iv = phi i32 [ 30, %entry ], [ %inc, %for.cond ]\n %p.0 = phi ptr [ %start, %entry ], [ %add.ptr, %for.cond ]\n %add.ptr = getelementptr i8, ptr %p.0, i32 %mul\n %arrayidx = getelementptr ptr, ptr %call, i32 %iv\n store ptr %p.0, ptr %arrayidx, align 4\n %inc = add i32 %iv, 1\n %tobool.not = icmp eq i32 %iv, 1024\n br i1 %tobool.not, label %for.end, label %for.cond\n\nfor.end: ; preds = %for.cond\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/vplan-sink-scalars-and-merge-vf1.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-interleave=2 -force-vector-width=1 -debug -disable-output %s 2>&1"
],
"tests": [
{
"test_name": "sink_with_sideeffects",
"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\ndefine void @sink_with_sideeffects(i1 %c, ptr %ptr) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.inc, %entry\n %tmp0 = phi i64 [ %tmp6, %for.inc ], [ 0, %entry ]\n %tmp1 = phi i64 [ %tmp7, %for.inc ], [ 1024, %entry ]\n %tmp2 = getelementptr i8, ptr %ptr, i64 %tmp0\n %tmp3 = load i8, ptr %tmp2, align 1\n store i8 0, ptr %tmp2, align 1\n %tmp4 = zext i8 %tmp3 to i32\n %tmp5 = trunc i32 %tmp4 to i8\n br i1 %c, label %if.then, label %for.inc\n\nif.then: ; preds = %for.body\n store i8 %tmp5, ptr %tmp2, align 1\n br label %for.inc\n\nfor.inc: ; preds = %if.then, %for.body\n %tmp6 = add nuw nsw i64 %tmp0, 1\n %tmp7 = add i64 %tmp1, -1\n %tmp8 = icmp eq i64 %tmp7, 0\n br i1 %tmp8, label %for.end, label %for.body\n\nfor.end: ; preds = %for.inc\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[LoopVectorizer] Assertion `EPResumeVal && \"must have a resume value for the canonical IV\"' failed.",
"body": "clang -Wno-incompatible-pointer-types -O3 -march=z13 -S -c crash19.i -o a.out -w -mllvm -disable-licm-promotion -mllvm -epilogue-vectorization-force-VF=2 \n\n[crash19.tar.gz](https://github.com/user-attachments/files/18383534/crash19.tar.gz)\n\n#9 0x000002aa3ff5e440 preparePlanForEpilogueVectorLoop\n#12 0x000002aa3ffa098a llvm::LoopVectorizePass::run\n\n@bmahjour \n@fhahn ",
"author": "JonPsson1",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "fhahn",
"body": "@JonPsson1 Was the test case fuzzer generated? Just curious, because it had a loop with unsigned max as iteration count."
},
{
"author": "JonPsson1",
"body": "> [@JonPsson1](https://github.com/JonPsson1) Was the test case fuzzer generated? Just curious, because it had a loop with unsigned max as iteration count.\n\nNo, it was a CSmith test case."
},
{
"author": "fhahn",
"body": "@JonPsson1 Could you check if it fixes the full reproducer? If not, it would be great if you could share the full reproducer?"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
Timeout
| null |
139728
|
https://github.com/llvm/llvm-project/issues/139728
|
crash
|
be6c1684c058ff40b5cb29e7eb88f06f72dd50df
| 2025-05-13T13:36:11
|
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "d79d9b8fbfc7e8411aeaf2f5e1be9d4247594fee",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
16142,
16157
],
[
16210,
16216
],
[
17799,
17815
],
[
18696,
18701
]
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::getLastInstructionInBundle",
"BoUpSLP::setInsertPointAfterBundle",
"BoUpSLP::vectorizeTree"
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit d79d9b8fbfc7e8411aeaf2f5e1be9d4247594fee
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Fri May 16 12:52:27 2025 -0400
[SLP]Change the insertion point for outside-block-used nodes and prevec phi operand gathers
Need to set the insertion point for (non-schedulable) vector node after
the last instruction in the node to avoid def-use breakage. But it also
causes miscompilation with gather/buildvector operands of the phi nodes,
used in the same phi only in the block.
These nodes supposed to be inserted at the end of the block and after
changing the insertion point for the non-schedulable vec block, it also
may break def-use dependencies. Need to prevector such nodes, to emit
them as early as possible, so the vectorized nodes are inserted before
these nodes.
Fixes #139728
Reviewers: hiraditya, HanKuanChen, RKSimon
Reviewed By: RKSimon
Pull Request: https://github.com/llvm/llvm-project/pull/139917
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index eb339282fdae..19d19946ea23 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -16142,16 +16142,10 @@ Instruction &BoUpSLP::getLastInstructionInBundle(const TreeEntry *E) {
[](Value *V) {
return !isa<GetElementPtrInst>(V) && isa<Instruction>(V);
})) ||
- all_of(E->Scalars,
- [](Value *V) {
- return isa<PoisonValue>(V) ||
- (!isVectorLikeInstWithConstOps(V) &&
- isUsedOutsideBlock(V));
- }) ||
- (E->isGather() && E->Idx == 0 && all_of(E->Scalars, [](Value *V) {
- return isa<ExtractElementInst, UndefValue>(V) ||
- areAllOperandsNonInsts(V);
- })))
+ all_of(E->Scalars, [](Value *V) {
+ return isa<PoisonValue>(V) ||
+ (!isVectorLikeInstWithConstOps(V) && isUsedOutsideBlock(V));
+ }))
Res = FindLastInst();
else
Res = FindFirstInst();
@@ -16210,7 +16204,7 @@ void BoUpSLP::setInsertPointAfterBundle(const TreeEntry *E) {
}
if (IsPHI ||
(!E->isGather() && E->State != TreeEntry::SplitVectorize &&
- doesNotNeedToSchedule(E->Scalars)) ||
+ all_of(E->Scalars, areAllOperandsNonInsts)) ||
(GatheredLoadsEntriesFirst.has_value() &&
E->Idx >= *GatheredLoadsEntriesFirst && !E->isGather() &&
E->getOpcode() == Instruction::Load)) {
@@ -17799,17 +17793,27 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) {
Value *VecOp = NewPhi->getIncomingValueForBlock(IBB);
NewPhi->addIncoming(VecOp, IBB);
TreeEntry *OpTE = getOperandEntry(E, I);
+ assert(!OpTE->VectorizedValue && "Expected no vectorized value.");
OpTE->VectorizedValue = VecOp;
continue;
}
Builder.SetInsertPoint(IBB->getTerminator());
Builder.SetCurrentDebugLocation(PH->getDebugLoc());
- Value *Vec = vectorizeOperand(E, I);
+ const TreeEntry *OpE = getOperandEntry(E, I);
+ Value *Vec;
+ if (OpE->isGather()) {
+ assert(OpE->VectorizedValue && "Expected vectorized value.");
+ Vec = OpE->VectorizedValue;
+ if (auto *IVec = dyn_cast<Instruction>(Vec))
+ Builder.SetInsertPoint(IVec->getNextNonDebugInstruction());
+ } else {
+ Vec = vectorizeOperand(E, I);
+ }
if (VecTy != Vec->getType()) {
- assert((It != MinBWs.end() || getOperandEntry(E, I)->isGather() ||
- MinBWs.contains(getOperandEntry(E, I))) &&
- "Expected item in MinBWs.");
+ assert(
+ (It != MinBWs.end() || OpE->isGather() || MinBWs.contains(OpE)) &&
+ "Expected item in MinBWs.");
Vec = Builder.CreateIntCast(Vec, VecTy, GetOperandSignedness(I));
}
NewPhi->addIncoming(Vec, IBB);
@@ -18696,6 +18700,28 @@ Value *BoUpSLP::vectorizeTree(
else
Builder.SetInsertPoint(&F->getEntryBlock(), F->getEntryBlock().begin());
+ // Vectorize gather operands of the PHI nodes.
+ for (const std::unique_ptr<TreeEntry> &TE : reverse(VectorizableTree)) {
+ if (TE->isGather() && TE->UserTreeIndex.UserTE &&
+ TE->UserTreeIndex.UserTE->hasState() &&
+ !TE->UserTreeIndex.UserTE->isAltShuffle() &&
+ TE->UserTreeIndex.UserTE->State == TreeEntry::Vectorize &&
+ TE->UserTreeIndex.UserTE->getOpcode() == Instruction::PHI &&
+ !TE->VectorizedValue) {
+ auto *PH = cast<PHINode>(TE->UserTreeIndex.UserTE->getMainOp());
+ BasicBlock *IBB = PH->getIncomingBlock(TE->UserTreeIndex.EdgeIdx);
+ // If there is the same incoming block earlier - skip, it will be handled
+ // in PHI node.
+ if (TE->UserTreeIndex.EdgeIdx > 0 &&
+ any_of(seq<unsigned>(TE->UserTreeIndex.EdgeIdx), [&](unsigned Idx) {
+ return PH->getIncomingBlock(Idx) == IBB;
+ }))
+ continue;
+ Builder.SetInsertPoint(IBB->getTerminator());
+ Builder.SetCurrentDebugLocation(PH->getDebugLoc());
+ (void)vectorizeTree(TE.get());
+ }
+ }
// Emit gathered loads first to emit better code for the users of those
// gathered loads.
for (const std::unique_ptr<TreeEntry> &TE : VectorizableTree) {
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/AArch64/reused-scalar-repeated-in-node.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=aarch64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define void @test() {\nentry:\n br label %bb61\n\nbb61: ; preds = %entry\n br label %bb64\n\nbb62: ; No predecessors!\n br i1 poison, label %bb63, label %bb64\n\nbb63: ; preds = %bb62\n br label %bb64\n\nbb64: ; preds = %bb63, %bb62, %bb61\n %i = phi nsz float [ poison, %bb61 ], [ poison, %bb63 ], [ poison, %bb62 ]\n %i65 = phi nsz float [ poison, %bb61 ], [ poison, %bb63 ], [ poison, %bb62 ]\n %i66 = load float, ptr poison, align 16\n %i67 = load float, ptr poison, align 4\n %i68 = load float, ptr poison, align 8\n %i69 = load float, ptr poison, align 4\n %i70 = load float, ptr poison, align 4\n %i71 = load float, ptr poison, align 16\n %i72 = load float, ptr poison, align 4\n %i73 = load float, ptr poison, align 8\n %i74 = load float, ptr poison, align 4\n %i75 = load float, ptr poison, align 16\n %i76 = load float, ptr poison, align 4\n br i1 poison, label %bb167, label %bb77\n\nbb77: ; preds = %bb64\n br label %bb78\n\nbb78: ; preds = %bb78, %bb77\n %i79 = phi nsz float [ %i66, %bb77 ], [ %i103, %bb78 ]\n %i80 = phi nsz float [ %i67, %bb77 ], [ %i104, %bb78 ]\n %i81 = phi nsz float [ %i68, %bb77 ], [ %i105, %bb78 ]\n %i82 = phi nsz float [ poison, %bb77 ], [ %i106, %bb78 ]\n %i83 = phi nsz float [ poison, %bb77 ], [ %i123, %bb78 ]\n %i84 = phi nsz float [ %i69, %bb77 ], [ %i124, %bb78 ]\n %i85 = phi nsz float [ poison, %bb77 ], [ %i125, %bb78 ]\n %i86 = phi nsz float [ %i70, %bb77 ], [ %i126, %bb78 ]\n %i87 = fmul fast float %i79, poison\n %i88 = fmul fast float %i80, poison\n %i89 = fmul fast float %i81, poison\n %i90 = fmul fast float %i82, poison\n %i91 = fmul fast float %i83, poison\n %i92 = fadd fast float %i91, %i87\n %i93 = fmul fast float %i84, poison\n %i94 = fadd fast float %i93, %i88\n %i95 = fmul fast float %i85, poison\n %i96 = fadd fast float %i95, %i89\n %i97 = fmul fast float %i86, poison\n %i98 = fadd fast float %i97, %i90\n %i99 = fadd fast float %i92, poison\n %i100 = fadd fast float %i94, poison\n %i101 = fadd fast float %i96, poison\n %i102 = fadd fast float %i98, poison\n %i103 = fadd fast float %i99, poison\n %i104 = fadd fast float %i100, poison\n %i105 = fadd fast float %i101, poison\n %i106 = fadd fast float %i102, poison\n %i107 = fmul fast float %i79, poison\n %i108 = fmul fast float %i80, poison\n %i109 = fmul fast float %i81, poison\n %i110 = fmul fast float %i82, poison\n %i111 = fmul fast float %i83, poison\n %i112 = fadd fast float %i111, %i107\n %i113 = fmul fast float %i84, poison\n %i114 = fadd fast float %i113, %i108\n %i115 = fmul fast float %i85, poison\n %i116 = fadd fast float %i115, %i109\n %i117 = fmul fast float %i86, poison\n %i118 = fadd fast float %i117, %i110\n %i119 = fadd fast float %i112, poison\n %i120 = fadd fast float %i114, poison\n %i121 = fadd fast float %i116, poison\n %i122 = fadd fast float %i118, poison\n %i123 = fadd fast float %i119, poison\n %i124 = fadd fast float %i120, poison\n %i125 = fadd fast float %i121, poison\n %i126 = fadd fast float %i122, poison\n %i127 = fmul fast float %i79, %i\n %i128 = fmul fast float %i80, %i\n %i129 = fmul fast float %i81, %i\n %i130 = fmul fast float %i82, %i\n %i131 = fmul fast float %i83, %i65\n %i132 = fadd fast float %i131, %i127\n %i133 = fmul fast float %i84, %i65\n %i134 = fadd fast float %i133, %i128\n %i135 = fmul fast float %i85, %i65\n %i136 = fadd fast float %i135, %i129\n %i137 = fmul fast float %i86, %i65\n %i138 = fadd fast float %i137, %i130\n %i139 = fadd fast float %i132, poison\n %i140 = fadd fast float %i134, poison\n %i141 = fadd fast float %i136, poison\n %i142 = fadd fast float %i138, poison\n %i143 = fadd fast float %i139, poison\n %i144 = fadd fast float %i140, poison\n %i145 = fadd fast float %i141, poison\n %i146 = fadd fast float %i142, poison\n %i147 = fmul fast float %i79, poison\n %i148 = fmul fast float %i80, poison\n %i149 = fmul fast float %i81, poison\n %i150 = fmul fast float %i82, poison\n %i151 = fmul fast float %i83, poison\n %i152 = fadd fast float %i151, %i147\n %i153 = fmul fast float %i84, poison\n %i154 = fadd fast float %i153, %i148\n %i155 = fmul fast float %i85, poison\n %i156 = fadd fast float %i155, %i149\n %i157 = fmul fast float %i86, poison\n %i158 = fadd fast float %i157, %i150\n %i159 = fadd fast float %i152, poison\n %i160 = fadd fast float %i154, poison\n %i161 = fadd fast float %i156, poison\n %i162 = fadd fast float %i158, poison\n %i163 = fadd fast float %i159, poison\n %i164 = fadd fast float %i160, poison\n %i165 = fadd fast float %i161, poison\n %i166 = fadd fast float %i162, poison\n br i1 poison, label %bb78, label %bb167\n\nbb167: ; preds = %bb78, %bb64\n %i168 = phi nsz float [ %i76, %bb64 ], [ %i166, %bb78 ]\n %i169 = phi nsz float [ poison, %bb64 ], [ %i165, %bb78 ]\n %i170 = phi nsz float [ poison, %bb64 ], [ %i164, %bb78 ]\n %i171 = phi nsz float [ %i75, %bb64 ], [ %i163, %bb78 ]\n %i172 = phi nsz float [ %i74, %bb64 ], [ %i146, %bb78 ]\n %i173 = phi nsz float [ %i73, %bb64 ], [ %i145, %bb78 ]\n %i174 = phi nsz float [ %i72, %bb64 ], [ %i144, %bb78 ]\n %i175 = phi nsz float [ %i71, %bb64 ], [ %i143, %bb78 ]\n %i176 = phi nsz float [ %i70, %bb64 ], [ %i126, %bb78 ]\n %i177 = phi nsz float [ poison, %bb64 ], [ %i125, %bb78 ]\n %i178 = phi nsz float [ %i69, %bb64 ], [ %i124, %bb78 ]\n %i179 = phi nsz float [ poison, %bb64 ], [ %i123, %bb78 ]\n %i180 = phi nsz float [ poison, %bb64 ], [ %i106, %bb78 ]\n %i181 = phi nsz float [ %i68, %bb64 ], [ %i105, %bb78 ]\n %i182 = phi nsz float [ %i67, %bb64 ], [ %i104, %bb78 ]\n %i183 = phi nsz float [ %i66, %bb64 ], [ %i103, %bb78 ]\n store float %i182, ptr poison, align 1\n store float %i174, ptr poison, align 1\n br i1 poison, label %bb186, label %bb184\n\nbb184: ; preds = %bb167\n br label %bb185\n\nbb185: ; preds = %bb185, %bb184\n br i1 poison, label %bb185, label %bb186\n\nbb186: ; preds = %bb185, %bb167\n %i187 = phi nsz float [ %i178, %bb167 ], [ poison, %bb185 ]\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/buildvectors-parent-phi-nodes.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-generic-linux-gnu -mattr=+avx < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define void @test(ptr %0, float %1) {\n %3 = load float, ptr %0, align 4\n br label %4\n\n4: ; preds = %4, %2\n %5 = phi float [ %1, %4 ], [ %3, %2 ]\n %6 = phi float [ %1, %4 ], [ 0.000000e+00, %2 ]\n %7 = phi float [ %28, %4 ], [ 0.000000e+00, %2 ]\n %8 = phi float [ %26, %4 ], [ 0.000000e+00, %2 ]\n %9 = phi float [ %26, %4 ], [ %3, %2 ]\n %10 = phi float [ %24, %4 ], [ 0.000000e+00, %2 ]\n %11 = fmul float %9, 0.000000e+00\n %12 = fadd float %11, 0.000000e+00\n %13 = fmul float %7, 0.000000e+00\n %14 = fadd float %13, 0.000000e+00\n %15 = fmul float %10, 0.000000e+00\n %16 = fadd float %15, 0.000000e+00\n %17 = fmul float %8, 0.000000e+00\n %18 = fadd float %17, 0.000000e+00\n %19 = insertelement <4 x float> zeroinitializer, float %12, i64 0\n %20 = insertelement <4 x float> %19, float %14, i64 1\n %21 = insertelement <4 x float> %20, float %16, i64 2\n %22 = insertelement <4 x float> %21, float %18, i64 3\n store <4 x float> %22, ptr %0, align 16\n %23 = fmul float %6, 0.000000e+00\n %24 = fadd float %23, 0.000000e+00\n %25 = fmul float %6, 0.000000e+00\n %26 = fadd float %25, 0.000000e+00\n %27 = fmul float %5, 0.000000e+00\n %28 = fadd float %27, 0.000000e+00\n br label %4\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/full-matched-bv-with-subvectors.ll",
"commands": [
"opt -S --passes=slp-vectorizer -slp-threshold=-9999 -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define i32 @test(i64 %l.549) {\nentry:\n %conv3 = sext i32 0 to i64\n br label %if.then19\n\np: ; preds = %if.end29, %if.end25\n %l.0 = phi i64 [ %xor, %if.end29 ], [ %l.5493, %if.end25 ]\n %m.0 = phi i64 [ %not21, %if.end29 ], [ %m.550, %if.end25 ]\n br i1 false, label %s, label %q\n\nq: ; preds = %land.lhs.true, %p\n %xor39 = phi i64 [ 0, %p ], [ 0, %land.lhs.true ]\n %l.1 = phi i64 [ 0, %p ], [ 0, %land.lhs.true ]\n %m.1 = phi i64 [ 0, %p ], [ 0, %land.lhs.true ]\n br i1 false, label %lor.lhs.false, label %r\n\nlor.lhs.false: ; preds = %q\n br i1 false, label %land.lhs.true, label %s\n\nr: ; preds = %if.then19, %q\n %xor38 = phi i64 [ %xor39, %q ], [ %xor, %if.then19 ]\n %j.0 = phi i64 [ %conv3, %q ], [ %not21, %if.then19 ]\n %l.2 = phi i64 [ %l.1, %q ], [ %l.549, %if.then19 ]\n %m.2 = phi i64 [ %m.1, %q ], [ %m.550, %if.then19 ]\n br i1 false, label %s, label %land.lhs.true\n\nland.lhs.true: ; preds = %r, %lor.lhs.false\n %xor37 = phi i64 [ %xor38, %r ], [ 0, %lor.lhs.false ]\n %j.1 = phi i64 [ %j.0, %r ], [ 0, %lor.lhs.false ]\n %l.3 = phi i64 [ %l.2, %r ], [ 0, %lor.lhs.false ]\n %m.3 = phi i64 [ %m.2, %r ], [ 0, %lor.lhs.false ]\n br i1 false, label %q, label %s\n\ns: ; preds = %land.lhs.true, %r, %lor.lhs.false, %p\n %xor36 = phi i64 [ %xor37, %land.lhs.true ], [ %xor38, %r ], [ %xor39, %lor.lhs.false ], [ %l.0, %p ]\n %j.2 = phi i64 [ %j.1, %land.lhs.true ], [ %j.0, %r ], [ %conv3, %lor.lhs.false ], [ %m.0, %p ]\n %l.4 = phi i64 [ %l.3, %land.lhs.true ], [ %l.2, %r ], [ %l.1, %lor.lhs.false ], [ %l.0, %p ]\n %m.4 = phi i64 [ %m.3, %land.lhs.true ], [ %m.2, %r ], [ %m.1, %lor.lhs.false ], [ %m.0, %p ]\n br label %if.then19\n\nif.then19: ; preds = %s, %entry\n %m.550 = phi i64 [ 0, %entry ], [ %m.4, %s ]\n %l.5493 = phi i64 [ 0, %entry ], [ %l.4, %s ]\n %xor = xor i64 0, 0\n %not21 = xor i64 0, 0\n br i1 false, label %r, label %if.end25\n\nif.end25: ; preds = %if.then19\n br i1 false, label %if.end29, label %p\n\nif.end29: ; preds = %if.end25\n br label %p\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/matched-bv-schedulable.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s -slp-threshold=-99999"
],
"tests": [
{
"test_name": "test",
"test_body": "define void @test() {\nbb:\n br i1 false, label %bb1, label %bb5\n\nbb1: ; preds = %bb1, %bb\n %phi = phi i32 [ %or4, %bb1 ], [ 0, %bb ]\n %phi2 = phi i32 [ %add, %bb1 ], [ 0, %bb ]\n %add = add i32 1, 0\n %or = or i32 0, %phi2\n %or3 = or i32 %or, 0\n %mul = mul i32 0, 0\n %or4 = or i32 %phi, %mul\n br i1 false, label %bb1, label %bb5\n\nbb5: ; preds = %bb1, %bb\n %phi6 = phi i32 [ 0, %bb ], [ %or4, %bb1 ]\n %phi7 = phi i32 [ 0, %bb ], [ %or, %bb1 ]\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/matched-nodes-updated.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-9999 < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define i32 @test(i32 %s.0) {\nentry:\n br label %k\n\nk: ; preds = %t, %entry\n %.pre = phi i32 [ 0, %entry ], [ %.pre4053, %t ]\n br label %o\n\nif.end3: ; No predecessors!\n br label %if.end6\n\nif.end6: ; preds = %o, %if.end3\n %.pre43 = phi i32 [ 0, %if.end3 ], [ 0, %o ]\n %0 = phi i32 [ 0, %if.end3 ], [ 0, %o ]\n %1 = phi i32 [ 0, %if.end3 ], [ 0, %o ]\n %h.4 = phi i32 [ 0, %if.end3 ], [ %h.6, %o ]\n %i.4 = phi i32 [ 0, %if.end3 ], [ %i.7, %o ]\n %j.4 = phi i32 [ 0, %if.end3 ], [ %j.5, %o ]\n %l.4 = phi i32 [ 0, %if.end3 ], [ 0, %o ]\n %not8 = xor i32 %i.4, 0\n %not9 = xor i32 %h.4, 0\n br i1 false, label %if.end24, label %if.then11\n\nif.then11: ; preds = %if.end6\n br label %if.end24\n\nif.then18: ; No predecessors!\n br label %t\n\nt: ; preds = %o, %if.then18\n %.pre40 = phi i32 [ %.pre4053, %o ], [ 0, %if.then18 ]\n %i.5 = phi i32 [ 0, %o ], [ 0, %if.then18 ]\n %l.5 = phi i32 [ %l.7, %o ], [ 0, %if.then18 ]\n %r.2 = phi i32 [ %r.4, %o ], [ 0, %if.then18 ]\n %s.2 = phi i32 [ %s.4, %o ], [ 0, %if.then18 ]\n br i1 false, label %if.end24, label %k\n\nif.end24: ; preds = %t, %if.then11, %if.end6\n %.pre4050 = phi i32 [ 0, %if.then11 ], [ 0, %if.end6 ], [ %.pre40, %t ]\n %.pre42 = phi i32 [ 0, %if.then11 ], [ %.pre43, %if.end6 ], [ %.pre40, %t ]\n %2 = phi i32 [ 0, %if.then11 ], [ %0, %if.end6 ], [ %.pre40, %t ]\n %3 = phi i32 [ 0, %if.then11 ], [ %1, %if.end6 ], [ %.pre40, %t ]\n %i.6 = phi i32 [ %i.4, %if.then11 ], [ %i.7, %if.end6 ], [ %i.5, %t ]\n %l.6 = phi i32 [ 0, %if.then11 ], [ %l.4, %if.end6 ], [ %l.5, %t ]\n %r.3 = phi i32 [ %j.4, %if.then11 ], [ %not8, %if.end6 ], [ %r.2, %t ]\n %s.3 = phi i32 [ 0, %if.then11 ], [ %not9, %if.end6 ], [ %s.2, %t ]\n br label %o\n\no: ; preds = %if.end24, %k\n %.pre4053 = phi i32 [ 0, %k ], [ %.pre4050, %if.end24 ]\n %.pre46 = phi i32 [ 0, %k ], [ %.pre42, %if.end24 ]\n %4 = phi i32 [ 0, %k ], [ %2, %if.end24 ]\n %5 = phi i32 [ 0, %k ], [ %3, %if.end24 ]\n %h.6 = phi i32 [ 0, %k ], [ %r.3, %if.end24 ]\n %i.7 = phi i32 [ 0, %k ], [ %i.6, %if.end24 ]\n %j.5 = phi i32 [ 0, %k ], [ %s.3, %if.end24 ]\n %l.7 = phi i32 [ %.pre, %k ], [ %l.6, %if.end24 ]\n %r.4 = phi i32 [ 0, %k ], [ %r.3, %if.end24 ]\n %s.4 = phi i32 [ %s.0, %k ], [ %s.3, %if.end24 ]\n br i1 false, label %t, label %if.end6\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/node-outside-used-only.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-99999 < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine i64 @test() {\n;\nbb:\n br label %bb1\n\nbb1:\n %phi = phi i32 [ 0, %bb ], [ %or, %bb5 ]\n %phi2 = phi i32 [ 0, %bb ], [ %or4, %bb5 ]\n %or = or i32 %phi, 0\n %add = add i32 0, 0\n %or3 = or i32 %add, %phi2\n %or4 = or i32 %or3, 0\n br label %bb5\n\nbb5:\n br i1 false, label %bb6, label %bb1\n\nbb6:\n %phi7 = phi i32 [ %or, %bb5 ]\n %phi8 = phi i32 [ %or3, %bb5 ]\n ret i64 0\n}",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/reduced-val-vectorized-in-transform.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-10 < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define i32 @test(i1 %cond) {\nentry:\n br label %bb\n\nbb: ; preds = %bb, %entry\n %p1 = phi i32 [ %or92, %bb ], [ 0, %entry ]\n %p2 = phi i32 [ %0, %bb ], [ 0, %entry ]\n %p3 = phi i32 [ %4, %bb ], [ 0, %entry ]\n %0 = or i32 1, 0\n %or8.i = or i32 0, 0\n %or9.i = or i32 0, 0\n %or91 = or i32 %p1, 0\n %or12.i = or i32 %p2, 0\n %or92 = or i32 1, 0\n %1 = xor i32 %or91, %or12.i\n %2 = xor i32 %1, %or9.i\n %3 = xor i32 %2, %or8.i\n %4 = xor i32 %3, %or92\n br i1 %cond, label %exit, label %bb\n\nexit: ; preds = %bb\n ret i32 %4\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/split-node-num-operands.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -mattr=+avx -slp-threshold=-1000 < %s"
],
"tests": [
{
"test_name": "Foo",
"test_body": "define i64 @Foo(ptr align 8 dereferenceable(344) %0, i64 %1) {\n %3 = getelementptr i8, ptr %0, i64 104\n %4 = getelementptr i8, ptr %0, i64 112\n %5 = getelementptr i8, ptr %0, i64 24\n %6 = load i64, ptr %3, align 8\n %7 = load i64, ptr %4, align 8\n %8 = load i64, ptr %5, align 8\n %9 = load i64, ptr %0, align 8\n br label %10\n\n10: ; preds = %18, %2\n %11 = phi i64 [ %9, %2 ], [ 0, %18 ]\n %12 = phi i64 [ %8, %2 ], [ %12, %18 ]\n %13 = phi i64 [ %7, %2 ], [ 0, %18 ]\n %14 = phi i64 [ %6, %2 ], [ 0, %18 ]\n switch i32 0, label %15 [\n i32 0, label %18\n ]\n\n15: ; preds = %10\n %16 = tail call i64 @llvm.umin.i64(i64 0, i64 0)\n %17 = tail call i64 @llvm.umax.i64(i64 0, i64 0)\n br label %18\n\n18: ; preds = %15, %10\n %19 = phi i64 [ %17, %15 ], [ 0, %10 ]\n %20 = phi i64 [ %16, %15 ], [ 0, %10 ]\n %21 = phi i64 [ %11, %15 ], [ 0, %10 ]\n %22 = phi i64 [ %12, %15 ], [ 0, %10 ]\n %23 = phi i64 [ %13, %15 ], [ %1, %10 ]\n %24 = phi i64 [ %14, %15 ], [ 0, %10 ]\n br i1 false, label %.loopexit206, label %10\n\n.loopexit206: ; preds = %18\n switch i32 0, label %26 [\n i32 0, label %.cont174\n i32 1, label %25\n ]\n\n25: ; preds = %.loopexit206\n br label %.cont174\n\n26: ; preds = %.loopexit206\n %27 = tail call i64 @llvm.umin.i64(i64 0, i64 0)\n %28 = tail call i64 @llvm.umax.i64(i64 0, i64 0)\n br label %.cont174\n\n.cont174: ; preds = %26, %25, %.loopexit206\n %.sroa.139.1 = phi i64 [ %28, %26 ], [ %19, %25 ], [ %19, %.loopexit206 ]\n %.sroa.133.1 = phi i64 [ %27, %26 ], [ 0, %25 ], [ %20, %.loopexit206 ]\n %.sroa.81.1 = phi i64 [ %23, %26 ], [ 0, %25 ], [ %23, %.loopexit206 ]\n %.sroa.75.1 = phi i64 [ %24, %26 ], [ 0, %25 ], [ %24, %.loopexit206 ]\n %.sroa.21.1 = phi i64 [ %21, %26 ], [ 0, %25 ], [ %21, %.loopexit206 ]\n %.sroa.15.1 = phi i64 [ %22, %26 ], [ 0, %25 ], [ %22, %.loopexit206 ]\n %29 = phi i64 [ %28, %26 ], [ 0, %25 ], [ %19, %.loopexit206 ]\n %30 = phi i64 [ %27, %26 ], [ 0, %25 ], [ %20, %.loopexit206 ]\n ret i64 0\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i64 @llvm.umax.i64(i64, i64) #0\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i64 @llvm.umin.i64(i64, i64) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/SLPVectorizer/revec.ll",
"commands": [
"opt -passes=slp-vectorizer -S -slp-revec -slp-max-reg-size=1024 -slp-threshold=-100 %s"
],
"tests": [
{
"test_name": "test8",
"test_body": "define void @test8() {\nentry:\n br i1 false, label %for0, label %for.body\n\nfor0: ; preds = %for.body, %entry\n %0 = phi <2 x float> [ zeroinitializer, %entry ], [ %4, %for.body ]\n %1 = phi <2 x float> [ zeroinitializer, %entry ], [ %5, %for.body ]\n %2 = phi <2 x float> [ zeroinitializer, %entry ], [ %4, %for.body ]\n %3 = phi <2 x float> [ zeroinitializer, %entry ], [ %5, %for.body ]\n ret void\n\nfor.body: ; preds = %for.body, %entry\n %4 = phi <2 x float> [ %4, %for.body ], [ zeroinitializer, %entry ]\n %5 = phi <2 x float> [ %5, %for.body ], [ zeroinitializer, %entry ]\n br i1 false, label %for0, label %for.body\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "test7",
"test_body": "define void @test7() {\n %1 = getelementptr i8, ptr null, i64 16\n %2 = trunc <8 x i64> zeroinitializer to <8 x i16>\n store <8 x i16> %2, ptr %1, align 2\n %3 = trunc <8 x i64> zeroinitializer to <8 x i16>\n store <8 x i16> %3, ptr null, align 2\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 case.",
"body": "To reproduce run opt with the test below using -passes=slp-vectorizer -slp-threshold=-99999:\n\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 i64 @wombat() #0 gc \"statepoint-example\" {\nbb:\n br label %bb1\n\nbb1: ; preds = %bb5, %bb\n %phi = phi i32 [ 0, %bb ], [ %or, %bb5 ]\n %phi2 = phi i32 [ 0, %bb ], [ %or4, %bb5 ]\n %or = or i32 %phi, 0\n %add = add i32 0, 0\n %or3 = or i32 %add, %phi2\n %or4 = or i32 %or3, 0\n br label %bb5\n\nbb5: ; preds = %bb1\n br i1 false, label %bb6, label %bb1\n\nbb6: ; preds = %bb5\n %phi7 = phi i32 [ %or, %bb5 ]\n %phi8 = phi i32 [ %or3, %bb5 ]\n ret i64 0\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```\n\nReproducer: https://godbolt.org/z/xh9xjfEKc\n\nStack dump:\n```\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer -slp-threshold=-99999 <source>\n1.\tRunning pass \"verify\" on module \"<source>\"\n #0 0x00000000055a8748 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x55a8748)\n #1 0x00000000055a60d4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007479c4242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007479c42969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007479c4242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007479c42287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x000000000080bfcd llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0\n #7 0x00000000054e4741 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x54e4741)\n #8 0x00000000053e0e38 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x53e0e38)\n #9 0x0000000000940c0e 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+0x940c0e)\n#10 0x000000000539ff70 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x539ff70)\n#11 0x000000000094b05a 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+0x94b05a)\n#12 0x000000000093e82c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x93e82c)\n#13 0x00007479c4229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#14 0x00007479c4229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#15 0x0000000000936465 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x936465)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```",
"author": "TatyanaDoubts",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
|
894935cb5146fd2ac6334cc8b11e6d6e0e264fe6
| null |
158259
|
https://github.com/llvm/llvm-project/issues/158259
|
crash
|
da315a3528807574d1c9ba44758d35bfc515e709
| 2025-09-12T09:57:14
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "45ce88758d24df7c2c322b152cf4894f3e8ee45a",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
[
1762,
1770
]
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"GeneratedRTChecks"
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 45ce88758d24df7c2c322b152cf4894f3e8ee45a
Author: Florian Hahn <flo@fhahn.com>
Date: Tue Sep 30 11:03:55 2025 +0100
[LV] Don't preserve LCSSA in SCEVExpander for runtime checks. (#159556)
LV does not preserve LCSSA, it constructs it just before processing a
loop to vectorize. Runtime check expressions are invariant to that loop,
so expanding them should not break LCSSA form for the loop we are about
to vectorize.
This fixes a crash when discarding instructions generated when expanding
runtime checks, if the expansion introduces LCSSA phis for values from
other loops which are not in LCSSA form: we would introduce new LCSSA
phis and update all outside users, some of which are not created by the
expander and cannot be cleaned up.
Fixes https://github.com/llvm/llvm-project/issues/158259.
PR: https://github.com/llvm/llvm-project/pull/159556
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index ab5c9c99b944..a0043bed2e0c 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1762,9 +1762,10 @@ public:
GeneratedRTChecks(PredicatedScalarEvolution &PSE, DominatorTree *DT,
LoopInfo *LI, TargetTransformInfo *TTI,
const DataLayout &DL, TTI::TargetCostKind CostKind)
- : DT(DT), LI(LI), TTI(TTI), SCEVExp(*PSE.getSE(), DL, "scev.check"),
- MemCheckExp(*PSE.getSE(), DL, "scev.check"), PSE(PSE),
- CostKind(CostKind) {}
+ : DT(DT), LI(LI), TTI(TTI),
+ SCEVExp(*PSE.getSE(), DL, "scev.check", /*PreserveLCSSA=*/false),
+ MemCheckExp(*PSE.getSE(), DL, "scev.check", /*PreserveLCSSA=*/false),
+ PSE(PSE), CostKind(CostKind) {}
/// Generate runtime checks in SCEVCheckBlock and MemCheckBlock, so we can
/// accurately estimate the cost of the runtime checks. The blocks are
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/X86/cleanup-runtime-checks.ll",
"commands": [
"opt -p loop-vectorize -S %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndeclare ptr @get()\ndeclare i1 @cond()\n\n; Make sure we can clean up the created runtime checks, if vectorization isn't\n; profitable.\ndefine void @widget(i32 %arg, i64 %arg1, ptr %src) #0 {\n;\nentry:\n br label %loop.1.header\n\nloop.1.header:\n br label %inner.1\n\ninner.1:\n %c.1 = call i1 @cond()\n br i1 %c.1, label %inner.2, label %inner.1\n\ninner.2:\n %load = call ptr @get()\n %c.2 = call i1 @cond()\n br i1 %c.2, label %loop.2, label %loop.1.latch\n\nloop.1.latch:\n br label %loop.1.header\n\nloop.2:\n %iv = phi i32 [ %arg, %inner.2 ], [ %iv.next, %loop.2 ]\n %phi8 = phi i32 [ 99, %inner.2 ], [ %or, %loop.2 ]\n %gep.src = getelementptr i32, ptr %src, i32 %iv\n %l = load i32, ptr %gep.src, align 4\n %or = or i32 %phi8, %l\n store i32 %or, ptr %load, align 4\n %iv.next = add i32 %iv, 1\n %ec = icmp eq i32 %iv, 100\n br i1 %ec, label %exit, label %loop.2, !prof !0\n\nexit:\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+avx2\" }\n!0 = !{!\"branch_weights\", i32 89478484, i32 1879048192}\n;.\n;.",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/pr45259.ll",
"commands": [
"opt < %s -S -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=1"
],
"tests": [
{
"test_name": "widget",
"test_body": "define i8 @widget(ptr %arr, i8 %t9) {\nbb:\n br label %bb6\n\nbb6: ; preds = %bb6, %bb\n %t1.0 = phi ptr [ %arr, %bb ], [ null, %bb6 ]\n %c = call i1 @cond()\n br i1 %c, label %for.preheader, label %bb6\n\nfor.preheader: ; preds = %bb6\n br label %for.body\n\nfor.body: ; preds = %for.body, %for.preheader\n %iv = phi i8 [ %iv.next, %for.body ], [ 0, %for.preheader ]\n %iv.next = add i8 %iv, 1\n %ptr = getelementptr inbounds i8, ptr %arr, i8 %iv.next\n %t3.i = icmp slt i8 %iv.next, %t9\n %t3.i8 = zext i1 %t3.i to i8\n store i8 %t3.i8, ptr %ptr, align 1\n %ec = icmp eq ptr %t1.0, %ptr\n br i1 %ec, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n %iv.next.lcssa = phi i8 [ %iv.next, %for.body ]\n ret i8 %iv.next.lcssa\n}\n\ndeclare i1 @cond()\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/pr47343-expander-lcssa-after-cfg-update.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-width=2 %s -S"
],
"tests": [
{
"test_name": "f",
"test_body": "@f.e = external global i32, align 1\n@d = external global ptr, align 1\n\ndeclare i1 @cond()\n\ndefine void @f() {\nentry:\n br label %outer.header\n\nouter.header: ; preds = %outer.latch, %entry\n %0 = load ptr, ptr @d, align 1\n %c.0 = call i1 @cond()\n br i1 %c.0, label %outer.exit.0, label %inner.1.header\n\ninner.1.header: ; preds = %inner.1.latch, %outer.header\n %c.1 = call i1 @cond()\n br i1 %c.1, label %inner.1.latch, label %outer.latch\n\ninner.1.latch: ; preds = %inner.1.header\n %c.2 = call i1 @cond()\n br i1 %c.2, label %outer.exit.1, label %inner.1.header\n\nouter.latch: ; preds = %inner.1.header\n br label %outer.header\n\nouter.exit.0: ; preds = %outer.header\n br label %loop\n\nouter.exit.1: ; preds = %inner.1.latch\n br label %loop\n\nloop: ; preds = %loop, %outer.exit.1, %outer.exit.0\n %iv = phi i32 [ %iv.next, %loop ], [ 0, %outer.exit.0 ], [ 0, %outer.exit.1 ]\n %conv6.us.us.us = zext i1 false to i32\n store i32 %conv6.us.us.us, ptr @f.e, align 1\n store i8 10, ptr %0, align 1\n %iv.next = add nsw i32 %iv, 1\n %ec = icmp eq i32 %iv.next, 500\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/reuse-lcssa-phi-scev-expansion.ll",
"commands": [
"opt -p loop-vectorize -force-vector-width=2 -S %s"
],
"tests": [
{
"test_name": "runtime_checks_ptr_inductions",
"test_body": "declare i32 @val()\n\ndefine void @runtime_checks_ptr_inductions(ptr %dst.1, ptr %dst.2, i1 %c) {\nentry:\n br label %loop.1\n\nloop.1: ; preds = %loop.1, %entry\n %ptr.iv.1 = phi ptr [ %dst.1, %entry ], [ %ptr.iv.1.next, %loop.1 ]\n %call = call i32 @val()\n %sel.dst = select i1 %c, ptr %dst.1, ptr %dst.2\n %ptr.iv.1.next = getelementptr i8, ptr %ptr.iv.1, i64 1\n %ec.1 = icmp eq i32 %call, 0\n br i1 %ec.1, label %loop.2.header, label %loop.1\n\nloop.2.header: ; preds = %loop.2.latch, %loop.1\n %iv = phi i32 [ 1, %loop.1 ], [ %dec7, %loop.2.latch ]\n %ptr.iv.2 = phi ptr [ %ptr.iv.1, %loop.1 ], [ %ptr.iv.2.next, %loop.2.latch ]\n %ptr.iv.3 = phi ptr [ %sel.dst, %loop.1 ], [ %ptr.iv.3.next, %loop.2.latch ]\n %ec.2 = icmp eq i32 %iv, 1024\n br i1 %ec.2, label %exit, label %loop.2.latch\n\nloop.2.latch: ; preds = %loop.2.header\n %dec7 = add i32 %iv, 1\n %ptr.iv.3.next = getelementptr i8, ptr %ptr.iv.3, i64 1\n %l = load i8, ptr %ptr.iv.3, align 1\n %ptr.iv.2.next = getelementptr i8, ptr %ptr.iv.2, i64 1\n store i8 %l, ptr %ptr.iv.2, align 1\n br label %loop.2.header\n\nexit: ; preds = %loop.2.header\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/skeleton-lcssa-crash.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-width=2 -force-vector-interleave=1 -S %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define i16 @test(ptr %arg, i64 %N) {\nentry:\n br label %outer\n\nouter: ; preds = %outer.latch, %outer, %entry\n %l.1 = load ptr, ptr %arg, align 8\n %l.2 = load ptr, ptr %arg, align 8\n %c.1 = call i1 @cond()\n br i1 %c.1, label %outer, label %inner\n\ninner: ; preds = %inner.latch, %outer\n %c.2 = call i1 @cond()\n br i1 %c.2, label %outer.latch, label %inner.bb\n\ninner.bb: ; preds = %inner\n %c.3 = call i1 @cond()\n br i1 %c.3, label %loop.3, label %inner.latch\n\ninner.latch: ; preds = %inner.bb\n %c.4 = call i1 @cond()\n br i1 %c.4, label %exit, label %inner\n\nouter.latch: ; preds = %inner\n br label %outer\n\nloop.3: ; preds = %loop.3, %inner.bb\n %iv = phi i64 [ %iv.next, %loop.3 ], [ 0, %inner.bb ]\n %iv.next = add nuw nsw i64 %iv, 1\n %c.5 = icmp ult i64 %iv, %N\n %gep.1 = getelementptr inbounds i16, ptr %l.1, i64 %iv.next\n %loop.l.1 = load i16, ptr %gep.1, align 2\n %gep.2 = getelementptr inbounds i16, ptr %l.2, i64 0\n store i16 %loop.l.1, ptr %gep.2, align 2\n br i1 %c.5, label %loop.3, label %exit\n\nexit: ; preds = %loop.3, %inner.latch\n %l.3 = load i16, ptr %l.1, align 2\n ret i16 %l.3\n}\n\ndeclare i1 @cond()\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "LoopVectorizer crashes in SCEVExpanderCleanup",
"body": "Assert in vectorizer during SCEVExpanderCleanup: https://godbolt.org/z/Ezcf68T85\n\nAssert message:\n\n```\nopt: .../llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp:2466: 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\nIR reproducer:\n\n```llvm\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @widget(i32 %arg, i64 %arg1) #0 {\nbb:\n br label %bb2\nbb2: ; preds = %bb4, %bb\n br label %bb5\nbb3: ; preds = %bb5\n %load = load ptr addrspace(1), ptr null, align 8%getelementptr = getelementptr i32, ptr addrspace(1) null, i64 %arg1\n br i1 false, label %bb7, label %bb4\nbb4: ; preds = %bb3\n br label %bb2\nbb5: ; preds = %bb5, %bb2\n br i1 false, label %bb3, label %bb5\nbb6: ; preds = %bb7\n ret void\nbb7: ; preds = %bb7, %bb3\n %phi = phi i32 [ %add, %bb7 ], [ %arg, %bb3 ]\n %phi8 = phi i32 [ %or, %bb7 ], [ 0, %bb3 ]\n %load9 = load i32, ptr addrspace(1) %getelementptr, align 4\n %or = or i32 %phi8, 0\n store i32 %or, ptr addrspace(1) %load, align 4\n %add = add i32 %phi, 1\n %icmp = icmp eq i32 %phi, 0\n br i1 %icmp, label %bb6, label %bb7, !prof !0\n}\nattributes #0 = { \"target-features\"=\"+avx2\" }\n!0 = !{!\"branch_weights\", i32 89478484, i32 1879048192}\n```\nRun as: `opt -passes=loop-vectorize`\n",
"author": "Theodor",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "hiraditya",
"body": "Stack trace\n```\nopt: /root/llvm-project/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp:2466: 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.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.\nStack dump:\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 \"widget\"\n #0 0x00000000058aae78 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x58aae78)\n #1 0x00000000058a7d24 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x000073e015642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x000073e0156969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x000073e015642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x000073e0156287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x000073e01562871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x000073e015639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x0000000004b3a12f llvm::SCEVExpanderCleaner::cleanup() (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4b3a12f)\n #9 0x00000000035ed532 (anonymous namespace)::GeneratedRTChecks::~GeneratedRTChecks() LoopVectorize.cpp:0:0\n#10 0x00000000036409aa llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x36409aa)\n```"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
Cannot find a good commit
| null |
166035
|
https://github.com/llvm/llvm-project/issues/166035
|
crash
|
bf5332cd8266cddb3bfb2e8436a2161c10602855
| 2025-11-02T02:09:29
|
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "7d5659083cb21722416b38fe92b7200fe89be232",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
20975,
20980
]
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::BlockScheduling::tryScheduleBundle"
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 7d5659083cb21722416b38fe92b7200fe89be232
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Mon Nov 3 06:25:20 2025 -0800
[SLP]Do not create copyable node, if parent node is non-schedulable and has a use in binop.
If the parent node is non-schedulable (only externally used instructions), and at least one instruction has multiple uses and used in the binop, such copyable node should be created. Otherwise, it may contain wrong def-use chain model, which cannot be effective detected.
Fixes #166035
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 34b405ced8c0..bf3f52c51b64 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -20975,6 +20975,27 @@ BoUpSLP::BlockScheduling::tryScheduleBundle(ArrayRef<Value *> VL, BoUpSLP *SLP,
if (isa<PHINode>(S.getMainOp()) ||
isVectorLikeInstWithConstOps(S.getMainOp()))
return nullptr;
+ // If the parent node is non-schedulable and the current node is copyable, and
+ // any of parent instructions are used outside several basic blocks or in
+ // bin-op node - cancel scheduling, it may cause wrong def-use deps in
+ // analysis, leading to a crash.
+ // Non-scheduled nodes may not have related ScheduleData model, which may lead
+ // to a skipped dep analysis.
+ if (S.areInstructionsWithCopyableElements() && EI && EI.UserTE->hasState() &&
+ EI.UserTE->doesNotNeedToSchedule() &&
+ EI.UserTE->getOpcode() != Instruction::PHI &&
+ any_of(EI.UserTE->Scalars, [](Value *V) {
+ auto *I = dyn_cast<Instruction>(V);
+ if (!I || I->hasOneUser())
+ return false;
+ for (User *U : I->users()) {
+ auto *UI = cast<Instruction>(U);
+ if (isa<BinaryOperator>(UI))
+ return true;
+ }
+ return false;
+ }))
+ return std::nullopt;
bool HasCopyables = S.areInstructionsWithCopyableElements();
if (((!HasCopyables && doesNotNeedToSchedule(VL)) ||
all_of(VL, [&](Value *V) { return S.isNonSchedulable(V); }))) {
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/parent-non-schedule-multi-use-in-binop.ll",
"commands": [
"opt -passes=slp-vectorizer -S --mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n@a = common global [100 x i64] zeroinitializer, align 64\n\ndefine void @test() {\n;\nentry:\n %.promoted104.i = load i64, ptr getelementptr inbounds nuw (i8, ptr @a, i64 56), align 8\n %.promoted103.i = load i64, ptr getelementptr inbounds nuw (i8, ptr @a, i64 48), align 8\n %0 = add i64 %.promoted104.i, 1\n %1 = add i64 %.promoted103.i, 1\n %2 = add i64 %0, 1\n br i1 false, label %lop.rhscnt.i.peel, label %land.end.i.peel\n\nlop.rhscnt.i.peel:\n %3 = or i64 %1, 1\n br label %land.end.i.peel\n\nland.end.i.peel:\n %4 = phi i64 [ %2, %entry ], [ %0, %lop.rhscnt.i.peel ]\n %5 = phi i64 [ %1, %entry ], [ %3, %lop.rhscnt.i.peel ]\n store i64 %5, ptr getelementptr inbounds nuw (i8, ptr @a, i64 48), align 8\n store i64 %4, ptr getelementptr inbounds nuw (i8, ptr @a, i64 56), align 8\n ret void\n}",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "Clang crashes when compiling with PGO",
"body": "The crash happens on the last commit `8331c732b4ce523e0731981f`\n\n```\n$ clang-trunk -v\nclang version 22.0.0git (https://github.com/llvm/llvm-project.git 8331c732b4ce523e0731981ffd42f4e3f4064d2d)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\n```\n\nClang compiles successfully under plain `-O3` but it crashes when using PGO `-O3 -fprofile-instr-generate`\n\n```\n$ clang-trunk -O3 abc.c\n$ clang-trunk -O3 -fprofile-instr-generate abc.c\nclang-22: /data/soft/trunk/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:21837: void llvm::slpvectorizer::BoUpSLP::scheduleBlock(const llvm::slpvectorizer::BoUpSLP&, BlockScheduling*): Assertion `all_of(Bundles, [](const ScheduleBundle *Bundle) { return Bundle->isScheduled(); }) && \"must be scheduled at this point\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\nStack dump:\n0.\tProgram arguments: /data/installed/root-clang/bin/clang-22 -cc1 -triple x86_64-unknown-linux-gnu -O3 -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name abc.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=/home/absozero/projects/reduce -fprofile-instrument=clang -fcoverage-compilation-dir=/home/absozero/projects/reduce -resource-dir /data/installed/root-clang/lib/clang/22 -I/data/installed/root-bin/include/ -internal-isystem /data/installed/root-clang/lib/clang/22/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -ferror-limit 19 -fmessage-length=176 -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/abc-11c2d3.o -x c abc.c\n1.\t<eof> parser at end of file\n2.\tOptimizer\n3.\tRunning pass \"function<eager-inv>(drop-unnecessary-assumes,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-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-arithmetic;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<O3>,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;switch-to-arithmetic;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 \"abc.c\"\n4.\tRunning pass \"slp-vectorizer\" on function \"main\"\n #0 0x000059f4656e6dc2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/installed/root-clang/bin/clang-22+0x43e8dc2)\n #1 0x000059f4656e3abf llvm::sys::RunSignalHandlers() (/data/installed/root-clang/bin/clang-22+0x43e5abf)\n #2 0x000059f4656e3c0c SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #3 0x000075f681e45330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)\n #4 0x000075f681e9eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #5 0x000075f681e9eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #6 0x000075f681e9eb2c pthread_kill ./nptl/pthread_kill.c:89:10\n #7 0x000075f681e4527e raise ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x000075f681e288ff abort ./stdlib/abort.c:81:7\n #9 0x000075f681e2881b _nl_load_domain ./intl/loadmsgcat.c:1177:9\n#10 0x000075f681e3b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)\n#11 0x000059f46728a217 llvm::slpvectorizer::BoUpSLP::scheduleBlock(llvm::slpvectorizer::BoUpSLP const&, llvm::slpvectorizer::BoUpSLP::BlockScheduling*) (/data/installed/root-clang/bin/clang-22+0x5f8c217)\n#12 0x000059f46729c30b llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::SmallDenseSet<llvm::Value*, 4u, llvm::DenseMapInfo<llvm::Value*, void>> const&, llvm::Instruction*, llvm::ArrayRef<std::tuple<llvm::Value*, unsigned int, bool>>) (/data/installed/root-clang/bin/clang-22+0x5f9e30b)\n#13 0x000059f4672a017a llvm::slpvectorizer::BoUpSLP::vectorizeTree() (/data/installed/root-clang/bin/clang-22+0x5fa217a)\n#14 0x000059f4672bba0e llvm::SLPVectorizerPass::vectorizeStoreChain(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, unsigned int, unsigned int, unsigned int&) (/data/installed/root-clang/bin/clang-22+0x5fbda0e)\n#15 0x000059f4672bd1fe 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::map<long, unsigned int, std::less<long>, std::allocator<std::pair<long const, unsigned int>>> const&)::operator()(std::map<long, unsigned int, std::less<long>, std::allocator<std::pair<long const, unsigned int>>> const&) const SLPVectorizer.cpp:0:0\n#16 0x000059f4672bfc98 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>>&) (/data/installed/root-clang/bin/clang-22+0x5fc1c98)\n#17 0x000059f4672c0c65 llvm::SLPVectorizerPass::vectorizeStoreChains(llvm::slpvectorizer::BoUpSLP&) (/data/installed/root-clang/bin/clang-22+0x5fc2c65)\n#18 0x000059f4672c2b7a llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (/data/installed/root-clang/bin/clang-22+0x5fc4b7a)\n#19 0x000059f4672c3829 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/data/installed/root-clang/bin/clang-22+0x5fc5829)\n#20 0x000059f4667895e5 llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/data/installed/root-clang/bin/clang-22+0x548b5e5)\n#21 0x000059f464ffc5c5 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/data/installed/root-clang/bin/clang-22+0x3cfe5c5)\n#22 0x000059f4626a8935 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/data/installed/root-clang/bin/clang-22+0x13aa935)\n#23 0x000059f464ffacc1 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/data/installed/root-clang/bin/clang-22+0x3cfccc1)\n#24 0x000059f4626a9075 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/data/installed/root-clang/bin/clang-22+0x13ab075)\n#25 0x000059f464ffb4ad llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/data/installed/root-clang/bin/clang-22+0x3cfd4ad)\n#26 0x000059f4659a1932 (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#27 0x000059f4659a590d 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*) (/data/installed/root-clang/bin/clang-22+0x46a790d)\n#28 0x000059f46602d060 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/data/installed/root-clang/bin/clang-22+0x4d2f060)\n#29 0x000059f467b27dec clang::ParseAST(clang::Sema&, bool, bool) (/data/installed/root-clang/bin/clang-22+0x6829dec)\n#30 0x000059f466358107 clang::FrontendAction::Execute() (/data/installed/root-clang/bin/clang-22+0x505a107)\n#31 0x000059f4662ddf0e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/data/installed/root-clang/bin/clang-22+0x4fdff0e)\n#32 0x000059f46645141e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/data/installed/root-clang/bin/clang-22+0x515341e)\n#33 0x000059f46221b09b cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/data/installed/root-clang/bin/clang-22+0xf1d09b)\n#34 0x000059f4622105e7 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0\n#35 0x000059f46221535e clang_main(int, char**, llvm::ToolContext const&) (/data/installed/root-clang/bin/clang-22+0xf1735e)\n#36 0x000059f4620ab74a main (/data/installed/root-clang/bin/clang-22+0xdad74a)\n#37 0x000075f681e2a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3\n#38 0x000075f681e2a28b call_init ./csu/../csu/libc-start.c:128:20\n#39 0x000075f681e2a28b __libc_start_main ./csu/../csu/libc-start.c:347:5\n#40 0x000059f46220fb55 _start (/data/installed/root-clang/bin/clang-22+0xf11b55)\nclang-trunk: error: unable to execute command: Aborted\nclang-trunk: error: clang frontend command failed due to signal (use -v to see invocation)\nclang version 22.0.0git (https://github.com/llvm/llvm-project.git 8331c732b4ce523e0731981ffd42f4e3f4064d2d)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /data/installed/root-clang/bin\nBuild config: +assertions\nclang-trunk: note: diagnostic msg:\n********************\n\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\nPreprocessed source(s) and associated run script(s) are located at:\nclang-trunk: note: diagnostic msg: /tmp/abc-afc680.c\nclang-trunk: note: diagnostic msg: /tmp/abc-afc680.sh\nclang-trunk: note: diagnostic msg:\n\n********************\n```\n\nThe test file is \n\n```c\nchar a, b;\nint c, d;\nstruct e {\n unsigned f;\n} g;\nshort h;\nvolatile int i;\nstatic int j[] = {3, 3};\nchar(k)(char l) { return l; }\nchar(m)(char l) { return l < 0 ? 0 : l; }\nvoid(n)() { a || c ? 0 : a; }\nvoid(o)(int l, int p) { (l && p && l > p) || 0 ? 0 : 0; }\nvoid(q)(char l) { l == 0 ? 0 : l; }\nstatic int r() {\n short s;\n struct e t;\n for (; h; h++) {\n g.f = 0;\n for (; g.f <= 2; g.f++) {\n q(0);\n s = s == j;\n q(d);\n o((0 != t.f) != j[1], 5);\n t = g;\n }\n j[1] = 9;\n n();\n b = k(i || 0 || (o(m(b), t.f), t.f)) && 0;\n }\n}\nvoid main() { r(); }\n```\n",
"author": "Slice0w0",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": [
{
"author": "aviralgarg05",
"body": "I would like to solve this issue"
},
{
"author": "alexey-bataev",
"body": "> I would like to solve this issue\n\nThis one is very tricky, deals with the multiple deps for copyable elements and parent nodes, which do not require scheduling."
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null | null |
118798
|
https://github.com/llvm/llvm-project/issues/118798
|
hang
|
8a90b5b31776957cb9cfa4f9547d19544640c5cc
| 2024-12-05T13:19:25
|
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "27eaa8a40ef338bea611f693fa8e810b1fc8d78d",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": [
[
427,
433
]
],
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": [
"InstCombinerImpl::commonShiftTransforms"
],
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 27eaa8a40ef338bea611f693fa8e810b1fc8d78d
Author: Maurice Heumann <MauriceHeumann@gmail.com>
Date: Thu Dec 5 16:57:27 2024 +0100
[InstCombine] Prevent infinite loop with two shifts (#118806)
The following pattern: `(C2 << X) << C1` will usually be transformed
into `(C2 << C1) << X`, essentially swapping `X` and `C1`.
However, this should only be done when `C1` is an immediate constant,
otherwise thiscan lead to both constants being swapped forever.
This fixes #118798.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
index 10c3ccdb2243..d511e79e3e48 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
@@ -427,7 +427,8 @@ Instruction *InstCombinerImpl::commonShiftTransforms(BinaryOperator &I) {
if (Instruction *R = FoldOpIntoSelect(I, SI))
return R;
- if (Constant *CUI = dyn_cast<Constant>(Op1))
+ Constant *CUI;
+ if (match(Op1, m_ImmConstant(CUI)))
if (Instruction *Res = FoldShiftByConstant(Op0, CUI, I))
return Res;
|
[
{
"file": "llvm/test/Transforms/InstCombine/shl-twice-constant.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "testfunc",
"test_body": "@c = external constant i8\n@c2 = external constant i8\n\ndefine i64 @testfunc() {\n %shl1 = shl i64 1, ptrtoint (ptr @c2 to i64)\n %shl2 = shl i64 %shl1, ptrtoint (ptr @c to i64)\n ret i64 %shl2\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[InstCombine] Infinite loop when combining two `shl` instructions",
"body": "The following sample triggers an infinite loop in instcombine:\n\n```\n@c = external constant i8\n@c2 = external constant i8\n\ndefine i16 @testfunc() {\nentry:\n %0 = shl i64 1, ptrtoint (ptr @c2 to i64)\n %1 = shl i64 %0, ptrtoint (ptr @c to i64)\n %2 = inttoptr i64 %1 to ptr\n %3 = load i16, ptr %2, align 1\n ret i16 %3\n}\n```\n\nhttps://godbolt.org/z/WP6YvGjPq\n",
"author": "momo5502",
"labels": [
"llvm:instcombine",
"llvm:hang"
],
"comments": [
{
"author": "momo5502",
"body": "I have a potential fix and will create a PR soon"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
N/A
| null |
91691
|
https://github.com/llvm/llvm-project/issues/91691
|
miscompilation
|
1fadb2b0c881ced247931f442fdee6c4ed96dccb
| 2024-05-10T02:43:43
|
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "b5f4210e9f51f938ae517f219f04f9ab431a2684",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": [
[
3343,
3349
],
[
3366,
3371
],
[
3379,
3384
],
[
3448,
3461
]
],
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": [
"foldBitCeil",
"isSafeToRemoveBitCeilSelect"
],
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit b5f4210e9f51f938ae517f219f04f9ab431a2684
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Mon May 13 14:27:59 2024 +0800
[InstCombine] Drop nuw flag when CtlzOp is a sub nuw (#91776)
See the following case:
```
define i32 @src1(i32 %x) {
%dec = sub nuw i32 -2, %x
%ctlz = tail call i32 @llvm.ctlz.i32(i32 %dec, i1 false)
%sub = sub nsw i32 32, %ctlz
%shl = shl i32 1, %sub
%ugt = icmp ult i32 %x, -2
%sel = select i1 %ugt, i32 %shl, i32 1
ret i32 %sel
}
define i32 @tgt1(i32 %x) {
%dec = sub nuw i32 -2, %x
%ctlz = tail call i32 @llvm.ctlz.i32(i32 %dec, i1 false)
%sub = sub nsw i32 32, %ctlz
%and = and i32 %sub, 31
%shl = shl nuw i32 1, %and
ret i32 %shl
}
```
`nuw` in `%dec` should be dropped after the select instruction is
eliminated.
Alive2: https://alive2.llvm.org/ce/z/7S9529
Fixes https://github.com/llvm/llvm-project/issues/91691.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index ee090e012508..a3ddb402bf66 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -3343,7 +3343,8 @@ Instruction *InstCombinerImpl::foldSelectOfBools(SelectInst &SI) {
// pattern.
static bool isSafeToRemoveBitCeilSelect(ICmpInst::Predicate Pred, Value *Cond0,
const APInt *Cond1, Value *CtlzOp,
- unsigned BitWidth) {
+ unsigned BitWidth,
+ bool &ShouldDropNUW) {
// The challenge in recognizing std::bit_ceil(X) is that the operand is used
// for the CTLZ proper and select condition, each possibly with some
// operation like add and sub.
@@ -3366,6 +3367,8 @@ static bool isSafeToRemoveBitCeilSelect(ICmpInst::Predicate Pred, Value *Cond0,
ConstantRange CR = ConstantRange::makeExactICmpRegion(
CmpInst::getInversePredicate(Pred), *Cond1);
+ ShouldDropNUW = false;
+
// Match the operation that's used to compute CtlzOp from CommonAncestor. If
// CtlzOp == CommonAncestor, return true as no operation is needed. If a
// match is found, execute the operation on CR, update CR, and return true.
@@ -3379,6 +3382,7 @@ static bool isSafeToRemoveBitCeilSelect(ICmpInst::Predicate Pred, Value *Cond0,
return true;
}
if (match(CtlzOp, m_Sub(m_APInt(C), m_Specific(CommonAncestor)))) {
+ ShouldDropNUW = true;
CR = ConstantRange(*C).sub(CR);
return true;
}
@@ -3448,14 +3452,20 @@ static Instruction *foldBitCeil(SelectInst &SI, IRBuilderBase &Builder) {
Pred = CmpInst::getInversePredicate(Pred);
}
+ bool ShouldDropNUW;
+
if (!match(FalseVal, m_One()) ||
!match(TrueVal,
m_OneUse(m_Shl(m_One(), m_OneUse(m_Sub(m_SpecificInt(BitWidth),
m_Value(Ctlz)))))) ||
!match(Ctlz, m_Intrinsic<Intrinsic::ctlz>(m_Value(CtlzOp), m_Zero())) ||
- !isSafeToRemoveBitCeilSelect(Pred, Cond0, Cond1, CtlzOp, BitWidth))
+ !isSafeToRemoveBitCeilSelect(Pred, Cond0, Cond1, CtlzOp, BitWidth,
+ ShouldDropNUW))
return nullptr;
+ if (ShouldDropNUW)
+ cast<Instruction>(CtlzOp)->setHasNoUnsignedWrap(false);
+
// Build 1 << (-CTLZ & (BitWidth-1)). The negation likely corresponds to a
// single hardware instruction as opposed to BitWidth - CTLZ, where BitWidth
// is an integer constant. Masking with BitWidth-1 comes free on some
|
[
{
"file": "llvm/test/Transforms/InstCombine/bit_ceil.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "pr91691",
"test_body": "define i32 @pr91691(i32 %0) {\n %2 = sub nuw i32 -2, %0\n %3 = tail call i32 @llvm.ctlz.i32(i32 %2, i1 false)\n %4 = sub i32 32, %3\n %5 = shl i32 1, %4\n %6 = icmp ult i32 %0, -2\n %7 = select i1 %6, i32 %5, i32 1\n ret i32 %7\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctlz.i32(i32, i1 immarg) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "bit_ceil_v4i32",
"test_body": "define <4 x i32> @bit_ceil_v4i32(<4 x i32> %x) {\n %dec = add <4 x i32> %x, splat (i32 -1)\n %ctlz = tail call <4 x i32> @llvm.ctlz.v4i32(<4 x i32> %dec, i1 false)\n %sub = sub <4 x i32> splat (i32 32), %ctlz\n %shl = shl <4 x i32> splat (i32 1), %sub\n %ugt = icmp ugt <4 x i32> %x, splat (i32 1)\n %sel = select <4 x i1> %ugt, <4 x i32> %shl, <4 x i32> splat (i32 1)\n ret <4 x i32> %sel\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x i32> @llvm.ctlz.v4i32(<4 x i32>, i1 immarg) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "pr91691_keep_nsw",
"test_body": "define i32 @pr91691_keep_nsw(i32 %0) {\n %2 = sub nsw i32 -2, %0\n %3 = tail call i32 @llvm.ctlz.i32(i32 %2, i1 false)\n %4 = sub i32 32, %3\n %5 = shl i32 1, %4\n %6 = icmp ult i32 %0, -2\n %7 = select i1 %6, i32 %5, i32 1\n ret i32 %7\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctlz.i32(i32, i1 immarg) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "instcombine removes a select, making code more poisonous",
"body": "https://alive2.llvm.org/ce/z/c__jy8\r\n\r\nthis function:\r\n```llvm\r\ndefine i32 @f(i32 %0) {\r\n %2 = sub nuw i32 -2, %0\r\n %3 = tail call i32 @llvm.ctlz.i32(i32 %2, i1 false)\r\n %4 = sub i32 32, %3\r\n %5 = shl i32 1, %4\r\n %6 = icmp ult i32 %0, -2\r\n %7 = select i1 %6, i32 %5, i32 1\r\n ret i32 %7\r\n}\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\r\ndeclare i32 @llvm.ctlz.i32(i32, i1 immarg) #0\r\n\r\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\r\n```\r\n\r\nis getting rewritten to not have the select, but the select was blocking a poison value. the bad thing happens when -1 is passed as an argument, see the Alive link for a detailed execution trace\r\n\r\n```llvm\r\ndefine i32 @f(i32 %0) {\r\n %2 = sub nuw i32 -2, %0\r\n %3 = tail call range(i32 0, 33) i32 @llvm.ctlz.i32(i32 %2, i1 false)\r\n %4 = sub nsw i32 0, %3\r\n %5 = and i32 %4, 31\r\n %6 = shl nuw i32 1, %5\r\n ret i32 %6\r\n}\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\r\ndeclare i32 @llvm.ctlz.i32(i32, i1 immarg) #0\r\n\r\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\r\n```\r\n\r\ncc @nunoplopes ",
"author": "regehr",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
|
Cannot find a good commit
| null |
165087
|
https://github.com/llvm/llvm-project/issues/165087
|
crash
|
3d3dd559a0830ea9048cbbc92b0f7b762c5dd0e3
| 2025-10-25T08:30:57
|
[
"llvm/test/Transforms/LoopFusion"
] |
{
"fix_commit": "1286de408cc4a3ba1bd6cb6fed7d9517c0429462",
"components": [
"LoopFuse"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": [
[
1083,
1110
],
[
1453,
1463
]
],
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": [
"canSinkInst",
"collectMovablePreheaderInsts",
"fixPHINodes",
"movePreheaderInsts"
],
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 1286de408cc4a3ba1bd6cb6fed7d9517c0429462
Author: Congzhe <congzhe.cao@huawei.com>
Date: Thu Jan 22 16:12:12 2026 -0500
[LoopFusion] Optimize away Phi nodes that are sunk from the 2nd loop preheader (#176503)
Fixed issue #165087.
When we sink phis from the 2nd loop preheader to the exit block, we
optimize it a bit further, i.e., propagate the uses of each phi node with
its incoming value and optimize away the phis. Deleted `fixPHINodes()`
too because the phis are already optimized away and there is no point
processing `fixPHINodes()`.
diff --git a/llvm/lib/Transforms/Scalar/LoopFuse.cpp b/llvm/lib/Transforms/Scalar/LoopFuse.cpp
index d7284c98b48c..9c86b73dfc8d 100644
--- a/llvm/lib/Transforms/Scalar/LoopFuse.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopFuse.cpp
@@ -1083,28 +1083,6 @@ private:
return true;
}
- /// This function fixes PHI nodes after fusion in \p SafeToSink.
- /// \p SafeToSink instructions are the instructions that are to be moved past
- /// the fused loop. Thus, the PHI nodes in \p SafeToSink should be updated to
- /// receive values from the fused loop if they are currently taking values
- /// from the first loop (i.e. FC0)'s latch.
- void fixPHINodes(ArrayRef<Instruction *> SafeToSink,
- const FusionCandidate &FC0,
- const FusionCandidate &FC1) const {
- for (Instruction *Inst : SafeToSink) {
- // No update needed for non-PHI nodes.
- PHINode *Phi = dyn_cast<PHINode>(Inst);
- if (!Phi)
- continue;
- for (unsigned I = 0; I < Phi->getNumIncomingValues(); I++) {
- if (Phi->getIncomingBlock(I) != FC0.Latch)
- continue;
- assert(FC1.Latch && "FC1 latch is not set");
- Phi->setIncomingBlock(I, FC1.Latch);
- }
- }
- }
-
/// Collect instructions in the \p FC1 Preheader that can be hoisted
/// to the \p FC0 Preheader or sunk into the \p FC1 Body
bool collectMovablePreheaderInsts(
@@ -1453,11 +1431,19 @@ private:
// insert instructions in reverse order to maintain dominance relationship
for (Instruction *I : reverse(SinkInsts)) {
assert(I->getParent() == FC1.Preheader);
- I->moveBefore(*FC1.ExitBlock, FC1.ExitBlock->getFirstInsertionPt());
+ if (isa<PHINode>(I)) {
+ // The Phis to be sunk should have only one incoming value, as is
+ // assured by the condition that the second loop is dominated by the
+ // first one which is enforced by isStrictlyAdjacent().
+ // Replace the phi uses with the corresponding incoming value to clean
+ // up the code.
+ assert(cast<PHINode>(I)->getNumIncomingValues() == 1 &&
+ "Expected the sunk PHI node to have 1 incoming value.");
+ I->replaceAllUsesWith(I->getOperand(0));
+ I->eraseFromParent();
+ } else
+ I->moveBefore(*FC1.ExitBlock, FC1.ExitBlock->getFirstInsertionPt());
}
- // PHI nodes in SinkInsts need to be updated to receive values from the
- // fused loop.
- fixPHINodes(SinkInsts, FC0, FC1);
}
/// Determine if two fusion candidates have identical guards
|
[
{
"file": "llvm/test/Transforms/LoopFusion/lcssa.ll",
"commands": [
"opt -S -passes=loop-fusion < %s 2>&1"
],
"tests": [
{
"test_name": "test1",
"test_body": "define void @test1() {\nentry:\n br label %vector.ph\n\nvector.ph: ; preds = %middle.block, %entry\n br label %middle.block\n\nmiddle.block: ; preds = %vector.ph\n br i1 true, label %for.cond17.preheader, label %vector.ph\n\nfor.cond17.preheader: ; preds = %middle.block\n %.lcssa92 = phi i16 [ 1, %middle.block ]\n br label %vector.ph61\n\nvector.ph61: ; preds = %vector.ph61, %for.cond17.preheader\n br i1 true, label %for.end41, label %vector.ph61\n\nfor.end41: ; preds = %vector.ph61\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopFusion/pr165087.ll",
"commands": [
"opt -S -passes=loop-fusion < %s 2>&1"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n; When the two loops are legal to get fused, and when there are phi nodes in the second loop preheader\n; that will be sunk to the exit block, replace the phi uses with the corresponding incoming value.\n; This fixes llvm issue 165087.\n\ndefine i8 @_Z3fn1ssb() {\n;\nentry:\n br label %for.body11.1\n\nfor.body11.1: ; preds = %for.body11.1, %entry\n %indvars.iv.1 = phi i64 [ %indvars.iv.next.1, %for.body11.1 ], [ 2, %entry ]\n %indvars.iv.next.1 = add i64 %indvars.iv.1, 1\n %exitcond.1.not = icmp eq i64 %indvars.iv.next.1, 0\n br i1 %exitcond.1.not, label %for.body11.2.preheader, label %for.body11.1\n\nfor.body11.2.preheader: ; preds = %for.body11.1\n %.sroa.speculated.1.lcssa = phi i8 [ 0, %for.body11.1 ]\n br label %for.body11.2\n\nfor.body11.2: ; preds = %for.body11.2, %for.body11.2.preheader\n %indvars.iv.2 = phi i64 [ %indvars.iv.next.2, %for.body11.2 ], [ 2, %for.body11.2.preheader ]\n %indvars.iv.next.2 = add i64 %indvars.iv.2, 1\n %exitcond.2.not = icmp eq i64 %indvars.iv.next.2, 0\n br i1 %exitcond.2.not, label %for.cond.cleanup6.2.loopexit, label %for.body11.2\n\nfor.cond.cleanup6.2.loopexit: ; preds = %for.body11.2\n %.sroa.speculated.2.lcssa = phi i8 [ %.sroa.speculated.1.lcssa, %for.body11.2 ]\n ret i8 %.sroa.speculated.2.lcssa\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/LoopFusion/sunk-phi-nodes.ll",
"commands": [
"opt -passes=loop-fusion -S < %s 2>&1"
],
"tests": [
{
"test_name": "check_sunk_phi_nodes",
"test_body": "define dso_local i32 @check_sunk_phi_nodes() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.inc, %entry\n %sum1.02 = phi i32 [ 0, %entry ], [ %add, %for.inc ]\n %i.01 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]\n %add = add nsw i32 %sum1.02, %i.01\n br label %for.inc\n\nfor.inc: ; preds = %for.body\n %inc = add nsw i32 %i.01, 1\n %cmp = icmp slt i32 %inc, 10\n br i1 %cmp, label %for.body, label %for.end\n\nfor.end: ; preds = %for.inc\n %sum1.0.lcssa = phi i32 [ %add, %for.inc ]\n br label %for.body4\n\nfor.body4: ; preds = %for.inc6, %for.end\n %i1.04 = phi i32 [ 0, %for.end ], [ %inc7, %for.inc6 ]\n %sum2.03 = phi i32 [ 0, %for.end ], [ %add5, %for.inc6 ]\n %mul = mul nsw i32 %i1.04, %i1.04\n %add5 = add nsw i32 %sum2.03, %mul\n br label %for.inc6\n\nfor.inc6: ; preds = %for.body4\n %inc7 = add nsw i32 %i1.04, 1\n %cmp3 = icmp slt i32 %inc7, 10\n br i1 %cmp3, label %for.body4, label %for.end8\n\nfor.end8: ; preds = %for.inc6\n %sum2.0.lcssa = phi i32 [ %add5, %for.inc6 ]\n %0 = add i32 %sum1.0.lcssa, %sum2.0.lcssa\n ret i32 %0\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[LoopFusion] Assert \"Instruction does not dominate all uses\"",
"body": "This IR:\n\n```\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32\"\ntarget triple = \"aarch64-unknown-linux-gnu\"\n\ndefine i8 @_Z3fn1ssb() {\nentry:\n br label %for.body11.1\n\nfor.body11.1: ; preds = %for.body11.1, %entry\n %indvars.iv.1 = phi i64 [ %indvars.iv.next.1, %for.body11.1 ], [ 2, %entry ]\n %indvars.iv.next.1 = add i64 %indvars.iv.1, 1\n %exitcond.1.not = icmp eq i64 %indvars.iv.next.1, 0\n br i1 %exitcond.1.not, label %for.body11.2.preheader, label %for.body11.1\n\nfor.body11.2.preheader: ; preds = %for.body11.1\n %.sroa.speculated.1.lcssa = phi i8 [ 0, %for.body11.1 ]\n br label %for.body11.2\n\nfor.body11.2: ; preds = %for.body11.2, %for.body11.2.preheader\n %indvars.iv.2 = phi i64 [ %indvars.iv.next.2, %for.body11.2 ], [ 2, %for.body11.2.preheader ]\n %indvars.iv.next.2 = add i64 %indvars.iv.2, 1\n %exitcond.2.not = icmp eq i64 %indvars.iv.next.2, 0\n br i1 %exitcond.2.not, label %for.cond.cleanup6.2.loopexit, label %for.body11.2\n\nfor.cond.cleanup6.2.loopexit: ; preds = %for.body11.2\n %.sroa.speculated.2.lcssa = phi i8 [ %.sroa.speculated.1.lcssa, %for.body11.2 ]\n ret i8 %.sroa.speculated.2.lcssa\n}\n```\n\ncompiled with `opt -S -passes=loop-fusion `, triggers this assert:\n\n```\nInstruction does not dominate all uses!\n %.sroa.speculated.1.lcssa = phi i8 [ 0, %for.body11.1 ]\n %.sroa.speculated.2.lcssa = phi i8 [ %.sroa.speculated.1.lcssa, %for.body11.1 ]\nopt: /root/llvm-project/llvm/lib/Transforms/Scalar/LoopFuse.cpp:1827: llvm::Loop* {anonymous}::LoopFuser::performFusion(const {anonymous}::FusionCandidate&, const {anonymous}::FusionCandidate&): Assertion `!verifyFunction(*FC0.Header->getParent(), &errs())' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -S -passes=loop-fusion <source>\n1.\tRunning pass \"function(loop-fusion)\" on module \"<source>\"\n2.\tRunning pass \"loop-fusion\" on function \"_Z3fn1ssb\"\n #0 0x0000000005965e58 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5965e58)\n #1 0x0000000005962d04 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x0000785d49242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x0000785d492969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x0000785d49242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x0000785d492287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x0000785d4922871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x0000785d49239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x000000000468b1fc (anonymous namespace)::LoopFuser::performFusion((anonymous namespace)::FusionCandidate const&, (anonymous namespace)::FusionCandidate const&) LoopFuse.cpp:0:0\n #9 0x000000000468fcfe (anonymous namespace)::LoopFuser::fuseCandidates() LoopFuse.cpp:0:0\n#10 0x0000000004691861 llvm::LoopFusePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4691861)\n#11 0x0000000002f977be llvm::detail::PassModel<llvm::Function, llvm::LoopFusePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2f977be)\n\n```\n\nSee also: https://godbolt.org/z/bW9rMf7dj\n\nIR was reproduced from this C reproducer:\n\n```\n#include <algorithm>\nunsigned char a;\nextern int d[][1][1];\nchar b;\nint c;\nvoid fn1(short e, short f, bool g) {\n for (; b;)\n for (short h = 0; h < 011; h += 3)\n for (short i = 0; i < 2; i = 0201)\n for (int j = 2; j < c; j += 0 >= 0) {\n d[i][i][j] = std::max((long long)4, (long long)0);\n a = std::max(a, (unsigned char)(f && (e || g)));\n }\n}\n```",
"author": "sjoerdmeijer",
"labels": [
"loopoptim",
"crash-on-valid",
"loop-fusion"
],
"comments": [
{
"author": "sjoerdmeijer",
"body": "CC: @madhur13490 "
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null | null |
111887
|
https://github.com/llvm/llvm-project/issues/111887
|
crash
|
195486950fa64938e62f6d85d31222fa41d0ee09
| 2024-10-10T18:31:43
|
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "4b5018d2311596778cade4db5177e2ab879cc218",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
1293,
1300
],
[
6322,
6328
],
[
18820,
18826
],
[
18916,
18921
],
[
18936,
18941
],
[
19015,
19031
],
[
19054,
19074
]
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::buildExternalUses",
"tryToReduce"
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 4b5018d2311596778cade4db5177e2ab879cc218
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Thu Oct 10 13:40:22 2024 -0700
[SLP]Track repeated reduced value as it might be vectorized
Need to track changes with the repeated reduced value, since it might be
vectorized in the next attempt for reduction vectorization, to correctly
generate the code and avoid compiler crash.
Fixes #111887
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 94de520a2715..e2958c49b8ca 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -1293,8 +1293,7 @@ public:
using InstrList = SmallVector<Instruction *, 16>;
using ValueSet = SmallPtrSet<Value *, 16>;
using StoreList = SmallVector<StoreInst *, 8>;
- using ExtraValueToDebugLocsMap =
- MapVector<Value *, SmallVector<Instruction *, 2>>;
+ using ExtraValueToDebugLocsMap = SmallDenseSet<Value *, 4>;
using OrdersType = SmallVector<unsigned, 4>;
BoUpSLP(Function *Func, ScalarEvolution *Se, TargetTransformInfo *Tti,
@@ -6322,7 +6321,7 @@ void BoUpSLP::buildExternalUses(
continue;
// Check if the scalar is externally used as an extra arg.
- const auto *ExtI = ExternallyUsedValues.find(Scalar);
+ const auto ExtI = ExternallyUsedValues.find(Scalar);
if (ExtI != ExternallyUsedValues.end()) {
int FoundLane = Entry->findLaneForValue(Scalar);
LLVM_DEBUG(dbgs() << "SLP: Need to extract: Extra arg from lane "
@@ -18820,7 +18819,7 @@ public:
// List of the values that were reduced in other trees as part of gather
// nodes and thus requiring extract if fully vectorized in other trees.
SmallPtrSet<Value *, 4> RequiredExtract;
- Value *VectorizedTree = nullptr;
+ WeakTrackingVH VectorizedTree = nullptr;
bool CheckForReusedReductionOps = false;
// Try to vectorize elements based on their type.
SmallVector<InstructionsState> States;
@@ -18916,6 +18915,7 @@ public:
bool SameScaleFactor = false;
bool OptReusedScalars = IsSupportedHorRdxIdentityOp &&
SameValuesCounter.size() != Candidates.size();
+ BoUpSLP::ExtraValueToDebugLocsMap ExternallyUsedValues;
if (OptReusedScalars) {
SameScaleFactor =
(RdxKind == RecurKind::Add || RdxKind == RecurKind::FAdd ||
@@ -18936,6 +18936,7 @@ public:
emitScaleForReusedOps(Candidates.front(), Builder, Cnt);
VectorizedTree = GetNewVectorizedTree(VectorizedTree, RedVal);
VectorizedVals.try_emplace(OrigV, Cnt);
+ ExternallyUsedValues.insert(OrigV);
continue;
}
}
@@ -19015,17 +19016,18 @@ public:
V.reorderBottomToTop(/*IgnoreReorder=*/true);
// Keep extracted other reduction values, if they are used in the
// vectorization trees.
- BoUpSLP::ExtraValueToDebugLocsMap LocalExternallyUsedValues;
+ BoUpSLP::ExtraValueToDebugLocsMap LocalExternallyUsedValues(
+ ExternallyUsedValues);
// The reduction root is used as the insertion point for new
// instructions, so set it as externally used to prevent it from being
// deleted.
- LocalExternallyUsedValues[ReductionRoot];
+ LocalExternallyUsedValues.insert(ReductionRoot);
for (unsigned Cnt = 0, Sz = ReducedVals.size(); Cnt < Sz; ++Cnt) {
if (Cnt == I || (ShuffledExtracts && Cnt == I - 1))
continue;
for (Value *V : ReducedVals[Cnt])
if (isa<Instruction>(V))
- LocalExternallyUsedValues[TrackedVals[V]];
+ LocalExternallyUsedValues.insert(TrackedVals[V]);
}
if (!IsSupportedHorRdxIdentityOp) {
// Number of uses of the candidates in the vector of values.
@@ -19054,21 +19056,21 @@ public:
// Check if the scalar was vectorized as part of the vectorization
// tree but not the top node.
if (!VLScalars.contains(RdxVal) && V.isVectorized(RdxVal)) {
- LocalExternallyUsedValues[RdxVal];
+ LocalExternallyUsedValues.insert(RdxVal);
continue;
}
Value *OrigV = TrackedToOrig.at(RdxVal);
unsigned NumOps =
VectorizedVals.lookup(OrigV) + At(SameValuesCounter, OrigV);
if (NumOps != ReducedValsToOps.at(OrigV).size())
- LocalExternallyUsedValues[RdxVal];
+ LocalExternallyUsedValues.insert(RdxVal);
}
// Do not need the list of reused scalars in regular mode anymore.
if (!IsSupportedHorRdxIdentityOp)
SameValuesCounter.clear();
for (Value *RdxVal : VL)
if (RequiredExtract.contains(RdxVal))
- LocalExternallyUsedValues[RdxVal];
+ LocalExternallyUsedValues.insert(RdxVal);
V.buildExternalUses(LocalExternallyUsedValues);
V.computeMinimumValueSizes();
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/RISCV/reduced-value-repeated-and-vectorized.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=riscv64-unknown-linux-gnu -mattr=+v < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define void @test() {\nentry:\n %0 = load i16, ptr null, align 2\n %1 = xor i16 %0, 0\n %2 = tail call i16 @llvm.smax.i16(i16 %1, i16 %0)\n %3 = tail call i16 @llvm.smax.i16(i16 0, i16 %2)\n %4 = load i16, ptr getelementptr inbounds (i8, ptr null, i64 6), align 2\n %5 = xor i16 %4, 0\n %6 = tail call i16 @llvm.smax.i16(i16 %5, i16 %0)\n %7 = tail call i16 @llvm.smax.i16(i16 %3, i16 %6)\n %8 = load i16, ptr getelementptr (i8, ptr null, i64 12), align 2\n %9 = xor i16 %8, 0\n %10 = tail call i16 @llvm.smax.i16(i16 %9, i16 %0)\n %11 = tail call i16 @llvm.smax.i16(i16 %7, i16 %10)\n %12 = load i16, ptr getelementptr (i8, ptr null, i64 18), align 2\n %13 = xor i16 %12, 0\n %14 = tail call i16 @llvm.smax.i16(i16 %13, i16 %0)\n %15 = tail call i16 @llvm.smax.i16(i16 %11, i16 %14)\n %16 = tail call i16 @llvm.smax.i16(i16 %15, i16 0)\n ret void\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i16 @llvm.smax.i16(i16, i16) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[SLP-Vectorizer] Segfault in `HorizontalReduction::matchAssociativeReduction`",
"body": "Testcase:\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\nfor.body.preheader:\r\n %0 = load i16, ptr null, align 2\r\n %1 = xor i16 %0, 0\r\n %2 = tail call i16 @llvm.smax.i16(i16 %1, i16 %0)\r\n %3 = tail call i16 @llvm.smax.i16(i16 0, i16 %2)\r\n %4 = load i16, ptr getelementptr inbounds (i8, ptr null, i64 6), align 2\r\n %5 = xor i16 %4, 0\r\n %6 = tail call i16 @llvm.smax.i16(i16 %5, i16 %0)\r\n %7 = tail call i16 @llvm.smax.i16(i16 %3, i16 %6)\r\n %8 = load i16, ptr getelementptr (i8, ptr null, i64 12), align 2\r\n %9 = xor i16 %8, 0\r\n %10 = tail call i16 @llvm.smax.i16(i16 %9, i16 %0)\r\n %11 = tail call i16 @llvm.smax.i16(i16 %7, i16 %10)\r\n %12 = load i16, ptr getelementptr (i8, ptr null, i64 18), align 2\r\n %13 = xor i16 %12, 0\r\n %14 = tail call i16 @llvm.smax.i16(i16 %13, i16 %0)\r\n %15 = tail call i16 @llvm.smax.i16(i16 %11, i16 %14)\r\n %16 = tail call i16 @llvm.smax.i16(i16 %15, i16 0)\r\n ret i32 0\r\n}\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\r\ndeclare i16 @llvm.smax.i16(i16, i16) #1\r\n\r\n; uselistorder directives\r\nuselistorder ptr null, { 3, 2, 1, 0 }\r\nuselistorder ptr @llvm.smax.i16, { 8, 7, 6, 5, 4, 3, 2, 1, 0 }\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-smmpm,-experimental-smnpm,-experimental-ssctr,-experimental-ssnpm,-experimental-sspm,-experimental-supm,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-experimental-zvbc32e,-experimental-zvkgs,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssqosid,-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,-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\nattributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\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=slp-vectorizer reduced.ll\r\nWARNING: You're attempting to print out a bitcode file.\r\nThis is inadvisable as it may cause display problems. If\r\nyou REALLY want to taste LLVM bitcode first-hand, you\r\ncan force output with the `-f' option.\r\n\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=slp-vectorizer reduced.ll\r\n1. Running pass \"function(slp-vectorizer)\" on module \"reduced.ll\"\r\n2. Running pass \"slp-vectorizer\" on function \"main\"\r\n #0 0x0000602da32b35e0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x30fe5e0)\r\n #1 0x0000602da32b09ef llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x30fb9ef)\r\n #2 0x0000602da32b0b45 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007ea045842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x0000602da29cea64 llvm::getUnderlyingObject(llvm::Value const*, unsigned int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2819a64)\r\n #5 0x0000602da22d706d (anonymous namespace)::HorizontalReduction::matchAssociativeReduction(llvm::slpvectorizer::BoUpSLP&, llvm::Instruction*, llvm::ScalarEvolution&, llvm::DataLayout const&, llvm::TargetLibraryInfo const&)::'lambda0'(unsigned long, llvm::LoadInst*)::operator()(unsigned long, llvm::LoadInst*) const SLPVectorizer.cpp:0:0\r\n #6 0x0000602da22d797e generateKeySubkey(llvm::Value*, llvm::TargetLibraryInfo const*, llvm::function_ref<llvm::hash_code (unsigned long, llvm::LoadInst*)>, bool) (.constprop.0) SLPVectorizer.cpp:0:0\r\n #7 0x0000602da230d085 (anonymous namespace)::HorizontalReduction::matchAssociativeReduction(llvm::slpvectorizer::BoUpSLP&, llvm::Instruction*, llvm::ScalarEvolution&, llvm::DataLayout const&, llvm::TargetLibraryInfo const&) SLPVectorizer.cpp:0:0\r\n #8 0x0000602da231f7cc llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x216a7cc)\r\n #9 0x0000602da2323ec2 llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*) (.constprop.0) SLPVectorizer.cpp:0:0\r\n#10 0x0000602da2327dfb llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2172dfb)\r\n#11 0x0000602da232e400 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#12 0x0000602da232ef62 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2179f62)\r\n#13 0x0000602da1071366 llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, 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+0xebc366)\r\n#14 0x0000602da30bc88f 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+0x2f0788f)\r\n#15 0x0000602da1073bb6 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+0xebebb6)\r\n#16 0x0000602da30bac1b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2f05c1b)\r\n#17 0x0000602da106fcc6 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+0xebacc6)\r\n#18 0x0000602da30bb77d 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+0x2f0677d)\r\n#19 0x0000602da088061b 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+0x6cb61b)\r\n#20 0x0000602da0872331 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x6bd331)\r\n#21 0x00007ea045829d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#22 0x00007ea045829e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#23 0x00007ea045829e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#24 0x0000602da0868855 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x6b3855)\r\nzsh: segmentation fault (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\n\r\nGodbolt: https://godbolt.org/z/nbar8q6ej\r\n\r\nFound via fuzzer (C program before reduction).",
"author": "patrick-rivos",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
|
a98882112387b6bc585e758a8139fd06ac41f448
| null |
124387
|
https://github.com/llvm/llvm-project/issues/124387
|
miscompilation
|
77c325b646301e394bcd89c2980b4c2da8af49cd
| 2025-01-25T03:24:37
|
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "2131115be5b9d8b39af80973d9b64c0adc41d38d",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": [
[
1039,
1049
]
],
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": [
"InstCombinerImpl::SimplifyDemandedUseBits"
],
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 2131115be5b9d8b39af80973d9b64c0adc41d38d
Author: Fangrui Song <i@maskray.me>
Date: Sat Jan 25 13:35:11 2025 -0800
[InstCombine] Drop Range attribute when simplifying 'fshl' based on demanded bits (#124429)
When simplifying operands based on demanded bits, the return value range
of llvm.fshl might change. Keeping the Range attribute might cause
llvm.fshl to generate a poison and lead to miscompile. Drop the Range
attribute similar to `dropPosonGeneratingFlags` elsewhere.
Fix #124387
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index 943598a30f04..2c8939b5a051 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -1039,11 +1039,14 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Instruction *I,
APInt DemandedMaskLHS(DemandedMask.lshr(ShiftAmt));
APInt DemandedMaskRHS(DemandedMask.shl(BitWidth - ShiftAmt));
if (I->getOperand(0) != I->getOperand(1)) {
- if (SimplifyDemandedBits(I, 0, DemandedMaskLHS, LHSKnown,
- Depth + 1, Q) ||
+ if (SimplifyDemandedBits(I, 0, DemandedMaskLHS, LHSKnown, Depth + 1,
+ Q) ||
SimplifyDemandedBits(I, 1, DemandedMaskRHS, RHSKnown, Depth + 1,
- Q))
+ Q)) {
+ // Range attribute may no longer hold.
+ I->dropPoisonGeneratingReturnAttributes();
return I;
+ }
} else { // fshl is a rotate
// Avoid converting rotate into funnel shift.
// Only simplify if one operand is constant.
|
[
{
"file": "llvm/test/Transforms/InstCombine/fsh.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "fshl_range_trunc",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.fshl.i32(i32, i32, i32) #0\n\ndefine i8 @fshl_range_trunc(i1 %x) {\n %zext = zext i1 %x to i32\n %or = or disjoint i32 %zext, -2\n %fshl = call range(i32 -4, 2) i32 @llvm.fshl.i32(i32 %or, i32 %or, i32 1)\n %tr = trunc nsw i32 %fshl to i8\n ret i8 %tr\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[clang] Miscompile with -O2/3/s",
"body": "This code prints random value at `-O2/3/s` and -1 at `-O0/1`:\n\n```c\nint printf(const char *, ...);\nint a, b;\nvoid c(char d) { a = d; }\nint e(int d) {\n if (d < 0)\n return 1;\n return 0;\n}\nint f() {\n if (b)\n return 0;\n return 1;\n}\nint g(int d) {\n int h = 0;\n if (3 + d)\n h = f() - 1 - 1;\n return e(h) + h + h;\n}\nint main() {\n int i = g(0);\n c(i);\n printf(\"%d\\n\", a);\n}\n```\n\nCompiler Explorer: https://godbolt.org/z/KfWsKxcvE\n\nIt starts from x86_64 clang 19.1.0. ",
"author": "cardigan1008",
"labels": [
"miscompilation",
"llvm:instcombine",
"regression:19"
],
"comments": [
{
"author": "MaskRay",
"body": "InstCombine miscompiles \n\n```llvm\ndefine i32 @src(i32 %x) local_unnamed_addr {\nentry:\n %cmp = icmp eq i32 %x, 0\n %zext = zext i1 %cmp to i32\n %or = or disjoint i32 %zext, -2\n %fshl = call range(i32 -4, 2) i32 @llvm.fshl.i32(i32 %or, i32 %or, i32 1)\n %tr = trunc nsw i32 %fshl to i8\n %res = sext i8 %tr to i32\n ret i32 %res\n}\n```\n\nedit: `g` has a Range return attribute, which is propagated to the call site in `main` after inlining.\nInstCombine `InstCombinerImpl::SimplifyDemandedUseBits` simplifies the operand, but keeps the no-longer-valid Range return attribute.\n\nThen, CorrelatedValuePropagationPass added nsw, and the value eventually becomes poison."
},
{
"author": "nikic",
"body": "Slightly reduced: https://alive2.llvm.org/ce/z/3Kf7-2\n\nI assume the problem is that we don't clear the return range attribute in SimplifyDemanded."
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
Cannot find a good commit
| null |
140442
|
https://github.com/llvm/llvm-project/issues/140442
|
crash
|
b18ebd17b82db0bdf5bb8cae59c3208288fbef93
| 2025-05-18T08:07:12
|
[
"llvm/test/Transforms/LoopUnroll"
] |
{
"fix_commit": "7e14161f49b32387988cf9d937bbfaa27d0fbdd5",
"components": [
"LoopPeel"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": [
[
1214,
1220
]
],
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": [
"llvm::peelLoop"
],
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 7e14161f49b32387988cf9d937bbfaa27d0fbdd5
Author: Florian Hahn <flo@fhahn.com>
Date: Sun May 18 10:17:20 2025 +0100
[LoopPeel] Handle constants when updating exit values when peeling last.
Account for constant values when updating exit values after peeling an
iteration from the end. This can happen if the inner loop gets unrolled
and simplified.
Fixes https://github.com/llvm/llvm-project/issues/140442.
diff --git a/llvm/lib/Transforms/Utils/LoopPeel.cpp b/llvm/lib/Transforms/Utils/LoopPeel.cpp
index c5c637ab6e20..646354bba9df 100644
--- a/llvm/lib/Transforms/Utils/LoopPeel.cpp
+++ b/llvm/lib/Transforms/Utils/LoopPeel.cpp
@@ -1214,7 +1214,7 @@ bool llvm::peelLoop(Loop *L, unsigned PeelCount, bool PeelLast, LoopInfo *LI,
// Now adjust users of the original exit values by replacing them with the
// exit value from the peeled iteration.
for (const auto &[P, E] : ExitValues)
- P->replaceAllUsesWith(VMap.lookup(E));
+ P->replaceAllUsesWith(isa<Constant>(E) ? E : &*VMap.lookup(E));
formLCSSA(*L, DT, LI, SE);
} else {
// Now adjust the phi nodes in the loop header to get their initial values
|
[
{
"file": "llvm/test/Transforms/LoopUnroll/unroll-and-peel-last-iteration.ll",
"commands": [
"opt -p loop-unroll -S %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n; Test case for https://github.com/llvm/llvm-project/issues/140442.\ndefine i32 @peel_last_iter_of_outer_lcssa_phi_with_constant_after_unrolling_inner() {\n;\nentry:\n br label %outer.header\n\nouter.header:\n %iv = phi i16 [ 0, %entry ], [ %iv.next, %outer.latch ]\n %0 = icmp eq i16 %iv, 999\n br label %inner.header\n\ninner.header:\n %inner.iv = phi i32 [ 0, %outer.header ], [ %inner.iv.next, %inner.latch ]\n %1 = add i32 %inner.iv, 1\n br i1 %0, label %then, label %inner.latch\n\nthen:\n call void @foo(i32 %inner.iv)\n br label %inner.latch\n\ninner.latch:\n %inner.iv.next = add i32 %inner.iv, 1\n %inner.ec = icmp eq i32 %inner.iv.next, 1\n br i1 %inner.ec, label %outer.latch, label %inner.header\n\nouter.latch:\n %iv.next = add i16 %iv, 1\n %ec = icmp eq i16 %iv.next, 1000\n br i1 %ec, label %exit, label %outer.header\n\nexit:\n ret i32 %1\n}\n\ndeclare void @foo(i32)\n;.\n;.",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[LoopUnroll] Assertion `New && \"Value::replaceAllUsesWith(<null>) is invalid!\"' failed.",
"body": "Reproducer: https://godbolt.org/z/ahxqn68Mn\n```\n; bin/opt -passes=\"loop-unroll<O3>\" reduced.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 i32 @main() {\nentry:\n br label %for.cond52.preheader.i.i\n\nfor.cond52.preheader.i.i: ; preds = %for.end213.i.i, %entry\n %p_158.addr.0380.i.i1 = phi i16 [ 0, %entry ], [ %inc215.i.i, %for.end213.i.i ]\n %0 = icmp eq i16 %p_158.addr.0380.i.i1, -1\n br label %for.body136.i.i\n\nfor.body136.i.i: ; preds = %for.end54.preheader.peel.i.i.i, %for.cond52.preheader.i.i\n %1 = add i32 0, 0\n br i1 %0, label %for.end54.preheader.peel.i.i.i, label %for.end54.preheader.peel.i.i.i\n\nfor.end54.preheader.peel.i.i.i: ; preds = %for.body136.i.i, %for.body136.i.i\n br i1 true, label %for.end213.i.i, label %for.body136.i.i\n\nfor.end213.i.i: ; preds = %for.end54.preheader.peel.i.i.i\n %inc215.i.i = add i16 %p_158.addr.0380.i.i1, 1\n %exitcond387.not.i.i = icmp eq i16 %inc215.i.i, 0\n br i1 %exitcond387.not.i.i, label %for.end141.peel.i.i, label %for.cond52.preheader.i.i\n\nfor.end141.peel.i.i: ; preds = %for.end213.i.i\n ret i32 %1\n}\n```\n```\nopt: /root/llvm-project/llvm/lib/IR/Value.cpp:516: void llvm::Value::doRAUW(llvm::Value*, llvm::Value::ReplaceMetadataUses): Assertion `New && \"Value::replaceAllUsesWith(<null>) is invalid!\"' failed.\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=loop-unroll<O3> <source>\n1.\tRunning pass \"function(loop-unroll<O3>)\" on module \"<source>\"\n2.\tRunning pass \"loop-unroll<O3>\" on function \"main\"\n #0 0x00000000055c5a48 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x55c5a48)\n #1 0x00000000055c33d4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x000078c7a1842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x000078c7a18969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x000078c7a1842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x000078c7a18287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x000078c7a182871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x000078c7a1839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x00000000053f248a (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x53f248a)\n #9 0x0000000004830404 llvm::peelLoop(llvm::Loop*, unsigned int, bool, llvm::LoopInfo*, llvm::ScalarEvolution*, llvm::DominatorTree&, llvm::AssumptionCache*, bool, llvm::ValueMap<llvm::Value const*, llvm::WeakTrackingVH, llvm::ValueMapConfig<llvm::Value const*, llvm::sys::SmartMutex<false>>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4830404)\n#10 0x0000000004424eb9 tryToUnrollLoop(llvm::Loop*, llvm::DominatorTree&, llvm::LoopInfo*, llvm::ScalarEvolution&, llvm::TargetTransformInfo const&, llvm::AssumptionCache&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::ProfileSummaryInfo*, bool, int, bool, bool, bool, std::optional<unsigned int>, std::optional<unsigned int>, std::optional<bool>, std::optional<bool>, std::optional<bool>, std::optional<bool>, std::optional<bool>, std::optional<unsigned int>, llvm::AAResults*) LoopUnrollPass.cpp:0:0\n#11 0x0000000004427b27 llvm::LoopUnrollPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4427b27)\n#12 0x0000000002d6a54e llvm::detail::PassModel<llvm::Function, llvm::LoopUnrollPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2d6a54e)\n#13 0x00000000053bcd00 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x53bcd00)\n#14 0x0000000000e8bbee 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+0xe8bbee)\n#15 0x00000000053bd213 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x53bd213)\n#16 0x0000000000e8aa3e 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+0xe8aa3e)\n#17 0x00000000053bae30 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x53bae30)\n#18 0x000000000094c2aa 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+0x94c2aa)\n#19 0x000000000093fa7c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x93fa7c)\n#20 0x000078c7a1829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#21 0x000078c7a1829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#22 0x0000000000937695 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x937695)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```\nllvm version: 3ccb15d6caf57f2a866d496ada2fb52d14b179d2",
"author": "dtcxzyw",
"labels": [
"crash-on-valid",
"llvm:transforms",
"generated by fuzzer"
],
"comments": [
{
"author": "fhahn",
"body": "Probably related to 3fcfce4c5e5fd1c3072e8db1d692c93459e8cd74, taking a look"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
3fcfce4c5e5fd1c3072e8db1d692c93459e8cd74
| null |
164185
|
https://github.com/llvm/llvm-project/issues/164185
|
crash
|
ee50839700af4800a2d72702a5583b72e1ffb81e
| 2025-10-19T22:22:53
|
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "154138c25f358ed812eafc2880225c3d88221e8a",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
10546,
10553
]
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"tryToFindDuplicates"
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 154138c25f358ed812eafc2880225c3d88221e8a
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Mon Oct 20 04:15:47 2025 -0700
[SLP]Do not pack div-like copyable values
If a main instruction in the copyables is a div-like instruction, the
compiler cannot pack duplicates, extending with poisons, these
instructions, being vectorize, will result in undefined behavior.
Fixes #164185
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 048a3e691fe5..3f18bd70539a 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -10546,8 +10546,11 @@ static bool tryToFindDuplicates(SmallVectorImpl<Value *> &VL,
PoisonValue::get(UniqueValues.front()->getType()));
// Check that extended with poisons/copyable operations are still valid
// for vectorization (div/rem are not allowed).
- if (!S.areInstructionsWithCopyableElements() &&
- !getSameOpcode(PaddedUniqueValues, TLI).valid()) {
+ if ((!S.areInstructionsWithCopyableElements() &&
+ !getSameOpcode(PaddedUniqueValues, TLI).valid()) ||
+ (S.areInstructionsWithCopyableElements() && S.isMulDivLikeOp() &&
+ (S.getMainOp()->isIntDivRem() || S.getMainOp()->isFPDivRem() ||
+ isa<CallInst>(S.getMainOp())))) {
LLVM_DEBUG(dbgs() << "SLP: Scalar used twice in bundle.\n");
ReuseShuffleIndices.clear();
return false;
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/AArch64/div-like-mixed-with-undefs.ll",
"commands": [
"opt -passes=slp-vectorizer -S -slp-threshold=-100 -mtriple=aarch64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine ptr @test(ptr %d) {\n;\nentry:\n %0 = load i8, ptr null, align 1\n %cmp4.2 = icmp eq i8 %0, 0\n %1 = select i1 %cmp4.2, i64 0, i64 0\n %2 = shl i64 %1, 1\n %3 = getelementptr i8, ptr %d, i64 %2\n %4 = xor i64 0, 0\n %5 = udiv i64 %4, 0\n %6 = mul i64 %5, 6\n %7 = getelementptr i8, ptr %d, i64 %6\n %8 = shl i64 %1, 0\n %scevgep42 = getelementptr i8, ptr %d, i64 %8\n %9 = mul i64 %5, 1\n %10 = getelementptr i8, ptr %d, i64 %9\n %11 = udiv i64 1, 0\n %12 = mul i64 %11, 1\n %13 = getelementptr i8, ptr %d, i64 %12\n %14 = mul i64 %11, 0\n %15 = getelementptr i8, ptr %d, i64 %14\n ret ptr %15\n}",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[SLP] Crash in BoUpSLP::collectValuesToDemote",
"body": "This IR:\n\n```\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32\"\ntarget triple = \"aarch64-unknown-linux-gnu\"\n\ndefine ptr @_Z1bbPA2_sPA2_A2_c(ptr %d) {\nentry:\n %0 = load i8, ptr null, align 1\n %cmp4.2 = icmp eq i8 %0, 0\n %1 = select i1 %cmp4.2, i64 0, i64 0\n %2 = shl i64 %1, 1\n %3 = getelementptr i8, ptr %d, i64 %2\n %4 = xor i64 0, 0\n %5 = udiv i64 %4, 0\n %6 = mul i64 %5, 6\n %7 = getelementptr i8, ptr %d, i64 %6\n %8 = shl i64 %1, 0\n %scevgep42 = getelementptr i8, ptr %d, i64 %8\n %9 = mul i64 %5, 1\n %10 = getelementptr i8, ptr %d, i64 %9\n %11 = udiv i64 1, 0\n %12 = mul i64 %11, 1\n %13 = getelementptr i8, ptr %d, i64 %12\n %14 = mul i64 %11, 0\n %15 = getelementptr i8, ptr %d, i64 %14\n ret ptr %15\n\n; uselistorder directives\n uselistorder ptr %d, { 5, 4, 3, 2, 1, 0 }\n}\n```\n\nTriggers this assert:\n\n```\nopt: /root/llvm-project/llvm/include/llvm/Support/Casting.h:572: decltype(auto) llvm::cast(From*) [with To = llvm::Instruction; From = llvm::Value]: Assertion `isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer <source>\n1.\tRunning pass \"function(slp-vectorizer)\" on module \"<source>\"\n2.\tRunning pass \"slp-vectorizer\" on function \"_Z1bbPA2_sPA2_A2_c\"\n #0 0x0000000005944c48 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5944c48)\n #1 0x0000000005941af4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x000076c276e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x000076c276e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x000076c276e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x000076c276e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x000076c276e2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x000076c276e39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x0000000000bc65ea (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xbc65ea)\n #9 0x00000000036b185d llvm::slpvectorizer::BoUpSLP::collectValuesToDemote(llvm::slpvectorizer::BoUpSLP::TreeEntry const&, bool, unsigned int&, llvm::SmallVectorImpl<unsigned int>&, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, void>>&, llvm::SmallDenseSet<unsigned int, 8u, llvm::DenseMapInfo<unsigned int, void>> const&, unsigned int&, bool&, bool) const::'lambda10'(unsigned int, unsigned int)::operator()(unsigned int, unsigned int) const::'lambda'(llvm::Value*)::operator()(llvm::Value*) const SLPVectorizer.cpp:0:0\n#10 0x00000000036b1aec bool llvm::function_ref<bool (unsigned int, unsigned int)>::callback_fn<llvm::slpvectorizer::BoUpSLP::collectValuesToDemote(llvm::slpvectorizer::BoUpSLP::TreeEntry const&, bool, unsigned int&, llvm::SmallVectorImpl<unsigned int>&, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, void>>&, llvm::SmallDenseSet<unsigned int, 8u, llvm::DenseMapInfo<unsigned int, void>> const&, unsigned int&, bool&, bool) const::'lambda10'(unsigned int, unsigned int)>(long, unsigned int, unsigned int) SLPVectorizer.cpp:0:0\n#11 0x00000000037363bd llvm::slpvectorizer::BoUpSLP::collectValuesToDemote(llvm::slpvectorizer::BoUpSLP::TreeEntry const&, bool, unsigned int&, llvm::SmallVectorImpl<unsigned int>&, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, void>>&, llvm::SmallDenseSet<unsigned int, 8u, llvm::DenseMapInfo<unsigned int, void>> const&, unsigned int&, bool&, bool) const::'lambda6'(unsigned int&, llvm::ArrayRef<llvm::slpvectorizer::BoUpSLP::TreeEntry const*>, llvm::function_ref<bool (unsigned int, unsigned int)>)::operator()(unsigned int&, llvm::ArrayRef<llvm::slpvectorizer::BoUpSLP::TreeEntry const*>, llvm::function_ref<bool (unsigned int, unsigned int)>) const SLPVectorizer.cpp:0:0\n#12 0x0000000003734455 llvm::slpvectorizer::BoUpSLP::collectValuesToDemote(llvm::slpvectorizer::BoUpSLP::TreeEntry const&, bool, unsigned int&, llvm::SmallVectorImpl<unsigned int>&, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, void>>&, llvm::SmallDenseSet<unsigned int, 8u, llvm::DenseMapInfo<unsigned int, void>> const&, unsigned int&, bool&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3734455)\n#13 0x00000000037365c6 llvm::slpvectorizer::BoUpSLP::collectValuesToDemote(llvm::slpvectorizer::BoUpSLP::TreeEntry const&, bool, unsigned int&, llvm::SmallVectorImpl<unsigned int>&, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, void>>&, llvm::SmallDenseSet<unsigned int, 8u, llvm::DenseMapInfo<unsigned int, void>> const&, unsigned int&, bool&, bool) const::'lambda6'(unsigned int&, llvm::ArrayRef<llvm::slpvectorizer::BoUpSLP::TreeEntry const*>, llvm::function_ref<bool (unsigned int, unsigned int)>)::operator()(unsigned int&, llvm::ArrayRef<llvm::slpvectorizer::BoUpSLP::TreeEntry const*>, llvm::function_ref<bool (unsigned int, unsigned int)>) const SLPVectorizer.cpp:0:0\n#14 0x00000000037340e5 llvm::slpvectorizer::BoUpSLP::collectValuesToDemote(llvm::slpvectorizer::BoUpSLP::TreeEntry const&, bool, unsigned int&, llvm::SmallVectorImpl<unsigned int>&, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, void>>&, llvm::SmallDenseSet<unsigned int, 8u, llvm::DenseMapInfo<unsigned int, void>> const&, unsigned int&, bool&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x37340e5)\n#15 0x0000000003736f0c llvm::slpvectorizer::BoUpSLP::computeMinimumValueSizes()::'lambda'(llvm::slpvectorizer::BoUpSLP::TreeEntry const&, bool, bool, unsigned int, bool, bool)::operator()(llvm::slpvectorizer::BoUpSLP::TreeEntry const&, bool, bool, unsigned int, bool, bool) const SLPVectorizer.cpp:0:0\n#16 0x00000000037892b2 llvm::slpvectorizer::BoUpSLP::computeMinimumValueSizes() (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x37892b2)\n#17 0x00000000037b2cec llvm::SLPVectorizerPass::tryToVectorizeList(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x37b2cec)\n#18 0x00000000037b515a llvm::SLPVectorizerPass::vectorizeGEPIndices(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x37b515a)\n```\n\nSee also: https://godbolt.org/z/r8Mhn8oKf\n\nCan be triggered from source code:\n\n```\nshort a;\nvoid b(bool c, short d[][2], char h[][2][2]) {\n for (short e;;)\n for (int f = 2; f < 10; f += 3)\n#pragma clang loop interleave(enable)\n for (int g((h[2][1][f] == 0) + 3); g < c + 8; g += 3)\n a = d[g][e] - d[e][g - 2];\n}\n```\n",
"author": "sjoerdmeijer",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
7f03b22dce1f4dae9db3ec8919db7dbd98202e0b
| null |
104761
|
https://github.com/llvm/llvm-project/issues/104761
|
crash
|
5cfa8baef33636827e5aa8dd76888c724433b53e
| 2024-08-19T11:00:31
|
[
"llvm/test/Analysis/LoopCacheAnalysis"
] |
{
"fix_commit": "2e6deb1dd3a4422807633ba08773e8d786e43d4c",
"components": [
"LoopCacheAnalysis"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": [
[
16,
21
],
[
31,
37
],
[
192,
199
]
],
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": [
[
328,
333
],
[
338,
351
],
[
696,
702
]
],
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": [
"CacheCost::computeLoopCacheCost",
"IndexedReference::computeRefCost",
"IndexedReference::tryDelinearizeFixedSize"
],
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 2e6deb1dd3a4422807633ba08773e8d786e43d4c
Author: Sjoerd Meijer <smeijer@nvidia.com>
Date: Thu Nov 14 08:40:45 2024 +0000
[LoopInterchange] Fix overflow in cost calculation (#111807)
If the iteration count is really large, e.g. UINT_MAX, then the cost
calculation can overflows and trigger an assert. So saturate the cost to
INT_MAX if this is the case by using InstructionCost as a type which
already supports this kind of overflow handling.
This fixes #104761
diff --git a/llvm/include/llvm/Analysis/LoopCacheAnalysis.h b/llvm/include/llvm/Analysis/LoopCacheAnalysis.h
index 4fd2485e39d6..3e22487e5e34 100644
--- a/llvm/include/llvm/Analysis/LoopCacheAnalysis.h
+++ b/llvm/include/llvm/Analysis/LoopCacheAnalysis.h
@@ -16,6 +16,7 @@
#include "llvm/Analysis/LoopAnalysisManager.h"
#include "llvm/IR/PassManager.h"
+#include "llvm/Support/InstructionCost.h"
#include <optional>
namespace llvm {
@@ -31,7 +32,7 @@ class ScalarEvolution;
class SCEV;
class TargetTransformInfo;
-using CacheCostTy = int64_t;
+using CacheCostTy = InstructionCost;
using LoopVectorTy = SmallVector<Loop *, 8>;
/// Represents a memory reference as a base pointer and a set of indexing
@@ -192,8 +193,6 @@ class CacheCost {
using LoopCacheCostTy = std::pair<const Loop *, CacheCostTy>;
public:
- static CacheCostTy constexpr InvalidCost = -1;
-
/// Construct a CacheCost object for the loop nest described by \p Loops.
/// The optional parameter \p TRT can be used to specify the max. distance
/// between array elements accessed in a loop so that the elements are
diff --git a/llvm/lib/Analysis/LoopCacheAnalysis.cpp b/llvm/lib/Analysis/LoopCacheAnalysis.cpp
index 7ca9f15ad5fc..2897b922f61e 100644
--- a/llvm/lib/Analysis/LoopCacheAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopCacheAnalysis.cpp
@@ -328,6 +328,8 @@ CacheCostTy IndexedReference::computeRefCost(const Loop &L,
const SCEV *TripCount =
computeTripCount(*AR->getLoop(), *Sizes.back(), SE);
Type *WiderType = SE.getWiderType(RefCost->getType(), TripCount->getType());
+ // For the multiplication result to fit, request a type twice as wide.
+ WiderType = WiderType->getExtendedType();
RefCost = SE.getMulExpr(SE.getNoopOrZeroExtend(RefCost, WiderType),
SE.getNoopOrZeroExtend(TripCount, WiderType));
}
@@ -338,14 +340,18 @@ CacheCostTy IndexedReference::computeRefCost(const Loop &L,
assert(RefCost && "Expecting a valid RefCost");
// Attempt to fold RefCost into a constant.
+ // CacheCostTy is a signed integer, but the tripcount value can be large
+ // and may not fit, so saturate/limit the value to the maximum signed
+ // integer value.
if (auto ConstantCost = dyn_cast<SCEVConstant>(RefCost))
- return ConstantCost->getValue()->getZExtValue();
+ return ConstantCost->getValue()->getLimitedValue(
+ std::numeric_limits<int64_t>::max());
LLVM_DEBUG(dbgs().indent(4)
<< "RefCost is not a constant! Setting to RefCost=InvalidCost "
"(invalid value).\n");
- return CacheCost::InvalidCost;
+ return CacheCostTy::getInvalid();
}
bool IndexedReference::tryDelinearizeFixedSize(
@@ -696,7 +702,7 @@ CacheCostTy
CacheCost::computeLoopCacheCost(const Loop &L,
const ReferenceGroupsTy &RefGroups) const {
if (!L.isLoopSimplifyForm())
- return InvalidCost;
+ return CacheCostTy::getInvalid();
LLVM_DEBUG(dbgs() << "Considering loop '" << L.getName()
<< "' as innermost loop.\n");
|
[
{
"file": "llvm/test/Analysis/LoopCacheAnalysis/interchange-refcost-overflow.ll",
"commands": [
"opt < %s -passes='print<loop-cache-cost>' -disable-output 2>&1"
],
"tests": [
{
"test_name": "foo",
"test_body": "@A = external local_unnamed_addr global [11 x [11 x [11 x i32]]], align 16\n\ndefine void @foo(i32 noundef %b) {\nentry:\n %0 = sext i32 %b to i64\n br label %outer.loop\n\nouter.loop: ; preds = %outer.loop.cleanup, %entry\n %indvars.iv = phi i64 [ %indvars.iv.next, %outer.loop.cleanup ], [ 0, %entry ]\n br label %inner.loop\n\nouter.loop.cleanup: ; preds = %inner.loop\n %indvars.iv.next = add nsw i64 %indvars.iv, %0\n br label %outer.loop\n\ninner.loop: ; preds = %inner.loop, %outer.loop\n %inner.iv = phi i64 [ 0, %outer.loop ], [ %add, %inner.loop ]\n %arrayidx3 = getelementptr inbounds [11 x [11 x [11 x i32]]], ptr @A, i64 0, i64 %indvars.iv, i64 %inner.iv, i64 %inner.iv\n store i32 0, ptr %arrayidx3, align 4\n %add = add nuw i64 %inner.iv, 2\n %cmp = icmp ult i64 %inner.iv, -5\n br i1 %cmp, label %inner.loop, label %outer.loop.cleanup\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[LoopInterchange] Assertion `getActiveBits() <= 64 && \"Too many bits for uint64_t\"",
"body": "With options \"-O3 --target=aarch64 func.cpp -mllvm -enable-loopinterchange\" and this input:\r\n```\r\nunsigned int A[11][11][11] __attribute__((aligned(16)));\r\nvoid a(int b) {\r\n for (int c;; c += b)\r\n for (long d = 0; d < -3ULL; d += 2ULL)\r\n A[c][d][d] = 0;\r\n}\r\n```\r\n\r\nLoop-interchange runs in an assert:\r\n\r\n```\r\nllvm-project/llvm/include/llvm/ADT/APInt.h:1501: uint64_t llvm::APInt::getZExtValue() const: Assertion `getActiveBits() <= 64 && \"Too many bits for uint64_t\"' failed.\r\n```\r\n\r\nIR reproducer, compile this with \"opt -passes=loop-interchange -S\":\r\n\r\n```\r\ntarget datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32\"\r\ntarget triple = \"aarch64-unknown-linux-gnu\"\r\n\r\n@A = local_unnamed_addr global [11 x [11 x [11 x i32]]] zeroinitializer, align 16\r\n\r\ndefine void @_Z1ai(i32 noundef %b) local_unnamed_addr #0 {\r\nentry:\r\n %0 = sext i32 %b to i64\r\n br label %for.cond\r\n\r\n; Loop:\r\nfor.cond: ; preds = %for.cond.cleanup, %entry\r\n %indvars.iv = phi i64 [ %indvars.iv.next, %for.cond.cleanup ], [ 0, %entry ]\r\n br label %for.body\r\n\r\nfor.cond.cleanup: ; preds = %for.body\r\n %indvars.iv.next = add nsw i64 %indvars.iv, %0\r\n br label %for.cond\r\n\r\nfor.body: ; preds = %for.cond, %for.body\r\n %d.010 = phi i64 [ 0, %for.cond ], [ %add, %for.body ]\r\n %arrayidx3 = getelementptr inbounds [11 x [11 x [11 x i32]]], ptr @A, i64 0, i64 %indvars.iv, i64 %d.010, i64 %d.010\r\n store i32 0, ptr %arrayidx3, align 4\r\n %add = add nuw i64 %d.010, 2\r\n %cmp = icmp ult i64 %d.010, -5\r\n br i1 %cmp, label %for.body, label %for.cond.cleanup\r\n}\r\n```",
"author": "sjoerdmeijer",
"labels": [
"crash-on-valid",
"llvm:analysis"
],
"comments": [
{
"author": "RKSimon",
"body": "```\r\nopt: /root/llvm-project/llvm/include/llvm/ADT/APInt.h:1501: uint64_t llvm::APInt::getZExtValue() const: Assertion `getActiveBits() <= 64 && \"Too many bits for uint64_t\"' 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=loop-interchange -debug <source>\r\n1.\tRunning pass \"function(loop(loop-interchange))\" on module \"<source>\"\r\n2.\tRunning pass \"loop(loop-interchange)\" on function \"_Z1ai\"\r\n #0 0x0000000004f7f528 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f7f528)\r\n #1 0x0000000004f7cc9c SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007f497b842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x00007f497b8969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x00007f497b842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x00007f497b8287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00007f497b82871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x00007f497b839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x00000000045677cc llvm::IndexedReference::computeRefCost(llvm::Loop const&, unsigned int) const (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x45677cc)\r\n #9 0x000000000456995f llvm::CacheCost::computeLoopCacheCost(llvm::Loop const&, llvm::SmallVector<llvm::SmallVector<std::unique_ptr<llvm::IndexedReference, std::default_delete<llvm::IndexedReference>>, 8u>, 8u> const&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x456995f)\r\n#10 0x000000000456c137 llvm::CacheCost::calculateCacheFootprint() (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x456c137)\r\n#11 0x0000000004573d5c llvm::CacheCost::getCacheCost(llvm::Loop&, llvm::LoopStandardAnalysisResults&, llvm::DependenceInfo&, std::optional<unsigned int>) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4573d5c)\r\n#12 0x0000000003c71d66 llvm::LoopInterchangePass::run(llvm::LoopNest&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3c71d66)\r\n#13 0x0000000002eb0a6e llvm::detail::PassModel<llvm::LoopNest, llvm::LoopInterchangePass, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::LoopNest&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2eb0a6e)\r\n#14 0x0000000003c85255 llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::runWithLoopNestPasses(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3c85255)\r\n#15 0x0000000003c85ce3 llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3c85ce3)\r\n#16 0x0000000003c868b8 llvm::FunctionToLoopPassAdaptor::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3c868b8)\r\n#17 0x0000000000df128e llvm::detail::PassModel<llvm::Function, llvm::FunctionToLoopPassAdaptor, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xdf128e)\r\n#18 0x0000000004d7c368 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d7c368)\r\n#19 0x0000000000df14be 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+0xdf14be)\r\n#20 0x0000000004d7ad5e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d7ad5e)\r\n#21 0x0000000000df0f8e 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+0xdf0f8e)\r\n#22 0x0000000004d78ec0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d78ec0)\r\n#23 0x00000000008e7582 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+0x8e7582)\r\n#24 0x00000000008da45c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8da45c)\r\n#25 0x00007f497b829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#26 0x00007f497b829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#27 0x00000000008d1eee _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8d1eee)\r\n```\r\nWhich seems to be due to the getZExtValue() call inside IndexedReference::computeRefCost\r\nhttps://github.com/llvm/llvm-project/blob/b05c55472bf7cadcd0e4cb1a669b3474695b0524/llvm/lib/Analysis/LoopCacheAnalysis.cpp#L340:L343"
},
{
"author": "svs-quic",
"body": "cc: @caojoshua "
},
{
"author": "sjoerdmeijer",
"body": "I have a fix, will put it up for review tomorrow. "
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
|
09d879d060ed31b22a6e72f7f5e44fe9b5660aa3
| null |
176720
|
https://github.com/llvm/llvm-project/issues/176720
|
crash
|
ca51c973b5feb0b7e9c798316b03d66d9ab338cf
| 2026-01-19T10:04:55
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "69fbab2b72b1c9d5678ba6a6ad234e689ed9bce9",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": [
[
3420,
3425
]
],
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": [
"VPReplicateRecipe::computeCost"
],
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 69fbab2b72b1c9d5678ba6a6ad234e689ed9bce9
Author: Florian Hahn <flo@fhahn.com>
Date: Mon Jan 19 21:25:52 2026 +0000
[VPlan] Fall back to legacy cost if operands may be force-scalarized.
If any of the operands of a VPReplicateRecipe have been
force-scalarized, then the legacy cost model skips the scalarization
overhead, but we cannot match this in the VPlan cost model.
Bail out for now in those very rare cases.
Fixes https://github.com/llvm/llvm-project/issues/176720.
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index 5ef0c0d195eb..64890ac9e9b9 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -3420,6 +3420,20 @@ InstructionCost VPReplicateRecipe::computeCost(ElementCount VF,
if (isSingleScalar())
return ScalarCost;
+ // If any of the operands is from a different replicate region and has its
+ // cost skipped, it may have been forced to scalar. Fall back to legacy cost
+ // model to avoid cost mis-match.
+ if (any_of(operands(), [&Ctx, VF](VPValue *Op) {
+ auto *PredR = dyn_cast<VPPredInstPHIRecipe>(Op);
+ if (!PredR)
+ return false;
+ return Ctx.skipCostComputation(
+ dyn_cast_or_null<Instruction>(
+ PredR->getOperand(0)->getUnderlyingValue()),
+ VF.isVector());
+ }))
+ break;
+
ScalarCost = ScalarCost * VF.getFixedValue() +
Ctx.getScalarizationOverhead(Ctx.Types.inferScalarType(this),
to_vector(operands()), VF);
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/X86/cost-model.ll",
"commands": [
"opt < %s -passes=loop-vectorize -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7-avx -S"
],
"tests": [
{
"test_name": "replicating_sdiv_operand_profitable_to_scalarize",
"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\"\ntarget triple = \"x86_64-apple-macosx10.8.0\"\n\ndefine void @replicating_sdiv_operand_profitable_to_scalarize(i32 %x) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 0, %entry ], [ %div1, %loop ]\n %accum = phi i32 [ 0, %entry ], [ %next, %loop ]\n %div1 = sdiv i32 2, %x\n %sub = sub i32 %x, %div1\n %or1 = or i32 %sub, %iv\n %or2 = or i32 %div1, 3\n %div2 = sdiv i32 %div1, %or2\n %or3 = or i32 %or1, %div2\n %next = add i32 %accum, 3\n %cond = icmp ugt i32 %accum, 35\n br i1 %cond, label %exit, label %loop\n\nexit: ; preds = %loop\n %result = phi i32 [ %or3, %loop ]\n ret void\n}\n\nattributes #0 = { \"target-cpu\"=\"skylake-avx512\" }\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "Assertion `(BestFactor.Width == LegacyVF.Width || BestPlan.hasEarlyExit() || ... || planContainsAdditionalSimplifications( getPlanFor(LegacyVF.Width), CostCtx, OrigLoop, LegacyVF.Width)) && \" VPlan cost model and legacy cost model disagreed\"' failed.",
"body": "```\nopt: /root/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7269: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || BestPlan.hasEarlyExit() || !Legal->getLAI()->getSymbolicStrides().empty() || UsesEVLGatherScatter || planContainsAdditionalSimplifications( getPlanFor(BestFactor.Width), CostCtx, OrigLoop, BestFactor.Width) || planContainsAdditionalSimplifications( getPlanFor(LegacyVF.Width), CostCtx, OrigLoop, LegacyVF.Width)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\n```\n\nTo 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 void @wombat() #0 gc \"statepoint-example\" {\nbb:\n br label %bb2\n\nbb1: ; preds = %bb2\n %phi = phi i32 [ %or8, %bb2 ]\n ret void\n\nbb2: ; preds = %bb2, %bb\n %phi3 = phi i32 [ 0, %bb ], [ %sdiv, %bb2 ]\n %phi4 = phi i32 [ 0, %bb ], [ %add, %bb2 ]\n %or = or i32 0, 0\n %sdiv = sdiv i32 0, %or\n %sub = sub i32 0, %sdiv\n %or5 = or i32 %sub, %phi3\n %or6 = or i32 %sdiv, 1\n %sdiv7 = sdiv i32 %sdiv, %or6\n %or8 = or i32 %or5, %sdiv7\n %add = add i32 %phi4, 3\n %icmp = icmp ugt i32 %phi4, 35\n br i1 %icmp, label %bb1, label %bb2\n}\n\nattributes #0 = { \"target-cpu\"=\"skylake-avx512\" }\n```\nReproducer: https://godbolt.org/z/rzsds3acz\n\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 0x0000000005a80c68 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5a80c68)\n #1 0x0000000005a7db44 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007d0067042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007d00670969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007d0067042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007d00670287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x00007d006702871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x00007d0067039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x0000000003749648 llvm::LoopVectorizationPlanner::computeBestVF() (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3749648)\n #9 0x000000000374b5d2 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x374b5d2)\n#10 0x000000000374e770 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x374e770)\n#11 0x000000000374eefd llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x374eefd)\n#12 0x000000000302291e 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+0x302291e)\n#13 0x00000000057f51c1 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x57f51c1)\n#14 0x0000000000f07e1e 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+0xf07e1e)\n#15 0x00000000057f377a llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x57f377a)\n#16 0x000000000096470e 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+0x96470e)\n#17 0x00000000057f3131 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x57f3131)\n#18 0x000000000096e8ca llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x96e8ca)\n#19 0x0000000000962978 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x962978)\n#20 0x00007d0067029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#21 0x00007d0067029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#22 0x00000000009595f5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9595f5)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```",
"author": "TatyanaDoubts",
"labels": [
"vectorizers",
"crash-on-valid"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null | null |
131071
|
https://github.com/llvm/llvm-project/issues/131071
|
crash
|
fecd937910f640663885e0434bfed80cf4574072
| 2025-03-13T04:07:59
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "2e13ec561c8139951e3f0815c35c758a7a3011db",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
[
7121,
7126
],
[
9620,
9626
],
[
9640,
9649
]
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
[
32,
38
],
[
83,
88
],
[
106,
111
]
],
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": [
[
68,
79
]
],
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": [
[
494,
501
]
],
"llvm/lib/Transforms/Vectorize/VPlan.cpp": [
[
1532,
1543
]
],
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"LoopVectorizationPlanner::buildVPlan",
"LoopVectorizationPlanner::planInVPlanNativePath",
"LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes"
],
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
"VPlanTransforms::VPInstructionsToVPRecipes",
"sinkScalarOperands"
],
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": [
"LoopVectorizationPlanner::buildVPlans"
],
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 2e13ec561c8139951e3f0815c35c758a7a3011db
Author: Florian Hahn <flo@fhahn.com>
Date: Wed Mar 19 21:35:15 2025 +0000
[VPlan] Bail out on non-intrinsic calls in VPlanNativePath.
Update initial VPlan-construction in VPlanNativePath in line with the
inner loop path, in that it bails out when encountering constructs it
cannot handle, like non-intrinsic calls.
Fixes https://github.com/llvm/llvm-project/issues/131071.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h b/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
index ed3e45dd2c6c..7bbe8669cef6 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
@@ -494,8 +494,10 @@ protected:
private:
/// Build a VPlan according to the information gathered by Legal. \return a
/// VPlan for vectorization factors \p Range.Start and up to \p Range.End
- /// exclusive, possibly decreasing \p Range.End.
- VPlanPtr buildVPlan(VFRange &Range);
+ /// exclusive, possibly decreasing \p Range.End. If no VPlan can be built for
+ /// the input range, set the largest included VF to the maximum VF for which
+ /// no plan could be built.
+ VPlanPtr tryToBuildVPlan(VFRange &Range);
/// Build a VPlan using VPRecipes according to the information gather by
/// Legal. This method is only used for the legacy inner loop vectorizer.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 89337dc38535..61e0d18445b6 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7121,6 +7121,9 @@ LoopVectorizationPlanner::planInVPlanNativePath(ElementCount UserVF) {
<< "VF " << VF << " to build VPlans.\n");
buildVPlans(VF, VF);
+ if (VPlans.empty())
+ return VectorizationFactor::Disabled();
+
// For VPlan build stress testing, we bail out after VPlan construction.
if (VPlanBuildStressTest)
return VectorizationFactor::Disabled();
@@ -9620,7 +9623,7 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
return Plan;
}
-VPlanPtr LoopVectorizationPlanner::buildVPlan(VFRange &Range) {
+VPlanPtr LoopVectorizationPlanner::tryToBuildVPlan(VFRange &Range) {
// Outer loop handling: They may require CFG and instruction level
// transformations before even evaluating whether vectorization is profitable.
// Since we cannot modify the incoming IR, we need to build VPlan upfront in
@@ -9640,10 +9643,13 @@ VPlanPtr LoopVectorizationPlanner::buildVPlan(VFRange &Range) {
for (ElementCount VF : Range)
Plan->addVF(VF);
- VPlanTransforms::VPInstructionsToVPRecipes(
- Plan,
- [this](PHINode *P) { return Legal->getIntOrFpInductionDescriptor(P); },
- *PSE.getSE(), *TLI);
+ if (!VPlanTransforms::tryToConvertVPInstructionsToVPRecipes(
+ Plan,
+ [this](PHINode *P) {
+ return Legal->getIntOrFpInductionDescriptor(P);
+ },
+ *PSE.getSE(), *TLI))
+ return nullptr;
// Tail folding is not supported for outer loops, so the induction increment
// is guaranteed to not wrap.
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index b63cdd04530a..ef82734840ed 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -1532,12 +1532,13 @@ void LoopVectorizationPlanner::buildVPlans(ElementCount MinVF,
auto MaxVFTimes2 = MaxVF * 2;
for (ElementCount VF = MinVF; ElementCount::isKnownLT(VF, MaxVFTimes2);) {
VFRange SubRange = {VF, MaxVFTimes2};
- auto Plan = buildVPlan(SubRange);
- VPlanTransforms::optimize(*Plan);
- // Update the name of the latch of the top-level vector loop region region
- // after optimizations which includes block folding.
- Plan->getVectorLoopRegion()->getExiting()->setName("vector.latch");
- VPlans.push_back(std::move(Plan));
+ if (auto Plan = tryToBuildVPlan(SubRange)) {
+ VPlanTransforms::optimize(*Plan);
+ // Update the name of the latch of the top-level vector loop region region
+ // after optimizations which includes block folding.
+ Plan->getVectorLoopRegion()->getExiting()->setName("vector.latch");
+ VPlans.push_back(std::move(Plan));
+ }
VF = SubRange.End;
}
}
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index e6f788a18805..6c8680ac9661 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -32,7 +32,7 @@
using namespace llvm;
-void VPlanTransforms::VPInstructionsToVPRecipes(
+bool VPlanTransforms::tryToConvertVPInstructionsToVPRecipes(
VPlanPtr &Plan,
function_ref<const InductionDescriptor *(PHINode *)>
GetIntOrFpInductionDescriptor,
@@ -83,6 +83,9 @@ void VPlanTransforms::VPInstructionsToVPRecipes(
} else if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(Inst)) {
NewRecipe = new VPWidenGEPRecipe(GEP, Ingredient.operands());
} else if (CallInst *CI = dyn_cast<CallInst>(Inst)) {
+ Intrinsic::ID VectorID = getVectorIntrinsicIDForCall(CI, &TLI);
+ if (VectorID == Intrinsic::not_intrinsic)
+ return false;
NewRecipe = new VPWidenIntrinsicRecipe(
*CI, getVectorIntrinsicIDForCall(CI, &TLI),
{Ingredient.op_begin(), Ingredient.op_end() - 1}, CI->getType(),
@@ -106,6 +109,7 @@ void VPlanTransforms::VPInstructionsToVPRecipes(
Ingredient.eraseFromParent();
}
}
+ return true;
}
static bool sinkScalarOperands(VPlan &Plan) {
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.h b/llvm/lib/Transforms/Vectorize/VPlanTransforms.h
index 2ec07eea1ecc..fe93637ab723 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.h
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.h
@@ -68,12 +68,13 @@ struct VPlanTransforms {
bool RequiresScalarEpilogueCheck, bool TailFolded, Loop *TheLoop);
/// Replaces the VPInstructions in \p Plan with corresponding
- /// widen recipes.
- static void
- VPInstructionsToVPRecipes(VPlanPtr &Plan,
- function_ref<const InductionDescriptor *(PHINode *)>
- GetIntOrFpInductionDescriptor,
- ScalarEvolution &SE, const TargetLibraryInfo &TLI);
+ /// widen recipes. Returns false if any VPInstructions could not be converted
+ /// to a wide recipe if needed.
+ static bool tryToConvertVPInstructionsToVPRecipes(
+ VPlanPtr &Plan,
+ function_ref<const InductionDescriptor *(PHINode *)>
+ GetIntOrFpInductionDescriptor,
+ ScalarEvolution &SE, const TargetLibraryInfo &TLI);
/// Try to have all users of fixed-order recurrences appear after the recipe
/// defining their previous value, by either sinking users or hoisting recipes
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/vplan-widen-call-instruction.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-width=4 -enable-vplan-native-path -S %s"
],
"tests": [
{
"test_name": "call_to_non_intrinsic",
"test_body": "define void @call_to_non_intrinsic() {\nentry:\n br label %outer.header\n\nouter.header: ; preds = %outer.latch, %entry\n %outer.iv = phi i64 [ 0, %entry ], [ %outer.iv.next, %outer.latch ]\n br label %inner.header\n\ninner.header: ; preds = %inner.header, %outer.header\n %inner.iv = phi i64 [ 0, %outer.header ], [ %inner.iv.next, %inner.header ]\n call void @use()\n %inner.iv.next = add i64 %inner.iv, 1\n %inner.ec = icmp eq i64 %inner.iv.next, 100\n br i1 %inner.ec, label %outer.latch, label %inner.header\n\nouter.latch: ; preds = %inner.header\n %outer.iv.next = add i64 %outer.iv, 1\n %outer.ec = icmp eq i64 %outer.iv.next, 100\n br i1 %outer.ec, label %exit, label %outer.header, !llvm.loop !0\n\nexit: ; preds = %outer.latch\n ret void\n}\n\ndeclare void @use()\n\n!0 = distinct !{!0, !1}\n!1 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[LoopVectorize] Assertion `ID != Intrinsic::not_intrinsic && \"Not an intrinsic!\"' failed.",
"body": "Reproducer: https://godbolt.org/z/n7E1TjTv5\n```\n; bin/opt -passes=loop-vectorize -enable-vplan-native-path reduced.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 i32 @main() {\nentry:\n br label %for.cond2.preheader.i815\n\nfor.cond2.preheader.i815: ; preds = %for.cond.cleanup8.i835.split.us, %entry\n %I.03.i816 = phi i64 [ %inc20.i839, %for.cond.cleanup8.i835.split.us ], [ 0, %entry ]\n br label %cont.i830.us\n\ncont.i830.us: ; preds = %cont.i830.us, %for.cond2.preheader.i815\n %K.01.i824.us = phi i64 [ 0, %for.cond2.preheader.i815 ], [ %inc.i833.us, %cont.i830.us ]\n call void @use(ptr null, i64 0)\n %inc.i833.us = add i64 %K.01.i824.us, 1\n %exitcond.not.i834.us = icmp eq i64 %inc.i833.us, 0\n br i1 %exitcond.not.i834.us, label %for.cond.cleanup8.i835.split.us, label %cont.i830.us\n\nfor.cond.cleanup8.i835.split.us: ; preds = %cont.i830.us\n %inc20.i839 = add i64 %I.03.i816, 1\n %exitcond5.not.i840 = icmp eq i64 %inc20.i839, 0\n br i1 %exitcond5.not.i840, label %\"_ZZ4mainENK3$_7clEmmmPi.exit.loopexit1081\", label %for.cond2.preheader.i815, !llvm.loop !0\n\n\"_ZZ4mainENK3$_7clEmmmPi.exit.loopexit1081\": ; preds = %for.cond.cleanup8.i835.split.us\n ret i32 0\n}\n\ndeclare void @use(ptr, i64)\n\n!0 = distinct !{!0, !1, !2}\n!1 = !{!\"llvm.loop.mustprogress\"}\n!2 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n```\n```\nopt: /root/llvm-project/llvm/lib/Analysis/VectorUtils.cpp:175: bool llvm::isVectorIntrinsicWithOverloadTypeAtArg(llvm::Intrinsic::ID, int, const llvm::TargetTransformInfo*): Assertion `ID != Intrinsic::not_intrinsic && \"Not an intrinsic!\"' failed.\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=loop-vectorize -enable-vplan-native-path <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 \"main\"\n #0 0x0000000005475858 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5475858)\n #1 0x0000000005473214 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007024fda42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007024fda969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007024fda42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007024fda287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x00007024fda2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x00007024fda39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x0000000004bea5d7 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4bea5d7)\n #9 0x00000000045582f0 llvm::VPWidenIntrinsicRecipe::execute(llvm::VPTransformState&) (.part.0) VPlanRecipes.cpp:0:0\n#10 0x0000000004513ea7 llvm::VPBasicBlock::executeRecipes(llvm::VPTransformState*, llvm::BasicBlock*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4513ea7)\n#11 0x000000000451e4cf llvm::VPBasicBlock::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x451e4cf)\n#12 0x000000000451f5c0 llvm::VPRegionBlock::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x451f5c0)\n#13 0x000000000451f5c0 llvm::VPRegionBlock::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x451f5c0)\n#14 0x000000000452b451 llvm::VPlan::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x452b451)\n#15 0x00000000043ddd2f llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool, llvm::DenseMap<llvm::SCEV const*, llvm::Value*, llvm::DenseMapInfo<llvm::SCEV const*, void>, llvm::detail::DenseMapPair<llvm::SCEV const*, llvm::Value*>> const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43ddd2f)\n#16 0x00000000043f0e36 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43f0e36)\n#17 0x00000000043f45e9 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43f45e9)\n#18 0x00000000043f4c63 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43f4c63)\n#19 0x000000000319510e 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+0x319510e)\n#20 0x0000000005270840 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5270840)\n#21 0x0000000000e79f8e 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+0xe79f8e)\n#22 0x000000000526f15b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x526f15b)\n#23 0x0000000000e7910e 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+0xe7910e)\n#24 0x000000000526eb60 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x526eb60)\n#25 0x000000000094151a 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+0x94151a)\n#26 0x0000000000934c6c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x934c6c)\n#27 0x00007024fda29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#28 0x00007024fda29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#29 0x000000000092c755 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x92c755)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```\nReduced from llvm-test-suite/SingleSource/UnitTests/Vectorizer/VPlanNativePath/outer-loop-vect.cpp with ubsan+https://github.com/llvm/llvm-project/pull/130990 enabled\n\n\n",
"author": "dtcxzyw",
"labels": [
"vectorizers",
"crash-on-valid"
],
"comments": [
{
"author": "zhangjunphy",
"body": "It seems for vplan vectorization, `LoopVectorizationLegality::canVectorize` only checks the loop structure and then skips the check of individual instructions. So the pass later tries to rewirte that call to `@use` and failed."
},
{
"author": "zhangjunphy",
"body": "From the description of `isExplicitVecOuterLoop`. This does not seem to a problem of the LoopVectorization pass.\nWhen `-enable-vplan-native-path` is provided, LLVM only attempts to vectorize outer loops marked with a pragma.\nAnd the programmer is expected to ensure vectorization must be legal for those loops.\nhttps://github.com/llvm/llvm-project/blob/125553a6779ba179a9b4b5212c531da2474258fd/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp#L2183-L2192\n\n=============\nEdited for clarity."
},
{
"author": "dtcxzyw",
"body": "Does ubsan instrumentation break this assumption?\n"
},
{
"author": "zhangjunphy",
"body": "Well, I'm far from familiar with the design of vectorization and this is just my conclusion from reading the code.\n\nFrom what I understand, if the flag `-enable-vplan-native-path` is specified, the IR producer is required to be certain that the loop marked with \"llvm.loop.vectorize.enable\" is actually vectorizable. Otherwise this will cause problems as that flag will cause vectorization to bypass some legality checks and to directly attempt vectorizing the loop. \n\nIn this case, the instrumentation added the \"llvm.loop.vectorize.enable\" metadata to the loop. But there is the call to `@use` which is not vectorizable. And this check is bypassed with `-enable-vplan-native-path`, thus caused the problem."
},
{
"author": "fhahn",
"body": "It is true that the native path somewhat relies on the loops being marked safe for vectorization by the user, we still shouldn't crash. In this particular case we can easily detect that we cannot create a valid VPlan, and bail out. I will prepare a fix."
}
]
}
| true
|
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
|
Cannot find a good commit
| null |
151392
|
https://github.com/llvm/llvm-project/issues/151392
|
crash
|
c7500a2ec3baae1f0d7de0de94407d4bdb2e5d4d
| 2025-07-30T20:45:12
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "39c30665e99145e07b0170b552f18371a67b2e03",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": [
[
2836,
2847
]
],
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": [
"scalarizeInstruction"
],
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit 39c30665e99145e07b0170b552f18371a67b2e03
Author: Florian Hahn <flo@fhahn.com>
Date: Sat Aug 2 19:49:59 2025 +0100
[VPlan] Update type of cloned instruction in scalarizeInstruction.
The operands of the replicate recipe may have been narrowed, resulting
in a narrower result type. Update the type of the cloned instruction to
the correct type.
Fixes https://github.com/llvm/llvm-project/issues/151392.
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index 11b4677ec102..98d11f0bc789 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -2836,12 +2836,12 @@ static void scalarizeInstruction(const Instruction *Instr,
Instruction *Cloned = Instr->clone();
if (!IsVoidRetTy) {
Cloned->setName(Instr->getName() + ".cloned");
-#if !defined(NDEBUG)
- // Verify that VPlan type inference results agree with the type of the
- // generated values.
- assert(State.TypeAnalysis.inferScalarType(RepRecipe) == Cloned->getType() &&
- "inferred type and type from generated instructions do not match");
-#endif
+ Type *ResultTy = State.TypeAnalysis.inferScalarType(RepRecipe);
+ // The operands of the replicate recipe may have been narrowed, resulting in
+ // a narrower result type. Update the type of the cloned instruction to the
+ // correct type.
+ if (ResultTy != Cloned->getType())
+ Cloned->mutateType(ResultTy);
}
RepRecipe->applyFlags(*Cloned);
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/single-scalar-cast-minbw.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-width=4 -S %s"
],
"tests": [
{
"test_name": "single_scalar_cast_stored",
"test_body": "define void @single_scalar_cast_stored(ptr %src, ptr %dst, i32 %n) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %l = load i16, ptr %src, align 2\n %cmp = icmp eq i16 %l, 0\n %l.ext = zext i16 %l to i32\n %and = and i32 %l.ext, 15\n %sel = select i1 %cmp, i32 0, i32 %and\n %sel.trunc = trunc i32 %sel to i16\n store i16 %sel.trunc, ptr %dst, align 2\n %iv.next = add nuw i32 %iv, 1\n %ec = icmp ne i32 %iv.next, %n\n br i1 %ec, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[LoopVectorize] Assertion `State.TypeAnalysis.inferScalarType(RepRecipe) == Cloned->getType() && \"inferred type and type from generated instructions do not match\"' failed.",
"body": "Testcase:\n```llvm ir\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\n@b = external global [0 x i16]\n@n = internal global i16 9\n@u = external global [9 x i64]\n@p = external global [9 x i16]\n\ndefine i64 @c(i8 %k, i16 %n, ptr %p, ptr %u, ptr %w, i64 %indvars.iv133, i8 %sub, i8 %add98.us.us.us) {\nentry:\n %arrayidx36 = getelementptr i8, ptr %u, i64 64\n br label %for.cond18.preheader.us.us.us\n\nfor.cond18.preheader.us.us.us: ; preds = %cond.false.us.us.us, %entry\n br label %cond.false.us.us.us\n\ncond.false.us.us.us: ; preds = %for.body27.us.us.us, %for.cond18.preheader.us.us.us\n %ah.0.us.us.us = phi i32 [ %add67.us.us.us, %for.body27.us.us.us ], [ 0, %for.cond18.preheader.us.us.us ]\n %0 = load i16, ptr %p, align 2\n %conv22.us.us.us = sext i16 %0 to i32\n %cmp24.us.us.us = icmp slt i32 %ah.0.us.us.us, %conv22.us.us.us\n br i1 %cmp24.us.us.us, label %for.body27.us.us.us, label %for.cond18.preheader.us.us.us\n\nfor.body27.us.us.us: ; preds = %cond.false.us.us.us\n %1 = load i16, ptr %w, align 2\n %tobool.not.us.us.us = icmp eq i16 %1, 0\n %narrow.us.us.us = select i1 %tobool.not.us.us.us, i16 0, i16 %n\n %cond35.us.us.us = sext i16 %narrow.us.us.us to i32\n %2 = load i64, ptr %arrayidx36, align 8\n %conv37.us.us.us = trunc i64 %2 to i32\n %cond43.us.us.us = tail call i32 @llvm.smin.i32(i32 %cond35.us.us.us, i32 %conv37.us.us.us)\n %conv46.us.us.us = trunc i32 %cond43.us.us.us to i16\n store i16 %conv46.us.us.us, ptr @b, align 2\n %3 = load i8, ptr %w, align 1\n %conv54.us.us.us = sext i8 %3 to i16\n store i16 %conv54.us.us.us, ptr %u, align 2\n %add67.us.us.us = add i32 %ah.0.us.us.us, 1\n br label %cond.false.us.us.us\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.smin.i32(i32, i32) #0\n\ndefine i64 @main(ptr %k) #1 {\nentry:\n store i64 57, ptr getelementptr inbounds nuw (i8, ptr @u, i64 64), align 32\n %0 = load i16, ptr @n, align 2\n %1 = call i64 @c(i8 0, i16 %0, ptr @p, ptr @u, ptr %k, i64 0, i8 0, i8 0)\n ret i64 %1\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\nattributes #1 = { \"target-features\"=\"+v\" }\n```\n\nCommands/backtrace\n```\n$ /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt \"-passes=lto<O3>\" reduced.ll\nWARNING: You're attempting to print out a bitcode file.\nThis is inadvisable as it may cause display problems. If\nyou REALLY want to taste LLVM bitcode first-hand, you\ncan force output with the `-f' option.\n\nopt: /scratch/ewlu/daily-upstream-build/llvm/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp:2842: void scalarizeInstruction(const llvm::Instruction*, llvm::VPReplicateRecipe*, const llvm::VPLane&, llvm::VPTransformState&): Assertion `State.TypeAnalysis.inferScalarType(RepRecipe) == Cloned->getType() && \"inferred type and type from generated instructions do not match\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0. Program arguments: /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt -passes=lto<O3> reduced.ll\n1. Running pass \"function<eager-inv>(loop-mssa(licm<allowspeculation>),gvn<>,memcpyopt,dse,move-auto-init,mldst-motion<no-split-footer-bb>,loop(indvars,loop-deletion,loop-unroll-full),loop-distribute,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,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>,sccp,instcombine<max-iterations=1;no-verify-fixpoint>,bdce,slp-vectorizer,vector-combine,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop(evl-iv-simplify),jump-threading)\" on module \"reduced.ll\"\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\n #0 0x0000645af6577e72 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x338ee72)\n #1 0x0000645af6574b6f llvm::sys::RunSignalHandlers() (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x338bb6f)\n #2 0x0000645af6574cbc SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #3 0x000079da8fc45330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)\n #4 0x000079da8fc9eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #5 0x000079da8fc9eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #6 0x000079da8fc9eb2c pthread_kill ./nptl/pthread_kill.c:89:10\n #7 0x000079da8fc4527e raise ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x000079da8fc288ff abort ./stdlib/abort.c:81:7\n #9 0x000079da8fc2881b _nl_load_domain ./intl/loadmsgcat.c:1177:9\n#10 0x000079da8fc3b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)\n#11 0x0000645af4394a5d (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x11aba5d)\n#12 0x0000645af43986a3 llvm::VPReplicateRecipe::execute(llvm::VPTransformState&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x11af6a3)\n#13 0x0000645af433bee1 llvm::VPBasicBlock::executeRecipes(llvm::VPTransformState*, llvm::BasicBlock*) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x1152ee1)\n#14 0x0000645af43510d7 llvm::VPBasicBlock::execute(llvm::VPTransformState*) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x11680d7)\n#15 0x0000645af43582c1 llvm::VPlan::execute(llvm::VPTransformState*) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x116f2c1)\n#16 0x0000645af41d802f llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0xfef02f)\n#17 0x0000645af41e69f7 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0xffd9f7)\n#18 0x0000645af41e96a1 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x10006a1)\n#19 0x0000645af41e9c67 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x1000c67)\n#20 0x0000645af3a81535 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x898535)\n#21 0x0000645af635bb7d llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x3172b7d)\n#22 0x0000645af3a83d15 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x89ad15)\n#23 0x0000645af635bf67 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x3172f67)\n#24 0x0000645af3719fe5 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x530fe5)\n#25 0x0000645af635d10d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x317410d)\n#26 0x0000645af3726099 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x53d099)\n#27 0x0000645af37181a8 optMain (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x52f1a8)\n#28 0x000079da8fc2a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3\n#29 0x000079da8fc2a28b call_init ./csu/../csu/libc-start.c:128:20\n#30 0x000079da8fc2a28b __libc_start_main ./csu/../csu/libc-start.c:347:5\n#31 0x0000645af370e0b5 _start (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x5250b5)\nAborted (core dumped)\n```\n\nGodbolt: https://godbolt.org/z/T3cbfY9zG\n\nFound via fuzzer (C program before reduction)",
"author": "ewlu",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
3b7b95f78e24aca5175b8f864bfea2953a2dd34f
| null |
156656
|
https://github.com/llvm/llvm-project/issues/156656
|
crash
|
57b1b254297ed2d2fd9560e6a5eef0c44918223a
| 2025-09-03T12:40:52
|
[
"llvm/test/Transforms/GlobalOpt"
] |
{
"fix_commit": "f80e7e139e3e677638233037499f8cba50c66b9e",
"components": [
"GlobalOpt"
],
"bug_location_lineno": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": [
[
1680,
1686
],
[
1766,
1775
],
[
1779,
1785
]
],
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/include/llvm/Transforms/Utils/CodeMoverUtils.h": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/Utils/LoopUtils.h": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Analysis/HashRecognize.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": [
"ChangeCalleesToFastCall",
"StripAttr",
"changeCallSitesToColdCC",
"isValidCandidateForColdCC"
],
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/ControlFlowUtils.cpp": null,
"llvm/lib/Transforms/Utils/UnifyLoopExits.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.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/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/CodeMoverUtils.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/include/llvm/CodeGen/BasicTTIImpl.h": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/Float2Int.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/IPO/MergeFunctions.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/LoopUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp": null,
"llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null
}
}
|
commit f80e7e139e3e677638233037499f8cba50c66b9e
Author: Hongyu Chen <xxs_chy@outlook.com>
Date: Wed Oct 1 16:47:41 2025 +0800
[GlobalOpt] Check if users are CallBase when changing CC (#161399)
Fixes https://github.com/llvm/llvm-project/issues/156656
`hasChangeableCCImpl` guarantees the address of the function is not
taken, but it ignores assume-like calls.
This patch ignores assume-like calls when changing CC.
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index f88d51f443bc..99c4982c58b4 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -1680,7 +1680,9 @@ processGlobal(GlobalValue &GV,
/// FastCC.
static void ChangeCalleesToFastCall(Function *F) {
for (User *U : F->users())
- cast<CallBase>(U)->setCallingConv(CallingConv::Fast);
+ if (auto *Call = dyn_cast<CallBase>(U))
+ if (Call->getCalledOperand() == F)
+ Call->setCallingConv(CallingConv::Fast);
}
static AttributeList StripAttr(LLVMContext &C, AttributeList Attrs,
@@ -1766,10 +1768,12 @@ isValidCandidateForColdCC(Function &F,
return false;
for (User *U : F.users()) {
- CallBase &CB = cast<CallBase>(*U);
- Function *CallerFunc = CB.getParent()->getParent();
+ CallBase *CB = dyn_cast<CallBase>(U);
+ if (!CB || CB->getCalledOperand() != &F)
+ continue;
+ Function *CallerFunc = CB->getParent()->getParent();
BlockFrequencyInfo &CallerBFI = GetBFI(*CallerFunc);
- if (!isColdCallSite(CB, CallerBFI))
+ if (!isColdCallSite(*CB, CallerBFI))
return false;
if (!llvm::is_contained(AllCallsCold, CallerFunc))
return false;
@@ -1779,7 +1783,9 @@ isValidCandidateForColdCC(Function &F,
static void changeCallSitesToColdCC(Function *F) {
for (User *U : F->users())
- cast<CallBase>(U)->setCallingConv(CallingConv::Cold);
+ if (auto *Call = dyn_cast<CallBase>(U))
+ if (Call->getCalledOperand() == F)
+ Call->setCallingConv(CallingConv::Cold);
}
// This function iterates over all the call instructions in the input Function
|
[
{
"file": "llvm/test/Transforms/GlobalOpt/fastcc.ll",
"commands": [
"opt < %s -passes=globalopt -S"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndeclare token @llvm.call.preallocated.setup(i32)\ndeclare ptr @llvm.call.preallocated.arg(token, i32)\n\ndefine internal i32 @f(ptr %m) {\n;\n %v = load i32, ptr %m\n ret i32 %v\n}\n\ndefine internal x86_thiscallcc i32 @g(ptr %m) {\n;\n %v = load i32, ptr %m\n ret i32 %v\n}\n\n; Leave this one alone, because the user went out of their way to request this\n; convention.\ndefine internal coldcc i32 @h(ptr %m) {\n;\n %v = load i32, ptr %m\n ret i32 %v\n}\n\ndefine internal i32 @j(ptr %m) {\n;\n %v = load i32, ptr %m\n ret i32 %v\n}\n\ndefine internal i32 @inalloca(ptr inalloca(i32) %p) {\n;\n %rv = load i32, ptr %p\n ret i32 %rv\n}\n\ndefine i32 @inalloca2_caller(ptr inalloca(i32) %p) {\n;\n %rv = musttail call i32 @inalloca2(ptr inalloca(i32) %p)\n ret i32 %rv\n}\ndefine internal i32 @inalloca2(ptr inalloca(i32) %p) {\n; Because of the musttail caller, this inalloca cannot be dropped.\n;\n %rv = load i32, ptr %p\n ret i32 %rv\n}\n\ndefine internal i32 @preallocated(ptr preallocated(i32) %p) {\n;\n %rv = load i32, ptr %p\n ret i32 %rv\n}\n\ndefine void @call_things() {\n;\n %m = alloca i32\n call i32 @f(ptr %m)\n call x86_thiscallcc i32 @g(ptr %m)\n call coldcc i32 @h(ptr %m)\n call i32 @j(ptr %m)\n %args = alloca inalloca i32\n call i32 @inalloca(ptr inalloca(i32) %args)\n %c = call token @llvm.call.preallocated.setup(i32 1)\n %N = call ptr @llvm.call.preallocated.arg(token %c, i32 0) preallocated(i32)\n call i32 @preallocated(ptr preallocated(i32) %N) [\"preallocated\"(token %c)]\n ret void\n}\n\n@llvm.used = appending global [1 x ptr] [\n ptr @j\n], section \"llvm.metadata\"\n\ndefine internal i32 @assume_fastcc() {\n;\n %objsize = call i32 @llvm.objectsize.i32.p0(ptr @assume_fastcc, i1 false, i1 false, i1 false)\n ret i32 %objsize\n}\n\ndefine internal i32 @constexpr_self_user() addrspace(1) {\n;\n %objsize = call i32 @llvm.objectsize.i32.p0(ptr addrspacecast (ptr addrspace(1) @constexpr_self_user to ptr), i1 false, i1 false, i1 false)\n ret i32 %objsize\n}",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "crashes with assertion failure when running opt -passes=globalopt",
"body": "Run opt with -passes=globalopt\n\nReproducer:\nhttps://godbolt.org/z/6obEYeKEh\n\nBacktrace:\n```console\nopt: /root/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From*) [with To = llvm::CallBase; From = llvm::User]: Assertion `isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"' failed.\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=globalopt <source>\n1.\tRunning pass \"globalopt\" on module \"<source>\"\n #0 0x000000000578f178 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x578f178)\n #1 0x000000000578c024 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x000071ca6f842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x000071ca6f8969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x000071ca6f842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x000071ca6f8287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x000071ca6f82871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x000071ca6f839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x00000000030ac2ea optimizeGlobalsInModule(llvm::Module&, llvm::DataLayout const&, llvm::function_ref<llvm::TargetLibraryInfo& (llvm::Function&)>, llvm::function_ref<llvm::TargetTransformInfo& (llvm::Function&)>, llvm::function_ref<llvm::BlockFrequencyInfo& (llvm::Function&)>, llvm::function_ref<llvm::DominatorTree& (llvm::Function&)>, llvm::function_ref<void (llvm::Function&)>, llvm::function_ref<void (llvm::Function&)>) (.constprop.0) GlobalOpt.cpp:0:0\n #9 0x00000000030ad19f llvm::GlobalOptPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x30ad19f)\n#10 0x0000000002e23dae llvm::detail::PassModel<llvm::Module, llvm::GlobalOptPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2e23dae)\n#11 0x0000000005578c41 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5578c41)\n#12 0x0000000000976da8 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x976da8)\n#13 0x000000000096ae17 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x96ae17)\n#14 0x000071ca6f829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#15 0x000071ca6f829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#16 0x0000000000961f35 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x961f35)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```",
"author": "k-arrows",
"labels": [
"ipo",
"crash"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
|
Cannot find a good commit
| null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.