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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
142286
|
https://github.com/llvm/llvm-project/issues/142286
|
miscompilation
|
b9fa1dfd38ee75640402fdd0ca3640a51b95a8a3
| 2025-05-31T20:42:03
|
[
"llvm/test/Transforms/CorrelatedValuePropagation"
] |
{
"fix_commit": "0f7cc4132b62e0ecdbd3193e954b745c5f492e90",
"components": [
"CorrelatedValuePropagation"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": [
[
370,
384
],
[
395,
401
],
[
410,
436
]
],
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.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/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": [
"processSwitch"
],
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.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/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null
}
}
|
commit 0f7cc4132b62e0ecdbd3193e954b745c5f492e90
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Mon Jun 2 17:42:02 2025 +0800
[CVP] Keep `ReachableCaseCount` in sync with range of condition (#142302)
https://github.com/llvm/llvm-project/pull/79993 assumes that a reachable
case must be contained by `CR`. However, it doesn't hold for some edge
cases. This patch adds additional checks to ensure `ReachableCaseCount`
is correct.
Note: Similar optimization in SCCP isn't affected by this bug because it
uses `CR` to compute `ReachableCaseCount`.
Closes https://github.com/llvm/llvm-project/issues/142286.
diff --git a/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp b/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
index 5226aeb66f65..b95a851c99b4 100644
--- a/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
+++ b/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
@@ -370,15 +370,30 @@ static bool processSwitch(SwitchInst *I, LazyValueInfo *LVI,
{ // Scope for SwitchInstProfUpdateWrapper. It must not live during
// ConstantFoldTerminator() as the underlying SwitchInst can be changed.
SwitchInstProfUpdateWrapper SI(*I);
+ ConstantRange CR =
+ LVI->getConstantRangeAtUse(I->getOperandUse(0), /*UndefAllowed=*/false);
unsigned ReachableCaseCount = 0;
for (auto CI = SI->case_begin(), CE = SI->case_end(); CI != CE;) {
ConstantInt *Case = CI->getCaseValue();
- auto *Res = dyn_cast_or_null<ConstantInt>(
- LVI->getPredicateAt(CmpInst::ICMP_EQ, Cond, Case, I,
- /* UseBlockValue */ true));
+ std::optional<bool> Predicate = std::nullopt;
+ if (!CR.contains(Case->getValue()))
+ Predicate = false;
+ else if (CR.isSingleElement() &&
+ *CR.getSingleElement() == Case->getValue())
+ Predicate = true;
+ if (!Predicate) {
+ // Handle missing cases, e.g., the range has a hole.
+ auto *Res = dyn_cast_or_null<ConstantInt>(
+ LVI->getPredicateAt(CmpInst::ICMP_EQ, Cond, Case, I,
+ /* UseBlockValue=*/true));
+ if (Res && Res->isZero())
+ Predicate = false;
+ else if (Res && Res->isOne())
+ Predicate = true;
+ }
- if (Res && Res->isZero()) {
+ if (Predicate && !*Predicate) {
// This case never fires - remove it.
BasicBlock *Succ = CI->getCaseSuccessor();
Succ->removePredecessor(BB);
@@ -395,7 +410,7 @@ static bool processSwitch(SwitchInst *I, LazyValueInfo *LVI,
DTU.applyUpdatesPermissive({{DominatorTree::Delete, BB, Succ}});
continue;
}
- if (Res && Res->isOne()) {
+ if (Predicate && *Predicate) {
// This case always fires. Arrange for the switch to be turned into an
// unconditional branch by replacing the switch condition with the case
// value.
@@ -410,27 +425,24 @@ static bool processSwitch(SwitchInst *I, LazyValueInfo *LVI,
++ReachableCaseCount;
}
- if (ReachableCaseCount > 1 && !SI->defaultDestUnreachable()) {
+ // The default dest is unreachable if all cases are covered.
+ if (!SI->defaultDestUnreachable() &&
+ !CR.isSizeLargerThan(ReachableCaseCount)) {
BasicBlock *DefaultDest = SI->getDefaultDest();
- ConstantRange CR = LVI->getConstantRangeAtUse(I->getOperandUse(0),
- /*UndefAllowed*/ false);
- // The default dest is unreachable if all cases are covered.
- if (!CR.isSizeLargerThan(ReachableCaseCount)) {
- BasicBlock *NewUnreachableBB =
- BasicBlock::Create(BB->getContext(), "default.unreachable",
- BB->getParent(), DefaultDest);
- new UnreachableInst(BB->getContext(), NewUnreachableBB);
+ BasicBlock *NewUnreachableBB =
+ BasicBlock::Create(BB->getContext(), "default.unreachable",
+ BB->getParent(), DefaultDest);
+ new UnreachableInst(BB->getContext(), NewUnreachableBB);
- DefaultDest->removePredecessor(BB);
- SI->setDefaultDest(NewUnreachableBB);
+ DefaultDest->removePredecessor(BB);
+ SI->setDefaultDest(NewUnreachableBB);
- if (SuccessorsCount[DefaultDest] == 1)
- DTU.applyUpdates({{DominatorTree::Delete, BB, DefaultDest}});
- DTU.applyUpdates({{DominatorTree::Insert, BB, NewUnreachableBB}});
+ if (SuccessorsCount[DefaultDest] == 1)
+ DTU.applyUpdates({{DominatorTree::Delete, BB, DefaultDest}});
+ DTU.applyUpdates({{DominatorTree::Insert, BB, NewUnreachableBB}});
- ++NumDeadCases;
- Changed = true;
- }
+ ++NumDeadCases;
+ Changed = true;
}
}
|
[
{
"file": "llvm/test/Transforms/CorrelatedValuePropagation/switch.ll",
"commands": [
"opt < %s -passes=correlated-propagation -S"
],
"tests": [
{
"test_name": "pr142286",
"test_body": "define void @pr142286() {\nstart:\n br label %loop\n\nloop: ; preds = %loop3, %start\n %phi = phi i8 [ -1, %start ], [ 0, %loop3 ]\n br label %loop2\n\nloop2: ; preds = %loop3, %loop\n br label %loop3\n\nloop3: ; preds = %loop3, %loop2\n switch i8 %phi, label %exit [\n i8 0, label %loop3\n i8 1, label %loop2\n i8 2, label %loop\n ]\n\nexit: ; preds = %loop3\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "CorrelatedValuePropagation miscompilation",
"body": "Like https://github.com/llvm/llvm-project/issues/139866 this is from a fuzzer that generates Rust MIR: https://github.com/cbeuw/rustlantis.\n\nThe Rust MIR reproducer is: https://godbolt.org/z/sb568G8r4\n\nWith this command line, the program runs:\n```\nrustc 9870897538617236803.rs -Copt-level=2 -Cllvm-args=-opt-bisect-limit=478\n```\nAny greater value of opt-bisect-limit runs CorrelatedValuePropagation on `main` and produces a program that just executes a `ud2`.",
"author": "saethlin",
"labels": [
"miscompilation",
"release:cherry-pick-failed",
"generated by fuzzer"
],
"comments": [
{
"author": "nikic",
"body": "https://llvm.godbolt.org/z/s1sYaWbc3\n```llvm\n; RUN: opt -S -passes=correlated-propagation < %s\ndefine void @test() {\nstart:\n br label %loop\n\nloop:\n %phi = phi i8 [ -69, %start ], [ 0, %loop3 ]\n br label %loop2\n\nloop2:\n br label %loop3\n\nloop3:\n switch i8 %phi, label %exit [\n i8 0, label %loop3\n i8 1, label %loop2\n i8 2, label %loop\n ]\n\nexit:\n call void @foo()\n ret void\n}\n\ndeclare void @foo()\n```"
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
394e321a2ea021194891cf5b0c5747a901fb7915
| null |
87410
|
https://github.com/llvm/llvm-project/issues/87410
|
crash
|
0bbe953aa3289a32cd816647820c8676bb3a61bc
| 2024-04-02T21:05:28
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "c83698367125703827f1b739393f006c399cb213",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
[
8233,
8238
]
],
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": [
[
1513,
1518
]
],
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": [
[
1932,
1945
],
[
1949,
1963
]
],
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.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/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"VPRecipeBuilder::tryToBlend"
],
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": [
"VPBlendRecipe::print"
],
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": [
"VPBlendRecipe",
"clone",
"getIncomingValue",
"getMask",
"getNumIncomingValues"
],
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.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/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null
}
}
|
commit c83698367125703827f1b739393f006c399cb213
Author: Florian Hahn <flo@fhahn.com>
Date: Tue Apr 9 11:14:05 2024 +0100
[VPlan] Remove unused first mask op from VPBlendRecipe. (#87770)
VPBlendRecipe does not use the first mask operand. Removing it allows
VPlan-based DCE to remove unused mask computations.
This also fixes #87410, where unused Not VPInstructions are considered
having only their first lane demanded, but some of their operands
providing a vector value due to other users.
Fixes https://github.com/llvm/llvm-project/issues/87410
PR: https://github.com/llvm/llvm-project/pull/87770
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index fd54faf17ca3..5535cc55e932 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -8221,6 +8221,8 @@ VPBlendRecipe *VPRecipeBuilder::tryToBlend(PHINode *Phi,
// builder. At this point we generate the predication tree. There may be
// duplications since this is a simple recursive scan, but future
// optimizations will clean it up.
+ // TODO: At the moment the first mask is always skipped, but it would be
+ // better to skip the most expensive mask.
SmallVector<VPValue *, 2> OperandsWithMask;
for (unsigned In = 0; In < NumIncoming; In++) {
@@ -8233,6 +8235,8 @@ VPBlendRecipe *VPRecipeBuilder::tryToBlend(PHINode *Phi,
"Distinct incoming values with one having a full mask");
break;
}
+ if (In == 0)
+ continue;
OperandsWithMask.push_back(EdgeMask);
}
return new VPBlendRecipe(Phi, OperandsWithMask);
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 5f6334b974cf..5dc905a3c407 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -1932,14 +1932,12 @@ public:
class VPBlendRecipe : public VPSingleDefRecipe {
public:
/// The blend operation is a User of the incoming values and of their
- /// respective masks, ordered [I0, M0, I1, M1, ...]. Note that a single value
- /// might be incoming with a full mask for which there is no VPValue.
+ /// respective masks, ordered [I0, I1, M1, I2, M2, ...]. Note that the first
+ /// incoming value does not have a mask associated.
VPBlendRecipe(PHINode *Phi, ArrayRef<VPValue *> Operands)
: VPSingleDefRecipe(VPDef::VPBlendSC, Operands, Phi, Phi->getDebugLoc()) {
- assert(Operands.size() > 0 &&
- ((Operands.size() == 1) || (Operands.size() % 2 == 0)) &&
- "Expected either a single incoming value or a positive even number "
- "of operands");
+ assert((Operands.size() + 1) % 2 == 0 &&
+ "Expected an odd number of operands");
}
VPRecipeBase *clone() override {
@@ -1949,15 +1947,20 @@ public:
VP_CLASSOF_IMPL(VPDef::VPBlendSC)
- /// Return the number of incoming values, taking into account that a single
+ /// Return the number of incoming values, taking into account that the first
/// incoming value has no mask.
unsigned getNumIncomingValues() const { return (getNumOperands() + 1) / 2; }
/// Return incoming value number \p Idx.
- VPValue *getIncomingValue(unsigned Idx) const { return getOperand(Idx * 2); }
+ VPValue *getIncomingValue(unsigned Idx) const {
+ return Idx == 0 ? getOperand(0) : getOperand(Idx * 2 - 1);
+ }
/// Return mask number \p Idx.
- VPValue *getMask(unsigned Idx) const { return getOperand(Idx * 2 + 1); }
+ VPValue *getMask(unsigned Idx) const {
+ assert(Idx > 0 && "First index has no mask associated.");
+ return getOperand(Idx * 2);
+ }
/// Generate the phi/select nodes.
void execute(VPTransformState &State) override;
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index 2438e4dae3eb..625319954e9b 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -1513,6 +1513,8 @@ void VPBlendRecipe::print(raw_ostream &O, const Twine &Indent,
for (unsigned I = 0, E = getNumIncomingValues(); I < E; ++I) {
O << " ";
getIncomingValue(I)->printAsOperand(O, SlotTracker);
+ if (I == 0)
+ continue;
O << "/";
getMask(I)->printAsOperand(O, SlotTracker);
}
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/unused-blend-mask-for-first-operand.ll",
"commands": [
"opt -p loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -S %s"
],
"tests": [
{
"test_name": "test_not_first_lane_only_constant",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine void @test_not_first_lane_only_constant(ptr %A, ptr noalias %B) {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i16 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %gep.A = getelementptr inbounds i16, ptr %A, i16 %iv\n br i1 false, label %loop.latch, label %else.1\n\nelse.1: ; preds = %loop.header\n br i1 false, label %then.2, label %else.2\n\nthen.2: ; preds = %else.1\n br label %else.2\n\nelse.2: ; preds = %then.2, %else.1\n br label %loop.latch\n\nloop.latch: ; preds = %else.2, %loop.header\n %merge = phi ptr [ %B, %else.2 ], [ poison, %loop.header ]\n %l = load i16, ptr %merge, align 2\n %iv.next = add i16 %iv, 1\n store i16 %l, ptr %gep.A, align 2\n %c.2 = icmp eq i16 %iv.next, 1000\n br i1 %c.2, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "test_not_first_lane_only_wide_compare",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine void @test_not_first_lane_only_wide_compare(ptr %A, ptr noalias %B, i16 %x, i16 %y) {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i16 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %gep.A = getelementptr inbounds i16, ptr %A, i16 %iv\n %l.0 = load i16, ptr %gep.A, align 2\n %c.0 = icmp ult i16 %l.0, %x\n br i1 %c.0, label %loop.latch, label %else.1\n\nelse.1: ; preds = %loop.header\n %c.1 = icmp ult i16 %l.0, %y\n br i1 %c.1, label %then.2, label %else.2\n\nthen.2: ; preds = %else.1\n br label %else.2\n\nelse.2: ; preds = %then.2, %else.1\n br label %loop.latch\n\nloop.latch: ; preds = %else.2, %loop.header\n %merge = phi ptr [ %B, %else.2 ], [ poison, %loop.header ]\n %l = load i16, ptr %merge, align 2\n %iv.next = add i16 %iv, 1\n store i16 %l, ptr %gep.A, align 2\n %c.2 = icmp eq i16 %iv.next, 1000\n br i1 %c.2, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[LoopVectorize][VPlan] Assertion \"Trying to access a single scalar per part but has multiple scalars per part.\" failed.",
"body": "Reduced LLVM IR\r\n```llvm ir\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine i32 @main() #0 {\r\nentry:\r\n br label %for.body.i\r\n\r\nfor.body.i: ; preds = %if.end.i, %entry\r\n %q.0139.i = phi i16 [ 0, %entry ], [ %add.i, %if.end.i ]\r\n %idxprom.i = sext i16 0 to i64\r\n br i1 false, label %if.end.i, label %if.then.i\r\n\r\nif.then.i: ; preds = %for.body.i\r\n br i1 false, label %cond.end41.i, label %cond.end41.i\r\n\r\ncond.end41.i: ; preds = %if.then.i, %if.then.i\r\n br label %if.end.i\r\n\r\nif.end.i: ; preds = %cond.end41.i, %for.body.i\r\n %.in.i = phi ptr [ null, %cond.end41.i ], [ poison, %for.body.i ]\r\n %0 = load i16, ptr %.in.i, align 2\r\n %add.i = add i16 %q.0139.i, 1\r\n %tobool.not.i = icmp eq i16 %add.i, 0\r\n br i1 %tobool.not.i, label %m.exit, label %for.body.i\r\n\r\nm.exit: ; preds = %if.end.i\r\n %.lcssa = phi i16 [ %0, %if.end.i ]\r\n ret i32 0\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\r\n```\r\n\r\nBacktrace:\r\n```\r\nopt: /scratch/tc-testing/tc-apr-2/llvm/llvm/lib/Transforms/Vectorize/VPlan.cpp:249: 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\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt --passes=loop-vectorize reduced.ll\r\n #0 0x00005ed60f56eb60 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2d84b60)\r\n #1 0x00005ed60f56bf6f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2d81f6f)\r\n #2 0x00005ed60f56c0c5 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007f973de42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007f973de969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007f973de969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007f973de969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x00007f973de42476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007f973de287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x00007f973de2871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x00007f973de39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x00005ed60e6cbb72 llvm::VPTransformState::get(llvm::VPValue*, unsigned int, bool) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1ee1b72)\r\n#12 0x00005ed60e6fa9a6 llvm::VPInstruction::generatePerPart(llvm::VPTransformState&, unsigned int) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1f109a6)\r\n#13 0x00005ed60e6fbbdf llvm::VPInstruction::execute(llvm::VPTransformState&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1f11bdf)\r\n#14 0x00005ed60e6d74ff llvm::VPBasicBlock::execute(llvm::VPTransformState*) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1eed4ff)\r\n#15 0x00005ed60e6cd9e0 llvm::VPRegionBlock::execute(llvm::VPTransformState*) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1ee39e0)\r\n#16 0x00005ed60e6d90e6 llvm::VPlan::execute(llvm::VPTransformState*) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1eef0e6)\r\n#17 0x00005ed60e5d76f3 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-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1ded6f3)\r\n#18 0x00005ed60e5e9718 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1dff718)\r\n#19 0x00005ed60e5eb73e llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1e0173e)\r\n#20 0x00005ed60e5ec88d llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1e0288d)\r\n#21 0x00005ed60d4f3276 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0xd09276)\r\n#22 0x00005ed60f395141 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2bab141)\r\n#23 0x00005ed60d4eabd6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0xd00bd6)\r\n#24 0x00005ed60f393e3b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2ba9e3b)\r\n#25 0x00005ed60d4f2dc6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0xd08dc6)\r\n#26 0x00005ed60f391cb1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2ba7cb1)\r\n#27 0x00005ed60cd6cce5 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x582ce5)\r\n#28 0x00005ed60cd5f316 optMain (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x575316)\r\n#29 0x00007f973de29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#30 0x00007f973de29e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#31 0x00007f973de29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#32 0x00005ed60cd54f95 _start (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x56af95)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt\r\n```\r\nGodbolt: https://godbolt.org/z/jYWea8z4q\r\n\r\nFound via fuzzer.",
"author": "patrick-rivos",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true
|
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
|
911055e34f2b1530d9900e23873e300b77ea8d96
| null |
91178
|
https://github.com/llvm/llvm-project/issues/91178
|
miscompilation
|
7098cd215b95286794d9e0c822e8323ad0509750
| 2024-05-06T09:44:48
|
[
"llvm/test/Transforms/InstCombine",
"llvm/test/Transforms/PGOProfile"
] |
{
"fix_commit": "d085b42cbbefe79a41113abcd2b1e1f2a203acef",
"components": [
"InstructionSimplify"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": [
[
4312,
4317
]
],
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.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/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": [
"simplifyWithOpReplaced"
],
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.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/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null
}
}
|
commit d085b42cbbefe79a41113abcd2b1e1f2a203acef
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Wed May 8 10:04:09 2024 +0800
[InstSimplify] Do not simplify freeze in `simplifyWithOpReplaced` (#91215)
See the LangRef:
> All uses of a value returned by the same ‘freeze’ instruction are
guaranteed to always observe the same value, while different ‘freeze’
instructions may yield different values.
It is incorrect to replace freezes with the simplified value.
Proof:
https://alive2.llvm.org/ce/z/3Dn9Cd
https://alive2.llvm.org/ce/z/Qyh5h6
Fixes https://github.com/llvm/llvm-project/issues/91178
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 4061dae83c10..37a7259a5cd0 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -4312,6 +4312,10 @@ static Value *simplifyWithOpReplaced(Value *V, Value *Op, Value *RepOp,
if (match(I, m_Intrinsic<Intrinsic::is_constant>()))
return nullptr;
+ // Don't simplify freeze.
+ if (isa<FreezeInst>(I))
+ return nullptr;
+
// Replace Op with RepOp in instruction operands.
SmallVector<Value *, 8> NewOps;
bool AnyReplaced = false;
|
[
{
"file": "llvm/test/Transforms/InstCombine/icmp.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "icmp_freeze_sext",
"test_body": "target datalayout = \"e-p:64:64:64-p1:16:16:16-p2:32:32:32-p3:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64\"\n\ndefine i1 @icmp_freeze_sext(i16 %x, i16 %y) {\n %cmp1 = icmp uge i16 %x, %y\n %ext = sext i1 %cmp1 to i16\n %ext.fr = freeze i16 %ext\n %cmp2 = icmp uge i16 %ext.fr, %y\n ret i1 %cmp2\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
},
{
"file": "llvm/test/Transforms/InstCombine/select.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "test_replace_freeze_oneuse",
"test_body": "target datalayout = \"e-p:64:64-p1:16:16-p2:32:32:32-p3:64:64:64\"\n\ndefine i8 @test_replace_freeze_oneuse(i1 %x, i8 %y) {\n %ext = zext i1 %x to i8\n %shl = shl nuw i8 %ext, %y\n %shl.fr = freeze i8 %shl\n %sel = select i1 %x, i8 0, i8 %shl.fr\n ret i8 %sel\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "sequence_select_with_same_cond_extra_use",
"test_body": "target datalayout = \"e-p:64:64-p1:16:16-p2:32:32:32-p3:64:64:64\"\n\ndeclare void @use32(i32)\n\ndefine i32 @sequence_select_with_same_cond_extra_use(i1 %c1, i1 %c2) {\n %s1 = select i1 %c1, i32 23, i32 45\n call void @use32(i32 %s1)\n %s2 = select i1 %c2, i32 666, i32 %s1\n %s3 = select i1 %c1, i32 789, i32 %s2\n ret i32 %s3\n}\n",
"additional_args": null,
"lli_expected_out": null
},
{
"test_name": "test_replace_freeze_multiuse",
"test_body": "target datalayout = \"e-p:64:64-p1:16:16-p2:32:32:32-p3:64:64:64\"\n\ndefine i8 @test_replace_freeze_multiuse(i1 %x, i8 %y) {\n %ext = zext i1 %x to i8\n %shl = shl nuw i8 %ext, %y\n %shl.fr = freeze i8 %shl\n %sel = select i1 %x, i8 0, i8 %shl.fr\n %add = add i8 %shl.fr, %sel\n ret i8 %add\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[InstCombine] Miscompilation which simplifies a use of a multi-use freeze",
"body": "Reduced test case: https://alive2.llvm.org/ce/z/_JyUGw\r\n```\r\ndefine i8 @func78(i1 %0, i8 %1) {\r\n %3 = zext i1 %0 to i8\r\n %4 = shl i8 %3, %1\r\n %5 = freeze i8 %4\r\n %6 = select i1 %0, i8 0, i8 %5\r\n %7 = call i8 @llvm.fshr.i8(i8 0, i8 %5, i8 %6)\r\n ret i8 %7\r\n}\r\n```\r\n\r\n```\r\n----------------------------------------\r\ndefine i8 @func78(i1 %#0, i8 %#1) {\r\n#2:\r\n %#3 = zext i1 %#0 to i8\r\n %#4 = shl i8 %#3, %#1\r\n %#5 = freeze i8 %#4\r\n %#6 = select i1 %#0, i8 0, i8 %#5\r\n %#7 = fshr i8 0, i8 %#5, i8 %#6\r\n ret i8 %#7\r\n}\r\n=>\r\ndefine i8 @func78(i1 %#0, i8 %#1) nofree noundef willreturn memory(none) {\r\n#2:\r\n %#3 = zext i1 %#0 to i8\r\n %#4 = shl nuw i8 %#3, %#1\r\n %#5 = freeze i8 %#4\r\n ret i8 %#5\r\n}\r\nTransformation doesn't verify!\r\n\r\nERROR: Value mismatch\r\n\r\nExample:\r\ni1 %#0 = #x0 (0)\r\ni8 %#1 = #x08 (8)\r\n\r\nSource:\r\ni8 %#3 = #x00 (0)\r\ni8 %#4 = poison\r\ni8 %#5 = #x00 (0)\r\ni8 %#6 = #x00 (0)\r\ni8 %#7 = #x00 (0)\r\n\r\nTarget:\r\ni8 %#3 = #x00 (0)\r\ni8 %#4 = poison\r\ni8 %#5 = #x9d (157, -99)\r\nSource value: #x00 (0)\r\nTarget value: #x9d (157, -99)\r\n\r\nSummary:\r\n 0 correct transformations\r\n 1 incorrect transformations\r\n 0 failed-to-prove transformations\r\n 0 Alive2 errors\r\n```",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
0db5d8e12384d780d2ded6b972233dc8b1632560
| null |
88796
|
https://github.com/llvm/llvm-project/issues/88796
|
crash
|
9ef28cf88ca6e45c3ecb75c649463f8797db68d2
| 2024-04-15T21:04:00
|
[
"llvm/test/Transforms/VectorCombine"
] |
{
"fix_commit": "57b9c15227ec15a5e2abf4587d7d0ad536cff9e6",
"components": [
"VectorCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [
[
1961,
1977
]
],
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.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/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [
"VectorCombine::foldTruncFromReductions"
],
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.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/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null
}
}
|
commit 57b9c15227ec15a5e2abf4587d7d0ad536cff9e6
Author: Ramkumar Ramachandra <r@artagnon.com>
Date: Wed May 8 09:47:55 2024 +0100
VectorCombine: fix logical error after m_Trunc match (#91201)
The matcher m_Trunc() matches an Operator with a given Opcode, which
could either be an Instruction or ConstExpr.
VectorCombine::foldTruncFromReductions() incorrectly assumes that the
pattern matched is always an Instruction, and attempts a cast. Fix this.
Fixes #88796.
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index bbb70134870a..8573a8adf53b 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -1961,17 +1961,17 @@ bool VectorCombine::foldTruncFromReductions(Instruction &I) {
if (!match(ReductionSrc, m_OneUse(m_Trunc(m_Value(TruncSrc)))))
return false;
- auto *Trunc = cast<CastInst>(ReductionSrc);
auto *TruncSrcTy = cast<VectorType>(TruncSrc->getType());
auto *ReductionSrcTy = cast<VectorType>(ReductionSrc->getType());
Type *ResultTy = I.getType();
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
- InstructionCost OldCost =
- TTI.getCastInstrCost(Instruction::Trunc, ReductionSrcTy, TruncSrcTy,
- TTI::CastContextHint::None, CostKind, Trunc) +
- TTI.getArithmeticReductionCost(ReductionOpc, ReductionSrcTy, std::nullopt,
- CostKind);
+ InstructionCost OldCost = TTI.getArithmeticReductionCost(
+ ReductionOpc, ReductionSrcTy, std::nullopt, CostKind);
+ if (auto *Trunc = dyn_cast<CastInst>(ReductionSrc))
+ OldCost +=
+ TTI.getCastInstrCost(Instruction::Trunc, ReductionSrcTy, TruncSrcTy,
+ TTI::CastContextHint::None, CostKind, Trunc);
InstructionCost NewCost =
TTI.getArithmeticReductionCost(ReductionOpc, TruncSrcTy, std::nullopt,
CostKind) +
|
[
{
"file": "llvm/test/Transforms/VectorCombine/pr88796.ll",
"commands": [
"opt -passes=vector-combine -S %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define i32 @test() {\nentry:\n %0 = tail call i16 @llvm.vector.reduce.and.nxv8i16(<vscale x 8 x i16> trunc (<vscale x 8 x i32> splat (i32 268435456) to <vscale x 8 x i16>))\n ret i32 0\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i16 @llvm.vector.reduce.and.nxv8i16(<vscale x 8 x i16>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[VectorCombine] Assertion 'isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"' failed.",
"body": "Reduced LLVM IR:\r\n```llvm ir\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine i32 @main() #0 {\r\nentry:\r\n %0 = tail call i16 @llvm.vector.reduce.and.nxv8i16(<vscale x 8 x i16> trunc (<vscale x 8 x i32> shufflevector (<vscale x 8 x i32> insertelement (<vscale x 8 x i32> poison, i32 268435456, i64 0), <vscale x 8 x i32> poison, <vscale x 8 x i32> zeroinitializer) to <vscale x 8 x i16>))\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.vector.reduce.and.nxv8i16(<vscale x 8 x i16>) #1\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl256b,+zvl32b,+zvl64b,-e,-experimental-smmpm,-experimental-smnpm,-experimental-ssnpm,-experimental-sspm,-experimental-ssqosid,-experimental-supm,-experimental-zaamo,-experimental-zabha,-experimental-zalasr,-experimental-zalrsc,-experimental-zfbfmin,-experimental-zicfilp,-experimental-zicfiss,-experimental-ztso,-experimental-zvfbfmin,-experimental-zvfbfwma,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smepmp,-ssaia,-ssccptr,-sscofpmf,-sscounterenw,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-za128rs,-za64rs,-zacas,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-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,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\nattributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\r\n```\r\nGodbolt: https://godbolt.org/z/jrEv178Ev\r\n\r\nBacktrace:\r\n```\r\nopt: /scratch/tc-testing/tc-apr-15/llvm/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From*) [with To = llvm::CastInst; 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.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/opt --passes=vector-combine reduced.ll\r\n #0 0x00005eb857c5a1b0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/opt+0x2da91b0)\r\n #1 0x00005eb857c575bf llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/opt+0x2da65bf)\r\n #2 0x00005eb857c57715 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x000071f7d0e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x000071f7d0e969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x000071f7d0e969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x000071f7d0e969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x000071f7d0e42476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x000071f7d0e287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x000071f7d0e2871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x000071f7d0e39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x00005eb856da36eb (anonymous namespace)::VectorCombine::run()::'lambda'(llvm::Instruction&)::operator()(llvm::Instruction&) const VectorCombine.cpp:0:0\r\n#12 0x00005eb856da4290 llvm::VectorCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/opt+0x1ef3290)\r\n#13 0x00005eb855bc7936 llvm::detail::PassModel<llvm::Function, llvm::VectorCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/opt+0xd16936)\r\n#14 0x00005eb857a7f451 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/opt+0x2bce451)\r\n#15 0x00005eb855bbec26 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/opt+0xd0dc26)\r\n#16 0x00005eb857a7e12b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/opt+0x2bcd12b)\r\n#17 0x00005eb855bc6ee6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/opt+0xd15ee6)\r\n#18 0x00005eb857a7bf61 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/opt+0x2bcaf61)\r\n#19 0x00005eb855440205 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/opt+0x58f205)\r\n#20 0x00005eb855432836 optMain (/scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/opt+0x581836)\r\n#21 0x000071f7d0e29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#22 0x000071f7d0e29e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#23 0x000071f7d0e29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#24 0x00005eb8554284b5 _start (/scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/opt+0x5774b5)\r\nzsh: IOT instruction /scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/op\r\n```\r\n\r\nFound via fuzzer.",
"author": "patrick-rivos",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
769c22f25b81b74e4da7871d4e552584605caef1
| null |
164164
|
https://github.com/llvm/llvm-project/issues/164164
|
crash
|
b9ce7656e93a8cd54b2e9f44d8bae49c55a76a4b
| 2025-10-19T14:11:35
|
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "e6b0be376412bf0599f6e75aa5e67f95cd36b411",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
5343,
5349
]
],
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.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/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"areAllOperandsReplacedByCopyableData"
],
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.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/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null
}
}
|
commit e6b0be376412bf0599f6e75aa5e67f95cd36b411
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Sun Oct 19 11:29:14 2025 -0700
[SLP]Correctly calculate number of copyable operands
The compiler shall not check for overflow of the number of copyable
operands counter, otherwise non-copyable operand can be counted as
copyable and lead to a compiler crash.
Fixes #164164
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 9cd52da1ce1c..048a3e691fe5 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -5343,7 +5343,7 @@ private:
unsigned &OpCnt =
OrderedEntriesCount.try_emplace(TE, 0).first->getSecond();
EdgeInfo EI(TE, U.getOperandNo());
- if (!getScheduleCopyableData(EI, Op) && OpCnt < NumOps)
+ if (!getScheduleCopyableData(EI, Op))
continue;
// Found copyable operand - continue.
++OpCnt;
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/num-uses-for-copyable-elements.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-apple-macosx15.0.0 -mcpu=skylake-avx512 -S < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @test(ptr %output) {\n;\nentry:\n %arrayidx.2.i = getelementptr i8, ptr %output, i64 8\n %0 = load i32, ptr %output, align 4\n %arrayidx.3.i = getelementptr i8, ptr %output, i64 12\n %1 = load i32, ptr %arrayidx.3.i, align 4\n %xor7 = xor i32 -1, %0\n %or.i = tail call i32 @llvm.fshl.i32(i32 %xor7, i32 0, i32 2)\n %or.i11 = tail call i32 @llvm.fshl.i32(i32 %1, i32 %1, i32 2)\n store i32 %or.i, ptr %arrayidx.2.i, align 4\n store i32 %or.i11, ptr %arrayidx.3.i, align 4\n ret void\n}\n\ndeclare i32 @llvm.fshl.i32(i32, i32, i32)",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[SLP] Assertion `all_of(Bundles, [](const ScheduleBundle *Bundle) { return Bundle->isScheduled(); }) && \"must be scheduled at this point\"' failed.",
"body": "The following input triggers an assertion with `-p slp-vectorizer` on current `main`:\nhttps://llvm.godbolt.org/z/xsTTooc64\n\n```\ntarget 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-macosx15.0.0\"\n\ndefine void @crash(ptr %output) #0 {\nentry:\n %arrayidx.2.i = getelementptr i8, ptr %output, i64 8\n %0 = load i32, ptr %output, align 4\n %arrayidx.3.i = getelementptr i8, ptr %output, i64 12\n %1 = load i32, ptr %arrayidx.3.i, align 4\n %xor7 = xor i32 -1, %0\n %or.i = tail call i32 @llvm.fshl.i32(i32 %xor7, i32 0, i32 2)\n %or.i11 = tail call i32 @llvm.fshl.i32(i32 %1, i32 %1, i32 2)\n store i32 %or.i, ptr %arrayidx.2.i, align 4\n store i32 %or.i11, ptr %arrayidx.3.i, align 4\n ret void\n}\n\ndeclare i32 @llvm.fshl.i32(i32, i32, i32) #1\n\nattributes #0 = { \"target-cpu\"=\"skylake-avx512\" }\n``",
"author": "fhahn",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid"
],
"comments": [
{
"author": "fhahn",
"body": "cc @alexey-bataev "
}
]
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
739bfdeb91f409ef326cc407be01b935a58f2d3c
| null |
113143
|
https://github.com/llvm/llvm-project/issues/113143
|
crash
|
42ba452aa94e4da277842d8990ad958a6256e558
| 2024-10-21T10:11:54
|
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "9e03920cbf946e7ba282e99213707643a23ae5fb",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
12466,
12472
]
],
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.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/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::isGatherShuffledSingleRegisterEntry"
],
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.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/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null
}
}
|
commit 9e03920cbf946e7ba282e99213707643a23ae5fb
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Mon Oct 21 08:57:36 2024 -0700
[SLP]Ignore root gather node, when searching for reuses
Root gather/buildvector node should be ignored when SLP vectorizer tries
to find matching gather nodes, vectorized earlier. This node is
definitely the last one in the pipeline and it does not have users. It
may cause the compiler crash
Fixes #113143
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 1098bf578d2d..a11e3f3815cb 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -12466,7 +12466,7 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
// Build a list of tree entries where V is used.
SmallPtrSet<const TreeEntry *, 4> VToTEs;
for (const TreeEntry *TEPtr : ValueToGatherNodes.find(V)->second) {
- if (TEPtr == TE)
+ if (TEPtr == TE || TEPtr->Idx == 0)
continue;
assert(any_of(TEPtr->Scalars,
[&](Value *V) { return GatheredScalars.contains(V); }) &&
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/root-gather-reused-scalar.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define void @test(ptr %a, i32 %0, i32 %1, i1 %cmp1) {\nentry:\n %2 = load i32, ptr %a, align 4\n %tobool10.not = icmp eq i32 %0, 0\n %cmp4.3 = icmp ne i32 %1, 0\n %3 = and i1 %cmp4.3, %tobool10.not\n %cmp2.2 = xor i1 %tobool10.not, true\n %conv3.2 = zext i1 %cmp2.2 to i32\n %cmp4.2 = icmp ne i32 %2, %conv3.2\n %cmp2.1 = xor i1 %cmp1, true\n %conv3.1 = zext i1 %cmp2.1 to i32\n %cmp4.1 = icmp ne i32 %2, %conv3.1\n %4 = select i1 %3, i1 %cmp4.2, i1 false\n %5 = select i1 %4, i1 %cmp4.1, i1 false\n %and.3 = zext i1 %5 to i32\n store i32 %and.3, ptr %a, align 4\n ret void\n}\n",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "clang crashes on valid code at -O2 on x86_64-linux-gnu: Assertion `TEPtr->UserTreeIndices.size() == 1 && \"Expected only single user of a gather node.\"' failed ",
"body": "It appears to be a recent regression as it doesn't reproduce with 19.1.0 and earlier. \r\n\r\nCompiler Explorer: https://godbolt.org/z/a1W3c5ard\r\n\r\n```\r\n[523] % clangtk -v\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git df8b785838a2db01b4d056e603f7317209accefb)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\r\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nCandidate multilib: .;@m64\r\nSelected multilib: .;@m64\r\n[524] % \r\n[524] % clangtk -O2 small.c\r\nclang-20: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:12559: std::optional<llvm::TargetTransformInfo::ShuffleKind> llvm::slpvectorizer::BoUpSLP::isGatherShuffledSingleRegisterEntry(const llvm::slpvectorizer::BoUpSLP::TreeEntry*, llvm::ArrayRef<llvm::Value*>, llvm::MutableArrayRef<int>, llvm::SmallVectorImpl<const llvm::slpvectorizer::BoUpSLP::TreeEntry*>&, unsigned int, bool): Assertion `TEPtr->UserTreeIndices.size() == 1 && \"Expected only single user of a gather node.\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/20241020-clangtk-m64-O2-build-231331/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20241020-clangtk-m64-O2-build-231331/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/20 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-572b89.o -x c small.c\r\n1.\t<eof> parser at end of file\r\n2.\tOptimizer\r\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"small.c\"\r\n4.\tRunning pass \"slp-vectorizer\" on function \"main\"\r\n #0 0x0000560576c8b9af llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x43f29af)\r\n #1 0x0000560576c89184 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007f4623c27420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #3 0x00007f462365e00b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #4 0x00007f462363d859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\r\n #5 0x00007f462363d729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #6 0x00007f462363d729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #7 0x00007f462364efd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #8 0x0000560578707edc llvm::slpvectorizer::BoUpSLP::isGatherShuffledSingleRegisterEntry(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::MutableArrayRef<int>, llvm::SmallVectorImpl<llvm::slpvectorizer::BoUpSLP::TreeEntry const*>&, unsigned int, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5e6eedc)\r\n #9 0x0000560578708cd8 llvm::slpvectorizer::BoUpSLP::isGatherShuffledEntry(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallVectorImpl<int>&, llvm::SmallVectorImpl<llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, 6u>>&, unsigned int, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5e6fcd8)\r\n#10 0x000056057870a6f3 llvm::InstructionCost llvm::slpvectorizer::BoUpSLP::processBuildVector<llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator, llvm::InstructionCost, llvm::TargetTransformInfo, llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP, llvm::SmallPtrSetImpl<llvm::Value*>>(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::Type*, llvm::TargetTransformInfo&, llvm::ArrayRef<llvm::Value*>&, llvm::slpvectorizer::BoUpSLP&, llvm::SmallPtrSetImpl<llvm::Value*>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5e716f3)\r\n#11 0x000056057870cde7 llvm::slpvectorizer::BoUpSLP::getEntryCost(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallPtrSetImpl<llvm::Value*>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5e73de7)\r\n#12 0x0000560578745f69 llvm::slpvectorizer::BoUpSLP::getTreeCost(llvm::ArrayRef<llvm::Value*>) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5eacf69)\r\n#13 0x000056057874b57b (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&) SLPVectorizer.cpp:0:0\r\n#14 0x000056057874eb79 llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5eb5b79)\r\n#15 0x000056057875349b llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (.constprop.0) SLPVectorizer.cpp:0:0\r\n#16 0x0000560578757d50 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5ebed50)\r\n#17 0x000056057875e590 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\r\n#18 0x000056057875f263 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5ec6263)\r\n#19 0x00005605781e0e66 llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5947e66)\r\n#20 0x0000560576614891 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3d7b891)\r\n#21 0x000056057410e656 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x1875656)\r\n#22 0x00005605766131fd llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3d7a1fd)\r\n#23 0x000056057410d196 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x1874196)\r\n#24 0x0000560576612c31 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3d79c31)\r\n#25 0x0000560576f44dd3 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#26 0x0000560576f483a8 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x46af3a8)\r\n#27 0x000056057764462c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4dab62c)\r\n#28 0x000056057951629c clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x6c7d29c)\r\n#29 0x0000560577644a48 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4daba48)\r\n#30 0x000056057790d3d9 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x50743d9)\r\n#31 0x00005605778895ce clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4ff05ce)\r\n#32 0x00005605779f9f26 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5160f26)\r\n#33 0x0000560573cd1fe5 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x1438fe5)\r\n#34 0x0000560573cc9afa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#35 0x0000560573cce52e clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x143552e)\r\n#36 0x0000560573bba67b main (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x132167b)\r\n#37 0x00007f462363f083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#38 0x0000560573cc958e _start (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x143058e)\r\nclangtk: error: unable to execute command: Aborted\r\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git df8b785838a2db01b4d056e603f7317209accefb)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nclangtk: note: diagnostic msg: \r\n********************\r\n\r\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\r\nPreprocessed source(s) and associated run script(s) are located at:\r\nclangtk: note: diagnostic msg: /tmp/small-d99d4e.c\r\nclangtk: note: diagnostic msg: /tmp/small-d99d4e.sh\r\nclangtk: note: diagnostic msg: \r\n\r\n********************\r\n[525] % \r\n[525] % cat small.c\r\nint a, b, c, d, e, f;\r\nint main() {\r\n for (f = 0; f < 4; f++) {\r\n d &= (((a > 0) != b) != c) && b;\r\n for (b = 0; b < 1; b++)\r\n if (e)\r\n break;\r\n }\r\n return 0;\r\n}\r\n```\r\n\r\n",
"author": "zhendongsu",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
f9bc00e4bb6e09a9f8e4add8e3988cb44b193cdb
| null |
158319
|
https://github.com/llvm/llvm-project/issues/158319
|
crash
|
111de45e838a7d33637da8807212284c988f7fae
| 2025-09-12T16:14:59
|
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "ef7e03a2d1571e3c651fa9ccd205dbacf1a103c8",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
[
1272,
1280
]
],
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.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/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
"simplifyRecipe"
],
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Analysis/DependenceAnalysis.cpp": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.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/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/LoopInterchange.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Utils/BasicBlockUtils.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null
}
}
|
commit ef7e03a2d1571e3c651fa9ccd205dbacf1a103c8
Author: Florian Hahn <flo@fhahn.com>
Date: Sat Sep 13 18:13:22 2025 +0100
[VPlan] Limit ExtractLastElem fold to recipes guaranteed single-scalar.
vputils::isSingleScalar(A) may return true to recipes that produce only
a single scalar value, but they could still end up as vector
instruction, because the recipe could not be converted to a
single-scalar VPInstruction/VPReplicateRecipe.
For now, only apply the fold for recipes guaranteed to produce a single
value, i.e. single-scalar VPInstructions and VPReplicateRecipes.
Fixes https://github.com/llvm/llvm-project/issues/158319.
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index fcd85ba9ab7f..a193c438e7ea 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -1272,9 +1272,11 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
if (match(Def,
m_VPInstruction<VPInstruction::ExtractLastElement>(m_VPValue(A))) &&
- vputils::isSingleScalar(A) && all_of(A->users(), [Def, A](VPUser *U) {
- return U->usesScalars(A) || Def == U;
- })) {
+ ((isa<VPInstruction>(A) && vputils::isSingleScalar(A)) ||
+ (isa<VPReplicateRecipe>(A) &&
+ cast<VPReplicateRecipe>(A)->isSingleScalar())) &&
+ all_of(A->users(),
+ [Def, A](VPUser *U) { return U->usesScalars(A) || Def == U; })) {
return Def->replaceAllUsesWith(A);
}
}
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/first-order-recurrence-with-uniform-ops.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=2 -S %s",
"opt -passes=loop-vectorize -force-vector-width=1 -force-vector-interleave=2 -S %s",
"opt -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -S %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n; Test case for https://github.com/llvm/llvm-project/issues/95520.\ndefine i32 @recurence_uniform_load(ptr %src, ptr noalias %dst, i64 %n) {\n; UNROLL-NO-IC-LABEL: define i32 @recurence_uniform_load(\n; UNROLL-NO-IC-SAME: ptr [[SRC:%.*]], ptr noalias [[DST:%.*]], i64 [[N:%.*]]) {\n; UNROLL-NO-IC-NEXT: [[ENTRY:.*]]:\n; UNROLL-NO-IC-NEXT: [[TMP0:%.*]] = add i64 [[N]], 1\n; UNROLL-NO-IC-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[TMP0]], 8\n; UNROLL-NO-IC-NEXT: br i1 [[MIN_ITERS_CHECK]], label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]\n; UNROLL-NO-IC: [[VECTOR_PH]]:\n; UNROLL-NO-IC-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[TMP0]], 8\n; UNROLL-NO-IC-NEXT: [[N_VEC:%.*]] = sub i64 [[TMP0]], [[N_MOD_VF]]\n; UNROLL-NO-IC-NEXT: br label %[[VECTOR_BODY:.*]]\n; UNROLL-NO-IC: [[VECTOR_BODY]]:\n; UNROLL-NO-IC-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]\n; UNROLL-NO-IC-NEXT: [[TMP1:%.*]] = load i32, ptr [[SRC]], align 4\n; UNROLL-NO-IC-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 8\n; UNROLL-NO-IC-NEXT: [[TMP2:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]\n; UNROLL-NO-IC-NEXT: br i1 [[TMP2]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]\n; UNROLL-NO-IC: [[MIDDLE_BLOCK]]:\n; UNROLL-NO-IC-NEXT: [[CMP_N:%.*]] = icmp eq i64 [[TMP0]], [[N_VEC]]\n; UNROLL-NO-IC-NEXT: br i1 [[CMP_N]], label %[[EXIT:.*]], label %[[SCALAR_PH]]\n; UNROLL-NO-IC: [[SCALAR_PH]]:\n; UNROLL-NO-IC-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]\n; UNROLL-NO-IC-NEXT: [[SCALAR_RECUR_INIT:%.*]] = phi i32 [ [[TMP1]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]\n; UNROLL-NO-IC-NEXT: br label %[[LOOP:.*]]\n; UNROLL-NO-IC: [[LOOP]]:\n; UNROLL-NO-IC-NEXT: [[PHI:%.*]] = phi i64 [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], [ [[ADD:%.*]], %[[LOOP]] ]\n; UNROLL-NO-IC-NEXT: [[RECUR:%.*]] = phi i32 [ [[SCALAR_RECUR_INIT]], %[[SCALAR_PH]] ], [ [[LOAD:%.*]], %[[LOOP]] ]\n; UNROLL-NO-IC-NEXT: [[ADD]] = add i64 [[PHI]], 1\n; UNROLL-NO-IC-NEXT: [[LOAD]] = load i32, ptr [[SRC]], align 4\n; UNROLL-NO-IC-NEXT: [[ICMP:%.*]] = icmp ult i64 [[PHI]], [[N]]\n; UNROLL-NO-IC-NEXT: br i1 [[ICMP]], label %[[LOOP]], label %[[EXIT]], !llvm.loop [[LOOP3:![0-9]+]]\n; UNROLL-NO-IC: [[EXIT]]:\n; UNROLL-NO-IC-NEXT: [[RECUR_LCSSA:%.*]] = phi i32 [ [[RECUR]], %[[LOOP]] ], [ [[TMP1]], %[[MIDDLE_BLOCK]] ]\n; UNROLL-NO-IC-NEXT: ret i32 [[RECUR_LCSSA]]\n;\n; UNROLL-NO-VF-LABEL: define i32 @recurence_uniform_load(\n; UNROLL-NO-VF-SAME: ptr [[SRC:%.*]], ptr noalias [[DST:%.*]], i64 [[N:%.*]]) {\n; UNROLL-NO-VF-NEXT: [[ENTRY:.*]]:\n; UNROLL-NO-VF-NEXT: [[TMP1:%.*]] = add i64 [[N]], 1\n; UNROLL-NO-VF-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[TMP1]], 2\n; UNROLL-NO-VF-NEXT: br i1 [[MIN_ITERS_CHECK]], label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]\n; UNROLL-NO-VF: [[VECTOR_PH]]:\n; UNROLL-NO-VF-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[TMP1]], 2\n; UNROLL-NO-VF-NEXT: [[N_VEC:%.*]] = sub i64 [[TMP1]], [[N_MOD_VF]]\n; UNROLL-NO-VF-NEXT: br label %[[VECTOR_BODY:.*]]\n; UNROLL-NO-VF: [[VECTOR_BODY]]:\n; UNROLL-NO-VF-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]\n; UNROLL-NO-VF-NEXT: [[TMP0:%.*]] = load i32, ptr [[SRC]], align 4\n; UNROLL-NO-VF-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 2\n; UNROLL-NO-VF-NEXT: [[TMP2:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]\n; UNROLL-NO-VF-NEXT: br i1 [[TMP2]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]\n; UNROLL-NO-VF: [[MIDDLE_BLOCK]]:\n; UNROLL-NO-VF-NEXT: [[CMP_N:%.*]] = icmp eq i64 [[TMP1]], [[N_VEC]]\n; UNROLL-NO-VF-NEXT: br i1 [[CMP_N]], label %[[EXIT:.*]], label %[[SCALAR_PH]]\n; UNROLL-NO-VF: [[SCALAR_PH]]:\n; UNROLL-NO-VF-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]\n; UNROLL-NO-VF-NEXT: [[SCALAR_RECUR_INIT:%.*]] = phi i32 [ [[TMP0]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]\n; UNROLL-NO-VF-NEXT: br label %[[LOOP:.*]]\n; UNROLL-NO-VF: [[LOOP]]:\n; UNROLL-NO-VF-NEXT: [[PHI:%.*]] = phi i64 [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], [ [[ADD:%.*]], %[[LOOP]] ]\n; UNROLL-NO-VF-NEXT: [[RECUR:%.*]] = phi i32 [ [[SCALAR_RECUR_INIT]], %[[SCALAR_PH]] ], [ [[LOAD:%.*]], %[[LOOP]] ]\n; UNROLL-NO-VF-NEXT: [[ADD]] = add i64 [[PHI]], 1\n; UNROLL-NO-VF-NEXT: [[LOAD]] = load i32, ptr [[SRC]], align 4\n; UNROLL-NO-VF-NEXT: [[ICMP:%.*]] = icmp ult i64 [[PHI]], [[N]]\n; UNROLL-NO-VF-NEXT: br i1 [[ICMP]], label %[[LOOP]], label %[[EXIT]], !llvm.loop [[LOOP3:![0-9]+]]\n; UNROLL-NO-VF: [[EXIT]]:\n; UNROLL-NO-VF-NEXT: [[RECUR_LCSSA:%.*]] = phi i32 [ [[RECUR]], %[[LOOP]] ], [ [[TMP0]], %[[MIDDLE_BLOCK]] ]\n; UNROLL-NO-VF-NEXT: ret i32 [[RECUR_LCSSA]]\n;\n; SINK-AFTER-LABEL: define i32 @recurence_uniform_load(\n; SINK-AFTER-SAME: ptr [[SRC:%.*]], ptr noalias [[DST:%.*]], i64 [[N:%.*]]) {\n; SINK-AFTER-NEXT: [[ENTRY:.*]]:\n; SINK-AFTER-NEXT: [[TMP0:%.*]] = add i64 [[N]], 1\n; SINK-AFTER-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[TMP0]], 4\n; SINK-AFTER-NEXT: br i1 [[MIN_ITERS_CHECK]], label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]\n; SINK-AFTER: [[VECTOR_PH]]:\n; SINK-AFTER-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[TMP0]], 4\n; SINK-AFTER-NEXT: [[N_VEC:%.*]] = sub i64 [[TMP0]], [[N_MOD_VF]]\n; SINK-AFTER-NEXT: br label %[[VECTOR_BODY:.*]]\n; SINK-AFTER: [[VECTOR_BODY]]:\n; SINK-AFTER-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]\n; SINK-AFTER-NEXT: [[TMP1:%.*]] = load i32, ptr [[SRC]], align 4\n; SINK-AFTER-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4\n; SINK-AFTER-NEXT: [[TMP2:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]\n; SINK-AFTER-NEXT: br i1 [[TMP2]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]\n; SINK-AFTER: [[MIDDLE_BLOCK]]:\n; SINK-AFTER-NEXT: [[CMP_N:%.*]] = icmp eq i64 [[TMP0]], [[N_VEC]]\n; SINK-AFTER-NEXT: br i1 [[CMP_N]], label %[[EXIT:.*]], label %[[SCALAR_PH]]\n; SINK-AFTER: [[SCALAR_PH]]:\n; SINK-AFTER-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]\n; SINK-AFTER-NEXT: [[SCALAR_RECUR_INIT:%.*]] = phi i32 [ [[TMP1]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]\n; SINK-AFTER-NEXT: br label %[[LOOP:.*]]\n; SINK-AFTER: [[LOOP]]:\n; SINK-AFTER-NEXT: [[PHI:%.*]] = phi i64 [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], [ [[ADD:%.*]], %[[LOOP]] ]\n; SINK-AFTER-NEXT: [[RECUR:%.*]] = phi i32 [ [[SCALAR_RECUR_INIT]], %[[SCALAR_PH]] ], [ [[LOAD:%.*]], %[[LOOP]] ]\n; SINK-AFTER-NEXT: [[ADD]] = add i64 [[PHI]], 1\n; SINK-AFTER-NEXT: [[LOAD]] = load i32, ptr [[SRC]], align 4\n; SINK-AFTER-NEXT: [[ICMP:%.*]] = icmp ult i64 [[PHI]], [[N]]\n; SINK-AFTER-NEXT: br i1 [[ICMP]], label %[[LOOP]], label %[[EXIT]], !llvm.loop [[LOOP3:![0-9]+]]\n; SINK-AFTER: [[EXIT]]:\n; SINK-AFTER-NEXT: [[RECUR_LCSSA:%.*]] = phi i32 [ [[RECUR]], %[[LOOP]] ], [ [[TMP1]], %[[MIDDLE_BLOCK]] ]\n; SINK-AFTER-NEXT: ret i32 [[RECUR_LCSSA]]\n;\nentry:\n br label %loop\n\nloop:\n %phi = phi i64 [ 0, %entry ], [ %add, %loop ]\n %recur = phi i32 [ 0, %entry ], [ %load, %loop ]\n %add = add i64 %phi, 1\n %load = load i32, ptr %src, align 4\n %icmp = icmp ult i64 %phi, %n\n br i1 %icmp, label %loop, label %exit\n\nexit:\n ret i32 %recur\n}\n\n; Test for https://github.com/llvm/llvm-project/issues/158319. The recurrence\n; phi can be removed.\ndefine i16 @for_phi_removed(ptr %src) {\n; UNROLL-NO-IC-LABEL: define i16 @for_phi_removed(\n; UNROLL-NO-IC-SAME: ptr [[SRC:%.*]]) {\n; UNROLL-NO-IC-NEXT: [[ENTRY:.*]]:\n; UNROLL-NO-IC-NEXT: br i1 false, label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]\n; UNROLL-NO-IC: [[VECTOR_PH]]:\n; UNROLL-NO-IC-NEXT: br label %[[VECTOR_BODY:.*]]\n; UNROLL-NO-IC: [[VECTOR_BODY]]:\n; UNROLL-NO-IC-NEXT: [[INDEX:%.*]] = phi i32 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]\n; UNROLL-NO-IC-NEXT: [[TMP0:%.*]] = load i32, ptr [[SRC]], align 4\n; UNROLL-NO-IC-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <4 x i32> poison, i32 [[TMP0]], i64 0\n; UNROLL-NO-IC-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <4 x i32> [[BROADCAST_SPLATINSERT]], <4 x i32> poison, <4 x i32> zeroinitializer\n; UNROLL-NO-IC-NEXT: [[TMP1:%.*]] = icmp eq <4 x i32> [[BROADCAST_SPLAT]], zeroinitializer\n; UNROLL-NO-IC-NEXT: [[TMP2:%.*]] = select <4 x i1> [[TMP1]], <4 x i16> splat (i16 1), <4 x i16> zeroinitializer\n; UNROLL-NO-IC-NEXT: [[INDEX_NEXT]] = add nuw i32 [[INDEX]], 8\n; UNROLL-NO-IC-NEXT: [[TMP3:%.*]] = icmp eq i32 [[INDEX_NEXT]], 104\n; UNROLL-NO-IC-NEXT: br i1 [[TMP3]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP4:![0-9]+]]\n; UNROLL-NO-IC: [[MIDDLE_BLOCK]]:\n; UNROLL-NO-IC-NEXT: [[VECTOR_RECUR_EXTRACT:%.*]] = extractelement <4 x i16> [[TMP2]], i32 3\n; UNROLL-NO-IC-NEXT: br label %[[SCALAR_PH]]\n; UNROLL-NO-IC: [[SCALAR_PH]]:\n; UNROLL-NO-IC-NEXT: [[BC_RESUME_VAL:%.*]] = phi i16 [ 104, %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]\n; UNROLL-NO-IC-NEXT: [[SCALAR_RECUR_INIT:%.*]] = phi i16 [ [[VECTOR_RECUR_EXTRACT]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]\n; UNROLL-NO-IC-NEXT: br label %[[LOOP:.*]]\n; UNROLL-NO-IC: [[LOOP]]:\n; UNROLL-NO-IC-NEXT: [[IV:%.*]] = phi i16 [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], %[[LOOP]] ]\n; UNROLL-NO-IC-NEXT: [[P:%.*]] = phi i16 [ [[SCALAR_RECUR_INIT]], %[[SCALAR_PH]] ], [ [[SEL:%.*]], %[[LOOP]] ]\n; UNROLL-NO-IC-NEXT: [[L:%.*]] = load i32, ptr [[SRC]], align 4\n; UNROLL-NO-IC-NEXT: [[C:%.*]] = icmp eq i32 [[L]], 0\n; UNROLL-NO-IC-NEXT: [[SEL]] = select i1 [[C]], i16 1, i16 0\n; UNROLL-NO-IC-NEXT: [[IV_NEXT]] = add i16 [[IV]], 1\n; UNROLL-NO-IC-NEXT: [[EC:%.*]] = icmp eq i16 [[IV_NEXT]], 111\n; UNROLL-NO-IC-NEXT: br i1 [[EC]], label %[[EXIT:.*]], label %[[LOOP]], !llvm.loop [[LOOP5:![0-9]+]]\n; UNROLL-NO-IC: [[EXIT]]:\n; UNROLL-NO-IC-NEXT: [[P_LCSSA:%.*]] = phi i16 [ [[P]], %[[LOOP]] ]\n; UNROLL-NO-IC-NEXT: ret i16 [[P_LCSSA]]\n;\n; UNROLL-NO-VF-LABEL: define i16 @for_phi_removed(\n; UNROLL-NO-VF-SAME: ptr [[SRC:%.*]]) {\n; UNROLL-NO-VF-NEXT: [[ENTRY:.*]]:\n; UNROLL-NO-VF-NEXT: br i1 false, label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]\n; UNROLL-NO-VF: [[VECTOR_PH]]:\n; UNROLL-NO-VF-NEXT: br label %[[VECTOR_BODY:.*]]\n; UNROLL-NO-VF: [[VECTOR_BODY]]:\n; UNROLL-NO-VF-NEXT: [[INDEX:%.*]] = phi i32 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]\n; UNROLL-NO-VF-NEXT: [[TMP0:%.*]] = load i32, ptr [[SRC]], align 4\n; UNROLL-NO-VF-NEXT: [[TMP1:%.*]] = icmp eq i32 [[TMP0]], 0\n; UNROLL-NO-VF-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i16 1, i16 0\n; UNROLL-NO-VF-NEXT: [[INDEX_NEXT]] = add nuw i32 [[INDEX]], 2\n; UNROLL-NO-VF-NEXT: [[TMP3:%.*]] = icmp eq i32 [[INDEX_NEXT]], 110\n; UNROLL-NO-VF-NEXT: br i1 [[TMP3]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP4:![0-9]+]]\n; UNROLL-NO-VF: [[MIDDLE_BLOCK]]:\n; UNROLL-NO-VF-NEXT: br label %[[SCALAR_PH]]\n; UNROLL-NO-VF: [[SCALAR_PH]]:\n; UNROLL-NO-VF-NEXT: [[BC_RESUME_VAL:%.*]] = phi i16 [ 110, %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]\n; UNROLL-NO-VF-NEXT: [[SCALAR_RECUR_INIT:%.*]] = phi i16 [ [[TMP2]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]\n; UNROLL-NO-VF-NEXT: br label %[[LOOP:.*]]\n; UNROLL-NO-VF: [[LOOP]]:\n; UNROLL-NO-VF-NEXT: [[IV:%.*]] = phi i16 [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], %[[LOOP]] ]\n; UNROLL-NO-VF-NEXT: [[P:%.*]] = phi i16 [ [[SCALAR_RECUR_INIT]], %[[SCALAR_PH]] ], [ [[SEL:%.*]], %[[LOOP]] ]\n; UNROLL-NO-VF-NEXT: [[L:%.*]] = load i32, ptr [[SRC]], align 4\n; UNROLL-NO-VF-NEXT: [[C:%.*]] = icmp eq i32 [[L]], 0\n; UNROLL-NO-VF-NEXT: [[SEL]] = select i1 [[C]], i16 1, i16 0\n; UNROLL-NO-VF-NEXT: [[IV_NEXT]] = add i16 [[IV]], 1\n; UNROLL-NO-VF-NEXT: [[EC:%.*]] = icmp eq i16 [[IV_NEXT]], 111\n; UNROLL-NO-VF-NEXT: br i1 [[EC]], label %[[EXIT:.*]], label %[[LOOP]], !llvm.loop [[LOOP5:![0-9]+]]\n; UNROLL-NO-VF: [[EXIT]]:\n; UNROLL-NO-VF-NEXT: [[P_LCSSA:%.*]] = phi i16 [ [[P]], %[[LOOP]] ]\n; UNROLL-NO-VF-NEXT: ret i16 [[P_LCSSA]]\n;\n; SINK-AFTER-LABEL: define i16 @for_phi_removed(\n; SINK-AFTER-SAME: ptr [[SRC:%.*]]) {\n; SINK-AFTER-NEXT: [[ENTRY:.*]]:\n; SINK-AFTER-NEXT: br i1 false, label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]\n; SINK-AFTER: [[VECTOR_PH]]:\n; SINK-AFTER-NEXT: br label %[[VECTOR_BODY:.*]]\n; SINK-AFTER: [[VECTOR_BODY]]:\n; SINK-AFTER-NEXT: [[INDEX:%.*]] = phi i32 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]\n; SINK-AFTER-NEXT: [[TMP0:%.*]] = load i32, ptr [[SRC]], align 4\n; SINK-AFTER-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <4 x i32> poison, i32 [[TMP0]], i64 0\n; SINK-AFTER-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <4 x i32> [[BROADCAST_SPLATINSERT]], <4 x i32> poison, <4 x i32> zeroinitializer\n; SINK-AFTER-NEXT: [[TMP1:%.*]] = icmp eq <4 x i32> [[BROADCAST_SPLAT]], zeroinitializer\n; SINK-AFTER-NEXT: [[TMP2:%.*]] = select <4 x i1> [[TMP1]], <4 x i16> splat (i16 1), <4 x i16> zeroinitializer\n; SINK-AFTER-NEXT: [[INDEX_NEXT]] = add nuw i32 [[INDEX]], 4\n; SINK-AFTER-NEXT: [[TMP3:%.*]] = icmp eq i32 [[INDEX_NEXT]], 108\n; SINK-AFTER-NEXT: br i1 [[TMP3]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP4:![0-9]+]]\n; SINK-AFTER: [[MIDDLE_BLOCK]]:\n; SINK-AFTER-NEXT: [[VECTOR_RECUR_EXTRACT:%.*]] = extractelement <4 x i16> [[TMP2]], i32 3\n; SINK-AFTER-NEXT: br label %[[SCALAR_PH]]\n; SINK-AFTER: [[SCALAR_PH]]:\n; SINK-AFTER-NEXT: [[BC_RESUME_VAL:%.*]] = phi i16 [ 108, %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]\n; SINK-AFTER-NEXT: [[SCALAR_RECUR_INIT:%.*]] = phi i16 [ [[VECTOR_RECUR_EXTRACT]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]\n; SINK-AFTER-NEXT: br label %[[LOOP:.*]]\n; SINK-AFTER: [[LOOP]]:\n; SINK-AFTER-NEXT: [[IV:%.*]] = phi i16 [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], %[[LOOP]] ]\n; SINK-AFTER-NEXT: [[P:%.*]] = phi i16 [ [[SCALAR_RECUR_INIT]], %[[SCALAR_PH]] ], [ [[SEL:%.*]], %[[LOOP]] ]\n; SINK-AFTER-NEXT: [[L:%.*]] = load i32, ptr [[SRC]], align 4\n; SINK-AFTER-NEXT: [[C:%.*]] = icmp eq i32 [[L]], 0\n; SINK-AFTER-NEXT: [[SEL]] = select i1 [[C]], i16 1, i16 0\n; SINK-AFTER-NEXT: [[IV_NEXT]] = add i16 [[IV]], 1\n; SINK-AFTER-NEXT: [[EC:%.*]] = icmp eq i16 [[IV_NEXT]], 111\n; SINK-AFTER-NEXT: br i1 [[EC]], label %[[EXIT:.*]], label %[[LOOP]], !llvm.loop [[LOOP5:![0-9]+]]\n; SINK-AFTER: [[EXIT]]:\n; SINK-AFTER-NEXT: [[P_LCSSA:%.*]] = phi i16 [ [[P]], %[[LOOP]] ]\n; SINK-AFTER-NEXT: ret i16 [[P_LCSSA]]\n;\nentry:\n br label %loop\n\nloop:\n %iv = phi i16 [ 0, %entry ], [ %iv.next, %loop ]\n %p = phi i16 [ 0, %entry ] , [ %sel, %loop ]\n %l = load i32, ptr %src, align 4\n %c = icmp eq i32 %l, 0\n %sel = select i1 %c, i16 1, i16 0\n %iv.next = add i16 %iv, 1\n %ec = icmp eq i16 %iv.next, 111\n br i1 %ec, label %exit, label %loop\n\nexit:\n ret i16 %p\n}",
"additional_args": null,
"lli_expected_out": null
}
]
}
] |
{
"title": "[LoopVectorize] Instruction does not dominate all uses!",
"body": "Reproducer: https://godbolt.org/z/P1ea8d1bT\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 i16 @main() {\nentry:\n br label %safe_lshift_func_uint16_t_u_s.exit.i.i\n\nsafe_lshift_func_uint16_t_u_s.exit.i.i: ; preds = %safe_lshift_func_uint16_t_u_s.exit.i.i, %entry\n %l_1488.0377.i.i = phi i16 [ 0, %entry ], [ %l_1488.2.lcssa.2.i.i, %safe_lshift_func_uint16_t_u_s.exit.i.i ]\n %storemerge376.i.i = phi i16 [ 1, %entry ], [ %inc275.i.i, %safe_lshift_func_uint16_t_u_s.exit.i.i ]\n %0 = load i32, ptr null, align 4\n %tobool254.not.2.i.i = icmp eq i32 %0, 0\n %l_1488.2.lcssa.2.i.i = select i1 %tobool254.not.2.i.i, i16 1, i16 0\n %inc275.i.i = add i16 %storemerge376.i.i, 1\n %exitcond.not.i.i = icmp eq i16 %inc275.i.i, 0\n br i1 %exitcond.not.i.i, label %func_210.exit, label %safe_lshift_func_uint16_t_u_s.exit.i.i\n\nfunc_210.exit: ; preds = %safe_lshift_func_uint16_t_u_s.exit.i.i\n ret i16 %l_1488.0377.i.i\n}\n```\n```\nInstruction does not dominate all uses!\n %4 = extractelement <4 x i16> %2, i32 0\n %scalar.recur.init = phi i16 [ %4, %middle.block ], [ 0, %entry ]\nInstruction does not dominate all uses!\n %2 = select <4 x i1> %1, <4 x i16> splat (i16 1), <4 x i16> zeroinitializer\n %4 = extractelement <4 x i16> %2, i32 0\nPHI nodes not grouped at top of basic block!\n %bc.resume.val = phi i16 [ -7, %middle.block ], [ 1, %entry ]\nlabel %scalar.ph\nopt: /root/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10182: bool llvm::LoopVectorizePass::processLoop(llvm::Loop*): Assertion `!verifyFunction(*F, &dbgs())' 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 \"main\"\n #0 0x000000000589ea68 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x589ea68)\n #1 0x000000000589b914 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007e16e6e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007e16e6e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007e16e6e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007e16e6e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x00007e16e6e2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x00007e16e6e39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x00000000036379e9 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x36379e9)\n #9 0x0000000003639970 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3639970)\n#10 0x000000000363a055 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x363a055)\n#11 0x0000000002f3481e 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+0x2f3481e)\n#12 0x0000000005687c01 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5687c01)\n#13 0x0000000000eeb6ee 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+0xeeb6ee)\n#14 0x000000000568616a llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x568616a)\n#15 0x000000000096f08e 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+0x96f08e)\n#16 0x0000000005685b21 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5685b21)\n#17 0x0000000000979388 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+0x979388)\n#18 0x000000000096d409 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x96d409)\n#19 0x00007e16e6e29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#20 0x00007e16e6e29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#21 0x0000000000964555 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x964555)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```\ncc @fhahn \n",
"author": "dtcxzyw",
"labels": [
"vectorizers",
"crash-on-valid",
"generated by fuzzer"
],
"comments": []
}
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
c4b17bf9ed46acbd8b28987f2a6262964e4e2072
| null |
106239
|
https://github.com/llvm/llvm-project/issues/106239
|
crash
|
15405b32b1cdbefab9ce1b1f301a51ae25404037
| 2024-08-27T15:51:29
|
[
"llvm/test/Transforms/IndVarSimplify"
] | {"fix_commit":"c9a5e1b665dbba898e9981fd7d48881947e6560e","components":["SimplifyIndVar"],"bug_locati(...TRUNCATED)
| "commit c9a5e1b665dbba898e9981fd7d48881947e6560e\nAuthor: Nikita Popov <npopov@redhat.com>\nDate: (...TRUNCATED)
| [{"file":"llvm/test/Transforms/IndVarSimplify/pr106239.ll","commands":["opt -S -passes=indvars < %s"(...TRUNCATED)
| {"title":"[clang] Crash with O2 optimization flag","body":"I compiled this code with -O2 flag and it(...TRUNCATED)
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
4db93e5d56440be44d8ad2036e2579208c82ad37
| null |
127534
|
https://github.com/llvm/llvm-project/issues/127534
|
crash
|
6de5d1e46d1812de2bbbbe8d8d2c811e4d16acbe
| 2025-02-17T18:29:15
|
[
"llvm/test/Transforms/LoopSimplifyCFG"
] | {"fix_commit":"41437a6067b2f9dc8e7c458ff6417397796be31c","components":["LoopSimplifyCFG"],"bug_locat(...TRUNCATED)
| "commit 41437a6067b2f9dc8e7c458ff6417397796be31c\nAuthor: Aleksandr Popov <42888396+aleks-tmb@users.(...TRUNCATED)
| [{"file":"llvm/test/Transforms/LoopSimplifyCFG/pr117537.ll","commands":["opt -S -passes='print<scala(...TRUNCATED)
| {"title":"[SCEV] Assertion `isAvailableAtLoopEntry(RHS, L) && \"RHS is not available at Loop Entry\"(...TRUNCATED)
| 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_(...TRUNCATED)
| "commit 73d9974c91413f5a6dbe6f76f4b73ad226b6276b\nAuthor: Yingwei Zheng <dtcxzyw2333@gmail.com>\nDat(...TRUNCATED)
| [{"file":"llvm/test/Transforms/InstCombine/freeze.ll","commands":["opt < %s -passes=instcombine -S"](...TRUNCATED)
| {"title":"[InstCombine] Miscompilation when removing freezes","body":"Reproducer: https://alive2.llv(...TRUNCATED)
| true
|
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
Unrelated
| null |
LLVM APR Benchmark: A Large-Scale Automated Program Repair Benchmark of Real-World LLVM Middle-End Bugs
GitHub (We only accept pull requests from GitHub)
Motivation
The compiler is a critical infrastructure in the software development. The LLVM compiler infrastructure is widely used in both academia and industry. However, due to its inherent complexity, the LLVM compiler still contains many bugs that can be triggered in edge cases. As one of the LLVM maintainers, my job is to provide the minimal reproducible test cases for issues from fuzzers/ downstream users, and fix these bugs (or assign them to the right person). However, the process is time-consuming and boring. Thanks to the recent advances in compiler testing, we can automatically generate interesting test cases that trigger bugs and automatically reduce the tests to minimal ones. If we can also perform bug localization and repair automatically, it will significantly reduce the workload of us maintainers! Recently, LLM-based automated program repair (APR) techniques have been proposed. We have seen some successful cases in APR benchmarks like Defects4J and SWE-bench. But I believe that fixing LLVM bugs is more challenging than existing benchmarks due to its large C/C++ codebase, complex logic, long history, and the need for domain-specific knowledge. Therefore, I build this benchmark to see if we can automatically repair real-world LLVM bugs with the help of large language models and APR techniques. I hope this benchmark can help both SE researchers and LLVM community to understand how APR techniques work on a large-scale, real-world C/C++ project.
Dataset Description
In this benchmark, we only focus on three kinds of bugs in the LLVM middle-end:
- Crash: the compiler terminates exceptionally or hits an assertion failure (LLVM is built with
-DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ABI_BREAKING_CHECKS=WITH_ASSERTS). - Miscompilation: the compiler generates incorrect program from a well-defined source code.
- Hang: the compiler runs into an infinite loop or fails to reach a fixpoint.
All bugs can be triggered with an opt command and a small piece of LLVM textual IR.
This dataset collects some fixed LLVM middle-end bugs from GitHub issues since 2024-01-01. Each issue contains issue description, test cases, a reference patch, and some hints. All issues are checked against the following criteria:
- At least one of the given test cases can be used to reproduce the bug at a specific commit (
base_commit). For most of the miscompilation bugs, thesrcandtgtfunctions will be checked with alive2, an automatic refinement verification tool for LLVM. If miscompilation happens,alive-tvwill provide a counterexample. The remaining miscompilation bugs will be checked bylli. optpasses all the given tests after fixing the bug with the given reference patch (patch).optpasses all regression tests at a specific commit (hints.fix_commit).
Take Issue121459 as an example:
{
// Identifier of the bug. It can be an issue number, a pull request number,
// or a commit hash.
"bug_id": "121459",
// Points to issue/PR/commit url
"issue_url": "https://github.com/llvm/llvm-project/issues/121459",
// Bug type: crash/miscompilation/hang
"bug_type": "miscompilation",
// Fixes should be applied at the base commit
"base_commit": "68d265666e708bad1c63b419b6275aaba1a7dcd2",
// Knowledge cutoff date. It is not allowed to use the web knowledge base
// after this date or use a large language model trained with newer
// information. Please check the "Rules" section for exemptions.
"knowledge_cutoff": "2025-01-02T09:03:32Z",
// Regression test directories
"lit_test_dir": [
"llvm/test/Transforms/InstCombine"
],
// Bug localization hints at different granularity levels.
// Note that this information is provided in a best-effort way.
// They are not guaranteed to be available or accurate.
"hints": {
"fix_commit": "a4d92400a6db9566d84cb4b900149e36e117f452",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": [
[
2782,
2787
],
[
2838,
2843
],
[
2847,
2852
]
]
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": [
"foldGEPOfPhi"
]
}
},
// A reference patch extracted from hints.fix_commit
"patch": "<omitted>",
// Minimal reproducible tests
"tests": [
{
"file": "llvm/test/Transforms/InstCombine/opaque-ptr.ll",
"commands": [
"opt -S -passes='instcombine<no-verify-fixpoint>' < %s"
],
"tests": [
{
"test_name": "gep_of_phi_of_gep_different_type",
"test_body": "<omitted>"
},
{
"test_name": "gep_of_phi_of_gep_flags2",
"test_body": "<omitted>"
},
{
"test_name": "gep_of_phi_of_gep_flags1",
"test_body": "<omitted>"
}
]
}
],
// Issue description
"issue": {
"title": "[InstCombine] GEPNoWrapFlags is propagated incorrectly",
"body": "<omitted>",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": []
},
"verified": true,
// You are allowed to choose a subset of issues to fix.
// Althrough these properties are obtained from the golden patch,
// using properties is not treated as using hints.
"properties": {
"is_single_file_fix": true,
"is_single_func_fix": true
}
}
As of May 19, 2025, this benchmark contains 295 issues. You can run python3 scripts/dataset_summary.py locally to obtain the latest statistics.
Total issues: 295
Verified issues: 295 (100.00%)
Bug type summary:
miscompilation: 106
crash: 181
hang: 8
Bug component summary (Total = 50):
SLPVectorizer: 73
LoopVectorize: 71
InstCombine: 54
ScalarEvolution: 15
VectorCombine: 11
ValueTracking: 8
IR: 6
ConstraintElimination: 5
InstructionSimplify: 5
SimplifyIndVar: 4
Local: 4
LoopAccessAnalysis: 3
LoopPeel: 3
MemCpyOptimizer: 3
DeadStoreElimination: 3
MemorySSAUpdater: 3
...
Label summary:
crash: 111
miscompilation: 108
vectorizers: 81
llvm:SLPVectorizer: 73
crash-on-valid: 61
llvm:instcombine: 57
llvm:transforms: 40
llvm:analysis: 22
release:backport: 16
llvm:SCEV: 16
generated by fuzzer: 13
confirmed: 9
llvm:crash: 8
regression: 7
llvm:hang: 6
...
Changed files count summary:
Average: 1.17
Max: 5
Min: 1
Median: 1
Inserted lines summary:
Average: 10.71
Max: 164
Min: 0
Median: 6
Deleted lines summary:
Average: 5.55
Max: 169
Min: 0
Median: 2
Test count summary:
Average: 3.59
Max: 107
Min: 1
Median: 1
Patch summary:
Single file fix: 264 (89.49%)
Single func fix: 227 (76.95%)
Single hunk fix: 168 (56.95%)
You can see from the statistics that more than half of the bugs can be fixed with a single hunk. So I believe most of bugs can be fixed with the aid of LLM-based APR techniques :)
Getting Started
Prerequisites
- A C++17 compatible compiler
- ninja
- ccache
- Pre-built LLVM core libraries
- alive-tv
You can follow the Dockerfile to setup the environment.
Installation
git clone https://github.com/dtcxzyw/llvm-apr-benchmark.git
cd llvm-apr-benchmark
pip3 install -r requirements.txt
mkdir -p work && cd work
git clone https://github.com/llvm/llvm-project.git
Please set the following environment variables:
export LAB_LLVM_DIR=<path-to-llvm-src>
export LAB_LLVM_BUILD_DIR=<path-to-llvm-build-dir>
export LAB_LLVM_ALIVE_TV=<path-to-alive-tv>
export LAB_DATASET_DIR=<path-to-llvm-apr-benchmark>/dataset
export LAB_FIX_DIR=<path-to-llvm-apr-benchmark>/examples/fixes
Usage
This benchmark provides two helper modules to allow researchers to easily interact with LLVM and this benchmark.
To use these two helpers:
sys.path.append(os.path.join(os.path.dirname(os.environ["LAB_DATASET_DIR"]), "scripts"))
import llvm_helper
from lab_env import Environment as Env
# Environment variables
llvm_helper.llvm_dir # os.environ["LAB_LLVM_DIR"]
llvm_helper.llvm_build_dir # os.environ["LAB_LLVM_BUILD_DIR"]
llvm_helper.llvm_alive_tv # os.environ["LAB_LLVM_ALIVE_TV"]
llvm_helper.dataset_dir # os.environ["LAB_DATASET_DIR"]
# Execute git commands on the llvm source tree
source_code = llvm_helper.git_execute(['show', f'{commit}:{file_path}'])
# Get information of first failed test from the result of Environment.check_fast/check_full
res, log = env.check_fast()
if isinstance(log, list):
test = llvm_helper.get_first_failed_test(log)
env = Env(
# Load an issue from dataset/{issue_id}.json
issue_id,
# The knowledge cutoff date of LLM
base_model_knowledge_cutoff = "2024-01-01Z",
# Max concurrent jobs for build/test
max_build_jobs=None,
max_test_jobs=None,
)
# If any external knowledge is used, please call this function.
env.use_knowledge(url = "<url>", date = "<date>")
# Reset the source tree to the base commit. Please call it before each attempt.
env.reset()
# Build llvm
res, log = env.build()
# Provide a certificate with the patch and verification result
certificate = env.dump()
# Perform build + test
res, log = env.check_fast()
# Perform build + test + lit regression test
res, log = env.check_full()
# Issue information (always available)
bug_type = env.get_bug_type()
base_commit = env.get_base_commit()
tests = env.get_tests()
# Hints (optional)
fix_commit = env.get_hint_fix_commit()
components = env.get_hint_components()
files = env.get_hint_files()
functions = env.get_hint_bug_functions()
linenos = env.get_hint_line_level_bug_locations()
# Bisection result (optional)
# It is collected in a best-effort way and not always precise.
bisect_commit = env.get_bisect_commit()
# Issue description (optional)
issue = env.get_hint_issue()
# Collect instructions and intrinsics from the given LLVM IR.
# Then it will retrieve descriptions from llvm/docs/LangRef.dst.
# It is useful for LLMs to understand new flags/attributes/metadata.
keywords = env.get_ir_keywords(llvm_ir)
desc = env.get_langref_desc(keywords)
# Properties
is_single_func_fix = env.is_single_func_fix()
is_single_file_fix = env.is_single_file_fix()
Here is a simple repair loop:
env = Env(...)
# System prompts and user prompts
messages = []
while True:
# Reset the LLVM source code tree
env.reset()
# Get information from env
...
# Chat with LLM
...
# Modify the source code in place
...
res, log = env.check_full()
if res:
# The bug is fixed successfully
cert = json.dumps(env.dump(log = messages), indent=2)
print(cert)
break
# Append the feedback into user prompts for the next iteration
messages.append(construct_user_prompt_from_feedback(log))
I have drafted a poor baseline which is powered by DeepSeek-R1. This baseline implementation is only for reference purposes since I am neither an expert in LLM nor APR.
Rules
To claim that your APR tool successfully fixes a bug, please obey the following rules:
- Knowledge allowed to use:
- Any static content/ dynamic feedback provided by
lab_env.Environment - Any content in the LLVM source tree before the base commit
- Large language model trained with dataset before the knowledge cutoff date
- Any other content on the web created before the knowledge cutoff date
- Any static content/ dynamic feedback provided by
optwith this patch passes both the given tests and the regression testsuite.
License
This project is licensed under the Apache License 2.0. Please see the LICENSE for details.
Please cite this work with the following BibTex entry:
@misc{llvm-apr-benchmark,
title = {LLVM APR Benchmark: A Large-Scale Automated Program Repair Benchmark of Real-World LLVM Middle-End Bugs},
url = {https://github.com/dtcxzyw/llvm-apr-benchmark},
author = {Yingwei Zheng},
year = {2025},
}
- Downloads last month
- 91