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 | test_commit
string |
---|---|---|---|---|---|---|---|---|---|---|---|---|
128770
|
https://github.com/llvm/llvm-project/issues/128770
|
crash
|
7f482aa848c5f136d2b32431f91f88492c78c709
| 2025-02-25T20:34:44 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "418a9872851ef5342b29baa36dd672129f129953",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
13353,
13358
],
[
13453,
13459
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::isGatherShuffledSingleRegisterEntry"
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 418a9872851ef5342b29baa36dd672129f129953
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Wed Feb 26 12:59:27 2025 -0800
[SLP]Do not use node, if it is a subvector or buildvector node
If the buildvector has some matches with another node, which is
a subvector of another buildvector node, need to check for this and
cancel matching to avoid incorrect ordering of the nodes.
Fixes #128770
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 02fea2eaf9d4..b25b09306aca 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -13353,6 +13353,14 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
return EdgeInfo(const_cast<TreeEntry *>(TE), 0);
return TE->UserTreeIndex;
};
+ auto HasGatherUser = [&](const TreeEntry *TE) {
+ while (TE->Idx != 0 && TE->UserTreeIndex) {
+ if (TE->UserTreeIndex.EdgeIdx == UINT_MAX)
+ return true;
+ TE = TE->UserTreeIndex.UserTE;
+ }
+ return false;
+ };
const EdgeInfo TEUseEI = GetUserEntry(TE);
if (!TEUseEI)
return std::nullopt;
@@ -13453,7 +13461,8 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
// If the user instruction is used for some reason in different
// vectorized nodes - make it depend on index.
if (TEUseEI.UserTE != UseEI.UserTE &&
- TEUseEI.UserTE->Idx < UseEI.UserTE->Idx)
+ (TEUseEI.UserTE->Idx < UseEI.UserTE->Idx ||
+ HasGatherUser(TEUseEI.UserTE)))
continue;
}
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/buildvector-reused-with-bv-subvector.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -mcpu=skylake < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @test(ptr %0, i64 %1, i64 %2) {\n;\n %4 = ptrtoint ptr %0 to i64\n %5 = ptrtoint ptr %0 to i64\n %6 = ptrtoint ptr %0 to i64\n %7 = ptrtoint ptr %0 to i64\n %8 = ptrtoint ptr %0 to i64\n br label %.preheader.lr.ph\n\n.preheader.lr.ph:\n br label %.preheader.us.us.preheader\n\n.preheader.us.us.preheader:\n %9 = or i64 %1, %7\n %10 = or i64 %2, %7\n %11 = or i64 %1, %4\n %12 = or i64 %1, %8\n %13 = or i64 %5, %8\n %14 = or i64 %8, %4\n %15 = or i64 %5, %6\n %16 = or i64 %6, %4\n br label %.preheader.us.us\n\n.preheader.us.us:\n %diff.check1 = icmp ult i64 %9, 32\n %diff.check2 = icmp ult i64 %10, 32\n %conflict.rdx3 = or i1 %diff.check1, %diff.check2\n %diff.check4 = icmp ult i64 %11, 32\n %conflict.rdx5 = or i1 %conflict.rdx3, %diff.check4\n %diff.check6 = icmp ult i64 %12, 32\n %conflict.rdx7 = or i1 %conflict.rdx5, %diff.check6\n %diff.check8 = icmp ult i64 %13, 32\n %conflict.rdx9 = or i1 %conflict.rdx7, %diff.check8\n %diff.check10 = icmp ult i64 %14, 32\n %conflict.rdx11 = or i1 %conflict.rdx9, %diff.check10\n %diff.check12 = icmp ult i64 %15, 32\n %conflict.rdx13 = or i1 %conflict.rdx11, %diff.check12\n %diff.check14 = icmp ult i64 %16, 32\n %conflict.rdx15 = or i1 %conflict.rdx13, %diff.check14\n br i1 %conflict.rdx15, label %scalar.ph, label %.preheader.us.us\n\nscalar.ph:\n ret void\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "SLP: Instruction does not dominate all uses (insertelement/shufflevector)",
"body": "[slp.ll.gz](https://github.com/user-attachments/files/18972113/slp.ll.gz)\n\nReproducer: `opt -passes=slp-vectorizer slp.ll -mcpu=skylake`\n\n@alexey-bataev can you please take a look?",
"author": "vzakhari",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
135912
|
https://github.com/llvm/llvm-project/issues/135912
|
crash
|
d3153ad66c539ad146062b6e65741901e5b5e1cc
| 2025-04-16T05:32:48 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "af28c9c65a23806a09d7929792df5ed2e9bdf946",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
7479,
7486
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::reorderBottomToTop"
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit af28c9c65a23806a09d7929792df5ed2e9bdf946
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Wed Apr 16 06:20:34 2025 -0700
[SLP]Do not reorder split node operand with reuses, if not possible
Need to check if the operand node of the split vectorize node has reuses
and check if it is possible to build the order for this node to reorder
it correctly.
Fixes #135912
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index f9acc276f37f..f97386159d02 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -7479,8 +7479,8 @@ void BoUpSLP::reorderBottomToTop(bool IgnoreReorder) {
for (const auto &P : Data.first->CombinedEntriesWithIndices) {
TreeEntry &OpTE = *VectorizableTree[P.first].get();
OrdersType Order = OpTE.ReorderIndices;
- if (Order.empty()) {
- if (!OpTE.isGather())
+ if (Order.empty() || !OpTE.ReuseShuffleIndices.empty()) {
+ if (!OpTE.isGather() && OpTE.ReuseShuffleIndices.empty())
continue;
const auto BestOrder =
getReorderingData(OpTE, /*TopToBottom=*/false, IgnoreReorder);
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/split-vector-operand-with-reuses.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @test(ptr %p) {\n;\nentry:\n %arrayidx7.us.i.841 = getelementptr i8, ptr %p, i64 36\n %arrayidx7.us.i.946 = getelementptr i8, ptr %p, i64 40\n %arrayidx7.us.i.1051 = getelementptr i8, ptr %p, i64 44\n %arrayidx7.us.i.1156 = getelementptr i8, ptr %p, i64 48\n %arrayidx7.us.i.1261 = getelementptr i8, ptr %p, i64 52\n %arrayidx7.us.i.1366 = getelementptr i8, ptr %p, i64 56\n %arrayidx7.us.i.1471 = getelementptr i8, ptr %p, i64 60\n %arrayidx7.us.i.1576 = getelementptr i8, ptr %p, i64 64\n %add8.us.i.1.4 = add i32 0, 0\n %rem.us.i.1.4 = srem i32 %add8.us.i.1.4, 1\n %add8.us.i.1.5 = add i32 0, 0\n %rem.us.i.1.5 = srem i32 %add8.us.i.1.5, 1\n %invariant.op91 = add i32 %rem.us.i.1.4, %rem.us.i.1.5\n %add8.us.i.1.6 = add i32 0, 0\n %rem.us.i.1.6 = srem i32 %add8.us.i.1.6, 1\n %invariant.op92 = add i32 %invariant.op91, %rem.us.i.1.6\n %0 = load i32, ptr %arrayidx7.us.i.841, align 4\n %1 = load i32, ptr %arrayidx7.us.i.946, align 4\n %2 = load i32, ptr %arrayidx7.us.i.1051, align 4\n %3 = load i32, ptr %arrayidx7.us.i.1156, align 4\n %4 = load i32, ptr %arrayidx7.us.i.1261, align 4\n %5 = load i32, ptr %arrayidx7.us.i.1366, align 4\n %add8.us.i.7.6 = or i32 %5, 0\n %rem.us.i.7.6 = srem i32 %add8.us.i.7.6, 1\n %6 = load i32, ptr %arrayidx7.us.i.1471, align 4\n %add8.us.i.7.7 = or i32 %6, 0\n %rem.us.i.7.7 = srem i32 %add8.us.i.7.7, 1\n %invariant.op165 = add i32 %rem.us.i.7.6, %rem.us.i.7.7\n %7 = load i32, ptr %arrayidx7.us.i.1576, align 4\n %add8.us.i.7.8 = or i32 %7, 0\n %rem.us.i.7.8 = srem i32 %add8.us.i.7.8, 1\n %invariant.op166 = add i32 %invariant.op165, %rem.us.i.7.8\n %add8.us.i.8 = or i32 %0, 0\n %rem.us.i.8 = srem i32 %add8.us.i.8, 1\n %invariant.op167 = add i32 %invariant.op166, %rem.us.i.8\n %add8.us.i.8.1 = or i32 %1, 0\n %rem.us.i.8.1 = srem i32 %add8.us.i.8.1, 1\n %invariant.op168 = add i32 %invariant.op167, %rem.us.i.8.1\n %add8.us.i.8.2 = or i32 %2, 0\n %rem.us.i.8.2 = srem i32 %add8.us.i.8.2, 1\n %invariant.op169 = add i32 %invariant.op168, %rem.us.i.8.2\n %add8.us.i.8.3 = or i32 %3, 0\n %rem.us.i.8.3 = srem i32 %add8.us.i.8.3, 1\n %invariant.op170 = add i32 %invariant.op169, %rem.us.i.8.3\n %add8.us.i.8.4 = or i32 %4, 0\n %rem.us.i.8.4 = srem i32 %add8.us.i.8.4, 1\n %invariant.op171 = add i32 %invariant.op170, %rem.us.i.8.4\n %add8.us.i.8.5 = or i32 %5, 0\n %rem.us.i.8.5 = srem i32 %add8.us.i.8.5, 1\n %invariant.op172 = add i32 %invariant.op171, %rem.us.i.8.5\n %add8.us.i.8.6 = or i32 %6, 0\n %rem.us.i.8.6 = srem i32 %add8.us.i.8.6, 0\n %invariant.op173 = add i32 %invariant.op172, %rem.us.i.8.6\n %add8.us.i.8.7 = or i32 %7, 0\n %rem.us.i.8.7 = srem i32 %add8.us.i.8.7, 0\n %invariant.op174 = add i32 %invariant.op173, %rem.us.i.8.7\n %invariant.op181 = add i32 %invariant.op174, 0\n %invariant.op182 = add i32 %invariant.op181, 0\n %invariant.op183 = add i32 %invariant.op182, 0\n %invariant.op184 = add i32 %invariant.op183, 0\n %invariant.op185 = add i32 %invariant.op184, 0\n %invariant.op186 = add i32 %invariant.op185, 0\n %invariant.op187 = add i32 %invariant.op186, 0\n %invariant.op188 = add i32 %invariant.op187, 0\n %add8.us.i.11.1 = or i32 %4, 0\n %rem.us.i.11.1 = srem i32 %add8.us.i.11.1, 1\n %invariant.op189 = add i32 %invariant.op188, %rem.us.i.11.1\n %add8.us.i.11.2 = add i32 0, 0\n %rem.us.i.11.2 = srem i32 %add8.us.i.11.2, 1\n %invariant.op190 = add i32 %invariant.op189, %rem.us.i.11.2\n %add8.us.i.11.3 = add i32 %6, %2\n %rem.us.i.11.3 = srem i32 %add8.us.i.11.3, 1\n %invariant.op191 = add i32 %invariant.op190, %rem.us.i.11.3\n %add8.us.i.11.4 = add i32 %7, %2\n %rem.us.i.11.4 = srem i32 %add8.us.i.11.4, 1\n %invariant.op192 = add i32 %invariant.op191, %rem.us.i.11.4\n %8 = load i32, ptr %p, align 4\n %add8.us.i.12 = add i32 %4, %8\n %rem.us.i.12 = srem i32 %add8.us.i.12, 1\n %invariant.op193 = add i32 %invariant.op192, %rem.us.i.12\n %add8.us.i.12.1 = add i32 %5, %8\n %rem.us.i.12.1 = srem i32 %add8.us.i.12.1, 1\n %invariant.op194 = add i32 %invariant.op193, %rem.us.i.12.1\n %add8.us.i.12.2 = add i32 0, 0\n %rem.us.i.12.2 = srem i32 %add8.us.i.12.2, 1\n %invariant.op195 = add i32 %invariant.op194, %rem.us.i.12.2\n %add8.us.i.12.3 = add i32 0, 0\n %rem.us.i.12.3 = srem i32 %add8.us.i.12.3, 1\n %invariant.op196 = add i32 %invariant.op195, %rem.us.i.12.3\n %add8.us.i.13 = add i32 0, 0\n %rem.us.i.13 = srem i32 %add8.us.i.13, 0\n %invariant.op197 = add i32 %invariant.op196, %rem.us.i.13\n %add8.us.i.13.1 = add i32 0, 0\n %rem.us.i.13.1 = srem i32 %add8.us.i.13.1, 0\n %invariant.op198 = add i32 %invariant.op197, %rem.us.i.13.1\n %add8.us.i.13.2 = add i32 0, 0\n %rem.us.i.13.2 = srem i32 %add8.us.i.13.2, 1\n %invariant.op199 = add i32 %invariant.op198, %rem.us.i.13.2\n %add8.us.i.14 = add i32 0, 0\n %rem.us.i.14 = srem i32 %add8.us.i.14, 1\n %invariant.op200 = add i32 %invariant.op199, %rem.us.i.14\n %add8.us.i.14.1 = add i32 0, 0\n %rem.us.i.14.1 = srem i32 %add8.us.i.14.1, 1\n %invariant.op201 = add i32 %invariant.op200, %rem.us.i.14.1\n %add8.us.i.15 = add i32 0, 0\n %rem.us.i.15 = srem i32 %add8.us.i.15, 1\n %invariant.op202 = add i32 %invariant.op201, %rem.us.i.15\n br label %for.cond1.preheader.us.i\n\nfor.cond1.preheader.us.i:\n %a.promoted253537.us.i = phi i32 [ %add9.us.i.15.reass, %for.cond1.preheader.us.i ], [ 0, %entry ]\n %add9.us.i.15.reass = add i32 %invariant.op92, %invariant.op202\n br label %for.cond1.preheader.us.i\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[clang] Crash at -O3: Assertion `OpTE1.isSame...\"' failed.",
"body": "This code crashes at `-O3`:\n\n```c\nint a, b, c, d;\nvoid *malloc();\nvoid e(int f) {\n int *g = malloc(sizeof(int));\n for (; d; d++) {\n b = 0;\n for (; b < f - 1; b++) {\n c = b + 1;\n for (; c < f; c++)\n a += (g[b] + g[c]) % 2;\n }\n }\n}\nvoid h() { e(1 + 16); }\n```\n\nCompiler Explorer: https://godbolt.org/z/h3h3qe174\n\nCrash:\n\n```console\nclang: /root/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:17358: llvm::Value* llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*): Assertion `OpTE1.isSame( ArrayRef(E->Scalars).take_front(OpTE1.getVectorFactor())) && \"Expected same first part of scalars.\"' failed.\n```\n\nBacktrace:\n\n```console\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O3 <source>\n1.\t<eof> parser at end of file\n2.\tOptimizer\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,chr,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"<source>\"\n4.\tRunning pass \"slp-vectorizer\" on function \"h\"\n #0 0x0000000003ee5798 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3ee5798)\n #1 0x0000000003ee3424 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3ee3424)\n #2 0x0000000003e27f68 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0\n #3 0x00007c46db642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #4 0x00007c46db6969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #5 0x00007c46db642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #6 0x00007c46db6287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #7 0x00007c46db62871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #8 0x00007c46db639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #9 0x0000000005b118bd llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5b118bd)\n#10 0x0000000005b0b18e llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5b0b18e)\n#11 0x0000000005b0c98d llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5b0c98d)\n#12 0x0000000005b0acc2 llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5b0acc2)\n#13 0x0000000005b0c98d llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5b0c98d)\n#14 0x0000000005b2fdc4 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::SmallDenseSet<llvm::Value*, 4u, llvm::DenseMapInfo<llvm::Value*, void>> const&, llvm::Instruction*, llvm::ArrayRef<std::tuple<llvm::Value*, unsigned int, bool>>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5b2fdc4)\n#15 0x0000000005b449ff (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&, llvm::AssumptionCache*) SLPVectorizer.cpp:0:0\n#16 0x0000000005b476cf llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5b476cf)\n#17 0x0000000005b4bee0 llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5b4bee0)\n#18 0x0000000005b50846 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5b50846)\n#19 0x0000000005b5749e llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\n#20 0x0000000005b5805b llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5b5805b)\n#21 0x00000000055bd0ee llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x55bd0ee)\n#22 0x00000000038884b0 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x38884b0)\n#23 0x00000000011f0b2e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x11f0b2e)\n#24 0x0000000003886d83 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3886d83)\n#25 0x00000000011efa6e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x11efa6e)\n#26 0x0000000003886790 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3886790)\n#27 0x0000000004198802 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\n#28 0x000000000419bfab clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x419bfab)\n#29 0x000000000487fea0 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x487fea0)\n#30 0x00000000065342ec clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x65342ec)\n#31 0x0000000004880288 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4880288)\n#32 0x0000000004b72995 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4b72995)\n#33 0x0000000004af188e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4af188e)\n#34 0x0000000004c6226e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4c6226e)\n#35 0x0000000000d9ee9f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd9ee9f)\n#36 0x0000000000d965aa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#37 0x00000000048e6769 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0\n#38 0x0000000003e28404 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e28404)\n#39 0x00000000048e6d7f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0\n#40 0x00000000048a91dd clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x48a91dd)\n#41 0x00000000048aa26e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x48aa26e)\n#42 0x00000000048b20c5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x48b20c5)\n#43 0x0000000000d9bbe8 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd9bbe8)\n#44 0x0000000000c265e4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc265e4)\n#45 0x00007c46db629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#46 0x00007c46db629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#47 0x0000000000d96055 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd96055)\n```\n\n",
"author": "cardigan1008",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid"
],
"comments": [
{
"author": "cardigan1008",
"body": "This issue seems to be related to https://github.com/llvm/llvm-project/issues/130972. cc @alexey-bataev "
},
{
"author": "dtcxzyw",
"body": "Reduced reproducer: https://godbolt.org/z/6b31EPqqr\n"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
113810
|
https://github.com/llvm/llvm-project/issues/113810
|
crash
|
ce0368eb8417f2d369499bb98b1f0ccbe2219598
| 2024-10-27T14:16:44 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "7152bf3bc805b8d9b1873058ab0a084d7b6079d6",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
7947,
7954
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::buildTree_rec"
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 7152bf3bc805b8d9b1873058ab0a084d7b6079d6
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Mon Oct 28 06:37:24 2024 -0700
[SLP]Do not create new vector node if scalars fully overlap with the existing one
If the list of scalars vectorized as the part of the same vector node,
no need to generate vector node again, it will be handled as part of
overlapping matching.
Fixes #113810
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 2afd02dae3a8..268546fe99e1 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -7947,8 +7947,13 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
Nodes.insert(E);
SmallPtrSet<Value *, 8> Values(VL.begin(), VL.end());
if (any_of(Nodes, [&](const TreeEntry *E) {
- return all_of(E->Scalars,
- [&](Value *V) { return Values.contains(V); });
+ if (all_of(E->Scalars,
+ [&](Value *V) { return Values.contains(V); }))
+ return true;
+ SmallPtrSet<Value *, 8> EValues(E->Scalars.begin(),
+ E->Scalars.end());
+ return (
+ all_of(VL, [&](Value *V) { return EValues.contains(V); }));
})) {
LLVM_DEBUG(dbgs() << "SLP: Gathering due to full overlap.\n");
if (TryToFindDuplicates(S))
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/full-overlap-non-schedulable.ll",
"commands": [
"opt -S --passes=slp-vectorizer < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define void @test(ptr %p1, ptr %0, i32 %1, i1 %c1, ptr %p2) {\ntop:\n %2 = getelementptr i8, ptr %0, i64 8\n %3 = getelementptr i8, ptr %0, i64 12\n %4 = getelementptr i8, ptr %0, i64 16\n %5 = getelementptr i8, ptr %0, i64 20\n br i1 %c1, label %L42, label %L41\n\nL41: ; preds = %top\n %.not276 = icmp eq ptr %2, null\n %6 = load i32, ptr %2, align 4\n %7 = select i1 %.not276, i32 0, i32 %6\n %.not277 = icmp eq ptr %3, null\n %8 = load i32, ptr %3, align 4\n %9 = select i1 %.not277, i32 0, i32 %8\n %.not278 = icmp eq ptr %4, null\n %10 = load i32, ptr %4, align 4\n %11 = select i1 %.not278, i32 0, i32 %10\n %.not279 = icmp eq ptr %5, null\n %12 = load i32, ptr %5, align 4\n %13 = select i1 %.not279, i32 0, i32 %12\n br label %L112\n\nL42: ; preds = %top\n %14 = load i32, ptr %2, align 4\n %.not280 = icmp eq i32 %14, 0\n br i1 %.not280, label %L112, label %L47\n\nL47: ; preds = %L42\n %15 = load i32, ptr %3, align 4\n %.not282 = icmp eq ptr %4, null\n %16 = load i32, ptr %4, align 4\n %17 = select i1 %.not282, i32 0, i32 %16\n %.not283 = icmp eq ptr %5, null\n %18 = load i32, ptr %5, align 4\n %19 = select i1 %.not283, i32 0, i32 %18\n br label %L112\n\nL112: ; preds = %L47, %L42, %L41\n %value_phi13336 = phi i32 [ %19, %L47 ], [ %13, %L41 ], [ 0, %L42 ]\n %value_phi12335 = phi i32 [ %17, %L47 ], [ %11, %L41 ], [ %1, %L42 ]\n %value_phi11334 = phi i32 [ %15, %L47 ], [ %9, %L41 ], [ 0, %L42 ]\n %value_phi10333 = phi i32 [ 0, %L47 ], [ %7, %L41 ], [ 0, %L42 ]\n store i32 %value_phi10333, ptr %p2, align 4\n store i32 %value_phi11334, ptr %p1, align 4\n store i32 %value_phi12335, ptr %p2, align 4\n store i32 %value_phi13336, ptr %p1, align 4\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "SLPVectorizer miscompilation",
"body": "This IR\r\n```llvm\r\n; Function Attrs: alignstack(16)\r\ndefine swiftcc { ptr addrspace(10), i8 } @julia__zip_iterate_all_17381(ptr noalias nocapture noundef nonnull align 4 dereferenceable(96) %union_bytes_return, ptr nonnull swiftself %pgcstack_arg, ptr addrspace(11) nocapture noundef nonnull readonly align 4 dereferenceable(48) %0, ptr addrspace(11) nocapture noundef nonnull readonly align 4 dereferenceable(48) %1) #0 {\r\ntop:\r\n %pgcstack = call ptr @julia.get_pgcstack()\r\n %ptls_field = getelementptr inbounds i8, ptr %pgcstack, i32 8\r\n %ptls_load = load ptr, ptr %ptls_field, align 4\r\n %2 = getelementptr inbounds i8, ptr %ptls_load, i32 16\r\n %safepoint = load ptr, ptr %2, align 4\r\n fence syncscope(\"singlethread\") seq_cst\r\n call void @julia.safepoint(ptr %safepoint)\r\n fence syncscope(\"singlethread\") seq_cst\r\n %3 = load i32, ptr addrspace(11) %1, align 4\r\n %4 = load i32, ptr addrspace(11) %0, align 4\r\n %.not = icmp eq i32 %3, %4\r\n br i1 %.not, label %L26, label %L20\r\n\r\nL20: ; preds = %top\r\n %5 = add i32 %3, 1\r\n %6 = getelementptr inbounds i8, ptr addrspace(11) %1, i32 4\r\n %7 = getelementptr inbounds i8, ptr addrspace(11) %1, i32 8\r\n %8 = getelementptr inbounds i8, ptr addrspace(11) %1, i32 12\r\n %9 = getelementptr inbounds i8, ptr addrspace(11) %1, i32 16\r\n %10 = getelementptr inbounds i8, ptr addrspace(11) %1, i32 20\r\n %.not265 = icmp eq ptr addrspace(11) %6, null\r\n %11 = load i32, ptr addrspace(11) %6, align 4\r\n %12 = select i1 %.not265, i32 undef, i32 %11\r\n %.not266 = icmp eq ptr addrspace(11) %7, null\r\n %13 = load i32, ptr addrspace(11) %7, align 4\r\n %14 = select i1 %.not266, i32 undef, i32 %13\r\n %.not267 = icmp eq ptr addrspace(11) %8, null\r\n %15 = load i32, ptr addrspace(11) %8, align 4\r\n %16 = select i1 %.not267, i32 undef, i32 %15\r\n %.not268 = icmp eq ptr addrspace(11) %9, null\r\n %17 = load i32, ptr addrspace(11) %9, align 4\r\n %18 = select i1 %.not268, i32 undef, i32 %17\r\n %.not269 = icmp eq ptr addrspace(11) %10, null\r\n %19 = load i32, ptr addrspace(11) %10, align 4\r\n %20 = select i1 %.not269, i32 undef, i32 %19\r\n br label %L112\r\n\r\nL26: ; preds = %top\r\n %21 = getelementptr inbounds i8, ptr addrspace(11) %1, i32 4\r\n %22 = getelementptr inbounds i8, ptr addrspace(11) %1, i32 8\r\n %23 = getelementptr inbounds i8, ptr addrspace(11) %1, i32 12\r\n %24 = getelementptr inbounds i8, ptr addrspace(11) %1, i32 16\r\n %25 = getelementptr inbounds i8, ptr addrspace(11) %1, i32 20\r\n %26 = getelementptr inbounds i8, ptr addrspace(11) %0, i32 4\r\n %27 = getelementptr inbounds i8, ptr addrspace(11) %0, i32 12\r\n %28 = getelementptr inbounds i8, ptr addrspace(11) %0, i32 16\r\n %29 = getelementptr inbounds i8, ptr addrspace(11) %0, i32 20\r\n %30 = load i32, ptr addrspace(11) %21, align 4\r\n %31 = load i32, ptr addrspace(11) %26, align 4\r\n %.not275 = icmp eq i32 %30, %31\r\n br i1 %.not275, label %L42, label %L41\r\n\r\nL41: ; preds = %L26\r\n %32 = add i32 %30, 1\r\n %.not276 = icmp eq ptr addrspace(11) %22, null\r\n %33 = load i32, ptr addrspace(11) %22, align 4\r\n %34 = select i1 %.not276, i32 undef, i32 %33\r\n %.not277 = icmp eq ptr addrspace(11) %23, null\r\n %35 = load i32, ptr addrspace(11) %23, align 4\r\n %36 = select i1 %.not277, i32 undef, i32 %35\r\n %.not278 = icmp eq ptr addrspace(11) %24, null\r\n %37 = load i32, ptr addrspace(11) %24, align 4\r\n %38 = select i1 %.not278, i32 undef, i32 %37\r\n %.not279 = icmp eq ptr addrspace(11) %25, null\r\n %39 = load i32, ptr addrspace(11) %25, align 4\r\n %40 = select i1 %.not279, i32 undef, i32 %39\r\n br label %L112\r\n\r\nL42: ; preds = %L26\r\n %41 = getelementptr inbounds i8, ptr addrspace(11) %0, i32 8\r\n %42 = load i32, ptr addrspace(11) %22, align 4\r\n %43 = load i32, ptr addrspace(11) %41, align 4\r\n %.not280 = icmp eq i32 %42, %43\r\n br i1 %.not280, label %L48, label %L47\r\n\r\nL47: ; preds = %L42\r\n %44 = add i32 %42, 1\r\n %.not281 = icmp eq ptr addrspace(11) %23, null\r\n %45 = load i32, ptr addrspace(11) %23, align 4\r\n %46 = select i1 %.not281, i32 undef, i32 %45\r\n %.not282 = icmp eq ptr addrspace(11) %24, null\r\n %47 = load i32, ptr addrspace(11) %24, align 4\r\n %48 = select i1 %.not282, i32 undef, i32 %47\r\n %.not283 = icmp eq ptr addrspace(11) %25, null\r\n %49 = load i32, ptr addrspace(11) %25, align 4\r\n %50 = select i1 %.not283, i32 undef, i32 %49\r\n br label %L112\r\n\r\nL48: ; preds = %L42\r\n %51 = load i32, ptr addrspace(11) %23, align 4\r\n %52 = load i32, ptr addrspace(11) %27, align 4\r\n %.not284 = icmp eq i32 %51, %52\r\n br i1 %.not284, label %L54, label %L53\r\n\r\nL53: ; preds = %L48\r\n %53 = add i32 %51, 1\r\n %.not285 = icmp eq ptr addrspace(11) %24, null\r\n %54 = load i32, ptr addrspace(11) %24, align 4\r\n %55 = select i1 %.not285, i32 undef, i32 %54\r\n %.not286 = icmp eq ptr addrspace(11) %25, null\r\n %56 = load i32, ptr addrspace(11) %25, align 4\r\n %57 = select i1 %.not286, i32 undef, i32 %56\r\n br label %L112\r\n\r\nL54: ; preds = %L48\r\n %58 = load i32, ptr addrspace(11) %24, align 4\r\n %59 = load i32, ptr addrspace(11) %28, align 4\r\n %.not287 = icmp eq i32 %58, %59\r\n br i1 %.not287, label %L87, label %L59\r\n\r\nL59: ; preds = %L54\r\n %60 = add i32 %58, 1\r\n %.not288 = icmp eq ptr addrspace(11) %25, null\r\n %61 = load i32, ptr addrspace(11) %25, align 4\r\n %62 = select i1 %.not288, i32 undef, i32 %61\r\n br label %L112\r\n\r\nL87: ; preds = %L54\r\n %63 = load i32, ptr addrspace(11) %25, align 4\r\n %64 = add i32 %63, 1\r\n %65 = load i32, ptr addrspace(11) %29, align 4\r\n %66 = icmp eq i32 %63, %65\r\n br i1 %66, label %common.ret, label %L112\r\n\r\nL112: ; preds = %L87, %L20, %L41, %L47, %L53, %L59\r\n %value_phi13336 = phi i32 [ %64, %L87 ], [ %62, %L59 ], [ %57, %L53 ], [ %50, %L47 ], [ %40, %L41 ], [ %20, %L20 ]\r\n %value_phi12335 = phi i32 [ 1, %L87 ], [ %60, %L59 ], [ %55, %L53 ], [ %48, %L47 ], [ %38, %L41 ], [ %18, %L20 ]\r\n %value_phi11334 = phi i32 [ 1, %L87 ], [ 1, %L59 ], [ %53, %L53 ], [ %46, %L47 ], [ %36, %L41 ], [ %16, %L20 ]\r\n %value_phi10333 = phi i32 [ 1, %L87 ], [ 1, %L59 ], [ 1, %L53 ], [ %44, %L47 ], [ %34, %L41 ], [ %14, %L20 ]\r\n %value_phi9332 = phi i32 [ 1, %L87 ], [ 1, %L59 ], [ 1, %L53 ], [ 1, %L47 ], [ %32, %L41 ], [ %12, %L20 ]\r\n %value_phi2326 = phi i32 [ 1, %L87 ], [ 1, %L59 ], [ 1, %L53 ], [ 1, %L47 ], [ 1, %L41 ], [ %5, %L20 ]\r\n %67 = getelementptr inbounds i8, ptr addrspace(11) %0, i32 24\r\n %68 = getelementptr inbounds i8, ptr addrspace(11) %1, i32 24\r\n %69 = load i32, ptr addrspace(11) %68, align 4\r\n %70 = load i32, ptr addrspace(11) %67, align 4\r\n %.not289 = icmp eq i32 %69, %70\r\n br i1 %.not289, label %L134, label %L128\r\n\r\nL128: ; preds = %L112\r\n %71 = add i32 %69, 1\r\n %72 = getelementptr inbounds i8, ptr addrspace(11) %1, i32 28\r\n %73 = getelementptr inbounds i8, ptr addrspace(11) %1, i32 32\r\n %74 = getelementptr inbounds i8, ptr addrspace(11) %1, i32 36\r\n %75 = getelementptr inbounds i8, ptr addrspace(11) %1, i32 40\r\n %76 = getelementptr inbounds i8, ptr addrspace(11) %1, i32 44\r\n %.not290 = icmp eq ptr addrspace(11) %72, null\r\n %77 = load i32, ptr addrspace(11) %72, align 4\r\n %78 = select i1 %.not290, i32 undef, i32 %77\r\n %.not291 = icmp eq ptr addrspace(11) %73, null\r\n %79 = load i32, ptr addrspace(11) %73, align 4\r\n %80 = select i1 %.not291, i32 undef, i32 %79\r\n %.not292 = icmp eq ptr addrspace(11) %74, null\r\n %81 = load i32, ptr addrspace(11) %74, align 4\r\n %82 = select i1 %.not292, i32 undef, i32 %81\r\n %.not293 = icmp eq ptr addrspace(11) %75, null\r\n %83 = load i32, ptr addrspace(11) %75, align 4\r\n %84 = select i1 %.not293, i32 undef, i32 %83\r\n %.not294 = icmp eq ptr addrspace(11) %76, null\r\n %85 = load i32, ptr addrspace(11) %76, align 4\r\n %86 = select i1 %.not294, i32 undef, i32 %85\r\n br label %L230\r\n\r\nL134: ; preds = %L112\r\n %87 = getelementptr inbounds i8, ptr addrspace(11) %1, i32 28\r\n %88 = getelementptr inbounds i8, ptr addrspace(11) %1, i32 32\r\n %89 = getelementptr inbounds i8, ptr addrspace(11) %1, i32 36\r\n %90 = getelementptr inbounds i8, ptr addrspace(11) %1, i32 40\r\n %91 = getelementptr inbounds i8, ptr addrspace(11) %1, i32 44\r\n %92 = getelementptr inbounds i8, ptr addrspace(11) %0, i32 28\r\n %93 = getelementptr inbounds i8, ptr addrspace(11) %0, i32 36\r\n %94 = getelementptr inbounds i8, ptr addrspace(11) %0, i32 40\r\n %95 = getelementptr inbounds i8, ptr addrspace(11) %0, i32 44\r\n %96 = load i32, ptr addrspace(11) %87, align 4\r\n %97 = load i32, ptr addrspace(11) %92, align 4\r\n %.not300 = icmp eq i32 %96, %97\r\n br i1 %.not300, label %L150, label %L149\r\n\r\nL149: ; preds = %L134\r\n %98 = add i32 %96, 1\r\n %.not301 = icmp eq ptr addrspace(11) %88, null\r\n %99 = load i32, ptr addrspace(11) %88, align 4\r\n %100 = select i1 %.not301, i32 undef, i32 %99\r\n %.not302 = icmp eq ptr addrspace(11) %89, null\r\n %101 = load i32, ptr addrspace(11) %89, align 4\r\n %102 = select i1 %.not302, i32 undef, i32 %101\r\n %.not303 = icmp eq ptr addrspace(11) %90, null\r\n %103 = load i32, ptr addrspace(11) %90, align 4\r\n %104 = select i1 %.not303, i32 undef, i32 %103\r\n %.not304 = icmp eq ptr addrspace(11) %91, null\r\n %105 = load i32, ptr addrspace(11) %91, align 4\r\n %106 = select i1 %.not304, i32 undef, i32 %105\r\n br label %L230\r\n\r\nL150: ; preds = %L134\r\n %107 = getelementptr inbounds i8, ptr addrspace(11) %0, i32 32\r\n %108 = load i32, ptr addrspace(11) %88, align 4\r\n %109 = load i32, ptr addrspace(11) %107, align 4\r\n %.not305 = icmp eq i32 %108, %109\r\n br i1 %.not305, label %L156, label %L155\r\n\r\nL155: ; preds = %L150\r\n %110 = add i32 %108, 1\r\n %.not306 = icmp eq ptr addrspace(11) %89, null\r\n %111 = load i32, ptr addrspace(11) %89, align 4\r\n %112 = select i1 %.not306, i32 undef, i32 %111\r\n %.not307 = icmp eq ptr addrspace(11) %90, null\r\n %113 = load i32, ptr addrspace(11) %90, align 4\r\n %114 = select i1 %.not307, i32 undef, i32 %113\r\n %.not308 = icmp eq ptr addrspace(11) %91, null\r\n %115 = load i32, ptr addrspace(11) %91, align 4\r\n %116 = select i1 %.not308, i32 undef, i32 %115\r\n br label %L230\r\n\r\nL156: ; preds = %L150\r\n %117 = load i32, ptr addrspace(11) %89, align 4\r\n %118 = load i32, ptr addrspace(11) %93, align 4\r\n %.not309 = icmp eq i32 %117, %118\r\n br i1 %.not309, label %L162, label %L161\r\n\r\nL161: ; preds = %L156\r\n %119 = add i32 %117, 1\r\n %.not310 = icmp eq ptr addrspace(11) %90, null\r\n %120 = load i32, ptr addrspace(11) %90, align 4\r\n %121 = select i1 %.not310, i32 undef, i32 %120\r\n %.not311 = icmp eq ptr addrspace(11) %91, null\r\n %122 = load i32, ptr addrspace(11) %91, align 4\r\n %123 = select i1 %.not311, i32 undef, i32 %122\r\n br label %L230\r\n\r\nL162: ; preds = %L156\r\n %124 = load i32, ptr addrspace(11) %90, align 4\r\n %125 = load i32, ptr addrspace(11) %94, align 4\r\n %.not312 = icmp eq i32 %124, %125\r\n br i1 %.not312, label %L195, label %L167\r\n\r\nL167: ; preds = %L162\r\n %126 = add i32 %124, 1\r\n %.not313 = icmp eq ptr addrspace(11) %91, null\r\n %127 = load i32, ptr addrspace(11) %91, align 4\r\n %128 = select i1 %.not313, i32 undef, i32 %127\r\n br label %L230\r\n\r\nL195: ; preds = %L162\r\n %129 = load i32, ptr addrspace(11) %91, align 4\r\n %130 = add i32 %129, 1\r\n %131 = load i32, ptr addrspace(11) %95, align 4\r\n %132 = icmp eq i32 %129, %131\r\n br i1 %132, label %common.ret, label %L230\r\n\r\ncommon.ret: ; preds = %L87, %L195, %L230\r\n %common.ret.op = phi { ptr addrspace(10), i8 } [ { ptr addrspace(10) null, i8 2 }, %L230 ], [ { ptr addrspace(10) null, i8 1 }, %L195 ], [ { ptr addrspace(10) null, i8 1 }, %L87 ]\r\n ret { ptr addrspace(10), i8 } %common.ret.op\r\n\r\nL230: ; preds = %L195, %L128, %L149, %L155, %L161, %L167\r\n %value_phi29359 = phi i32 [ %130, %L195 ], [ %128, %L167 ], [ %123, %L161 ], [ %116, %L155 ], [ %106, %L149 ], [ %86, %L128 ]\r\n %value_phi28358 = phi i32 [ 1, %L195 ], [ %126, %L167 ], [ %121, %L161 ], [ %114, %L155 ], [ %104, %L149 ], [ %84, %L128 ]\r\n %value_phi27357 = phi i32 [ 1, %L195 ], [ 1, %L167 ], [ %119, %L161 ], [ %112, %L155 ], [ %102, %L149 ], [ %82, %L128 ]\r\n %value_phi26356 = phi i32 [ 1, %L195 ], [ 1, %L167 ], [ 1, %L161 ], [ %110, %L155 ], [ %100, %L149 ], [ %80, %L128 ]\r\n %value_phi25355 = phi i32 [ 1, %L195 ], [ 1, %L167 ], [ 1, %L161 ], [ 1, %L155 ], [ %98, %L149 ], [ %78, %L128 ]\r\n %value_phi18349 = phi i32 [ 1, %L195 ], [ 1, %L167 ], [ 1, %L161 ], [ 1, %L155 ], [ 1, %L149 ], [ %71, %L128 ]\r\n store i32 %value_phi2326, ptr %union_bytes_return, align 4\r\n %.sroa.0429.sroa.0.sroa.2.0.union_bytes_return.sroa_idx = getelementptr inbounds i8, ptr %union_bytes_return, i32 4\r\n store i32 %value_phi9332, ptr %.sroa.0429.sroa.0.sroa.2.0.union_bytes_return.sroa_idx, align 4\r\n %.sroa.0429.sroa.0.sroa.3.0.union_bytes_return.sroa_idx = getelementptr inbounds i8, ptr %union_bytes_return, i32 8\r\n store i32 %value_phi10333, ptr %.sroa.0429.sroa.0.sroa.3.0.union_bytes_return.sroa_idx, align 4\r\n %.sroa.0429.sroa.0.sroa.4.0.union_bytes_return.sroa_idx = getelementptr inbounds i8, ptr %union_bytes_return, i32 12\r\n store i32 %value_phi11334, ptr %.sroa.0429.sroa.0.sroa.4.0.union_bytes_return.sroa_idx, align 4\r\n %.sroa.0429.sroa.0.sroa.5.0.union_bytes_return.sroa_idx = getelementptr inbounds i8, ptr %union_bytes_return, i32 16\r\n store i32 %value_phi12335, ptr %.sroa.0429.sroa.0.sroa.5.0.union_bytes_return.sroa_idx, align 4\r\n %.sroa.0429.sroa.0.sroa.6.0.union_bytes_return.sroa_idx = getelementptr inbounds i8, ptr %union_bytes_return, i32 20\r\n store i32 %value_phi13336, ptr %.sroa.0429.sroa.0.sroa.6.0.union_bytes_return.sroa_idx, align 4\r\n %.sroa.0429.sroa.2.0.union_bytes_return.sroa_idx = getelementptr inbounds i8, ptr %union_bytes_return, i32 24\r\n store i32 %value_phi18349, ptr %.sroa.0429.sroa.2.0.union_bytes_return.sroa_idx, align 4\r\n %.sroa.0429.sroa.3.0.union_bytes_return.sroa_idx = getelementptr inbounds i8, ptr %union_bytes_return, i32 28\r\n store i32 %value_phi25355, ptr %.sroa.0429.sroa.3.0.union_bytes_return.sroa_idx, align 4\r\n %.sroa.0429.sroa.4.0.union_bytes_return.sroa_idx = getelementptr inbounds i8, ptr %union_bytes_return, i32 32\r\n store i32 %value_phi26356, ptr %.sroa.0429.sroa.4.0.union_bytes_return.sroa_idx, align 4\r\n %.sroa.0429.sroa.5.0.union_bytes_return.sroa_idx = getelementptr inbounds i8, ptr %union_bytes_return, i32 36\r\n store i32 %value_phi27357, ptr %.sroa.0429.sroa.5.0.union_bytes_return.sroa_idx, align 4\r\n %.sroa.0429.sroa.6.0.union_bytes_return.sroa_idx = getelementptr inbounds i8, ptr %union_bytes_return, i32 40\r\n store i32 %value_phi28358, ptr %.sroa.0429.sroa.6.0.union_bytes_return.sroa_idx, align 4\r\n %.sroa.0429.sroa.7.0.union_bytes_return.sroa_idx = getelementptr inbounds i8, ptr %union_bytes_return, i32 44\r\n store i32 %value_phi29359, ptr %.sroa.0429.sroa.7.0.union_bytes_return.sroa_idx, align 4\r\n %.sroa.0429.sroa.8.0.union_bytes_return.sroa_idx = getelementptr inbounds i8, ptr %union_bytes_return, i32 48\r\n store i32 %value_phi2326, ptr %.sroa.0429.sroa.8.0.union_bytes_return.sroa_idx, align 4\r\n %.sroa.0429.sroa.8.sroa.2.0..sroa.0429.sroa.8.0.union_bytes_return.sroa_idx.sroa_idx = getelementptr inbounds i8, ptr %union_bytes_return, i32 52\r\n store i32 %value_phi9332, ptr %.sroa.0429.sroa.8.sroa.2.0..sroa.0429.sroa.8.0.union_bytes_return.sroa_idx.sroa_idx, align 4\r\n %.sroa.0429.sroa.8.sroa.3.0..sroa.0429.sroa.8.0.union_bytes_return.sroa_idx.sroa_idx = getelementptr inbounds i8, ptr %union_bytes_return, i32 56\r\n store i32 %value_phi10333, ptr %.sroa.0429.sroa.8.sroa.3.0..sroa.0429.sroa.8.0.union_bytes_return.sroa_idx.sroa_idx, align 4\r\n %.sroa.0429.sroa.8.sroa.4.0..sroa.0429.sroa.8.0.union_bytes_return.sroa_idx.sroa_idx = getelementptr inbounds i8, ptr %union_bytes_return, i32 60\r\n store i32 %value_phi11334, ptr %.sroa.0429.sroa.8.sroa.4.0..sroa.0429.sroa.8.0.union_bytes_return.sroa_idx.sroa_idx, align 4\r\n %.sroa.0429.sroa.8.sroa.5.0..sroa.0429.sroa.8.0.union_bytes_return.sroa_idx.sroa_idx = getelementptr inbounds i8, ptr %union_bytes_return, i32 64\r\n store i32 %value_phi12335, ptr %.sroa.0429.sroa.8.sroa.5.0..sroa.0429.sroa.8.0.union_bytes_return.sroa_idx.sroa_idx, align 4\r\n %.sroa.0429.sroa.8.sroa.6.0..sroa.0429.sroa.8.0.union_bytes_return.sroa_idx.sroa_idx = getelementptr inbounds i8, ptr %union_bytes_return, i32 68\r\n store i32 %value_phi13336, ptr %.sroa.0429.sroa.8.sroa.6.0..sroa.0429.sroa.8.0.union_bytes_return.sroa_idx.sroa_idx, align 4\r\n %.sroa.4430.0.union_bytes_return.sroa_idx = getelementptr inbounds i8, ptr %union_bytes_return, i32 72\r\n store i32 %value_phi18349, ptr %.sroa.4430.0.union_bytes_return.sroa_idx, align 4\r\n %.sroa.5431.0.union_bytes_return.sroa_idx = getelementptr inbounds i8, ptr %union_bytes_return, i32 76\r\n store i32 %value_phi25355, ptr %.sroa.5431.0.union_bytes_return.sroa_idx, align 4\r\n %.sroa.6432.0.union_bytes_return.sroa_idx = getelementptr inbounds i8, ptr %union_bytes_return, i32 80\r\n store i32 %value_phi26356, ptr %.sroa.6432.0.union_bytes_return.sroa_idx, align 4\r\n %.sroa.7433.0.union_bytes_return.sroa_idx = getelementptr inbounds i8, ptr %union_bytes_return, i32 84\r\n store i32 %value_phi27357, ptr %.sroa.7433.0.union_bytes_return.sroa_idx, align 4\r\n %.sroa.8434.0.union_bytes_return.sroa_idx = getelementptr inbounds i8, ptr %union_bytes_return, i32 88\r\n store i32 %value_phi28358, ptr %.sroa.8434.0.union_bytes_return.sroa_idx, align 4\r\n %.sroa.9435.0.union_bytes_return.sroa_idx = getelementptr inbounds i8, ptr %union_bytes_return, i32 92\r\n store i32 %value_phi29359, ptr %.sroa.9435.0.union_bytes_return.sroa_idx, align 4\r\n br label %common.ret\r\n}\r\n\r\ndeclare ptr @julia.get_pgcstack()\r\n\r\n; Function Attrs: memory(argmem: readwrite, inaccessiblemem: readwrite)\r\ndeclare void @julia.safepoint(ptr) #2\r\n\r\n; Function Attrs: willreturn memory(argmem: read, inaccessiblemem: readwrite)\r\ndeclare nonnull align 16 dereferenceable(16) ptr addrspace(10) @jl_alloc_genericmemory(ptr addrspace(10), i32) #3\r\n\r\n; Function Attrs: nounwind willreturn allockind(\"alloc\") allocsize(1) memory(argmem: read, inaccessiblemem: readwrite)\r\ndeclare noalias nonnull ptr addrspace(10) @julia.gc_alloc_obj(ptr, i32, ptr addrspace(10)) #4\r\n\r\n; Function Attrs: norecurse nosync nounwind speculatable willreturn memory(none)\r\ndeclare noundef nonnull ptr addrspace(13) @julia.gc_loaded(ptr addrspace(10) nocapture noundef nonnull readnone, ptr noundef nonnull readnone) #5\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)\r\ndeclare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #6\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)\r\ndeclare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #6\r\n```\r\ngives error \r\n```\r\nInstruction does not dominate all uses!\r\n %20 = shufflevector <4 x ptr addrspace(11)> %19, <4 x ptr addrspace(11)> poison, <4 x i32> zeroinitializer\r\n %17 = shufflevector <4 x ptr addrspace(11)> %20, <4 x ptr addrspace(11)> poison, <2 x i32> zeroinitializer\r\nInstruction does not dominate all uses!\r\n %90 = shufflevector <4 x ptr addrspace(11)> %89, <4 x ptr addrspace(11)> poison, <4 x i32> zeroinitializer\r\n %87 = shufflevector <4 x ptr addrspace(11)> %90, <4 x ptr addrspace(11)> poison, <2 x i32> zeroinitializer\r\nLLVM ERROR: Broken module found, compilation aborted!\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer <source>\r\n1.\tRunning pass \"verify\" on module \"<source>\"\r\n #0 0x00000000050e6958 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x50e6958)\r\n #1 0x00000000050e434c SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007508e6a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x00007508e6a969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x00007508e6a42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x00007508e6a287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00000000007d7105 llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0\r\n #7 0x00000000050254d8 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x50254d8)\r\n #8 0x0000000004f23440 llvm::VerifierPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f23440)\r\n #9 0x00000000009000ae llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9000ae)\r\n#10 0x0000000004ee6850 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4ee6850)\r\n#11 0x000000000090adda llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x90adda)\r\n#12 0x00000000008fdd2a optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8fdd2a)\r\n#13 0x00007508e6a29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#14 0x00007508e6a29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#15 0x00000000008f57ae _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8f57ae)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```\r\nhttps://godbolt.org/z/sah34KE77",
"author": "Zentrik",
"labels": [
"miscompilation",
"llvm:SLPVectorizer"
],
"comments": [
{
"author": "Zentrik",
"body": "Reduced IR:\r\n```llvm\r\ndefine swiftcc { ptr addrspace(10), i8 } @julia__zip_iterate_all_17381(ptr addrspace(11) %0, i32 %1) {\r\ntop:\r\n %2 = getelementptr i8, ptr addrspace(11) %0, i32 8\r\n %3 = getelementptr i8, ptr addrspace(11) %0, i32 12\r\n %4 = getelementptr i8, ptr addrspace(11) %0, i32 16\r\n %5 = getelementptr i8, ptr addrspace(11) %0, i32 20\r\n br i1 false, label %L42, label %L41\r\n\r\nL41: ; preds = %top\r\n %.not276 = icmp eq ptr addrspace(11) %2, null\r\n %6 = select i1 %.not276, i32 0, i32 0\r\n %.not277 = icmp eq ptr addrspace(11) %3, null\r\n %7 = select i1 %.not277, i32 0, i32 0\r\n %.not278 = icmp eq ptr addrspace(11) %4, null\r\n %8 = select i1 %.not278, i32 0, i32 0\r\n %.not279 = icmp eq ptr addrspace(11) %5, null\r\n %9 = select i1 %.not279, i32 0, i32 0\r\n br label %common.ret\r\n\r\nL42: ; preds = %top\r\n %.not282 = icmp eq ptr addrspace(11) %4, null\r\n %10 = select i1 %.not282, i32 0, i32 0\r\n %.not283 = icmp eq ptr addrspace(11) %5, null\r\n %11 = select i1 %.not283, i32 0, i32 0\r\n br label %common.ret\r\n\r\nL59: ; No predecessors!\r\n %12 = select i1 false, i32 0, i32 0\r\n br label %common.ret\r\n\r\ncommon.ret: ; preds = %L59, %L42, %L41\r\n %value_phi13336 = phi i32 [ %12, %L59 ], [ %11, %L42 ], [ %9, %L41 ]\r\n %value_phi12335 = phi i32 [ 0, %L59 ], [ %10, %L42 ], [ %8, %L41 ]\r\n %value_phi11334 = phi i32 [ 0, %L59 ], [ %1, %L42 ], [ %7, %L41 ]\r\n %value_phi10333 = phi i32 [ 0, %L59 ], [ 0, %L42 ], [ %6, %L41 ]\r\n ret { ptr addrspace(10), i8 } zeroinitializer\r\n}\r\n```\r\nhttps://godbolt.org/z/a8xzqGYo9"
},
{
"author": "Zentrik",
"body": "Bisected to 69332bb8995aef60d830406de12cb79a5039026 and f3d2609af3031ddb54030548e86335f295cf49ca, @alexey-bataev "
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
129373
|
https://github.com/llvm/llvm-project/issues/129373
|
hang
|
88460137d97c0b8d3742203e0173ab9ed6c5c8a7
| 2025-03-01T09:39:32 |
[
"llvm/test/Transforms/VectorCombine"
] |
{
"fix_commit": "5ddf40fa78705384966c22da78e12134df7bd723",
"components": [
"VectorCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [
[
1579,
1584
]
],
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [
"VectorCombine::scalarizeLoadExtract"
],
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 5ddf40fa78705384966c22da78e12134df7bd723
Author: Simon Pilgrim <llvm-dev@redking.me.uk>
Date: Sat Mar 1 16:54:22 2025 +0000
[VectorCombine] scalarizeLoadExtract - don't create scalar loads if any extract is waiting to be erased (#129375)
If any extract is waiting to be erased, then bail out as this will distort the cost calculation and possibly lead to infinite loops.
Fixes #129373
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index bb4e1c0f67e7..2e8458e2cd03 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -1579,6 +1579,11 @@ bool VectorCombine::scalarizeLoadExtract(Instruction &I) {
if (!UI || UI->getParent() != LI->getParent())
return false;
+ // If any extract is waiting to be erased, then bail out as this will
+ // distort the cost calculation and possibly lead to infinite loops.
+ if (UI->use_empty())
+ return false;
+
// Check if any instruction between the load and the extract may modify
// memory.
if (LastCheckedInst->comesBefore(UI)) {
|
[
{
"file": "llvm/test/Transforms/VectorCombine/X86/load-extractelement-scalarization.ll",
"commands": [
"opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=sse2",
"opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=avx2"
],
"tests": [
{
"test_name": "multiple_extract",
"test_body": "define void @multiple_extract(ptr %p) {\n %vp = load ptr, ptr %p, align 8\n %v = load <2 x i32>, ptr %vp, align 16\n %e0 = extractelement <2 x i32> %v, i64 0\n %e1 = extractelement <2 x i32> %v, i64 1\n store i32 %e0, ptr %p, align 4\n %p1 = getelementptr inbounds nuw i8, ptr %p, i64 4\n store i32 %e1, ptr %p1, align 4\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "unused_extract",
"test_body": "define void @unused_extract(ptr %p) {\n %load = load <4 x float>, ptr %p, align 8\n %shuffle0 = shufflevector <4 x float> zeroinitializer, <4 x float> %load, <4 x i32> <i32 0, i32 4, i32 1, i32 5>\n %shuffle1 = shufflevector <4 x float> %shuffle0, <4 x float> zeroinitializer, <4 x i32> <i32 0, i32 4, i32 poison, i32 poison>\n %extract = extractelement <4 x float> %load, i64 1\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[VectorCombine] scalarizeLoadExtract - infinite loop if we scalarize a dead extract waiting to be erased",
"body": "Reduced test case:\n\n```ll\ndefine void @infinite_loop(ptr %p0) {\n %load = load <4 x float>, ptr %p0, align 8\n %shuffle0 = shufflevector <4 x float> zeroinitializer, <4 x float> %load, <4 x i32> <i32 0, i32 4, i32 1, i32 5>\n %shuffle1 = shufflevector <4 x float> %shuffle0, <4 x float> zeroinitializer, <4 x i32> <i32 0, i32 4, i32 poison, i32 poison>\n %extract = extractelement <4 x float> %load, i64 1\n ret void\n}\n```\n\nscalarizeLoadExtract iterates across all users of a load, and doesn't account for possible orders in the worklist that prevent unused instructions that use the load from being erased afterward.\n\nFix incoming",
"author": "RKSimon",
"labels": [
"release:backport",
"vectorizers",
"hang"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
141237
|
https://github.com/llvm/llvm-project/issues/141237
|
crash
|
af2a957ce30e3d91e17e2194e4be0a6b6481e4ba
| 2025-05-23T15:00:13 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "a9b2998e315af64b7a68606af9064db425699c39",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
[
7082,
7087
],
[
7315,
7321
],
[
7352,
7357
],
[
7477,
7485
]
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": [
[
364,
369
]
],
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"LoopVectorizationPlanner::computeBestVF",
"VPCostContext::getLegacyCost",
"VPCostContext::skipCostComputation",
"planContainsAdditionalSimplifications"
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit a9b2998e315af64b7a68606af9064db425699c39
Author: Florian Hahn <flo@fhahn.com>
Date: Sat May 24 11:09:27 2025 +0100
[VPlan] Skip cost assert if VPlan converted to single-scalar recipes.
Check if a VPlan transform converted recipes to single-scalar
VPReplicateRecipes (after 07c085af3efcd67503232f99a1652efc6e54c1a9). If
that's the case, the legacy cost model incorrectly overestimates the cost.
Fixes https://github.com/llvm/llvm-project/issues/141237.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 275b3d567856..8a35afbb73f3 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7082,6 +7082,11 @@ InstructionCost VPCostContext::getLegacyCost(Instruction *UI,
return CM.getInstructionCost(UI, VF);
}
+bool VPCostContext::isLegacyUniformAfterVectorization(Instruction *I,
+ ElementCount VF) const {
+ return CM.isUniformAfterVectorization(I, VF);
+}
+
bool VPCostContext::skipCostComputation(Instruction *UI, bool IsVector) const {
return CM.ValuesToIgnore.contains(UI) ||
(IsVector && CM.VecValuesToIgnore.contains(UI)) ||
@@ -7315,7 +7320,8 @@ InstructionCost LoopVectorizationPlanner::cost(VPlan &Plan,
/// cost-model did not account for.
static bool planContainsAdditionalSimplifications(VPlan &Plan,
VPCostContext &CostCtx,
- Loop *TheLoop) {
+ Loop *TheLoop,
+ ElementCount VF) {
// First collect all instructions for the recipes in Plan.
auto GetInstructionForCost = [](const VPRecipeBase *R) -> Instruction * {
if (auto *S = dyn_cast<VPSingleDefRecipe>(R))
@@ -7352,6 +7358,16 @@ static bool planContainsAdditionalSimplifications(VPlan &Plan,
// comparing against the legacy cost isn't desirable.
if (isa<VPPartialReductionRecipe>(&R))
return true;
+
+ /// If a VPlan transform folded a recipe to one producing a single-scalar,
+ /// but the original instruction wasn't uniform-after-vectorization in the
+ /// legacy cost model, the legacy cost overestimates the actual cost.
+ if (auto *RepR = dyn_cast<VPReplicateRecipe>(&R)) {
+ if (RepR->isSingleScalar() &&
+ !CostCtx.isLegacyUniformAfterVectorization(
+ RepR->getUnderlyingInstr(), VF))
+ return true;
+ }
if (Instruction *UI = GetInstructionForCost(&R)) {
// If we adjusted the predicate of the recipe, the cost in the legacy
// cost model may be different.
@@ -7477,9 +7493,10 @@ VectorizationFactor LoopVectorizationPlanner::computeBestVF() {
// legacy cost model doesn't properly model costs for such loops.
assert((BestFactor.Width == LegacyVF.Width || BestPlan.hasEarlyExit() ||
planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width),
- CostCtx, OrigLoop) ||
- planContainsAdditionalSimplifications(getPlanFor(LegacyVF.Width),
- CostCtx, OrigLoop)) &&
+ CostCtx, OrigLoop,
+ BestFactor.Width) ||
+ planContainsAdditionalSimplifications(
+ getPlanFor(LegacyVF.Width), CostCtx, OrigLoop, LegacyVF.Width)) &&
" VPlan cost model and legacy cost model disagreed");
assert((BestFactor.Width.isScalar() || BestFactor.ScalarCost > 0) &&
"when vectorizing, the scalar cost must be computed.");
diff --git a/llvm/lib/Transforms/Vectorize/VPlanHelpers.h b/llvm/lib/Transforms/Vectorize/VPlanHelpers.h
index 1d42c8f5f373..0446991ebfff 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanHelpers.h
+++ b/llvm/lib/Transforms/Vectorize/VPlanHelpers.h
@@ -364,6 +364,11 @@ struct VPCostContext {
/// Returns the OperandInfo for \p V, if it is a live-in.
TargetTransformInfo::OperandValueInfo getOperandInfo(VPValue *V) const;
+
+ /// Return true if \p I is considered uniform-after-vectorization in the
+ /// legacy cost model for \p VF. Only used to check for additional VPlan
+ /// simplifications.
+ bool isLegacyUniformAfterVectorization(Instruction *I, ElementCount VF) const;
};
/// This class can be used to assign names to VPValues. For VPValues without
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/X86/uniform_load.ll",
"commands": [
"opt -passes=loop-vectorize -S %s"
],
"tests": [
{
"test_name": "foo",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@inc = external global float, align 4\n\ndefine void @foo(ptr noalias captures(none) %A, i64 %N) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %l.inc = load float, ptr @inc, align 4\n %gep.A = getelementptr inbounds float, ptr %A, i64 %iv\n %l.A = load float, ptr %gep.A, align 4\n %add = fadd float %l.inc, %l.A\n store float %add, ptr %gep.A, align 4\n %iv.next = add nuw nsw i64 %iv, 1\n %ec = icmp eq i64 %iv.next, 32\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { \"target-cpu\"=\"core-avx2\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "uniform_load_can_fold_users",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @uniform_load_can_fold_users(ptr noalias %src, ptr %dst, i64 %start, double %d) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv.1 = phi i64 [ 0, %entry ], [ %iv.1.next, %loop ]\n %iv.2 = phi i64 [ %start, %entry ], [ %iv.2.next, %loop ]\n %l = load double, ptr %src, align 8\n %m = fmul double %l, 9.000000e+00\n %div = fdiv double %m, %d\n %sub = sub i64 %iv.1, 1\n %gep.1 = getelementptr double, ptr %dst, i64 %iv.1\n %gep.2 = getelementptr double, ptr %gep.1, i64 %sub\n store double %div, ptr %gep.2, align 8\n %iv.1.next = add i64 %iv.1, 1\n %iv.2.next = add i64 %iv.2, -1\n %ec = icmp sgt i64 %iv.2, 0\n br i1 %ec, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Crash in LoopVectorizationPlanner::computeBestVF()",
"body": "Reduced reproducer:\n```\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @reduced_test_(ptr %0, i64 %1, ptr %.sroa.067.0.copyload) {\n._crit_edge103:\n br label %2\n\n2: ; preds = %2, %._crit_edge103\n %indvars.iv = phi i64 [ 0, %._crit_edge103 ], [ %indvars.iv.next, %2 ]\n %3 = phi i64 [ %1, %._crit_edge103 ], [ %10, %2 ]\n %4 = load double, ptr %0, align 8\n %5 = fmul double %4, 0.000000e+00\n %6 = fdiv double %5, 0.000000e+00\n %7 = sub i64 %indvars.iv, %1\n %8 = getelementptr double, ptr %.sroa.067.0.copyload, i64 %indvars.iv\n %9 = getelementptr double, ptr %8, i64 %7\n store double %6, ptr %9, align 8\n %indvars.iv.next = add i64 %indvars.iv, 1\n %10 = add i64 %3, -1\n %11 = icmp sgt i64 %3, 0\n br i1 %11, label %2, label %._crit_edge106\n\n._crit_edge106: ; preds = %2\n ret void\n}\n```\nCrash:\n```\n$ opt -O2 reduced.ll \nWARNING: You're attempting to print out a bitcode file.\nThis is inadvisable as it may cause display problems. If\nyou REALLY want to taste LLVM bitcode first-hand, you\ncan force output with the `-f' option.\n\nopt: .../llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7478: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || BestPlan.hasEarlyExit() || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop) || planContainsAdditionalSimplifications(getPlanFor(LegacyVF.Width), CostCtx, OrigLoop)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0. Program arguments: opt -O2 reduced.ll\n1. Running pass \"function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-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 \"reduced.ll\"\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"reduced_test_\"\n #0 0x0000000001b16948 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (.../llvm-5162/bin/opt+0x1b16948)\n #1 0x0000000001b13bd4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007ce1f6c45330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)\n #3 0x00007ce1f6c9eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #4 0x00007ce1f6c9eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #5 0x00007ce1f6c9eb2c pthread_kill ./nptl/pthread_kill.c:89:10\n #6 0x00007ce1f6c4527e raise ./signal/../sysdeps/posix/raise.c:27:6\n #7 0x00007ce1f6c288ff abort ./stdlib/abort.c:81:7\n #8 0x00007ce1f6c2881b _nl_load_domain ./intl/loadmsgcat.c:1177:9\n #9 0x00007ce1f6c3b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)\n#10 0x0000000003b73b36 llvm::LoopVectorizationPlanner::computeBestVF() (.../llvm-5162/bin/opt+0x3b73b36)\n#11 0x0000000003b7556a llvm::LoopVectorizePass::processLoop(llvm::Loop*) (.../llvm-5162/bin/opt+0x3b7556a)\n#12 0x0000000003b78140 llvm::LoopVectorizePass::runImpl(llvm::Function&) (.../llvm-5162/bin/opt+0x3b78140)\n#13 0x0000000003b78793 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (opt+0x3b78793)\n#14 0x00000000036215ae llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) PassBuilder.cpp:0:0\n#15 0x0000000001de4030 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (opt+0x1de4030)\n#16 0x0000000002e4da6e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) NVPTXTargetMachine.cpp:0:0\n#17 0x0000000001de4543 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (opt+0x1de4543)\n#18 0x0000000002e4da2e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) NVPTXTargetMachine.cpp:0:0\n#19 0x0000000001de2160 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (opt+0x1de2160)\n#20 0x00000000034ad61a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (opt+0x34ad61a)\n...\nAborted\n```",
"author": "eugeneepshteyn",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
116809
|
https://github.com/llvm/llvm-project/issues/116809
|
crash
|
0a1795f781163a8e7b72fee492f87ab27d5e3995
| 2024-11-19T14:26:43 |
[
"llvm/test/Transforms/LICM"
] |
{
"fix_commit": "18b02bbf441660683df7f3925946984203d49bab",
"components": [
"LICM",
"MemorySSAUpdater"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": [
[
1403,
1411
]
],
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": [
[
1465,
1472
]
],
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": [
[
190,
196
]
],
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": [
"MemorySSAUpdater::createMemoryAccessBefore",
"MemorySSAUpdater::createMemoryAccessInBB"
],
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": [
"cloneInstructionInExitBlock"
],
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 18b02bbf441660683df7f3925946984203d49bab
Author: DianQK <dianqk@dianqk.net>
Date: Wed Nov 20 19:52:51 2024 +0800
[LICM] allow MemoryAccess creation failure (#116813)
Fixes #116809.
After running some passes (SimpleLoopUnswitch, LoopInstSimplify, etc.),
MemorySSA might be outdated, and the instruction `I` may have become a
non-memory touching instruction.
LICM has already handled this, but it does not pass
`CreationMustSucceed=false` to `createDefinedAccess`.
diff --git a/llvm/include/llvm/Analysis/MemorySSAUpdater.h b/llvm/include/llvm/Analysis/MemorySSAUpdater.h
index d4da3ef1146d..055feceefb05 100644
--- a/llvm/include/llvm/Analysis/MemorySSAUpdater.h
+++ b/llvm/include/llvm/Analysis/MemorySSAUpdater.h
@@ -190,7 +190,8 @@ public:
/// inaccessible and it *must* have removeMemoryAccess called on it.
MemoryAccess *createMemoryAccessInBB(Instruction *I, MemoryAccess *Definition,
const BasicBlock *BB,
- MemorySSA::InsertionPlace Point);
+ MemorySSA::InsertionPlace Point,
+ bool CreationMustSucceed = true);
/// Create a MemoryAccess in MemorySSA before an existing MemoryAccess.
///
diff --git a/llvm/lib/Analysis/MemorySSAUpdater.cpp b/llvm/lib/Analysis/MemorySSAUpdater.cpp
index aa550f0b6a7b..f672bd0e1e13 100644
--- a/llvm/lib/Analysis/MemorySSAUpdater.cpp
+++ b/llvm/lib/Analysis/MemorySSAUpdater.cpp
@@ -1403,9 +1403,11 @@ void MemorySSAUpdater::changeToUnreachable(const Instruction *I) {
MemoryAccess *MemorySSAUpdater::createMemoryAccessInBB(
Instruction *I, MemoryAccess *Definition, const BasicBlock *BB,
- MemorySSA::InsertionPlace Point) {
- MemoryUseOrDef *NewAccess = MSSA->createDefinedAccess(I, Definition);
- MSSA->insertIntoListsForBlock(NewAccess, BB, Point);
+ MemorySSA::InsertionPlace Point, bool CreationMustSucceed) {
+ MemoryUseOrDef *NewAccess = MSSA->createDefinedAccess(
+ I, Definition, /*Template=*/nullptr, CreationMustSucceed);
+ if (NewAccess)
+ MSSA->insertIntoListsForBlock(NewAccess, BB, Point);
return NewAccess;
}
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index fa04ced7182d..94bfe44a847a 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -1465,8 +1465,11 @@ static Instruction *cloneInstructionInExitBlock(
if (MSSAU.getMemorySSA()->getMemoryAccess(&I)) {
// Create a new MemoryAccess and let MemorySSA set its defining access.
+ // After running some passes, MemorySSA might be outdated, and the
+ // instruction `I` may have become a non-memory touching instruction.
MemoryAccess *NewMemAcc = MSSAU.createMemoryAccessInBB(
- New, nullptr, New->getParent(), MemorySSA::Beginning);
+ New, nullptr, New->getParent(), MemorySSA::Beginning,
+ /*CreationMustSucceed=*/false);
if (NewMemAcc) {
if (auto *MemDef = dyn_cast<MemoryDef>(NewMemAcc))
MSSAU.insertDef(MemDef, /*RenameUses=*/true);
|
[
{
"file": "llvm/test/Transforms/LICM/PR116813-memoryssa-outdated.ll",
"commands": [
"opt -passes='loop-mssa(simple-loop-unswitch<nontrivial>,licm)' -verify-memoryssa -S < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n; Check that running LICM after SimpleLoopUnswitch does not result in a crash.\n\ndefine i32 @foo(i1 %arg, ptr %arg1) {\n;\nstart:\n br label %loop\n\nloop: ; preds = %loop, %bb\n %i = select i1 %arg, ptr %arg1, ptr @bar\n %i3 = call i32 %i()\n br i1 %arg, label %loop, label %ret\n\nret: ; preds = %loop\n ret i32 %i3\n}\n\ndeclare i32 @bar() nounwind willreturn memory(none)",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SimpleLoopUnswitch][LICM] Assertion `NewAccess != nullptr && \"Tried to create a memory access for a \" \"non-memory touching instruction\"'",
"body": "The following IR triggers the assertion mentioned in the title:\r\n\r\n```llvm\r\n; opt -passes='loop-mssa(simple-loop-unswitch<nontrivial>,licm)'\r\ndefine i32 @foo(i1 %arg, ptr %arg1) {\r\nbb:\r\n br label %bb2\r\n\r\nbb2: ; preds = %bb2, %bb\r\n %i = select i1 %arg, ptr %arg1, ptr @bar\r\n %i3 = call i32 %i()\r\n br i1 %arg, label %bb2, label %bb4\r\n\r\nbb4: ; preds = %bb2\r\n ret i32 %i3\r\n}\r\n\r\ndeclare i32 @bar() nounwind willreturn memory(none)\r\n```\r\n\r\nhttps://llvm.godbolt.org/z/bj79jxo8x",
"author": "DianQK",
"labels": [
"crash",
"llvm:analysis",
"llvm:transforms"
],
"comments": []
}
| true |
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
| null |
106523
|
https://github.com/llvm/llvm-project/issues/106523
|
crash
|
2002533802dbe74c82476e30d093baf6d4cdee50
| 2024-08-29T10:12:29 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "2dfb1c664c0a0afc512b900c45989e247406e523",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
[
772,
777
],
[
795,
801
]
],
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": [
[
36,
46
]
],
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
"VPlanTransforms::adjustFixedOrderRecurrences",
"sinkRecurrenceUsersAfterPrevious"
],
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 2dfb1c664c0a0afc512b900c45989e247406e523
Author: Florian Hahn <flo@fhahn.com>
Date: Wed Oct 23 13:12:03 2024 -0700
[VPlan] Try to hoist Previous (and operands), if sinking fails for FORs. (#108945)
In some cases, Previous (and its operands) can be hoisted. This allows
supporting additional cases where sinking of all users of to FOR fails,
e.g. due having to sink recipes with side-effects.
This fixes a crash where we fail to create a scalar VPlan for a
first-order recurrence, but can create a vector VPlan, because the trunc
instruction of an IV which generates the previous value of the
recurrence has been optimized to a truncated induction recipe, thus
hoisting it to the beginning.
Fixes https://github.com/llvm/llvm-project/issues/106523.
PR: https://github.com/llvm/llvm-project/pull/108945
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index d50f3c0c3f3e..c6e09c4f2e6e 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -772,6 +772,105 @@ sinkRecurrenceUsersAfterPrevious(VPFirstOrderRecurrencePHIRecipe *FOR,
return true;
}
+/// Try to hoist \p Previous and its operands before all users of \p FOR.
+static bool hoistPreviousBeforeFORUsers(VPFirstOrderRecurrencePHIRecipe *FOR,
+ VPRecipeBase *Previous,
+ VPDominatorTree &VPDT) {
+ if (Previous->mayHaveSideEffects() || Previous->mayReadFromMemory())
+ return false;
+
+ // Collect recipes that need hoisting.
+ SmallVector<VPRecipeBase *> HoistCandidates;
+ SmallPtrSet<VPRecipeBase *, 8> Visited;
+ VPRecipeBase *HoistPoint = nullptr;
+ // Find the closest hoist point by looking at all users of FOR and selecting
+ // the recipe dominating all other users.
+ for (VPUser *U : FOR->users()) {
+ auto *R = dyn_cast<VPRecipeBase>(U);
+ if (!R)
+ continue;
+ if (!HoistPoint || VPDT.properlyDominates(R, HoistPoint))
+ HoistPoint = R;
+ }
+ assert(all_of(FOR->users(),
+ [&VPDT, HoistPoint](VPUser *U) {
+ auto *R = dyn_cast<VPRecipeBase>(U);
+ return !R || HoistPoint == R ||
+ VPDT.properlyDominates(HoistPoint, R);
+ }) &&
+ "HoistPoint must dominate all users of FOR");
+
+ auto NeedsHoisting = [HoistPoint, &VPDT,
+ &Visited](VPValue *HoistCandidateV) -> VPRecipeBase * {
+ VPRecipeBase *HoistCandidate = HoistCandidateV->getDefiningRecipe();
+ if (!HoistCandidate)
+ return nullptr;
+ VPRegionBlock *EnclosingLoopRegion =
+ HoistCandidate->getParent()->getEnclosingLoopRegion();
+ assert((!HoistCandidate->getParent()->getParent() ||
+ HoistCandidate->getParent()->getParent() == EnclosingLoopRegion) &&
+ "CFG in VPlan should still be flat, without replicate regions");
+ // Hoist candidate was already visited, no need to hoist.
+ if (!Visited.insert(HoistCandidate).second)
+ return nullptr;
+
+ // Candidate is outside loop region or a header phi, dominates FOR users w/o
+ // hoisting.
+ if (!EnclosingLoopRegion || isa<VPHeaderPHIRecipe>(HoistCandidate))
+ return nullptr;
+
+ // If we reached a recipe that dominates HoistPoint, we don't need to
+ // hoist the recipe.
+ if (VPDT.properlyDominates(HoistCandidate, HoistPoint))
+ return nullptr;
+ return HoistCandidate;
+ };
+ auto CanHoist = [&](VPRecipeBase *HoistCandidate) {
+ // Avoid hoisting candidates with side-effects, as we do not yet analyze
+ // associated dependencies.
+ return !HoistCandidate->mayHaveSideEffects();
+ };
+
+ if (!NeedsHoisting(Previous->getVPSingleValue()))
+ return true;
+
+ // Recursively try to hoist Previous and its operands before all users of FOR.
+ HoistCandidates.push_back(Previous);
+
+ for (unsigned I = 0; I != HoistCandidates.size(); ++I) {
+ VPRecipeBase *Current = HoistCandidates[I];
+ assert(Current->getNumDefinedValues() == 1 &&
+ "only recipes with a single defined value expected");
+ if (!CanHoist(Current))
+ return false;
+
+ for (VPValue *Op : Current->operands()) {
+ // If we reach FOR, it means the original Previous depends on some other
+ // recurrence that in turn depends on FOR. If that is the case, we would
+ // also need to hoist recipes involving the other FOR, which may break
+ // dependencies.
+ if (Op == FOR)
+ return false;
+
+ if (auto *R = NeedsHoisting(Op))
+ HoistCandidates.push_back(R);
+ }
+ }
+
+ // Order recipes to hoist by dominance so earlier instructions are processed
+ // first.
+ sort(HoistCandidates, [&VPDT](const VPRecipeBase *A, const VPRecipeBase *B) {
+ return VPDT.properlyDominates(A, B);
+ });
+
+ for (VPRecipeBase *HoistCandidate : HoistCandidates) {
+ HoistCandidate->moveBefore(*HoistPoint->getParent(),
+ HoistPoint->getIterator());
+ }
+
+ return true;
+}
+
bool VPlanTransforms::adjustFixedOrderRecurrences(VPlan &Plan,
VPBuilder &LoopBuilder) {
VPDominatorTree VPDT;
@@ -795,7 +894,8 @@ bool VPlanTransforms::adjustFixedOrderRecurrences(VPlan &Plan,
Previous = PrevPhi->getBackedgeValue()->getDefiningRecipe();
}
- if (!sinkRecurrenceUsersAfterPrevious(FOR, Previous, VPDT))
+ if (!sinkRecurrenceUsersAfterPrevious(FOR, Previous, VPDT) &&
+ !hoistPreviousBeforeFORUsers(FOR, Previous, VPDT))
return false;
// Introduce a recipe to combine the incoming and previous values of a
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.h b/llvm/lib/Transforms/Vectorize/VPlanTransforms.h
index 60a44bfb0dca..11e094db6294 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.h
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.h
@@ -36,11 +36,11 @@ struct VPlanTransforms {
GetIntOrFpInductionDescriptor,
ScalarEvolution &SE, const TargetLibraryInfo &TLI);
- /// Sink users of fixed-order recurrences after the recipe defining their
- /// previous value. Then introduce FirstOrderRecurrenceSplice VPInstructions
- /// to combine the value from the recurrence phis and previous values. The
- /// current implementation assumes all users can be sunk after the previous
- /// value, which is enforced by earlier legality checks.
+ /// Try to have all users of fixed-order recurrences appear after the recipe
+ /// defining their previous value, by either sinking users or hoisting recipes
+ /// defining their previous value (and its operands). Then introduce
+ /// FirstOrderRecurrenceSplice VPInstructions to combine the value from the
+ /// recurrence phis and previous values.
/// \returns true if all users of fixed-order recurrences could be re-arranged
/// as needed or false if it is not possible. In the latter case, \p Plan is
/// not valid.
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/X86/fixed-order-recurrence.ll",
"commands": [
"opt -passes=loop-vectorize -S -o - %s"
],
"tests": [
{
"test_name": "test_pr62954_scalar_epilogue_required",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-pc_linux\"\n\ndefine i64 @test_pr62954_scalar_epilogue_required(ptr %A, ptr noalias %B, ptr %C) {\nentry:\n %gep = getelementptr i8, ptr %A, i64 872\n %rec.start = load i64, ptr %gep, align 8\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 1, %entry ], [ %iv.next, %loop ]\n %for = phi i64 [ %rec.start, %entry ], [ %neg.iv, %loop ]\n %gep.B = getelementptr double, ptr %B, i64 %iv\n %l.B = load double, ptr %gep.B, align 8\n %neg.iv = sub nsw i64 0, %iv\n store i64 %neg.iv, ptr %gep, align 8\n %iv.next = add nuw nsw i64 %iv, 2\n %ec = icmp ugt i64 %iv, 74\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n %.in.lcssa = phi i64 [ %for, %loop ]\n %.lcssa = phi double [ %l.B, %loop ]\n store double %.lcssa, ptr %C, align 8\n ret i64 %.in.lcssa\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "thirdorderrec",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-pc_linux\"\n\ndefine void @thirdorderrec(ptr nocapture noundef readonly %x, ptr noalias nocapture noundef writeonly %y, i32 noundef %n) {\nentry:\n %cmp38 = icmp sgt i32 %n, 3\n br i1 %cmp38, label %for.body.preheader, label %for.cond.cleanup\n\nfor.body.preheader: ; preds = %entry\n %wide.trip.count = zext i32 %n to i64\n %.pre = load i8, ptr %x, align 1\n %arrayidx5.phi.trans.insert = getelementptr inbounds i8, ptr %x, i64 1\n %.pre44 = load i8, ptr %arrayidx5.phi.trans.insert, align 1\n %arrayidx12.phi.trans.insert = getelementptr inbounds i8, ptr %x, i64 2\n %.pre45 = load i8, ptr %arrayidx12.phi.trans.insert, align 1\n br label %for.body\n\nfor.cond.cleanup: ; preds = %for.body, %entry\n ret void\n\nfor.body: ; preds = %for.body, %for.body.preheader\n %0 = phi i8 [ %.pre45, %for.body.preheader ], [ %3, %for.body ]\n %1 = phi i8 [ %.pre44, %for.body.preheader ], [ %0, %for.body ]\n %2 = phi i8 [ %.pre, %for.body.preheader ], [ %1, %for.body ]\n %indvars.iv = phi i64 [ 3, %for.body.preheader ], [ %indvars.iv.next, %for.body ]\n %add8 = add i8 %1, %2\n %add15 = add i8 %add8, %0\n %arrayidx18 = getelementptr inbounds i8, ptr %x, i64 %indvars.iv\n %3 = load i8, ptr %arrayidx18, align 1\n %add21 = add i8 %add15, %3\n %arrayidx24 = getelementptr inbounds i8, ptr %y, i64 %indvars.iv\n store i8 %add21, ptr %arrayidx24, align 1\n %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1\n %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count\n br i1 %exitcond.not, label %for.cond.cleanup, label %for.body\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "for_iv_trunc_optimized",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-pc_linux\"\n\ndefine void @for_iv_trunc_optimized(ptr %dst) {\nbb:\n br label %loop\n\nloop: ; preds = %loop, %bb\n %iv = phi i64 [ 1, %bb ], [ %add, %loop ]\n %for.1 = phi i32 [ 1, %bb ], [ %trunc, %loop ]\n %for.2 = phi i32 [ 0, %bb ], [ %or, %loop ]\n %or = or i32 %for.1, 3\n %add = add i64 %iv, 1\n store i32 %for.2, ptr %dst, align 4\n %icmp = icmp ult i64 %iv, 337\n %trunc = trunc i64 %iv to i32\n br i1 %icmp, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "firstorderrec",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-pc_linux\"\n\ndefine void @firstorderrec(ptr nocapture noundef readonly %x, ptr noalias nocapture noundef writeonly %y, i32 noundef %n) {\nentry:\n %cmp18 = icmp sgt i32 %n, 1\n br i1 %cmp18, label %for.body.preheader, label %for.cond.cleanup\n\nfor.body.preheader: ; preds = %entry\n %wide.trip.count = zext i32 %n to i64\n %.pre = load i8, ptr %x, align 1\n br label %for.body\n\nfor.cond.cleanup: ; preds = %for.body, %entry\n ret void\n\nfor.body: ; preds = %for.body, %for.body.preheader\n %0 = phi i8 [ %.pre, %for.body.preheader ], [ %1, %for.body ]\n %indvars.iv = phi i64 [ 1, %for.body.preheader ], [ %indvars.iv.next, %for.body ]\n %arrayidx4 = getelementptr inbounds i8, ptr %x, i64 %indvars.iv\n %1 = load i8, ptr %arrayidx4, align 1\n %add7 = add i8 %1, %0\n %arrayidx10 = getelementptr inbounds i8, ptr %y, i64 %indvars.iv\n store i8 %add7, ptr %arrayidx10, align 1\n %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1\n %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count\n br i1 %exitcond.not, label %for.cond.cleanup, label %for.body\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/first-order-recurrence-chains-vplan.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -debug-only=loop-vectorize -disable-output -S %s 2>&1"
],
"tests": [
{
"test_name": "test_chained_first_order_recurrences_4",
"test_body": "define i32 @test_chained_first_order_recurrences_4(ptr %base, i64 %x) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]\n %for.x = phi i64 [ %for.x.next, %loop ], [ 0, %entry ]\n %for.y = phi i32 [ %for.x.prev, %loop ], [ 0, %entry ]\n %iv.next = add i64 %iv, 1\n %gep = getelementptr i64, ptr %base, i64 %iv\n %for.x.prev = trunc i64 %for.x to i32\n %for.y.i64 = sext i32 %for.y to i64\n store i64 %for.y.i64, ptr %gep, align 4\n %for.x.next = mul i64 %x, 2\n %icmp = icmp ugt i64 %iv, 4096\n br i1 %icmp, label %ret, label %loop\n\nret: ; preds = %loop\n ret i32 0\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_chained_first_order_recurrences_3",
"test_body": "define void @test_chained_first_order_recurrences_3(ptr %ptr) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %for.1 = phi i16 [ 22, %entry ], [ %for.1.next, %loop ]\n %for.2 = phi i16 [ 33, %entry ], [ %for.1, %loop ]\n %for.3 = phi i16 [ 33, %entry ], [ %for.2, %loop ]\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.next = add nuw nsw i64 %iv, 1\n %gep.ptr = getelementptr inbounds i16, ptr %ptr, i64 %iv\n %for.1.next = load i16, ptr %gep.ptr, align 2\n %add.1 = add i16 %for.1, %for.2\n %add.2 = add i16 %add.1, %for.3\n store i16 %add.2, ptr %gep.ptr, align 2\n %exitcond.not = icmp eq i64 %iv.next, 1000\n br i1 %exitcond.not, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_chained_first_order_recurrences_1",
"test_body": "define void @test_chained_first_order_recurrences_1(ptr %ptr) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %for.1 = phi i16 [ 22, %entry ], [ %for.1.next, %loop ]\n %for.2 = phi i16 [ 33, %entry ], [ %for.1, %loop ]\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.next = add nuw nsw i64 %iv, 1\n %gep.ptr = getelementptr inbounds i16, ptr %ptr, i64 %iv\n %for.1.next = load i16, ptr %gep.ptr, align 2\n %add = add i16 %for.1, %for.2\n store i16 %add, ptr %gep.ptr, align 2\n %exitcond.not = icmp eq i64 %iv.next, 1000\n br i1 %exitcond.not, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_chained_first_order_recurrences_5_hoist_to_load",
"test_body": "define i32 @test_chained_first_order_recurrences_5_hoist_to_load(ptr %base) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]\n %for.x = phi i64 [ %for.x.next, %loop ], [ 0, %entry ]\n %for.y = phi i32 [ %for.x.prev, %loop ], [ 0, %entry ]\n %iv.next = add i64 %iv, 1\n %gep = getelementptr i64, ptr %base, i64 %iv\n %l = load i64, ptr %gep, align 4\n %for.x.prev = trunc i64 %for.x to i32\n %for.y.i64 = sext i32 %for.y to i64\n store i64 %for.y.i64, ptr %gep, align 4\n %for.x.next = mul i64 %l, 2\n %icmp = icmp ugt i64 %iv, 4096\n br i1 %icmp, label %ret, label %loop\n\nret: ; preds = %loop\n ret i32 0\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/first-order-recurrence-multiply-recurrences.ll",
"commands": [],
"tests": [
{
"test_name": "test_pr54223_sink_after_insertion_order",
"test_body": "define void @test_pr54223_sink_after_insertion_order(ptr noalias %a, ptr noalias %b, ptr noalias %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %for.1 = phi float [ 0.000000e+00, %entry ], [ %for.1.next, %loop ]\n %for.2 = phi float [ 0.000000e+00, %entry ], [ %for.2.next, %loop ]\n %neg = fneg float %for.2\n %muladd = call float @llvm.fmuladd.f32(float %for.1, float %neg, float 0.000000e+00)\n %dst.gep = getelementptr inbounds float, ptr %dst, i64 %iv\n %iv.next = add nuw nsw i64 %iv, 1\n %for.1.next = load float, ptr %a, align 4\n %for.2.next = load float, ptr %b, align 4\n store float %muladd, ptr %dst.gep, align 4\n %exitcond.not = icmp eq i64 %iv.next, 10000\n br i1 %exitcond.not, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.fmuladd.f32(float, float, float) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_pr54233_for_depend_on_each_other",
"test_body": "define void @test_pr54233_for_depend_on_each_other(ptr noalias %a, ptr noalias %b) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %for.1 = phi i32 [ 0, %entry ], [ %for.1.next, %loop ]\n %for.2 = phi i32 [ 0, %entry ], [ %for.2.next, %loop ]\n %or = or i32 %for.2, 10\n %shl = shl i32 %for.2, %for.1\n %xor = xor i32 %shl, 255\n %and = and i32 %xor, %or\n %for.1.next = xor i32 12, %for.2\n %for.2.next = load i32, ptr %b, align 4\n %a.gep = getelementptr inbounds i32, ptr %a, i64 %iv\n store i32 %and, ptr %a.gep, align 4\n %iv.next = add nuw i64 %iv, 1\n %exitcond = icmp eq i64 %iv, 1000\n br i1 %exitcond, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Assertion `hasPlanWithVF(ScalarVF) && \"More than a single plan/VF w/o any plan having scalar VF\"' failed.",
"body": "To reproduce run the following test with -passes=loop-vectorize\r\n```\r\n; ModuleID = './reduced.ll'\r\nsource_filename = \"./reduced.ll\"\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine void @wombat() gc \"statepoint-example\" {\r\nbb:\r\n br label %bb1\r\n\r\nbb1: ; preds = %bb1, %bb\r\n %phi = phi i64 [ %add, %bb1 ], [ 1, %bb ]\r\n %phi2 = phi i32 [ %trunc, %bb1 ], [ 1, %bb ]\r\n %phi3 = phi i32 [ %or, %bb1 ], [ 0, %bb ]\r\n %or = or i32 %phi2, 0\r\n %add = add i64 %phi, 1\r\n store i32 %phi3, ptr addrspace(1) null, align 4\r\n %icmp = icmp ult i64 %phi, 337\r\n %trunc = trunc i64 %phi to i32\r\n br i1 %icmp, label %bb1, label %bb4\r\n\r\nbb4: ; preds = %bb1\r\n ret void\r\n}\r\n```\r\n\r\nReproducer: https://godbolt.org/z/e14eWvxMb\r\n\r\nStack dump:\r\n```\r\nopt: /root/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7304: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `hasPlanWithVF(ScalarVF) && \"More than a single plan/VF w/o any plan having scalar VF\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=loop-vectorize <source>\r\n1.\tRunning pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"<source>\"\r\n2.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"wombat\"\r\n #0 0x0000000004fa4138 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4fa4138)\r\n #1 0x0000000004fa18ac SignalHandler(int) Signals.cpp:0:0\r\n #2 0x000073e073a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x000073e073a969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x000073e073a42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x000073e073a287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x000073e073a2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x000073e073a39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x0000000003fe5276 llvm::LoopVectorizationPlanner::computeBestVF() (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3fe5276)\r\n #9 0x0000000004001214 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4001214)\r\n#10 0x0000000004003eb9 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4003eb9)\r\n#11 0x0000000004004543 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4004543)\r\n#12 0x0000000002ec85ae 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+0x2ec85ae)\r\n#13 0x0000000004da08f8 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4da08f8)\r\n#14 0x0000000000df11be 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+0xdf11be)\r\n#15 0x0000000004d9f2fe llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d9f2fe)\r\n#16 0x0000000000df0aae 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+0xdf0aae)\r\n#17 0x0000000004d9d490 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d9d490)\r\n#18 0x00000000008e8002 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8e8002)\r\n#19 0x00000000008daedc optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8daedc)\r\n#20 0x000073e073a29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#21 0x000073e073a29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#22 0x00000000008d296e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8d296e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139",
"author": "TatyanaDoubts",
"labels": [
"vectorizers",
"crash-on-valid"
],
"comments": [
{
"author": "fhahn",
"body": "Very interesting issue thanks! Proposed fix https://github.com/llvm/llvm-project/issues/106523"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
104714
|
https://github.com/llvm/llvm-project/issues/104714
|
crash
|
a2d8743cc86f96f6b1cbd85798328bd3fb2bf4de
| 2024-08-18T15:54:27 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "cb4efe1d078144a72306732a56afea3885650e8d",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
[
7237,
7242
],
[
7292,
7298
]
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"LoopVectorizationPlanner::computeBestVF",
"LoopVectorizationPlanner::cost"
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit cb4efe1d078144a72306732a56afea3885650e8d
Author: Florian Hahn <flo@fhahn.com>
Date: Thu Aug 22 21:38:06 2024 +0100
[VPlan] Don't trigger VF assertion if VPlan has extra simplifications.
There are cases where VPlans contain some simplifications that are very
hard to accurately account for up-front in the legacy cost model. Those
cases are caused by un-simplified inputs, which trigger the assert
ensuring both the legacy and VPlan-based cost model agree on the VF.
To avoid false positives due to missed simplifications in general, only
trigger the assert if the chosen VPlan doesn't contain any additional
simplifications.
Fixes https://github.com/llvm/llvm-project/issues/104714.
Fixes https://github.com/llvm/llvm-project/issues/105713.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 8e9324ba718b..32e8f3312578 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7237,6 +7237,56 @@ InstructionCost LoopVectorizationPlanner::cost(VPlan &Plan,
return Cost;
}
+/// Return true if the original loop \ TheLoop contains any instructions that do
+/// not have corresponding recipes in \p Plan and are not marked to be ignored
+/// in \p CostCtx. This means the VPlan contains simplification that the legacy
+/// cost-model did not account for.
+static bool
+planContainsAdditionalSimplifications(VPlan &Plan, ElementCount VF,
+ VPCostContext &CostCtx, Loop *TheLoop,
+ LoopVectorizationCostModel &CM) {
+ // First collect all instructions for the recipes in Plan.
+ auto GetInstructionForCost = [](const VPRecipeBase *R) -> Instruction * {
+ if (auto *S = dyn_cast<VPSingleDefRecipe>(R))
+ return dyn_cast_or_null<Instruction>(S->getUnderlyingValue());
+ if (auto *WidenMem = dyn_cast<VPWidenMemoryRecipe>(R))
+ return &WidenMem->getIngredient();
+ return nullptr;
+ };
+
+ DenseSet<Instruction *> SeenInstrs;
+ auto Iter = vp_depth_first_deep(Plan.getEntry());
+ for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(Iter)) {
+ for (VPRecipeBase &R : *VPBB) {
+ if (auto *IR = dyn_cast<VPInterleaveRecipe>(&R)) {
+ auto *IG = IR->getInterleaveGroup();
+ unsigned NumMembers = IG->getNumMembers();
+ for (unsigned I = 0; I != NumMembers; ++I) {
+ if (Instruction *M = IG->getMember(I))
+ SeenInstrs.insert(M);
+ }
+ continue;
+ }
+ if (Instruction *UI = GetInstructionForCost(&R))
+ SeenInstrs.insert(UI);
+ }
+ }
+
+ // Return true if the loop contains any instructions that are not also part of
+ // the VPlan or are skipped for VPlan-based cost computations. This indicates
+ // that the VPlan contains extra simplifications.
+ return any_of(
+ TheLoop->blocks(), [&SeenInstrs, VF, &CostCtx, &CM](BasicBlock *BB) {
+ return any_of(*BB, [&SeenInstrs, VF, &CostCtx, &CM](Instruction &I) {
+ if (isa<PHINode>(&I))
+ return false;
+ return !SeenInstrs.contains(&I) &&
+ !CostCtx.skipCostComputation(&I, true) &&
+ !CM.canTruncateToMinimalBitwidth(&I, VF);
+ });
+ });
+}
+
VectorizationFactor LoopVectorizationPlanner::computeBestVF() {
if (VPlans.empty())
return VectorizationFactor::Disabled();
@@ -7292,7 +7342,20 @@ VectorizationFactor LoopVectorizationPlanner::computeBestVF() {
// cost-model and will be retired once the VPlan-based cost-model is
// stabilized.
VectorizationFactor LegacyVF = selectVectorizationFactor();
- assert(BestFactor.Width == LegacyVF.Width &&
+ VPlan &BestPlan = getPlanFor(BestFactor.Width);
+
+ // Pre-compute the cost and use it to check if BestPlan contains any
+ // simplifications not accounted for in the legacy cost model. If that's the
+ // case, don't trigger the assertion, as the extra simplifications may cause a
+ // different VF to be picked by the VPlan-based cost model.
+ LLVMContext &LLVMCtx = OrigLoop->getHeader()->getContext();
+ VPCostContext CostCtx(CM.TTI, *CM.TLI, Legal->getWidestInductionType(),
+ LLVMCtx, CM);
+ precomputeCosts(BestPlan, BestFactor.Width, CostCtx);
+ assert((BestFactor.Width == LegacyVF.Width ||
+ planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width),
+ BestFactor.Width, CostCtx,
+ OrigLoop, CM)) &&
" VPlan cost model and legacy cost model disagreed");
assert((BestFactor.Width.isScalar() || BestFactor.ScalarCost > 0) &&
"when vectorizing, the scalar cost must be computed.");
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/RISCV/blocks-with-dead-instructions.ll",
"commands": [
"opt -p loop-vectorize -S %s"
],
"tests": [
{
"test_name": "empty_block_with_phi_2",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @empty_block_with_phi_2(ptr %src, i64 %N) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i32 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i32 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %loop.latch, label %else\n\nelse: ; preds = %loop.header\n br label %loop.latch\n\nloop.latch: ; preds = %else, %loop.header\n %p = phi i16 [ %l, %loop.header ], [ 99, %else ]\n store i16 %p, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 1\n %0 = icmp eq i64 %iv.next, %N\n br i1 %0, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "dead_load_in_block",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @dead_load_in_block(ptr %dst, ptr %src, i8 %N, i64 %x) #0 {\nentry:\n %N.ext = zext i8 %N to i64\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %l.0 = load i32, ptr %src, align 4\n %c.0 = icmp eq i32 %l.0, 0\n br i1 %c.0, label %loop.latch, label %then\n\nthen: ; preds = %loop.header\n %gep.src.x = getelementptr i32, ptr %src, i64 %x\n %l.dead = load i32, ptr %gep.src.x, align 4\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n %gep.dst = getelementptr i32, ptr %dst, i64 %iv\n store i32 0, ptr %gep.dst, align 4\n %iv.next = add i64 %iv, 3\n %cmp = icmp ult i64 %iv, %N.ext\n br i1 %cmp, label %loop.header, label %exit\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "multiple_blocks_with_dead_insts_3",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @multiple_blocks_with_dead_insts_3(ptr %src) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 0, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %else\n\nthen: ; preds = %loop.header\n %dead.gep.1 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nelse: ; preds = %loop.header\n %dead.gep.2 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %else, %then\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %ec = icmp eq i64 %iv.next, 1000\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "multiple_blocks_with_dead_insts_4",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @multiple_blocks_with_dead_insts_4(ptr %src, i64 %N) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %else\n\nthen: ; preds = %loop.header\n br label %then.1\n\nthen.1: ; preds = %then\n %dead.gep.1 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nelse: ; preds = %loop.header\n %dead.gep.2 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %else, %then.1\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %ec = icmp eq i64 %iv.next, %N\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "empty_block_with_phi_1",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @empty_block_with_phi_1(ptr %src, i64 %N) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i32 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i32 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %loop.latch\n\nthen: ; preds = %loop.header\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n %p = phi i16 [ %l, %loop.header ], [ 99, %then ]\n store i16 %p, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 1\n %0 = icmp eq i64 %iv.next, %N\n br i1 %0, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "block_with_dead_inst_2",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @block_with_dead_inst_2(ptr %src) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 0, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %loop.latch, label %else\n\nelse: ; preds = %loop.header\n %dead.gep = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %else, %loop.header\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %ec = icmp eq i64 %iv.next, 1000\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "multiple_blocks_with_dead_inst_multiple_successors_6",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @multiple_blocks_with_dead_inst_multiple_successors_6(ptr %src, i1 %ic, i64 %N) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %else\n\nthen: ; preds = %loop.header\n br i1 %ic, label %then.1, label %else\n\nthen.1: ; preds = %then\n %dead.gep.1 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nelse: ; preds = %then, %loop.header\n br label %else.2\n\nelse.2: ; preds = %else\n %dead.gep.2 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %else.2, %then.1\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %ec = icmp eq i64 %iv.next, %N\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "multiple_blocks_with_dead_inst_multiple_successors_5",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @multiple_blocks_with_dead_inst_multiple_successors_5(ptr %src) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %else\n\nthen: ; preds = %loop.header\n br label %then.1\n\nthen.1: ; preds = %then\n %dead.gep.1 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nelse: ; preds = %loop.header\n br label %else.2\n\nelse.2: ; preds = %else\n %dead.gep.2 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %else.2, %then.1\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %ec = icmp eq i64 %iv.next, 1000\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "block_with_dead_inst_1",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @block_with_dead_inst_1(ptr %src, i64 %N) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %loop.latch\n\nthen: ; preds = %loop.header\n %dead.gep = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %0 = icmp eq i64 %iv.next, %N\n br i1 %0, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[VPlan] Assertion `VF.Width == BestVF && \"VPlan cost model and legacy cost model disagreed\"' failed.",
"body": "Tested using d082f1f37d8cb7a0c6875537ba873a631b154d53\r\n\r\nC Testcase:\r\n```c\r\nint a;\r\nextern int b[];\r\nsigned char c;\r\nint d[1];\r\nvoid e() {\r\n for (short f = 2; f < c; f += 3) {\r\n a = ({ d[f - 1]; }) ? d[f] : 0;\r\n b[f] = 0;\r\n }\r\n}\r\n```\r\nCommand:\r\n```\r\n/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/clang -march=rv64gcv_zvl256b -O3 red.c -o /dev/null\r\n```\r\n\r\nTestcase:\r\n```llvm ir\r\n; ModuleID = 'reduced.bc'\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine void @e(i8 %0, i64 %indvars.iv) #0 {\r\nentry:\r\n %1 = zext i8 %0 to i64\r\n br label %for.body\r\n\r\nfor.cond.for.cond.cleanup_crit_edge: ; preds = %cond.end\r\n ret void\r\n\r\nfor.body: ; preds = %cond.end, %entry\r\n %indvars.iv1 = phi i64 [ 0, %entry ], [ %indvars.iv.next, %cond.end ]\r\n %sub = add i64 0, 0\r\n %arrayidx = getelementptr [1 x i32], ptr null, i64 0, i64 %sub\r\n %2 = load i32, ptr %arrayidx, align 4\r\n %tobool.not = icmp eq i32 %2, 0\r\n br i1 %tobool.not, label %cond.end, label %cond.true\r\n\r\ncond.true: ; preds = %for.body\r\n %arrayidx5 = getelementptr [1 x i32], ptr null, i64 0, i64 %indvars.iv\r\n %3 = load i32, ptr %arrayidx5, align 4\r\n br label %cond.end\r\n\r\ncond.end: ; preds = %cond.true, %for.body\r\n %arrayidx7 = getelementptr [0 x i32], ptr null, i64 0, i64 %indvars.iv1\r\n store i32 0, ptr %arrayidx7, align 4\r\n %indvars.iv.next = add i64 %indvars.iv1, 3\r\n %cmp = icmp ult i64 %indvars.iv1, %1\r\n br i1 %cmp, label %for.body, label %for.cond.for.cond.cleanup_crit_edge\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl256b,+zvl32b,+zvl64b,-b,-e,-experimental-smmpm,-experimental-smnpm,-experimental-ssnpm,-experimental-sspm,-experimental-ssqosid,-experimental-supm,-experimental-zacas,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\n```\r\n\r\nCommand/backtrace:\r\n```\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes loop-vectorize reduced.ll -S\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10037: bool llvm::LoopVectorizePass::processLoop(llvm::Loop*): Assertion `VF.Width == BestVF && \"VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes loop-vectorize reduced.ll -S\r\n1. Running pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"reduced.ll\"\r\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"e\"\r\n #0 0x000063e889a673c0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2ff63c0)\r\n #1 0x000063e889a647df llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2ff37df)\r\n #2 0x000063e889a64935 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007a5322242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007a53222969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007a53222969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007a53222969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x00007a5322242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007a53222287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x00007a532222871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x00007a5322239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x000063e888a5ba9a llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1feaa9a)\r\n#12 0x000063e888a5df51 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1fecf51)\r\n#13 0x000063e888a5e5c7 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1fed5c7)\r\n#14 0x000063e8878c6096 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe55096)\r\n#15 0x000063e88987deef llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e0ceef)\r\n#16 0x000063e8878c91d6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe581d6)\r\n#17 0x000063e88987cc6b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e0bc6b)\r\n#18 0x000063e8878c54c6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe544c6)\r\n#19 0x000063e88987accd llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e09ccd)\r\n#20 0x000063e8870f3eb6 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x682eb6)\r\n#21 0x000063e8870e5c41 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x674c41)\r\n#22 0x00007a5322229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#23 0x00007a5322229e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#24 0x00007a5322229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#25 0x000063e8870dbff5 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x66aff5)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\nGodbolt: https://godbolt.org/z/v1nbzWqMb\r\n\r\nFound via fuzzer.\r\n\r\ncc @fhahn ",
"author": "patrick-rivos",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "patrick-rivos",
"body": "Linking some meta-discussion about the assert here: https://github.com/llvm/llvm-project/issues/100591"
},
{
"author": "zhendongsu",
"body": "Some additional reproducers on x86_64-linux-gnu in case they are of help:\r\n\r\n```\r\n[519] % clangtk -v\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git 410f751144e8b2e9574f03e0d0fb8560fe3cb797)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\r\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nCandidate multilib: .;@m64\r\nSelected multilib: .;@m64\r\n[520] % \r\n[520] % clangtk -Os small.c\r\nclang-20: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7288: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `BestFactor.Width == LegacyVF.Width && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/WAIT/20240822-clangtk-m64-Os-Wall-Wextra-pipe-fPIC-build-182745/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/WAIT/20240822-clangtk-m64-Os-Wall-Wextra-pipe-fPIC-build-182745/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/20 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Os -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-e51115.o -x c small.c\r\n1.\t<eof> parser at end of file\r\n2.\tOptimizer\r\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"small.c\"\r\n4.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\r\n #0 0x00005559685ec3ef llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x42ea3ef)\r\n #1 0x00005559685e9934 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007f0380f76420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #3 0x00007f03809ad00b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #4 0x00007f038098c859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\r\n #5 0x00007f038098c729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #6 0x00007f038098c729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #7 0x00007f038099dfd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #8 0x0000555969ef4948 llvm::LoopVectorizationPlanner::computeBestVF() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5bf2948)\r\n #9 0x0000555969f0f9ea llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c0d9ea)\r\n#10 0x0000555969f12691 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c10691)\r\n#11 0x0000555969f12d43 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c10d43)\r\n#12 0x0000555969a9d326 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x579b326)\r\n#13 0x0000555967f872a1 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c852a1)\r\n#14 0x0000555965ae2ae6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x17e0ae6)\r\n#15 0x0000555967f85bed llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c83bed)\r\n#16 0x0000555965ae19e6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x17df9e6)\r\n#17 0x0000555967f83cf1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c81cf1)\r\n#18 0x00005559688a0c29 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#19 0x00005559688a3d83 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x45a1d83)\r\n#20 0x0000555968f440fa clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4c420fa)\r\n#21 0x000055596ad8938c clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x6a8738c)\r\n#22 0x0000555968f44598 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4c42598)\r\n#23 0x00005559691dec59 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4edcc59)\r\n#24 0x00005559691603be clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4e5e3be)\r\n#25 0x00005559692cb886 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4fc9886)\r\n#26 0x00005559656b5dd5 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13b3dd5)\r\n#27 0x00005559656aee7a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#28 0x00005559656b284e clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13b084e)\r\n#29 0x00005559655a31bb main (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x12a11bb)\r\n#30 0x00007f038098e083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#31 0x00005559656ae90e _start (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13ac90e)\r\nclangtk: error: unable to execute command: Aborted\r\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git 410f751144e8b2e9574f03e0d0fb8560fe3cb797)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nclangtk: note: diagnostic msg: \r\n********************\r\n\r\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\r\nPreprocessed source(s) and associated run script(s) are located at:\r\nclangtk: note: diagnostic msg: /tmp/small-1b0f28.c\r\nclangtk: note: diagnostic msg: /tmp/small-1b0f28.sh\r\nclangtk: note: diagnostic msg: \r\n\r\n********************\r\n[521] % \r\n[521] % cat small.c\r\nchar a;\r\nint b, *c = &b, d[3], e;\r\nint main() {\r\n int f, g[3] = {0,0,0};\r\n g[e] = *c = 0;\r\n for (; *c < 3; (*c)++) {\r\n f = a ? b % a : 0;\r\n g[2] &= d[*c] & f;\r\n }\r\n return 0;\r\n}\r\n```\r\n\r\n```\r\n[537] % clangtk -O3 small.c\r\nclang-20: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7288: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `BestFactor.Width == LegacyVF.Width && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/WAIT/20240814-clangtk-m64-O3-build-085604/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/WAIT/20240814-clangtk-m64-O3-build-085604/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/20 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-83d1cf.o -x c small.c\r\n1.\t<eof> parser at end of file\r\n2.\tOptimizer\r\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,chr,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"small.c\"\r\n4.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\r\n #0 0x0000558427a123ef llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x42ea3ef)\r\n #1 0x0000558427a0f934 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007fa32f70a420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #3 0x00007fa32f14100b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #4 0x00007fa32f120859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\r\n #5 0x00007fa32f120729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #6 0x00007fa32f120729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #7 0x00007fa32f131fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #8 0x000055842931a948 llvm::LoopVectorizationPlanner::computeBestVF() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5bf2948)\r\n #9 0x00005584293359ea llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c0d9ea)\r\n#10 0x0000558429338691 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c10691)\r\n#11 0x0000558429338d43 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c10d43)\r\n#12 0x0000558428ec3326 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x579b326)\r\n#13 0x00005584273ad2a1 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c852a1)\r\n#14 0x0000558424f08ae6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x17e0ae6)\r\n#15 0x00005584273abbed llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c83bed)\r\n#16 0x0000558424f079e6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x17df9e6)\r\n#17 0x00005584273a9cf1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c81cf1)\r\n#18 0x0000558427cc6c29 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#19 0x0000558427cc9d83 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x45a1d83)\r\n#20 0x000055842836a0fa clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4c420fa)\r\n#21 0x000055842a1af38c clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x6a8738c)\r\n#22 0x000055842836a598 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4c42598)\r\n#23 0x0000558428604c59 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4edcc59)\r\n#24 0x00005584285863be clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4e5e3be)\r\n#25 0x00005584286f1886 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4fc9886)\r\n#26 0x0000558424adbdd5 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13b3dd5)\r\n#27 0x0000558424ad4e7a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#28 0x0000558424ad884e clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13b084e)\r\n#29 0x00005584249c91bb main (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x12a11bb)\r\n#30 0x00007fa32f122083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#31 0x0000558424ad490e _start (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13ac90e)\r\nclangtk: error: unable to execute command: Aborted\r\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git 410f751144e8b2e9574f03e0d0fb8560fe3cb797)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nclangtk: note: diagnostic msg: \r\n********************\r\n\r\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\r\nPreprocessed source(s) and associated run script(s) are located at:\r\nclangtk: note: diagnostic msg: /tmp/small-aeee73.c\r\nclangtk: note: diagnostic msg: /tmp/small-aeee73.sh\r\nclangtk: note: diagnostic msg: \r\n\r\n********************\r\n[538] % \r\n[538] % cat small.c\r\nint a[1], *d, e, f[1];\r\nstatic int b, c, *volatile g = &c;\r\nvoid h(int i) { b = b >> 1 ^ a[b ^ i & 1]; }\r\nvoid j(long i) {\r\n b = b >> 1 ^ b;\r\n b = b >> 1 ^ a[b ^ 1];\r\n h(i >> 1);\r\n h(i >> 3);\r\n h(i >> 2);\r\n h(i >> 4);\r\n h(i >> 5);\r\n}\r\nstatic void m() {\r\n int l;\r\n while (e) {\r\n c = 0;\r\n for (; c < 5; c++) {\r\n l = 0;\r\n for (; l < 7; l++)\r\n if (*d)\r\n j(f[c * l]);\r\n }\r\n }\r\n}\r\nint main() {\r\n if (e) {\r\n m();\r\n g;\r\n }\r\n return 0;\r\n}\r\n```\r\n"
},
{
"author": "fhahn",
"body": "@zhendongsu thanks for the report, it was the same issue as the test case @sjoerdmeijer shared at https://github.com/llvm/llvm-project/issues/100591, which was a different underlying issue to the one for this issue.\r\n\r\nBoth should be fixed now, please let me know if you find any other instances of this triggering."
},
{
"author": "zhendongsu",
"body": "Hi @fhahn, here is another related instance that still triggers:\r\n```\r\n[512] % clangtk -v\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git f22b1da8791edd557ce34c87190e329df2e1c892)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\r\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nCandidate multilib: .;@m64\r\nSelected multilib: .;@m64\r\n[513] % \r\n[513] % clangtk -Os small.c\r\nclang-20: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7359: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), BestFactor.Width, CostCtx, OrigLoop, CM)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/20240825-clangtk-m64-Os-Wall-Wextra-pipe-fPIC-build-043108/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20240825-clangtk-m64-Os-Wall-Wextra-pipe-fPIC-build-043108/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/20 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Os -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-d7ba19.o -x c small.c\r\n1.\t<eof> parser at end of file\r\n2.\tOptimizer\r\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"small.c\"\r\n4.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\r\n #0 0x0000564ef7a4babf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x42ddabf)\r\n #1 0x0000564ef7a49004 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007f89634f9420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #3 0x00007f8962f3000b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #4 0x00007f8962f0f859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\r\n #5 0x00007f8962f0f729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #6 0x00007f8962f0f729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #7 0x00007f8962f20fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #8 0x0000564ef9358b42 llvm::LoopVectorizationPlanner::computeBestVF() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5beab42)\r\n #9 0x0000564ef937504a llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c0704a)\r\n#10 0x0000564ef9377c81 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c09c81)\r\n#11 0x0000564ef9378333 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c0a333)\r\n#12 0x0000564ef8f026e6 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x57946e6)\r\n#13 0x0000564ef73e68d1 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c788d1)\r\n#14 0x0000564ef4f4ff46 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x17e1f46)\r\n#15 0x0000564ef73e521d llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c7721d)\r\n#16 0x0000564ef4f4ee46 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x17e0e46)\r\n#17 0x0000564ef73e3321 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c75321)\r\n#18 0x0000564ef7d04bb1 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#19 0x0000564ef7d07d73 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4599d73)\r\n#20 0x0000564ef83a840c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4c3a40c)\r\n#21 0x0000564efa1f004c clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x6a8204c)\r\n#22 0x0000564ef83a8828 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4c3a828)\r\n#23 0x0000564ef8643cb9 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4ed5cb9)\r\n#24 0x0000564ef85c543e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4e5743e)\r\n#25 0x0000564ef8730876 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4fc2876)\r\n#26 0x0000564ef4b21e55 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13b3e55)\r\n#27 0x0000564ef4b1aefa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#28 0x0000564ef4b1e8ce clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13b08ce)\r\n#29 0x0000564ef4a0f1bb main (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x12a11bb)\r\n#30 0x00007f8962f11083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#31 0x0000564ef4b1a98e _start (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13ac98e)\r\nclangtk: error: unable to execute command: Aborted\r\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git f22b1da8791edd557ce34c87190e329df2e1c892)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nclangtk: note: diagnostic msg: \r\n********************\r\n\r\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\r\nPreprocessed source(s) and associated run script(s) are located at:\r\nclangtk: note: diagnostic msg: /tmp/small-6fc973.c\r\nclangtk: note: diagnostic msg: /tmp/small-6fc973.sh\r\nclangtk: note: diagnostic msg: \r\n\r\n********************\r\n[514] % \r\n[514] % cat small.c\r\nint a, d;\r\nstatic int b = 1, c;\r\nvoid e() {\r\n while (a)\r\n b--;\r\n}\r\nint main() {\r\n for (d = 0; d < 3; d++)\r\n if (a)\r\n for (c = 0; c < 2; c++)\r\n if (b)\r\n break;\r\n return 0;\r\n}\r\n```\r\n\r\nCompiler Explorer: https://godbolt.org/z/zanjboPYo"
},
{
"author": "zhendongsu",
"body": "Hi @fhahn, another reproducer that triggers at -O{s,2,3}:\r\n```\r\n[520] % clangtk -v\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git 7e6b1504c7cf6976ac8e9012c4513ffa258bd8eb)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\r\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nCandidate multilib: .;@m64\r\nSelected multilib: .;@m64\r\n[521] % \r\n[521] % clangtk -O3 small.c\r\nclang-20: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7359: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), BestFactor.Width, CostCtx, OrigLoop, CM)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/20240826-clangtk-m64-Os-build-191303/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20240826-clangtk-m64-Os-build-191303/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/20 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-bd6e8d.o -x c small.c\r\n1.\t<eof> parser at end of file\r\n2.\tOptimizer\r\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,chr,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"small.c\"\r\n4.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\r\n #0 0x0000561e24237f5f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x42f4f5f)\r\n #1 0x0000561e242354a4 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007f7461dc8420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #3 0x00007f74617ff00b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #4 0x00007f74617de859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\r\n #5 0x00007f74617de729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #6 0x00007f74617de729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #7 0x00007f74617effd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #8 0x0000561e25b45232 llvm::LoopVectorizationPlanner::computeBestVF() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c02232)\r\n #9 0x0000561e25b616ca llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c1e6ca)\r\n#10 0x0000561e25b64301 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c21301)\r\n#11 0x0000561e25b649b3 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c219b3)\r\n#12 0x0000561e256ef0a6 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x57ac0a6)\r\n#13 0x0000561e23bd2da1 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c8fda1)\r\n#14 0x0000561e21724f86 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x17e1f86)\r\n#15 0x0000561e23bd16ed llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c8e6ed)\r\n#16 0x0000561e21723e86 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x17e0e86)\r\n#17 0x0000561e23bcf7f1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c8c7f1)\r\n#18 0x0000561e244f0f41 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#19 0x0000561e244f4103 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x45b1103)\r\n#20 0x0000561e24b9480c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4c5180c)\r\n#21 0x0000561e269dcc5c clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x6a99c5c)\r\n#22 0x0000561e24b94c28 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4c51c28)\r\n#23 0x0000561e24e30189 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4eed189)\r\n#24 0x0000561e24db162e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4e6e62e)\r\n#25 0x0000561e24f1cde6 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4fd9de6)\r\n#26 0x0000561e212f6ed5 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13b3ed5)\r\n#27 0x0000561e212eff7a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#28 0x0000561e212f394e clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13b094e)\r\n#29 0x0000561e211e41eb main (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x12a11eb)\r\n#30 0x00007f74617e0083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#31 0x0000561e212efa0e _start (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13aca0e)\r\nclangtk: error: unable to execute command: Aborted\r\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git 7e6b1504c7cf6976ac8e9012c4513ffa258bd8eb)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nclangtk: note: diagnostic msg: \r\n********************\r\n\r\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\r\nPreprocessed source(s) and associated run script(s) are located at:\r\nclangtk: note: diagnostic msg: /tmp/small-796071.c\r\nclangtk: note: diagnostic msg: /tmp/small-796071.sh\r\nclangtk: note: diagnostic msg: \r\n\r\n********************\r\n[522] % \r\n[522] % cat small.c\r\nchar a;\r\nstatic char b, *c = &b, **d = &c;\r\nint e;\r\nunsigned f;\r\nchar g(int h) { return a << h; }\r\nint main() {\r\n char ***i[2] = {&d, &d};\r\n int *j;\r\n for (; f < 3; f++) {\r\n j = &e;\r\n *j = g(**d);\r\n }\r\n return 0;\r\n}\r\n```\r\n\r\nCompiler Explorer: https://godbolt.org/z/7Y5PzTx4P"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
115465
|
https://github.com/llvm/llvm-project/issues/115465
|
miscompilation
|
d822c099eeacc69f6bf834a6373a41d0c9f84a3e
| 2024-11-08T11:25:34 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "27bf45aa36386136db179c494358670a994a98a5",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": [
[
2904,
2910
]
],
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": [
"InstCombinerImpl::visitShuffleVectorInst"
],
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 27bf45aa36386136db179c494358670a994a98a5
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Sun Nov 10 17:07:25 2024 +0800
[InstCombine] Fix poison safety of folding shufflevector into select (#115483)
We are allowed to fold shufflevector into select iff the condition is
guaranteed not to be poison or the RHS is a poison.
Alive2: https://alive2.llvm.org/ce/z/28zEWR
Closes https://github.com/llvm/llvm-project/issues/115465.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
index 454fe5a91d37..ede89b099e8d 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -2904,7 +2904,9 @@ Instruction *InstCombinerImpl::visitShuffleVectorInst(ShuffleVectorInst &SVI) {
if (auto *SI = dyn_cast<SelectInst>(LHS)) {
// We cannot do this fold for elementwise select since ShuffleVector is
// not elementwise.
- if (SI->getCondition()->getType()->isIntegerTy()) {
+ if (SI->getCondition()->getType()->isIntegerTy() &&
+ (isa<PoisonValue>(RHS) ||
+ isGuaranteedNotToBePoison(SI->getCondition()))) {
if (Instruction *I = FoldOpIntoSelect(SVI, SI))
return I;
}
|
[
{
"file": "llvm/test/Transforms/InstCombine/vec_shuffle.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "shuf_cmp_may_be_poison",
"test_body": "define <4 x i8> @shuf_cmp_may_be_poison(<4 x i8> %x, <4 x i8> %y, i1 %cmp) {\n %sel = select i1 %cmp, <4 x i8> %y, <4 x i8> <i8 0, i8 poison, i8 0, i8 poison>\n %shuf = shufflevector <4 x i8> %sel, <4 x i8> <i8 poison, i8 1, i8 poison, i8 3>, <4 x i32> <i32 0, i32 5, i32 2, i32 7>\n ret <4 x i8> %shuf\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "shuf_same_length_vec_select",
"test_body": "define <4 x i32> @shuf_same_length_vec_select(<4 x i1> %cond) {\n %sel = select <4 x i1> %cond, <4 x i32> <i32 0, i32 1, i32 2, i32 3>, <4 x i32> <i32 4, i32 5, i32 6, i32 7>\n %shuf = shufflevector <4 x i32> %sel, <4 x i32> <i32 8, i32 9, i32 10, i32 11>, <4 x i32> <i32 2, i32 1, i32 3, i32 5>\n ret <4 x i32> %shuf\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstCombine] folded select produces different result on a blended vector",
"body": "Alive2 report: https://alive2.llvm.org/ce/z/73v-ug\r\n\r\n```llvm\r\n----------------------------------------\r\ndefine <4 x i8> @sel_shuf_commute3.2(<4 x i8> %x, <4 x i8> %y, i1 %cmp) {\r\n#0:\r\n %blend = shufflevector <4 x i8> { 0, 0, 0, 0 }, <4 x i8> %y, 0, 5, 2, 3\r\n %r = select i1 %cmp, <4 x i8> %y, <4 x i8> %blend\r\n %#1 = select <4 x i1> { 0, 1, 0, 1 }, <4 x i8> { 0, 1, 2, 3 }, <4 x i8> %r\r\n ret <4 x i8> %#1\r\n}\r\n=>\r\ndefine <4 x i8> @sel_shuf_commute3.2(<4 x i8> %x, <4 x i8> %y, i1 %cmp) {\r\n#0:\r\n %#1 = shufflevector <4 x i8> %y, <4 x i8> { poison, 1, poison, 3 }, 0, 5, 2, 7\r\n %#2 = select i1 %cmp, <4 x i8> %#1, <4 x i8> { 0, 1, 0, 3 }\r\n ret <4 x i8> %#2\r\n}\r\nTransformation doesn't verify!\r\n\r\nERROR: Target is more poisonous than source\r\n\r\nExample:\r\n<4 x i8> %x = < poison, poison, poison, poison >\r\n<4 x i8> %y = < poison, poison, poison, poison >\r\ni1 %cmp = poison\r\n\r\nSource:\r\n<4 x i8> %blend = < #x00 (0), poison, #x00 (0), #x00 (0) >\r\n<4 x i8> %r = < poison, poison, poison, poison >\r\n<4 x i8> %#1 = < poison, #x01 (1), poison, #x03 (3) >\r\n\r\nTarget:\r\n<4 x i8> %#1 = < poison, #x01 (1), poison, #x03 (3) >\r\n<4 x i8> %#2 = < poison, poison, poison, poison >\r\nSource value: < poison, #x01 (1), poison, #x03 (3) >\r\nTarget value: < poison, poison, poison, poison >\r\n\r\nSummary:\r\n 0 correct transformations\r\n 1 incorrect transformations\r\n 0 failed-to-prove transformations\r\n 0 Alive2 errors\r\n```\r\n",
"author": "bongjunj",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
91177
|
https://github.com/llvm/llvm-project/issues/91177
|
miscompilation
|
de8cf69abf4f8b16d5c5ecb77a6dfb1f5c09e45a
| 2024-05-06T09:27:25 |
[
"llvm/test/Transforms/FunctionAttrs"
] |
{
"fix_commit": "f34d30cdae0f59698f660d5cc8fb993fb3441064",
"components": [
"FunctionAttrs"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": [
[
1186,
1195
]
],
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": [
"isReturnNonNull"
],
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit f34d30cdae0f59698f660d5cc8fb993fb3441064
Author: Nikita Popov <npopov@redhat.com>
Date: Tue May 7 09:47:28 2024 +0900
[FunctionAttrs] Fix incorrect nonnull inference for non-inbounds GEP (#91180)
For inbounds GEPs, if the source pointer is non-null, the result must
also be non-null. However, this does not hold for non-inbounds GEPs.
Fixes https://github.com/llvm/llvm-project/issues/91177.
diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
index 8e11cbf1cee4..26a4508aa151 100644
--- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -1186,10 +1186,15 @@ static bool isReturnNonNull(Function *F, const SCCNodeSet &SCCNodes,
switch (RVI->getOpcode()) {
// Extend the analysis by looking upwards.
case Instruction::BitCast:
- case Instruction::GetElementPtr:
case Instruction::AddrSpaceCast:
FlowsToReturn.insert(RVI->getOperand(0));
continue;
+ case Instruction::GetElementPtr:
+ if (cast<GEPOperator>(RVI)->isInBounds()) {
+ FlowsToReturn.insert(RVI->getOperand(0));
+ continue;
+ }
+ return false;
case Instruction::Select: {
SelectInst *SI = cast<SelectInst>(RVI);
FlowsToReturn.insert(SI->getTrueValue());
|
[
{
"file": "llvm/test/Transforms/FunctionAttrs/nocapture.ll",
"commands": [
"opt -passes=function-attrs -S < %s",
"opt -passes=attributor-light -S < %s"
],
"tests": [
{
"test_name": "lookup_bit",
"test_body": "@lookup_table = external global [2 x i1]\n\n; Function Attrs: nounwind memory(none)\ndefine ptr @lookup_bit(ptr %q, i32 %bitno) #0 {\n %tmp = ptrtoint ptr %q to i32\n %tmp2 = lshr i32 %tmp, %bitno\n %bit = and i32 %tmp2, 1\n %lookup = getelementptr [2 x i1], ptr @lookup_table, i32 0, i32 %bit\n ret ptr %lookup\n}\n\nattributes #0 = { nounwind memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/FunctionAttrs/nonnull.ll",
"commands": [
"opt -S -passes=function-attrs -enable-nonnull-arg-prop %s",
"opt -S -passes=attributor-light %s"
],
"tests": [
{
"test_name": "pr91177_non_inbounds_gep",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine ptr @pr91177_non_inbounds_gep(ptr nonnull %arg) {\n %res = getelementptr i8, ptr %arg, i64 -8\n ret ptr %res\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "PR43833_simple",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\n\ndeclare void @sink(ptr)\n\ndefine void @PR43833_simple(ptr %0, i32 %1) {\n %3 = icmp ne i32 %1, 0\n br i1 %3, label %4, label %7\n\n4: ; preds = %2\n %5 = zext i32 %1 to i64\n %6 = getelementptr inbounds i32, ptr %0, i64 %5\n br label %8\n\n7: ; preds = %8, %2\n ret void\n\n8: ; preds = %8, %4\n %9 = phi i32 [ 1, %4 ], [ %10, %8 ]\n tail call void @sink(ptr %6)\n %10 = add nuw nsw i32 %9, 1\n %11 = icmp eq i32 %10, %1\n br i1 %11, label %7, label %8\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[FunctionAttrs] Incorrect nonnull inference for non-inbounds GEP",
"body": "FunctionAttrs incorrectly infers that the following function returns nonnull (https://llvm.godbolt.org/z/49Kbq15xn):\r\n```llvm\r\ndefine ptr @test(ptr nonnull %arg) {\r\n %res = getelementptr i8, ptr %arg, i64 -8\r\n ret ptr %res\r\n}\r\n```\r\nThis is because the code assumes that the result of a GEP is non-null if the source is non-null here: https://github.com/llvm/llvm-project/blob/d98a78590f4f9e43fdfb69fde7d154a985e4560f/llvm/lib/Transforms/IPO/FunctionAttrs.cpp#L1189 This is not correct for non-inbounds GEPs.",
"author": "nikic",
"labels": [
"miscompilation",
"ipo"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
140994
|
https://github.com/llvm/llvm-project/issues/140994
|
miscompilation
|
7c080e267722ba14439e2f35789c5c293672ab84
| 2025-05-22T02:48:33 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "3ec0c5c7fef03985b43432c6b914c289d8a5435e",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": [
[
25,
30
],
[
3879,
3889
]
],
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": [
"InstCombinerImpl::visitSelectInst"
],
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 3ec0c5c7fef03985b43432c6b914c289d8a5435e
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Sat May 31 16:25:10 2025 +0800
[InstCombine] Propagate FMF from select instead of fcmp (#141010)
Previously,
https://github.com/llvm/llvm-project/commit/3d6b53980ce4ee855484fc8ae6ac3f99c85e48c3
propagates FMF from fcmp to avoid performance regressions. With the help
of https://github.com/llvm/llvm-project/pull/139861,
https://github.com/llvm/llvm-project/pull/141015, and
https://github.com/llvm/llvm-project/pull/141914, we can still convert
SPF into fabs/minnum/maxnum intrinsics even if some flags are missing.
This patch propagates FMF from select to address the long-standing
issue.
Closes https://github.com/llvm/llvm-project/issues/140994.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index a791fc5db669..cca5705f6b58 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -25,6 +25,7 @@
#include "llvm/IR/ConstantRange.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
+#include "llvm/IR/FMF.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
@@ -3879,11 +3880,16 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
// (X ugt Y) ? X : Y -> (X ole Y) ? Y : X
if (FCmp->hasOneUse() && FCmpInst::isUnordered(Pred)) {
FCmpInst::Predicate InvPred = FCmp->getInversePredicate();
- // FIXME: The FMF should propagate from the select, not the fcmp.
Value *NewCond = Builder.CreateFCmpFMF(InvPred, Cmp0, Cmp1, FCmp,
FCmp->getName() + ".inv");
+ // Propagate ninf/nnan from fcmp to select.
+ FastMathFlags FMF = SI.getFastMathFlags();
+ if (FCmp->hasNoNaNs())
+ FMF.setNoNaNs(true);
+ if (FCmp->hasNoInfs())
+ FMF.setNoInfs(true);
Value *NewSel =
- Builder.CreateSelectFMF(NewCond, FalseVal, TrueVal, FCmp);
+ Builder.CreateSelectFMF(NewCond, FalseVal, TrueVal, FMF);
return replaceInstUsesWith(SI, NewSel);
}
}
|
[
{
"file": "llvm/test/Transforms/InstCombine/clamp-to-minmax.ll",
"commands": [
"opt < %s -passes=instcombine -S",
"opt < %s -passes=instcombine -use-constant-fp-for-fixed-length-splat -use-constant-int-for-fixed-length-splat -S"
],
"tests": [
{
"test_name": "clamp_negative_same_op",
"test_body": "define half @clamp_negative_same_op(half %x) {\n %inner_cmp = fcmp nnan ninf nsz ult half %x, 2.550000e+02\n %inner_sel = select i1 %inner_cmp, half %x, half 2.550000e+02\n %outer_cmp = fcmp nnan ninf nsz ult half %x, 1.000000e+00\n %r = select i1 %outer_cmp, half %inner_sel, half 1.000000e+00\n ret half %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "clamp_float_fast_unordered_nonstrict_maxmin",
"test_body": "define half @clamp_float_fast_unordered_nonstrict_maxmin(half %x) {\n %cmp2 = fcmp nnan ninf nsz ult half %x, 2.550000e+02\n %min = select i1 %cmp2, half %x, half 2.550000e+02\n %cmp1 = fcmp nnan ninf nsz ule half %x, 1.000000e+00\n %r = select i1 %cmp1, half 1.000000e+00, half %min\n ret half %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "clamp_float_fast_ordered_nonstrict_minmax",
"test_body": "define half @clamp_float_fast_ordered_nonstrict_minmax(half %x) {\n %cmp2 = fcmp nnan ninf nsz ogt half %x, 1.000000e+00\n %max = select i1 %cmp2, half %x, half 1.000000e+00\n %cmp1 = fcmp nnan ninf nsz oge half %x, 2.550000e+02\n %r = select i1 %cmp1, half 2.550000e+02, half %max\n ret half %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "clamp_float_fast_ordered_strict_maxmin",
"test_body": "define half @clamp_float_fast_ordered_strict_maxmin(half %x) {\n %cmp2 = fcmp nnan ninf nsz olt half %x, 2.550000e+02\n %min = select i1 %cmp2, half %x, half 2.550000e+02\n %cmp1 = fcmp nnan ninf nsz olt half %x, 1.000000e+00\n %r = select i1 %cmp1, half 1.000000e+00, half %min\n ret half %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "clamp_float_fast_ordered_strict_minmax",
"test_body": "define half @clamp_float_fast_ordered_strict_minmax(half %x) {\n %cmp2 = fcmp nnan ninf nsz ogt half %x, 1.000000e+00\n %max = select i1 %cmp2, half %x, half 1.000000e+00\n %cmp1 = fcmp nnan ninf nsz ogt half %x, 2.550000e+02\n %r = select i1 %cmp1, half 2.550000e+02, half %max\n ret half %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "clamp_float_fast_ordered_nonstrict_maxmin",
"test_body": "define half @clamp_float_fast_ordered_nonstrict_maxmin(half %x) {\n %cmp2 = fcmp nnan ninf nsz olt half %x, 2.550000e+02\n %min = select i1 %cmp2, half %x, half 2.550000e+02\n %cmp1 = fcmp nnan ninf nsz ole half %x, 1.000000e+00\n %r = select i1 %cmp1, half 1.000000e+00, half %min\n ret half %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "clamp_float_fast_unordered_nonstrict_minmax",
"test_body": "define half @clamp_float_fast_unordered_nonstrict_minmax(half %x) {\n %cmp2 = fcmp nnan ninf nsz ugt half %x, 1.000000e+00\n %max = select i1 %cmp2, half %x, half 1.000000e+00\n %cmp1 = fcmp nnan ninf nsz uge half %x, 2.550000e+02\n %r = select i1 %cmp1, half 2.550000e+02, half %max\n ret half %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "clamp_test_1",
"test_body": "define half @clamp_test_1(half %x) {\n %inner_cmp = fcmp nnan ninf nsz ult half %x, 2.550000e+02\n %inner_sel = select i1 %inner_cmp, half %x, half 2.550000e+02\n %outer_cmp = fcmp nnan ninf nsz ugt half %x, 1.000000e+00\n %r = select i1 %outer_cmp, half %inner_sel, half 1.000000e+00\n ret half %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "clamp_float_fast_unordered_strict_maxmin",
"test_body": "define half @clamp_float_fast_unordered_strict_maxmin(half %x) {\n %cmp2 = fcmp nnan ninf nsz ult half %x, 2.550000e+02\n %min = select i1 %cmp2, half %x, half 2.550000e+02\n %cmp1 = fcmp nnan ninf nsz ult half %x, 1.000000e+00\n %r = select i1 %cmp1, half 1.000000e+00, half %min\n ret half %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "clamp_negative_wrong_const",
"test_body": "define half @clamp_negative_wrong_const(half %x) {\n %inner_cmp = fcmp nnan ninf nsz ult half %x, 2.550000e+02\n %inner_sel = select i1 %inner_cmp, half %x, half 2.550000e+02\n %outer_cmp = fcmp nnan ninf nsz ugt half %x, 5.120000e+02\n %r = select i1 %outer_cmp, half %inner_sel, half 5.120000e+02\n ret half %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "clamp_float_fast_unordered_strict_minmax",
"test_body": "define half @clamp_float_fast_unordered_strict_minmax(half %x) {\n %cmp2 = fcmp nnan ninf nsz ugt half %x, 1.000000e+00\n %max = select i1 %cmp2, half %x, half 1.000000e+00\n %cmp1 = fcmp nnan ninf nsz ugt half %x, 2.550000e+02\n %r = select i1 %cmp1, half 2.550000e+02, half %max\n ret half %r\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/InstCombine/fcmp-fadd-select.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "test_fcmp_ugt_fadd_select_fastmath_preserve",
"test_body": "define half @test_fcmp_ugt_fadd_select_fastmath_preserve(half %in) {\n %cmp1 = fcmp ugt half %in, 0.000000e+00\n %add = fadd nnan half %in, 1.000000e+00\n %sel = select nnan nsz i1 %cmp1, half %add, half 1.000000e+00\n ret half %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fcmp_uge_fadd_select_fastmath_preserve",
"test_body": "define half @test_fcmp_uge_fadd_select_fastmath_preserve(half %in) {\n %cmp1 = fcmp uge half %in, 0.000000e+00\n %add = fadd nnan half %in, 1.000000e+00\n %sel = select nnan nsz i1 %cmp1, half %add, half 1.000000e+00\n ret half %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fcmp_ugt_fadd_select_neg_constant",
"test_body": "define half @test_fcmp_ugt_fadd_select_neg_constant(half %in) {\n %cmp1 = fcmp ugt half %in, -0.000000e+00\n %add = fadd half %in, 1.000000e+00\n %sel = select nnan nsz i1 %cmp1, half %add, half 1.000000e+00\n ret half %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fcmp_ugt_fadd_select_constant_swapped",
"test_body": "define half @test_fcmp_ugt_fadd_select_constant_swapped(half %in) {\n %cmp1 = fcmp ugt half %in, 0.000000e+00\n %add = fadd half %in, 1.000000e+00\n %sel = select nnan nsz i1 %cmp1, half 1.000000e+00, half %add\n ret half %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fcmp_uge_fadd_select_constant_swapped",
"test_body": "define half @test_fcmp_uge_fadd_select_constant_swapped(half %in) {\n %cmp1 = fcmp uge half %in, 0.000000e+00\n %add = fadd half %in, 1.000000e+00\n %sel = select nnan nsz i1 %cmp1, half 1.000000e+00, half %add\n ret half %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fcmp_ult_fadd_select_fastmath_preserve",
"test_body": "define half @test_fcmp_ult_fadd_select_fastmath_preserve(half %in) {\n %cmp1 = fcmp ult half %in, 0.000000e+00\n %add = fadd nnan half %in, 1.000000e+00\n %sel = select nnan nsz i1 %cmp1, half %add, half 1.000000e+00\n ret half %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fcmp_ule_fadd_select_constant_swapped",
"test_body": "define half @test_fcmp_ule_fadd_select_constant_swapped(half %in) {\n %cmp1 = fcmp ule half %in, 0.000000e+00\n %add = fadd half %in, 1.000000e+00\n %sel = select nnan nsz i1 %cmp1, half 1.000000e+00, half %add\n ret half %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fcmp_uge_fadd_select_neg_constant",
"test_body": "define half @test_fcmp_uge_fadd_select_neg_constant(half %in) {\n %cmp1 = fcmp uge half %in, -0.000000e+00\n %add = fadd half %in, 1.000000e+00\n %sel = select nnan nsz i1 %cmp1, half %add, half 1.000000e+00\n ret half %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fcmp_ule_fadd_select_neg_constant",
"test_body": "define half @test_fcmp_ule_fadd_select_neg_constant(half %in) {\n %cmp1 = fcmp ule half %in, -0.000000e+00\n %add = fadd half %in, 1.000000e+00\n %sel = select nnan nsz i1 %cmp1, half %add, half 1.000000e+00\n ret half %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fcmp_ult_fadd_select_constant_swapped",
"test_body": "define half @test_fcmp_ult_fadd_select_constant_swapped(half %in) {\n %cmp1 = fcmp ult half %in, 0.000000e+00\n %add = fadd half %in, 1.000000e+00\n %sel = select nnan nsz i1 %cmp1, half 1.000000e+00, half %add\n ret half %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fcmp_uge_fadd_select_constant",
"test_body": "define half @test_fcmp_uge_fadd_select_constant(half %in) {\n %cmp1 = fcmp uge half %in, 0.000000e+00\n %add = fadd half %in, 1.000000e+00\n %sel = select nnan nsz i1 %cmp1, half %add, half 1.000000e+00\n ret half %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fcmp_ult_fadd_select_neg_constant",
"test_body": "define half @test_fcmp_ult_fadd_select_neg_constant(half %in) {\n %cmp1 = fcmp ult half %in, -0.000000e+00\n %add = fadd half %in, 1.000000e+00\n %sel = select nnan nsz i1 %cmp1, half %add, half 1.000000e+00\n ret half %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fcmp_ugt_fadd_select_constant",
"test_body": "define half @test_fcmp_ugt_fadd_select_constant(half %in) {\n %cmp1 = fcmp ugt half %in, 0.000000e+00\n %add = fadd half %in, 1.000000e+00\n %sel = select nnan nsz i1 %cmp1, half %add, half 1.000000e+00\n ret half %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fcmp_ule_fadd_select_constant",
"test_body": "define half @test_fcmp_ule_fadd_select_constant(half %in) {\n %cmp1 = fcmp ule half %in, 0.000000e+00\n %add = fadd half %in, 1.000000e+00\n %sel = select nnan nsz i1 %cmp1, half %add, half 1.000000e+00\n ret half %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fcmp_ule_fadd_select_fastmath_preserve",
"test_body": "define half @test_fcmp_ule_fadd_select_fastmath_preserve(half %in) {\n %cmp1 = fcmp ule half %in, 0.000000e+00\n %add = fadd nnan half %in, 1.000000e+00\n %sel = select nnan nsz i1 %cmp1, half %add, half 1.000000e+00\n ret half %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/InstCombine/minmax-fold.ll",
"commands": [
"opt -S -passes=instcombine < %s"
],
"tests": [
{
"test_name": "common_factor_umax_extra_use_both",
"test_body": "declare void @extra_use(i32)\n\ndefine i32 @common_factor_umax_extra_use_both(i32 %a, i32 %b, i32 %c) {\n %cmp_bc = icmp ugt i32 %b, %c\n %max_bc = select i1 %cmp_bc, i32 %b, i32 %c\n %cmp_ba = icmp ugt i32 %b, %a\n %max_ba = select i1 %cmp_ba, i32 %b, i32 %a\n %cmp_bc_ba = icmp ugt i32 %max_bc, %max_ba\n %max_abc = select i1 %cmp_bc_ba, i32 %max_bc, i32 %max_ba\n call void @extra_use(i32 %max_bc)\n call void @extra_use(i32 %max_ba)\n ret i32 %max_abc\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "not_min_of_min",
"test_body": "define half @not_min_of_min(i8 %i, half %x) {\n %cmp1 = fcmp nnan ninf nsz ult half %x, 1.000000e+00\n %min1 = select i1 %cmp1, half %x, half 1.000000e+00\n %cmp2 = fcmp nnan ninf nsz ult half %x, 2.000000e+00\n %min2 = select i1 %cmp2, half %x, half 2.000000e+00\n %cmp3 = icmp ult i8 %i, 16\n %r = select i1 %cmp3, half %min1, half %min2\n ret half %r\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/InstCombine/minmax-fp.ll",
"commands": [
"opt -S -passes=instcombine < %s"
],
"tests": [
{
"test_name": "t15",
"test_body": "define i8 @t15(half %a) {\n %1 = fcmp nsz ule half %a, 0.000000e+00\n %2 = fptosi half %a to i8\n %3 = select i1 %1, i8 %2, i8 0\n ret i8 %3\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "fneg_fmax",
"test_body": "define half @fneg_fmax(half %x, half %y) {\n %n1 = fneg half %x\n %n2 = fneg half %y\n %cond = fcmp nnan ogt half %n1, %n2\n %max = select i1 %cond, half %n1, half %n2\n ret half %max\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "t11",
"test_body": "define i8 @t11(half %a, half %b) {\n %1 = fcmp nnan ninf nsz ult half %b, %a\n %2 = fptosi half %a to i8\n %3 = fptosi half %b to i8\n %4 = select i1 %1, i8 %3, i8 %2\n ret i8 %4\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "fneg_fmin",
"test_body": "define double @fneg_fmin(double %x, double %y) {\n %n1 = fneg double %x\n %n2 = fneg double %y\n %cond = fcmp nnan nsz ule double %n1, %n2\n %max = select i1 %cond, double %n1, double %n2\n ret double %max\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "t14_commute",
"test_body": "define i8 @t14_commute(half %a) {\n %1 = fcmp ule half %a, 0.000000e+00\n %2 = fptosi half %a to i8\n %3 = select i1 %1, i8 0, i8 %2\n ret i8 %3\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "t9",
"test_body": "define i8 @t9(half %a) {\n %1 = fcmp ult half %a, 0.000000e+00\n %2 = fptosi half %a to i8\n %3 = select i1 %1, i8 %2, i8 0\n ret i8 %3\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/InstCombine/unordered-fcmp-select.ll",
"commands": [
"opt -S -passes=instcombine < %s"
],
"tests": [
{
"test_name": "select_min_ugt",
"test_body": "define half @select_min_ugt(half %a, half %b) {\n %cmp = fcmp nnan ninf nsz ugt half %a, %b\n %sel = select i1 %cmp, half %b, half %a\n ret half %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "select_fcmp_une",
"test_body": "define half @select_fcmp_une(half %a, half %b) {\n %cmp = fcmp une half %a, %b\n %sel = select nnan i1 %cmp, half %a, half %b\n ret half %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "select_min_uge",
"test_body": "define half @select_min_uge(half %a, half %b) {\n %cmp = fcmp nsz uge half %a, %b\n %sel = select nnan ninf nsz i1 %cmp, half %b, half %a\n ret half %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "select_max_uge",
"test_body": "define half @select_max_uge(half %a, half %b) {\n %cmp = fcmp nnan uge half %a, %b\n %sel = select ninf i1 %cmp, half %a, half %b\n ret half %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "select_fcmp_ueq",
"test_body": "define half @select_fcmp_ueq(half %a, half %b) {\n %cmp = fcmp ueq half %a, %b\n %sel = select nnan i1 %cmp, half %a, half %b\n ret half %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "select_min_ule",
"test_body": "define half @select_min_ule(half %a, half %b) {\n %cmp = fcmp ule half %a, %b\n %sel = select ninf i1 %cmp, half %a, half %b\n ret half %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "select_max_ugt",
"test_body": "define half @select_max_ugt(half %a, half %b) {\n %cmp = fcmp ugt half %a, %b\n %sel = select i1 %cmp, half %a, half %b\n ret half %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "select_max_ule",
"test_body": "define half @select_max_ule(half %a, half %b) {\n %cmp = fcmp nnan ninf nsz ule half %a, %b\n %sel = select nsz i1 %cmp, half %b, half %a\n ret half %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "select_min_ult",
"test_body": "define half @select_min_ult(half %a, half %b) {\n %cmp = fcmp nsz ult half %a, %b\n %sel = select nnan ninf nsz i1 %cmp, half %a, half %b\n ret half %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "select_max_ult",
"test_body": "define half @select_max_ult(half %a, half %b) {\n %cmp = fcmp ult half %a, %b\n %sel = select nnan ninf i1 %cmp, half %b, half %a\n ret half %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstCombine] `(fcmp une T, F) ? T : F --> T` should not rely on the nsz flag on fcmp",
"body": "Reproducer: https://alive2.llvm.org/ce/z/_FgncC\n```\ndefine double @src(double %x, double %y) {\n %cmp = fcmp nsz une double %x, %y\n %cond = select i1 %cmp, double %x, double %y\n ret double %cond\n}\n\ndefine double @tgt(double returned %x, double %y) {\n ret double %x\n}\n```\n```\nTransformation doesn't verify!\n\nERROR: Value mismatch\n\nExample:\ndouble %x = #x8000000000000000 (-0.0)\ndouble %y = #x0000000000000000 (+0.0)\n\nSource:\ni1 %cmp = #x0 (0)\ndouble %cond = #x0000000000000000 (+0.0)\n\nTarget:\nSource value: #x0000000000000000 (+0.0)\nTarget value: #x8000000000000000 (-0.0)\n```\n`nsz` flag should not be propagated from fcmp into select.\n",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:instcombine",
"floating-point"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
125301
|
https://github.com/llvm/llvm-project/issues/125301
|
crash
|
4f381d0be845a8702c89a0a7f4bd9188e1ff60a3
| 2025-01-31T21:43:25 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "75b922dccfc35ec25a520b1941e6682a300802b8",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": [
[
1058,
1063
]
],
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": [
"classof"
],
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 75b922dccfc35ec25a520b1941e6682a300802b8
Author: Florian Hahn <flo@fhahn.com>
Date: Sat Feb 1 21:40:58 2025 +0000
[VPlan] Check VPWidenIntrinsicSC in VPRecipeWithIRFlags::classof.
When VPWidenIntrinsicRecipe was changed to inhert from VPRecipeWithIRFlags,
VPRecipeWithIRFlags::classof wasn't updated accordingly. Also check for
VPWidenIntrinsicSC in VPRecipeWithIRFlags::classof.
Fixes https://github.com/llvm/llvm-project/issues/125301.
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 459222234bc3..87ef2dc6d8ea 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -1058,6 +1058,7 @@ public:
R->getVPDefID() == VPRecipeBase::VPWidenEVLSC ||
R->getVPDefID() == VPRecipeBase::VPWidenGEPSC ||
R->getVPDefID() == VPRecipeBase::VPWidenCastSC ||
+ R->getVPDefID() == VPRecipeBase::VPWidenIntrinsicSC ||
R->getVPDefID() == VPRecipeBase::VPReplicateSC ||
R->getVPDefID() == VPRecipeBase::VPReverseVectorPointerSC ||
R->getVPDefID() == VPRecipeBase::VPVectorPointerSC;
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/drop-poison-generating-flags.ll",
"commands": [
"opt -p loop-vectorize -mcpu=neoverse-v2 -force-vector-width=4 -S %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ntarget triple = \"aarch64-unknown-linux\"\n\n; Test case where we visit a VPWidenIntrinsic (for @llvm.fabs) with nnan flags.\n; For https://github.com/llvm/llvm-project/issues/125301.\ndefine void @check_widen_intrinsic_with_nnan(ptr noalias %dst.0, ptr noalias %dst.1, ptr noalias %src.1, ptr %src.2) {\n;\nentry:\n br label %loop.header\n\nloop.header:\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %gep.src.1 = getelementptr inbounds double, ptr %src.1, i64 %iv\n %l.1 = load double, ptr %gep.src.1, align 8\n %abs = tail call nnan double @llvm.fabs.f64(double %l.1)\n %c.0 = fcmp olt double %abs, 1.000000e+00\n br i1 %c.0, label %then, label %else\n\nthen:\n %l.2 = load double, ptr %src.2, align 8\n %iv.sub.1 = add nsw i64 %iv, -1\n %gep.iv.sub.1 = getelementptr double, ptr %dst.0, i64 %iv.sub.1\n store double 0.000000e+00, ptr %gep.iv.sub.1, align 8\n %c.1 = fcmp oeq double %l.2, 0.000000e+00\n br i1 %c.1, label %merge, label %loop.latch\n\nelse:\n %iv.sub.2 = add nsw i64 %iv, -1\n %gep.iv.sub.2 = getelementptr double, ptr %dst.0, i64 %iv.sub.2\n store double 0.000000e+00, ptr %gep.iv.sub.2, align 8\n br label %merge\n\nmerge:\n %merge.iv = phi i64 [ %iv.sub.2, %else ], [ %iv.sub.1, %then ]\n %gep.dst.1 = getelementptr inbounds i32, ptr %dst.1, i64 %merge.iv\n store i32 10, ptr %gep.dst.1, align 4\n br label %loop.latch\n\nloop.latch:\n %iv.next = add nuw nsw i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1000\n br i1 %exitcond.not, label %exit, label %loop.header\n\nexit:\nret void\n}\n\ndeclare double @llvm.fabs.f64(double)",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[vplan] Assertion: found instruction with poison generating flags not covered by VPRecipeWithIRFlags",
"body": "```\nclang++ -O3 -mcpu=neoverse-v2 -c reduced.ll\n\nclang++: llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp:1926: llvm::VPlanTransforms::dropPoisonGeneratingRecipes(llvm::VPlan&, const std::function<bool(llvm::BasicBlock*)>&)::<lambda(llvm::VPRecipeBase*)>: Assertion `(!Instr || !Instr->hasPoisonGeneratingFlags()) && \"found instruction with poison generating flags not covered by \" \"VPRecipeWithIRFlags\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\nStack dump:\n0. Program arguments: clang++ -O3 -mcpu=neoverse-v2 -c reduced.ll\n1. Optimizer\n2. Running pass \"function<eager-inv>(float2int,lower-constant-intrinsics,chr,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"reduced.ll\"\n3. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"foo\"\n #0 0x0000aaaaaf09abe8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)\n #1 0x0000aaaaaf098908 llvm::sys::RunSignalHandlers()\n #2 0x0000aaaaaf098c88 llvm::sys::CleanupOnSignal(unsigned long)\n #3 0x0000aaaaaefee5bc CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0\n #4 0x0000fffff7fb08dc (linux-vdso.so.1+0x8dc)\n #5 0x0000fffff7c2f200 __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #6 0x0000fffff7bea67c gsignal ./signal/../sysdeps/posix/raise.c:27:6\n #7 0x0000fffff7bd7130 abort ./stdlib/abort.c:81:7\n #8 0x0000fffff7be3fd0 __assert_fail_base ./assert/assert.c:89:7\n #9 0x0000fffff7be4040 __assert_perror_fail ./assert/assert-perr.c:31:1\n#10 0x0000aaaab0bfd210 llvm::VPlanTransforms::dropPoisonGeneratingRecipes(llvm::VPlan&, std::function<bool (llvm::BasicBlock*)> const&)::'lambda'(llvm::VPRecipeBase*)::operator()(llvm::VPRecipeBase*) const (.isra.0) VPlanTransforms.cpp:0:0\n#11 0x0000aaaab0c065b4 llvm::VPlanTransforms::dropPoisonGeneratingRecipes(llvm::VPlan&, std::function<bool (llvm::BasicBlock*)> const&) \n#12 0x0000aaaab0b99078 llvm::LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(llvm::VFRange&)\n#13 0x0000aaaab0b99634 llvm::LoopVectorizationPlanner::buildVPlansWithVPRecipes(llvm::ElementCount, llvm::ElementCount)\n#14 0x0000aaaab0b99c1c llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int)\n#15 0x0000aaaab0b9b05c llvm::LoopVectorizePass::processLoop(llvm::Loop*) \n#16 0x0000aaaab0b9d464 llvm::LoopVectorizePass::runImpl(llvm::Function&) \n#17 0x0000aaaab0b9da1c llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) \n#18 0x0000aaaab07856fc llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) PassBuilder.cpp:0:0\n#19 0x0000aaaaaeb3fef8 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&)\n#20 0x0000aaaaadbd51dc llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) NVPTXTargetMachine.cpp:0:0\n#21 0x0000aaaaaeb3e97c llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&)\n#22 0x0000aaaaadbd513c llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) NVPTXTargetMachine.cpp:0:0\n#23 0x0000aaaaaeb3e3a4 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) \n#24 0x0000aaaaafa2b598 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\n#25 0x0000aaaaafa2e258 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*)\n#26 0x0000aaaaafb69e8c clang::CodeGenAction::ExecuteAction()\n#27 0x0000aaaaafef684c clang::FrontendAction::Execute()\n#28 0x0000aaaaafe8bb30 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) \n#29 0x0000aaaaaffe49b0 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) \n#30 0x0000aaaaadb8f874 cc1_main(llvm::ArrayRef<char const*>, char const*, void*)\n#31 0x0000aaaaadb87f34 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#32 0x0000aaaaafcd7778 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0\n#33 0x0000aaaaaefeeac0 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)\n#34 0x0000aaaaafcd7d48 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0\n#35 0x0000aaaaafc9daf4 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const\n#36 0x0000aaaaafc9e744 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const \n#37 0x0000aaaaafca6268 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) \n#38 0x0000aaaaadb8c654 clang_main(int, char**, llvm::ToolContext const&)\n#39 0x0000aaaaadb9c06c main\n#40 0x0000fffff7bd73fc __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3\n#41 0x0000fffff7bd74cc call_init ./csu/../csu/libc-start.c:128:20\n#42 0x0000fffff7bd74cc __libc_start_main ./csu/../csu/libc-start.c:379:5\n#43 0x0000aaaaadb87a24 _start\nclang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)\nclang version 21.0.0git (https://github.com/llvm/llvm-project 82b923defe27cc46ecf3084f3a8f1c0d1c36199e)\nTarget: aarch64-unknown-linux-gnu\nThread model: posix\nInstalledDir: \nBuild config: +assertions\nclang++: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.\n```\n```\n# works ok\nclang++ -O3 -mcpu=neoverse-n1 -c reduced.ll\n```\n\n```\n; ModuleID = '<bc file>'\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32\"\ntarget triple = \"aarch64-unknown-linux-gnu\"\n\ndefine void @foo(ptr %0, ptr %1, ptr %bar, i64 %2) {\n br label %4\n\n4: ; preds = %5, %3\n br label %5\n\n5: ; preds = %26, %4\n %6 = phi i32 [ %27, %26 ], [ 0, %4 ]\n %7 = phi i64 [ %28, %26 ], [ %2, %4 ]\n %8 = icmp sgt i64 %7, 0\n br i1 %8, label %9, label %4\n\n9: ; preds = %5\n %10 = load double, ptr %1, align 8\n %11 = call nnan double @llvm.fabs.f64(double %10)\n %12 = fcmp olt double %11, 1.000000e+00\n br i1 %12, label %13, label %21\n\n13: ; preds = %9\n %14 = load double, ptr %bar, align 8\n %15 = zext i32 %6 to i64\n %16 = add i64 %15, -1\n %17 = getelementptr double, ptr %0, i64 %16\n store double 0.000000e+00, ptr %17, align 8\n %18 = fcmp oeq double %14, 0.000000e+00\n br i1 %18, label %19, label %26\n\n19: ; preds = %13\n %20 = getelementptr i32, ptr null, i64 %16\n store i32 0, ptr %20, align 4\n br label %26\n\n21: ; preds = %9\n %22 = zext i32 %6 to i64\n %23 = add i64 %22, -1\n %24 = getelementptr double, ptr %0, i64 %23\n store double 0.000000e+00, ptr %24, align 8\n %25 = getelementptr i32, ptr null, i64 %23\n store i32 0, ptr %25, align 4\n br label %26\n\n26: ; preds = %21, %19, %13\n %27 = add nsw i32 %6, 1\n %28 = add i64 %7, -1\n br label %5\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare double @llvm.fabs.f64(double) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n```",
"author": "ashermancinelli",
"labels": [
"release:backport",
"vectorizers",
"crash"
],
"comments": [
{
"author": "fhahn",
"body": "@ashermancinelli it looks like `reduced.ll` is missing from the issue here? Could you attach it (or share a link to godbolt)?"
},
{
"author": "ashermancinelli",
"body": "@fhahn Sorry about that! I updated the description."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
81415
|
https://github.com/llvm/llvm-project/issues/81415
|
crash
|
0ea64ad88abcbb939547a92000d98efb2b00d95f
| 2024-02-11T14:16:02 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "0dacba3ad1b5214ca35eda14987c0b76568a070e",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
[
977,
985
],
[
990,
1000
]
],
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
"VPlanTransforms::truncateToMinimalBitwidths"
],
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 0dacba3ad1b5214ca35eda14987c0b76568a070e
Author: Florian Hahn <flo@fhahn.com>
Date: Fri Feb 16 12:58:39 2024 +0000
[VPlan] Handle truncating ICMPs in truncateToMinimalBWs.
Update truncateToMinimalBitwidths to handle truncating ICMPs. For ICMPs,
the new target type will be the same as the original type. In that case,
only truncate the operands, but skip the extend. This is in line with
what the original truncateToMinimalBitwidths did for compares.
Fixes https://github.com/llvm/llvm-project/issues/81415.
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 16855a9227a1..99198cfa9955 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -977,9 +977,6 @@ void VPlanTransforms::truncateToMinimalBitwidths(
Type *OldResTy = TypeInfo.inferScalarType(ResultVPV);
unsigned OldResSizeInBits = OldResTy->getScalarSizeInBits();
assert(OldResTy->isIntegerTy() && "only integer types supported");
- if (OldResSizeInBits == NewResSizeInBits)
- continue;
- assert(OldResSizeInBits > NewResSizeInBits && "Nothing to shrink?");
(void)OldResSizeInBits;
auto *NewResTy = IntegerType::get(Ctx, NewResSizeInBits);
@@ -990,11 +987,17 @@ void VPlanTransforms::truncateToMinimalBitwidths(
if (auto *VPW = dyn_cast<VPRecipeWithIRFlags>(&R))
VPW->dropPoisonGeneratingFlags();
- // Extend result to original width.
- auto *Ext = new VPWidenCastRecipe(Instruction::ZExt, ResultVPV, OldResTy);
- Ext->insertAfter(&R);
- ResultVPV->replaceAllUsesWith(Ext);
- Ext->setOperand(0, ResultVPV);
+ if (OldResSizeInBits != NewResSizeInBits) {
+ // Extend result to original width.
+ auto *Ext =
+ new VPWidenCastRecipe(Instruction::ZExt, ResultVPV, OldResTy);
+ Ext->insertAfter(&R);
+ ResultVPV->replaceAllUsesWith(Ext);
+ Ext->setOperand(0, ResultVPV);
+ assert(OldResSizeInBits > NewResSizeInBits && "Nothing to shrink?");
+ } else
+ assert(cast<VPWidenRecipe>(&R)->getOpcode() == Instruction::ICmp &&
+ "Only ICmps should not need extending the result.");
if (isa<VPWidenMemoryInstructionRecipe>(&R)) {
assert(!cast<VPWidenMemoryInstructionRecipe>(&R)->isStore() && "stores cannot be narrowed");
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/trunc-reductions.ll",
"commands": [
"opt -passes=loop-vectorize,dce,instcombine -force-vector-interleave=1 -force-vector-width=8 -S < %s"
],
"tests": [
{
"test_name": "reduction_and_or",
"test_body": "define i32 @reduction_and_or(i16 %a, i32 %b, ptr %src) {\nentry:\n %ext1 = zext i16 %a to i32\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %or67 = phi i32 [ 10, %entry ], [ %or, %loop ]\n %t = trunc i32 %b to i16\n %ext = sext i16 %t to i32\n %cmp = icmp sgt i32 %ext, %ext1\n %ext2 = zext i1 %cmp to i32\n %cmp3 = icmp sge i32 %iv, %ext2\n %ext4 = zext i1 %cmp3 to i32\n %div = sdiv i32 %ext4, %b\n %and = and i32 %div, 0\n %gep = getelementptr inbounds i32, ptr %src, i32 %iv\n %l = load i32, ptr %gep, align 4\n %add = add i32 %and, %l\n %or = or i32 %or67, %add\n %iv.next = add nsw i32 %iv, 1\n %tobool.not = icmp eq i32 %iv.next, 999\n br i1 %tobool.not, label %exit, label %loop\n\nexit: ; preds = %loop\n %or.lcssa = phi i32 [ %or, %loop ]\n ret i32 %or.lcssa\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "clang crashes at -O{s,2,3} on x86_64-linux-gnu: Assertion `MinBWs.size() == NumProcessedRecipes && \"some entries in MinBWs haven't been processed\"' failed",
"body": "It appears to be a recent regression as it does not reproduce with 17.0.1 and earlier versions.\r\n\r\nCompiler Explorer: https://godbolt.org/z/vGGoa684a\r\n\r\n```\r\n[511] % clangtk -v\r\nclang version 19.0.0git (https://github.com/llvm/llvm-project.git 5932fcc47855fdd209784f38820422d2369b84b2)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/opfuzz/bin\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\r\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nCandidate multilib: .;@m64\r\nSelected multilib: .;@m64\r\n[512] % \r\n[512] % clangtk -Os small.c\r\nclang-19: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp:1038: static void llvm::VPlanTransforms::truncateToMinimalBitwidths(llvm::VPlan&, const llvm::MapVector<llvm::Instruction*, long unsigned int>&, llvm::LLVMContext&): Assertion `MinBWs.size() == NumProcessedRecipes && \"some entries in MinBWs haven't been processed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-19 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/20240211-clangtk-m64-Os-Weverything-pipe-fPIC-build-024130/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20240211-clangtk-m64-Os-Weverything-pipe-fPIC-build-024130/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/19 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Os -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-d74fff.o -x c small.c\r\n1.\t<eof> parser at end of file\r\n2.\tOptimizer\r\n #0 0x000055fb61397fcf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x3f04fcf)\r\n #1 0x000055fb613954f4 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007fdd88b17420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #3 0x00007fdd8851e00b raise /build/glibc-wuryBv/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #4 0x00007fdd884fd859 abort /build/glibc-wuryBv/glibc-2.31/stdlib/abort.c:81:7\r\n #5 0x00007fdd884fd729 get_sysdep_segment_value /build/glibc-wuryBv/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #6 0x00007fdd884fd729 _nl_load_domain /build/glibc-wuryBv/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #7 0x00007fdd8850efd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #8 0x000055fb62c44895 llvm::VPlanTransforms::truncateToMinimalBitwidths(llvm::VPlan&, llvm::MapVector<llvm::Instruction*, unsigned long, llvm::DenseMap<llvm::Instruction*, unsigned int, llvm::DenseMapInfo<llvm::Instruction*, void>, llvm::detail::DenseMapPair<llvm::Instruction*, unsigned int>>, llvm::SmallVector<std::pair<llvm::Instruction*, unsigned long>, 0u>> const&, llvm::LLVMContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x57b1895)\r\n #9 0x000055fb62b2644a llvm::LoopVectorizationPlanner::buildVPlansWithVPRecipes(llvm::ElementCount, llvm::ElementCount) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x569344a)\r\n#10 0x000055fb62b2d861 llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x569a861)\r\n#11 0x000055fb62b30a1f llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x569da1f)\r\n#12 0x000055fb62b33acd llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x56a0acd)\r\n#13 0x000055fb62b34d20 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x56a1d20)\r\n#14 0x000055fb62717536 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x5284536)\r\n#15 0x000055fb5ea6d61d llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x15da61d)\r\n#16 0x000055fb60d5cb3d llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x38c9b3d)\r\n#17 0x000055fb5ea509a6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x15bd9a6)\r\n#18 0x000055fb60d5aa6d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x38c7a6d)\r\n#19 0x000055fb6161dc90 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#20 0x000055fb61620f60 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#21 0x000055fb616215cb clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x418e5cb)\r\n#22 0x000055fb61c5730a clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x47c430a)\r\n#23 0x000055fb63944ee9 clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x64b1ee9)\r\n#24 0x000055fb61c566a8 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x47c36a8)\r\n#25 0x000055fb61ed4429 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x4a41429)\r\n#26 0x000055fb61e508de clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x49bd8de)\r\n#27 0x000055fb61fb8d46 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x4b25d46)\r\n#28 0x000055fb5e655986 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x11c2986)\r\n#29 0x000055fb5e64cfba ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#30 0x000055fb5e652434 clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x11bf434)\r\n#31 0x000055fb5e564aab main (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x10d1aab)\r\n#32 0x00007fdd884ff083 __libc_start_main /build/glibc-wuryBv/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#33 0x000055fb5e64ca7e _start (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x11b9a7e)\r\nclangtk: error: unable to execute command: Aborted\r\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\r\nclang version 19.0.0git (https://github.com/llvm/llvm-project.git 5932fcc47855fdd209784f38820422d2369b84b2)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/opfuzz/bin\r\nclangtk: note: diagnostic msg: \r\n********************\r\n\r\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\r\nPreprocessed source(s) and associated run script(s) are located at:\r\nclangtk: note: diagnostic msg: /tmp/small-ca7a0b.c\r\nclangtk: note: diagnostic msg: /tmp/small-ca7a0b.sh\r\nclangtk: note: diagnostic msg: \r\n\r\n********************\r\n[513] % \r\n[513] % cat small.c\r\nstatic int *a, **b = &a, f = 1;\r\nint c, d, h;\r\nshort e, g;\r\nint main() {\r\n int **i[9] = {&a, &a, &a, &a, &a, &a, &a, &a, &a};\r\n for (; d; d++)\r\n if ((**b < e) | f) {\r\n int *j = &f, k;\r\n c = h;\r\n k = g > ((long)j == 1);\r\n }\r\n return 0;\r\n}\r\n```",
"author": "zhendongsu",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "zhendongsu",
"body": "Another related test that reproduces the crash only at -Os.\r\n\r\n```\r\n[513] % clangtk -v\r\nclang version 19.0.0git (https://github.com/llvm/llvm-project.git e769fb8699e3fa8e40623764f7713bfc783b0330)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/opfuzz/bin\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\r\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nCandidate multilib: .;@m64\r\nSelected multilib: .;@m64\r\n[514] % \r\n[514] % clangtk -Os small.c\r\nclang-19: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp:1038: static void llvm::VPlanTransforms::truncateToMinimalBitwidths(llvm::VPlan&, const llvm::MapVector<llvm::Instruction*, long unsigned int>&, llvm::LLVMContext&): Assertion `MinBWs.size() == NumProcessedRecipes && \"some entries in MinBWs haven't been processed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-19 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/DUP/20240215-clangtk-m64-Os-Weverything-pipe-fPIC-build-144944/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/DUP/20240215-clangtk-m64-Os-Weverything-pipe-fPIC-build-144944/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/19 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Os -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-a3d3db.o -x c small.c\r\n1.\t<eof> parser at end of file\r\n2.\tOptimizer\r\n #0 0x000055bf09b51e2f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x3f38e2f)\r\n #1 0x000055bf09b4f354 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007fdb52bbc420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #3 0x00007fdb525c300b raise /build/glibc-wuryBv/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #4 0x00007fdb525a2859 abort /build/glibc-wuryBv/glibc-2.31/stdlib/abort.c:81:7\r\n #5 0x00007fdb525a2729 get_sysdep_segment_value /build/glibc-wuryBv/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #6 0x00007fdb525a2729 _nl_load_domain /build/glibc-wuryBv/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #7 0x00007fdb525b3fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #8 0x000055bf0b405565 llvm::VPlanTransforms::truncateToMinimalBitwidths(llvm::VPlan&, llvm::MapVector<llvm::Instruction*, unsigned long, llvm::DenseMap<llvm::Instruction*, unsigned int, llvm::DenseMapInfo<llvm::Instruction*, void>, llvm::detail::DenseMapPair<llvm::Instruction*, unsigned int>>, llvm::SmallVector<std::pair<llvm::Instruction*, unsigned long>, 0u>> const&, llvm::LLVMContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x57ec565)\r\n #9 0x000055bf0b2e62ba llvm::LoopVectorizationPlanner::buildVPlansWithVPRecipes(llvm::ElementCount, llvm::ElementCount) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x56cd2ba)\r\n#10 0x000055bf0b2ed661 llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x56d4661)\r\n#11 0x000055bf0b2f081f llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x56d781f)\r\n#12 0x000055bf0b2f38cd llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x56da8cd)\r\n#13 0x000055bf0b2f4b20 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x56dbb20)\r\n#14 0x000055bf0aed6086 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x52bd086)\r\n#15 0x000055bf0721ff8d llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x1606f8d)\r\n#16 0x000055bf0951611d llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x38fd11d)\r\n#17 0x000055bf072032e6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x15ea2e6)\r\n#18 0x000055bf0951404d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x38fb04d)\r\n#19 0x000055bf09dd88c0 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#20 0x000055bf09ddbb80 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#21 0x000055bf09ddc1eb clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x41c31eb)\r\n#22 0x000055bf0a41298a clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x47f998a)\r\n#23 0x000055bf0c10e439 clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x64f5439)\r\n#24 0x000055bf0a411d18 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x47f8d18)\r\n#25 0x000055bf0a6903e9 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x4a773e9)\r\n#26 0x000055bf0a60d21e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x49f421e)\r\n#27 0x000055bf0a776736 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x4b5d736)\r\n#28 0x000055bf06e06b76 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x11edb76)\r\n#29 0x000055bf06dfe1aa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#30 0x000055bf06e03624 clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x11ea624)\r\n#31 0x000055bf06d15abb main (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x10fcabb)\r\n#32 0x00007fdb525a4083 __libc_start_main /build/glibc-wuryBv/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#33 0x000055bf06dfdc6e _start (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x11e4c6e)\r\nclangtk: error: unable to execute command: Aborted\r\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\r\nclang version 19.0.0git (https://github.com/llvm/llvm-project.git e769fb8699e3fa8e40623764f7713bfc783b0330)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/opfuzz/bin\r\nclangtk: note: diagnostic msg: \r\n********************\r\n\r\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\r\nPreprocessed source(s) and associated run script(s) are located at:\r\nclangtk: note: diagnostic msg: /tmp/small-585ede.c\r\nclangtk: note: diagnostic msg: /tmp/small-585ede.sh\r\nclangtk: note: diagnostic msg: \r\n\r\n********************\r\n[515] % \r\n[515] % cat small.c\r\nint a = 1, b, c, d;\r\nshort e() { return a == 1 ? a : a % b; }\r\nstatic int f;\r\nshort g;\r\nunsigned short h;\r\nint main() {\r\n int *i[10] = {&f};\r\n for (c = -2; c; c++) {\r\n g = e();\r\n d |= f & ((b >= (g > h)) / a);\r\n }\r\n return 0;\r\n}\r\n```"
},
{
"author": "fhahn",
"body": "Thanks for the test case, should be fixed! \r\n\r\nIt looks like this only gets triggered when the resulting truncated compare is dead. Please let me know if you see any issues with similar cases where the resulting loop/compares in the loop aren't dead."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
142518
|
https://github.com/llvm/llvm-project/issues/142518
|
miscompilation
|
9ba332f9963561bb5ac6933266afe38eb8fde8cd
| 2025-06-03T02:15:27 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "e2c698c7e836306f1a25c67597ae9e25a1fcc575",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": [
[
4513,
4518
]
],
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": [
"InstCombinerImpl::sinkNotIntoLogicalOp"
],
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit e2c698c7e836306f1a25c67597ae9e25a1fcc575
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Wed Jun 4 17:48:01 2025 +0800
[InstCombine] Fix miscompilation in `sinkNotIntoLogicalOp` (#142727)
Consider the following case:
```
define i1 @src(i8 %x) {
%cmp = icmp slt i8 %x, -1
%not1 = xor i1 %cmp, true
%or = or i1 %cmp, %not1
%not2 = xor i1 %or, true
ret i1 %not2
}
```
`sinkNotIntoLogicalOp(%or)` calls `freelyInvert(%cmp,
/*IgnoredUser=*/%or)` first. However, as `%cmp` is also used by `Op1 =
%not1`, the RHS of `%or` is set to `%cmp.not = xor i1 %cmp, true`. Thus
`Op1` is out of date in the second call to `freelyInvert`. Similarly,
the second call may change `Op0`. According to the analysis above, I
decided to avoid this fold when one of the operands is also a user of
the other.
Closes https://github.com/llvm/llvm-project/issues/142518.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index 2fb4bfecda8a..c6c231f81c4a 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -4513,6 +4513,12 @@ bool InstCombinerImpl::sinkNotIntoLogicalOp(Instruction &I) {
if (Op0 == Op1)
return false;
+ // If one of the operands is a user of the other,
+ // freelyInvert->freelyInvertAllUsersOf will change the operands of I, which
+ // may cause miscompilation.
+ if (match(Op0, m_Not(m_Specific(Op1))) || match(Op1, m_Not(m_Specific(Op0))))
+ return false;
+
Instruction::BinaryOps NewOpc =
match(&I, m_LogicalAnd()) ? Instruction::Or : Instruction::And;
bool IsBinaryOp = isa<BinaryOperator>(I);
|
[
{
"file": "llvm/test/Transforms/InstCombine/pr142518.ll",
"commands": [
"opt -S -passes=instcombine < %s"
],
"tests": [
{
"test_name": "pr142518",
"test_body": "define i8 @pr142518(ptr %p, i8 %x, i1 %c) #0 {\nentry:\n %flag = alloca i8, align 1\n %cmp = icmp slt i8 %x, -1\n br label %loop\n\nloop: ; preds = %loop, %entry\n %phi = phi i1 [ %cmp, %entry ], [ %c, %loop ]\n %not1 = xor i1 %phi, true\n %or = or i1 %cmp, %not1\n %not2 = xor i1 %or, true\n %ext2 = zext i1 %not2 to i8\n store i8 %ext2, ptr %p, align 1\n store i8 1, ptr %flag, align 1\n %flagv = load i8, ptr %flag, align 1\n %cond = icmp eq i8 %flagv, 0\n br i1 %cond, label %loop, label %exit\n\nexit: ; preds = %loop\n %not3 = xor i1 %or, true\n %ext3 = zext i1 %not3 to i8\n ret i8 %ext3\n}\n\nattributes #0 = { \"instcombine-no-verify-fixpoint\" }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "InstCombine 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\nI've tried to reduce the MIR, but I think there's a pretty complicated structure required because I can't get the MIR very small.\nhttps://godbolt.org/z/G6qsWP57T\n\nThe program seems to miscompile starting at `rustc -Zmir-opt-level=0 -Copt-level=1 -Cllvm-args=-opt-bisect-limit=159`",
"author": "saethlin",
"labels": [
"miscompilation",
"llvm:instcombine",
"generated by fuzzer"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Reproducer: https://alive2.llvm.org/ce/z/l2ArgJ\n\n> I've tried to reduce the MIR, but I think there's a pretty complicated structure required because I can't get the MIR very small.\n\nFYI you can use https://github.com/dtcxzyw/llvm-ub-aware-interpreter?tab=readme-ov-file#automatic-ub-free-test-case-reduction-for-middle-end-miscompilation-bugs to reduce csmith/rustlantics-generated miscompilation reproducers.\n"
},
{
"author": "saethlin",
"body": "I'd love to use llubi but it doesn't compile against the tip of master or the llvm submodule in rust-lang/rust. So I'm not really sure how to get a working build on my system."
},
{
"author": "dtcxzyw",
"body": "> I'd love to use llubi but it doesn't compile against the tip of master or the llvm submodule in rust-lang/rust. So I'm not really sure how to get a working build on my system.\n\nFixed. It was broken by recent changes to ValueTracking: https://github.com/llvm/llvm-project/pull/142384"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
97452
|
https://github.com/llvm/llvm-project/issues/97452
|
crash
|
5c204b1d2619cbad7b7ad228b62feae08781a6db
| 2024-07-02T17:49:01 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "2b3b405b09a0d965a4aff1f92958418ddbf1e7f6",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
[
6813,
6818
]
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"LoopVectorizationCostModel::getInstructionCost"
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 2b3b405b09a0d965a4aff1f92958418ddbf1e7f6
Author: Florian Hahn <flo@fhahn.com>
Date: Thu Jul 4 11:44:50 2024 +0100
[LV] Don't vectorize first-order recurrence with VF <vscale x 1 x ..>
The assertion added as part of https://github.com/llvm/llvm-project/pull/93395
surfaced cases where first-order recurrences are vectorized with
<vscale x 1 x ..>. If vscale is 1, then we are unable to extract the
penultimate value (second to last lane). Previously this case got
mis-compiled, trying to extract from an invalid lane (-1)
https://llvm.godbolt.org/z/3adzYYcf9.
Fixes https://github.com/llvm/llvm-project/issues/97452.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index f9c0c66e6e0a..d7b0240fd8a8 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -6813,6 +6813,11 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I, ElementCount VF,
// First-order recurrences are replaced by vector shuffles inside the loop.
if (VF.isVector() && Legal->isFixedOrderRecurrence(Phi)) {
+ // For <vscale x 1 x i64>, if vscale = 1 we are unable to extract the
+ // penultimate value of the recurrence.
+ // TODO: Consider vscale_range info.
+ if (VF.isScalable() && VF.getKnownMinValue() == 1)
+ return InstructionCost::getInvalid();
SmallVector<int> Mask(VF.getKnownMinValue());
std::iota(Mask.begin(), Mask.end(), VF.getKnownMinValue() - 1);
return TTI.getShuffleCost(TargetTransformInfo::SK_Splice,
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/RISCV/first-order-recurrence-scalable-vf1.ll",
"commands": [
"opt -p loop-vectorize -S %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\n; Make sure we do not pick <vscale x 1 x i64> as VF for a loop with a\n; first-order recurrence.\ndefine i64 @pr97452_scalable_vf1_for(ptr %src) #0 {\n;\nentry:\n br label %loop\n\nloop:\n %for = phi i64 [ 0, %entry ], [ %l, %loop ]\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.next = add i64 %iv, 1\n %gep = getelementptr inbounds i64, ptr %src, i64 %iv\n %l = load i64, ptr %gep, align 8\n %ec = icmp eq i64 %iv, 22\n br i1 %ec, label %exit, label %loop\n\nexit:\n %res = phi i64 [ %for, %loop ]\n ret i64 %res\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v,+zvl128b,+zvl256b\" }\n;.\n;.",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/first-order-recurrence-scalable-vf1.ll",
"commands": [
"opt -p loop-vectorize -scalable-vectorization=on -force-vector-width=1 -force-target-supports-scalable-vectors=true -S %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\n\ndefine i64 @pr97452_scalable_vf1_for_live_out(ptr %src) {\n;\nentry:\n br label %loop\n\nloop:\n %for = phi i64 [ 0, %entry ], [ %l, %loop ]\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.next = add i64 %iv, 1\n %gep = getelementptr inbounds i64, ptr %src, i64 %iv\n %l = load i64, ptr %gep, align 8\n %ec = icmp eq i64 %iv, 22\n br i1 %ec, label %exit, label %loop\n\nexit:\n %res = phi i64 [ %for, %loop ]\n ret i64 %res\n}\n\n\ndefine void @pr97452_scalable_vf1_for_no_live_out(ptr %src, ptr noalias %dst) {\n;\nentry:\n br label %loop\n\nloop:\n %for = phi i64 [ 0, %entry ], [ %l, %loop ]\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.next = add i64 %iv, 1\n %gep = getelementptr inbounds i64, ptr %src, i64 %iv\n %l = load i64, ptr %gep, align 8\n %gep.dst = getelementptr inbounds i64, ptr %dst, i64 %iv\n store i64 %l, ptr %gep.dst\n %ec = icmp eq i64 %iv, 22\n br i1 %ec, label %exit, label %loop\n\nexit:\n ret void\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[LoopVectorize] Assertion `Offset <= State.VF.getKnownMinValue() && \"invalid offset to extract from\"' failed.",
"body": "Reduced testcase:\r\n```llvm ir\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine i32 @main() #0 {\r\nentry:\r\n br label %for.body\r\n\r\nfor.cond.cleanup: ; preds = %for.body\r\n %.lcssa17 = phi i64 [ %0, %for.body ]\r\n ret i32 0\r\n\r\nfor.body: ; preds = %for.body, %entry\r\n %0 = phi i64 [ 0, %entry ], [ %1, %for.body ]\r\n %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]\r\n %indvars.iv.next = add i64 %indvars.iv, 1\r\n %1 = load i64, ptr null, align 8\r\n %exitcond.not = icmp eq i64 %indvars.iv, 22\r\n br i1 %exitcond.not, label %for.cond.cleanup, label %for.body\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+v,+zvl128b,+zvl256b\" }\r\n```\r\n\r\nCommand/backtrace:\r\n```bash\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize reduced.ll\r\nWARNING: You're attempting to print out a bitcode file.\r\nThis is inadvisable as it may cause display problems. If\r\nyou REALLY want to taste LLVM bitcode first-hand, you\r\ncan force output with the `-f' option.\r\n\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp:569: llvm::Value* llvm::VPInstruction::generatePerPart(llvm::VPTransformState&, unsigned int): Assertion `Offset <= State.VF.getKnownMinValue() && \"invalid offset to extract from\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize reduced.ll\r\n1. Running pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"reduced.ll\"\r\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\r\n #0 0x000055972ae01800 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2ed2800)\r\n #1 0x000055972adfec0f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2ecfc0f)\r\n #2 0x000055972adfed65 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x0000728161442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007281614969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007281614969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007281614969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x0000728161442476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007281614287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x000072816142871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x0000728161439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x0000559729f62d80 llvm::VPInstruction::generatePerPart(llvm::VPTransformState&, unsigned int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2033d80)\r\n#12 0x0000559729f63155 llvm::VPInstruction::execute(llvm::VPTransformState&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2034155)\r\n#13 0x0000559729f2de47 llvm::VPBasicBlock::executeRecipes(llvm::VPTransformState*, llvm::BasicBlock*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1ffee47)\r\n#14 0x0000559729f2e141 llvm::VPIRBasicBlock::execute(llvm::VPTransformState*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1fff141)\r\n#15 0x0000559729f30286 llvm::VPlan::execute(llvm::VPTransformState*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2001286)\r\n#16 0x0000559729e2380a llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool, llvm::DenseMap<llvm::SCEV const*, llvm::Value*, llvm::DenseMapInfo<llvm::SCEV const*, void>, llvm::detail::DenseMapPair<llvm::SCEV const*, llvm::Value*>> const*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1ef480a)\r\n#17 0x0000559729e34a7c llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f05a7c)\r\n#18 0x0000559729e36f7e llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f07f7e)\r\n#19 0x0000559729e380a0 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f090a0)\r\n#20 0x0000559728cc6dc6 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xd97dc6)\r\n#21 0x000055972ac1ce46 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2cede46)\r\n#22 0x0000559728cc9f56 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xd9af56)\r\n#23 0x000055972ac1bbcb llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2cecbcb)\r\n#24 0x0000559728cc6526 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xd97526)\r\n#25 0x000055972ac19d02 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2cead02)\r\n#26 0x0000559728520136 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5f1136)\r\n#27 0x0000559728511d51 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5e2d51)\r\n#28 0x0000728161429d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#29 0x0000728161429e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#30 0x0000728161429e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#31 0x0000559728507b85 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5d8b85)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\nGodbolt: https://godbolt.org/z/ojz8sMa1r\r\n\r\nFound via fuzzer",
"author": "patrick-rivos",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "svs-quic",
"body": "Bisected to #93395 \r\ncc: @fhahn "
},
{
"author": "fhahn",
"body": "Thanks for the test case. Should be fixed now. The assertion highlighted a case where we previously miscompiled for the case where VF is <vscale x 1 x ..>; in that case we are unable to extract the penultimate value (second-to-last) if vscale = 1"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
93769
|
https://github.com/llvm/llvm-project/issues/93769
|
miscompilation
|
d517f15e09e49e172387cb6deb76e4ee2d45d0e4
| 2024-05-30T04:55:57 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "971c49fbf361c22ccf20913f61a58c28b26c4e27",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": [
[
2857,
2864
]
],
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": [
"foldFNegIntoConstant"
],
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 971c49fbf361c22ccf20913f61a58c28b26c4e27
Author: SahilPatidar <patidarsahil2001@gmail.com>
Date: Thu Jun 12 16:01:43 2025 +0530
[InstCombine] Ensure Safe Handling of Flags in foldFNegIntoConstant (#94148)
Fix #93769
alive2: https://alive2.llvm.org/ce/z/MHShQY
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
index fc7dd302b27a..f0f709bb16d8 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
@@ -2857,8 +2857,14 @@ static Instruction *foldFNegIntoConstant(Instruction &I, const DataLayout &DL) {
// Fold negation into constant operand.
// -(X * C) --> X * (-C)
if (match(FNegOp, m_FMul(m_Value(X), m_Constant(C))))
- if (Constant *NegC = ConstantFoldUnaryOpOperand(Instruction::FNeg, C, DL))
- return BinaryOperator::CreateFMulFMF(X, NegC, &I);
+ if (Constant *NegC = ConstantFoldUnaryOpOperand(Instruction::FNeg, C, DL)) {
+ FastMathFlags FNegF = I.getFastMathFlags();
+ FastMathFlags OpF = FNegOp->getFastMathFlags();
+ FastMathFlags FMF = FastMathFlags::unionValue(FNegF, OpF) |
+ FastMathFlags::intersectRewrite(FNegF, OpF);
+ FMF.setNoInfs(FNegF.noInfs() && OpF.noInfs());
+ return BinaryOperator::CreateFMulFMF(X, NegC, FMF);
+ }
// -(X / C) --> X / (-C)
if (match(FNegOp, m_FDiv(m_Value(X), m_Constant(C))))
if (Constant *NegC = ConstantFoldUnaryOpOperand(Instruction::FNeg, C, DL))
|
[
{
"file": "llvm/test/Transforms/InstCombine/fneg.ll",
"commands": [
"opt < %s -passes=instcombine -S",
"opt < %s -passes=instcombine -use-constant-fp-for-fixed-length-splat -S"
],
"tests": [
{
"test_name": "test_fneg_mul_combine_nsz_ninf_with_vec_const",
"test_body": "define <2 x float> @test_fneg_mul_combine_nsz_ninf_with_vec_const(<2 x float> %a) {\n %f1 = fmul nsz <2 x float> %a, <float 0.000000e+00, float -0.000000e+00>\n %f2 = fneg ninf <2 x float> %f1\n ret <2 x float> %f2\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fneg_mul_combine_reassoc_ninf_with_vec_const1",
"test_body": "define <2 x float> @test_fneg_mul_combine_reassoc_ninf_with_vec_const1(<2 x float> %a) {\n %f1 = fmul <2 x float> %a, <float 0.000000e+00, float -0.000000e+00>\n %f2 = fneg ninf <2 x float> %f1\n ret <2 x float> %f2\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fneg_ninf_mul_with_anyzero",
"test_body": "define float @test_fneg_ninf_mul_with_anyzero(float %a) {\n %mul = fmul float %a, 0.000000e+00\n %f = fneg ninf float %mul\n ret float %f\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fneg_mul_combine_contract_ninf_with_vec_const2",
"test_body": "define <2 x float> @test_fneg_mul_combine_contract_ninf_with_vec_const2(<2 x float> %a) {\n %f1 = fmul ninf <2 x float> %a, <float 0.000000e+00, float -0.000000e+00>\n %f2 = fneg ninf <2 x float> %f1\n ret <2 x float> %f2\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "fmul_fneg",
"test_body": "define float @fmul_fneg(float %x) {\n %m = fmul float %x, 4.200000e+01\n %r = fneg float %m\n ret float %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "fmul_fsub_fmf",
"test_body": "define float @fmul_fsub_fmf(float %x) {\n %m = fmul float %x, 4.200000e+01\n %r = fsub nsz float -0.000000e+00, %m\n ret float %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fneg_nnan_mul_with_anyzero",
"test_body": "define float @test_fneg_nnan_mul_with_anyzero(float %a) {\n %f1 = fmul ninf float %a, 0.000000e+00\n %f2 = fneg nnan float %f1\n ret float %f2\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fneg_mul_combine_nnan_ninf_with_vec_const2",
"test_body": "define <2 x float> @test_fneg_mul_combine_nnan_ninf_with_vec_const2(<2 x float> %a) {\n %f1 = fmul ninf <2 x float> %a, <float 0.000000e+00, float -0.000000e+00>\n %f2 = fneg nnan ninf <2 x float> %f1\n ret <2 x float> %f2\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fsub_ninf_mul_with_anyzero",
"test_body": "define float @test_fsub_ninf_mul_with_anyzero(float %a) {\n %f1 = fmul nsz float %a, 0.000000e+00\n %f2 = fsub ninf float -0.000000e+00, %f1\n ret float %f2\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fneg_nsz_mul_with_anyzero",
"test_body": "define float @test_fneg_nsz_mul_with_anyzero(float %a) {\n %f1 = fmul ninf float %a, 0.000000e+00\n %f2 = fneg nsz float %f1\n ret float %f2\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fneg_ninf_mul_nnan_with_const",
"test_body": "define float @test_fneg_ninf_mul_nnan_with_const(float %a) {\n %f1 = fmul nnan float %a, 0.000000e+00\n %f2 = fneg ninf float %f1\n ret float %f2\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fneg_ninf_nnan_mul_with_vec_const",
"test_body": "define <2 x float> @test_fneg_ninf_nnan_mul_with_vec_const(<2 x float> %a) {\n %f1 = fmul <2 x float> %a, <float 0.000000e+00, float -0.000000e+00>\n %f2 = fneg nnan ninf <2 x float> %f1\n ret <2 x float> %f2\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fneg_mul_combine_reassoc_ninf_with_vec_const3",
"test_body": "define <2 x float> @test_fneg_mul_combine_reassoc_ninf_with_vec_const3(<2 x float> %a) {\n %f1 = fmul <2 x float> %a, <float 0.000000e+00, float -0.000000e+00>\n %f2 = fneg ninf <2 x float> %f1\n ret <2 x float> %f2\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fneg_mul_combine_contract_ninf_with_vec_const1",
"test_body": "define <2 x float> @test_fneg_mul_combine_contract_ninf_with_vec_const1(<2 x float> %a) {\n %f1 = fmul <2 x float> %a, <float 0.000000e+00, float -0.000000e+00>\n %f2 = fneg ninf <2 x float> %f1\n ret <2 x float> %f2\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "fmul_fneg_fmf",
"test_body": "define float @fmul_fneg_fmf(float %x) {\n %m = fmul float %x, 4.200000e+01\n %r = fneg nsz float %m\n ret float %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fneg_mul_combine_nnan_ninf_with_vec_const",
"test_body": "define <2 x float> @test_fneg_mul_combine_nnan_ninf_with_vec_const(<2 x float> %a) {\n %f1 = fmul nnan <2 x float> %a, <float 0.000000e+00, float -0.000000e+00>\n %f2 = fneg ninf <2 x float> %f1\n ret <2 x float> %f2\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fneg_mul_combine_reassoc_ninf_with_vec_const2",
"test_body": "define <2 x float> @test_fneg_mul_combine_reassoc_ninf_with_vec_const2(<2 x float> %a) {\n %f1 = fmul ninf <2 x float> %a, <float 0.000000e+00, float -0.000000e+00>\n %f2 = fneg ninf <2 x float> %f1\n ret <2 x float> %f2\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fneg_mul_combine_contract_ninf_with_vec_const3",
"test_body": "define <2 x float> @test_fneg_mul_combine_contract_ninf_with_vec_const3(<2 x float> %a) {\n %f1 = fmul <2 x float> %a, <float 0.000000e+00, float -0.000000e+00>\n %f2 = fneg ninf <2 x float> %f1\n ret <2 x float> %f2\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fneg_ninf_mul_nsz_with_const",
"test_body": "define float @test_fneg_ninf_mul_nsz_with_const(float %a) {\n %f1 = fmul nsz float %a, 0.000000e+00\n %f2 = fneg ninf float %f1\n ret float %f2\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "foldFNegIntoConstant incorrectly preserves fast math flags for 0 constants",
"body": "> https://alive2.llvm.org/ce/z/MHShQY longer version\r\n\r\n_Originally posted by @arsenm in https://github.com/llvm/llvm-project/pull/92512#discussion_r1619895371_\r\n\r\n\r\nSome of the combines in foldFNegIntoConstant are unsafely taking the flags directly from the original fneg instruction, when the preservation logic requires dropping ninf in some cases. ",
"author": "arsenm",
"labels": [
"miscompilation",
"llvm:instcombine",
"floating-point"
],
"comments": [
{
"author": "SahilPatidar",
"body": "@arsenm, could we use the same logic you shared in #92512 for dropping `ninf`?\r\n```cpp\r\n FastMathFlags FMF = match(C, m_AnyZeroFP())? I.getFastMathFlags() &\r\n cast<FPMathOperator>(I.getOperand(0))->getFastMathFlags():\r\n I.getFastMathFlags();\r\n```\r\nHowever, this logic will also drop `nnan` and other flags. Should we check specifically for ninf instead?"
},
{
"author": "arsenm",
"body": "> However, this logic will also drop `nnan` and other flags. Should we check specifically for ninf instead?\r\n\r\nThat will be conservatively correct, but I think this can do better. For example, nnan on the fneg should be sufficient to preserve nnan on the final result, same with nsz "
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
121581
|
https://github.com/llvm/llvm-project/issues/121581
|
miscompilation
|
95c5c5d4badf7c2128d098be325356e15c2197be
| 2025-01-03T16:31:11 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "fac46469977da9c4e9c6eeaac21103c971190577",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": [
[
747,
752
],
[
764,
770
],
[
804,
810
]
],
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": [
"InstCombinerImpl::foldGEPICmp"
],
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit fac46469977da9c4e9c6eeaac21103c971190577
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Sat Jan 4 17:23:57 2025 +0800
[InstCombine] Check no wrap flags before folding icmp of GEPs with same indices (#121628)
Alive2: https://alive2.llvm.org/ce/z/Dr3Sbe
Closes https://github.com/llvm/llvm-project/issues/121581.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index d6fdade25559..8b23583c5106 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -747,6 +747,8 @@ Instruction *InstCombinerImpl::foldGEPICmp(GEPOperator *GEPLHS, Value *RHS,
ConstantExpr::getPointerBitCastOrAddrSpaceCast(
cast<Constant>(RHS), Base->getType()));
} else if (GEPOperator *GEPRHS = dyn_cast<GEPOperator>(RHS)) {
+ GEPNoWrapFlags NW = GEPLHS->getNoWrapFlags() & GEPRHS->getNoWrapFlags();
+
// If the base pointers are different, but the indices are the same, just
// compare the base pointer.
if (PtrBase != GEPRHS->getOperand(0)) {
@@ -764,7 +766,8 @@ Instruction *InstCombinerImpl::foldGEPICmp(GEPOperator *GEPLHS, Value *RHS,
// If all indices are the same, just compare the base pointers.
Type *BaseType = GEPLHS->getOperand(0)->getType();
- if (IndicesTheSame && CmpInst::makeCmpResultType(BaseType) == I.getType())
+ if (IndicesTheSame &&
+ CmpInst::makeCmpResultType(BaseType) == I.getType() && CanFold(NW))
return new ICmpInst(Cond, GEPLHS->getOperand(0), GEPRHS->getOperand(0));
// If we're comparing GEPs with two base pointers that only differ in type
@@ -804,7 +807,6 @@ Instruction *InstCombinerImpl::foldGEPICmp(GEPOperator *GEPLHS, Value *RHS,
return transformToIndexedCompare(GEPLHS, RHS, Cond, DL, *this);
}
- GEPNoWrapFlags NW = GEPLHS->getNoWrapFlags() & GEPRHS->getNoWrapFlags();
if (GEPLHS->getNumOperands() == GEPRHS->getNumOperands() &&
GEPLHS->getSourceElementType() == GEPRHS->getSourceElementType()) {
// If the GEPs only differ by one index, compare it.
|
[
{
"file": "llvm/test/Transforms/InstCombine/icmp-gep.ll",
"commands": [
"opt -passes=instcombine -S < %s"
],
"tests": [
{
"test_name": "pointer_icmp_aligned_with_offset_negative",
"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 @pointer_icmp_aligned_with_offset_negative(ptr align 8 %a, ptr align 8 %a2) {\n %gep = getelementptr i8, ptr %a, i64 8\n %cmp = icmp eq ptr %gep, %a2\n ret i1 %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "gep_diff_base_same_indices_nuw_nusw",
"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 @gep_diff_base_same_indices_nuw_nusw(ptr %x, ptr %y, i64 %z) {\n %gep1 = getelementptr nuw i8, ptr %x, i64 %z\n %gep2 = getelementptr nusw i8, ptr %y, i64 %z\n %cmp = icmp ult ptr %gep1, %gep2\n ret i1 %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "gep_diff_base_same_indices",
"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 @gep_diff_base_same_indices(ptr %x, ptr %y, i64 %z) {\n %gep1 = getelementptr i8, ptr %x, i64 %z\n %gep2 = getelementptr i8, ptr %y, i64 %z\n %cmp = icmp ult ptr %gep1, %gep2\n ret i1 %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "gep_diff_base_same_indices_nusw",
"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 @gep_diff_base_same_indices_nusw(ptr %x, ptr %y, i64 %z) {\n %gep1 = getelementptr nusw i8, ptr %x, i64 %z\n %gep2 = getelementptr nusw i8, ptr %y, i64 %z\n %cmp = icmp ult ptr %gep1, %gep2\n ret i1 %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "gep_diff_base_same_indices_nuw",
"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 @gep_diff_base_same_indices_nuw(ptr %x, ptr %y, i64 %z) {\n %gep1 = getelementptr nuw i8, ptr %x, i64 %z\n %gep2 = getelementptr nuw i8, ptr %y, i64 %z\n %cmp = icmp ult ptr %gep1, %gep2\n ret i1 %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstCombine] Incorrect fold of the comparison of GEPs",
"body": "Alive2: https://alive2.llvm.org/ce/z/HRsqeW\n```\ndefine i1 @test(ptr %x, ptr %y) {\n %gep1 = getelementptr i8, ptr %x, i32 1\n %gep2 = getelementptr i8, ptr %y, i32 1\n %cmp = icmp ult ptr %gep1, %gep2\n ret i1 %cmp\n}\n```\n```\n\n----------------------------------------\ndefine i1 @test(ptr %x, ptr %y) {\n#0:\n %gep1 = gep ptr %x, 1 x i32 1\n %gep2 = gep ptr %y, 1 x i32 1\n %cmp = icmp ult ptr %gep1, %gep2\n ret i1 %cmp\n}\n=>\ndefine i1 @test(ptr %x, ptr %y) {\n#0:\n %cmp = icmp ult ptr %x, %y\n ret i1 %cmp\n}\nTransformation doesn't verify!\n\nERROR: Value mismatch\n\nExample:\nptr %x = pointer(non-local, block_id=0, offset=-1) / Address=#xf\nptr %y = null\n\nSource:\nptr %gep1 = null\nptr %gep2 = pointer(non-local, block_id=0, offset=1) / Address=#x1\ni1 %cmp = #x1 (1)\n\nSOURCE MEMORY STATE\n===================\nNON-LOCAL BLOCKS:\nBlock 0 >\tsize: 0\talign: 1\talloc type: 0\talive: false\taddress: 0\nBlock 1 >\tsize: 1\talign: 2\talloc type: 0\talive: true\taddress: 2\nBlock 2 >\tsize: 0\talign: 1\talloc type: 0\talive: true\taddress: 3\n\nTarget:\ni1 %cmp = #x0 (0)\nSource value: #x1 (1)\nTarget value: #x0 (0)\n\nSummary:\n 0 correct transformations\n 1 incorrect transformations\n 0 failed-to-prove transformations\n 0 Alive2 errors\n```",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
97330
|
https://github.com/llvm/llvm-project/issues/97330
|
miscompilation
|
fdcfb277465e4530e5837fb8a95031794e58cb9b
| 2024-07-01T17:37:19 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "b558ac0eef57a3737b1e27844115fa91e0b32582",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": [
[
91,
98
],
[
124,
173
],
[
1105,
1117
],
[
1119,
1131
]
],
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": [
[
545,
554
]
],
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": [
"InstCombinerImpl::SimplifyDemandedBits",
"InstCombinerImpl::SimplifyDemandedUseBits"
],
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit b558ac0eef57a3737b1e27844115fa91e0b32582
Author: Nikita Popov <npopov@redhat.com>
Date: Tue Jul 2 10:08:45 2024 +0200
[InstCombine] Fix context for multi-use demanded bits simplification
When simplifying a multi-use root value, the demanded bits were
reset to full, but we also need to reset the context extract. To
make this convenient (without requiring by-value passing of
SimplifyQuery), move the logic that that handles constants and
dispatches to SimplifyDemandedUseBits/SimplifyMultipleUseDemandedBits
into SimplifyDemandedBits. The SimplifyDemandedInstructionBits
caller starts with full demanded bits and an appropriate context
anyway.
The different context instruction does mean that the ephemeral
value protection no longer triggers in some cases, as the changes
to assume tests show.
An alternative, which I will explore in a followup, is to always
use SimplifyMultipleUseDemandedBits() -- the previous root special
case is only really intended for SimplifyDemandedInstructionBits(),
which now no longer shares this code path.
Fixes https://github.com/llvm/llvm-project/issues/97330.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
index 318c455fd7ef..64fbcc80e0ed 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
+++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
@@ -545,10 +545,11 @@ public:
ConstantInt *&Less, ConstantInt *&Equal,
ConstantInt *&Greater);
- /// Attempts to replace V with a simpler value based on the demanded
+ /// Attempts to replace I with a simpler value based on the demanded
/// bits.
- Value *SimplifyDemandedUseBits(Value *V, APInt DemandedMask, KnownBits &Known,
- unsigned Depth, const SimplifyQuery &Q);
+ Value *SimplifyDemandedUseBits(Instruction *I, const APInt &DemandedMask,
+ KnownBits &Known, unsigned Depth,
+ const SimplifyQuery &Q);
using InstCombiner::SimplifyDemandedBits;
bool SimplifyDemandedBits(Instruction *I, unsigned Op,
const APInt &DemandedMask, KnownBits &Known,
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index 6cf2e71363ab..b1d03786f321 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -91,8 +91,47 @@ bool InstCombinerImpl::SimplifyDemandedBits(Instruction *I, unsigned OpNo,
KnownBits &Known, unsigned Depth,
const SimplifyQuery &Q) {
Use &U = I->getOperandUse(OpNo);
- Value *NewVal = SimplifyDemandedUseBits(U.get(), DemandedMask, Known,
- Depth, Q);
+ Value *V = U.get();
+ if (isa<Constant>(V)) {
+ llvm::computeKnownBits(V, Known, Depth, Q);
+ return false;
+ }
+
+ Known.resetAll();
+ if (DemandedMask.isZero()) {
+ // Not demanding any bits from V.
+ replaceUse(U, UndefValue::get(V->getType()));
+ return true;
+ }
+
+ if (Depth == MaxAnalysisRecursionDepth)
+ return false;
+
+ Instruction *VInst = dyn_cast<Instruction>(V);
+ if (!VInst) {
+ llvm::computeKnownBits(V, Known, Depth, Q);
+ return false;
+ }
+
+ Value *NewVal;
+ if (VInst->hasOneUse()) {
+ // If the instruction has one use, we can directly simplify it.
+ NewVal = SimplifyDemandedUseBits(VInst, DemandedMask, Known, Depth, Q);
+ } else if (Depth != 0) {
+ // If there are multiple uses of this instruction and we aren't at the root,
+ // then we can simplify VInst to some other value, but not modify the
+ // instruction.
+ NewVal =
+ SimplifyMultipleUseDemandedBits(VInst, DemandedMask, Known, Depth, Q);
+ } else {
+ // If this is the root being simplified, allow it to have multiple uses,
+ // just set the DemandedMask to all bits and reset the context instruction.
+ // This allows visitTruncInst (for example) to simplify the operand of a
+ // trunc without duplicating all the SimplifyDemandedUseBits() logic.
+ NewVal =
+ SimplifyDemandedUseBits(VInst, APInt::getAllOnes(Known.getBitWidth()),
+ Known, Depth, Q.getWithInstruction(VInst));
+ }
if (!NewVal) return false;
if (Instruction* OpInst = dyn_cast<Instruction>(U))
salvageDebugInfo(*OpInst);
@@ -124,50 +163,21 @@ bool InstCombinerImpl::SimplifyDemandedBits(Instruction *I, unsigned OpNo,
/// operands based on the information about what bits are demanded. This returns
/// some other non-null value if it found out that V is equal to another value
/// in the context where the specified bits are demanded, but not for all users.
-Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
+Value *InstCombinerImpl::SimplifyDemandedUseBits(Instruction *I,
+ const APInt &DemandedMask,
KnownBits &Known,
unsigned Depth,
const SimplifyQuery &Q) {
- assert(V != nullptr && "Null pointer of Value???");
+ assert(I != nullptr && "Null pointer of Value???");
assert(Depth <= MaxAnalysisRecursionDepth && "Limit Search Depth");
uint32_t BitWidth = DemandedMask.getBitWidth();
- Type *VTy = V->getType();
+ Type *VTy = I->getType();
assert(
(!VTy->isIntOrIntVectorTy() || VTy->getScalarSizeInBits() == BitWidth) &&
Known.getBitWidth() == BitWidth &&
"Value *V, DemandedMask and Known must have same BitWidth");
- if (isa<Constant>(V)) {
- llvm::computeKnownBits(V, Known, Depth, Q);
- return nullptr;
- }
-
- Known.resetAll();
- if (DemandedMask.isZero()) // Not demanding any bits from V.
- return UndefValue::get(VTy);
-
- if (Depth == MaxAnalysisRecursionDepth)
- return nullptr;
-
- Instruction *I = dyn_cast<Instruction>(V);
- if (!I) {
- llvm::computeKnownBits(V, Known, Depth, Q);
- return nullptr; // Only analyze instructions.
- }
-
- // If there are multiple uses of this value and we aren't at the root, then
- // we can't do any simplifications of the operands, because DemandedMask
- // only reflects the bits demanded by *one* of the users.
- if (Depth != 0 && !I->hasOneUse())
- return SimplifyMultipleUseDemandedBits(I, DemandedMask, Known, Depth, Q);
-
KnownBits LHSKnown(BitWidth), RHSKnown(BitWidth);
- // If this is the root being simplified, allow it to have multiple uses,
- // just set the DemandedMask to all bits so that we can try to simplify the
- // operands. This allows visitTruncInst (for example) to simplify the
- // operand of a trunc without duplicating all the logic below.
- if (Depth == 0 && !V->hasOneUse())
- DemandedMask.setAllBits();
// Update flags after simplifying an operand based on the fact that some high
// order bits are not demanded.
@@ -1105,13 +1115,13 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
}
if (!KnownBitsComputed)
- llvm::computeKnownBits(V, Known, Depth, Q);
+ llvm::computeKnownBits(I, Known, Depth, Q);
break;
}
}
- if (V->getType()->isPointerTy()) {
- Align Alignment = V->getPointerAlignment(DL);
+ if (I->getType()->isPointerTy()) {
+ Align Alignment = I->getPointerAlignment(DL);
Known.Zero.setLowBits(Log2(Alignment));
}
@@ -1119,13 +1129,14 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
// constant. We can't directly simplify pointers as a constant because of
// pointer provenance.
// TODO: We could return `(inttoptr const)` for pointers.
- if (!V->getType()->isPointerTy() && DemandedMask.isSubsetOf(Known.Zero | Known.One))
+ if (!I->getType()->isPointerTy() &&
+ DemandedMask.isSubsetOf(Known.Zero | Known.One))
return Constant::getIntegerValue(VTy, Known.One);
if (VerifyKnownBits) {
- KnownBits ReferenceKnown = llvm::computeKnownBits(V, Depth, Q);
+ KnownBits ReferenceKnown = llvm::computeKnownBits(I, Depth, Q);
if (Known != ReferenceKnown) {
- errs() << "Mismatched known bits for " << *V << " in "
+ errs() << "Mismatched known bits for " << *I << " in "
<< I->getFunction()->getName() << "\n";
errs() << "computeKnownBits(): " << ReferenceKnown << "\n";
errs() << "SimplifyDemandedBits(): " << Known << "\n";
|
[
{
"file": "llvm/test/Transforms/InstCombine/assume-inseltpoison.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "PR40940",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #0\n\ndefine i32 @PR40940(<4 x i8> %x) {\n %shuf = shufflevector <4 x i8> %x, <4 x i8> poison, <4 x i32> <i32 1, i32 1, i32 2, i32 3>\n %t2 = bitcast <4 x i8> %shuf to i32\n %t3 = icmp ult i32 %t2, 65536\n call void @llvm.assume(i1 %t3)\n ret i32 %t2\n}\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/InstCombine/assume.ll",
"commands": [
"opt < %s -passes=instcombine -S",
"opt < %s -passes=instcombine --enable-knowledge-retention -S",
"opt < %s -passes=instcombine -S --try-experimental-debuginfo-iterators",
"opt < %s -passes=instcombine --enable-knowledge-retention -S --try-experimental-debuginfo-iterators"
],
"tests": [
{
"test_name": "PR40940",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #0\n\ndefine i32 @PR40940(<4 x i8> %x) {\n %shuf = shufflevector <4 x i8> %x, <4 x i8> undef, <4 x i32> <i32 1, i32 1, i32 2, i32 3>\n %t2 = bitcast <4 x i8> %shuf to i32\n %t3 = icmp ult i32 %t2, 65536\n call void @llvm.assume(i1 %t3)\n ret i32 %t2\n}\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n\n!llvm.dbg.cu = !{}\n!llvm.module.flags = !{!0, !1, !2, !3}\n\n!0 = !{i32 2, !\"Dwarf Version\", i32 4}\n!1 = !{i32 2, !\"Debug Info Version\", i32 3}\n!2 = !{i32 1, !\"wchar_size\", i32 4}\n!3 = !{i32 8, !\"PIC Level\", i32 2}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/InstCombine/known-bits.ll",
"commands": [
"opt -S -passes=instcombine < %s"
],
"tests": [
{
"test_name": "simplifydemanded_context",
"test_body": "define i8 @simplifydemanded_context(i8 %x, i8 %y) {\n %and1 = and i8 %x, 1\n call void @dummy()\n %x.lobits = and i8 %x, 3\n %precond = icmp eq i8 %x.lobits, 0\n call void @llvm.assume(i1 %precond)\n %and2 = and i8 %and1, %y\n ret i8 %and2\n}\n\ndeclare void @dummy()\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #0\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "pr97330",
"test_body": "define i16 @pr97330(i1 %c, ptr %p1, ptr %p2) {\nentry:\n %v = load i64, ptr %p1, align 8\n %conv = trunc i64 %v to i16\n br i1 %c, label %exit, label %if\n\nif: ; preds = %entry\n %cmp = icmp ne i16 %conv, 1\n %conv2 = zext i1 %cmp to i32\n store i32 %conv2, ptr %p2, align 4\n %cmp2 = icmp eq i64 %v, 1\n call void @llvm.assume(i1 %cmp2)\n unreachable\n\nexit: ; preds = %entry\n ret i16 %conv\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #0\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstCombine] Miscompilation with llvm.assume in unreachable blocks",
"body": "Reproducer: https://alive2.llvm.org/ce/z/zKvpXV\r\n```\r\n; bin/opt -passes=instcombine reduced.ll -S\r\ndefine i16 @src(i16 %g, ptr %e, ptr %d) {\r\nentry:\r\n %0 = load i64, ptr %d, align 8\r\n %conv = trunc i64 %0 to i16\r\n %tobool.not.i = icmp eq i16 %g, 0\r\n br i1 %tobool.not.i, label %i.exit, label %for.cond.preheader.i\r\n\r\nfor.cond.preheader.i:\r\n %cmp5.i = icmp ne i16 %g, %conv\r\n %conv6.i = zext i1 %cmp5.i to i32\r\n store i32 %conv6.i, ptr %e, align 4\r\n %cmp7.i = icmp eq i64 %0, 1\r\n call void @llvm.assume(i1 %cmp7.i)\r\n unreachable\r\n\r\ni.exit:\r\n ret i16 %conv\r\n}\r\n```\r\n```\r\ndefine i16 @tgt(i16 %g, ptr %e, ptr %d) {\r\nentry:\r\n %tobool.not.i = icmp eq i16 %g, 0\r\n br i1 %tobool.not.i, label %i.exit, label %for.cond.preheader.i\r\n\r\nfor.cond.preheader.i: ; preds = %entry\r\n unreachable\r\n\r\ni.exit: ; preds = %entry\r\n ret i16 1\r\n}\r\n```\r\n\r\nllvm version: a8e1c3e1239604ac787b6a2d39b5278ddec8aa8a\r\n\r\ncc @nikic",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Reverting https://github.com/llvm/llvm-project/commit/11484cb817bcc2a6e2ef9572be982a1a5a4964ec fixes this issue.\r\n"
},
{
"author": "nikic",
"body": "I've applied two fixes for this. https://github.com/llvm/llvm-project/commit/86b37944a70229b07626e63bdb9a46b4bc3d1460 tries to stick closer to the current logic, while https://github.com/llvm/llvm-project/commit/05670b42f5b45710bfdba48dcb7e8c30c8c7478f is a more thorough fix on top of that."
},
{
"author": "dtcxzyw",
"body": "Confirmed that the original case has been fixed. Thank you!\r\n"
},
{
"author": "chapuni",
"body": "@nikic Fixed, thanks!"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
121432
|
https://github.com/llvm/llvm-project/issues/121432
|
miscompilation
|
b51a082e1afd707f8cf1473e4c49374e7e951d2d
| 2025-01-01T11:07:27 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "c05599966cd594c15834378f57669719d221c4d4",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": [
[
2673,
2680
]
],
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": [
"InstCombinerImpl::visitCallInst"
],
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit c05599966cd594c15834378f57669719d221c4d4
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Mon Jan 6 16:23:46 2025 +0800
[InstCombine] Fix FMF propagation in `copysign Mag, (copysign ?, X) -> copysign Mag, X` (#121574)
Closes https://github.com/llvm/llvm-project/issues/121432.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index cdb2c11ef046..5494c70b34b1 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -2673,8 +2673,12 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
// Propagate sign argument through nested calls:
// copysign Mag, (copysign ?, X) --> copysign Mag, X
Value *X;
- if (match(Sign, m_Intrinsic<Intrinsic::copysign>(m_Value(), m_Value(X))))
- return replaceOperand(*II, 1, X);
+ if (match(Sign, m_Intrinsic<Intrinsic::copysign>(m_Value(), m_Value(X)))) {
+ Value *CopySign = Builder.CreateCopySign(
+ Mag, X,
+ II->getFastMathFlags() & cast<Instruction>(Sign)->getFastMathFlags());
+ return replaceInstUsesWith(*II, CopySign);
+ }
// Clear sign-bit of constant magnitude:
// copysign -MagC, X --> copysign MagC, X
|
[
{
"file": "llvm/test/Transforms/InstCombine/copysign.ll",
"commands": [
"opt -S -passes=instcombine < %s"
],
"tests": [
{
"test_name": "copysign_sign_arg_mixed",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.copysign.f32(float, float) #0\n\ndefine float @copysign_sign_arg_mixed(float %x, float %y, float %z) {\n %s = call ninf nsz float @llvm.copysign.f32(float %y, float %z)\n %r = call nnan nsz float @llvm.copysign.f32(float %x, float %s)\n ret float %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "copysign_sign_arg",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.copysign.f32(float, float) #0\n\ndefine float @copysign_sign_arg(float %x, float %y, float %z) {\n %s = call float @llvm.copysign.f32(float %y, float %z)\n %r = call ninf float @llvm.copysign.f32(float %x, float %s)\n ret float %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "fneg_mag",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.copysign.f32(float, float) #0\n\ndefine float @fneg_mag(float %x, float %y) {\n %n = fneg float %x\n %r = call float @llvm.copysign.f32(float %n, float %y)\n ret float %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "copysign_sign_arg_nnan",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.copysign.f32(float, float) #0\n\ndefine float @copysign_sign_arg_nnan(float %x, float %y, float %z) {\n %s = call nnan float @llvm.copysign.f32(float %y, float %z)\n %r = call nnan float @llvm.copysign.f32(float %x, float %s)\n ret float %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "not_known_positive_sign_arg",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.copysign.f32(float, float) #0\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.maxnum.f32(float, float) #0\n\ndefine float @not_known_positive_sign_arg(float %x, float %y) {\n %max = call float @llvm.maxnum.f32(float %x, float 0.000000e+00)\n %r = call ninf float @llvm.copysign.f32(float %y, float %max)\n ret float %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstCombine] FMF flags should not be propagated",
"body": "Alive2: https://alive2.llvm.org/ce/z/ajCxTh\n```\ndefine float @src1(float noundef %x, float noundef %y, float noundef %z) {\n %s = call float @llvm.copysign.f32(float %y, float %z)\n %r = call nnan float @llvm.copysign.f32(float %x, float %s)\n ret float %r\n}\n\ndefine float @tgt1(float noundef %x, float noundef %y, float noundef %z) {\n %r = call nnan float @llvm.copysign.f32(float %x, float %z)\n ret float %r\n}\n\ndefine float @src2(float noundef %x, float noundef %y, float noundef %z) {\n %s = call float @llvm.copysign.f32(float %y, float %z)\n %r = call ninf float @llvm.copysign.f32(float %x, float %s)\n ret float %r\n}\n\ndefine float @tgt2(float noundef %x, float noundef %y, float noundef %z) {\n %r = call ninf float @llvm.copysign.f32(float %x, float %z)\n ret float %r\n}\n\ndefine float @src3(float noundef %x, float noundef %y, float noundef %z) {\n %s = call float @llvm.copysign.f32(float %y, float %z)\n %r = call nsz float @llvm.copysign.f32(float %x, float %s)\n ret float %r\n}\n\ndefine float @tgt3(float noundef %x, float noundef %y, float noundef %z) {\n %r = call nsz float @llvm.copysign.f32(float %x, float %z)\n ret float %r\n}\n```\n",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:instcombine",
"floating-point"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
124526
|
https://github.com/llvm/llvm-project/issues/124526
|
crash
|
e14962a39cc6476bebba65e5639b74b0318c7fc3
| 2025-01-27T10:24:37 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "212f344b84b400c0a9dedfa3c1ec6af9d9d30223",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": [
[
732,
738
]
],
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": [
"tryFactorization"
],
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 212f344b84b400c0a9dedfa3c1ec6af9d9d30223
Author: Nikita Popov <npopov@redhat.com>
Date: Mon Jan 27 16:24:15 2025 +0100
[InstCombine] Handle constant expression result in tryFactorization()
If IRBuilder folds the result to a constant expression, don't try
to set nowrap flags on it.
Fixes https://github.com/llvm/llvm-project/issues/124526.
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index cad17c511b6d..a64c188575e6 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -732,7 +732,7 @@ static Value *tryFactorization(BinaryOperator &I, const SimplifyQuery &SQ,
RetVal->takeName(&I);
// Try to add no-overflow flags to the final value.
- if (isa<OverflowingBinaryOperator>(RetVal)) {
+ if (isa<BinaryOperator>(RetVal)) {
bool HasNSW = false;
bool HasNUW = false;
if (isa<OverflowingBinaryOperator>(&I)) {
|
[
{
"file": "llvm/test/Transforms/InstCombine/add2.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "mul_add_to_mul_9",
"test_body": "define i16 @mul_add_to_mul_9(i16 %a) {\n %mul1 = mul nsw i16 %a, 16384\n %mul2 = mul nsw i16 %a, 16384\n %add = add nsw i16 %mul1, %mul2\n ret i16 %add\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "shl_add_to_shl_constexpr",
"test_body": "@g = external global i8\n\ndefine i32 @shl_add_to_shl_constexpr() {\n %shl = shl i32 ptrtoint (ptr @g to i32), 1\n %add = add i32 %shl, %shl\n ret i32 %add\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[clang] Crash at -O2: Assertion `isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"' failed.",
"body": "This code crashes at `-O2`:\n\n```c\nint a, b;\nvoid c();\nint d(int e) {\n if (e)\n return 3;\n return 2;\n}\nint f(int e) {\n int i = d(e) + e;\n return i;\n}\nint j(int e) {\n static char g;\n char *h = &g;\n a = h - \"\";\n b = a << e;\n return f(b - 7) + 303 + b;\n}\nvoid k() {\n int l = j(4);\n c(l);\n}\n```\n\nCompiler Explorer: https://godbolt.org/z/4h9PrKG8z\n\nCrash:\n\n```console\nclang: /root/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From*) [with To = llvm::Instruction; From = llvm::Value]: Assertion `isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"' failed.\n```\n\nBacktrace:\n\n```console\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O2 -Wextra -Wall <source>\n1.\t<eof> parser at end of file\n2.\tOptimizer\n3.\tRunning pass \"require<globals-aa>,function(invalidate<aa>),require<profile-summary>,cgscc(devirt<4>(inline,function-attrs<skip-non-recursive-function-attrs>,openmp-opt-cgscc,function<eager-inv;no-rerun>(sroa<modify-cfg>,early-cse<memssa>,speculative-execution<only-if-divergent-target>,jump-threading,correlated-propagation,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>,aggressive-instcombine,libcalls-shrinkwrap,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,reassociate,constraint-elimination,loop-mssa(loop-instsimplify,loop-simplifycfg,licm<no-allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-unswitch<no-nontrivial;trivial>),simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>,loop(loop-idiom,indvars,extra-simple-loop-unswitch-passes,loop-deletion,loop-unroll-full),sroa<modify-cfg>,vector-combine,mldst-motion<no-split-footer-bb>,gvn<>,sccp,bdce,instcombine<max-iterations=1;no-verify-fixpoint>,jump-threading,correlated-propagation,adce,memcpyopt,dse,move-auto-init,loop-mssa(licm<allowspeculation>),coro-elide,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>),function-attrs,function(require<should-not-run-function-passes>),coro-split,coro-annotation-elide)),function(invalidate<should-not-run-function-passes>),cgscc(devirt<4>())\" on module \"<source>\"\n4.\tRunning pass \"cgscc(devirt<4>(inline,function-attrs<skip-non-recursive-function-attrs>,openmp-opt-cgscc,function<eager-inv;no-rerun>(sroa<modify-cfg>,early-cse<memssa>,speculative-execution<only-if-divergent-target>,jump-threading,correlated-propagation,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>,aggressive-instcombine,libcalls-shrinkwrap,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,reassociate,constraint-elimination,loop-mssa(loop-instsimplify,loop-simplifycfg,licm<no-allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-unswitch<no-nontrivial;trivial>),simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>,loop(loop-idiom,indvars,extra-simple-loop-unswitch-passes,loop-deletion,loop-unroll-full),sroa<modify-cfg>,vector-combine,mldst-motion<no-split-footer-bb>,gvn<>,sccp,bdce,instcombine<max-iterations=1;no-verify-fixpoint>,jump-threading,correlated-propagation,adce,memcpyopt,dse,move-auto-init,loop-mssa(licm<allowspeculation>),coro-elide,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>),function-attrs,function(require<should-not-run-function-passes>),coro-split,coro-annotation-elide))\" on module \"<source>\"\n5.\tRunning pass \"instcombine<max-iterations=1;no-verify-fixpoint>\" on function \"k\"\n #0 0x0000000003def1b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3def1b8)\n #1 0x0000000003dece74 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dece74)\n #2 0x0000000003d39368 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0\n #3 0x0000789749042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #4 0x00007897490969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #5 0x0000789749042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #6 0x00007897490287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #7 0x000078974902871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #8 0x0000789749039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #9 0x0000000000d8d74a (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd8d74a)\n#10 0x0000000003935620 tryFactorization(llvm::BinaryOperator&, llvm::SimplifyQuery const&, llvm::IRBuilder<llvm::TargetFolder, llvm::IRBuilderCallbackInserter>&, llvm::Instruction::BinaryOps, llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*) InstructionCombining.cpp:0:0\n#11 0x0000000003935ce2 llvm::InstCombinerImpl::tryFactorizationFolds(llvm::BinaryOperator&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3935ce2)\n#12 0x0000000003935d67 llvm::InstCombinerImpl::foldUsingDistributiveLaws(llvm::BinaryOperator&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3935d67)\n#13 0x0000000003972ab2 llvm::InstCombinerImpl::visitAdd(llvm::BinaryOperator&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3972ab2)\n#14 0x00000000039586c1 llvm::InstCombinerImpl::run() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x39586c1)\n#15 0x000000000395a066 combineInstructionsOverFunction(llvm::Function&, llvm::InstructionWorklist&, llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::BranchProbabilityInfo*, llvm::ProfileSummaryInfo*, llvm::InstCombineOptions const&) (.isra.0) InstructionCombining.cpp:0:0\n#16 0x000000000395b52c llvm::InstCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x395b52c)\n#17 0x0000000004094a6e llvm::detail::PassModel<llvm::Function, llvm::InstCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4094a6e)\n#18 0x0000000003796c50 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3796c50)\n#19 0x000000000114aa4e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x114aa4e)\n#20 0x0000000002c71112 llvm::CGSCCToFunctionPassAdaptor::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x2c71112)\n#21 0x000000000114aede llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::CGSCCToFunctionPassAdaptor, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x114aede)\n#22 0x0000000002c68502 llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x2c68502)\n#23 0x000000000548dd6e llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x548dd6e)\n#24 0x0000000002c6dbd6 llvm::DevirtSCCRepeatedPass::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x2c6dbd6)\n#25 0x000000000548dd8e llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::DevirtSCCRepeatedPass, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x548dd8e)\n#26 0x0000000002c6ba86 llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x2c6ba86)\n#27 0x000000000548dd4e llvm::detail::PassModel<llvm::Module, llvm::ModuleToPostOrderCGSCCPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x548dd4e)\n#28 0x0000000003794f70 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3794f70)\n#29 0x00000000056e3783 llvm::ModuleInlinerWrapperPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x56e3783)\n#30 0x000000000532b69e llvm::detail::PassModel<llvm::Module, llvm::ModuleInlinerWrapperPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x532b69e)\n#31 0x0000000003794f70 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3794f70)\n#32 0x00000000040a7734 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\n#33 0x00000000040ab13e clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x40ab13e)\n#34 0x000000000477edb0 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x477edb0)\n#35 0x00000000067c259c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x67c259c)\n#36 0x000000000477f1b8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x477f1b8)\n#37 0x0000000004a44575 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4a44575)\n#38 0x00000000049c72ae clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x49c72ae)\n#39 0x0000000004b31ede clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4b31ede)\n#40 0x0000000000cfcd0f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xcfcd0f)\n#41 0x0000000000cf47aa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#42 0x00000000047c5ae9 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0\n#43 0x0000000003d39814 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3d39814)\n#44 0x00000000047c60df clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0\n#45 0x0000000004788f4d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4788f4d)\n#46 0x0000000004789fce clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4789fce)\n#47 0x0000000004791b05 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4791b05)\n#48 0x0000000000cf9b23 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xcf9b23)\n#49 0x0000000000bc2a84 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbc2a84)\n#50 0x0000789749029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#51 0x0000789749029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#52 0x0000000000cf4255 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xcf4255)\n```",
"author": "cardigan1008",
"labels": [
"crash",
"llvm:instcombine",
"regression:19"
],
"comments": [
{
"author": "shafik",
"body": "Looks like a clang-19 regression: https://godbolt.org/z/EvWdTGY6E"
},
{
"author": "nikic",
"body": "```llvm\n; RUN: opt -passes=instcombine < %s\n@g = external global i8\n\ndefine i32 @test() {\n %shl = shl i32 ptrtoint (ptr @g to i32), 1\n %add1 = add i32 %shl, -1\n %add2 = add i32 %shl, 2\n %add3 = add i32 %add1, %add2\n ret i32 %add3 \n} \n```"
},
{
"author": "nikic",
"body": "Further reduced:\n```llvm\n@g = external global i8\n\ndefine i32 @test() {\n %shl = shl i32 ptrtoint (ptr @g to i32), 1\n %add = add i32 %shl, %shl\n ret i32 %add \n} \n```"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
139728
|
https://github.com/llvm/llvm-project/issues/139728
|
crash
|
be6c1684c058ff40b5cb29e7eb88f06f72dd50df
| 2025-05-13T13:36:11 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "d79d9b8fbfc7e8411aeaf2f5e1be9d4247594fee",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
16142,
16157
],
[
16210,
16216
],
[
17799,
17815
],
[
18696,
18701
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::getLastInstructionInBundle",
"BoUpSLP::setInsertPointAfterBundle",
"BoUpSLP::vectorizeTree"
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit d79d9b8fbfc7e8411aeaf2f5e1be9d4247594fee
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Fri May 16 12:52:27 2025 -0400
[SLP]Change the insertion point for outside-block-used nodes and prevec phi operand gathers
Need to set the insertion point for (non-schedulable) vector node after
the last instruction in the node to avoid def-use breakage. But it also
causes miscompilation with gather/buildvector operands of the phi nodes,
used in the same phi only in the block.
These nodes supposed to be inserted at the end of the block and after
changing the insertion point for the non-schedulable vec block, it also
may break def-use dependencies. Need to prevector such nodes, to emit
them as early as possible, so the vectorized nodes are inserted before
these nodes.
Fixes #139728
Reviewers: hiraditya, HanKuanChen, RKSimon
Reviewed By: RKSimon
Pull Request: https://github.com/llvm/llvm-project/pull/139917
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index eb339282fdae..19d19946ea23 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -16142,16 +16142,10 @@ Instruction &BoUpSLP::getLastInstructionInBundle(const TreeEntry *E) {
[](Value *V) {
return !isa<GetElementPtrInst>(V) && isa<Instruction>(V);
})) ||
- all_of(E->Scalars,
- [](Value *V) {
- return isa<PoisonValue>(V) ||
- (!isVectorLikeInstWithConstOps(V) &&
- isUsedOutsideBlock(V));
- }) ||
- (E->isGather() && E->Idx == 0 && all_of(E->Scalars, [](Value *V) {
- return isa<ExtractElementInst, UndefValue>(V) ||
- areAllOperandsNonInsts(V);
- })))
+ all_of(E->Scalars, [](Value *V) {
+ return isa<PoisonValue>(V) ||
+ (!isVectorLikeInstWithConstOps(V) && isUsedOutsideBlock(V));
+ }))
Res = FindLastInst();
else
Res = FindFirstInst();
@@ -16210,7 +16204,7 @@ void BoUpSLP::setInsertPointAfterBundle(const TreeEntry *E) {
}
if (IsPHI ||
(!E->isGather() && E->State != TreeEntry::SplitVectorize &&
- doesNotNeedToSchedule(E->Scalars)) ||
+ all_of(E->Scalars, areAllOperandsNonInsts)) ||
(GatheredLoadsEntriesFirst.has_value() &&
E->Idx >= *GatheredLoadsEntriesFirst && !E->isGather() &&
E->getOpcode() == Instruction::Load)) {
@@ -17799,17 +17793,27 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) {
Value *VecOp = NewPhi->getIncomingValueForBlock(IBB);
NewPhi->addIncoming(VecOp, IBB);
TreeEntry *OpTE = getOperandEntry(E, I);
+ assert(!OpTE->VectorizedValue && "Expected no vectorized value.");
OpTE->VectorizedValue = VecOp;
continue;
}
Builder.SetInsertPoint(IBB->getTerminator());
Builder.SetCurrentDebugLocation(PH->getDebugLoc());
- Value *Vec = vectorizeOperand(E, I);
+ const TreeEntry *OpE = getOperandEntry(E, I);
+ Value *Vec;
+ if (OpE->isGather()) {
+ assert(OpE->VectorizedValue && "Expected vectorized value.");
+ Vec = OpE->VectorizedValue;
+ if (auto *IVec = dyn_cast<Instruction>(Vec))
+ Builder.SetInsertPoint(IVec->getNextNonDebugInstruction());
+ } else {
+ Vec = vectorizeOperand(E, I);
+ }
if (VecTy != Vec->getType()) {
- assert((It != MinBWs.end() || getOperandEntry(E, I)->isGather() ||
- MinBWs.contains(getOperandEntry(E, I))) &&
- "Expected item in MinBWs.");
+ assert(
+ (It != MinBWs.end() || OpE->isGather() || MinBWs.contains(OpE)) &&
+ "Expected item in MinBWs.");
Vec = Builder.CreateIntCast(Vec, VecTy, GetOperandSignedness(I));
}
NewPhi->addIncoming(Vec, IBB);
@@ -18696,6 +18700,28 @@ Value *BoUpSLP::vectorizeTree(
else
Builder.SetInsertPoint(&F->getEntryBlock(), F->getEntryBlock().begin());
+ // Vectorize gather operands of the PHI nodes.
+ for (const std::unique_ptr<TreeEntry> &TE : reverse(VectorizableTree)) {
+ if (TE->isGather() && TE->UserTreeIndex.UserTE &&
+ TE->UserTreeIndex.UserTE->hasState() &&
+ !TE->UserTreeIndex.UserTE->isAltShuffle() &&
+ TE->UserTreeIndex.UserTE->State == TreeEntry::Vectorize &&
+ TE->UserTreeIndex.UserTE->getOpcode() == Instruction::PHI &&
+ !TE->VectorizedValue) {
+ auto *PH = cast<PHINode>(TE->UserTreeIndex.UserTE->getMainOp());
+ BasicBlock *IBB = PH->getIncomingBlock(TE->UserTreeIndex.EdgeIdx);
+ // If there is the same incoming block earlier - skip, it will be handled
+ // in PHI node.
+ if (TE->UserTreeIndex.EdgeIdx > 0 &&
+ any_of(seq<unsigned>(TE->UserTreeIndex.EdgeIdx), [&](unsigned Idx) {
+ return PH->getIncomingBlock(Idx) == IBB;
+ }))
+ continue;
+ Builder.SetInsertPoint(IBB->getTerminator());
+ Builder.SetCurrentDebugLocation(PH->getDebugLoc());
+ (void)vectorizeTree(TE.get());
+ }
+ }
// Emit gathered loads first to emit better code for the users of those
// gathered loads.
for (const std::unique_ptr<TreeEntry> &TE : VectorizableTree) {
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/AArch64/reused-scalar-repeated-in-node.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=aarch64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define void @test() {\nentry:\n br label %bb61\n\nbb61: ; preds = %entry\n br label %bb64\n\nbb62: ; No predecessors!\n br i1 poison, label %bb63, label %bb64\n\nbb63: ; preds = %bb62\n br label %bb64\n\nbb64: ; preds = %bb63, %bb62, %bb61\n %i = phi nsz float [ poison, %bb61 ], [ poison, %bb63 ], [ poison, %bb62 ]\n %i65 = phi nsz float [ poison, %bb61 ], [ poison, %bb63 ], [ poison, %bb62 ]\n %i66 = load float, ptr poison, align 16\n %i67 = load float, ptr poison, align 4\n %i68 = load float, ptr poison, align 8\n %i69 = load float, ptr poison, align 4\n %i70 = load float, ptr poison, align 4\n %i71 = load float, ptr poison, align 16\n %i72 = load float, ptr poison, align 4\n %i73 = load float, ptr poison, align 8\n %i74 = load float, ptr poison, align 4\n %i75 = load float, ptr poison, align 16\n %i76 = load float, ptr poison, align 4\n br i1 poison, label %bb167, label %bb77\n\nbb77: ; preds = %bb64\n br label %bb78\n\nbb78: ; preds = %bb78, %bb77\n %i79 = phi nsz float [ %i66, %bb77 ], [ %i103, %bb78 ]\n %i80 = phi nsz float [ %i67, %bb77 ], [ %i104, %bb78 ]\n %i81 = phi nsz float [ %i68, %bb77 ], [ %i105, %bb78 ]\n %i82 = phi nsz float [ poison, %bb77 ], [ %i106, %bb78 ]\n %i83 = phi nsz float [ poison, %bb77 ], [ %i123, %bb78 ]\n %i84 = phi nsz float [ %i69, %bb77 ], [ %i124, %bb78 ]\n %i85 = phi nsz float [ poison, %bb77 ], [ %i125, %bb78 ]\n %i86 = phi nsz float [ %i70, %bb77 ], [ %i126, %bb78 ]\n %i87 = fmul fast float %i79, poison\n %i88 = fmul fast float %i80, poison\n %i89 = fmul fast float %i81, poison\n %i90 = fmul fast float %i82, poison\n %i91 = fmul fast float %i83, poison\n %i92 = fadd fast float %i91, %i87\n %i93 = fmul fast float %i84, poison\n %i94 = fadd fast float %i93, %i88\n %i95 = fmul fast float %i85, poison\n %i96 = fadd fast float %i95, %i89\n %i97 = fmul fast float %i86, poison\n %i98 = fadd fast float %i97, %i90\n %i99 = fadd fast float %i92, poison\n %i100 = fadd fast float %i94, poison\n %i101 = fadd fast float %i96, poison\n %i102 = fadd fast float %i98, poison\n %i103 = fadd fast float %i99, poison\n %i104 = fadd fast float %i100, poison\n %i105 = fadd fast float %i101, poison\n %i106 = fadd fast float %i102, poison\n %i107 = fmul fast float %i79, poison\n %i108 = fmul fast float %i80, poison\n %i109 = fmul fast float %i81, poison\n %i110 = fmul fast float %i82, poison\n %i111 = fmul fast float %i83, poison\n %i112 = fadd fast float %i111, %i107\n %i113 = fmul fast float %i84, poison\n %i114 = fadd fast float %i113, %i108\n %i115 = fmul fast float %i85, poison\n %i116 = fadd fast float %i115, %i109\n %i117 = fmul fast float %i86, poison\n %i118 = fadd fast float %i117, %i110\n %i119 = fadd fast float %i112, poison\n %i120 = fadd fast float %i114, poison\n %i121 = fadd fast float %i116, poison\n %i122 = fadd fast float %i118, poison\n %i123 = fadd fast float %i119, poison\n %i124 = fadd fast float %i120, poison\n %i125 = fadd fast float %i121, poison\n %i126 = fadd fast float %i122, poison\n %i127 = fmul fast float %i79, %i\n %i128 = fmul fast float %i80, %i\n %i129 = fmul fast float %i81, %i\n %i130 = fmul fast float %i82, %i\n %i131 = fmul fast float %i83, %i65\n %i132 = fadd fast float %i131, %i127\n %i133 = fmul fast float %i84, %i65\n %i134 = fadd fast float %i133, %i128\n %i135 = fmul fast float %i85, %i65\n %i136 = fadd fast float %i135, %i129\n %i137 = fmul fast float %i86, %i65\n %i138 = fadd fast float %i137, %i130\n %i139 = fadd fast float %i132, poison\n %i140 = fadd fast float %i134, poison\n %i141 = fadd fast float %i136, poison\n %i142 = fadd fast float %i138, poison\n %i143 = fadd fast float %i139, poison\n %i144 = fadd fast float %i140, poison\n %i145 = fadd fast float %i141, poison\n %i146 = fadd fast float %i142, poison\n %i147 = fmul fast float %i79, poison\n %i148 = fmul fast float %i80, poison\n %i149 = fmul fast float %i81, poison\n %i150 = fmul fast float %i82, poison\n %i151 = fmul fast float %i83, poison\n %i152 = fadd fast float %i151, %i147\n %i153 = fmul fast float %i84, poison\n %i154 = fadd fast float %i153, %i148\n %i155 = fmul fast float %i85, poison\n %i156 = fadd fast float %i155, %i149\n %i157 = fmul fast float %i86, poison\n %i158 = fadd fast float %i157, %i150\n %i159 = fadd fast float %i152, poison\n %i160 = fadd fast float %i154, poison\n %i161 = fadd fast float %i156, poison\n %i162 = fadd fast float %i158, poison\n %i163 = fadd fast float %i159, poison\n %i164 = fadd fast float %i160, poison\n %i165 = fadd fast float %i161, poison\n %i166 = fadd fast float %i162, poison\n br i1 poison, label %bb78, label %bb167\n\nbb167: ; preds = %bb78, %bb64\n %i168 = phi nsz float [ %i76, %bb64 ], [ %i166, %bb78 ]\n %i169 = phi nsz float [ poison, %bb64 ], [ %i165, %bb78 ]\n %i170 = phi nsz float [ poison, %bb64 ], [ %i164, %bb78 ]\n %i171 = phi nsz float [ %i75, %bb64 ], [ %i163, %bb78 ]\n %i172 = phi nsz float [ %i74, %bb64 ], [ %i146, %bb78 ]\n %i173 = phi nsz float [ %i73, %bb64 ], [ %i145, %bb78 ]\n %i174 = phi nsz float [ %i72, %bb64 ], [ %i144, %bb78 ]\n %i175 = phi nsz float [ %i71, %bb64 ], [ %i143, %bb78 ]\n %i176 = phi nsz float [ %i70, %bb64 ], [ %i126, %bb78 ]\n %i177 = phi nsz float [ poison, %bb64 ], [ %i125, %bb78 ]\n %i178 = phi nsz float [ %i69, %bb64 ], [ %i124, %bb78 ]\n %i179 = phi nsz float [ poison, %bb64 ], [ %i123, %bb78 ]\n %i180 = phi nsz float [ poison, %bb64 ], [ %i106, %bb78 ]\n %i181 = phi nsz float [ %i68, %bb64 ], [ %i105, %bb78 ]\n %i182 = phi nsz float [ %i67, %bb64 ], [ %i104, %bb78 ]\n %i183 = phi nsz float [ %i66, %bb64 ], [ %i103, %bb78 ]\n store float %i182, ptr poison, align 1\n store float %i174, ptr poison, align 1\n br i1 poison, label %bb186, label %bb184\n\nbb184: ; preds = %bb167\n br label %bb185\n\nbb185: ; preds = %bb185, %bb184\n br i1 poison, label %bb185, label %bb186\n\nbb186: ; preds = %bb185, %bb167\n %i187 = phi nsz float [ %i178, %bb167 ], [ poison, %bb185 ]\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/buildvectors-parent-phi-nodes.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-generic-linux-gnu -mattr=+avx < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define void @test(ptr %0, float %1) {\n %3 = load float, ptr %0, align 4\n br label %4\n\n4: ; preds = %4, %2\n %5 = phi float [ %1, %4 ], [ %3, %2 ]\n %6 = phi float [ %1, %4 ], [ 0.000000e+00, %2 ]\n %7 = phi float [ %28, %4 ], [ 0.000000e+00, %2 ]\n %8 = phi float [ %26, %4 ], [ 0.000000e+00, %2 ]\n %9 = phi float [ %26, %4 ], [ %3, %2 ]\n %10 = phi float [ %24, %4 ], [ 0.000000e+00, %2 ]\n %11 = fmul float %9, 0.000000e+00\n %12 = fadd float %11, 0.000000e+00\n %13 = fmul float %7, 0.000000e+00\n %14 = fadd float %13, 0.000000e+00\n %15 = fmul float %10, 0.000000e+00\n %16 = fadd float %15, 0.000000e+00\n %17 = fmul float %8, 0.000000e+00\n %18 = fadd float %17, 0.000000e+00\n %19 = insertelement <4 x float> zeroinitializer, float %12, i64 0\n %20 = insertelement <4 x float> %19, float %14, i64 1\n %21 = insertelement <4 x float> %20, float %16, i64 2\n %22 = insertelement <4 x float> %21, float %18, i64 3\n store <4 x float> %22, ptr %0, align 16\n %23 = fmul float %6, 0.000000e+00\n %24 = fadd float %23, 0.000000e+00\n %25 = fmul float %6, 0.000000e+00\n %26 = fadd float %25, 0.000000e+00\n %27 = fmul float %5, 0.000000e+00\n %28 = fadd float %27, 0.000000e+00\n br label %4\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/full-matched-bv-with-subvectors.ll",
"commands": [
"opt -S --passes=slp-vectorizer -slp-threshold=-9999 -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define i32 @test(i64 %l.549) {\nentry:\n %conv3 = sext i32 0 to i64\n br label %if.then19\n\np: ; preds = %if.end29, %if.end25\n %l.0 = phi i64 [ %xor, %if.end29 ], [ %l.5493, %if.end25 ]\n %m.0 = phi i64 [ %not21, %if.end29 ], [ %m.550, %if.end25 ]\n br i1 false, label %s, label %q\n\nq: ; preds = %land.lhs.true, %p\n %xor39 = phi i64 [ 0, %p ], [ 0, %land.lhs.true ]\n %l.1 = phi i64 [ 0, %p ], [ 0, %land.lhs.true ]\n %m.1 = phi i64 [ 0, %p ], [ 0, %land.lhs.true ]\n br i1 false, label %lor.lhs.false, label %r\n\nlor.lhs.false: ; preds = %q\n br i1 false, label %land.lhs.true, label %s\n\nr: ; preds = %if.then19, %q\n %xor38 = phi i64 [ %xor39, %q ], [ %xor, %if.then19 ]\n %j.0 = phi i64 [ %conv3, %q ], [ %not21, %if.then19 ]\n %l.2 = phi i64 [ %l.1, %q ], [ %l.549, %if.then19 ]\n %m.2 = phi i64 [ %m.1, %q ], [ %m.550, %if.then19 ]\n br i1 false, label %s, label %land.lhs.true\n\nland.lhs.true: ; preds = %r, %lor.lhs.false\n %xor37 = phi i64 [ %xor38, %r ], [ 0, %lor.lhs.false ]\n %j.1 = phi i64 [ %j.0, %r ], [ 0, %lor.lhs.false ]\n %l.3 = phi i64 [ %l.2, %r ], [ 0, %lor.lhs.false ]\n %m.3 = phi i64 [ %m.2, %r ], [ 0, %lor.lhs.false ]\n br i1 false, label %q, label %s\n\ns: ; preds = %land.lhs.true, %r, %lor.lhs.false, %p\n %xor36 = phi i64 [ %xor37, %land.lhs.true ], [ %xor38, %r ], [ %xor39, %lor.lhs.false ], [ %l.0, %p ]\n %j.2 = phi i64 [ %j.1, %land.lhs.true ], [ %j.0, %r ], [ %conv3, %lor.lhs.false ], [ %m.0, %p ]\n %l.4 = phi i64 [ %l.3, %land.lhs.true ], [ %l.2, %r ], [ %l.1, %lor.lhs.false ], [ %l.0, %p ]\n %m.4 = phi i64 [ %m.3, %land.lhs.true ], [ %m.2, %r ], [ %m.1, %lor.lhs.false ], [ %m.0, %p ]\n br label %if.then19\n\nif.then19: ; preds = %s, %entry\n %m.550 = phi i64 [ 0, %entry ], [ %m.4, %s ]\n %l.5493 = phi i64 [ 0, %entry ], [ %l.4, %s ]\n %xor = xor i64 0, 0\n %not21 = xor i64 0, 0\n br i1 false, label %r, label %if.end25\n\nif.end25: ; preds = %if.then19\n br i1 false, label %if.end29, label %p\n\nif.end29: ; preds = %if.end25\n br label %p\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/matched-bv-schedulable.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s -slp-threshold=-99999"
],
"tests": [
{
"test_name": "test",
"test_body": "define void @test() {\nbb:\n br i1 false, label %bb1, label %bb5\n\nbb1: ; preds = %bb1, %bb\n %phi = phi i32 [ %or4, %bb1 ], [ 0, %bb ]\n %phi2 = phi i32 [ %add, %bb1 ], [ 0, %bb ]\n %add = add i32 1, 0\n %or = or i32 0, %phi2\n %or3 = or i32 %or, 0\n %mul = mul i32 0, 0\n %or4 = or i32 %phi, %mul\n br i1 false, label %bb1, label %bb5\n\nbb5: ; preds = %bb1, %bb\n %phi6 = phi i32 [ 0, %bb ], [ %or4, %bb1 ]\n %phi7 = phi i32 [ 0, %bb ], [ %or, %bb1 ]\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/matched-nodes-updated.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-9999 < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define i32 @test(i32 %s.0) {\nentry:\n br label %k\n\nk: ; preds = %t, %entry\n %.pre = phi i32 [ 0, %entry ], [ %.pre4053, %t ]\n br label %o\n\nif.end3: ; No predecessors!\n br label %if.end6\n\nif.end6: ; preds = %o, %if.end3\n %.pre43 = phi i32 [ 0, %if.end3 ], [ 0, %o ]\n %0 = phi i32 [ 0, %if.end3 ], [ 0, %o ]\n %1 = phi i32 [ 0, %if.end3 ], [ 0, %o ]\n %h.4 = phi i32 [ 0, %if.end3 ], [ %h.6, %o ]\n %i.4 = phi i32 [ 0, %if.end3 ], [ %i.7, %o ]\n %j.4 = phi i32 [ 0, %if.end3 ], [ %j.5, %o ]\n %l.4 = phi i32 [ 0, %if.end3 ], [ 0, %o ]\n %not8 = xor i32 %i.4, 0\n %not9 = xor i32 %h.4, 0\n br i1 false, label %if.end24, label %if.then11\n\nif.then11: ; preds = %if.end6\n br label %if.end24\n\nif.then18: ; No predecessors!\n br label %t\n\nt: ; preds = %o, %if.then18\n %.pre40 = phi i32 [ %.pre4053, %o ], [ 0, %if.then18 ]\n %i.5 = phi i32 [ 0, %o ], [ 0, %if.then18 ]\n %l.5 = phi i32 [ %l.7, %o ], [ 0, %if.then18 ]\n %r.2 = phi i32 [ %r.4, %o ], [ 0, %if.then18 ]\n %s.2 = phi i32 [ %s.4, %o ], [ 0, %if.then18 ]\n br i1 false, label %if.end24, label %k\n\nif.end24: ; preds = %t, %if.then11, %if.end6\n %.pre4050 = phi i32 [ 0, %if.then11 ], [ 0, %if.end6 ], [ %.pre40, %t ]\n %.pre42 = phi i32 [ 0, %if.then11 ], [ %.pre43, %if.end6 ], [ %.pre40, %t ]\n %2 = phi i32 [ 0, %if.then11 ], [ %0, %if.end6 ], [ %.pre40, %t ]\n %3 = phi i32 [ 0, %if.then11 ], [ %1, %if.end6 ], [ %.pre40, %t ]\n %i.6 = phi i32 [ %i.4, %if.then11 ], [ %i.7, %if.end6 ], [ %i.5, %t ]\n %l.6 = phi i32 [ 0, %if.then11 ], [ %l.4, %if.end6 ], [ %l.5, %t ]\n %r.3 = phi i32 [ %j.4, %if.then11 ], [ %not8, %if.end6 ], [ %r.2, %t ]\n %s.3 = phi i32 [ 0, %if.then11 ], [ %not9, %if.end6 ], [ %s.2, %t ]\n br label %o\n\no: ; preds = %if.end24, %k\n %.pre4053 = phi i32 [ 0, %k ], [ %.pre4050, %if.end24 ]\n %.pre46 = phi i32 [ 0, %k ], [ %.pre42, %if.end24 ]\n %4 = phi i32 [ 0, %k ], [ %2, %if.end24 ]\n %5 = phi i32 [ 0, %k ], [ %3, %if.end24 ]\n %h.6 = phi i32 [ 0, %k ], [ %r.3, %if.end24 ]\n %i.7 = phi i32 [ 0, %k ], [ %i.6, %if.end24 ]\n %j.5 = phi i32 [ 0, %k ], [ %s.3, %if.end24 ]\n %l.7 = phi i32 [ %.pre, %k ], [ %l.6, %if.end24 ]\n %r.4 = phi i32 [ 0, %k ], [ %r.3, %if.end24 ]\n %s.4 = phi i32 [ %s.0, %k ], [ %s.3, %if.end24 ]\n br i1 false, label %t, label %if.end6\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/node-outside-used-only.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-99999 < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine i64 @test() {\n;\nbb:\n br label %bb1\n\nbb1:\n %phi = phi i32 [ 0, %bb ], [ %or, %bb5 ]\n %phi2 = phi i32 [ 0, %bb ], [ %or4, %bb5 ]\n %or = or i32 %phi, 0\n %add = add i32 0, 0\n %or3 = or i32 %add, %phi2\n %or4 = or i32 %or3, 0\n br label %bb5\n\nbb5:\n br i1 false, label %bb6, label %bb1\n\nbb6:\n %phi7 = phi i32 [ %or, %bb5 ]\n %phi8 = phi i32 [ %or3, %bb5 ]\n ret i64 0\n}",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/reduced-val-vectorized-in-transform.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-10 < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define i32 @test(i1 %cond) {\nentry:\n br label %bb\n\nbb: ; preds = %bb, %entry\n %p1 = phi i32 [ %or92, %bb ], [ 0, %entry ]\n %p2 = phi i32 [ %0, %bb ], [ 0, %entry ]\n %p3 = phi i32 [ %4, %bb ], [ 0, %entry ]\n %0 = or i32 1, 0\n %or8.i = or i32 0, 0\n %or9.i = or i32 0, 0\n %or91 = or i32 %p1, 0\n %or12.i = or i32 %p2, 0\n %or92 = or i32 1, 0\n %1 = xor i32 %or91, %or12.i\n %2 = xor i32 %1, %or9.i\n %3 = xor i32 %2, %or8.i\n %4 = xor i32 %3, %or92\n br i1 %cond, label %exit, label %bb\n\nexit: ; preds = %bb\n ret i32 %4\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/split-node-num-operands.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -mattr=+avx -slp-threshold=-1000 < %s"
],
"tests": [
{
"test_name": "Foo",
"test_body": "define i64 @Foo(ptr align 8 dereferenceable(344) %0, i64 %1) {\n %3 = getelementptr i8, ptr %0, i64 104\n %4 = getelementptr i8, ptr %0, i64 112\n %5 = getelementptr i8, ptr %0, i64 24\n %6 = load i64, ptr %3, align 8\n %7 = load i64, ptr %4, align 8\n %8 = load i64, ptr %5, align 8\n %9 = load i64, ptr %0, align 8\n br label %10\n\n10: ; preds = %18, %2\n %11 = phi i64 [ %9, %2 ], [ 0, %18 ]\n %12 = phi i64 [ %8, %2 ], [ %12, %18 ]\n %13 = phi i64 [ %7, %2 ], [ 0, %18 ]\n %14 = phi i64 [ %6, %2 ], [ 0, %18 ]\n switch i32 0, label %15 [\n i32 0, label %18\n ]\n\n15: ; preds = %10\n %16 = tail call i64 @llvm.umin.i64(i64 0, i64 0)\n %17 = tail call i64 @llvm.umax.i64(i64 0, i64 0)\n br label %18\n\n18: ; preds = %15, %10\n %19 = phi i64 [ %17, %15 ], [ 0, %10 ]\n %20 = phi i64 [ %16, %15 ], [ 0, %10 ]\n %21 = phi i64 [ %11, %15 ], [ 0, %10 ]\n %22 = phi i64 [ %12, %15 ], [ 0, %10 ]\n %23 = phi i64 [ %13, %15 ], [ %1, %10 ]\n %24 = phi i64 [ %14, %15 ], [ 0, %10 ]\n br i1 false, label %.loopexit206, label %10\n\n.loopexit206: ; preds = %18\n switch i32 0, label %26 [\n i32 0, label %.cont174\n i32 1, label %25\n ]\n\n25: ; preds = %.loopexit206\n br label %.cont174\n\n26: ; preds = %.loopexit206\n %27 = tail call i64 @llvm.umin.i64(i64 0, i64 0)\n %28 = tail call i64 @llvm.umax.i64(i64 0, i64 0)\n br label %.cont174\n\n.cont174: ; preds = %26, %25, %.loopexit206\n %.sroa.139.1 = phi i64 [ %28, %26 ], [ %19, %25 ], [ %19, %.loopexit206 ]\n %.sroa.133.1 = phi i64 [ %27, %26 ], [ 0, %25 ], [ %20, %.loopexit206 ]\n %.sroa.81.1 = phi i64 [ %23, %26 ], [ 0, %25 ], [ %23, %.loopexit206 ]\n %.sroa.75.1 = phi i64 [ %24, %26 ], [ 0, %25 ], [ %24, %.loopexit206 ]\n %.sroa.21.1 = phi i64 [ %21, %26 ], [ 0, %25 ], [ %21, %.loopexit206 ]\n %.sroa.15.1 = phi i64 [ %22, %26 ], [ 0, %25 ], [ %22, %.loopexit206 ]\n %29 = phi i64 [ %28, %26 ], [ 0, %25 ], [ %19, %.loopexit206 ]\n %30 = phi i64 [ %27, %26 ], [ 0, %25 ], [ %20, %.loopexit206 ]\n ret i64 0\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i64 @llvm.umax.i64(i64, i64) #0\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i64 @llvm.umin.i64(i64, i64) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/SLPVectorizer/revec.ll",
"commands": [
"opt -passes=slp-vectorizer -S -slp-revec -slp-max-reg-size=1024 -slp-threshold=-100 %s"
],
"tests": [
{
"test_name": "test8",
"test_body": "define void @test8() {\nentry:\n br i1 false, label %for0, label %for.body\n\nfor0: ; preds = %for.body, %entry\n %0 = phi <2 x float> [ zeroinitializer, %entry ], [ %4, %for.body ]\n %1 = phi <2 x float> [ zeroinitializer, %entry ], [ %5, %for.body ]\n %2 = phi <2 x float> [ zeroinitializer, %entry ], [ %4, %for.body ]\n %3 = phi <2 x float> [ zeroinitializer, %entry ], [ %5, %for.body ]\n ret void\n\nfor.body: ; preds = %for.body, %entry\n %4 = phi <2 x float> [ %4, %for.body ], [ zeroinitializer, %entry ]\n %5 = phi <2 x float> [ %5, %for.body ], [ zeroinitializer, %entry ]\n br i1 false, label %for0, label %for.body\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test7",
"test_body": "define void @test7() {\n %1 = getelementptr i8, ptr null, i64 16\n %2 = trunc <8 x i64> zeroinitializer to <8 x i16>\n store <8 x i16> %2, ptr %1, align 2\n %3 = trunc <8 x i64> zeroinitializer to <8 x i16>\n store <8 x i16> %3, ptr null, align 2\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Instruction does not dominate all uses! LLVM ERROR: Broken module found, compilation aborted! Yet another case.",
"body": "To reproduce run opt with the test below using -passes=slp-vectorizer -slp-threshold=-99999:\n\n```\n; ModuleID = './reduced.ll'\nsource_filename = \"./reduced.ll\"\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i64 @wombat() #0 gc \"statepoint-example\" {\nbb:\n br label %bb1\n\nbb1: ; preds = %bb5, %bb\n %phi = phi i32 [ 0, %bb ], [ %or, %bb5 ]\n %phi2 = phi i32 [ 0, %bb ], [ %or4, %bb5 ]\n %or = or i32 %phi, 0\n %add = add i32 0, 0\n %or3 = or i32 %add, %phi2\n %or4 = or i32 %or3, 0\n br label %bb5\n\nbb5: ; preds = %bb1\n br i1 false, label %bb6, label %bb1\n\nbb6: ; preds = %bb5\n %phi7 = phi i32 [ %or, %bb5 ]\n %phi8 = phi i32 [ %or3, %bb5 ]\n ret i64 0\n}\n\nattributes #0 = { \"target-features\"=\"+prfchw,-cldemote,+avx,+aes,+sahf,+pclmul,-xop,+crc32,-amx-fp8,+xsaves,-avx512fp16,-usermsr,-sm4,-egpr,+sse4.1,-avx512ifma,+xsave,+sse4.2,-tsxldtrk,-sm3,-ptwrite,-widekl,-movrs,+invpcid,+64bit,+xsavec,-avx10.1-512,-avx512vpopcntdq,+cmov,-avx512vp2intersect,+avx512cd,+movbe,-avxvnniint8,-ccmp,-amx-int8,-kl,-avx10.1-256,+evex512,-avxvnni,+rtm,+adx,+avx2,-hreset,-movdiri,-serialize,-sha512,-vpclmulqdq,+avx512vl,-uintr,-cf,+clflushopt,-raoint,-cmpccxadd,+bmi,-amx-tile,+sse,-avx10.2-256,-gfni,-avxvnniint16,-amx-fp16,-zu,-ndd,+xsaveopt,+rdrnd,+avx512f,-amx-bf16,-avx512bf16,-avx512vnni,-push2pop2,+cx8,+avx512bw,+sse3,+pku,-nf,-amx-tf32,-amx-avx512,+fsgsbase,-clzero,-mwaitx,-lwp,+lzcnt,-sha,-movdir64b,-ppx,-wbnoinvd,-enqcmd,-amx-transpose,-avx10.2-512,-avxneconvert,-tbm,-pconfig,-amx-complex,+ssse3,+cx16,+bmi2,+fma,+popcnt,-avxifma,+f16c,-avx512bitalg,-rdpru,+clwb,+mmx,+sse2,+rdseed,-avx512vbmi2,-prefetchi,-amx-movrs,-rdpid,-fma4,-avx512vbmi,-shstk,-vaes,-waitpkg,-sgx,+fxsr,+avx512dq,-sse4a,-avx512f\" }\n```\n\nReproducer: https://godbolt.org/z/xh9xjfEKc\n\nStack dump:\n```\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer -slp-threshold=-99999 <source>\n1.\tRunning pass \"verify\" on module \"<source>\"\n #0 0x00000000055a8748 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x55a8748)\n #1 0x00000000055a60d4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007479c4242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007479c42969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007479c4242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007479c42287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x000000000080bfcd llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0\n #7 0x00000000054e4741 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x54e4741)\n #8 0x00000000053e0e38 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x53e0e38)\n #9 0x0000000000940c0e llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x940c0e)\n#10 0x000000000539ff70 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x539ff70)\n#11 0x000000000094b05a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x94b05a)\n#12 0x000000000093e82c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x93e82c)\n#13 0x00007479c4229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#14 0x00007479c4229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#15 0x0000000000936465 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x936465)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```",
"author": "TatyanaDoubts",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
156091
|
https://github.com/llvm/llvm-project/issues/156091
|
crash
|
86c4ef506d96468d3f4c196a61767c40ce180d2e
| 2025-08-29T19:55:36 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "0aac22758a81a98d9612ed1ad4853d9e434e8451",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
[
1134,
1140
],
[
1657,
1663
]
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"getCallWideningDecision",
"needsExtract"
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 0aac22758a81a98d9612ed1ad4853d9e434e8451
Author: Florian Hahn <flo@fhahn.com>
Date: Sun Aug 31 15:12:41 2025 +0100
[LV] Correctly cost chains of replicating calls in legacy CM.
Check for scalarized calls in needsExtract to fix a divergence between
legacy and VPlan-based cost model.
The legacy cost model was missing a check for scalarized calls in
needsExtract, which meant if incorrectly assumed the result of a
scalarized call needs extracting.
Exposed by https://github.com/llvm/llvm-project/pull/154617.
Fixes https://github.com/llvm/llvm-project/issues/156091.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 56403dba92df..1f4610ad191c 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1134,7 +1134,10 @@ public:
CallWideningDecision getCallWideningDecision(CallInst *CI,
ElementCount VF) const {
assert(!VF.isScalar() && "Expected vector VF");
- return CallWideningDecisions.at({CI, VF});
+ auto I = CallWideningDecisions.find({CI, VF});
+ if (I == CallWideningDecisions.end())
+ return {CM_Unknown, nullptr, Intrinsic::not_intrinsic, std::nullopt, 0};
+ return I->second;
}
/// Return True if instruction \p I is an optimizable truncate whose operand
@@ -1657,7 +1660,9 @@ private:
Instruction *I = dyn_cast<Instruction>(V);
if (VF.isScalar() || !I || !TheLoop->contains(I) ||
TheLoop->isLoopInvariant(I) ||
- getWideningDecision(I, VF) == CM_Scalarize)
+ getWideningDecision(I, VF) == CM_Scalarize ||
+ (isa<CallInst>(I) &&
+ getCallWideningDecision(cast<CallInst>(I), VF).Kind == CM_Scalarize))
return false;
// Assume we can vectorize V (and hence we need extraction) if the
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/X86/cost-conditional-branches.ll",
"commands": [
"opt < %s -passes=loop-vectorize -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7-avx -S"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ntarget triple = \"x86_64-apple-macosx10.8.0\"\n\n; Test case for https://github.com/llvm/llvm-project/issues/156091.\ndefine void @test_replicate_call_chain(float %x, ptr noalias %A, ptr noalias %B, ptr align 4 noalias %C, ptr align 4 noalias %D, ptr noalias %E) #0 {\n;\nentry:\n br label %loop.header\n\nloop.header:\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %dec.iv = phi i64 [ 100, %entry ], [ %dec.iv.next, %loop.latch ]\n %iv.inc = add i64 %iv, 1\n %gep.A = getelementptr inbounds float, ptr %A, i64 %iv\n %l.A = load float, ptr %gep.A, align 4\n %c.A = fcmp ogt float %l.A, 0.0\n %gep.B = getelementptr inbounds float, ptr %B, i64 %iv\n %l.B = load float, ptr %gep.B, align 4\n %c.B = fcmp ogt float %l.B, 0.0\n %gep.C = getelementptr float, ptr %C, i64 %iv.inc\n %and = and i1 %c.A, %c.B\n br i1 %and, label %then, label %else\n\nthen:\n store float 0.0, ptr %gep.C, align 4\n br label %loop.latch\n\nelse:\n %iv.mul.2 = shl i64 %iv, 2\n %gep.D = getelementptr i8, ptr %D, i64 %iv.mul.2\n %l.D = load float, ptr %gep.D, align 4\n %mul = fmul float %l.D, 2.0\n %pow.1 = tail call float @llvm.pow.f32(float %mul, float %x)\n %pow.2 = tail call float @llvm.pow.f32(float %pow.1, float %x)\n store float %pow.2, ptr %gep.C, align 4\n br label %loop.latch\n\nloop.latch:\n store float 0.000000e+00, ptr %E, align 4\n %iv.next = add i64 %iv, 1\n %dec.iv.next = add i64 %dec.iv, -1\n %ec = icmp ne i64 %dec.iv.next, 0\n br i1 %ec, label %loop.header, label %exit\n\nexit:\n ret void\n}\n\ndefine i64 @avx512_cond_load_cost(ptr %src, i32 %a, i64 %b, i32 %c, i32 %d) #1 {\n;\nentry:\n br label %loop.header\n\nloop.header:\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %c.1 = icmp slt i32 %iv, 0\n br i1 %c.1, label %if.then, label %loop.latch\n\nif.then:\n %1 = urem i32 %a, %c\n %mul = sub i32 0, %1\n %div = udiv i32 %c, %d\n %or = or i32 %div, %mul\n %ext = sext i32 %or to i64\n %gep = getelementptr { i64, i64, i64 }, ptr %src, i64 %ext, i32 2\n %l = load i64, ptr %gep, align 8\n %or.2 = or i64 %l, %b\n br label %loop.latch\n\nloop.latch:\n %res = phi i64 [ 0, %loop.header ], [ %or.2, %if.then ]\n %iv.next = add i32 %iv, 1\n %ec = icmp ult i32 %iv, %c\n br i1 %ec, label %loop.header, label %exit\n\nexit:\n ret i64 %res\n}\n\ndefine void @cost_duplicate_recipe_for_sinking(ptr %A, i64 %N) #2 {\n;\nentry:\n br label %loop.header\n\nloop.header:\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %iv.shl = shl nsw i64 %iv, 2\n %gep.0 = getelementptr nusw double, ptr %A, i64 %iv.shl\n %l = load double, ptr %gep.0, align 8\n %c = fcmp oeq double %l, 0.000000e+00\n br i1 %c, label %if.then, label %loop.latch\n\nif.then:\n %gep.1 = getelementptr double, ptr %A, i64 %iv.shl\n store double 0.000000e+00, ptr %gep.1, align 8\n br label %loop.latch\n\nloop.latch:\n %iv.next = add nsw i64 %iv, 1\n %ec = icmp eq i64 %iv, %N\n br i1 %ec, label %exit, label %loop.header\n\nexit:\n ret void\n}\n\n; Test for https://github.com/llvm/llvm-project/issues/129236.\ndefine i32 @cost_ashr_with_op_known_invariant_via_scev(i8 %a) {\n;\nentry:\n %cmp.i = icmp eq i16 0, 0\n %conv.i = sext i16 0 to i32\n %conv5.i = sext i8 %a to i32\n br label %loop.header\n\nloop.header:\n %iv = phi i8 [ 100, %entry ], [ %iv.next, %loop.latch ]\n br i1 %cmp.i, label %then, label %else\n\nthen:\n %p.1 = phi i32 [ %rem.i, %else ], [ 0, %loop.header ]\n %shr.i = ashr i32 %conv5.i, %p.1\n %tobool6.not.i = icmp eq i32 %shr.i, 0\n %sext.i = shl i32 %p.1, 24\n %2 = ashr exact i32 %sext.i, 24\n %3 = select i1 %tobool6.not.i, i32 %2, i32 0\n br label %loop.latch\n\nelse:\n %rem.i = urem i32 -1, %conv.i\n %cmp3.i = icmp sgt i32 %rem.i, 1\n br i1 %cmp3.i, label %loop.latch, label %then\n\nloop.latch:\n %p.2 = phi i32 [ 0, %else ], [ %3, %then ]\n %iv.next = add i8 %iv, -1\n %ec = icmp eq i8 %iv.next, 0\n br i1 %ec, label %exit, label %loop.header\n\nexit:\n ret i32 %p.2\n}\n\nattributes #0 = { \"target-cpu\"=\"znver4\" }\nattributes #1 = { \"target-features\"=\"+avx512bw,+avx512cd,+avx512dq,+avx512f,+avx512vl\" }\nattributes #2 = { \"target-cpu\"=\"znver3\" }",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/X86/cost-model.ll",
"commands": [
"opt < %s -passes=loop-vectorize -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7-avx -S"
],
"tests": [
{
"test_name": "cost_assume",
"test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-apple-macosx10.8.0\"\n\ndefine i64 @cost_assume(ptr %end, i64 %N) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %0 = phi i64 [ 0, %entry ], [ %1, %loop ]\n %1 = add i64 %0, 1\n %iv.next = add nsw i64 %iv, 1\n %c = icmp ne i64 %N, 0\n tail call void @llvm.assume(i1 %c)\n %gep = getelementptr nusw [9 x i8], ptr null, i64 %iv.next\n %ec = icmp eq ptr %gep, %end\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i64 %1\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #0\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[VPlan] VPlan cost model and legacy cost model disagreed assertion hit",
"body": "[reduced.ll.gz](https://github.com/user-attachments/files/22052471/reduced.ll.gz)\n\nReproducer: `opt --passes=loop-vectorize reduced.ll`:\n```\nopt: .../llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7066: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || BestPlan.hasEarlyExit() || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop, BestFactor.Width) || planContainsAdditionalSimplifications( getPlanFor(LegacyVF.Width), CostCtx, OrigLoop, LegacyVF.Width)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\n```\n\nThe issue appeared between 3addfd0186c1 and 988ab5aca06e. It affects `CPU2017/621.wrf_s`.\n\nThe only suspect (by just looking through the commits) is #154617. @fhahn can you please take a look?",
"author": "vzakhari",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
111874
|
https://github.com/llvm/llvm-project/issues/111874
|
crash
|
6a65e98fa7901dc1de91172d065fafb16ce89d77
| 2024-10-10T17:06:05 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "65da32c634a8345fcbe021f69fc6a609d074c08c",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
[
6480,
6491
]
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"LoopVectorizationCostModel::getInstructionCost"
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 65da32c634a8345fcbe021f69fc6a609d074c08c
Author: Florian Hahn <flo@fhahn.com>
Date: Fri Oct 11 11:26:57 2024 +0100
[LV] Account for any-of reduction when computing costs of blend phis.
Any-of reductions are narrowed to i1. Update the legacy cost model to
use the correct type when computing the cost of a phi that gets lowered
to selects (BLEND).
This fixes a divergence between legacy and VPlan-based cost models after
36fc291b6ec6d.
Fixes https://github.com/llvm/llvm-project/issues/111874.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 05dc58a42249..54f57fb0b6b5 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -6480,12 +6480,32 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I,
// Phi nodes in non-header blocks (not inductions, reductions, etc.) are
// converted into select instructions. We require N - 1 selects per phi
// node, where N is the number of incoming values.
- if (VF.isVector() && Phi->getParent() != TheLoop->getHeader())
+ if (VF.isVector() && Phi->getParent() != TheLoop->getHeader()) {
+ Type *ResultTy = Phi->getType();
+
+ // All instructions in an Any-of reduction chain are narrowed to bool.
+ // Check if that is the case for this phi node.
+ auto *HeaderUser = cast_if_present<PHINode>(
+ find_singleton<User>(Phi->users(), [this](User *U, bool) -> User * {
+ auto *Phi = dyn_cast<PHINode>(U);
+ if (Phi && Phi->getParent() == TheLoop->getHeader())
+ return Phi;
+ return nullptr;
+ }));
+ if (HeaderUser) {
+ auto &ReductionVars = Legal->getReductionVars();
+ auto Iter = ReductionVars.find(HeaderUser);
+ if (Iter != ReductionVars.end() &&
+ RecurrenceDescriptor::isAnyOfRecurrenceKind(
+ Iter->second.getRecurrenceKind()))
+ ResultTy = Type::getInt1Ty(Phi->getContext());
+ }
return (Phi->getNumIncomingValues() - 1) *
TTI.getCmpSelInstrCost(
- Instruction::Select, ToVectorTy(Phi->getType(), VF),
+ Instruction::Select, ToVectorTy(ResultTy, VF),
ToVectorTy(Type::getInt1Ty(Phi->getContext()), VF),
CmpInst::BAD_ICMP_PREDICATE, CostKind);
+ }
return TTI.getCFInstrCost(Instruction::PHI, CostKind);
}
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/RISCV/blend-any-of-reduction-cost.ll",
"commands": [
"opt -p loop-vectorize -S %s"
],
"tests": [
{
"test_name": "any_of_reduction_used_in_blend",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine i32 @any_of_reduction_used_in_blend(ptr %src, i64 %N, i1 %c.0, i1 %c.1) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %any.of.red = phi i32 [ 0, %entry ], [ %any.of.red.next, %loop.latch ]\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n br i1 %c.0, label %loop.latch, label %else.1\n\nelse.1: ; preds = %loop.header\n br i1 %c.1, label %loop.latch, label %else.2\n\nelse.2: ; preds = %else.1\n %l = load ptr, ptr %src, align 8\n %c.2 = icmp eq ptr %l, null\n %sel = select i1 %c.2, i32 0, i32 %any.of.red\n br label %loop.latch\n\nloop.latch: ; preds = %else.2, %else.1, %loop.header\n %any.of.red.next = phi i32 [ %any.of.red, %loop.header ], [ %any.of.red, %else.1 ], [ %sel, %else.2 ]\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv.next, %N\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n %res = phi i32 [ %any.of.red.next, %loop.latch ]\n ret i32 %res\n}\n\nattributes #0 = { \"target-cpu\"=\"sifive-p670\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "any_of_reduction_used_in_blend_with_mutliple_phis",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine i32 @any_of_reduction_used_in_blend_with_mutliple_phis(ptr %src, i64 %N, i1 %c.0, i1 %c.1) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %any.of.red = phi i32 [ 0, %entry ], [ %any.of.red.next, %loop.latch ]\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n br i1 %c.0, label %x.1, label %else.1\n\nelse.1: ; preds = %loop.header\n br i1 %c.1, label %x.1, label %else.2\n\nelse.2: ; preds = %else.1\n %l = load ptr, ptr %src, align 8\n %c.2 = icmp eq ptr %l, null\n %sel = select i1 %c.2, i32 0, i32 %any.of.red\n br label %loop.latch\n\nx.1: ; preds = %else.1, %loop.header\n %p = phi i32 [ %any.of.red, %loop.header ], [ %any.of.red, %else.1 ]\n br label %loop.latch\n\nloop.latch: ; preds = %x.1, %else.2\n %any.of.red.next = phi i32 [ %p, %x.1 ], [ %sel, %else.2 ]\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv.next, %N\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n %res = phi i32 [ %any.of.red.next, %loop.latch ]\n ret i32 %res\n}\n\nattributes #0 = { \"target-cpu\"=\"sifive-p670\" }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Crash in LV: \"VPlan cost model and legacy cost model disagreed\"",
"body": "Loop vectorizer crash for the following reproducer:\r\n```\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine void @init_dependence_analysis(ptr %iiv_used.i.i.i.sroa.0, i64 %indvars.iv71.i.i.i, i1 %cmp104.not.i.i.i, i1 %tobool108.not.i.i.i) #0 {\r\nentry:\r\n br label %for.cond101.preheader.i.i.i\r\n\r\nfor.cond101.preheader.i.i.i: ; preds = %for.inc121.i.i.i, %entry\r\n %separability.0.i.i = phi i32 [ 0, %entry ], [ %separability.2.i.i, %for.inc121.i.i.i ]\r\n br label %for.body103.i.i.i\r\n\r\nfor.body103.i.i.i: ; preds = %for.inc121.i.i.i, %for.cond101.preheader.i.i.i\r\n %separability.1.i.i = phi i32 [ %separability.0.i.i, %for.cond101.preheader.i.i.i ], [ %separability.2.i.i, %for.inc121.i.i.i ]\r\n %indvars.iv71.i.i.i5 = phi i64 [ 0, %for.cond101.preheader.i.i.i ], [ %indvars.iv.next72.i.i.i, %for.inc121.i.i.i ]\r\n br i1 %cmp104.not.i.i.i, label %for.inc121.i.i.i, label %land.lhs.true105.i.i.i\r\n\r\nland.lhs.true105.i.i.i: ; preds = %for.body103.i.i.i\r\n br i1 %tobool108.not.i.i.i, label %for.inc121.i.i.i, label %land.lhs.true109.i.i.i\r\n\r\nland.lhs.true109.i.i.i: ; preds = %land.lhs.true105.i.i.i\r\n %0 = load ptr, ptr %iiv_used.i.i.i.sroa.0, align 8\r\n %cmp118.i.i.i = icmp eq ptr %0, null\r\n %spec.select209.i.i = select i1 %cmp118.i.i.i, i32 0, i32 %separability.1.i.i\r\n br label %for.inc121.i.i.i\r\n\r\nfor.inc121.i.i.i: ; preds = %land.lhs.true109.i.i.i, %land.lhs.true105.i.i.i, %for.body103.i.i.i\r\n %separability.2.i.i = phi i32 [ %separability.1.i.i, %for.body103.i.i.i ], [ %separability.1.i.i, %land.lhs.true105.i.i.i ], [ %spec.select209.i.i, %land.lhs.true109.i.i.i ]\r\n %indvars.iv.next72.i.i.i = add i64 %indvars.iv71.i.i.i5, 1\r\n %exitcond74.not.i.i.i = icmp eq i64 %indvars.iv71.i.i.i5, %indvars.iv71.i.i.i\r\n br i1 %exitcond74.not.i.i.i, label %for.cond101.preheader.i.i.i, label %for.body103.i.i.i\r\n\r\n; uselistorder directives\r\n uselistorder i32 %separability.2.i.i, { 1, 0 }\r\n}\r\n\r\nattributes #0 = { \"target-cpu\"=\"sifive-p670\" }\r\n```\r\n\r\nopt -S --passes=loop-vectorize ./reduced.ll\r\nLoopVectorize.cpp:7430: VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\n",
"author": "alexey-bataev",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
108698
|
https://github.com/llvm/llvm-project/issues/108698
|
miscompilation
|
ba8e4246e2f17030788e8a4954bf5c290332206f
| 2024-09-14T13:16:53 |
[
"llvm/test/Transforms/VectorCombine"
] |
{
"fix_commit": "87663fdab9d0e7bcc0b963ea078da9e2eb574908",
"components": [
"VectorCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [
[
2597,
2607
],
[
2628,
2634
]
],
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [
"VectorCombine::shrinkType"
],
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 87663fdab9d0e7bcc0b963ea078da9e2eb574908
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Sun Sep 15 18:38:06 2024 +0800
[VectorCombine] Don't shrink lshr if the shamt is not less than bitwidth (#108705)
Consider the following case:
```
define <2 x i32> @test(<2 x i64> %vec.ind16, <2 x i32> %broadcast.splat20) {
%19 = icmp eq <2 x i64> %vec.ind16, zeroinitializer
%20 = zext <2 x i1> %19 to <2 x i32>
%21 = lshr <2 x i32> %20, %broadcast.splat20
ret <2 x i32> %21
}
```
After https://github.com/llvm/llvm-project/pull/104606, we shrink the
lshr into:
```
define <2 x i32> @test(<2 x i64> %vec.ind16, <2 x i32> %broadcast.splat20) {
%1 = icmp eq <2 x i64> %vec.ind16, zeroinitializer
%2 = trunc <2 x i32> %broadcast.splat20 to <2 x i1>
%3 = lshr <2 x i1> %1, %2
%4 = zext <2 x i1> %3 to <2 x i32>
ret <2 x i32> %4
}
```
It is incorrect since `lshr i1 X, 1` returns `poison`.
This patch adds additional check on the shamt operand. The lshr will get
shrunk iff we ensure that the shamt is less than bitwidth of the smaller
type. As `computeKnownBits(&I, *DL).countMaxActiveBits() > BW` always
evaluates to true for `lshr(zext(X), Y)`, this check will only apply to
bitwise logical instructions.
Alive2: https://alive2.llvm.org/ce/z/j_RmTa
Fixes https://github.com/llvm/llvm-project/issues/108698.
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index d7afe2f426d3..58701bfa60a3 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -2597,11 +2597,19 @@ bool VectorCombine::shrinkType(llvm::Instruction &I) {
auto *SmallTy = cast<FixedVectorType>(ZExted->getType());
unsigned BW = SmallTy->getElementType()->getPrimitiveSizeInBits();
- // Check that the expression overall uses at most the same number of bits as
- // ZExted
- KnownBits KB = computeKnownBits(&I, *DL);
- if (KB.countMaxActiveBits() > BW)
- return false;
+ if (I.getOpcode() == Instruction::LShr) {
+ // Check that the shift amount is less than the number of bits in the
+ // smaller type. Otherwise, the smaller lshr will return a poison value.
+ KnownBits ShAmtKB = computeKnownBits(I.getOperand(1), *DL);
+ if (ShAmtKB.getMaxValue().uge(BW))
+ return false;
+ } else {
+ // Check that the expression overall uses at most the same number of bits as
+ // ZExted
+ KnownBits KB = computeKnownBits(&I, *DL);
+ if (KB.countMaxActiveBits() > BW)
+ return false;
+ }
// Calculate costs of leaving current IR as it is and moving ZExt operation
// later, along with adding truncates if needed
@@ -2628,7 +2636,7 @@ bool VectorCombine::shrinkType(llvm::Instruction &I) {
return false;
// Check if we can propagate ZExt through its other users
- KB = computeKnownBits(UI, *DL);
+ KnownBits KB = computeKnownBits(UI, *DL);
if (KB.countMaxActiveBits() > BW)
return false;
|
[
{
"file": "llvm/test/Transforms/VectorCombine/AArch64/shrink-types.ll",
"commands": [
"opt -passes=vector-combine -S %s"
],
"tests": [
{
"test_name": "pr108698",
"test_body": "target triple = \"aarch64\"\n\ndefine <2 x i32> @pr108698(<2 x i64> %x, <2 x i32> %y) {\n %cmp = icmp eq <2 x i64> %x, zeroinitializer\n %ext = zext <2 x i1> %cmp to <2 x i32>\n %lshr = lshr <2 x i32> %ext, %y\n ret <2 x i32> %lshr\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "wrong code at -O{2,3} on x86_64-linux-gnu",
"body": "It appears to be a recent regression as it doesn't reproduce with 18.1.0 and earlier. \r\n\r\nCompiler Explorer: https://godbolt.org/z/EGasYh8x1\r\n\r\n```\r\n[691] % clangtk -v\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git 223e2efa5e886502a9467b7ef700ebce9b7886e8)\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[692] % \r\n[692] % clangtk -O1 small.c; ./a.out\r\n[693] % \r\n[693] % clangtk -O2 small.c\r\n[694] % ./a.out\r\nAborted\r\n[695] % \r\n[695] % cat small.c\r\nchar a[8];\r\nint b = 1, c;\r\nint main() {\r\n for (; c < 8; c++)\r\n a[c] = !c >> b;\r\n if (a[0] != 0)\r\n __builtin_abort();\r\n return 0;\r\n}\r\n```",
"author": "zhendongsu",
"labels": [
"miscompilation",
"vectorizers"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Reproducer: https://alive2.llvm.org/ce/z/5SkPZS\r\n```\r\n; bin/opt -passes=vector-combine test.ll -S\r\n\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine <2 x i32> @test(<2 x i64> %vec.ind16, <2 x i32> %broadcast.splat20) {\r\n %19 = icmp eq <2 x i64> %vec.ind16, zeroinitializer\r\n %20 = zext <2 x i1> %19 to <2 x i32>\r\n %21 = lshr <2 x i32> %20, %broadcast.splat20\r\n ret <2 x i32> %21\r\n}\r\n```\r\n```\r\ndefine <2 x i32> @test(<2 x i64> %vec.ind16, <2 x i32> %broadcast.splat20) {\r\n %1 = icmp eq <2 x i64> %vec.ind16, zeroinitializer\r\n %2 = trunc <2 x i32> %broadcast.splat20 to <2 x i1>\r\n %3 = lshr <2 x i1> %1, %2\r\n %4 = zext <2 x i1> %3 to <2 x i32>\r\n ret <2 x i32> %4\r\n}\r\n```"
},
{
"author": "dtcxzyw",
"body": "Related PR: https://github.com/llvm/llvm-project/pull/104606\r\n"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
119063
|
https://github.com/llvm/llvm-project/issues/119063
|
crash
|
118f7b95c8546826f222c13daea47cde4aa97bc9
| 2024-12-07T08:46:55 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "f4f6566e44566f3d8cf9517767d457227125ca93",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": [
[
3622,
3628
]
],
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": [
"InstCombinerImpl::foldICmpBinOpEqualityWithConstant"
],
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit f4f6566e44566f3d8cf9517767d457227125ca93
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Sun Dec 8 13:21:34 2024 +0800
[InstCombine] Fix type mismatch in `foldICmpBinOpEqualityWithConstant` (#119068)
Closes https://github.com/llvm/llvm-project/issues/119063.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index b694fde30927..54053c4c9e28 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -3622,7 +3622,8 @@ Instruction *InstCombinerImpl::foldICmpBinOpEqualityWithConstant(
m_OneUse(m_c_Or(m_CombineAnd(m_Value(Sel),
m_Select(m_Value(Cond), m_Value(TV),
m_Value(FV))),
- m_Value(Other))))) {
+ m_Value(Other)))) &&
+ Cond->getType() == Cmp.getType()) {
const SimplifyQuery Q = SQ.getWithInstruction(&Cmp);
// Easy case is if eq/ne matches whether 0 is trueval/falseval.
if (Pred == ICmpInst::ICMP_EQ
|
[
{
"file": "llvm/test/Transforms/InstCombine/icmp-or-of-select-with-zero.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "pr119063",
"test_body": "define <4 x i1> @pr119063(<4 x i32> %x, i1 %cond) {\nentry:\n %sel = select i1 %cond, <4 x i32> splat (i32 1), <4 x i32> zeroinitializer\n %or = or <4 x i32> %sel, %x\n %cmp = icmp ne <4 x i32> %or, zeroinitializer\n ret <4 x i1> %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "src_tv_ne_invert",
"test_body": "declare void @use.i8(i8)\n\ndeclare void @use.i1(i1)\n\ndefine i1 @src_tv_ne_invert(i1 %c1, i8 %a, i8 %b, i8 %x, i8 %yy) {\n %not_c0 = icmp ugt i8 %a, %b\n call void @use.i1(i1 %not_c0)\n %c0 = xor i1 %not_c0, true\n %y = add nuw i8 %yy, 1\n %sel = select i1 %c0, i8 0, i8 %y\n %cc = or i1 %c0, %c1\n %sel_other = select i1 %cc, i8 %y, i8 %b\n %selx = or i8 %sel, %x\n %r = icmp ne i8 %selx, 0\n call void @use.i8(i8 %sel)\n call void @use.i8(i8 %sel_other)\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstCombine] Assertion `S1->getType() == S2->getType() && \"Cannot create binary operator with two operands of differing type!\"' failed.",
"body": "This code crashes at O2/3:\n```c\nint a, b;\nstatic int c;\nstatic int *d = &c;\nshort e;\nchar g;\nunsigned short h;\nint *i;\nint j(int k) {\n if (k & a)\n return 1;\n return 0;\n}\nint l(int k) {\n int f = j(k);\n return f;\n}\nvoid n() { int *m[] = {0, &d}; }\nvoid o() {\n for (; g; g++) {\n int *p = &b;\n short *q = &e;\n int r = l(*d + 5);\n *p = 0;\n *q = *i || (unsigned short)(r + 22158 + 36566 + *d - 1641080165) + h;\n }\n}\n```\n\nCompiler Explorer: https://godbolt.org/z/n7GPEKsxb\n\nBisected to https://github.com/llvm/llvm-project/commit/4eb98384099cbd1d901d8ef6a210af95d9c36adf, which was committed by @fhahn \n\nCrash: \n```\nclang: /root/llvm-project/llvm/lib/IR/Instructions.cpp:2642: static llvm::BinaryOperator* llvm::BinaryOperator::Create(llvm::Instruction::BinaryOps, llvm::Value*, llvm::Value*, const llvm::Twine&, llvm::InsertPosition): Assertion `S1->getType() == S2->getType() && \"Cannot create binary operator with two operands of differing type!\"' failed.\n```\n\nBacktrace:\n```\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O2 -Wall -Wextra <source>\n1.\t<eof> parser at end of file\n2.\tOptimizer\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"<source>\"\n4.\tRunning pass \"instcombine<max-iterations=1;no-verify-fixpoint>\" on function \"o\"\n #0 0x0000000003c05148 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3c05148)\n #1 0x0000000003c02e54 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3c02e54)\n #2 0x0000000003b503b8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0\n #3 0x00007bfb65442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #4 0x00007bfb654969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #5 0x00007bfb65442476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #6 0x00007bfb654287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #7 0x00007bfb6542871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #8 0x00007bfb65439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #9 0x000000000351a1f3 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x351a1f3)\n#10 0x0000000003523d7c (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3523d7c)\n#11 0x00000000037edc06 llvm::InstCombinerImpl::foldICmpBinOpEqualityWithConstant(llvm::ICmpInst&, llvm::BinaryOperator*, llvm::APInt const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x37edc06)\n#12 0x0000000003810ac9 llvm::InstCombinerImpl::foldICmpInstWithConstant(llvm::ICmpInst&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3810ac9)\n#13 0x0000000003819aad llvm::InstCombinerImpl::visitICmpInst(llvm::ICmpInst&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3819aad)\n#14 0x0000000003775251 llvm::InstCombinerImpl::run() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3775251)\n#15 0x0000000003776bc6 combineInstructionsOverFunction(llvm::Function&, llvm::InstructionWorklist&, llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::BranchProbabilityInfo*, llvm::ProfileSummaryInfo*, llvm::InstCombineOptions const&) (.isra.0) InstructionCombining.cpp:0:0\n#16 0x000000000377805c llvm::InstCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x377805c)\n#17 0x0000000003ea39ae llvm::detail::PassModel<llvm::Function, llvm::InstCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3ea39ae)\n#18 0x00000000035b5920 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x35b5920)\n#19 0x00000000010f19ce llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x10f19ce)\n#20 0x00000000035b423b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x35b423b)\n#21 0x00000000010f105e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x10f105e)\n#22 0x00000000035b3c40 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x35b3c40)\n#23 0x0000000003eb5912 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\n#24 0x0000000003eb918d clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3eb918d)\n#25 0x00000000045875de clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45875de)\n#26 0x000000000654152c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x654152c)\n#27 0x00000000045879b8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45879b8)\n#28 0x0000000004842b39 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4842b39)\n#29 0x00000000047c27ce clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x47c27ce)\n#30 0x000000000492db9e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x492db9e)\n#31 0x0000000000cb21bf cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xcb21bf)\n#32 0x0000000000ca9d5a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#33 0x00000000045cad09 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0\n#34 0x0000000003b50864 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3b50864)\n#35 0x00000000045cb2ff clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0\n#36 0x000000000459149d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x459149d)\n#37 0x000000000459258d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x459258d)\n#38 0x0000000004599945 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4599945)\n#39 0x0000000000caf003 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xcaf003)\n#40 0x0000000000b82f64 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xb82f64)\n#41 0x00007bfb65429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#42 0x00007bfb65429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#43 0x0000000000ca9805 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xca9805)\n```",
"author": "cardigan1008",
"labels": [
"llvm:instcombine",
"crash-on-valid"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Reduced reproducer: https://godbolt.org/z/najxdPz5h\n"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
93152
|
https://github.com/llvm/llvm-project/issues/93152
|
crash
|
d3ce1078186389ce39505f06c2a0100dce9187a5
| 2024-05-23T08:42:34 |
[
"llvm/test/Transforms/LowerSwitch"
] |
{
"fix_commit": "67aec0cd62d607b4e5b7198769be061454ce67b3",
"components": [
"LowerSwitch"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": [
[
208,
214
]
],
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": [
"NewLeafBlock"
],
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 67aec0cd62d607b4e5b7198769be061454ce67b3
Author: Peter Rong <peterrong96@gmail.com>
Date: Mon May 27 10:58:22 2024 -0700
[LowerSwitch] Use unsigned integer for range comparison (#93237)
Commit 1db51d8eb2 switched from int64_t to `APInt` to prevent high precision integer overflow.
However, when comparing the "range" of switch cases, we should switch to unsigned integer to prevent overflow.
This patch fixes https://github.com/llvm/llvm-project/issues/93152.
Some test cases are added.
Signed-off-by: Peter Rong <PeterRong96@gmail.com>
diff --git a/llvm/lib/Transforms/Utils/LowerSwitch.cpp b/llvm/lib/Transforms/Utils/LowerSwitch.cpp
index f5921e5ccb09..f4ef6d02abf0 100644
--- a/llvm/lib/Transforms/Utils/LowerSwitch.cpp
+++ b/llvm/lib/Transforms/Utils/LowerSwitch.cpp
@@ -208,7 +208,7 @@ BasicBlock *NewLeafBlock(CaseRange &Leaf, Value *Val, ConstantInt *LowerBound,
PHINode *PN = cast<PHINode>(I);
// Remove all but one incoming entries from the cluster
APInt Range = Leaf.High->getValue() - Leaf.Low->getValue();
- for (APInt j(Range.getBitWidth(), 0, true); j.slt(Range); ++j) {
+ for (APInt j(Range.getBitWidth(), 0, false); j.ult(Range); ++j) {
PN->removeIncomingValue(OrigBlock);
}
|
[
{
"file": "llvm/test/Transforms/LowerSwitch/93152.ll",
"commands": [
"opt < %s -passes=lower-switch -S"
],
"tests": [
{
"test_name": "<module>",
"test_body": "define void @i3_range_4(i3 %0) {\n;\nbb.0:\n switch i3 %0, label %bb.2 [\n i3 -1, label %bb.1\n i3 -2, label %bb.1\n i3 2, label %bb.1\n i3 1, label %bb.1\n i3 0, label %bb.1\n ]\n\nbb.1: ; preds = %bb.0, %bb.0, %bb.0, %bb.0, %bb.0\n %tmp = phi i3 [ 0, %bb.0 ], [ 0, %bb.0 ], [ 0, %bb.0 ], [ 0, %bb.0 ], [ 0, %bb.0 ]\n br label %bb.2\n\nbb.2: ; preds = %bb.1, %bb.0\n ret void\n}\n\ndefine void @i3_range_6(i3 %0) {\n;\nbb.0:\n switch i3 %0, label %bb.2 [\n i3 -1, label %bb.1\n i3 -2, label %bb.1\n i3 -3, label %bb.1\n i3 3, label %bb.1\n i3 2, label %bb.1\n i3 1, label %bb.1\n i3 0, label %bb.1\n ]\n\nbb.1: ; preds = %bb.0, %bb.0, %bb.0, %bb.0, %bb.0\n %tmp = phi i3 [ 0, %bb.0 ], [ 0, %bb.0 ], [ 0, %bb.0 ], [ 0, %bb.0 ], [ 0, %bb.0 ], [ 0, %bb.0 ], [ 0, %bb.0 ]\n br label %bb.2\n\nbb.2: ; preds = %bb.1, %bb.0\n ret void\n}\n\n\ndefine void @i3_range_7(i3 %0) {\n;\nbb.0:\n switch i3 %0, label %bb.2 [\n i3 -1, label %bb.1\n i3 -2, label %bb.1\n i3 -3, label %bb.1\n i3 -4, label %bb.1\n i3 3, label %bb.1\n i3 2, label %bb.1\n i3 1, label %bb.1\n i3 0, label %bb.1\n ]\n\nbb.1: ; preds = %bb.0, %bb.0, %bb.0, %bb.0, %bb.0\n %tmp = phi i3 [ 0, %bb.0 ], [ 0, %bb.0 ], [ 0, %bb.0 ], [ 0, %bb.0 ], [ 0, %bb.0 ], [ 0, %bb.0 ], [ 0, %bb.0 ], [ 0, %bb.0 ]\n br label %bb.2\n\nbb.2: ; preds = %bb.1, %bb.0\n ret void\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "LLVM ERROR: Broken function found after pass \"LowerSwitchPass\", compilation aborted!",
"body": "llvm commit: 4cc6d0f4dfb26d\r\nReproduce with:\r\n```opt -passes=\"lower-switch\" -verify-each bbi-95731.ll -o /dev/null```\r\nResult:\r\n```\r\nPHINode should have one entry for each predecessor of its parent basic block!\r\n %tmp = phi i3 [ 0, %LeafBlock ], [ 0, %bb.0 ], [ 0, %bb.0 ], [ 0, %bb.0 ], [ 0, %bb.0 ]\r\nLLVM ERROR: Broken function found after pass \"LowerSwitchPass\", compilation aborted!\r\n```\r\nIf we look at what lower-switch actually produces (-print-after-all) we see\r\n```\r\n; *** IR Dump After LowerSwitchPass on v_257_0 ***\r\ndefine void @v_257_0(i3 %0) {\r\nbb.0:\r\n br label %LeafBlock\r\n\r\nLeafBlock: ; preds = %bb.0\r\n %.off = add i3 %0, 2\r\n %SwitchLeaf = icmp ule i3 %.off, -4\r\n br i1 %SwitchLeaf, label %bb.1, label %bb.2\r\n\r\nbb.1: ; preds = %LeafBlock\r\n %tmp = phi i3 [ 0, %LeafBlock ], [ 0, %bb.0 ], [ 0, %bb.0 ], [ 0, %bb.0 ], [ 0, %bb.0 ]\r\n br label %bb.2\r\n\r\nbb.2: ; preds = %LeafBlock, %bb.1\r\n ret void\r\n}\r\nPHINode should have one entry for each predecessor of its parent basic block!\r\n %tmp = phi i3 [ 0, %LeafBlock ], [ 0, %bb.0 ], [ 0, %bb.0 ], [ 0, %bb.0 ], [ 0, %bb.0 ]\r\n```\r\nSo it has removed the switch instruction but it only updated one of the five phi operands for %bb.0.\r\nThe input looked like\r\n```\r\ndefine void @v_257_0(i3 %0) {\r\nbb.0:\r\n switch i3 %0, label %bb.2 [\r\n i3 -1, label %bb.1\r\n i3 -2, label %bb.1\r\n i3 2, label %bb.1\r\n i3 1, label %bb.1\r\n i3 0, label %bb.1\r\n ]\r\n\r\nbb.1: ; preds = %bb.0, %bb.0, %bb.0, %bb.0, %bb.0\r\n %tmp = phi i3 [ 0, %bb.0 ], [ 0, %bb.0 ], [ 0, %bb.0 ], [ 0, %bb.0 ], [ 0, %bb.0 ]\r\n br label %bb.2\r\n\r\nbb.2: ; preds = %bb.1, %bb.0\r\n ret void\r\n}\r\n```\r\nSo there is one phi operand for each of the values that makes it jump from %bb.0 to %bb.1 and lower-switch only updated one of them when it changed things.\r\n[bbi-95731.ll.gz](https://github.com/llvm/llvm-project/files/15414163/bbi-95731.ll.gz)\r\n",
"author": "mikaelholmen",
"labels": [
"crash-on-valid",
"llvm:transforms"
],
"comments": [
{
"author": "mikaelholmen",
"body": "This starts happening with 1db51d8eb2d\r\n```\r\n[Transform] Rewrite LowerSwitch using APInt\r\n\r\nThis rewrite fixes https://github.com/llvm/llvm-project/issues/59316.\r\n\r\nPreviously LowerSwitch uses int64_t, which will crash on case branches using integers with more than 64 bits.\r\nUsing APInt fixes this problem. This patch also includes a test\r\n\r\nReviewed By: RKSimon\r\n\r\nDifferential Revision: https://reviews.llvm.org/D140747\r\n```"
},
{
"author": "DataCorrupted",
"body": "I am taking a look. Some initial thoughts:\r\n\r\n- https://github.com/llvm/llvm-project/commit/1db51d8eb2d220a4f0000555ada310990098cf5b didn't attempt to change how it optimizes the switch. Maybe we forgot to change the API in that optimization.\r\n- `i3` is playing a role here: if you switch it to `i32`, [it'll pass](https://godbolt.org/z/c5Yveb8Kf). "
},
{
"author": "DataCorrupted",
"body": "I found the problem. Fixing it now. Will push a patch shortly"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
119393
|
https://github.com/llvm/llvm-project/issues/119393
|
crash
|
13539c219c49c581d6ba5270d09b19da9b1e3975
| 2024-12-10T15:25:03 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "a42aa8f265372a15d31a2af10b548fc239ed4b51",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
13222,
13230
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::isGatherShuffledSingleRegisterEntry"
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit a42aa8f265372a15d31a2af10b548fc239ed4b51
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Tue Dec 10 09:19:48 2024 -0800
[SLP]Fix adjusting of the mask for the fully matched nodes.
When checking for the poison elements in the matches node, need to
consider the register number, when clearing the corresponding mask
element.
Fixes #119393
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index c729c6cc9195..d90d7cc8f29e 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -13222,9 +13222,9 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
copy(CommonMask, Mask.begin());
}
// Clear undef scalars.
- for (int I = 0, Sz = VL.size(); I < Sz; ++I)
+ for (unsigned I : seq<unsigned>(VL.size()))
if (isa<PoisonValue>(VL[I]))
- Mask[I] = PoisonMaskElem;
+ Mask[Part * VL.size() + I] = PoisonMaskElem;
return TargetTransformInfo::SK_PermuteSingleSrc;
}
// No perfect match, just shuffle, so choose the first tree node from the
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/full-match-with-poison-scalar.ll",
"commands": [
"opt -S --passes=slp-vectorizer -slp-threshold=-200 -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define i32 @test() {\nentry:\n br label %func_135.exit.i\n\nfunc_135.exit.i: ; preds = %entry\n %g_228.promoted166.i1105.i = phi i32 [ 0, %entry ]\n %cmp55.i.i1199.i = icmp ugt i32 %g_228.promoted166.i1105.i, 0\n %cmp55.1.i.i1200.i = icmp ugt i32 %g_228.promoted166.i1105.i, 0\n %cmp55.2.i.i1201.i = icmp ugt i32 %g_228.promoted166.i1105.i, 0\n %cmp55.3.i.i1202.i = icmp ugt i32 %g_228.promoted166.i1105.i, 0\n %0 = xor i1 %cmp55.2.i.i1201.i, %cmp55.3.i.i1202.i\n %1 = xor i1 %cmp55.1.i.i1200.i, %0\n %2 = xor i1 %cmp55.i.i1199.i, %1\n %dec.i.i1204.i = add i32 %g_228.promoted166.i1105.i, 0\n %cmp55.i.i1199.1.i = icmp ugt i32 %dec.i.i1204.i, 0\n %cmp55.1.i.i1200.1.i = icmp ugt i32 %dec.i.i1204.i, 0\n %cmp55.2.i.i1201.1.i = icmp ugt i32 %dec.i.i1204.i, 0\n %cmp55.3.i.i1202.1.i = icmp ugt i32 %dec.i.i1204.i, 0\n %3 = xor i1 %cmp55.2.i.i1201.1.i, %cmp55.3.i.i1202.1.i\n %4 = xor i1 %cmp55.1.i.i1200.1.i, %3\n %5 = xor i1 %cmp55.i.i1199.1.i, %4\n %6 = xor i1 %2, %5\n %dec.i.i1204.1.i = add i32 %g_228.promoted166.i1105.i, 0\n %cmp55.i.i1199.2.i = icmp ugt i32 %dec.i.i1204.1.i, 0\n %cmp55.1.i.i1200.2.i = icmp ugt i32 %dec.i.i1204.1.i, 0\n %cmp55.2.i.i1201.2.i = icmp ugt i32 %dec.i.i1204.1.i, 0\n %cmp55.3.i.i1202.2.i = icmp ugt i32 %dec.i.i1204.1.i, 0\n %7 = add i32 0, 0\n %8 = icmp ult i32 %7, 0\n %9 = xor i1 %cmp55.3.i.i1202.2.i, %8\n %10 = xor i1 %cmp55.2.i.i1201.2.i, %9\n %11 = xor i1 %cmp55.1.i.i1200.2.i, %10\n %12 = xor i1 %cmp55.i.i1199.2.i, %11\n %13 = xor i1 %12, %6\n %dec.i.i1204.2.i = add i32 %g_228.promoted166.i1105.i, 0\n %cmp55.i.i1199.3.i = icmp ugt i32 %dec.i.i1204.2.i, 0\n %cmp55.1.i.i1200.3.i = icmp ugt i32 %dec.i.i1204.2.i, 0\n %cmp55.2.i.i1201.3.i = icmp ugt i32 %dec.i.i1204.2.i, 0\n %14 = xor i1 %cmp55.1.i.i1200.3.i, %cmp55.2.i.i1201.3.i\n %15 = xor i1 %cmp55.i.i1199.3.i, %14\n %16 = xor i1 %15, %13\n %17 = zext i1 %16 to i16\n br label %if.then.sink.split.i\n\nfor.cond7.preheader.i1132.1.i: ; No predecessors!\n br label %if.then.sink.split.i\n\nif.then.sink.split.i: ; preds = %for.cond7.preheader.i1132.1.i, %func_135.exit.i\n %xor58.5.i.i1203.3.3.sink.i = phi i16 [ 0, %for.cond7.preheader.i1132.1.i ], [ %17, %func_135.exit.i ]\n ret i32 0\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SLPVectorizer] Assertion `I1 == PoisonMaskElem && \"Expected unused subvectors mask\"' failed.",
"body": "Reproducer: https://godbolt.org/z/3dahr6Mb4\n```\n; bin/opt -passes=slp-vectorizer reduced.ll -S\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i32 @main() {\nentry:\n br label %func_135.exit.i\n\nfunc_135.exit.i:\n %g_228.promoted166.i1105.i = phi i32 [ 0, %entry ]\n %cmp55.i.i1199.i = icmp ugt i32 %g_228.promoted166.i1105.i, 0\n %cmp55.1.i.i1200.i = icmp ugt i32 %g_228.promoted166.i1105.i, 0\n %cmp55.2.i.i1201.i = icmp ugt i32 %g_228.promoted166.i1105.i, 0\n %cmp55.3.i.i1202.i = icmp ugt i32 %g_228.promoted166.i1105.i, 0\n %0 = xor i1 %cmp55.2.i.i1201.i, %cmp55.3.i.i1202.i\n %1 = xor i1 %cmp55.1.i.i1200.i, %0\n %2 = xor i1 %cmp55.i.i1199.i, %1\n %dec.i.i1204.i = add i32 %g_228.promoted166.i1105.i, 0\n %cmp55.i.i1199.1.i = icmp ugt i32 %dec.i.i1204.i, 0\n %cmp55.1.i.i1200.1.i = icmp ugt i32 %dec.i.i1204.i, 0\n %cmp55.2.i.i1201.1.i = icmp ugt i32 %dec.i.i1204.i, 0\n %cmp55.3.i.i1202.1.i = icmp ugt i32 %dec.i.i1204.i, 0\n %3 = xor i1 %cmp55.2.i.i1201.1.i, %cmp55.3.i.i1202.1.i\n %4 = xor i1 %cmp55.1.i.i1200.1.i, %3\n %5 = xor i1 %cmp55.i.i1199.1.i, %4\n %6 = xor i1 %2, %5\n %dec.i.i1204.1.i = add i32 %g_228.promoted166.i1105.i, 0\n %cmp55.i.i1199.2.i = icmp ugt i32 %dec.i.i1204.1.i, 0\n %cmp55.1.i.i1200.2.i = icmp ugt i32 %dec.i.i1204.1.i, 0\n %cmp55.2.i.i1201.2.i = icmp ugt i32 %dec.i.i1204.1.i, 0\n %cmp55.3.i.i1202.2.i = icmp ugt i32 %dec.i.i1204.1.i, 0\n %7 = add i32 0, 0\n %8 = icmp ult i32 %7, 0\n %9 = xor i1 %cmp55.3.i.i1202.2.i, %8\n %10 = xor i1 %cmp55.2.i.i1201.2.i, %9\n %11 = xor i1 %cmp55.1.i.i1200.2.i, %10\n %12 = xor i1 %cmp55.i.i1199.2.i, %11\n %13 = xor i1 %12, %6\n %dec.i.i1204.2.i = add i32 %g_228.promoted166.i1105.i, 0\n %cmp55.i.i1199.3.i = icmp ugt i32 %dec.i.i1204.2.i, 0\n %cmp55.1.i.i1200.3.i = icmp ugt i32 %dec.i.i1204.2.i, 0\n %cmp55.2.i.i1201.3.i = icmp ugt i32 %dec.i.i1204.2.i, 0\n %14 = xor i1 %cmp55.1.i.i1200.3.i, %cmp55.2.i.i1201.3.i\n %15 = xor i1 %cmp55.i.i1199.3.i, %14\n %16 = xor i1 %15, %13\n %17 = zext i1 %16 to i16\n br label %if.then.sink.split.i\n\nfor.cond7.preheader.i1132.1.i: ; No predecessors!\n br label %if.then.sink.split.i\n\nif.then.sink.split.i: ; preds = %for.cond7.preheader.i1132.1.i, %func_135.exit.i\n %xor58.5.i.i1203.3.3.sink.i = phi i16 [ 0, %for.cond7.preheader.i1132.1.i ], [ %17, %func_135.exit.i ]\n ret i32 0\n}\n```\n```\nopt: /root/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:10913: llvm::InstructionCost llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator::finalize(llvm::ArrayRef<int>, llvm::ArrayRef<std::pair<const llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int> >, llvm::ArrayRef<int>, unsigned int, llvm::function_ref<void(llvm::Value*&, llvm::SmallVectorImpl<int>&)>): Assertion `I1 == PoisonMaskElem && \"Expected unused subvectors mask\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer <source>\n1.\tRunning pass \"function(slp-vectorizer)\" on module \"<source>\"\n2.\tRunning pass \"slp-vectorizer\" on function \"main\"\n #0 0x00000000051c9e58 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x51c9e58)\n #1 0x00000000051c785c SignalHandler(int) Signals.cpp:0:0\n #2 0x000078cea7e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x000078cea7e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x000078cea7e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x000078cea7e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x000078cea7e2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x000078cea7e39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x00000000041fda54 llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator::finalize(llvm::ArrayRef<int>, llvm::ArrayRef<std::pair<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, unsigned int>>, llvm::ArrayRef<int>, unsigned int, llvm::function_ref<void (llvm::Value*&, llvm::SmallVectorImpl<int>&)>) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41fda54)\n #9 0x00000000042390b0 llvm::InstructionCost llvm::slpvectorizer::BoUpSLP::processBuildVector<llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator, llvm::InstructionCost, llvm::TargetTransformInfo, llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP, llvm::SmallPtrSetImpl<llvm::Value*>>(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::Type*, llvm::TargetTransformInfo&, llvm::ArrayRef<llvm::Value*>&, llvm::slpvectorizer::BoUpSLP&, llvm::SmallPtrSetImpl<llvm::Value*>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x42390b0)\n#10 0x0000000004243fa7 llvm::slpvectorizer::BoUpSLP::getEntryCost(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallPtrSetImpl<llvm::Value*>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4243fa7)\n#11 0x0000000004277f91 llvm::slpvectorizer::BoUpSLP::getTreeCost(llvm::ArrayRef<llvm::Value*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4277f91)\n#12 0x000000000427da60 (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&) SLPVectorizer.cpp:0:0\n#13 0x0000000004280ea9 llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4280ea9)\n#14 0x000000000428563b llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (.constprop.0) SLPVectorizer.cpp:0:0\n#15 0x0000000004289c9f llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4289c9f)\n#16 0x0000000004290786 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\n#17 0x00000000042912cb llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x42912cb)\n#18 0x0000000002fdbfee llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2fdbfee)\n#19 0x0000000004fc8d00 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4fc8d00)\n#20 0x0000000000e3b51e 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+0xe3b51e)\n#21 0x0000000004fc761b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4fc761b)\n#22 0x0000000000e3abae 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+0xe3abae)\n#23 0x0000000004fc7020 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4fc7020)\n#24 0x00000000009177ca llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9177ca)\n#25 0x0000000000909e49 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x909e49)\n#26 0x000078cea7e29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#27 0x000078cea7e29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#28 0x0000000000901705 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x901705)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```",
"author": "dtcxzyw",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
131071
|
https://github.com/llvm/llvm-project/issues/131071
|
crash
|
fecd937910f640663885e0434bfed80cf4574072
| 2025-03-13T04:07:59 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "2e13ec561c8139951e3f0815c35c758a7a3011db",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
[
7121,
7126
],
[
9620,
9626
],
[
9640,
9649
]
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
[
32,
38
],
[
83,
88
],
[
106,
111
]
],
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": [
[
68,
79
]
],
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": [
[
494,
501
]
],
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": [
[
1532,
1543
]
],
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"LoopVectorizationPlanner::buildVPlan",
"LoopVectorizationPlanner::planInVPlanNativePath",
"LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes"
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
"VPlanTransforms::VPInstructionsToVPRecipes",
"sinkScalarOperands"
],
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": [
"LoopVectorizationPlanner::buildVPlans"
],
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 2e13ec561c8139951e3f0815c35c758a7a3011db
Author: Florian Hahn <flo@fhahn.com>
Date: Wed Mar 19 21:35:15 2025 +0000
[VPlan] Bail out on non-intrinsic calls in VPlanNativePath.
Update initial VPlan-construction in VPlanNativePath in line with the
inner loop path, in that it bails out when encountering constructs it
cannot handle, like non-intrinsic calls.
Fixes https://github.com/llvm/llvm-project/issues/131071.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h b/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
index ed3e45dd2c6c..7bbe8669cef6 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
@@ -494,8 +494,10 @@ protected:
private:
/// Build a VPlan according to the information gathered by Legal. \return a
/// VPlan for vectorization factors \p Range.Start and up to \p Range.End
- /// exclusive, possibly decreasing \p Range.End.
- VPlanPtr buildVPlan(VFRange &Range);
+ /// exclusive, possibly decreasing \p Range.End. If no VPlan can be built for
+ /// the input range, set the largest included VF to the maximum VF for which
+ /// no plan could be built.
+ VPlanPtr tryToBuildVPlan(VFRange &Range);
/// Build a VPlan using VPRecipes according to the information gather by
/// Legal. This method is only used for the legacy inner loop vectorizer.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 89337dc38535..61e0d18445b6 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7121,6 +7121,9 @@ LoopVectorizationPlanner::planInVPlanNativePath(ElementCount UserVF) {
<< "VF " << VF << " to build VPlans.\n");
buildVPlans(VF, VF);
+ if (VPlans.empty())
+ return VectorizationFactor::Disabled();
+
// For VPlan build stress testing, we bail out after VPlan construction.
if (VPlanBuildStressTest)
return VectorizationFactor::Disabled();
@@ -9620,7 +9623,7 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
return Plan;
}
-VPlanPtr LoopVectorizationPlanner::buildVPlan(VFRange &Range) {
+VPlanPtr LoopVectorizationPlanner::tryToBuildVPlan(VFRange &Range) {
// Outer loop handling: They may require CFG and instruction level
// transformations before even evaluating whether vectorization is profitable.
// Since we cannot modify the incoming IR, we need to build VPlan upfront in
@@ -9640,10 +9643,13 @@ VPlanPtr LoopVectorizationPlanner::buildVPlan(VFRange &Range) {
for (ElementCount VF : Range)
Plan->addVF(VF);
- VPlanTransforms::VPInstructionsToVPRecipes(
- Plan,
- [this](PHINode *P) { return Legal->getIntOrFpInductionDescriptor(P); },
- *PSE.getSE(), *TLI);
+ if (!VPlanTransforms::tryToConvertVPInstructionsToVPRecipes(
+ Plan,
+ [this](PHINode *P) {
+ return Legal->getIntOrFpInductionDescriptor(P);
+ },
+ *PSE.getSE(), *TLI))
+ return nullptr;
// Tail folding is not supported for outer loops, so the induction increment
// is guaranteed to not wrap.
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index b63cdd04530a..ef82734840ed 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -1532,12 +1532,13 @@ void LoopVectorizationPlanner::buildVPlans(ElementCount MinVF,
auto MaxVFTimes2 = MaxVF * 2;
for (ElementCount VF = MinVF; ElementCount::isKnownLT(VF, MaxVFTimes2);) {
VFRange SubRange = {VF, MaxVFTimes2};
- auto Plan = buildVPlan(SubRange);
- VPlanTransforms::optimize(*Plan);
- // Update the name of the latch of the top-level vector loop region region
- // after optimizations which includes block folding.
- Plan->getVectorLoopRegion()->getExiting()->setName("vector.latch");
- VPlans.push_back(std::move(Plan));
+ if (auto Plan = tryToBuildVPlan(SubRange)) {
+ VPlanTransforms::optimize(*Plan);
+ // Update the name of the latch of the top-level vector loop region region
+ // after optimizations which includes block folding.
+ Plan->getVectorLoopRegion()->getExiting()->setName("vector.latch");
+ VPlans.push_back(std::move(Plan));
+ }
VF = SubRange.End;
}
}
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index e6f788a18805..6c8680ac9661 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -32,7 +32,7 @@
using namespace llvm;
-void VPlanTransforms::VPInstructionsToVPRecipes(
+bool VPlanTransforms::tryToConvertVPInstructionsToVPRecipes(
VPlanPtr &Plan,
function_ref<const InductionDescriptor *(PHINode *)>
GetIntOrFpInductionDescriptor,
@@ -83,6 +83,9 @@ void VPlanTransforms::VPInstructionsToVPRecipes(
} else if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(Inst)) {
NewRecipe = new VPWidenGEPRecipe(GEP, Ingredient.operands());
} else if (CallInst *CI = dyn_cast<CallInst>(Inst)) {
+ Intrinsic::ID VectorID = getVectorIntrinsicIDForCall(CI, &TLI);
+ if (VectorID == Intrinsic::not_intrinsic)
+ return false;
NewRecipe = new VPWidenIntrinsicRecipe(
*CI, getVectorIntrinsicIDForCall(CI, &TLI),
{Ingredient.op_begin(), Ingredient.op_end() - 1}, CI->getType(),
@@ -106,6 +109,7 @@ void VPlanTransforms::VPInstructionsToVPRecipes(
Ingredient.eraseFromParent();
}
}
+ return true;
}
static bool sinkScalarOperands(VPlan &Plan) {
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.h b/llvm/lib/Transforms/Vectorize/VPlanTransforms.h
index 2ec07eea1ecc..fe93637ab723 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.h
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.h
@@ -68,12 +68,13 @@ struct VPlanTransforms {
bool RequiresScalarEpilogueCheck, bool TailFolded, Loop *TheLoop);
/// Replaces the VPInstructions in \p Plan with corresponding
- /// widen recipes.
- static void
- VPInstructionsToVPRecipes(VPlanPtr &Plan,
- function_ref<const InductionDescriptor *(PHINode *)>
- GetIntOrFpInductionDescriptor,
- ScalarEvolution &SE, const TargetLibraryInfo &TLI);
+ /// widen recipes. Returns false if any VPInstructions could not be converted
+ /// to a wide recipe if needed.
+ static bool tryToConvertVPInstructionsToVPRecipes(
+ VPlanPtr &Plan,
+ function_ref<const InductionDescriptor *(PHINode *)>
+ GetIntOrFpInductionDescriptor,
+ ScalarEvolution &SE, const TargetLibraryInfo &TLI);
/// Try to have all users of fixed-order recurrences appear after the recipe
/// defining their previous value, by either sinking users or hoisting recipes
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/vplan-widen-call-instruction.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-width=4 -enable-vplan-native-path -S %s"
],
"tests": [
{
"test_name": "call_to_non_intrinsic",
"test_body": "define void @call_to_non_intrinsic() {\nentry:\n br label %outer.header\n\nouter.header: ; preds = %outer.latch, %entry\n %outer.iv = phi i64 [ 0, %entry ], [ %outer.iv.next, %outer.latch ]\n br label %inner.header\n\ninner.header: ; preds = %inner.header, %outer.header\n %inner.iv = phi i64 [ 0, %outer.header ], [ %inner.iv.next, %inner.header ]\n call void @use()\n %inner.iv.next = add i64 %inner.iv, 1\n %inner.ec = icmp eq i64 %inner.iv.next, 100\n br i1 %inner.ec, label %outer.latch, label %inner.header\n\nouter.latch: ; preds = %inner.header\n %outer.iv.next = add i64 %outer.iv, 1\n %outer.ec = icmp eq i64 %outer.iv.next, 100\n br i1 %outer.ec, label %exit, label %outer.header, !llvm.loop !0\n\nexit: ; preds = %outer.latch\n ret void\n}\n\ndeclare void @use()\n\n!0 = distinct !{!0, !1}\n!1 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[LoopVectorize] Assertion `ID != Intrinsic::not_intrinsic && \"Not an intrinsic!\"' failed.",
"body": "Reproducer: https://godbolt.org/z/n7E1TjTv5\n```\n; bin/opt -passes=loop-vectorize -enable-vplan-native-path reduced.ll -S\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i32 @main() {\nentry:\n br label %for.cond2.preheader.i815\n\nfor.cond2.preheader.i815: ; preds = %for.cond.cleanup8.i835.split.us, %entry\n %I.03.i816 = phi i64 [ %inc20.i839, %for.cond.cleanup8.i835.split.us ], [ 0, %entry ]\n br label %cont.i830.us\n\ncont.i830.us: ; preds = %cont.i830.us, %for.cond2.preheader.i815\n %K.01.i824.us = phi i64 [ 0, %for.cond2.preheader.i815 ], [ %inc.i833.us, %cont.i830.us ]\n call void @use(ptr null, i64 0)\n %inc.i833.us = add i64 %K.01.i824.us, 1\n %exitcond.not.i834.us = icmp eq i64 %inc.i833.us, 0\n br i1 %exitcond.not.i834.us, label %for.cond.cleanup8.i835.split.us, label %cont.i830.us\n\nfor.cond.cleanup8.i835.split.us: ; preds = %cont.i830.us\n %inc20.i839 = add i64 %I.03.i816, 1\n %exitcond5.not.i840 = icmp eq i64 %inc20.i839, 0\n br i1 %exitcond5.not.i840, label %\"_ZZ4mainENK3$_7clEmmmPi.exit.loopexit1081\", label %for.cond2.preheader.i815, !llvm.loop !0\n\n\"_ZZ4mainENK3$_7clEmmmPi.exit.loopexit1081\": ; preds = %for.cond.cleanup8.i835.split.us\n ret i32 0\n}\n\ndeclare void @use(ptr, i64)\n\n!0 = distinct !{!0, !1, !2}\n!1 = !{!\"llvm.loop.mustprogress\"}\n!2 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n```\n```\nopt: /root/llvm-project/llvm/lib/Analysis/VectorUtils.cpp:175: bool llvm::isVectorIntrinsicWithOverloadTypeAtArg(llvm::Intrinsic::ID, int, const llvm::TargetTransformInfo*): Assertion `ID != Intrinsic::not_intrinsic && \"Not an intrinsic!\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=loop-vectorize -enable-vplan-native-path <source>\n1.\tRunning pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"<source>\"\n2.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\n #0 0x0000000005475858 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5475858)\n #1 0x0000000005473214 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007024fda42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007024fda969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007024fda42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007024fda287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x00007024fda2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x00007024fda39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x0000000004bea5d7 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4bea5d7)\n #9 0x00000000045582f0 llvm::VPWidenIntrinsicRecipe::execute(llvm::VPTransformState&) (.part.0) VPlanRecipes.cpp:0:0\n#10 0x0000000004513ea7 llvm::VPBasicBlock::executeRecipes(llvm::VPTransformState*, llvm::BasicBlock*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4513ea7)\n#11 0x000000000451e4cf llvm::VPBasicBlock::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x451e4cf)\n#12 0x000000000451f5c0 llvm::VPRegionBlock::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x451f5c0)\n#13 0x000000000451f5c0 llvm::VPRegionBlock::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x451f5c0)\n#14 0x000000000452b451 llvm::VPlan::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x452b451)\n#15 0x00000000043ddd2f llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool, llvm::DenseMap<llvm::SCEV const*, llvm::Value*, llvm::DenseMapInfo<llvm::SCEV const*, void>, llvm::detail::DenseMapPair<llvm::SCEV const*, llvm::Value*>> const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43ddd2f)\n#16 0x00000000043f0e36 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43f0e36)\n#17 0x00000000043f45e9 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43f45e9)\n#18 0x00000000043f4c63 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43f4c63)\n#19 0x000000000319510e llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x319510e)\n#20 0x0000000005270840 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5270840)\n#21 0x0000000000e79f8e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe79f8e)\n#22 0x000000000526f15b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x526f15b)\n#23 0x0000000000e7910e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe7910e)\n#24 0x000000000526eb60 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x526eb60)\n#25 0x000000000094151a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x94151a)\n#26 0x0000000000934c6c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x934c6c)\n#27 0x00007024fda29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#28 0x00007024fda29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#29 0x000000000092c755 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x92c755)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```\nReduced from llvm-test-suite/SingleSource/UnitTests/Vectorizer/VPlanNativePath/outer-loop-vect.cpp with ubsan+https://github.com/llvm/llvm-project/pull/130990 enabled\n\n\n",
"author": "dtcxzyw",
"labels": [
"vectorizers",
"crash-on-valid"
],
"comments": [
{
"author": "zhangjunphy",
"body": "It seems for vplan vectorization, `LoopVectorizationLegality::canVectorize` only checks the loop structure and then skips the check of individual instructions. So the pass later tries to rewirte that call to `@use` and failed."
},
{
"author": "zhangjunphy",
"body": "From the description of `isExplicitVecOuterLoop`. This does not seem to a problem of the LoopVectorization pass.\nWhen `-enable-vplan-native-path` is provided, LLVM only attempts to vectorize outer loops marked with a pragma.\nAnd the programmer is expected to ensure vectorization must be legal for those loops.\nhttps://github.com/llvm/llvm-project/blob/125553a6779ba179a9b4b5212c531da2474258fd/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp#L2183-L2192\n\n=============\nEdited for clarity."
},
{
"author": "dtcxzyw",
"body": "Does ubsan instrumentation break this assumption?\n"
},
{
"author": "zhangjunphy",
"body": "Well, I'm far from familiar with the design of vectorization and this is just my conclusion from reading the code.\n\nFrom what I understand, if the flag `-enable-vplan-native-path` is specified, the IR producer is required to be certain that the loop marked with \"llvm.loop.vectorize.enable\" is actually vectorizable. Otherwise this will cause problems as that flag will cause vectorization to bypass some legality checks and to directly attempt vectorizing the loop. \n\nIn this case, the instrumentation added the \"llvm.loop.vectorize.enable\" metadata to the loop. But there is the call to `@use` which is not vectorizable. And this check is bypassed with `-enable-vplan-native-path`, thus caused the problem."
},
{
"author": "fhahn",
"body": "It is true that the native path somewhat relies on the loops being marked safe for vectorization by the user, we still shouldn't crash. In this particular case we can easily detect that we cannot create a valid VPlan, and bail out. I will prepare a fix."
}
]
}
| true |
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
| null |
126012
|
https://github.com/llvm/llvm-project/issues/126012
|
miscompilation
|
52a02b6d1e0c6b492495ff79a3a06ce93e6180b8
| 2025-02-06T05:45:23 |
[
"llvm/test/Transforms/IndVarSimplify"
] |
{
"fix_commit": "7aed53eb1982113e825534f0f66d0a0e46e7a5ed",
"components": [
"ScalarEvolution"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": [
[
12400,
12405
]
],
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": [
"ScalarEvolution::isImpliedViaMerge"
],
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 7aed53eb1982113e825534f0f66d0a0e46e7a5ed
Author: Nikita Popov <npopov@redhat.com>
Date: Mon Feb 10 10:07:21 2025 +0100
[ScalarEvolution] Handle addrec incoming value in isImpliedViaMerge() (#126236)
The code already guards against values coming from a previous iteration
using properlyDominates(). However, addrecs are considered to properly
dominate the loop they are defined in.
Handle this special case separately, by checking for expressions that
have computable loop evolution (this should cover cases like a zext of
an addrec as well).
I considered changing the definition of properlyDominates() instead, but
decided against it. The current definition is useful in other context,
e.g. when deciding whether an expression is safe to expand in a given
block.
Fixes https://github.com/llvm/llvm-project/issues/126012.
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index f89887118d8d..46a5c44f4e41 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -12400,6 +12400,12 @@ bool ScalarEvolution::isImpliedViaMerge(CmpPredicate Pred, const SCEV *LHS,
// iteration of a loop.
if (!properlyDominates(L, LBB))
return false;
+ // Addrecs are considered to properly dominate their loop, so are missed
+ // by the previous check. Discard any values that have computable
+ // evolution in this loop.
+ if (auto *Loop = LI.getLoopFor(LBB))
+ if (hasComputableLoopEvolution(L, Loop))
+ return false;
if (!ProvedEasily(L, RHS))
return false;
}
|
[
{
"file": "llvm/test/Transforms/IndVarSimplify/pr126012.ll",
"commands": [
"opt -S -passes=indvars < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define i32 @test() {\nentry:\n br label %for.preheader\n\nfor.preheader: ; preds = %for.inc, %entry\n %indvar1 = phi i32 [ 0, %entry ], [ %phi, %for.inc ]\n %indvar2 = phi i32 [ 1, %entry ], [ %indvar3, %for.inc ]\n %indvar3 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]\n %cond1 = icmp eq i32 %indvar3, 0\n br i1 %cond1, label %for.inc, label %for.end\n\nfor.end: ; preds = %for.preheader\n %cmp = icmp sgt i32 %indvar2, 0\n %ext = zext i1 %cmp to i32\n br label %for.inc\n\nfor.inc: ; preds = %for.end, %for.preheader\n %phi = phi i32 [ %ext, %for.end ], [ 0, %for.preheader ]\n %inc = add i32 %indvar3, 1\n %exitcond = icmp eq i32 %indvar3, 2\n br i1 %exitcond, label %for.exit, label %for.preheader\n\nfor.exit: ; preds = %for.inc\n ret i32 %indvar1\n}\n",
"lli_expected_out": null,
"additional_args": "-src-unroll=4 -tgt-unroll=4"
}
]
}
] |
{
"title": "[IndVarSimplify] Miscompilation at O2",
"body": "Reproducer: https://alive2.llvm.org/ce/z/UTnMBe\n```\n; bin/opt -passes=indvars reduced.ll -S\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@.str = constant [4 x i8] c\"%d\\0A\\00\"\n\ndefine i32 @main() {\nentry:\n br label %for.cond1.preheader.i.i\n\nfor.cond1.preheader.i.i: ; preds = %for.inc18.i.i, %entry\n %.pre.i.i = phi i64 [ 0, %entry ], [ %1, %for.inc18.i.i ]\n %j.sroa.0.043.i.i = phi i64 [ 1, %entry ], [ %storemerge42.i.i, %for.inc18.i.i ]\n %storemerge42.i.i = phi i64 [ 0, %entry ], [ %inc22.i.i, %for.inc18.i.i ]\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i\n\nfor.end.i.i: ; preds = %for.cond1.preheader.i.i\n %0 = icmp sgt i64 %j.sroa.0.043.i.i, 0\n %dec.348.i.i = add i64 %.pre.i.i, 1\n %spec.select.i.i = select i1 %0, i64 %dec.348.i.i, i64 0\n br label %for.inc18.i.i\n\nfor.inc18.i.i: ; preds = %for.end.i.i, %for.cond1.preheader.i.i\n %1 = phi i64 [ %spec.select.i.i, %for.end.i.i ], [ 0, %for.cond1.preheader.i.i ]\n %inc22.i.i = add i64 %storemerge42.i.i, 1\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i\n\ng.exit: ; preds = %for.inc18.i.i\n %conv = trunc i64 %.pre.i.i to i32\n %call1 = call i32 (ptr, ...) @printf(ptr @.str, i32 %conv)\n ret i32 0\n}\n\ndeclare i32 @printf(ptr, ...)\n```\nBefore:\n```\nEntering function main\n br label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 0\n phi i64 %j.sroa.0.043.i.i -> i64 1\n phi i64 %storemerge42.i.i -> i64 0\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> T\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.inc18.i.i\n phi i64 %1 -> i64 0\n %inc22.i.i = add i64 %storemerge42.i.i, 1 -> i64 1\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 0\n phi i64 %j.sroa.0.043.i.i -> i64 0\n phi i64 %storemerge42.i.i -> i64 1\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %0 = icmp sgt i64 %j.sroa.0.043.i.i, 0 -> F\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 1\n %spec.select.i.i = select i1 %0, i64 %dec.348.i.i, i64 0 -> i64 0\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %1 -> i64 0\n %inc22.i.i = add i64 %storemerge42.i.i, 1 -> i64 2\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 0\n phi i64 %j.sroa.0.043.i.i -> i64 1\n phi i64 %storemerge42.i.i -> i64 2\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %0 = icmp sgt i64 %j.sroa.0.043.i.i, 0 -> T\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 1\n %spec.select.i.i = select i1 %0, i64 %dec.348.i.i, i64 0 -> i64 1\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %1 -> i64 1\n %inc22.i.i = add i64 %storemerge42.i.i, 1 -> i64 3\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 1\n phi i64 %j.sroa.0.043.i.i -> i64 2\n phi i64 %storemerge42.i.i -> i64 3\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %0 = icmp sgt i64 %j.sroa.0.043.i.i, 0 -> T\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 2\n %spec.select.i.i = select i1 %0, i64 %dec.348.i.i, i64 0 -> i64 2\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %1 -> i64 2\n %inc22.i.i = add i64 %storemerge42.i.i, 1 -> i64 4\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 2\n phi i64 %j.sroa.0.043.i.i -> i64 3\n phi i64 %storemerge42.i.i -> i64 4\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %0 = icmp sgt i64 %j.sroa.0.043.i.i, 0 -> T\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 3\n %spec.select.i.i = select i1 %0, i64 %dec.348.i.i, i64 0 -> i64 3\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %1 -> i64 3\n %inc22.i.i = add i64 %storemerge42.i.i, 1 -> i64 5\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 3\n phi i64 %j.sroa.0.043.i.i -> i64 4\n phi i64 %storemerge42.i.i -> i64 5\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %0 = icmp sgt i64 %j.sroa.0.043.i.i, 0 -> T\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 4\n %spec.select.i.i = select i1 %0, i64 %dec.348.i.i, i64 0 -> i64 4\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %1 -> i64 4\n %inc22.i.i = add i64 %storemerge42.i.i, 1 -> i64 6\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 4\n phi i64 %j.sroa.0.043.i.i -> i64 5\n phi i64 %storemerge42.i.i -> i64 6\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %0 = icmp sgt i64 %j.sroa.0.043.i.i, 0 -> T\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 5\n %spec.select.i.i = select i1 %0, i64 %dec.348.i.i, i64 0 -> i64 5\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %1 -> i64 5\n %inc22.i.i = add i64 %storemerge42.i.i, 1 -> i64 7\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 5\n phi i64 %j.sroa.0.043.i.i -> i64 6\n phi i64 %storemerge42.i.i -> i64 7\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %0 = icmp sgt i64 %j.sroa.0.043.i.i, 0 -> T\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 6\n %spec.select.i.i = select i1 %0, i64 %dec.348.i.i, i64 0 -> i64 6\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %1 -> i64 6\n %inc22.i.i = add i64 %storemerge42.i.i, 1 -> i64 8\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 6\n phi i64 %j.sroa.0.043.i.i -> i64 7\n phi i64 %storemerge42.i.i -> i64 8\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %0 = icmp sgt i64 %j.sroa.0.043.i.i, 0 -> T\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 7\n %spec.select.i.i = select i1 %0, i64 %dec.348.i.i, i64 0 -> i64 7\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %1 -> i64 7\n %inc22.i.i = add i64 %storemerge42.i.i, 1 -> i64 9\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 7\n phi i64 %j.sroa.0.043.i.i -> i64 8\n phi i64 %storemerge42.i.i -> i64 9\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %0 = icmp sgt i64 %j.sroa.0.043.i.i, 0 -> T\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 8\n %spec.select.i.i = select i1 %0, i64 %dec.348.i.i, i64 0 -> i64 8\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %1 -> i64 8\n %inc22.i.i = add i64 %storemerge42.i.i, 1 -> i64 10\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> T\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %g.exit\n %conv = trunc i64 %.pre.i.i to i32 -> i32 7\n %call1 = call i32 (ptr, ...) @printf(ptr @.str, i32 %conv)\n Printf: 7\n -> i32 2\n ret i32 0\nExiting function main\n```\nAfter:\n```\n; ModuleID = 'reduced.ll'\nsource_filename = \"reduced.ll\"\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@.str = constant [4 x i8] c\"%d\\0A\\00\"\n\ndefine i32 @main() {\nentry:\n br label %for.cond1.preheader.i.i\n\nfor.cond1.preheader.i.i: ; preds = %for.inc18.i.i, %entry\n %.pre.i.i = phi i64 [ 0, %entry ], [ %0, %for.inc18.i.i ]\n %storemerge42.i.i = phi i64 [ 0, %entry ], [ %inc22.i.i, %for.inc18.i.i ]\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i\n\nfor.end.i.i: ; preds = %for.cond1.preheader.i.i\n %dec.348.i.i = add i64 %.pre.i.i, 1\n %spec.select.i.i = select i1 true, i64 %dec.348.i.i, i64 0\n br label %for.inc18.i.i\n\nfor.inc18.i.i: ; preds = %for.end.i.i, %for.cond1.preheader.i.i\n %0 = phi i64 [ %spec.select.i.i, %for.end.i.i ], [ 0, %for.cond1.preheader.i.i ]\n %inc22.i.i = add nuw nsw i64 %storemerge42.i.i, 1\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i\n\ng.exit: ; preds = %for.inc18.i.i\n %.pre.i.i.lcssa = phi i64 [ %.pre.i.i, %for.inc18.i.i ]\n %conv = trunc i64 %.pre.i.i.lcssa to i32\n %call1 = call i32 (ptr, ...) @printf(ptr @.str, i32 %conv)\n ret i32 0\n}\n\ndeclare i32 @printf(ptr, ...)\n```\n```\nEntering function main\n br label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 0\n phi i64 %storemerge42.i.i -> i64 0\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> T\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.inc18.i.i\n phi i64 %0 -> i64 0\n %inc22.i.i = add nuw nsw i64 %storemerge42.i.i, 1 -> i64 1\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 0\n phi i64 %storemerge42.i.i -> i64 1\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 1\n %spec.select.i.i = select i1 true, i64 %dec.348.i.i, i64 0 -> i64 1\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %0 -> i64 1\n %inc22.i.i = add nuw nsw i64 %storemerge42.i.i, 1 -> i64 2\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 1\n phi i64 %storemerge42.i.i -> i64 2\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 2\n %spec.select.i.i = select i1 true, i64 %dec.348.i.i, i64 0 -> i64 2\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %0 -> i64 2\n %inc22.i.i = add nuw nsw i64 %storemerge42.i.i, 1 -> i64 3\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 2\n phi i64 %storemerge42.i.i -> i64 3\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 3\n %spec.select.i.i = select i1 true, i64 %dec.348.i.i, i64 0 -> i64 3\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %0 -> i64 3\n %inc22.i.i = add nuw nsw i64 %storemerge42.i.i, 1 -> i64 4\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 3\n phi i64 %storemerge42.i.i -> i64 4\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 4\n %spec.select.i.i = select i1 true, i64 %dec.348.i.i, i64 0 -> i64 4\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %0 -> i64 4\n %inc22.i.i = add nuw nsw i64 %storemerge42.i.i, 1 -> i64 5\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 4\n phi i64 %storemerge42.i.i -> i64 5\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 5\n %spec.select.i.i = select i1 true, i64 %dec.348.i.i, i64 0 -> i64 5\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %0 -> i64 5\n %inc22.i.i = add nuw nsw i64 %storemerge42.i.i, 1 -> i64 6\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 5\n phi i64 %storemerge42.i.i -> i64 6\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 6\n %spec.select.i.i = select i1 true, i64 %dec.348.i.i, i64 0 -> i64 6\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %0 -> i64 6\n %inc22.i.i = add nuw nsw i64 %storemerge42.i.i, 1 -> i64 7\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 6\n phi i64 %storemerge42.i.i -> i64 7\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 7\n %spec.select.i.i = select i1 true, i64 %dec.348.i.i, i64 0 -> i64 7\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %0 -> i64 7\n %inc22.i.i = add nuw nsw i64 %storemerge42.i.i, 1 -> i64 8\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 7\n phi i64 %storemerge42.i.i -> i64 8\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 8\n %spec.select.i.i = select i1 true, i64 %dec.348.i.i, i64 0 -> i64 8\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %0 -> i64 8\n %inc22.i.i = add nuw nsw i64 %storemerge42.i.i, 1 -> i64 9\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> F\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %for.cond1.preheader.i.i\n phi i64 %.pre.i.i -> i64 8\n phi i64 %storemerge42.i.i -> i64 9\n %tobool.not.i.i = icmp eq i64 %storemerge42.i.i, 0 -> F\n br i1 %tobool.not.i.i, label %for.inc18.i.i, label %for.end.i.i jump to %for.end.i.i\n %dec.348.i.i = add i64 %.pre.i.i, 1 -> i64 9\n %spec.select.i.i = select i1 true, i64 %dec.348.i.i, i64 0 -> i64 9\n br label %for.inc18.i.i jump to %for.inc18.i.i\n phi i64 %0 -> i64 9\n %inc22.i.i = add nuw nsw i64 %storemerge42.i.i, 1 -> i64 10\n %exitcond50.not.i.i = icmp eq i64 %storemerge42.i.i, 9 -> T\n br i1 %exitcond50.not.i.i, label %g.exit, label %for.cond1.preheader.i.i jump to %g.exit\n phi i64 %.pre.i.i.lcssa -> i64 8\n %conv = trunc i64 %.pre.i.i.lcssa to i32 -> i32 8\n %call1 = call i32 (ptr, ...) @printf(ptr @.str, i32 %conv)\n Printf: 8\n -> i32 2\n ret i32 0\nExiting function main\n```\nllvm version: 52fc6ffcda0895c0c7b976ad1f5cb5a282b571d2",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:SCEV"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Reduced reproducer: https://alive2.llvm.org/ce/z/_x96gs\n```\n; bin/opt -passes=indvars reduced.ll -S --debug\ndefine i32 @src() {\nentry:\n br label %for.preheader\n\nfor.preheader:\n %indvar1 = phi i32 [ 0, %entry ], [ %phi, %for.inc ]\n %indvar2 = phi i32 [ 1, %entry ], [ %indvar3, %for.inc ]\n %indvar3 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]\n %cond1 = icmp eq i32 %indvar3, 0\n br i1 %cond1, label %for.inc, label %for.end\n\nfor.end:\n %cmp = icmp sgt i32 %indvar2, 0\n %ext = zext i1 %cmp to i32\n br label %for.inc\n\nfor.inc:\n %phi = phi i32 [ %ext, %for.end ], [ 0, %for.preheader ]\n %inc = add i32 %indvar3, 1\n %exitcond = icmp eq i32 %indvar3, 2\n br i1 %exitcond, label %for.exit, label %for.preheader\n\nfor.exit:\n ret i32 %indvar1\n}\n\n```\n```\nINDVARS: Eliminated comparison: %cmp = icmp sgt i32 %indvar2, 0\n\ndefine i32 @src() {\nentry:\n br label %for.preheader\n\nfor.preheader: ; preds = %for.inc, %entry\n %indvar1 = phi i32 [ 0, %entry ], [ %phi, %for.inc ]\n %indvar3 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]\n %cond1 = icmp eq i32 %indvar3, 0\n br i1 %cond1, label %for.inc, label %for.end\n\nfor.end: ; preds = %for.preheader\n %ext = zext i1 true to i32\n br label %for.inc\n\nfor.inc: ; preds = %for.end, %for.preheader\n %phi = phi i32 [ %ext, %for.end ], [ 0, %for.preheader ]\n %inc = add nuw nsw i32 %indvar3, 1\n %exitcond = icmp eq i32 %indvar3, 2\n br i1 %exitcond, label %for.exit, label %for.preheader\n\nfor.exit: ; preds = %for.inc\n %indvar1.lcssa = phi i32 [ %indvar1, %for.inc ]\n ret i32 %indvar1.lcssa\n}\n```\n`ScalarEvolution::isImpliedViaMerge(sgt, %indvar2, 0, {0,+,1}<nuw><nsw><%for.preheader>(= %indvar3), 0)` wrongly returns true.\nI can't quite understand why `%indvar3` properly dominates `%for.preheader`: https://github.com/llvm/llvm-project/blob/26ecddb05d13c101ccd840a6710eb5f8b82de841/llvm/lib/Analysis/ScalarEvolution.cpp#L14131-L14141\n\n@nikic @fhahn Can you help fix this issue?\n\n\n"
},
{
"author": "nikic",
"body": "Related previous fix: https://reviews.llvm.org/D101829"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
154407
|
https://github.com/llvm/llvm-project/issues/154407
|
crash
|
3ce0ea38c2328c373227f5f1237b8ed88f7ecf06
| 2025-08-19T18:53:12 |
[
"llvm/test/Transforms/GVN/PRE"
] |
{
"fix_commit": "49fcfaa15aeeed147280e6e39d802ac712ed3d74",
"components": [
"GVN"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": [
[
2982,
2988
]
],
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": [
"GVNPass::performScalarPRE"
],
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 49fcfaa15aeeed147280e6e39d802ac712ed3d74
Author: Farzon Lotfi <farzonlotfi@microsoft.com>
Date: Tue Sep 2 17:16:42 2025 -0400
[GVN] Turn off ScalarPRE for TokenLike Types (#156513)
fixes #154407
In HLSL the GVNPass was adding a phi node on
a target extention type.
https://hlsl.godbolt.org/z/sc14YenEe
This is something we cleaned up in a past PR
(https://github.com/llvm/llvm-project/pull/154620) by introducing
`isTokenLikeTy`. In the case of the GVN pass the target extention type
was still making its way through. This change makes it so if we see this
type we don't do PRE.
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index 4baa3b3eb824..26e17cc849bf 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -2982,7 +2982,8 @@ bool GVNPass::performScalarPREInsertion(Instruction *Instr, BasicBlock *Pred,
bool GVNPass::performScalarPRE(Instruction *CurInst) {
if (isa<AllocaInst>(CurInst) || CurInst->isTerminator() ||
isa<PHINode>(CurInst) || CurInst->getType()->isVoidTy() ||
- CurInst->mayReadFromMemory() || CurInst->mayHaveSideEffects())
+ CurInst->mayReadFromMemory() || CurInst->mayHaveSideEffects() ||
+ CurInst->getType()->isTokenLikeTy())
return false;
// Don't do PRE on compares. The PHI would prevent CodeGenPrepare from
|
[
{
"file": "llvm/test/Transforms/GVN/PRE/no-phi-translate.ll",
"commands": [
"opt -S -passes=gvn %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n\n%\"$Globals\" = type { i32 }\n@CBV = external constant %\"$Globals\"\n@Out.str = private unnamed_addr constant [4 x i8] c\"Out\\00\", align 1\n\ndefine i32 @CSMain() local_unnamed_addr {\n;\nentry:\n %loadGlobal = load i32, ptr @CBV, align 4\n %cmp.i1.not = icmp eq i32 %loadGlobal, 0\n br i1 %cmp.i1.not, label %CSMain.exit, label %for.body.i.lr.ph\n\nfor.body.i.lr.ph:\n %buf = tail call target(\"dx.RawBuffer\", i32, 1, 0) @llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 4, i32 %loadGlobal, ptr nonnull @Out.str)\n br label %for.body.i\n\nfor.body.i:\n %loopPhi = phi i32 [ 0, %for.body.i.lr.ph ], [ %inc.i, %for.body.i ]\n %updateCnt = tail call noundef i32 @llvm.dx.resource.updatecounter(target(\"dx.RawBuffer\", i32, 1, 0) %buf, i8 1)\n %inc.i = add nuw nsw i32 %loopPhi, 1\n %exitcond = icmp ne i32 %inc.i, %loadGlobal\n br i1 %exitcond, label %for.body.i, label %CSMain.exit\n\nCSMain.exit:\n %bufExit = tail call target(\"dx.RawBuffer\", i32, 1, 0) @llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 4, i32 %loadGlobal, ptr nonnull @Out.str)\n %updateCntExit = tail call noundef i32 @llvm.dx.resource.updatecounter(target(\"dx.RawBuffer\", i32, 1, 0) %bufExit, i8 1)\n ret i32 %updateCntExit\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[HLSL] Assert & crash in OpLowerer when resolving `llvm.dx.resource.casthandle` on a phi node",
"body": "```\nRWStructuredBuffer<int> Out[4] : register(u0);\n\n[numthreads(4,1,1)]\nvoid main(uint GI : SV_GroupIndex) {\n for (int i = 0; i < GI; i++)\n Out[GI].IncrementCounter();\n \n Out[GI][0] = Out[GI].IncrementCounter();\n}\n```\n\nhttps://godbolt.org/z/Ezjdfadj1\n\n`OpLowerer::cleanupHandleCasts` is expecting the operand of `@llvm.dx.resource.casthandle` to be a `CallInst` and it is a phi node:\n```\n %.pre-phi = phi target(\"dx.RawBuffer\", i32, 1, 0) [ %1, %entry._Z4mainj.exit_crit_edge ], [ %3, %for.body.i ]\n\n %6 = call %dx.types.Handle @llvm.dx.resource.casthandle.s_dx.types.Handles.tdx.RawBuffer_i32_1_0t(target(\"dx.RawBuffer\", i32, 1, 0) %.pre-phi)\n```\n\n```\n #0 0x0000000003cff348 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3cff348)\n #1 0x0000000003cfcd1c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3cfcd1c)\n #2 0x0000000003c4cfd8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0\n #3 0x00007a5b5fe42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #4 0x00000000036cca1c llvm::Value::doRAUW(llvm::Value*, llvm::Value::ReplaceMetadataUses) (/opt/compiler-explorer/clang-trunk/bin/clang+0x36cca1c)\n #5 0x0000000002b3e445 (anonymous namespace)::OpLowerer::lowerIntrinsics() (.constprop.0) DXILOpLowering.cpp:0:0\n #6 0x0000000002b40de5 (anonymous namespace)::DXILOpLoweringLegacy::runOnModule(llvm::Module&) DXILOpLowering.cpp:0:0\n #7 0x0000000003644709 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3644709)\n #8 0x0000000003fa339d clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3fa339d)\n #9 0x000000000464753c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x464753c)\n#10 0x00000000062ce46c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x62ce46c)\n#11 0x0000000004647d2d clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+0x4647d2d)\n#12 0x0000000004953a3a clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+0x4953a3a)\n#13 0x00000000048ccd7b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x48ccd7b)\n#14 0x0000000004a44df3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4a44df3)\n#15 0x0000000000dc0775 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+0xdc0775)\n#16 0x0000000000db871d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#17 0x00000000046ba419 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0\n#18 0x0000000003c4d3f3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3c4d3f3)\n#19 0x00000000046ba639 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0\n#20 0x000000000467d5bd clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x467d5bd)\n#21 0x000000000467e571 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x467e571)\n#22 0x000000000468860c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x468860c)\n#23 0x0000000000dbcf81 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0xdbcf81)\n#24 0x0000000000c6bb44 main (/opt/compiler-explorer/clang-trunk/bin/clang+0xc6bb44)\n#25 0x00007a5b5fe29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#26 0x00007a5b5fe29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#27 0x0000000000db81b5 _start (/opt/compiler-explorer/clang-trunk/bin/clang+0xdb81b5)\n```",
"author": "hekota",
"labels": [
"crash",
"HLSL",
"llvm:GVN"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
88849
|
https://github.com/llvm/llvm-project/issues/88849
|
crash
|
6b98ab95f0d36705b5a1fc1e755c992ba2329c89
| 2024-04-16T07:36:13 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "b8741cc185e89a95c9161218084f7c8b5578cf96",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": [
[
254,
259
]
],
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": [
"VPTransformState::get"
],
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit b8741cc185e89a95c9161218084f7c8b5578cf96
Author: Florian Hahn <flo@fhahn.com>
Date: Fri Jul 19 10:33:07 2024 +0100
[VPlan] Relax assertion retrieving a scalar from VPTransformState::get.
The current assertion VPTransformState::get when retrieving a single
scalar only does not account for cases where a def has multiple users,
some demanding all scalar lanes, some demanding only a single scalar.
For an example, see the modified test case. Relax the assertion by also
allowing requesting scalar lanes only when the Def doesn't have only its
first lane used.
Fixes https://github.com/llvm/llvm-project/issues/88849.
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index 83a035fb4df8..58de6256900f 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -254,6 +254,7 @@ Value *VPTransformState::get(VPValue *Def, const VPIteration &Instance) {
Value *VPTransformState::get(VPValue *Def, unsigned Part, bool NeedsScalar) {
if (NeedsScalar) {
assert((VF.isScalar() || Def->isLiveIn() || hasVectorValue(Def, Part) ||
+ !vputils::onlyFirstLaneUsed(Def) ||
(hasScalarValue(Def, VPIteration(Part, 0)) &&
Data.PerPartScalars[Def][Part].size() == 1)) &&
"Trying to access a single scalar per part but has multiple scalars "
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/SystemZ/scalar-steps-with-users-demanding-all-lanes-and-first-lane-only.ll",
"commands": [
"opt -p loop-vectorize -mtriple=s390x-unknown-linux -mcpu=z16 -S %s"
],
"tests": [
{
"test_name": "test_scalar_iv_steps_used_by_replicate_and_first_lane_only_vpinst",
"test_body": "target datalayout = \"E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64\"\n\n@src = external global [8 x i32], align 4\n\ndefine void @test_scalar_iv_steps_used_by_replicate_and_first_lane_only_vpinst(ptr noalias %dst, ptr noalias %src.1) {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %mul.iv = mul nsw i64 %iv, 4\n %gep.src.1 = getelementptr inbounds i8, ptr %src.1, i64 %mul.iv\n %l.1 = load i8, ptr %gep.src.1, align 1\n %c = icmp eq i8 %l.1, 0\n br i1 %c, label %then, label %loop.latch\n\nthen: ; preds = %loop.header\n %iv.or = or disjoint i64 %iv, 4\n %gep.src = getelementptr inbounds [8 x i32], ptr @src, i64 0, i64 %iv.or\n %l.2 = load i32, ptr %gep.src, align 4\n store i32 %l.2, ptr %dst, align 4\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n %iv.next = add nuw nsw i64 %iv, 1\n %ec = icmp eq i64 %iv.next, 4\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "LoopVectorizer asserts: Assertion `(VF.isScalar() || Def->isLiveIn() || (hasScalarValue(Def, VPIteration(Part, 0)) && Data.PerPartScalars[Def][Part].size() == 1)) && \"Trying to access a single scalar per part but has multiple scalars \" \"per part.",
"body": "[tc_crash35_aftercreduce.ll.tar.gz](https://github.com/llvm/llvm-project/files/14988465/tc_crash35_aftercreduce.ll.tar.gz)\r\n\r\nopt -mtriple=s390x-unknown-linux -mcpu=z16 -O3 tc_crash35_aftercreduce.ll -o /dev/null\r\n\r\nVPlan.cpp:253: llvm::Value* llvm::VPTransformState::get(llvm::VPValue*, unsigned int, bool): Assertion `(VF.isScalar() || Def->isLiveIn() || (hasScalarValue(Def, VPIteration(Part, 0)) && Data.PerPartScalars[Def][Part].size() == 1)) && \"Trying to access a single scalar per part but has multiple scalars \" \"per part.\"' failed.\r\n\r\n@fhahn ",
"author": "JonPsson1",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "fhahn",
"body": "Should be fixed now, sorry for the delay @JonPsson1 !"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
78621
|
https://github.com/llvm/llvm-project/issues/78621
|
miscompilation
|
90ba33099cbb17e7c159e9ebc5a512037db99d6d
| 2024-01-18T20:57:06 |
[
"llvm/test/Transforms/ConstraintElimination"
] |
{
"fix_commit": "3d91d9613e294b242d853039209b40a0cb7853f2",
"components": [
"ConstraintElimination"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": [
[
1061,
1071
]
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": [
"State::addInfoFor"
],
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 3d91d9613e294b242d853039209b40a0cb7853f2
Author: Florian Hahn <flo@fhahn.com>
Date: Wed Jan 24 14:25:54 2024 +0000
[ConstraintElim] Make sure min/max intrinsic results are not poison.
The result of umin may be poison and in that case the added constraints
are not be valid in contexts where poison doesn't cause UB. Only queue
facts for min/max intrinsics if the result is guaranteed to not be
poison.
This could be improved in the future, by only adding the fact when
solving conditions using the result value.
Fixes https://github.com/llvm/llvm-project/issues/78621.
diff --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
index 8f09569d0d9c..7b672e89b67a 100644
--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -1061,11 +1061,16 @@ void State::addInfoFor(BasicBlock &BB) {
FactOrCheck::getCheck(DT.getNode(&BB), cast<CallInst>(&I)));
break;
// Enqueue the intrinsics to add extra info.
- case Intrinsic::abs:
case Intrinsic::umin:
case Intrinsic::umax:
case Intrinsic::smin:
case Intrinsic::smax:
+ // TODO: Check if it is possible to instead only added the min/max facts
+ // when simplifying uses of the min/max intrinsics.
+ if (!isGuaranteedNotToBePoison(&I))
+ break;
+ [[fallthrough]];
+ case Intrinsic::abs:
WorkList.push_back(FactOrCheck::getInstFact(DT.getNode(&BB), &I));
break;
}
|
[
{
"file": "llvm/test/Transforms/ConstraintElimination/minmax.ll",
"commands": [
"opt -passes=constraint-elimination -S %s"
],
"tests": [
{
"test_name": "smin_branchless",
"test_body": "define i1 @smin_branchless(i32 %x, i32 %y) {\nentry:\n %min = call i32 @llvm.smin.i32(i32 %x, i32 %y)\n %cmp1 = icmp sle i32 %min, %x\n %cmp2 = icmp sgt i32 %min, %x\n %ret = xor i1 %cmp1, %cmp2\n ret i1 %ret\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.smin.i32(i32, i32) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll",
"commands": [
"opt -p constraint-elimination -S %s"
],
"tests": [
{
"test_name": "umin_poison_call_before_UB",
"test_body": "define i1 @umin_poison_call_before_UB(i32 %arg) {\n %icmp = icmp slt i32 %arg, 0\n %shl = shl nuw nsw i32 %arg, 3\n %min = call i32 @llvm.umin.i32(i32 %shl, i32 80)\n call void @fn()\n call void @noundef(i32 noundef %min)\n %cmp2 = shl nuw nsw i32 %arg, 3\n ret i1 %icmp\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.umin.i32(i32, i32) #0\n\ndeclare void @noundef(i32 noundef)\n\ndeclare void @fn()\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "umin_not_used",
"test_body": "define i1 @umin_not_used(i32 %arg) {\n %icmp = icmp slt i32 %arg, 0\n %shl = shl nuw nsw i32 %arg, 3\n %1 = call i32 @llvm.umin.i32(i32 %shl, i32 80)\n %cmp2 = shl nuw nsw i32 %arg, 3\n ret i1 %icmp\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.umin.i32(i32, i32) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "umin_poison_is_UB_via_call",
"test_body": "define i1 @umin_poison_is_UB_via_call(i32 %arg) {\n %icmp = icmp slt i32 %arg, 0\n %shl = shl nuw nsw i32 %arg, 3\n %min = call i32 @llvm.umin.i32(i32 %shl, i32 80)\n call void @noundef(i32 noundef %min)\n %cmp2 = shl nuw nsw i32 %arg, 3\n ret i1 %icmp\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.umin.i32(i32, i32) #0\n\ndeclare void @noundef(i32 noundef)\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[ConstraintElimination] A miscompile in presence of `shl nuw nsw` and `llvm.umin`",
"body": "The following commit: https://github.com/llvm/llvm-project/commit/71f56e49ceca75dbf82cbb9537c2545c2d2e51c9\r\nTriggered this miscompile: https://alive2.llvm.org/ce/z/oBg-u8\r\n\r\nNow `opt -passes=constraint-elimination -S` turns\r\n```\r\ndefine i1 @test(i32 %arg) {\r\n %icmp = icmp slt i32 %arg, 0\r\n %shl = shl nuw nsw i32 %arg, 3\r\n %call4 = call i32 @llvm.umin.i32(i32 %shl, i32 80)\r\n ret i1 %icmp\r\n}\r\n\r\ndeclare i32 @llvm.umin.i32(i32, i32) #0\r\n\r\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\r\n```\r\ninto\r\n```\r\ndefine i1 @test(i32 %arg) {\r\n %shl = shl nuw nsw i32 %arg, 3\r\n %call4 = call i32 @llvm.umin.i32(i32 %shl, i32 80)\r\n ret i1 false\r\n}\r\n\r\ndeclare i32 @llvm.umin.i32(i32, i32) #0\r\n\r\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\r\n```\r\n\r\nGiven this debug output:\r\n```\r\nopt -passes=constraint-elimination before-constr-elim-renamed.ll -S -debug-only=constraint-elimination,constraint-system\r\nProcessing fact to add to the system: icmp ule i32 %call4, %shl\r\nAdding 'icmp ule i32 %call4, %shl'\r\n constraint: -8 * %arg + %call4 <= 0\r\n\r\n---\r\n-1 * %arg <= 0\r\n-8 * %arg + %call4 <= 0\r\n-1 * %call4 <= 0\r\n8 * %arg <= -1\r\nunsat\r\nAdding 'icmp sge i32 %call4, 0'\r\n constraint: -1 * %call4 <= 0\r\n\r\nAdding 'icmp sle i32 %call4, %shl'\r\n constraint: -8 * %arg + %call4 <= 0\r\n\r\nProcessing fact to add to the system: icmp ule i32 %call4, 80\r\nAdding 'icmp ule i32 %call4, 80'\r\n constraint: %call4 <= 80\r\n\r\nAdding 'icmp sge i32 %call4, 0'\r\n constraint: -1 * %call4 <= 0\r\n\r\nAdding 'icmp sle i32 %call4, 80'\r\n constraint: %call4 <= 80\r\n\r\nTop of stack : 0 1\r\nCB: 0 1\r\nProcessing condition to simplify: %icmp = icmp slt i32 %arg, 0\r\nChecking %icmp = icmp slt i32 %arg, 0\r\n---\r\n-1 * %call4 <= 0\r\n-8 * %arg + %call4 <= 0\r\n-1 * %call4 <= 0\r\n%call4 <= 80\r\n-1 * %arg <= 0\r\nsat\r\n---\r\n-1 * %call4 <= 0\r\n-8 * %arg + %call4 <= 0\r\n-1 * %call4 <= 0\r\n%call4 <= 80\r\n%arg <= -1\r\nunsat\r\nCondition icmp sge i32 %arg, 0 implied by dominating constraints\r\n-1 * %call4 <= 0\r\n-8 * %arg + %call4 <= 0\r\n-1 * %call4 <= 0\r\n%call4 <= 80\r\n```\r\nI'm not 100% sure if the aforementioned patch causes the miscompile, of if it merely triggers it on this specific reproducer. The fact that something like `-1 * %call4 <= 0` is reported as a \"dominating constraint\" seems suspicious to a person who's not familiar with the logic of ConstraintElimination and it doesn't look directly related to that patch. However, if I replace the `shl nuw nsw i32 %arg, 3\r\n` with `mul nuw nsw i32 %arg, 8`, the miscompile doesn't happen: https://alive2.llvm.org/ce/z/EL2bCh.",
"author": "DaniilSuchkov",
"labels": [
"miscompilation",
"release:backport",
"llvm:transforms"
],
"comments": [
{
"author": "nikic",
"body": "From the debug log, I suspect that we're using the unsigned constraint system to prove a signed fact for some reason.\r\n\r\ncc @fhahn "
},
{
"author": "nikic",
"body": "Okay, this is an interesting case.\r\n\r\nWe are adding an `icmp ule i32 %call4, %shl` fact, which get transferred as `icmp sge i32 %call4, 0` and `icmp sle i32 %call4, %shl` to the signed system, because `%shl` is known non-negative.\r\n\r\nThen we are checking whether a solution of these constraints plus `%arg <= -1` exists, which it does not.\r\n\r\nThis is \"correct\" in the sense that *if* that umin call returns a non-poison result, then `icmp slt i32 %arg, 0` is indeed known to be false. But we obviously can't actually make that assumption.\r\n\r\n@dtcxzyw @fhahn This makes me think that the way we are currently adding facts for MinMaxIntrinsic (and I guess abs as well) is pretty fundamentally incorrect, because it effectively imposes a constraint that the umin operation returns a well-defined value. Any thoughts on how to fix this without dropping support for them entirely?"
},
{
"author": "nikic",
"body": "(The difference between shl and mul in the reproducer is because ValueTracking apparently currently doesn't know that mul nuw nsw is non-negative, but knows that shl nuw nsw is.)"
},
{
"author": "dtcxzyw",
"body": "> @dtcxzyw @fhahn This makes me think that the way we are currently adding facts for MinMaxIntrinsic (and I guess abs as well) is pretty fundamentally incorrect, because it effectively imposes a constraint that the umin operation returns a well-defined value. Any thoughts on how to fix this without dropping support for them entirely?\r\n\r\nCan we conservatively check these intrinsics using `isGuaranteedNotToBePoison`?\r\n"
},
{
"author": "nikic",
"body": "If it's not too complicated, I think a better solution would be to only add the intrinsic constraints when the result variable is added to the constraint system."
},
{
"author": "fhahn",
"body": "> If it's not too complicated, I think a better solution would be to only add the intrinsic constraints when the result variable is added to the constraint system.\r\n\r\nOne way to do that would be to check the uses of the intrinsic and find all the branches that it feeds, and add it as fact for the successors."
},
{
"author": "nikic",
"body": "@dtcxzyw Do you plan to submit a PR for this issue?"
},
{
"author": "dtcxzyw",
"body": "> @dtcxzyw Do you plan to submit a PR for this issue?\r\n\r\nI will post a patch later."
},
{
"author": "fhahn",
"body": "I've pushed a fix that only adds the facts if the result is guaranteed to not be poison so the mis-compile is fixed. I also added a TODO to improve things if possible.\r\n\r\nReopening so we can pick the fix for the release branch"
},
{
"author": "nikic",
"body": "@fhahn Why does your fix only do this for min/max but not abs? Can't it have the same problem?"
},
{
"author": "fhahn",
"body": "> @fhahn Why does your fix only do this for min/max but not abs? Can't it have the same problem?\r\n\r\nI wasn't able to come up with a problematic test case so far for `abs`, but there's a few more things to try."
},
{
"author": "DaniilSuchkov",
"body": "@fhahn I'm not familiar with how this pass works, so I have a question: will this pass still use min/max/etc. to infer facts about the arguments of those intrinsics? I'm just a bit confused by the terminology: I see that it adds \"constraints\" based on things like `icmp`, which on their own don't actually constrain anything unless you branch on the result (or do something similar)."
},
{
"author": "nikic",
"body": "> @fhahn I'm not familiar with how this pass works, so I have a question: will this pass still use min/max/etc. to infer facts about the arguments of those intrinsics? I'm just a bit confused by the terminology: I see that it adds \"constraints\" based on things like `icmp`, which on their own don't actually constrain anything unless you branch on the result (or do something similar).\r\n\r\nConstraints for icmps will only be added in branches that the icmp dominates (or code that an assume with an icmp dominates). The intrinsic handling was a bit special in that constraints are added unconditionally."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
85333
|
https://github.com/llvm/llvm-project/issues/85333
|
miscompilation
|
fa67986d5b309ddd4c2ea74e8a5eeb0559aa8022
| 2024-03-14T23:23:02 |
[
"llvm/test/Transforms/GVNSink"
] |
{
"fix_commit": "1c979ab7e59feb03c58cac631a93143b0c776c20",
"components": [
"GVNSink"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": [
[
719,
730
]
],
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": [
"GVNSink::analyzeInstructionForSinking"
],
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 1c979ab7e59feb03c58cac631a93143b0c776c20
Author: AdityaK <hiraditya@msn.com>
Date: Tue Apr 30 11:31:45 2024 -0700
[GVNSink] Fix incorrect codegen with respect to GEPs #85333 (#88440)
As mentioned in #68882 and
https://discourse.llvm.org/t/rfc-replacing-getelementptr-with-ptradd/68699
Gep arithmetic isn't consistent with different types. GVNSink didn't
realize this and sank all geps
as long as their operands can be wired via PHIs
in a post-dominator.
Fixes: #85333
diff --git a/llvm/lib/Transforms/Scalar/GVNSink.cpp b/llvm/lib/Transforms/Scalar/GVNSink.cpp
index d4907326eb0a..1d2577e1da33 100644
--- a/llvm/lib/Transforms/Scalar/GVNSink.cpp
+++ b/llvm/lib/Transforms/Scalar/GVNSink.cpp
@@ -719,12 +719,11 @@ GVNSink::analyzeInstructionForSinking(LockstepReverseIterator &LRI,
// try and continue making progress.
Instruction *I0 = NewInsts[0];
- // If all instructions that are going to participate don't have the same
- // number of operands, we can't do any useful PHI analysis for all operands.
- auto hasDifferentNumOperands = [&I0](Instruction *I) {
- return I->getNumOperands() != I0->getNumOperands();
+ auto isNotSameOperation = [&I0](Instruction *I) {
+ return !I0->isSameOperationAs(I);
};
- if (any_of(NewInsts, hasDifferentNumOperands))
+
+ if (any_of(NewInsts, isNotSameOperation))
return std::nullopt;
for (unsigned OpNum = 0, E = I0->getNumOperands(); OpNum != E; ++OpNum) {
|
[
{
"file": "llvm/test/Transforms/GVNSink/different-gep-types.ll",
"commands": [
"opt -passes=gvn-sink -S %s"
],
"tests": [
{
"test_name": "bar",
"test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\n\n%\"struct.std::pair\" = type <{ i32, %struct.substruct, [2 x i8] }>\n%struct.substruct = type { i8, i8 }\n\ndefine void @bar(ptr noundef nonnull align 4 dereferenceable(4) %__i, i32 noundef %__n) {\nentry:\n %cmp = icmp eq i32 %__n, 1\n br i1 %cmp, label %if.then, label %if.else\n\nif.then: ; preds = %entry\n %0 = load ptr, ptr %__i, align 4\n %incdec.ptr4 = getelementptr inbounds i8, ptr %0, i32 -8\n br label %if.end6\n\nif.else: ; preds = %entry\n %1 = load ptr, ptr %__i, align 4\n %add.ptr = getelementptr inbounds %\"struct.std::pair\", ptr %1, i32 %__n\n br label %if.end6\n\nif.end6: ; preds = %if.else, %if.then\n %incdec.ptr.sink = phi ptr [ %incdec.ptr4, %if.then ], [ %add.ptr, %if.else ]\n store ptr %incdec.ptr.sink, ptr %__i, align 4\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "foo",
"test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\n\ndefine void @foo(ptr noundef nonnull align 4 dereferenceable(4) %__i, i32 noundef %__n) {\nentry:\n %cmp = icmp eq i32 %__n, 1\n br i1 %cmp, label %if.then, label %if.else\n\nif.then: ; preds = %entry\n %0 = load ptr, ptr %__i, align 4\n %incdec.ptr = getelementptr inbounds i8, ptr %0, i32 8\n store ptr %incdec.ptr, ptr %__i, align 4\n br label %if.end6\n\nif.else: ; preds = %entry\n %cmp2 = icmp eq i32 %__n, -1\n br i1 %cmp2, label %if.then3, label %if.else5\n\nif.then3: ; preds = %if.else\n %1 = load ptr, ptr %__i, align 4\n %incdec.ptr4 = getelementptr inbounds i8, ptr %1, i32 -8\n store ptr %incdec.ptr4, ptr %__i, align 4\n br label %if.end6\n\nif.else5: ; preds = %if.else\n %2 = load ptr, ptr %__i, align 4\n %add.ptr = getelementptr inbounds i8, ptr %2, i32 -4\n store ptr %add.ptr, ptr %__i, align 4\n br label %if.end6\n\nif.end6: ; preds = %if.else5, %if.then3, %if.then\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "GVNSink produces incorrect codegen with respect to GEPs",
"body": "```llvm\r\ntarget datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\r\ntarget triple = \"thumbv7em-none-unknown-eabi\"\r\n\r\n%\"struct.std::pair\" = type <{ i32, %struct.substruct, [2 x i8] }>\r\n%struct.substruct = type { i8, i8 }\r\n%\"struct.std::random_access_iterator_tag\" = type { i8 }\r\n\r\ndefine linkonce_odr dso_local void @__advance(ptr noundef nonnull align 4 dereferenceable(4) %__i, i32 noundef %__n) local_unnamed_addr {\r\nentry:\r\n %0 = call i1 @llvm.is.constant.i32(i32 %__n)\r\n %cmp = icmp eq i32 %__n, 1\r\n %or.cond = and i1 %0, %cmp\r\n br i1 %or.cond, label %if.then, label %if.else\r\n\r\nif.then: ; preds = %entry\r\n %1 = load ptr, ptr %__i, align 4\r\n %incdec.ptr = getelementptr inbounds i8, ptr %1, i32 8\r\n store ptr %incdec.ptr, ptr %__i, align 4\r\n br label %if.end6\r\n\r\nif.else: ; preds = %entry\r\n %2 = call i1 @llvm.is.constant.i32(i32 %__n)\r\n %cmp2 = icmp eq i32 %__n, -1\r\n %or.cond7 = and i1 %2, %cmp2\r\n br i1 %or.cond7, label %if.then3, label %if.else5\r\n\r\nif.then3: ; preds = %if.else\r\n %3 = load ptr, ptr %__i, align 4\r\n %incdec.ptr4 = getelementptr inbounds i8, ptr %3, i32 -8\r\n store ptr %incdec.ptr4, ptr %__i, align 4\r\n br label %if.end6\r\n\r\nif.else5: ; preds = %if.else\r\n %4 = load ptr, ptr %__i, align 4\r\n %add.ptr = getelementptr inbounds %\"struct.std::pair\", ptr %4, i32 %__n\r\n store ptr %add.ptr, ptr %__i, align 4\r\n br label %if.end6\r\n\r\nif.end6: ; preds = %if.then3, %if.else5, %if.then\r\n ret void\r\n}\r\n```\r\n\r\nThe above IR when piped through gvn-sink via `./bin/opt < /tmp/repro.ll -passes=gvn-sink -S` produces:\r\n\r\n```llvm\r\n; ModuleID = '<stdin>'\r\nsource_filename = \"<stdin>\"\r\ntarget datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\r\ntarget triple = \"thumbv7em-none-unknown-eabi\"\r\n\r\ndefine linkonce_odr dso_local void @__advance(ptr noundef nonnull align 4 dereferenceable(4) %__i, i32 noundef %__n) local_unnamed_addr {\r\nentry:\r\n %0 = call i1 @llvm.is.constant.i32(i32 %__n)\r\n %cmp = icmp eq i32 %__n, 1\r\n %or.cond = and i1 %0, %cmp\r\n br i1 %or.cond, label %if.then, label %if.else\r\n\r\nif.then: ; preds = %entry\r\n br label %if.end6\r\n\r\nif.else: ; preds = %entry\r\n %1 = call i1 @llvm.is.constant.i32(i32 %__n)\r\n %cmp2 = icmp eq i32 %__n, -1\r\n %or.cond7 = and i1 %1, %cmp2\r\n br i1 %or.cond7, label %if.then3, label %if.else5\r\n\r\nif.then3: ; preds = %if.else\r\n br label %if.end6\r\n\r\nif.else5: ; preds = %if.else\r\n br label %if.end6\r\n\r\nif.end6: ; preds = %if.else5, %if.then3, %if.then\r\n %.sink1 = phi i32 [ 8, %if.then ], [ -8, %if.then3 ], [ %__n, %if.else5 ]\r\n %2 = load ptr, ptr %__i, align 4\r\n %incdec.ptr = getelementptr inbounds i8, ptr %2, i32 %.sink1\r\n store ptr %incdec.ptr, ptr %__i, align 4\r\n ret void\r\n}\r\n\r\n; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)\r\ndeclare i1 @llvm.is.constant.i32(i32) #0\r\n\r\nattributes #0 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }\r\n```\r\n\r\nThe GEP in the result is incorrect. Prior, the GEPs were\r\n```llvm\r\n %incdec.ptr = getelementptr inbounds i8, ptr %1, i32 8\r\n %incdec.ptr4 = getelementptr inbounds i8, ptr %3, i32 -8\r\n %add.ptr = getelementptr inbounds %\"struct.std::pair\", ptr %4, i32 %__n\r\n```\r\nbut now it's\r\n```llvm\r\n%incdec.ptr = getelementptr inbounds i8, ptr %2, i32 %.sink1\r\n```\r\nThis results in an incorrect offset for `%add.ptr = getelementptr inbounds %\"struct.std::pair\", ptr %4, i32 %__n` since we'd now just add `%.sink1` bytes (where `%.sink1 = %__n` which is the second argument), whereas before we'd add `%__n * 8` bytes (where 8 is the sizeof `%\"struct.std::pair\"`).\r\n\r\nThe before ASM is:\r\n```asm\r\n__advance:\r\n ldr r2, [r0]\r\n add.w r1, r2, r1, lsl #3\r\n str r1, [r0]\r\n bx lr\r\n```\r\nbut the after asm is:\r\n```asm\r\n__advance:\r\n ldr r2, [r0]\r\n add r1, r2\r\n str r1, [r0]\r\n bx lr\r\n```\r\n\r\nThe GEP should not be a candidate for sinking.",
"author": "PiJoules",
"labels": [
"bug",
"miscompilation",
"llvm:GVN"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
77553
|
https://github.com/llvm/llvm-project/issues/77553
|
crash
|
c9c8f0c2fcf3b25ec310a75216f1d5b582ec343f
| 2024-01-10T04:18:48 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "66eedd1dd370d22ddf994540c20848618d64d1a6",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": [
[
1704,
1714
]
],
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": [
"InstCombinerImpl::foldSelectInstWithICmp"
],
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 66eedd1dd370d22ddf994540c20848618d64d1a6
Author: hanbeom <kese111@gmail.com>
Date: Thu Jan 11 17:34:30 2024 +0900
[InstCombine] Fix worklist management in select fold (#77738)
`InstCombine` uses `Worklist` to manage change history. `setOperand`,
which was previously used to change the `Select` Instruction, does not,
so it is `run` twice, which causes an `LLVM ERROR`.
This problem is resolved by changing `setOperand` to `replaceOperand` as
the change history will be registered in the Worklist.
Fixes #77553.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index ab55f235920a..21bfc91148bf 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -1704,11 +1704,11 @@ Instruction *InstCombinerImpl::foldSelectInstWithICmp(SelectInst &SI,
if (CmpRHS != CmpLHS && isa<Constant>(CmpRHS) && !isa<Constant>(CmpLHS)) {
if (CmpLHS == TrueVal && Pred == ICmpInst::ICMP_EQ) {
// Transform (X == C) ? X : Y -> (X == C) ? C : Y
- SI.setOperand(1, CmpRHS);
+ replaceOperand(SI, 1, CmpRHS);
Changed = true;
} else if (CmpLHS == FalseVal && Pred == ICmpInst::ICMP_NE) {
// Transform (X != C) ? Y : X -> (X != C) ? Y : C
- SI.setOperand(2, CmpRHS);
+ replaceOperand(SI, 2, CmpRHS);
Changed = true;
}
}
|
[
{
"file": "llvm/test/Transforms/InstCombine/select.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "src_select_xxory_eq0_xorxy_y",
"test_body": "target datalayout = \"e-p:64:64-p1:16:16-p2:32:32:32-p3:64:64:64\"\n\ndefine i32 @src_select_xxory_eq0_xorxy_y(i32 %x, i32 %y) {\n %xor = xor i32 %x, %y\n %xor0 = icmp eq i32 %xor, 0\n %cond = select i1 %xor0, i32 %xor, i32 %y\n ret i32 %cond\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "LLVM ERROR while InstCombine",
"body": "```\r\n$ bllvm0/bin/clang --version\r\nclang version 18.0.0git (git@github.com:ParkHanbum/llvm-project.git a9f39ff2b628e38826d5b95c1e8ae3cb7c692de9)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /home/m/bllvm0/bin\r\n```\r\nmy clang version.\r\n\r\nIR that caused the error\r\n```\r\ndefine i32 @no_trans_select_xor_eq0_xor_and(i32 %x, i32 %y) {\r\n; CHECK-LABEL: @no_trans_select_xor_eq0_xor_and(\r\n; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]\r\n; CHECK-NEXT: [[XOR0:%.*]] = icmp eq i32 [[XOR]], 0\r\n; CHECK-NEXT: [[AND:%.*]] = and i32 [[X]], [[Y]]\r\n; CHECK-NEXT: [[COND:%.*]] = select i1 [[XOR0]], i32 [[XOR]], i32 [[AND]]\r\n; CHECK-NEXT: ret i32 [[COND]]\r\n;\r\n %xor = xor i32 %x, %y\r\n %xor0 = icmp eq i32 %xor, 0\r\n %and = and i32 %x, %y\r\n %cond = select i1 %xor0, i32 %xor, i32 %and\r\n ret i32 %cond\r\n}\r\n```\r\n\r\nand Debug message :\r\n```\r\n$ bllvm0/bin/opt -passes=instcombine temp.ll -debug\r\nINSTCOMBINE ITERATION #1 on no_trans_select_xor_eq0_xor_and\r\nADD: ret i32 %cond\r\nADD: %cond = select i1 %xor0, i32 %xor, i32 %and\r\nADD: %and = and i32 %x, %y\r\nADD: %xor0 = icmp eq i32 %xor, 0\r\nADD: %xor = xor i32 %x, %y\r\nIC: Visiting: %xor = xor i32 %x, %y\r\nIC: Visiting: %xor0 = icmp eq i32 %xor, 0\r\nIC: Visiting: %and = and i32 %x, %y\r\nIC: Visiting: %cond = select i1 %xor0, i32 %xor, i32 %and\r\nIC: Mod = %cond = select i1 %xor0, i32 %xor, i32 %and\r\n New = %cond = select i1 %xor0, i32 0, i32 %and\r\nADD: %cond = select i1 %xor0, i32 0, i32 %and\r\nIC: Visiting: %cond = select i1 %xor0, i32 0, i32 %and\r\nIC: Visiting: ret i32 %cond\r\n\r\n\r\nINSTCOMBINE ITERATION #2 on no_trans_select_xor_eq0_xor_and\r\nADD: ret i32 %cond\r\nADD: %cond = select i1 %xor0, i32 0, i32 %and\r\nADD: %and = and i32 %x, %y\r\nADD: %xor0 = icmp eq i32 %xor, 0\r\nADD: %xor = xor i32 %x, %y\r\nIC: Visiting: %xor = xor i32 %x, %y\r\nIC: Visiting: %xor0 = icmp eq i32 %xor, 0\r\nIC: Old = %xor0 = icmp eq i32 %xor, 0\r\n New = <badref> = icmp eq i32 %x, %y\r\nADD: %xor0 = icmp eq i32 %x, %y\r\nIC: ERASE %1 = icmp eq i32 %xor, 0\r\nADD DEFERRED: %xor = xor i32 %x, %y\r\nIC: ERASE %xor = xor i32 %x, %y\r\nIC: Visiting: %xor0 = icmp eq i32 %x, %y\r\nIC: Visiting: %and = and i32 %x, %y\r\nIC: Visiting: %cond = select i1 %xor0, i32 0, i32 %and\r\nIC: Visiting: ret i32 %cond\r\nLLVM ERROR: Instruction Combining did not reach a fixpoint after 1 iterations\r\n\r\n```\r\n\r\nIf time isn't tight, I'd like to take on this issue.\r\n\r\n",
"author": "ParkHanbum",
"labels": [
"llvm:instcombine",
"crash-on-valid"
],
"comments": [
{
"author": "nikic",
"body": "The problem is likely that https://github.com/llvm/llvm-project/blob/084f1c2ee074a5ac8186ea4b5b181b48bf4621b6/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp#L1704-L1714 calls setOperand() instead of replaceOperand()."
},
{
"author": "ParkHanbum",
"body": "@nikic can I try this?"
},
{
"author": "nikic",
"body": "Sure."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
141628
|
https://github.com/llvm/llvm-project/issues/141628
|
crash
|
8a49db35f45e56c92522c6079e51553e80c07aec
| 2025-05-27T16:04:50 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "cb648ba97003bc0aa94e86f8e89ea6e3e3d09a11",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
15317,
15322
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::isGatherShuffledSingleRegisterEntry"
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit cb648ba97003bc0aa94e86f8e89ea6e3e3d09a11
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Thu May 29 08:49:31 2025 -0700
[SLP]Check if the user node has instructions, used only outside
Gather nodes with parents, which scalar instructions are used only
outside, are generated before the whole tree vectorization. Need to
teach isGatherShuffledSingleRegisterEntry to check that such nodes are
emitted first and they cannot depend on other nodes, which are emitted
later.
Fixes #141628
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 831703b375d9..3e7f4cb56c0b 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -15317,6 +15317,20 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
UserPHI ? UserPHI->getIncomingBlock(UseEI.EdgeIdx)->getTerminator()
: &getLastInstructionInBundle(UseEI.UserTE);
if (TEInsertPt == InsertPt) {
+ // Check nodes, which might be emitted first.
+ if (TEUseEI.UserTE->State == TreeEntry::Vectorize &&
+ (TEUseEI.UserTE->getOpcode() != Instruction::PHI ||
+ TEUseEI.UserTE->isAltShuffle()) &&
+ all_of(TEUseEI.UserTE->Scalars,
+ [](Value *V) { return isUsedOutsideBlock(V); })) {
+ if (UseEI.UserTE->State != TreeEntry::Vectorize ||
+ (UseEI.UserTE->getOpcode() == Instruction::PHI &&
+ !UseEI.UserTE->isAltShuffle()) ||
+ any_of(UseEI.UserTE->Scalars,
+ [](Value *V) { return !isUsedOutsideBlock(V); }))
+ continue;
+ }
+
// If the schedulable insertion point is used in multiple entries - just
// exit, no known ordering at this point, available only after real
// scheduling.
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/many-uses-parent-node.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-99999 < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine i32 @test(ptr addrspace(1) %arg) {\n;\nbb:\n br label %bb1\n\nbb1: ; preds = %bb\n %getelementptr = getelementptr i8, ptr addrspace(1) %arg, i64 20\n %getelementptr2 = getelementptr i8, ptr addrspace(1) %arg, i64 21\n %getelementptr3 = getelementptr i8, ptr addrspace(1) %arg, i64 22\n br i1 false, label %bb73, label %bb150\nbb4: ; No predecessors!\n br i1 false, label %bb68, label %bb70\nbb5: ; No predecessors!\n br i1 false, label %bb64, label %bb66\nbb6: ; No predecessors!\n br i1 false, label %bb60, label %bb62\nbb7: ; No predecessors!\n br i1 false, label %bb8, label %bb58\nbb8: ; preds = %bb7\n br i1 false, label %bb54, label %bb56\nbb9: ; No predecessors!\n br i1 false, label %bb50, label %bb52\nbb10: ; No predecessors!\n br i1 false, label %bb46, label %bb48\nbb11: ; No predecessors!\n br i1 false, label %bb42, label %bb44\nbb12: ; No predecessors!\n br i1 false, label %bb38, label %bb40\nbb13: ; No predecessors!\n br i1 false, label %bb36, label %bb122\nbb14: ; No predecessors!\n br i1 false, label %bb32, label %bb34\nbb15: ; No predecessors!\n br i1 false, label %bb28, label %bb30\nbb16: ; No predecessors!\n br i1 false, label %bb17, label %bb26\nbb17: ; preds = %bb16\n br i1 false, label %bb22, label %bb24\nbb18: ; No predecessors!\n br i1 false, label %bb19, label %bb20\nbb19: ; preds = %bb18\n %load = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb20: ; preds = %bb18\n %load21 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb22: ; preds = %bb17\n %load23 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb24: ; preds = %bb17\n %load25 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb26: ; preds = %bb16\n %load27 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb28: ; preds = %bb15\n %load29 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb30: ; preds = %bb15\n %load31 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb32: ; preds = %bb14\n %load33 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb34: ; preds = %bb14\n %load35 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb36: ; preds = %bb13\n %load37 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb38: ; preds = %bb12\n %load39 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb40: ; preds = %bb12\n %load41 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb42: ; preds = %bb11\n %load43 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb44: ; preds = %bb11\n %load45 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb46: ; preds = %bb10\n %load47 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb48: ; preds = %bb10\n %load49 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb50: ; preds = %bb9\n %load51 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb52: ; preds = %bb9\n %load53 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb54: ; preds = %bb8\n %load55 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb56: ; preds = %bb8\n %load57 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb58: ; preds = %bb7\n %load59 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb60: ; preds = %bb6\n %load61 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb62: ; preds = %bb6\n %load63 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb64: ; preds = %bb5\n %load65 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb66: ; preds = %bb5\n %load67 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb68: ; preds = %bb4\n %load69 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb70: ; preds = %bb4\n %load71 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb72: ; No predecessors!\n br i1 false, label %bb142, label %bb79\nbb73: ; preds = %bb1\n br i1 false, label %bb146, label %bb74\nbb74: ; preds = %bb73\n br i1 false, label %bb75, label %bb76\nbb75: ; preds = %bb74\n br label %bb150\nbb76: ; preds = %bb74\n br i1 false, label %bb153, label %bb77\nbb77: ; preds = %bb76\n %load78 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb79: ; preds = %bb72\n br i1 false, label %bb146, label %bb81\nbb80: ; No predecessors!\n br label %bb150\nbb81: ; preds = %bb79\n %load82 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb83: ; No predecessors!\n br label %bb138\nbb84: ; No predecessors!\n br i1 false, label %bb142, label %bb85\nbb85: ; preds = %bb84\n br i1 false, label %bb146, label %bb86\nbb86: ; preds = %bb85\n %load87 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb88: ; No predecessors!\n br label %bb134\nbb89: ; No predecessors!\n br i1 false, label %bb138, label %bb90\nbb90: ; preds = %bb89\n br i1 false, label %bb142, label %bb91\nbb91: ; preds = %bb90\n %load92 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb93: ; No predecessors!\n br label %bb130\nbb94: ; No predecessors!\n br i1 false, label %bb134, label %bb95\nbb95: ; preds = %bb94\n br i1 false, label %bb138, label %bb96\nbb96: ; preds = %bb95\n %load97 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb98: ; No predecessors!\n br label %bb126\nbb99: ; No predecessors!\n br i1 false, label %bb130, label %bb100\nbb100: ; preds = %bb99\n br i1 false, label %bb134, label %bb101\nbb101: ; preds = %bb100\n %load102 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb103: ; No predecessors!\n br label %bb124\nbb104: ; No predecessors!\n br i1 false, label %bb126, label %bb105\nbb105: ; preds = %bb104\n br i1 false, label %bb130, label %bb106\nbb106: ; preds = %bb105\n %load107 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb108: ; No predecessors!\n br label %bb124\nbb109: ; No predecessors!\n br i1 false, label %bb126, label %bb110\nbb110: ; preds = %bb109\n %load111 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb112: ; No predecessors!\n %load113 = load i8, ptr addrspace(1) %getelementptr3, align 1\n br label %bb124\nbb114: ; No predecessors!\n %load115 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb116: ; No predecessors!\n %load117 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb118: ; No predecessors!\n %load119 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb120: ; No predecessors!\n %load121 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\nbb122: ; preds = %bb13\n %load123 = load i8, ptr addrspace(1) %getelementptr3, align 1\n ret i32 0\n\nbb124: ; preds = %bb112, %bb108, %bb103\n %phi = phi ptr addrspace(1) [ null, %bb112 ], [ %getelementptr3, %bb108 ], [ null, %bb103 ]\n %phi125 = phi ptr addrspace(1) [ null, %bb112 ], [ null, %bb108 ], [ %getelementptr3, %bb103 ]\n br label %bb126\n\nbb126: ; preds = %bb124, %bb109, %bb104, %bb98\n %phi127 = phi ptr addrspace(1) [ null, %bb124 ], [ null, %bb98 ], [ null, %bb104 ], [ %getelementptr3, %bb109 ]\n %phi128 = phi ptr addrspace(1) [ null, %bb124 ], [ null, %bb98 ], [ %getelementptr3, %bb104 ], [ null, %bb109 ]\n %phi129 = phi ptr addrspace(1) [ null, %bb124 ], [ %getelementptr3, %bb98 ], [ null, %bb104 ], [ null, %bb109 ]\n br label %bb130\n\nbb130: ; preds = %bb126, %bb105, %bb99, %bb93\n %phi131 = phi ptr addrspace(1) [ null, %bb126 ], [ null, %bb93 ], [ null, %bb99 ], [ %getelementptr3, %bb105 ]\n %phi132 = phi ptr addrspace(1) [ null, %bb126 ], [ null, %bb93 ], [ %getelementptr3, %bb99 ], [ null, %bb105 ]\n %phi133 = phi ptr addrspace(1) [ null, %bb126 ], [ %getelementptr3, %bb93 ], [ null, %bb99 ], [ null, %bb105 ]\n br label %bb134\n\nbb134: ; preds = %bb130, %bb100, %bb94, %bb88\n %phi135 = phi ptr addrspace(1) [ null, %bb130 ], [ null, %bb88 ], [ null, %bb94 ], [ %getelementptr3, %bb100 ]\n %phi136 = phi ptr addrspace(1) [ null, %bb130 ], [ null, %bb88 ], [ %getelementptr3, %bb94 ], [ null, %bb100 ]\n %phi137 = phi ptr addrspace(1) [ null, %bb130 ], [ %getelementptr3, %bb88 ], [ null, %bb94 ], [ null, %bb100 ]\n br label %bb138\n\nbb138: ; preds = %bb134, %bb95, %bb89, %bb83\n %phi139 = phi ptr addrspace(1) [ null, %bb134 ], [ null, %bb83 ], [ null, %bb89 ], [ %getelementptr3, %bb95 ]\n %phi140 = phi ptr addrspace(1) [ null, %bb134 ], [ null, %bb83 ], [ %getelementptr3, %bb89 ], [ null, %bb95 ]\n %phi141 = phi ptr addrspace(1) [ null, %bb134 ], [ %getelementptr3, %bb83 ], [ null, %bb89 ], [ null, %bb95 ]\n br label %bb142\n\nbb142: ; preds = %bb138, %bb90, %bb84, %bb72\n %phi143 = phi ptr addrspace(1) [ null, %bb138 ], [ null, %bb72 ], [ null, %bb84 ], [ %getelementptr3, %bb90 ]\n %phi144 = phi ptr addrspace(1) [ null, %bb138 ], [ null, %bb72 ], [ %getelementptr3, %bb84 ], [ null, %bb90 ]\n %phi145 = phi ptr addrspace(1) [ null, %bb138 ], [ %getelementptr3, %bb72 ], [ null, %bb84 ], [ null, %bb90 ]\n br label %bb146\n\nbb146: ; preds = %bb142, %bb85, %bb79, %bb73\n %phi147 = phi ptr addrspace(1) [ null, %bb142 ], [ null, %bb73 ], [ null, %bb79 ], [ %getelementptr3, %bb85 ]\n %phi148 = phi ptr addrspace(1) [ null, %bb142 ], [ null, %bb73 ], [ %getelementptr3, %bb79 ], [ null, %bb85 ]\n %phi149 = phi ptr addrspace(1) [ null, %bb142 ], [ %getelementptr3, %bb73 ], [ null, %bb79 ], [ null, %bb85 ]\n br label %bb150\n\nbb150: ; preds = %bb146, %bb80, %bb75, %bb1\n %phi151 = phi ptr addrspace(1) [ %getelementptr2, %bb75 ], [ %getelementptr3, %bb80 ], [ null, %bb146 ], [ %getelementptr, %bb1 ]\n %phi152 = phi ptr addrspace(1) [ %getelementptr3, %bb75 ], [ null, %bb80 ], [ null, %bb146 ], [ %getelementptr2, %bb1 ]\n br label %bb153\n\nbb153: ; preds = %bb150, %bb76\n %phi154 = phi ptr addrspace(1) [ null, %bb150 ], [ %getelementptr3, %bb76 ]\n ret i32 0\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SLPVectorizer] Instruction does not dominate all uses!.. LLVM ERROR: Broken module found, compilation aborted!",
"body": "To reproduce run opt with the test below using -passes=slp-vectorizer -slp-threshold=-99999:\n\n[reduced-stripped.ll.zip](https://github.com/user-attachments/files/20462672/reduced-stripped.ll.zip)\n\nReproducer: https://godbolt.org/z/sf4Kvsqxa\n\nStack dump:\n```\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer -slp-threshold=-99999 <source>\n1.\tRunning pass \"verify\" on module \"<source>\"\n #0 0x00000000055ff378 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x55ff378)\n #1 0x00000000055fcd04 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007a8d0c442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007a8d0c4969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007a8d0c442476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007a8d0c4287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x0000000000810401 llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0\n #7 0x000000000553a631 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x553a631)\n #8 0x0000000005435df8 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5435df8)\n #9 0x000000000094557e llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x94557e)\n#10 0x00000000053f3af0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x53f3af0)\n#11 0x000000000094f9ca llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x94f9ca)\n#12 0x000000000094319c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x94319c)\n#13 0x00007a8d0c429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#14 0x00007a8d0c429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#15 0x000000000093add5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x93add5)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```\n",
"author": "TatyanaDoubts",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
114371
|
https://github.com/llvm/llvm-project/issues/114371
|
crash
|
71cfa381ef8c4fe659c67e8b2901d767e10f2aff
| 2024-10-31T07:26:11 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "e7080fd735d02590cdce1bef97a7f64a34145b15",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
16127,
16137
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::vectorizeTree"
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit e7080fd735d02590cdce1bef97a7f64a34145b15
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Thu Oct 31 09:26:53 2024 -0700
[SLP]Extra check if the intruction matked for removal, must be replaced in reduction ops
If the instruction is vectorized and it is a part of the reduced values
gather/buildvector node, it should replaced in reduced operation
instructions before removal properly, to avoid compiler crash.
Fixes #114371
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 268546fe99e1..593964177ad7 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -16127,11 +16127,13 @@ BoUpSLP::vectorizeTree(const ExtraValueToDebugLocsMap &ExternallyUsedValues,
if (IE->Idx != 0 &&
!(VectorizableTree.front()->isGather() &&
!IE->UserTreeIndices.empty() &&
- any_of(IE->UserTreeIndices,
- [&](const EdgeInfo &EI) {
- return EI.UserTE == VectorizableTree.front().get() &&
- EI.EdgeIdx == UINT_MAX;
- })) &&
+ (ValueToGatherNodes.lookup(I).contains(
+ VectorizableTree.front().get()) ||
+ any_of(IE->UserTreeIndices,
+ [&](const EdgeInfo &EI) {
+ return EI.UserTE == VectorizableTree.front().get() &&
+ EI.EdgeIdx == UINT_MAX;
+ }))) &&
!(GatheredLoadsEntriesFirst.has_value() &&
IE->Idx >= *GatheredLoadsEntriesFirst &&
VectorizableTree.front()->isGather() &&
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/external-reduced-value-vectorized.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define i32 @test(ptr %c, i16 %a, i16 %0) {\nentry:\n %tobool = icmp ne i16 %a, 0\n %1 = zext i1 %tobool to i16\n %cmp3 = icmp ugt i16 %0, %1\n %2 = and i1 %tobool, %cmp3\n %tobool.1 = icmp ne i16 %a, 0\n %3 = zext i1 %tobool.1 to i16\n %cmp3.1 = icmp ugt i16 %0, %3\n %4 = and i1 %tobool.1, %cmp3.1\n %5 = select i1 %2, i1 %4, i1 false\n %tobool.2 = icmp ne i16 %a, 0\n %6 = zext i1 %tobool.2 to i16\n %cmp3.2 = icmp ugt i16 %0, %6\n %7 = and i1 %tobool.2, %cmp3.2\n %8 = select i1 %5, i1 %7, i1 false\n %tobool.3 = icmp ne i16 %a, 0\n %9 = zext i1 %tobool.3 to i16\n %cmp3.3 = icmp ugt i16 %a, %9\n %10 = icmp ult i16 %a, -2\n %11 = and i1 %10, %cmp3.3\n %12 = select i1 %8, i1 %11, i1 false\n %13 = zext i1 %12 to i32\n store i32 %13, ptr %c, align 4\n ret i32 0\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "clang crashes on valid code at -O{2,3} on x86_64-linux-gnu: Assertion `(I->use_empty() || all_of(I->uses(), [&](Use &U) { return isDeleted( cast<Instruction>(U.getUser())); })) && \"trying to erase instruction with users.\"' 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/5Tca1zsE8\r\n\r\n```\r\n[507] % clangtk -v\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git fdc78120bde1426b223196bec645b6f27fc60f0e)\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[508] % \r\n[508] % clangtk -O2 small.c\r\nclang-20: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:2748: void llvm::slpvectorizer::BoUpSLP::removeInstructionsAndOperands(llvm::ArrayRef<U*>) [with T = llvm::Instruction]: Assertion `(I->use_empty() || all_of(I->uses(), [&](Use &U) { return isDeleted( cast<Instruction>(U.getUser())); })) && \"trying to erase instruction with users.\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, 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/20241031-clangtk-m64-O3-build-070121/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20241031-clangtk-m64-O3-build-070121/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-2a4e26.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 0x000055e84bc23a6f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4428a6f)\r\n #1 0x000055e84bc21274 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007efe85a5c420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #3 0x00007efe8549300b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #4 0x00007efe85472859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\r\n #5 0x00007efe85472729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #6 0x00007efe85472729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #7 0x00007efe85483fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #8 0x000055e84d68990f void llvm::slpvectorizer::BoUpSLP::removeInstructionsAndOperands<llvm::Instruction>(llvm::ArrayRef<llvm::Instruction*>) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5e8e90f)\r\n #9 0x000055e84d6e6d28 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::SmallDenseSet<llvm::Value*, 4u, llvm::DenseMapInfo<llvm::Value*, void>> const&, llvm::Instruction*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5eebd28)\r\n#10 0x000055e84d6f8d01 (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&) SLPVectorizer.cpp:0:0\r\n#11 0x000055e84d6fbb89 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+0x5f00b89)\r\n#12 0x000055e84d7004ab llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (.constprop.0) SLPVectorizer.cpp:0:0\r\n#13 0x000055e84d704d60 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5f09d60)\r\n#14 0x000055e84d70b5a0 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\r\n#15 0x000055e84d70c273 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5f11273)\r\n#16 0x000055e84d17e016 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+0x5983016)\r\n#17 0x000055e84b5aa8b1 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+0x3daf8b1)\r\n#18 0x000055e84909b826 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+0x18a0826)\r\n#19 0x000055e84b5a921d llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3dae21d)\r\n#20 0x000055e84909a226 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+0x189f226)\r\n#21 0x000055e84b5a8c51 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+0x3dadc51)\r\n#22 0x000055e84bedd2d3 (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#23 0x000055e84bee0aca 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+0x46e5aca)\r\n#24 0x000055e84c5df37c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4de437c)\r\n#25 0x000055e84e4e0fac clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x6ce5fac)\r\n#26 0x000055e84c5df798 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4de4798)\r\n#27 0x000055e84c8a7649 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x50ac649)\r\n#28 0x000055e84c823e7e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5028e7e)\r\n#29 0x000055e84c993f46 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5198f46)\r\n#30 0x000055e848c544f5 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x14594f5)\r\n#31 0x000055e848c4c01a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#32 0x000055e848c4ffd7 clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x1454fd7)\r\n#33 0x000055e848b3a78b main (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x133f78b)\r\n#34 0x00007efe85474083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#35 0x000055e848c4baae _start (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x1450aae)\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 fdc78120bde1426b223196bec645b6f27fc60f0e)\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-8056bb.c\r\nclangtk: note: diagnostic msg: /tmp/small-8056bb.sh\r\nclangtk: note: diagnostic msg: \r\n\r\n********************\r\n[509] % \r\n[509] % cat small.c\r\nshort a;\r\nint b, d;\r\nunsigned short c;\r\nint main() {\r\n b = 0;\r\n for (; b < 5; b++) {\r\n a--;\r\n d |= (3 - (((!a) < 1) < c && a)) & c;\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
}
| null |
137582
|
https://github.com/llvm/llvm-project/issues/137582
|
miscompilation
|
4075a3698a3fdda3a77ce2456e3bfefbc0f0c56e
| 2025-04-28T05:48:58 |
[
"llvm/test/Transforms/CorrelatedValuePropagation"
] |
{
"fix_commit": "830cf36bd4c491ef28d9bba74737e324639bb4cd",
"components": [
"IR",
"LazyValueInfo",
"ValueTracking"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": [
[
7201,
7220
],
[
7287,
7293
]
],
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": [
[
546,
569
],
[
586,
592
]
],
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": [
[
1701,
1707
]
],
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": [
[
585,
590
]
],
"llvm/lib/IR/Instruction.cpp": [
[
532,
539
],
[
554,
559
]
]
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": [
"llvm::isNotCrossLaneOperation",
"llvm::isSafeToSpeculativelyExecuteWithOpcode"
],
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": [
"LazyValueInfoImpl::getValueAtUse"
],
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": [
"isSafeToSpeculativelyExecuteWithVariableReplaced"
],
"llvm/lib/IR/Instruction.cpp": [
"Instruction::dropUBImplyingAttrsAndMetadata",
"Instruction::dropUBImplyingAttrsAndUnknownMetadata",
"Instruction::isExact"
]
}
}
|
commit 830cf36bd4c491ef28d9bba74737e324639bb4cd
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Wed Apr 30 11:53:38 2025 +0800
[LVI][ValueTracking] Take UB-implying attributes into account in `isSafeToSpeculativelyExecute` (#137604)
Closes https://github.com/llvm/llvm-project/issues/137582.
In the original case, LVI uses the edge information in `%entry ->
%if.end` to get a more precise result. However, since the call to `smin`
has an `noundef` return attribute, an immediate UB will be triggered
after optimization.
Currently, `isSafeToSpeculativelyExecuteWithOpcode(%min)` returns true
because
https://github.com/llvm/llvm-project/commit/6a288c1e32351d4be3b7630841af078fa1c3bb8b
only checks whether the function is speculatable. However, it is not
enough in this case.
This patch takes UB-implying attributes into account if
`IgnoreUBImplyingAttrs` is set to false. If it is set to true, the
caller is responsible for correctly propagating UB-implying attributes.
diff --git a/llvm/include/llvm/Analysis/ValueTracking.h b/llvm/include/llvm/Analysis/ValueTracking.h
index f927838c843a..61dbb07e7128 100644
--- a/llvm/include/llvm/Analysis/ValueTracking.h
+++ b/llvm/include/llvm/Analysis/ValueTracking.h
@@ -539,6 +539,12 @@ bool isNotCrossLaneOperation(const Instruction *I);
/// move the instruction as long as the correct dominance relationships for
/// the operands and users hold.
///
+/// If \p UseVariableInfo is true, the information from non-constant operands
+/// will be taken into account.
+///
+/// If \p IgnoreUBImplyingAttrs is true, UB-implying attributes will be ignored.
+/// The caller is responsible for correctly propagating them after hoisting.
+///
/// This method can return true for instructions that read memory;
/// for such instructions, moving them may change the resulting value.
bool isSafeToSpeculativelyExecute(const Instruction *I,
@@ -546,24 +552,28 @@ bool isSafeToSpeculativelyExecute(const Instruction *I,
AssumptionCache *AC = nullptr,
const DominatorTree *DT = nullptr,
const TargetLibraryInfo *TLI = nullptr,
- bool UseVariableInfo = true);
+ bool UseVariableInfo = true,
+ bool IgnoreUBImplyingAttrs = true);
inline bool isSafeToSpeculativelyExecute(const Instruction *I,
BasicBlock::iterator CtxI,
AssumptionCache *AC = nullptr,
const DominatorTree *DT = nullptr,
const TargetLibraryInfo *TLI = nullptr,
- bool UseVariableInfo = true) {
+ bool UseVariableInfo = true,
+ bool IgnoreUBImplyingAttrs = true) {
// Take an iterator, and unwrap it into an Instruction *.
- return isSafeToSpeculativelyExecute(I, &*CtxI, AC, DT, TLI, UseVariableInfo);
+ return isSafeToSpeculativelyExecute(I, &*CtxI, AC, DT, TLI, UseVariableInfo,
+ IgnoreUBImplyingAttrs);
}
/// Don't use information from its non-constant operands. This helper is used
/// when its operands are going to be replaced.
-inline bool
-isSafeToSpeculativelyExecuteWithVariableReplaced(const Instruction *I) {
+inline bool isSafeToSpeculativelyExecuteWithVariableReplaced(
+ const Instruction *I, bool IgnoreUBImplyingAttrs = true) {
return isSafeToSpeculativelyExecute(I, nullptr, nullptr, nullptr, nullptr,
- /*UseVariableInfo=*/false);
+ /*UseVariableInfo=*/false,
+ IgnoreUBImplyingAttrs);
}
/// This returns the same result as isSafeToSpeculativelyExecute if Opcode is
@@ -586,7 +596,8 @@ isSafeToSpeculativelyExecuteWithVariableReplaced(const Instruction *I) {
bool isSafeToSpeculativelyExecuteWithOpcode(
unsigned Opcode, const Instruction *Inst, const Instruction *CtxI = nullptr,
AssumptionCache *AC = nullptr, const DominatorTree *DT = nullptr,
- const TargetLibraryInfo *TLI = nullptr, bool UseVariableInfo = true);
+ const TargetLibraryInfo *TLI = nullptr, bool UseVariableInfo = true,
+ bool IgnoreUBImplyingAttrs = true);
/// Returns true if the result or effects of the given instructions \p I
/// depend values not reachable through the def use graph.
diff --git a/llvm/include/llvm/IR/Instruction.h b/llvm/include/llvm/IR/Instruction.h
index 900384432d75..d8069b2fb02a 100644
--- a/llvm/include/llvm/IR/Instruction.h
+++ b/llvm/include/llvm/IR/Instruction.h
@@ -585,6 +585,10 @@ public:
/// This should be used when speculating instructions.
void dropUBImplyingAttrsAndMetadata();
+ /// Return true if this instruction has UB-implying attributes
+ /// that can cause immediate undefined behavior.
+ bool hasUBImplyingAttrs() const LLVM_READONLY;
+
/// Determine whether the exact flag is set.
bool isExact() const LLVM_READONLY;
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp
index e49e004a48a5..2a562484fc37 100644
--- a/llvm/lib/Analysis/LazyValueInfo.cpp
+++ b/llvm/lib/Analysis/LazyValueInfo.cpp
@@ -1701,7 +1701,8 @@ ValueLatticeElement LazyValueInfoImpl::getValueAtUse(const Use &U) {
// of a cycle, we might end up reasoning about values from different cycle
// iterations (PR60629).
if (!CurrI->hasOneUse() ||
- !isSafeToSpeculativelyExecuteWithVariableReplaced(CurrI))
+ !isSafeToSpeculativelyExecuteWithVariableReplaced(
+ CurrI, /*IgnoreUBImplyingAttrs=*/false))
break;
CurrU = &*CurrI->use_begin();
}
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 1d3f8b7207a6..256e77b40a97 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -7201,20 +7201,19 @@ bool llvm::isNotCrossLaneOperation(const Instruction *I) {
!isa<CallBase, BitCastInst, ExtractElementInst>(I);
}
-bool llvm::isSafeToSpeculativelyExecute(const Instruction *Inst,
- const Instruction *CtxI,
- AssumptionCache *AC,
- const DominatorTree *DT,
- const TargetLibraryInfo *TLI,
- bool UseVariableInfo) {
+bool llvm::isSafeToSpeculativelyExecute(
+ const Instruction *Inst, const Instruction *CtxI, AssumptionCache *AC,
+ const DominatorTree *DT, const TargetLibraryInfo *TLI, bool UseVariableInfo,
+ bool IgnoreUBImplyingAttrs) {
return isSafeToSpeculativelyExecuteWithOpcode(Inst->getOpcode(), Inst, CtxI,
- AC, DT, TLI, UseVariableInfo);
+ AC, DT, TLI, UseVariableInfo,
+ IgnoreUBImplyingAttrs);
}
bool llvm::isSafeToSpeculativelyExecuteWithOpcode(
unsigned Opcode, const Instruction *Inst, const Instruction *CtxI,
AssumptionCache *AC, const DominatorTree *DT, const TargetLibraryInfo *TLI,
- bool UseVariableInfo) {
+ bool UseVariableInfo, bool IgnoreUBImplyingAttrs) {
#ifndef NDEBUG
if (Inst->getOpcode() != Opcode) {
// Check that the operands are actually compatible with the Opcode override.
@@ -7287,7 +7286,11 @@ bool llvm::isSafeToSpeculativelyExecuteWithOpcode(
// The called function could have undefined behavior or side-effects, even
// if marked readnone nounwind.
- return Callee && Callee->isSpeculatable();
+ if (!Callee || !Callee->isSpeculatable())
+ return false;
+ // Since the operands may be changed after hoisting, undefined behavior may
+ // be triggered by some UB-implying attributes.
+ return IgnoreUBImplyingAttrs || !CI->hasUBImplyingAttrs();
}
case Instruction::VAArg:
case Instruction::Alloca:
diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp
index e55a4b41e4d0..6f858110fb8c 100644
--- a/llvm/lib/IR/Instruction.cpp
+++ b/llvm/lib/IR/Instruction.cpp
@@ -532,8 +532,8 @@ void Instruction::dropUBImplyingAttrsAndUnknownMetadata(
if (!CB)
return;
// For call instructions, we also need to drop parameter and return attributes
- // that are can cause UB if the call is moved to a location where the
- // attribute is not valid.
+ // that can cause UB if the call is moved to a location where the attribute is
+ // not valid.
AttributeList AL = CB->getAttributes();
if (AL.isEmpty())
return;
@@ -554,6 +554,20 @@ void Instruction::dropUBImplyingAttrsAndMetadata() {
dropUBImplyingAttrsAndUnknownMetadata(KnownIDs);
}
+bool Instruction::hasUBImplyingAttrs() const {
+ auto *CB = dyn_cast<CallBase>(this);
+ if (!CB)
+ return false;
+ // For call instructions, we also need to check parameter and return
+ // attributes that can cause UB.
+ for (unsigned ArgNo = 0; ArgNo < CB->arg_size(); ArgNo++)
+ if (CB->isPassingUndefUB(ArgNo))
+ return true;
+ return CB->hasRetAttr(Attribute::NoUndef) ||
+ CB->hasRetAttr(Attribute::Dereferenceable) ||
+ CB->hasRetAttr(Attribute::DereferenceableOrNull);
+}
+
bool Instruction::isExact() const {
return cast<PossiblyExactOperator>(this)->isExact();
}
|
[
{
"file": "llvm/test/Transforms/CorrelatedValuePropagation/pr137582.ll",
"commands": [
"opt < %s -passes=correlated-propagation -S"
],
"tests": [
{
"test_name": "test",
"test_body": "define i8 @test(i16 %x) {\nentry:\n %or = or i16 %x, 1\n %conv = trunc i16 %or to i8\n %min = call noundef i8 @llvm.smin.i8(i8 %conv, i8 0)\n %cond = icmp eq i16 %x, 0\n br i1 %cond, label %if.end, label %if.then\n\nif.then: ; preds = %entry\n br label %if.end\n\nif.end: ; preds = %if.then, %entry\n %res = phi i8 [ %min, %entry ], [ 0, %if.then ]\n ret i8 %res\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i8 @llvm.smin.i8(i8, i8) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[CVP] Miscompilation at -O3",
"body": "Reproducer: https://alive2.llvm.org/ce/z/x4KrLX\n```\n\n----------------------------------------\ndefine i8 @func_124(i16 %.promoted) {\nentry:\n %inc20.i = or i16 %.promoted, 1\n %conv.i.i = trunc i16 %inc20.i to i8\n %narrow.i.i.i = smin i8 %conv.i.i, 0\n assume_welldefined i8 %narrow.i.i.i\n %tobool.not.i46 = icmp eq i16 %.promoted, 0\n br i1 %tobool.not.i46, label %func_127.exit, label %land.rhs.i47\n\nland.rhs.i47:\n br label %func_127.exit\n\nfunc_127.exit:\n %conv5.i.i.pn.in = phi i8 [ %narrow.i.i.i, %entry ], [ 0, %land.rhs.i47 ]\n ret i8 %conv5.i.i.pn.in\n}\n=>\ndefine i8 @func_124(i16 %.promoted) {\nentry:\n %inc20.i = or i16 %.promoted, 1\n %conv.i.i = trunc nsw nuw i16 %inc20.i to i8\n %narrow.i.i.i = smin i8 %conv.i.i, 0\n assume_welldefined i8 %narrow.i.i.i\n %tobool.not.i46 = icmp eq i16 %.promoted, 0\n br i1 %tobool.not.i46, label %func_127.exit, label %land.rhs.i47\n\nland.rhs.i47:\n br label %func_127.exit\n\nfunc_127.exit:\n %conv5.i.i.pn.in = phi i8 [ %narrow.i.i.i, %entry ], [ 0, %land.rhs.i47 ]\n %#range_0_%conv5.i.i.pn.in = !range i8 %conv5.i.i.pn.in, i8 128, i8 1\n ret i8 %#range_0_%conv5.i.i.pn.in\n}\nTransformation doesn't verify!\n\nERROR: Source is more defined than target\n\nExample:\ni16 %.promoted = #x0080 (128)\n\nSource:\ni16 %inc20.i = #x0081 (129)\ni8 %conv.i.i = #x81 (129, -127)\ni8 %narrow.i.i.i = #x81 (129, -127)\ni1 %tobool.not.i46 = #x0 (0)\n >> Jump to %land.rhs.i47\n >> Jump to %func_127.exit\ni8 %conv5.i.i.pn.in = #x00 (0)\n\nTarget:\ni16 %inc20.i = #x0081 (129)\ni8 %conv.i.i = poison\ni8 %narrow.i.i.i = poison\nvoid = UB triggered!\n\n\nSummary:\n 0 correct transformations\n 1 incorrect transformations\n 0 failed-to-prove transformations\n 0 Alive2 errors\n```\n",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:analysis",
"generated by fuzzer"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Related code: https://github.com/llvm/llvm-project/blob/60b3a5b7e7db40ec74d3c4839a3fae8b73d98851/llvm/lib/Analysis/LazyValueInfo.cpp#L1694-L1705"
}
]
}
| true |
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
| null |
134115
|
https://github.com/llvm/llvm-project/issues/134115
|
crash
|
6388a7acf7e31fdc7b9c168bd6ce0f4d25c98cd0
| 2025-04-02T17:01:09 |
[
"llvm/test/Transforms/FunctionAttrs"
] |
{
"fix_commit": "0547e84181ff10b24d6363bbfc97f168fe245397",
"components": [
"FunctionAttrs"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": [
[
661,
668
]
],
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": [
"getArgumentAccessInfo"
],
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 0547e84181ff10b24d6363bbfc97f168fe245397
Author: Arthur Eubanks <aeubanks@google.com>
Date: Wed Apr 23 15:56:24 2025 -0700
[FunctionAttrs] Bail if initializes range overflows 64-bit signed int (#137053)
Otherwise the range doesn't make sense since we interpret it as signed.
Fixes #134115
diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
index bbfed2ac2c09..74e8a849803d 100644
--- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -661,8 +661,13 @@ ArgumentAccessInfo getArgumentAccessInfo(const Instruction *I,
auto TypeSize = DL.getTypeStoreSize(Ty);
if (!TypeSize.isScalable() && Offset) {
int64_t Size = TypeSize.getFixedValue();
- return ConstantRange(APInt(64, *Offset, true),
- APInt(64, *Offset + Size, true));
+ APInt Low(64, *Offset, true);
+ bool Overflow;
+ APInt High = Low.sadd_ov(APInt(64, Size, true), Overflow);
+ // Bail if the range overflows signed 64-bit int.
+ if (Overflow)
+ return std::nullopt;
+ return ConstantRange(Low, High);
}
return std::nullopt;
};
|
[
{
"file": "llvm/test/Transforms/FunctionAttrs/initializes.ll",
"commands": [
"opt -passes=function-attrs -S < %s"
],
"tests": [
{
"test_name": "memset_offset_1_size_0",
"test_body": "define void @memset_offset_1_size_0(ptr %dst, ptr %src) {\n %dst.1 = getelementptr inbounds i8, ptr %dst, i64 1\n call void @llvm.memmove.p0.p0.i64(ptr %dst.1, ptr %src, i64 0, i1 false)\n ret void\n}\n\n; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)\ndeclare void @llvm.memmove.p0.p0.i64(ptr writeonly captures(none), ptr readonly captures(none), i64, i1 immarg) #0\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "range_overflows_signed_64_bit_int",
"test_body": "define void @range_overflows_signed_64_bit_int(ptr %arg) {\n %getelementptr = getelementptr i8, ptr %arg, i64 9223372036854775804\n store i32 0, ptr %getelementptr, align 4\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "FunctionAttrs: Assertion `isOrder edRanges(RangesRef)' failed.",
"body": "```\n$ cat /tmp/f.ll\ndefine i32 @f(ptr %arg, ptr %arg2) {\n store ptr %arg, ptr %arg2\n %getelementptr = getelementptr float, ptr %arg, i64 2305843009213693951\n %load = load i32, ptr %getelementptr, align 4\n ret i32 %load\n}\n$ opt -p function-attrs /tmp/f.ll -disable-output\nopt: ../../llvm/include/llvm/IR/ConstantRangeList.h:36: llvm::ConstantRangeList::ConstantRangeList(ArrayRef<ConstantRange>): Assertion `isOrder\nedRanges(RangesRef)' failed.\n```",
"author": "aeubanks",
"labels": [
"ipo",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
107015
|
https://github.com/llvm/llvm-project/issues/107015
|
crash
|
50a02e7c68f964c5d8338369746c849ed8d3bef4
| 2024-09-02T18:45:19 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "954ed05c1001489802ae43d4bea403181570a799",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
[
8393,
8398
]
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": [
[
174,
184
]
],
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"VPRecipeBuilder::tryToWiden"
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": [
"getVPValueOrAddLiveIn"
],
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 954ed05c1001489802ae43d4bea403181570a799
Author: Florian Hahn <flo@fhahn.com>
Date: Mon Sep 2 21:25:30 2024 +0100
[VPlan] Simplify MUL operands at recipe construction.
This moves the logic to create simplified operands using SCEV to MUL
recipe creation. This is needed to match the behavior of the legacy's cost
model. TODOs are to extend to other opcodes and move to a transform.
Note that this also restricts the number of SCEV simplifications we
apply to more precisely match the cases handled by the legacy cost
model.
Fixes https://github.com/llvm/llvm-project/issues/107015.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index a8722db654f5..a64848c1fdce 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -8393,6 +8393,20 @@ VPWidenRecipe *VPRecipeBuilder::tryToWiden(Instruction *I,
case Instruction::Sub:
case Instruction::Xor:
case Instruction::Freeze:
+ if (I->getOpcode() == Instruction::Mul) {
+ // Simplify operands of multiplications using SCEV. This is needed at the
+ // moment to match the behavior of the legacy cost-model.
+ // TODO: Generalize to any opcode and move to VPlan transformation.
+ SmallVector<VPValue *> NewOps(Operands);
+ ScalarEvolution &SE = *PSE.getSE();
+ for (unsigned I = 0; I < Operands.size(); ++I) {
+ Value *V = NewOps[I]->getUnderlyingValue();
+ if (!isa<Constant>(V) && SE.isSCEVable(V->getType()))
+ if (auto *C = dyn_cast<SCEVConstant>(PSE.getSE()->getSCEV(V)))
+ NewOps[I] = Plan.getOrAddLiveIn(C->getValue());
+ }
+ return new VPWidenRecipe(*I, make_range(NewOps.begin(), NewOps.end()));
+ }
return new VPWidenRecipe(*I, make_range(Operands.begin(), Operands.end()));
};
}
diff --git a/llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h b/llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h
index 0fbdeeddaf4a..25b8bf3e089e 100644
--- a/llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h
+++ b/llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h
@@ -174,11 +174,6 @@ public:
if (auto *R = Ingredient2Recipe.lookup(I))
return R->getVPSingleValue();
}
- ScalarEvolution &SE = *PSE.getSE();
- if (!isa<Constant>(V) && SE.isSCEVable(V->getType()))
- if (auto *C = dyn_cast<SCEVConstant>(PSE.getSE()->getSCEV(V)))
- return Plan.getOrAddLiveIn(C->getValue());
-
return Plan.getOrAddLiveIn(V);
}
};
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/mul-simplification.ll",
"commands": [
"opt -p loop-vectorize -S %s"
],
"tests": [
{
"test_name": "mul_select_operand_known_1_via_scev",
"test_body": "target triple = \"arm64-apple-macosx\"\n\ndefine i64 @mul_select_operand_known_1_via_scev() {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %red = phi i64 [ 12, %entry ], [ %red.next, %loop ]\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %0 = and i32 %iv, 1\n %cmp1.i = icmp eq i32 %0, 0\n %narrow.i = select i1 %cmp1.i, i32 1, i32 %iv\n %mul = zext nneg i32 %narrow.i to i64\n %red.next = mul nsw i64 %red, %mul\n %iv.next = add nuw nsw i32 %iv, 1\n %ec = icmp eq i32 %iv, 1\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n %res = phi i64 [ %red.next, %loop ]\n ret i64 %res\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[clang] Crash with assertion failed in Vectorize",
"body": "The compiler crashed with -O2 in this code:\r\n\r\n```c\r\n#include<stdint.h>\r\nstatic uint8_t b[][1] = {127};\r\nlong a(int c, int e) {\r\n long d;\r\n for (; c <= e; c++)\r\n if (c % 2 == 0)\r\n ;\r\n else\r\n d *= c;\r\n return d;\r\n}\r\nint64_t f();\r\nint16_t g() {\r\n int32_t h = 1653000360;\r\n f(a(h - 1653000360, b[0][0] - 126));\r\n uint8_t *i[] = {b, b};\r\n}\r\n```\r\n\r\nThe crash is:\r\n```\r\nclang: /root/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7369: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\n```\r\n\r\nThe details can be found here: https://godbolt.org/z/eeWW6raPb",
"author": "cardigan1008",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
| null |
140442
|
https://github.com/llvm/llvm-project/issues/140442
|
crash
|
b18ebd17b82db0bdf5bb8cae59c3208288fbef93
| 2025-05-18T08:07:12 |
[
"llvm/test/Transforms/LoopUnroll"
] |
{
"fix_commit": "7e14161f49b32387988cf9d937bbfaa27d0fbdd5",
"components": [
"LoopPeel"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": [
[
1214,
1220
]
],
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": [
"llvm::peelLoop"
],
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 7e14161f49b32387988cf9d937bbfaa27d0fbdd5
Author: Florian Hahn <flo@fhahn.com>
Date: Sun May 18 10:17:20 2025 +0100
[LoopPeel] Handle constants when updating exit values when peeling last.
Account for constant values when updating exit values after peeling an
iteration from the end. This can happen if the inner loop gets unrolled
and simplified.
Fixes https://github.com/llvm/llvm-project/issues/140442.
diff --git a/llvm/lib/Transforms/Utils/LoopPeel.cpp b/llvm/lib/Transforms/Utils/LoopPeel.cpp
index c5c637ab6e20..646354bba9df 100644
--- a/llvm/lib/Transforms/Utils/LoopPeel.cpp
+++ b/llvm/lib/Transforms/Utils/LoopPeel.cpp
@@ -1214,7 +1214,7 @@ bool llvm::peelLoop(Loop *L, unsigned PeelCount, bool PeelLast, LoopInfo *LI,
// Now adjust users of the original exit values by replacing them with the
// exit value from the peeled iteration.
for (const auto &[P, E] : ExitValues)
- P->replaceAllUsesWith(VMap.lookup(E));
+ P->replaceAllUsesWith(isa<Constant>(E) ? E : &*VMap.lookup(E));
formLCSSA(*L, DT, LI, SE);
} else {
// Now adjust the phi nodes in the loop header to get their initial values
|
[
{
"file": "llvm/test/Transforms/LoopUnroll/unroll-and-peel-last-iteration.ll",
"commands": [
"opt -p loop-unroll -S %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n; Test case for https://github.com/llvm/llvm-project/issues/140442.\ndefine i32 @peel_last_iter_of_outer_lcssa_phi_with_constant_after_unrolling_inner() {\n;\nentry:\n br label %outer.header\n\nouter.header:\n %iv = phi i16 [ 0, %entry ], [ %iv.next, %outer.latch ]\n %0 = icmp eq i16 %iv, 999\n br label %inner.header\n\ninner.header:\n %inner.iv = phi i32 [ 0, %outer.header ], [ %inner.iv.next, %inner.latch ]\n %1 = add i32 %inner.iv, 1\n br i1 %0, label %then, label %inner.latch\n\nthen:\n call void @foo(i32 %inner.iv)\n br label %inner.latch\n\ninner.latch:\n %inner.iv.next = add i32 %inner.iv, 1\n %inner.ec = icmp eq i32 %inner.iv.next, 1\n br i1 %inner.ec, label %outer.latch, label %inner.header\n\nouter.latch:\n %iv.next = add i16 %iv, 1\n %ec = icmp eq i16 %iv.next, 1000\n br i1 %ec, label %exit, label %outer.header\n\nexit:\n ret i32 %1\n}\n\ndeclare void @foo(i32)\n;.\n;.",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[LoopUnroll] Assertion `New && \"Value::replaceAllUsesWith(<null>) is invalid!\"' failed.",
"body": "Reproducer: https://godbolt.org/z/ahxqn68Mn\n```\n; bin/opt -passes=\"loop-unroll<O3>\" reduced.ll -S\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i32 @main() {\nentry:\n br label %for.cond52.preheader.i.i\n\nfor.cond52.preheader.i.i: ; preds = %for.end213.i.i, %entry\n %p_158.addr.0380.i.i1 = phi i16 [ 0, %entry ], [ %inc215.i.i, %for.end213.i.i ]\n %0 = icmp eq i16 %p_158.addr.0380.i.i1, -1\n br label %for.body136.i.i\n\nfor.body136.i.i: ; preds = %for.end54.preheader.peel.i.i.i, %for.cond52.preheader.i.i\n %1 = add i32 0, 0\n br i1 %0, label %for.end54.preheader.peel.i.i.i, label %for.end54.preheader.peel.i.i.i\n\nfor.end54.preheader.peel.i.i.i: ; preds = %for.body136.i.i, %for.body136.i.i\n br i1 true, label %for.end213.i.i, label %for.body136.i.i\n\nfor.end213.i.i: ; preds = %for.end54.preheader.peel.i.i.i\n %inc215.i.i = add i16 %p_158.addr.0380.i.i1, 1\n %exitcond387.not.i.i = icmp eq i16 %inc215.i.i, 0\n br i1 %exitcond387.not.i.i, label %for.end141.peel.i.i, label %for.cond52.preheader.i.i\n\nfor.end141.peel.i.i: ; preds = %for.end213.i.i\n ret i32 %1\n}\n```\n```\nopt: /root/llvm-project/llvm/lib/IR/Value.cpp:516: void llvm::Value::doRAUW(llvm::Value*, llvm::Value::ReplaceMetadataUses): Assertion `New && \"Value::replaceAllUsesWith(<null>) is invalid!\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=loop-unroll<O3> <source>\n1.\tRunning pass \"function(loop-unroll<O3>)\" on module \"<source>\"\n2.\tRunning pass \"loop-unroll<O3>\" on function \"main\"\n #0 0x00000000055c5a48 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x55c5a48)\n #1 0x00000000055c33d4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x000078c7a1842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x000078c7a18969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x000078c7a1842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x000078c7a18287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x000078c7a182871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x000078c7a1839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x00000000053f248a (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x53f248a)\n #9 0x0000000004830404 llvm::peelLoop(llvm::Loop*, unsigned int, bool, llvm::LoopInfo*, llvm::ScalarEvolution*, llvm::DominatorTree&, llvm::AssumptionCache*, bool, llvm::ValueMap<llvm::Value const*, llvm::WeakTrackingVH, llvm::ValueMapConfig<llvm::Value const*, llvm::sys::SmartMutex<false>>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4830404)\n#10 0x0000000004424eb9 tryToUnrollLoop(llvm::Loop*, llvm::DominatorTree&, llvm::LoopInfo*, llvm::ScalarEvolution&, llvm::TargetTransformInfo const&, llvm::AssumptionCache&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::ProfileSummaryInfo*, bool, int, bool, bool, bool, std::optional<unsigned int>, std::optional<unsigned int>, std::optional<bool>, std::optional<bool>, std::optional<bool>, std::optional<bool>, std::optional<bool>, std::optional<unsigned int>, llvm::AAResults*) LoopUnrollPass.cpp:0:0\n#11 0x0000000004427b27 llvm::LoopUnrollPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4427b27)\n#12 0x0000000002d6a54e llvm::detail::PassModel<llvm::Function, llvm::LoopUnrollPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2d6a54e)\n#13 0x00000000053bcd00 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x53bcd00)\n#14 0x0000000000e8bbee llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe8bbee)\n#15 0x00000000053bd213 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x53bd213)\n#16 0x0000000000e8aa3e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe8aa3e)\n#17 0x00000000053bae30 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x53bae30)\n#18 0x000000000094c2aa llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x94c2aa)\n#19 0x000000000093fa7c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x93fa7c)\n#20 0x000078c7a1829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#21 0x000078c7a1829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#22 0x0000000000937695 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x937695)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```\nllvm version: 3ccb15d6caf57f2a866d496ada2fb52d14b179d2",
"author": "dtcxzyw",
"labels": [
"crash-on-valid",
"llvm:transforms",
"generated by fuzzer"
],
"comments": [
{
"author": "fhahn",
"body": "Probably related to 3fcfce4c5e5fd1c3072e8db1d692c93459e8cd74, taking a look"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
98435
|
https://github.com/llvm/llvm-project/issues/98435
|
miscompilation
|
0e124537aabea0d18e030226a3ca4c6f494c1322
| 2024-07-11T06:06:08 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "9304af3927caecdb43d3a9b5d16c6a5b7a6b5594",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": [
[
1735,
1751
]
],
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": [
"InstCombinerImpl::SimplifyDemandedVectorElts"
],
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 9304af3927caecdb43d3a9b5d16c6a5b7a6b5594
Author: Jorge Botto <23462171+jf-botto@users.noreply.github.com>
Date: Fri Aug 9 11:52:56 2024 +0100
[InstCombine] Fixing wrong select folding in vectors with undef elements (#102244)
This PR fixes https://github.com/llvm/llvm-project/issues/98435.
`SimplifyDemandedVectorElts` mishandles the undef by assuming that
!isNullValue() means the condition is true.
By preventing any value that we're not certain equals 1 or 0, it avoids
having to make any particular choice by not demanding bits from a
particular branch with potentially picking a wrong value.
Proof: https://alive2.llvm.org/ce/z/r8CmEu
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index c494fec84c1e..153d8c238ed4 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -1735,17 +1735,12 @@ Value *InstCombinerImpl::SimplifyDemandedVectorElts(Value *V,
APInt DemandedLHS(DemandedElts), DemandedRHS(DemandedElts);
if (auto *CV = dyn_cast<ConstantVector>(Sel->getCondition())) {
for (unsigned i = 0; i < VWidth; i++) {
- // isNullValue() always returns false when called on a ConstantExpr.
- // Skip constant expressions to avoid propagating incorrect information.
Constant *CElt = CV->getAggregateElement(i);
- if (isa<ConstantExpr>(CElt))
- continue;
- // TODO: If a select condition element is undef, we can demand from
- // either side. If one side is known undef, choosing that side would
- // propagate undef.
+
+ // isNullValue() always returns false when called on a ConstantExpr.
if (CElt->isNullValue())
DemandedLHS.clearBit(i);
- else
+ else if (CElt->isOneValue())
DemandedRHS.clearBit(i);
}
}
|
[
{
"file": "llvm/test/Transforms/InstCombine/pr98435.ll",
"commands": [
"opt -S -passes=instcombine < %s 2>&1"
],
"tests": [
{
"test_name": "pr98435",
"test_body": "define <2 x i1> @pr98435(<2 x i1> %val) {\n %val1 = select <2 x i1> <i1 undef, i1 true>, <2 x i1> splat (i1 true), <2 x i1> %val\n ret <2 x i1> %val1\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Wrong select folding for undef conditions by InstCombine",
"body": "https://github.com/llvm/llvm-project/blob/7eae9bb856135136cddc4208a2b1546e9db44c9c/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp#L3582-L3585\r\n\r\nAlive2 report: https://alive2.llvm.org/ce/z/Qtu72J\r\n\r\n\r\n```ll\r\n----------------------------------------\r\ndefine <2 x i1> @fun0(<2 x i1> %val0, <2 x i1> %val1) {\r\n#0:\r\n %val2 = select <2 x i1> %val0, <2 x i1> %val0, <2 x i1> %val0\r\n %val3 = select <2 x i1> { undef, 1 }, <2 x i1> { 1, 1 }, <2 x i1> %val2\r\n ret <2 x i1> %val3\r\n}\r\n=>\r\ndefine <2 x i1> @fun0(<2 x i1> %val0, <2 x i1> %val1) {\r\n#0:\r\n ret <2 x i1> { poison, 1 }\r\n}\r\nTransformation doesn't verify!\r\n\r\nERROR: Target is more poisonous than source\r\n\r\nExample:\r\n<2 x i1> %val0 = < #x0 (0), #x0 (0) >\r\n<2 x i1> %val1 = < #x0 (0), #x0 (0) >\r\n\r\nSource:\r\n<2 x i1> %val2 = < #x0 (0), #x0 (0) >\r\n<2 x i1> %val3 = < #x0 (0)\t[based on undef value], #x1 (1) >\r\n\r\nTarget:\r\nSource value: < #x0 (0), #x1 (1) >\r\nTarget value: < poison, #x1 (1) >\r\n\r\nSummary:\r\n 0 correct transformations\r\n 1 incorrect transformations\r\n 0 failed-to-prove transformations\r\n 0 Alive2 errors\r\n```",
"author": "bongjunj",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": [
{
"author": "jf-botto",
"body": "Would this issue be to fix InstCombine to not try to optimise it or get InstCombine to pick `<2 x i1> { 1, 1 }` because `undef` let's it pick either values and picking a constant vector is better than picking a variable?"
},
{
"author": "nikic",
"body": "The problematic step seems to be this one: https://alive2.llvm.org/ce/z/C2waWU\r\n\r\nI don't think the quoted code is responsible for this, as it is guarded by `!isa<Constant>(CondVal)`."
},
{
"author": "jf-botto",
"body": "I think the problem is with how `SimplifyDemandedVectorElts` handles the undef: https://github.com/llvm/llvm-project/blob/af80d3a248101d6f5d9d5e229c7899136b8ce0b8/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp#L1721-L1760"
},
{
"author": "nikic",
"body": "@jf-botto Agree. It assumes that !isNullValue() means \"is true\", which is not the case."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
144212
|
https://github.com/llvm/llvm-project/issues/144212
|
crash
|
a383b1a95b63cf120b3dea554c2d66ccfaee066b
| 2025-06-14T07:41:27 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "30b16ec3415e7ddb597d096f818d011b1b4e6a63",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
[
1141,
1146
]
],
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
"simplifyRecipe"
],
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 30b16ec3415e7ddb597d096f818d011b1b4e6a63
Author: Florian Hahn <flo@fhahn.com>
Date: Mon Jun 16 22:54:25 2025 +0100
[VPlan] Simplify trivial VPFirstOrderRecurrencePHI recipes.
VPFirstOrderRecurrencePHIRecipes where the incoming values are the same
can be simplified and removed.
Fixes https://github.com/llvm/llvm-project/issues/144212.
The new test is added together with other related tests from
first-order-recurrence.ll
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 44a72755b9cf..05a0e15f9a19 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -1141,6 +1141,12 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
return;
}
+ if (auto *Phi = dyn_cast<VPFirstOrderRecurrencePHIRecipe>(Def)) {
+ if (Phi->getOperand(0) == Phi->getOperand(1))
+ Def->replaceAllUsesWith(Phi->getOperand(0));
+ return;
+ }
+
// Some simplifications can only be applied after unrolling. Perform them
// below.
if (!Plan->isUnrolled())
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/first-order-recurrence-dead-instructions.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=2 -S %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n; Test case for https://github.com/llvm/llvm-project/issues/144212.\ndefine i8 @recurrence_phi_with_same_incoming_values_after_simplifications(i8 %for.start, ptr %dst) {\n;\nentry:\n br label %loop\n\nloop:\n %iv = phi i32 [ 1, %entry ], [ %iv.next, %loop ]\n %for = phi i8 [ %for.start, %entry ], [ %for.next, %loop ]\n %for.next = and i8 %for.start, -1\n %iv.next = add i32 %iv, 1\n %gep.dst = getelementptr inbounds i8, ptr %dst, i32 %iv\n store i8 %for, ptr %gep.dst\n %ec = icmp eq i32 %iv.next, 0\n br i1 %ec, label %exit, label %loop\n\nexit:\n ret i8 %for.next\n}\n\n; %vec.dead will be marked as dead instruction in the vector loop and no recipe\n; will be created for it. Make sure a valid sink target is used.\ndefine i32 @sink_after_dead_inst(ptr %A.ptr) {\n;\nentry:\n br label %loop\n\nloop:\n %iv = phi i16 [ 0, %entry ], [ %iv.next, %loop ]\n %for = phi i32 [ 0, %entry ], [ %for.prev, %loop ]\n %cmp = icmp eq i32 %for, 15\n %C = icmp eq i1 %cmp, true\n %vec.dead = and i1 %C, 1\n %iv.next = add i16 %iv, 1\n %B1 = or i16 %iv.next, %iv.next\n %B3 = and i1 %cmp, %C\n %for.prev = zext i16 %B1 to i32\n\n %ext = zext i1 %B3 to i32\n %A.gep = getelementptr i32, ptr %A.ptr, i16 %iv\n store i32 0, ptr %A.gep\n br i1 %vec.dead, label %for.end, label %loop\n\nfor.end:\n ret i32 %for\n}\n\n; Dead instructions, like the exit condition are not part of the actual VPlan\n; and do not need to be sunk. PR44634.\ndefine void @sink_dead_inst(ptr %a) {\n;\nentry:\n br label %for.cond\n\nfor.cond:\n %iv = phi i16 [ -27, %entry ], [ %iv.next, %for.cond ]\n %rec.1 = phi i16 [ 0, %entry ], [ %rec.1.prev, %for.cond ]\n %rec.2 = phi i32 [ -27, %entry ], [ %rec.2.prev, %for.cond ]\n %use.rec.1 = sub i16 %rec.1, 10\n %cmp = icmp eq i32 %rec.2, 15\n %iv.next = add i16 %iv, 1\n %rec.2.prev = zext i16 %iv.next to i32\n %rec.1.prev = add i16 %iv.next, 5\n %gep = getelementptr i16, ptr %a, i16 %iv\n store i16 %use.rec.1, ptr %gep\n br i1 %cmp, label %for.end, label %for.cond\n\nfor.end:\n ret void\n}\n\n; %rec.1 only has %use.rec.1 as use, which can be removed. This enables %rec.1\n; to be removed also.\ndefine void @unused_recurrence(ptr %a) {\n;\nentry:\n br label %for.cond\n\nfor.cond:\n %iv = phi i16 [ -27, %entry ], [ %iv.next, %for.cond ]\n %rec.1 = phi i16 [ 0, %entry ], [ %rec.1.prev, %for.cond ]\n %use.rec.1 = sub i16 %rec.1, 10\n %iv.next= add i16 %iv, 1\n %rec.1.prev = add i16 %iv.next, 5\n %cmp = icmp eq i16 %iv, 1000\n br i1 %cmp, label %for.end, label %for.cond\n\nfor.end:\n ret void\n}",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/first-order-recurrence.ll",
"commands": [
"opt < %s -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=2 -force-widen-divrem-via-safe-divisor=0 -S",
"opt < %s -passes=loop-vectorize -force-vector-width=1 -force-vector-interleave=2 -force-widen-divrem-via-safe-divisor=0 -S",
"opt < %s -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -force-widen-divrem-via-safe-divisor=0 -S"
],
"tests": [
{
"test_name": "recurence_uniform_load",
"test_body": "target datalayout = \"e-m:e-i64:64-i128:128-n32:64-S128\"\n\ndefine i32 @recurence_uniform_load(ptr %src, ptr noalias %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\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, 1\n br i1 %icmp, label %loop, label %exit\n\nexit: ; preds = %loop\n ret i32 0\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "sink_into_replication_region",
"test_body": "target datalayout = \"e-m:e-i64:64-i128:128-n32:64-S128\"\n\ndefine i32 @sink_into_replication_region(i32 %y, ptr %dst) {\nbb:\n br label %bb2\n\nbb1: ; preds = %bb2\n %var = phi i32 [ %var6, %bb2 ]\n ret i32 %var\n\nbb2: ; preds = %bb2, %bb\n %var3 = phi i32 [ %var8, %bb2 ], [ %y, %bb ]\n %var4 = phi i32 [ %var7, %bb2 ], [ 0, %bb ]\n %var5 = phi i32 [ %var6, %bb2 ], [ 0, %bb ]\n %var6 = add i32 %var5, %var4\n %var7 = udiv i32 219220132, %var3\n %var8 = add nsw i32 %var3, -1\n store i32 %var4, ptr %dst, align 4\n %var9 = icmp slt i32 %var3, 2\n br i1 %var9, label %bb1, label %bb2, !prof !0\n}\n\n!0 = !{!\"branch_weights\", i32 1, i32 1}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[LoopVectorize] Assertion failure: Instruction does not dominate all uses!",
"body": "Reproducer: https://godbolt.org/z/WqTM1vavE\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 i8 @test(ptr %p) {\nentry:\n %.promoted835.i = load i8, ptr %p, align 1\n br label %for.inc346.i\n\nfor.inc346.i: ; preds = %for.inc346.i, %entry\n %storemerge827.i = phi i32 [ 1, %entry ], [ %inc347.i, %for.inc346.i ]\n %conv267822825.i = phi i8 [ %.promoted835.i, %entry ], [ %conv267.i, %for.inc346.i ]\n %conv267.i = and i8 %.promoted835.i, -1\n %inc347.i = add i32 %storemerge827.i, 1\n %exitcond.not.i217 = icmp eq i32 %inc347.i, 0\n br i1 %exitcond.not.i217, label %cleanup636.thread812.i, label %for.inc346.i\n\ncleanup636.thread812.i: ; preds = %for.inc346.i\n ret i8 %conv267.i\n}\n```\n```\nInstruction does not dominate all uses!\n %broadcast.splat2 = shufflevector <16 x i8> %broadcast.splatinsert1, <16 x i8> poison, <16 x i32> zeroinitializer\n %vector.recur = phi <16 x i8> [ %vector.recur.init, %vector.ph ], [ %broadcast.splat2, %vector.body ]\nopt: /root/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10329: bool llvm::LoopVectorizePass::processLoop(llvm::Loop*): Assertion `!verifyFunction(*L->getHeader()->getParent(), &dbgs())' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=loop-vectorize <source>\n1.\tRunning pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"<source>\"\n2.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"test\"\n #0 0x000000000563b448 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x563b448)\n #1 0x0000000005638dd4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x000072139da42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x000072139da969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x000072139da42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x000072139da287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x000072139da2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x000072139da39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x000000000348514a llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x348514a)\n #9 0x0000000003486e90 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3486e90)\n#10 0x00000000034874e3 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x34874e3)\n#11 0x0000000002da157e 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+0x2da157e)\n#12 0x000000000542c281 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x542c281)\n#13 0x0000000000ea33fe 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+0xea33fe)\n#14 0x000000000542c763 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x542c763)\n#15 0x0000000000ea224e 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+0xea224e)\n#16 0x000000000542a331 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x542a331)\n#17 0x000000000095988a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x95988a)\n#18 0x000000000094d05c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x94d05c)\n#19 0x000072139da29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#20 0x000072139da29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#21 0x0000000000944c95 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x944c95)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```\ncc @fhahn ",
"author": "dtcxzyw",
"labels": [
"vectorizers",
"crash-on-valid"
],
"comments": [
{
"author": "fhahn",
"body": "Taking a look. I assume this is coming from a larger reproducer? Looks like there are missed scalar folding opportunities."
},
{
"author": "lukel97",
"body": "Bisected back to 5f39be591714eba1be413e2b3ed6fc152a15bb8e"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
113520
|
https://github.com/llvm/llvm-project/issues/113520
|
miscompilation
|
907c13638819b36ecc5154775217068b1a1f4cfc
| 2024-10-24T04:03:39 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "e914421d7fbf22059ea2180233add0c914ec80f0",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
12068,
12075
],
[
15784,
15791
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::getTreeCost",
"BoUpSLP::vectorizeTree"
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit e914421d7fbf22059ea2180233add0c914ec80f0
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Thu Oct 24 08:57:07 2024 -0700
[SLP]Do correct signedness analysis for externally used scalars
If the scalars is used externally is in the root node, it may have
incorrect signedness info because of the conflict with the demanded bits
analysis. Need to perform exact signedness analysis and compute it
rather than rely on the precomputed value, which might be incorrect for
alternate zext/sext nodes.
Fixes #113520
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 012d85353f08..2afd02dae3a8 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -12068,8 +12068,9 @@ InstructionCost BoUpSLP::getTreeCost(ArrayRef<Value *> VectorizedVals) {
auto It = MinBWs.find(Entry);
if (It != MinBWs.end()) {
auto *MinTy = IntegerType::get(F->getContext(), It->second.first);
- unsigned Extend =
- It->second.second ? Instruction::SExt : Instruction::ZExt;
+ unsigned Extend = isKnownNonNegative(EU.Scalar, SimplifyQuery(*DL))
+ ? Instruction::ZExt
+ : Instruction::SExt;
VecTy = getWidenedType(MinTy, BundleWidth);
ExtraCost = TTI->getExtractWithExtendCost(Extend, EU.Scalar->getType(),
VecTy, EU.Lane);
@@ -15784,8 +15785,9 @@ BoUpSLP::vectorizeTree(const ExtraValueToDebugLocsMap &ExternallyUsedValues,
// to the larger type.
ExV = Ex;
if (Scalar->getType() != Ex->getType())
- ExV = Builder.CreateIntCast(Ex, Scalar->getType(),
- MinBWs.find(E)->second.second);
+ ExV = Builder.CreateIntCast(
+ Ex, Scalar->getType(),
+ !isKnownNonNegative(Scalar, SimplifyQuery(*DL)));
auto *I = dyn_cast<Instruction>(Ex);
ScalarToEEs[Scalar].try_emplace(I ? I->getParent()
: &F->getEntryBlock(),
|
[
{
"file": "<issue>",
"commands": [
"opt -S --passes=slp-vectorizer < %s"
],
"tests": [
{
"test_name": "add3_i96",
"test_body": "@0 = external global i1\n\ndefine <3 x i32> @add3_i96.2(<3 x i32> %0, <3 x i32> %1) {\n %4 = extractelement <3 x i32> %0, i64 0\n %5 = sext i32 %4 to i64\n %6 = extractelement <3 x i32> %1, i64 0\n %7 = zext i32 %6 to i64\n %8 = add nuw nsw i64 %7, %5\n %9 = extractelement <3 x i32> %0, i64 1\n %10 = zext i32 %9 to i64\n %11 = extractelement <3 x i32> %1, i64 1\n %12 = zext i32 %11 to i64\n %13 = add nuw nsw i64 %12, %10\n %14 = lshr i64 %8, 32\n %15 = add nuw nsw i64 %13, %14\n %16 = extractelement <3 x i32> %0, i64 2\n %17 = extractelement <3 x i32> %1, i64 2\n %18 = add i32 %17, %16\n %19 = or i64 %15, 32\n %20 = trunc i64 %19 to i32\n %21 = add i32 %18, %17\n %22 = trunc i64 %8 to i32\n %23 = insertelement <3 x i32> %1, i32 %22, i32 0\n ret <3 x i32> %23\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "`slp-vectorizer` miscompilation",
"body": "Alive2 report: https://alive2.llvm.org/ce/z/FmxNvP\r\n\r\n```llvm\r\n----------------------------------------\r\ndefine <3 x i32> @add3_i96.2(<3 x i32> %#0, <3 x i32> %#1) {\r\n#2:\r\n %#3 = extractelement <3 x i32> %#0, i64 0\r\n %#4 = sext i32 %#3 to i64\r\n %#5 = extractelement <3 x i32> %#1, i64 0\r\n %#6 = zext i32 %#5 to i64\r\n %#7 = add nsw nuw i64 %#6, %#4\r\n %#21 = trunc i64 %#7 to i32\r\n %#22 = insertelement <3 x i32> %#1, i32 %#21, i32 0\r\n ret <3 x i32> %#22\r\n}\r\n=>\r\ndefine <3 x i32> @add3_i96.2(<3 x i32> %#0, <3 x i32> %#1) {\r\n#2:\r\n %#3 = shufflevector <3 x i32> %#1, <3 x i32> %#0, 0, 3\r\n %#4 = extractelement <2 x i32> %#3, i32 0\r\n %#5 = sext i32 %#4 to i64\r\n %#6 = extractelement <2 x i32> %#3, i32 1\r\n %#7 = sext i32 %#6 to i64\r\n %#8 = add nsw nuw i64 %#5, %#7\r\n %#22 = trunc i64 %#8 to i32\r\n %#23 = insertelement <3 x i32> %#1, i32 %#22, i32 0\r\n ret <3 x i32> %#23\r\n}\r\nTransformation doesn't verify!\r\n\r\nERROR: Target is more poisonous than source\r\n\r\nExample:\r\n<3 x i32> %#0 = < #x00000008 (8), #x00000000 (0), #x00000000 (0) >\r\n<3 x i32> %#1 = < #xfffffff9 (4294967289, -7), #x00000000 (0), #x00000000 (0) >\r\n\r\nSource:\r\ni32 %#3 = #x00000008 (8)\r\ni64 %#4 = #x0000000000000008 (8)\r\ni32 %#5 = #xfffffff9 (4294967289, -7)\r\ni64 %#6 = #x00000000fffffff9 (4294967289)\r\ni64 %#7 = #x0000000100000001 (4294967297)\r\ni32 %#21 = #x00000001 (1)\r\n<3 x i32> %#22 = < #x00000001 (1), #x00000000 (0), #x00000000 (0) >\r\n\r\nTarget:\r\n<2 x i32> %#3 = < #xfffffff9 (4294967289, -7), #x00000008 (8) >\r\ni32 %#4 = #xfffffff9 (4294967289, -7)\r\ni64 %#5 = #xfffffffffffffff9 (18446744073709551609, -7)\r\ni32 %#6 = #x00000008 (8)\r\ni64 %#7 = #x0000000000000008 (8)\r\ni64 %#8 = poison\r\ni32 %#22 = poison\r\n<3 x i32> %#23 = < poison, #x00000000 (0), #x00000000 (0) >\r\nSource value: < #x00000001 (1), #x00000000 (0), #x00000000 (0) >\r\nTarget value: < poison, #x00000000 (0), #x00000000 (0) >\r\n\r\nSummary:\r\n 0 correct transformations\r\n 1 incorrect transformations\r\n 0 failed-to-prove transformations\r\n 0 Alive2 errors\r\n```",
"author": "bongjunj",
"labels": [
"miscompilation",
"llvm:SLPVectorizer"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
93298
|
https://github.com/llvm/llvm-project/issues/93298
|
crash
|
f31b197d9df141effd439de8be51ce24f3e8f200
| 2024-05-24T12:01:44 |
[
"llvm/test/Transforms/DeadStoreElimination"
] |
{
"fix_commit": "243ffbdf8b25285d04ee4393e86094312cb7c64f",
"components": [
"DeadStoreElimination"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": [
[
2109,
2118
]
],
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": [
"eliminateRedundantStoresOfExistingValues"
],
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 243ffbdf8b25285d04ee4393e86094312cb7c64f
Author: eaeltsin <109593613+eaeltsin@users.noreply.github.com>
Date: Mon May 27 09:26:44 2024 +0200
[DSE] Check write location in IsRedundantStore (#93400)
Fix https://github.com/llvm/llvm-project/issues/93298.
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index ed4212d29cef..172cce2cfa38 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -2109,10 +2109,12 @@ struct DSEState {
if (auto *MemSetI = dyn_cast<MemSetInst>(UpperInst)) {
if (auto *SI = dyn_cast<StoreInst>(DefInst)) {
// MemSetInst must have a write location.
- MemoryLocation UpperLoc = *getLocForWrite(UpperInst);
+ auto UpperLoc = getLocForWrite(UpperInst);
+ if (!UpperLoc)
+ return false;
int64_t InstWriteOffset = 0;
int64_t DepWriteOffset = 0;
- auto OR = isOverwrite(UpperInst, DefInst, UpperLoc, *MaybeDefLoc,
+ auto OR = isOverwrite(UpperInst, DefInst, *UpperLoc, *MaybeDefLoc,
InstWriteOffset, DepWriteOffset);
Value *StoredByte = isBytewiseValue(SI->getValueOperand(), DL);
return StoredByte && StoredByte == MemSetI->getOperand(1) &&
|
[
{
"file": "llvm/test/Transforms/DeadStoreElimination/simple.ll",
"commands": [
"opt < %s -passes=dse -S",
"opt < %s -aa-pipeline=basic-aa -passes=dse -S"
],
"tests": [
{
"test_name": "test48",
"test_body": "target datalayout = \"E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128\"\n\ndefine i32 @test48(ptr %P, ptr noalias %Q, ptr %R) {\n store i32 1, ptr %Q, align 4\n store i32 2, ptr %P, align 4\n store i32 3, ptr %Q, align 4\n %l = load i32, ptr %R, align 4\n ret i32 %l\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test49",
"test_body": "target datalayout = \"E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128\"\n\n; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)\ndeclare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0\n\ndefine void @test49() {\nbb:\n call void @llvm.memset.p0.i64(ptr readonly null, i8 0, i64 0, i1 false)\n store ptr null, ptr null, align 8\n ret void\n}\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[DSE] crash on applying * to std::nullopt",
"body": "[reduced5.zip](https://github.com/llvm/llvm-project/files/15433764/reduced5.zip)\r\n\r\nThe command\r\n```\r\nopt -passes=dse reduced5.ll\r\n```\r\nfails occasionally. Debug version reliably complains\r\n```\r\ninclude/c++/v1/optional:805: assertion this->has_value() failed: optional operator* called on a disengaged value\r\n```\r\nwith stack trace\r\n```\r\n frame #3: 0x00005555663c6a43 opt`std::__u::optional<llvm::MemoryLocation>::operator*(this= Has Value=false ) && at optional:805:5\r\n frame #4: 0x00005555663c4d58 opt`(anonymous namespace)::DSEState::eliminateRedundantStoresOfExistingValues(this=0x00007fffffff9130)::'lambda'()::operator()() const at DeadStoreElimination.cpp:2119:39\r\n frame #5: 0x00005555663bf842 opt`(anonymous namespace)::DSEState::eliminateRedundantStoresOfExistingValues(this=0x00007fffffff9960) at DeadStoreElimination.cpp:2132:12\r\n frame #6: 0x00005555663b8956 opt`(anonymous namespace)::eliminateDeadStores(F=0x000033187fe3e008, AA=0x000033187feaafc8, MSSA=0x000033187fe603f0, DT=0x000033187fef6d78, PDT=0x000033187fed18d0, TLI=0x000033187fe0cd18, LI=0x000033187fe11cc8) at DeadStoreElimination.cpp:2332:23\r\n frame #7: 0x00005555663b6b3e opt`llvm::DSEPass::run(this=0x000033187fe08ad8, F=0x000033187fe3e008, AM=0x00007fffffffc1d8) at DeadStoreElimination.cpp:2355:18\r\n```\r\n\r\nThe local fix is\r\n```\r\n==== llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp#184\r\n# action=edit type=text\r\n--- llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp\t2024-04-15 20:27:56.000000000 -0700\r\n+++ llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp\t2024-05-24 04:36:17.000000000 -0700\r\n@@ -2109,10 +2109,12 @@\r\n if (auto *MemSetI = dyn_cast<MemSetInst>(UpperInst)) {\r\n if (auto *SI = dyn_cast<StoreInst>(DefInst)) {\r\n // MemSetInst must have a write location.\r\n- MemoryLocation UpperLoc = *getLocForWrite(UpperInst);\r\n+ auto UpperLoc = getLocForWrite(UpperInst);\r\n+ if (!UpperLoc)\r\n+ return false;\r\n int64_t InstWriteOffset = 0;\r\n int64_t DepWriteOffset = 0;\r\n- auto OR = isOverwrite(UpperInst, DefInst, UpperLoc, *MaybeDefLoc,\r\n+ auto OR = isOverwrite(UpperInst, DefInst, *UpperLoc, *MaybeDefLoc,\r\n InstWriteOffset, DepWriteOffset);\r\n Value *StoredByte = isBytewiseValue(SI->getValueOperand(), DL);\r\n return StoredByte && StoredByte == MemSetI->getOperand(1) &&\r\n```\r\nwhich basically reverts a piece of https://github.com/llvm/llvm-project/commit/81d69e1bda9e4b6a83f29ba1f614e43ab4700972\r\n\r\nLooks like the actual problem happened earlier?\r\n\r\nPlease take a look, this is blocking us significantly.\r\n\r\n",
"author": "eaeltsin",
"labels": [
"crash",
"llvm:transforms"
],
"comments": [
{
"author": "eaeltsin",
"body": "@nikic @fhahn FYI\r\n\r\nthe reproducer was cooked by @alinas \r\n"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
157332
|
https://github.com/llvm/llvm-project/issues/157332
|
crash
|
c71318a9bf168d30bf3ccd59eaa826e93b283d4b
| 2025-09-07T08:45:43 |
[
"llvm/test/Transforms/GlobalOpt"
] |
{
"fix_commit": "cc052667b4b2f3bed12db68da876626e14f231f8",
"components": [
"GlobalOpt"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": [
[
2551,
2557
]
],
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": [
"OptimizeNonTrivialIFuncs"
],
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit cc052667b4b2f3bed12db68da876626e14f231f8
Author: Justin Riddell <arghnews@hotmail.co.uk>
Date: Wed Sep 10 03:32:52 2025 +0100
[GlobalOpt] Fix unreachable ifunc globalopt crash (#157332) (#157593)
Also fixes (#131488)
Unreachable case is triggering `Callees.empty()` assert. Since this was
[originally
](https://github.com/llvm/llvm-project/pull/87939/commits/02bd5a7013c558f1e5220fc89bafa68f40276549#diff-06aba0dac2a263dc14297a15655291d5506b760f54a736385bcf3208f83df843R2524)
a `continue` anyway, have applied that as a fix and added a test case.
Please let me know if there's a better way.
Not sure who/how to get folks to review, tagging a few people (apologies
if you're not the right person/this is the wrong way to do it, please
let me know what to do in future if so)
@labrinea @dtcxzyw @nikic @fhahn
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index d7edd1288309..f88d51f443bc 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -2551,7 +2551,8 @@ static bool OptimizeNonTrivialIFuncs(
}))
continue;
- assert(!Callees.empty() && "Expecting successful collection of versions");
+ if (Callees.empty())
+ continue;
LLVM_DEBUG(dbgs() << "Statically resolving calls to function "
<< Resolver->getName() << "\n");
|
[
{
"file": "llvm/test/Transforms/GlobalOpt/resolve-indirect-ifunc.ll",
"commands": [
"opt --passes=globalopt -o - -S < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine ptr @f1() {\n;\n unreachable\n}\n\n@i1 = ifunc void(), ptr @f1",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[GlobalOpt] Assertion `!Callees.empty() && \"Expecting successful collection of versions\"' failed.",
"body": "Reproducer:\nhttps://godbolt.org/z/x4Yd38Eav\n\nBacktrace:\n```console\nopt: /root/llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp:2554: bool OptimizeNonTrivialIFuncs(llvm::Module&, llvm::function_ref<llvm::TargetTransformInfo&(llvm::Function&)>): Assertion `!Callees.empty() && \"Expecting successful collection of versions\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace 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=globalopt <source>\n1.\tRunning pass \"globalopt\" on module \"<source>\"\n #0 0x00000000057a24d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x57a24d8)\n #1 0x000000000579f384 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007d453c842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007d453c8969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007d453c842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007d453c8287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x00007d453c82871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x00007d453c839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x00000000030ac2e4 OptimizeNonTrivialIFuncs(llvm::Module&, llvm::function_ref<llvm::TargetTransformInfo& (llvm::Function&)>) (.constprop.0) GlobalOpt.cpp:0:0\n #9 0x00000000030b376c optimizeGlobalsInModule(llvm::Module&, llvm::DataLayout const&, llvm::function_ref<llvm::TargetLibraryInfo& (llvm::Function&)>, llvm::function_ref<llvm::TargetTransformInfo& (llvm::Function&)>, llvm::function_ref<llvm::BlockFrequencyInfo& (llvm::Function&)>, llvm::function_ref<llvm::DominatorTree& (llvm::Function&)>, llvm::function_ref<void (llvm::Function&)>, llvm::function_ref<void (llvm::Function&)>) (.constprop.0) GlobalOpt.cpp:0:0\n#10 0x00000000030b480f llvm::GlobalOptPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x30b480f)\n#11 0x0000000002e2aaee llvm::detail::PassModel<llvm::Module, llvm::GlobalOptPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2e2aaee)\n#12 0x000000000558c2f1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x558c2f1)\n#13 0x00000000009776b8 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+0x9776b8)\n#14 0x000000000096b727 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x96b727)\n#15 0x00007d453c829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#16 0x00007d453c829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#17 0x0000000000962845 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x962845)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```",
"author": "k-arrows",
"labels": [
"ipo",
"crash"
],
"comments": [
{
"author": "k-arrows",
"body": "Reduced and modified from the following:\nhttps://github.com/llvm/llvm-project/blob/main/llvm/test/CodeGen/X86/partition.ll"
},
{
"author": "k-arrows",
"body": "The program written in C that hits the same assertion failure is listed in the following issue:\nhttps://github.com/llvm/llvm-project/issues/131488"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
139060
|
https://github.com/llvm/llvm-project/issues/139060
|
crash
|
c3ca0fb91eaef9133315024550ef7b0ca7b0458a
| 2025-05-08T10:54:48 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "8c6c525a6bbb34a146a3d1f239757758e2d738e8",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
[
5571,
5576
]
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"LoopVectorizationCostModel::computePredInstDiscount"
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 8c6c525a6bbb34a146a3d1f239757758e2d738e8
Author: Florian Hahn <flo@fhahn.com>
Date: Fri May 9 20:29:22 2025 +0100
[LV] Don't consider FORs as profitable to scalarize.
Fixed-order recurrence phis cannot be scalarized, they will always be
widened at the moment. Make sure they are not incorrectly considered
profitable to scalarize, similar to 41c1a7be3f1a2556e.
Fixes https://github.com/llvm/llvm-project/issues/139060.
Fixes https://github.com/llvm/llvm-project/issues/139065.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index b06bcbee9fdc..aabb04d03bc8 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -5571,6 +5571,10 @@ InstructionCost LoopVectorizationCostModel::computePredInstDiscount(
if (ScalarCosts.contains(I))
continue;
+ // Cannot scalarize fixed-order recurrence phis at the moment.
+ if (isa<PHINode>(I) && Legal->isFixedOrderRecurrence(cast<PHINode>(I)))
+ continue;
+
// Compute the cost of the vector instruction. Note that this cost already
// includes the scalarization overhead of the predicated instruction.
InstructionCost VectorCost = getInstructionCost(I, VF);
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/X86/fixed-order-recurrence.ll",
"commands": [
"opt -passes=loop-vectorize -S -o - %s"
],
"tests": [
{
"test_name": "test_first_order_recurrence_tried_to_scalarized",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-pc_linux\"\n\ndefine void @test_first_order_recurrence_tried_to_scalarized(ptr %dst, i1 %c, i32 %x) {\nentry:\n %N = select i1 %c, i32 8, i32 9\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %for = phi i32 [ 4, %entry ], [ %iv, %loop ]\n %iv.next = add nuw nsw i32 %iv, 1\n %sub = sub nsw i32 10, %for\n %gep.dst = getelementptr inbounds nuw i32, ptr %dst, i32 %iv\n store i32 %sub, ptr %gep.dst, align 4\n %ec = icmp eq i32 %iv.next, %N\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[clang] Crash at -O2: Assertion `(BestFactor.Width == LegacyVF.Width ... failed",
"body": "This code crashes at `-O2`:\n\n```c\nint *a;\nint b;\nvoid c(int d, int *g) {\n int e, f = g[0];\n e = 0;\n for (; e < d; e++) {\n a[e] = f + g[e + 1] - g[e];\n g[e] = f + g[e + 1];\n }\n}\nvoid h(int d, int g) { c(d, &g); }\nvoid i() {\n int j = 0;\n if (b)\n j = 1;\n h(j + 2, 4);\n}\nvoid main() {}\n```\n\nCompiler Explorer: https://godbolt.org/z/b1aTErPW1\n\nBisected to https://github.com/llvm/llvm-project/commit/673a4671f3e8b7158d990f6456428175a6eac38c, which was committed by @nikic \n\nCrash:\n\n```console\nclang: /root/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7667: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || BestPlan.hasEarlyExit() || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop) || planContainsAdditionalSimplifications(getPlanFor(LegacyVF.Width), CostCtx, OrigLoop)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\n```\n\nBacktrace:\n\n```console\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O2 <source>\n1.\t<eof> parser at end of file\n2.\tOptimizer\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"<source>\"\n4.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"i\"\n #0 0x0000000003f7c0a8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3f7c0a8)\n #1 0x0000000003f79d34 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3f79d34)\n #2 0x0000000003ebebf8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0\n #3 0x0000769685242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #4 0x00007696852969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #5 0x0000769685242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #6 0x00007696852287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #7 0x000076968522871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #8 0x0000769685239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #9 0x0000000005af0736 llvm::LoopVectorizationPlanner::computeBestVF() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5af0736)\n#10 0x0000000005b066aa llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5b066aa)\n#11 0x0000000005b09280 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5b09280)\n#12 0x0000000005b098d3 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5b098d3)\n#13 0x0000000005669c1e llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5669c1e)\n#14 0x000000000391d5f0 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x391d5f0)\n#15 0x0000000001200d3e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x1200d3e)\n#16 0x000000000391bec3 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x391bec3)\n#17 0x00000000011ffb8e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x11ffb8e)\n#18 0x000000000391b8d0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x391b8d0)\n#19 0x00000000042309de (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\n#20 0x0000000004233a61 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4233a61)\n#21 0x000000000491e800 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x491e800)\n#22 0x00000000065f0c0c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x65f0c0c)\n#23 0x000000000491ebe8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x491ebe8)\n#24 0x0000000004c11f15 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4c11f15)\n#25 0x0000000004b9131e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4b9131e)\n#26 0x0000000004d05d39 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4d05d39)\n#27 0x0000000000da788f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xda788f)\n#28 0x0000000000d9da5a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#29 0x00000000049854a9 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0\n#30 0x0000000003ebf094 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3ebf094)\n#31 0x0000000004985abf clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0\n#32 0x0000000004947f0d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4947f0d)\n#33 0x0000000004948f9e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4948f9e)\n#34 0x0000000004950df5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4950df5)\n#35 0x0000000000da37f8 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xda37f8)\n#36 0x0000000000c28b74 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc28b74)\n#37 0x0000769685229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#38 0x0000769685229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#39 0x0000000000d9d505 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd9d505)\n```",
"author": "cardigan1008",
"labels": [
"vectorizers",
"crash-on-valid"
],
"comments": [
{
"author": "fhahn",
"body": "taking a look"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
131195
|
https://github.com/llvm/llvm-project/issues/131195
|
crash
|
8413f4d837a96458104f63bab72c751b8285a458
| 2025-03-13T19:24:54 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "605a9f590d91a42ae652c2ab13487b5ad57c58a5",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
14081,
14086
],
[
14121,
14126
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::isGatherShuffledSingleRegisterEntry"
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 605a9f590d91a42ae652c2ab13487b5ad57c58a5
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Fri Mar 14 13:40:15 2025 -0700
[SLP]Check if user node is same as other node and check operand order
Need to check if the user node is same as other node and check operand
order to prevent a compiler crash when trying to find matching gather
node with user nodes, having the same last instruction.
Fixes #131195
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 9c3992b4a713..708dda9bd7f8 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -14081,6 +14081,17 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
}
return true;
};
+ auto CheckParentNodes = [&](const TreeEntry *User1, const TreeEntry *User2,
+ unsigned EdgeIdx) {
+ const TreeEntry *Ptr1 = User1;
+ while (Ptr1) {
+ unsigned Idx = Ptr1->UserTreeIndex.EdgeIdx;
+ Ptr1 = Ptr1->UserTreeIndex.UserTE;
+ if (Ptr1 == User2)
+ return Idx < EdgeIdx;
+ }
+ return false;
+ };
for (Value *V : VL) {
if (isConstant(V) || !VisitedValue.insert(V).second)
continue;
@@ -14121,6 +14132,9 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
(TEUseEI.UserTE->Idx < UseEI.UserTE->Idx ||
HasGatherUser(TEUseEI.UserTE)))
continue;
+ // If the user node is the operand of the other user node - skip.
+ if (CheckParentNodes(TEUseEI.UserTE, UseEI.UserTE, UseEI.EdgeIdx))
+ continue;
}
// Check if the user node of the TE comes after user node of TEPtr,
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/user-node-with-same-last-instr.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-99999 < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @wombat(i32 %arg) {\n;\nbb:\n br label %bb1\n\nbb1:\n br i1 false, label %bb2, label %bb5\n\nbb2:\n %phi = phi i32 [ %or, %bb4 ], [ 0, %bb1 ]\n %phi3 = phi i32 [ %sub, %bb4 ], [ 0, %bb1 ]\n %or = or i32 %phi, 1\n %and = and i32 0, %phi\n %sub = sub i32 %phi3, %arg\n br label %bb4\n\nbb4:\n br i1 false, label %bb2, label %bb5\n\nbb5:\n %phi6 = phi i32 [ 0, %bb1 ], [ %and, %bb4 ]\n %phi7 = phi i32 [ 0, %bb1 ], [ %sub, %bb4 ]\n ret void\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SLPVectorizer] Instruction does not dominate all uses! ...LLVM ERROR: Broken module found, compilation aborted!",
"body": "To reproduce run opt with the test below with -passes=slp-vectorizer -slp-threshold=-99999:\n```\n; ModuleID = './reduced.ll'\nsource_filename = \"./reduced.ll\"\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @wombat(i32 %arg) #0 gc \"statepoint-example\" {\nbb:\n br label %bb1\n\nbb1: ; preds = %bb\n br i1 false, label %bb2, label %bb5\n\nbb2: ; preds = %bb4, %bb1\n %phi = phi i32 [ %or, %bb4 ], [ 0, %bb1 ]\n %phi3 = phi i32 [ %sub, %bb4 ], [ 0, %bb1 ]\n %or = or i32 %phi, 1\n %and = and i32 0, %phi\n %sub = sub i32 %phi3, %arg\n br label %bb4\n\nbb4: ; preds = %bb2\n br i1 false, label %bb2, label %bb5\n\nbb5: ; preds = %bb4, %bb1\n %phi6 = phi i32 [ 0, %bb1 ], [ %and, %bb4 ]\n %phi7 = phi i32 [ 0, %bb1 ], [ %sub, %bb4 ]\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+prfchw,-cldemote,+avx,+aes,+sahf,+pclmul,-xop,+crc32,-amx-fp8,+xsaves,-avx512fp16,-usermsr,-sm4,-egpr,+sse4.1,-avx512ifma,+xsave,+sse4.2,-tsxldtrk,-sm3,-ptwrite,-widekl,-movrs,+invpcid,+64bit,+xsavec,-avx10.1-512,-avx512vpopcntdq,+cmov,-avx512vp2intersect,+avx512cd,+movbe,-avxvnniint8,-ccmp,-amx-int8,-kl,-avx10.1-256,+evex512,-avxvnni,+rtm,+adx,+avx2,-hreset,-movdiri,-serialize,-sha512,-vpclmulqdq,+avx512vl,-uintr,-cf,+clflushopt,-raoint,-cmpccxadd,+bmi,-amx-tile,+sse,-avx10.2-256,-gfni,-avxvnniint16,-amx-fp16,-zu,-ndd,+xsaveopt,+rdrnd,+avx512f,-amx-bf16,-avx512bf16,-avx512vnni,-push2pop2,+cx8,+avx512bw,+sse3,+pku,-nf,-amx-tf32,-amx-avx512,+fsgsbase,-clzero,-mwaitx,-lwp,+lzcnt,-sha,-movdir64b,-ppx,-wbnoinvd,-enqcmd,-amx-transpose,-avx10.2-512,-avxneconvert,-tbm,-pconfig,-amx-complex,+ssse3,+cx16,+bmi2,+fma,+popcnt,-avxifma,+f16c,-avx512bitalg,-rdpru,+clwb,+mmx,+sse2,+rdseed,-avx512vbmi2,-prefetchi,-amx-movrs,-rdpid,-fma4,-avx512vbmi,-shstk,-vaes,-waitpkg,-sgx,+fxsr,+avx512dq,-sse4a,-avx512f\" }\n```\nReproducer: https://godbolt.org/z/Pfa9ca1o9\n\n\n\nStack dump:\n```\nInstruction does not dominate all uses!\n %5 = insertelement <2 x i32> <i32 poison, i32 0>, i32 %arg, i32 0\n %1 = shufflevector <2 x i32> %5, <2 x i32> <i32 poison, i32 1>, <2 x i32> <i32 0, i32 3>\nLLVM ERROR: Broken module found, compilation aborted!\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer -slp-threshold=-99999 <source>\n1.\tRunning pass \"verify\" on module \"<source>\"\n #0 0x0000000005480a38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5480a38)\n #1 0x000000000547e3f4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x000072fce1242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x000072fce12969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x000072fce1242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x000072fce12287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x00000000008074fd llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0\n #7 0x00000000053bec18 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x53bec18)\n #8 0x00000000052bb868 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x52bb868)\n #9 0x000000000093768e llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x93768e)\n#10 0x000000000527a030 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x527a030)\n#11 0x0000000000941b4a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x941b4a)\n#12 0x000000000093522c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x93522c)\n#13 0x000072fce1229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#14 0x000072fce1229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#15 0x000000000092cd35 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x92cd35)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```",
"author": "TatyanaDoubts",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
134013
|
https://github.com/llvm/llvm-project/issues/134013
|
crash
|
65ed35393cc8a3b896d794ab316e0357d907efff
| 2025-04-02T00:52:53 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "48a4b14cb65d56ec3bbb473887c31d251092c83c",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
8873,
8878
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::buildTree_rec"
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 48a4b14cb65d56ec3bbb473887c31d251092c83c
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Wed Apr 2 05:57:16 2025 -0700
[SLP]Fix whole vector registers calculations for compares
Need to check that the calculated number of the elements is not larger
than the original number of scalars to prevent a compiler crash.
Fixes #134013
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index f9284b3a5f21..838e952c024c 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -8873,6 +8873,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
// Find the number of elements, which forms full vectors.
unsigned PWSz = getFullVectorNumberOfElements(
*TTI, UniqueValues.front()->getType(), UniqueValues.size());
+ PWSz = std::min<unsigned>(PWSz, VL.size());
if (PWSz == VL.size()) {
ReuseShuffleIndices.clear();
} else {
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/whole-registers-compare.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-99999 < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @test() {\n;\nentry:\n br label %do.body\n\ndo.body:\n %val.sroa.66.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.66.1, %do.body ]\n %val.sroa.60.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.60.2, %do.body ]\n %val.sroa.54.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.54.2, %do.body ]\n %val.sroa.48.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.48.2, %do.body ]\n %val.sroa.42.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.42.2, %do.body ]\n %val.sroa.36.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.36.2, %do.body ]\n %val.sroa.30.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.30.2, %do.body ]\n %val.sroa.24.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.24.2, %do.body ]\n %val.sroa.18.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.18.2, %do.body ]\n %val.sroa.12.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.12.2, %do.body ]\n %val.sroa.6.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.6.2, %do.body ]\n %val.sroa.0.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.0.1, %do.body ]\n %cmp119 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.6.1 = select i1 %cmp119, float 0.000000e+00, float 0.000000e+00\n %val.sroa.0.1 = select i1 %cmp119, float 0.000000e+00, float 0.000000e+00\n %cmp119.1 = fcmp uge float %val.sroa.6.1, 0.000000e+00\n %val.sroa.6.2 = select i1 %cmp119.1, float 0.000000e+00, float 0.000000e+00\n %cmp119.2 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.12.2 = select i1 %cmp119.2, float 0.000000e+00, float 0.000000e+00\n %cmp119.3 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.18.2 = select i1 %cmp119.3, float 0.000000e+00, float 0.000000e+00\n %cmp119.4 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.24.2 = select i1 %cmp119.4, float 0.000000e+00, float 0.000000e+00\n %cmp119.5 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.30.2 = select i1 %cmp119.5, float 0.000000e+00, float 0.000000e+00\n %cmp119.6 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.36.2 = select i1 %cmp119.6, float 0.000000e+00, float 0.000000e+00\n %cmp119.7 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.42.2 = select i1 %cmp119.7, float 0.000000e+00, float 0.000000e+00\n %cmp119.8 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.48.2 = select i1 %cmp119.8, float 0.000000e+00, float 0.000000e+00\n %cmp119.9 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.54.2 = select i1 %cmp119.9, float 0.000000e+00, float 0.000000e+00\n %cmp119.10 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.66.1 = select i1 %cmp119.10, float 0.000000e+00, float 0.000000e+00\n %val.sroa.60.2 = select i1 %cmp119.10, float 0.000000e+00, float 0.000000e+00\n br label %do.body\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "crash in slp vectorizer after \"[SLP]Fix a check for the whole register use\"",
"body": "After applying [bfd8cc0a3e82](https://github.com/llvm/llvm-project/commit/bfd8cc0a3e82), I am seeing a crash in SLPVectorize.cpp.\n\nReproducer:\n```\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine <2 x float> @foo() {\nentry:\n br label %do.body\n\ndo.body: ; preds = %do.body, %entry\n %val.sroa.66.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.66.1, %do.body ]\n %val.sroa.60.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.60.2, %do.body ]\n %val.sroa.54.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.54.2, %do.body ]\n %val.sroa.48.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.48.2, %do.body ]\n %val.sroa.42.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.42.2, %do.body ]\n %val.sroa.36.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.36.2, %do.body ]\n %val.sroa.30.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.30.2, %do.body ]\n %val.sroa.24.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.24.2, %do.body ]\n %val.sroa.18.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.18.2, %do.body ]\n %val.sroa.12.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.12.2, %do.body ]\n %val.sroa.6.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.6.2, %do.body ]\n %val.sroa.0.0 = phi float [ 0.000000e+00, %entry ], [ %val.sroa.0.1, %do.body ]\n %cmp119 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.6.1 = select i1 %cmp119, float 0.000000e+00, float 0.000000e+00\n %val.sroa.0.1 = select i1 %cmp119, float 0.000000e+00, float 0.000000e+00\n %cmp119.1 = fcmp uge float %val.sroa.6.1, 0.000000e+00\n %val.sroa.6.2 = select i1 %cmp119.1, float 0.000000e+00, float 0.000000e+00\n %cmp119.2 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.12.2 = select i1 %cmp119.2, float 0.000000e+00, float 0.000000e+00\n %cmp119.3 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.18.2 = select i1 %cmp119.3, float 0.000000e+00, float 0.000000e+00\n %cmp119.4 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.24.2 = select i1 %cmp119.4, float 0.000000e+00, float 0.000000e+00\n %cmp119.5 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.30.2 = select i1 %cmp119.5, float 0.000000e+00, float 0.000000e+00\n %cmp119.6 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.36.2 = select i1 %cmp119.6, float 0.000000e+00, float 0.000000e+00\n %cmp119.7 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.42.2 = select i1 %cmp119.7, float 0.000000e+00, float 0.000000e+00\n %cmp119.8 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.48.2 = select i1 %cmp119.8, float 0.000000e+00, float 0.000000e+00\n %cmp119.9 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.54.2 = select i1 %cmp119.9, float 0.000000e+00, float 0.000000e+00\n %cmp119.10 = fcmp uge float 0.000000e+00, 0.000000e+00\n %val.sroa.66.1 = select i1 %cmp119.10, float 0.000000e+00, float 0.000000e+00\n %val.sroa.60.2 = select i1 %cmp119.10, float 0.000000e+00, float 0.000000e+00\n br label %do.body\n}\n```\nCrash is occurring on [SLPVectorizer.cpp:16251](https://github.com/llvm/llvm-project/blob/ad1ca5f4a2bc09f99fd82e5444f5da37c2985e97/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp#L16251).\nAt the time `VF:12` and `Scalars.size():16`.\n",
"author": "macurtis-amd",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid"
],
"comments": [
{
"author": "macurtis-amd",
"body": "@alexey-bataev Thanks!"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
111934
|
https://github.com/llvm/llvm-project/issues/111934
|
miscompilation
|
f74f568b29885c3fa63c44e33f91f3bb7281138e
| 2024-10-11T03:29:55 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "6a65e98fa7901dc1de91172d065fafb16ce89d77",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": [
[
955,
963
],
[
971,
977
],
[
980,
986
],
[
3375,
3381
]
],
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": [
"InstCombinerImpl::foldAndOrOfICmps",
"foldIsPowerOf2"
],
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 6a65e98fa7901dc1de91172d065fafb16ce89d77
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Fri Oct 11 18:19:21 2024 +0800
[InstCombine] Drop range attributes in `foldIsPowerOf2` (#111946)
Fixes https://github.com/llvm/llvm-project/issues/111934.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index 688601a8ffa5..964616a4eb35 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -955,9 +955,11 @@ static Value *foldIsPowerOf2OrZero(ICmpInst *Cmp0, ICmpInst *Cmp1, bool IsAnd,
}
/// Reduce a pair of compares that check if a value has exactly 1 bit set.
-/// Also used for logical and/or, must be poison safe.
+/// Also used for logical and/or, must be poison safe if range attributes are
+/// dropped.
static Value *foldIsPowerOf2(ICmpInst *Cmp0, ICmpInst *Cmp1, bool JoinedByAnd,
- InstCombiner::BuilderTy &Builder) {
+ InstCombiner::BuilderTy &Builder,
+ InstCombinerImpl &IC) {
// Handle 'and' / 'or' commutation: make the equality check the first operand.
if (JoinedByAnd && Cmp1->getPredicate() == ICmpInst::ICMP_NE)
std::swap(Cmp0, Cmp1);
@@ -971,7 +973,10 @@ static Value *foldIsPowerOf2(ICmpInst *Cmp0, ICmpInst *Cmp1, bool JoinedByAnd,
match(Cmp1, m_SpecificICmp(ICmpInst::ICMP_ULT,
m_Intrinsic<Intrinsic::ctpop>(m_Specific(X)),
m_SpecificInt(2)))) {
- Value *CtPop = Cmp1->getOperand(0);
+ auto *CtPop = cast<Instruction>(Cmp1->getOperand(0));
+ // Drop range attributes and re-infer them in the next iteration.
+ CtPop->dropPoisonGeneratingAnnotations();
+ IC.addToWorklist(CtPop);
return Builder.CreateICmpEQ(CtPop, ConstantInt::get(CtPop->getType(), 1));
}
// (X == 0) || (ctpop(X) u> 1) --> ctpop(X) != 1
@@ -980,7 +985,10 @@ static Value *foldIsPowerOf2(ICmpInst *Cmp0, ICmpInst *Cmp1, bool JoinedByAnd,
match(Cmp1, m_SpecificICmp(ICmpInst::ICMP_UGT,
m_Intrinsic<Intrinsic::ctpop>(m_Specific(X)),
m_SpecificInt(1)))) {
- Value *CtPop = Cmp1->getOperand(0);
+ auto *CtPop = cast<Instruction>(Cmp1->getOperand(0));
+ // Drop range attributes and re-infer them in the next iteration.
+ CtPop->dropPoisonGeneratingAnnotations();
+ IC.addToWorklist(CtPop);
return Builder.CreateICmpNE(CtPop, ConstantInt::get(CtPop->getType(), 1));
}
return nullptr;
@@ -3375,7 +3383,7 @@ Value *InstCombinerImpl::foldAndOrOfICmps(ICmpInst *LHS, ICmpInst *RHS,
if (Value *V = foldSignedTruncationCheck(LHS, RHS, I, Builder))
return V;
- if (Value *V = foldIsPowerOf2(LHS, RHS, IsAnd, Builder))
+ if (Value *V = foldIsPowerOf2(LHS, RHS, IsAnd, Builder, *this))
return V;
if (Value *V = foldPowerOf2AndShiftedMask(LHS, RHS, IsAnd, Builder))
|
[
{
"file": "llvm/test/Transforms/InstCombine/ispow2.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "has_single_bit",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @has_single_bit(i32 %x) {\nentry:\n %cmp1 = icmp ne i32 %x, 0\n %popcnt = call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %x)\n %cmp2 = icmp ult i32 %popcnt, 2\n %sel = select i1 %cmp1, i1 %cmp2, i1 false\n ret i1 %sel\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "has_single_bit_inv",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @has_single_bit_inv(i32 %x) {\nentry:\n %cmp1 = icmp eq i32 %x, 0\n %popcnt = call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %x)\n %cmp2 = icmp ugt i32 %popcnt, 1\n %sel = select i1 %cmp1, i1 true, i1 %cmp2\n ret i1 %sel\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "not_pow2_or_z_known_bits_fail_wrong_cmp",
"test_body": "define <2 x i1> @not_pow2_or_z_known_bits_fail_wrong_cmp(<2 x i32> %xin) {\n %x = or <2 x i32> %xin, splat (i32 64)\n %cnt = call <2 x i32> @llvm.ctpop.v2i32(<2 x i32> %x)\n %r = icmp ugt <2 x i32> %cnt, splat (i32 2)\n ret <2 x i1> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <2 x i32> @llvm.ctpop.v2i32(<2 x i32>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstCombine] poison-generating attributes are not dropped when folding logical and/or of icmps",
"body": "Reproducer: https://alive2.llvm.org/ce/z/rSUfvo\r\n```\r\ndefine i1 @src(i32 noundef %Value) {\r\nentry:\r\n %cmp.not = icmp eq i32 %Value, 0\r\n %0 = call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %Value)\r\n %cmp1 = icmp ult i32 %0, 2\r\n %1 = select i1 %cmp.not, i1 false, i1 %cmp1\r\n ret i1 %1\r\n}\r\n\r\ndefine i1 @tgt(i32 noundef %Value) {\r\nentry:\r\n %0 = call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %Value)\r\n %1 = icmp eq i32 %0, 1\r\n ret i1 %1\r\n}\r\n```\r\nWhen `%Value == 0`, `@src` returns `false` but `@tgt` returns `poison`.\r\nThis miscompilation was triggered after https://github.com/llvm/llvm-project/pull/111284 was landed.\r\n",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
157322
|
https://github.com/llvm/llvm-project/issues/157322
|
crash
|
4c6a56225f3982ab2de7f8acb8d8560079a830c8
| 2025-09-07T04:03:31 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "fe6e17840159f7ae9785d8506ff2987a2df7ab08",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": [
[
193,
198
]
],
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": [
"PlainCFGBuilder::createVPInstructionsForVPBB"
],
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit fe6e17840159f7ae9785d8506ff2987a2df7ab08
Author: Luke Lau <luke@igalia.com>
Date: Mon Sep 8 17:01:43 2025 +0800
[VPlan] Don't build recipes for unconditional switches (#157323)
In #157322 we crash because we try to infer a type for a VPReplicate
switch recipe.
My understanding was that these switches should be removed by
VPlanPredicator, but this switch survived through it because it was
unconditional, i.e. had no cases other than the default case.
This fixes #157322 by not emitting any recipes for unconditional
switches to begin with, similar to how we treat unconditional branches.
diff --git a/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp b/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
index c1c525ee2312..cef91c15dd87 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
@@ -193,6 +193,9 @@ void PlainCFGBuilder::createVPInstructionsForVPBB(VPBasicBlock *VPBB,
}
if (auto *SI = dyn_cast<SwitchInst>(Inst)) {
+ // Don't emit recipes for unconditional switch instructions.
+ if (SI->getNumCases() == 0)
+ continue;
SmallVector<VPValue *> Ops = {getOrCreateVPOperand(SI->getCondition())};
for (auto Case : SI->cases())
Ops.push_back(getOrCreateVPOperand(Case.getCaseValue()));
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/predicate-switch.ll",
"commands": [
"opt -p loop-vectorize -force-vector-width=2 -force-vector-interleave=1 -S %s",
"opt -p loop-vectorize -force-vector-width=2 -force-vector-interleave=2 -S %s"
],
"tests": [
{
"test_name": "switch_unconditional",
"test_body": "define void @switch_unconditional(ptr %start) {\nentry:\n br label %loop\n\nloop: ; preds = %latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %latch ]\n %gep = getelementptr i32, ptr %start, i64 %iv\n %x = load i32, ptr %gep, align 4\n switch i32 %x, label %foo [\n ]\n\nfoo: ; preds = %loop\n br label %latch\n\nlatch: ; preds = %foo\n store i32 0, ptr %gep, align 4\n %iv.next = add i64 %iv, 1\n %cmp = icmp eq i64 %iv.next, 100\n br i1 %cmp, label %exit, label %loop\n\nexit: ; preds = %latch\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[Loop Vectorizer] Unhandled opcode UNREACHABLE executed at /root/llvm-project/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp:257!",
"body": "Reproducer:\nhttps://godbolt.org/z/M3rojTjfc\n\nBacktrace:\n```console\nUnhandled opcode\nUNREACHABLE executed at /root/llvm-project/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp:257!\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=loop-vectorize <source>\n1.\tRunning pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"<source>\"\n2.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"switch\"\n #0 0x00000000057a4688 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x57a4688)\n #1 0x00000000057a1534 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x0000705e12842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x0000705e128969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x0000705e12842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x0000705e128287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x00000000056db7aa (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x56db7aa)\n #7 0x00000000036a2db0 llvm::VPTypeAnalysis::inferScalarTypeForRecipe(llvm::VPReplicateRecipe const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x36a2db0)\n #8 0x00000000036a295c llvm::VPTypeAnalysis::inferScalarType(llvm::VPValue const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x36a295c)\n #9 0x000000000372765d (anonymous namespace)::VPlanVerifier::verifyVPBasicBlock(llvm::VPBasicBlock const*) VPlanVerifier.cpp:0:0\n#10 0x0000000003729f01 (anonymous namespace)::VPlanVerifier::verifyBlock(llvm::VPBlockBase const*) VPlanVerifier.cpp:0:0\n#11 0x000000000372b34a (anonymous namespace)::VPlanVerifier::verifyRegionRec(llvm::VPRegionBlock const*) VPlanVerifier.cpp:0:0\n#12 0x000000000372d952 llvm::verifyVPlanIsValid(llvm::VPlan const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x372d952)\n#13 0x000000000352ce13 llvm::LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(std::unique_ptr<llvm::VPlan, std::default_delete<llvm::VPlan>>, llvm::VFRange&, llvm::LoopVersioning*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x352ce13)\n#14 0x000000000352d428 llvm::LoopVectorizationPlanner::buildVPlansWithVPRecipes(llvm::ElementCount, llvm::ElementCount) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x352d428)\n#15 0x000000000352dd34 llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x352dd34)\n#16 0x0000000003531b77 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3531b77)\n#17 0x0000000003534da0 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3534da0)\n#18 0x000000000353544d llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x353544d)\n#19 0x0000000002e2b1ee llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2e2b1ee)\n#20 0x00000000055904d1 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x55904d1)\n#21 0x0000000000ee0cbe llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xee0cbe)\n#22 0x000000000558ea3a llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x558ea3a)\n#23 0x000000000096d5ae llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x96d5ae)\n#24 0x000000000558e3f1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x558e3f1)\n#25 0x00000000009778a8 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9778a8)\n#26 0x000000000096b917 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x96b917)\n#27 0x0000705e12829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#28 0x0000705e12829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#29 0x0000000000962a35 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x962a35)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```",
"author": "k-arrows",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "k-arrows",
"body": "This comes from the following:\nhttps://github.com/llvm/llvm-project/blob/main/llvm/test/Transforms/LoopUnroll/full-unroll-crashers.ll"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
142895
|
https://github.com/llvm/llvm-project/issues/142895
|
crash
|
d5d6f60632c6c6ef5a4342439f767e10880784e1
| 2025-06-05T03:42:55 |
[
"llvm/test/Transforms/LoopUnroll"
] |
{
"fix_commit": "4eac8daa38990871e50b804c0cc19a3ad9c98db2",
"components": [
"LoopPeel"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": [
[
1257,
1263
]
],
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": [
"llvm::peelLoop"
],
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 4eac8daa38990871e50b804c0cc19a3ad9c98db2
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Fri Jun 6 12:56:28 2025 +0800
[LoopPeel] Handle non-local instructions/arguments when updating exiting values (#142993)
Similar to
https://github.com/llvm/llvm-project/commit/7e14161f49b32387988cf9d937bbfaa27d0fbdd5,
the exiting value may be a non-local instruction or an argument.
Closes https://github.com/llvm/llvm-project/issues/142895.
diff --git a/llvm/lib/Transforms/Utils/LoopPeel.cpp b/llvm/lib/Transforms/Utils/LoopPeel.cpp
index bd025fddd0cf..9149f71941db 100644
--- a/llvm/lib/Transforms/Utils/LoopPeel.cpp
+++ b/llvm/lib/Transforms/Utils/LoopPeel.cpp
@@ -1257,7 +1257,11 @@ bool llvm::peelLoop(Loop *L, unsigned PeelCount, bool PeelLast, LoopInfo *LI,
// Now adjust users of the original exit values by replacing them with the
// exit value from the peeled iteration and remove them.
for (const auto &[P, E] : ExitValues) {
- P->replaceAllUsesWith(isa<Constant>(E) ? E : &*VMap.lookup(E));
+ Instruction *ExitInst = dyn_cast<Instruction>(E);
+ if (ExitInst && L->contains(ExitInst))
+ P->replaceAllUsesWith(&*VMap[ExitInst]);
+ else
+ P->replaceAllUsesWith(E);
P->eraseFromParent();
}
formLCSSA(*L, DT, LI, SE);
|
[
{
"file": "llvm/test/Transforms/LoopUnroll/unroll-and-peel-last-iteration.ll",
"commands": [
"opt -p loop-unroll -S %s"
],
"tests": [
{
"test_name": "pr142895_exit_value_is_inst",
"test_body": "define i32 @pr142895_exit_value_is_inst(i32 %arg) {\nentry:\n %mul = mul i32 %arg, 7\n br label %loop\n\nloop: ; preds = %loop, %entry\n %indvar = phi i32 [ 0, %entry ], [ %inc, %loop ]\n %cmp1 = icmp eq i32 %indvar, 32\n %sel = select i1 %cmp1, i32 0, i32 0\n %sub = sub i32 0, 0\n %xor = xor i32 0, 0\n %inc = add i32 %indvar, 1\n %exitcond = icmp ne i32 %inc, 33\n br i1 %exitcond, label %loop, label %exit\n\nexit: ; preds = %loop\n %exit.lcssa = phi i32 [ %mul, %loop ]\n ret i32 %exit.lcssa\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "pr142895_exit_value_is_arg",
"test_body": "define i32 @pr142895_exit_value_is_arg(i32 %arg) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %indvar = phi i32 [ 0, %entry ], [ %inc, %loop ]\n %cmp1 = icmp eq i32 %indvar, 32\n %sel = select i1 %cmp1, i32 0, i32 0\n %sub = sub i32 0, 0\n %xor = xor i32 0, 0\n %inc = add i32 %indvar, 1\n %exitcond = icmp ne i32 %inc, 33\n br i1 %exitcond, label %loop, label %exit\n\nexit: ; preds = %loop\n %exit.lcssa = phi i32 [ %arg, %loop ]\n ret i32 %exit.lcssa\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[LoopPeel] Assertion `V && \"Dereferencing deleted ValueHandle\"' failed.",
"body": "Crash is reproducible on Godbolt:\n[https://godbolt.org/z/4axfWq4dq](https://godbolt.org/z/4axfWq4dq)\n\nReproduce code (compile with `clang-21 -O3 foo.c`):\n```c\nchar func(char a, int b) {\n return b < 32 ? b : 0;\n}\n\nint a;\nint b;\nint main() {\n char v[4][4] = {};\n for (int i = 0; i < 33; i++) {\n for (int j = 0; j < 4; j++) {\n for (int k = 0; k < 4; k++) {\n a ^= v[0][k] - func(b ^= v[0][j], i);\n }\n }\n }\n return 0;\n}\n\n```\n\nStack dump:\n```\n #0 0x0000000003c94d38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3c94d38)\n #1 0x0000000003c92e7c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3c92e7c)\n #2 0x0000000003be36d8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0\n #3 0x000074a5bf042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #4 0x0000000005876204 (anonymous namespace)::VectorCombine::foldSingleElementStore(llvm::Instruction&) VectorCombine.cpp:0:0\n #5 0x00000000058805d9 (anonymous namespace)::VectorCombine::run()::'lambda'(llvm::Instruction&)::operator()(llvm::Instruction&) const (.isra.0) VectorCombine.cpp:0:0\n #6 0x0000000005881057 llvm::VectorCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5881057)\n #7 0x0000000004e48f3e llvm::detail::PassModel<llvm::Function, llvm::VectorCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4e48f3e)\n #8 0x0000000003656ddf llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3656ddf)\n #9 0x00000000011b1a9e 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-trunk/bin/clang+0x11b1a9e)\n#10 0x0000000002bec20e llvm::CGSCCToFunctionPassAdaptor::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x2bec20e)\n#11 0x00000000011b1f0e llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::CGSCCToFunctionPassAdaptor, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x11b1f0e)\n#12 0x0000000002be55c6 llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x2be55c6)\n#13 0x0000000004e489ee llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4e489ee)\n#14 0x0000000002bed3e9 llvm::DevirtSCCRepeatedPass::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x2bed3e9)\n#15 0x0000000004e48a0e llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::DevirtSCCRepeatedPass, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4e48a0e)\n#16 0x0000000002be8043 llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x2be8043)\n#17 0x0000000004e489ce llvm::detail::PassModel<llvm::Module, llvm::ModuleToPostOrderCGSCCPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4e489ce)\n#18 0x000000000365991f llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x365991f)\n#19 0x00000000054e64b9 llvm::ModuleInlinerWrapperPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x54e64b9)\n#20 0x0000000004d00f8e llvm::detail::PassModel<llvm::Module, llvm::ModuleInlinerWrapperPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4d00f8e)\n#21 0x000000000365991f llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x365991f)\n#22 0x0000000003f4491a (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\n#23 0x0000000003f47412 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3f47412)\n#24 0x00000000045e01e8 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x45e01e8)\n#25 0x000000000624133c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x624133c)\n#26 0x00000000045e0dbd clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+0x45e0dbd)\n#27 0x00000000048f107a clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+0x48f107a)\n#28 0x000000000486ca6b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x486ca6b)\n#29 0x00000000049e5683 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x49e5683)\n#30 0x0000000000dcab25 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+0xdcab25)\n#31 0x0000000000dc296d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#32 0x0000000004652b59 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0\n#33 0x0000000003be3af3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3be3af3)\n#34 0x0000000004652d79 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0\n#35 0x00000000046159ed clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x46159ed)\n#36 0x00000000046169b1 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x46169b1)\n#37 0x00000000046212dc clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x46212dc)\n#38 0x0000000000dc72b1 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0xdc72b1)\n#39 0x0000000000c47e24 main (/opt/compiler-explorer/clang-trunk/bin/clang+0xc47e24)\n#40 0x000074a5bf029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#41 0x000074a5bf029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#42 0x0000000000dc2405 _start (/opt/compiler-explorer/clang-trunk/bin/clang+0xdc2405)\n```",
"author": "rivertale",
"labels": [
"regression",
"crash",
"llvm:transforms"
],
"comments": [
{
"author": "shafik",
"body": "Looks like a regression on trunk: https://godbolt.org/z/d6P7cfxox"
},
{
"author": "dtcxzyw",
"body": "Reduced: https://godbolt.org/z/na9veEo6z\n```\n; bin/opt -passes=\"loop(loop-unroll-full)\" test.ll -S\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i32 @main(i32 %b.promoted) {\nentry:\n br label %for.cond1.preheader\n\nfor.cond1.preheader: ; preds = %for.cond1.preheader, %entry\n %i.045 = phi i32 [ 0, %entry ], [ %inc21, %for.cond1.preheader ]\n %cmp.i.not = icmp eq i32 %i.045, 32\n %conv15 = select i1 %cmp.i.not, i32 0, i32 0\n %sub.3.3 = sub i32 0, 0\n %xor16.3.3 = xor i32 0, 0\n %inc21 = add i32 %i.045, 1\n %exitcond = icmp ne i32 %inc21, 33\n br i1 %exitcond, label %for.cond1.preheader, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.cond1.preheader\n %xor.lcssa.lcssa.lcssa = phi i32 [ %b.promoted, %for.cond1.preheader ]\n ret i32 %xor.lcssa.lcssa.lcssa\n}\n```\n```\nopt: /root/llvm-project/llvm/include/llvm/IR/ValueHandle.h:95: llvm::Value& llvm::ValueHandleBase::operator*() const: Assertion `V && \"Dereferencing deleted ValueHandle\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=loop(loop-unroll-full) <source>\n1.\tRunning pass \"function(loop(loop-unroll-full))\" on module \"<source>\"\n2.\tRunning pass \"loop(loop-unroll-full)\" on function \"main\"\n #0 0x0000000005628878 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5628878)\n #1 0x0000000005626204 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x0000784aa1a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x0000784aa1a969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x0000784aa1a42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x0000784aa1a287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x0000784aa1a2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x0000784aa1a39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x0000000004875d88 llvm::peelLoop(llvm::Loop*, unsigned int, bool, llvm::LoopInfo*, llvm::ScalarEvolution*, llvm::DominatorTree&, llvm::AssumptionCache*, bool, llvm::ValueMap<llvm::Value const*, llvm::WeakTrackingVH, llvm::ValueMapConfig<llvm::Value const*, llvm::sys::SmartMutex<false>>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4875d88)\n #9 0x0000000004468359 tryToUnrollLoop(llvm::Loop*, llvm::DominatorTree&, llvm::LoopInfo*, llvm::ScalarEvolution&, llvm::TargetTransformInfo const&, llvm::AssumptionCache&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::ProfileSummaryInfo*, bool, int, bool, bool, bool, std::optional<unsigned int>, std::optional<unsigned int>, std::optional<bool>, std::optional<bool>, std::optional<bool>, std::optional<bool>, std::optional<bool>, std::optional<unsigned int>, llvm::AAResults*) LoopUnrollPass.cpp:0:0\n#10 0x00000000044691af llvm::LoopFullUnrollPass::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x44691af)\n#11 0x0000000002d9b20e llvm::detail::PassModel<llvm::Loop, llvm::LoopFullUnrollPass, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2d9b20e)\n#12 0x000000000440d346 std::optional<llvm::PreservedAnalyses> llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::runSinglePass<llvm::Loop, std::unique_ptr<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, std::default_delete<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>>>>(llvm::Loop&, std::unique_ptr<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, std::default_delete<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>>>&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&, llvm::PassInstrumentation&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x440d346)\n#13 0x000000000440d4ee llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::runWithoutLoopNestPasses(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x440d4ee)\n#14 0x000000000440e854 llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x440e854)\n#15 0x000000000440f35d llvm::FunctionToLoopPassAdaptor::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x440f35d)\n#16 0x0000000000ea0b8e llvm::detail::PassModel<llvm::Function, llvm::FunctionToLoopPassAdaptor, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xea0b8e)\n#17 0x000000000541eae0 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x541eae0)\n#18 0x0000000000ea19fe 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+0xea19fe)\n#19 0x000000000541eff3 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x541eff3)\n#20 0x0000000000ea084e 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+0xea084e)\n#21 0x000000000541cc10 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x541cc10)\n#22 0x0000000000956bba llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x956bba)\n#23 0x000000000094a38c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x94a38c)\n#24 0x0000784aa1a29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#25 0x0000784aa1a29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#26 0x0000000000941fc5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x941fc5)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
136650
|
https://github.com/llvm/llvm-project/issues/136650
|
miscompilation
|
2e389cb9aae0e9734fc8e16f6ebc6edb392d79a9
| 2025-04-22T03:44:35 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "8abc917fe04140b6c6088a67e0398f637efde808",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": [
[
1480,
1486
]
],
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": [
"InstCombinerImpl::foldLogicOfFCmps"
],
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 8abc917fe04140b6c6088a67e0398f637efde808
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Thu Apr 24 00:12:30 2025 +0800
[InstCombine] Do not fold logical is_finite test (#136851)
This patch disables the fold for logical is_finite test (i.e., `and
(fcmp ord x, 0), (fcmp u* x, inf) -> fcmp o* x, inf`).
It is still possible to allow this fold for several logical cases (e.g.,
`stripSignOnlyFPOps(RHS0)` does not strip any operations). Since this
patch has no real-world impact, I decided to disable this fold for all
logical cases.
Alive2: https://alive2.llvm.org/ce/z/aH4LC7
Closes https://github.com/llvm/llvm-project/issues/136650.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index f1b225c0f238..979a9cbedf2e 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -1480,7 +1480,9 @@ Value *InstCombinerImpl::foldLogicOfFCmps(FCmpInst *LHS, FCmpInst *RHS,
}
}
- if (IsAnd && stripSignOnlyFPOps(LHS0) == stripSignOnlyFPOps(RHS0)) {
+ // This transform is not valid for a logical select.
+ if (!IsLogicalSelect && IsAnd &&
+ stripSignOnlyFPOps(LHS0) == stripSignOnlyFPOps(RHS0)) {
// and (fcmp ord x, 0), (fcmp u* x, inf) -> fcmp o* x, inf
// and (fcmp ord x, 0), (fcmp u* fabs(x), inf) -> fcmp o* x, inf
if (Value *Left = matchIsFiniteTest(Builder, LHS, RHS))
|
[
{
"file": "llvm/test/Transforms/InstCombine/and-fcmp.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "clang_builtin_isnormal_inf_check_fabs_nnan_logical_select",
"test_body": "define i1 @clang_builtin_isnormal_inf_check_fabs_nnan_logical_select(half %x) {\n %copysign.x = call nnan half @llvm.fabs.f16(half %x)\n %ord = fcmp ord half %x, 0xH0000\n %cmp = fcmp uge half %copysign.x, 0xH7C00\n %and = select i1 %ord, i1 %cmp, i1 false\n ret i1 %and\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare half @llvm.fabs.f16(half) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "clang_builtin_isnormal_inf_check_copysign_logical_select",
"test_body": "define i1 @clang_builtin_isnormal_inf_check_copysign_logical_select(half %x, half %y) {\n %copysign.x = call half @llvm.copysign.f16(half %x, half %y)\n %ord = fcmp ord half %x, 0xH0000\n %cmp = fcmp uge half %copysign.x, 0xH7C00\n %and = select i1 %ord, i1 %cmp, i1 false\n ret i1 %and\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare half @llvm.copysign.f16(half, half) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnormal_logical_select_0",
"test_body": "define i1 @isnormal_logical_select_0(half %x) {\n %fabs.x = call half @llvm.fabs.f16(half %x)\n %ord = fcmp ord half %fabs.x, 0xH0000\n %cmp.inf = fcmp uge half %fabs.x, 0xH7C00\n %and = select i1 %ord, i1 %cmp.inf, i1 false\n ret i1 %and\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare half @llvm.fabs.f16(half) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "clang_builtin_isnormal_inf_check_copysign",
"test_body": "define i1 @clang_builtin_isnormal_inf_check_copysign(half %x, half %y) {\n %copysign.x = call half @llvm.copysign.f16(half %x, half %y)\n %ord = fcmp ord half %x, 0xH0000\n %cmp = fcmp uge half %copysign.x, 0xH7C00\n %and = and i1 %ord, %cmp\n ret i1 %and\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare half @llvm.copysign.f16(half, half) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstCombine] Poison safety violation in `foldLogicOfFCmps`",
"body": "Reproducer: https://alive2.llvm.org/ce/z/Qcvvgi\n```\n----------------------------------------\ndefine i1 @src(half %x, half %y) {\n#0:\n %copysign.x = copysign half %x, %y\n %ord = fcmp ord half %x, 0x0000\n %cmp = fcmp uge half %copysign.x, 0x7c00\n %#1 = select i1 %ord, i1 %cmp, i1 0\n ret i1 %#1\n}\n=>\ndefine i1 @src(half %x, half %y) nofree willreturn memory(none) {\n#0:\n %copysign.x = copysign half %x, %y\n %#1 = fcmp oeq half %copysign.x, 0x7c00\n ret i1 %#1\n}\nTransformation doesn't verify!\n\nERROR: Target is more poisonous than source\n\nExample:\nhalf %x = #x7c02 (SNaN)\nhalf %y = poison\n\nSource:\nhalf %copysign.x = poison\ni1 %ord = #x0 (0)\ni1 %cmp = poison\ni1 %#1 = #x0 (0)\n\nTarget:\nhalf %copysign.x = poison\ni1 %#1 = poison\nSource value: #x0 (0)\nTarget value: poison\n\nSummary:\n 0 correct transformations\n 1 incorrect transformations\n 0 failed-to-prove transformations\n 0 Alive2 errors\n```",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
96294
|
https://github.com/llvm/llvm-project/issues/96294
|
crash
|
5262865aac683b72f3e66de7a122e0c455ab6b9b
| 2024-06-21T10:15:21 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "fdb9f96fa2a926425bdf8315048db7623d63547d",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
[
6723,
6736
],
[
6771,
6776
],
[
6781,
6788
]
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"LoopVectorizationCostModel::collectValuesToIgnore"
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit fdb9f96fa2a926425bdf8315048db7623d63547d
Author: Florian Hahn <flo@fhahn.com>
Date: Sun Aug 4 20:54:25 2024 +0100
[LV] Consider earlier stores to invariant reduction address as dead.
For invariant stores to an address of a reduction, only the latest store
will be generated outside the loop. Consider earlier stores as dead.
This fixes a difference between the legacy and VPlan-based cost model.
Fixes https://github.com/llvm/llvm-project/issues/96294.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 40d10395de17..1eca9b10fad5 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -6723,14 +6723,18 @@ void LoopVectorizationCostModel::collectValuesToIgnore() {
return RequiresScalarEpilogue &&
!TheLoop->contains(cast<Instruction>(U)->getParent());
};
+ MapVector<Value *, SmallVector<Value *>> DeadInvariantStoreOps;
for (BasicBlock *BB : TheLoop->blocks())
for (Instruction &I : *BB) {
// Find all stores to invariant variables. Since they are going to sink
// outside the loop we do not need calculate cost for them.
StoreInst *SI;
if ((SI = dyn_cast<StoreInst>(&I)) &&
- Legal->isInvariantAddressOfReduction(SI->getPointerOperand()))
+ Legal->isInvariantAddressOfReduction(SI->getPointerOperand())) {
ValuesToIgnore.insert(&I);
+ auto I = DeadInvariantStoreOps.insert({SI->getPointerOperand(), {}});
+ I.first->second.push_back(SI->getValueOperand());
+ }
if (VecValuesToIgnore.contains(&I) || ValuesToIgnore.contains(&I))
continue;
@@ -6771,6 +6775,10 @@ void LoopVectorizationCostModel::collectValuesToIgnore() {
DeadInterleavePointerOps.append(Op->op_begin(), Op->op_end());
}
+ for (const auto &[_, Ops] : DeadInvariantStoreOps) {
+ for (Value *Op : ArrayRef(Ops).drop_back())
+ DeadOps.push_back(Op);
+ }
// Mark ops that would be trivially dead and are only used by ignored
// instructions as free.
BasicBlock *Header = TheLoop->getHeader();
@@ -6781,8 +6789,8 @@ void LoopVectorizationCostModel::collectValuesToIgnore() {
(isa<PHINode>(Op) && Op->getParent() == Header) ||
!wouldInstructionBeTriviallyDead(Op, TLI) ||
any_of(Op->users(), [this, IsLiveOutDead](User *U) {
- return !VecValuesToIgnore.contains(U) && ValuesToIgnore.contains(U) &&
- !IsLiveOutDead(U);
+ return !VecValuesToIgnore.contains(U) &&
+ !ValuesToIgnore.contains(U) && !IsLiveOutDead(U);
}))
continue;
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/X86/cost-model.ll",
"commands": [
"opt < %s -passes=loop-vectorize -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7-avx -S"
],
"tests": [
{
"test_name": "reduction_store",
"test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-apple-macosx10.8.0\"\n\ndefine void @reduction_store(ptr noalias %src, ptr %dst, i1 %x) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %red = phi i32 [ 0, %entry ], [ %red.next, %loop ]\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %gep.src = getelementptr inbounds i32, ptr %src, i32 %iv\n %l = load i32, ptr %gep.src, align 4\n %l.and = and i32 %l, 3\n store i32 %l.and, ptr %dst, align 4\n %x.ext = zext i1 %x to i64\n %lshr = lshr i64 %x.ext, 12\n %t = trunc i64 %lshr to i32\n %red.next = and i32 %red, %t\n store i32 %red.next, ptr %dst, align 4\n %iv.next = add i32 %iv, 1\n %ec = icmp eq i32 %iv, 29\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { \"target-cpu\"=\"znver3\" }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10353: bool llvm::LoopVectorizePass::processLoop(llvm::Loop*): Assertion `VF.Width == Width && \"VPlan cost model and legacy cost model disagreed\"' failed.",
"body": "[calcc-0ebd65.c.gz](https://github.com/user-attachments/files/15926158/calcc-0ebd65.c.gz)\r\n[calcc-0ebd65.sh.gz](https://github.com/user-attachments/files/15926159/calcc-0ebd65.sh.gz)\r\n\r\nStack backtrace is \r\n\r\n#11 0x0000000003adfddd llvm::LoopVectorizePass::processLoop(llvm::Loop*) /home/dcb40b/llvm/trunk/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10353:9\r\n#12 0x0000000003ae347f llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) /home/dcb40b/llvm/trunk/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10446:27\r\n#13 0x0000000003ae4382 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/dcb40b/llvm/trunk/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10486:5\r\n#14 0x00000000034fbd6d llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/dcb40b/llvm/trunk/llvm/include/llvm/IR/PassManagerInternal.h:91:3\r\n#15 0x0000000001ae5b21 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/dcb40b/llvm/trunk/llvm/include/llvm/IR/PassManagerImpl.h:53:18\r\n",
"author": "dcb314",
"labels": [
"vectorizers",
"crash-on-valid"
],
"comments": [
{
"author": "dcb314",
"body": "The crash first seems to occur sometime between git hash fd88089151e66a4cb1d90aaa224e4cb4e7a748f4 from yesterday 20240620\r\nand 225d8fc8eb24fb797154c1ef6dcbe5ba033142da from today,\r\nwhich is 134 commits.\r\n"
},
{
"author": "fhahn",
"body": "Thanks for the report, caused by https://github.com/llvm/llvm-project/pull/92555 which has been reverted for now. I'll add a reduced test based on the reproducer."
},
{
"author": "fhahn",
"body": "https://github.com/llvm/llvm-project/pull/92555 has been recommitted with a fix. Please let me know if you see any other issues!"
},
{
"author": "dcb314",
"body": "It has come back:\r\n\r\nclang: /home/dcb40b/llvm/trunk/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10377: bool llvm::LoopVectorizePass::processLoop(llvm::Loop*): Assertion `VF.Width == Width && \"VPlan cost model and legacy cost model disagreed\"' failed.\r\n\r\n[in-4e39b8.sh.gz](https://github.com/user-attachments/files/16445872/in-4e39b8.sh.gz)\r\n[Uploading in-4e39b8.c.gz…]()\r\n"
},
{
"author": "dcb314",
"body": "Seems to have come back sometime between d99efd53f5103df4db517f499fcdd26cd3b080a3\r\n(dated 20240710) and 4710e0f498cb661ca17c99cb174616102fcad923, dated 20240711.\r\n\r\n"
},
{
"author": "fhahn",
"body": "@dcb314 it looks like there has been an issue with uploading the `.c` file. Could you re-upload it again?"
},
{
"author": "dcb314",
"body": "My apologies for the failed upload.\r\nHere is another try:\r\n\r\n[in-4e39b8.c.gz](https://github.com/user-attachments/files/16455342/in-4e39b8.c.gz)\r\n"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
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/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": [
[
370,
384
],
[
395,
401
],
[
410,
436
]
],
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": [
"processSwitch"
],
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.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",
"lli_expected_out": null,
"additional_args": 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
}
| null |
147218
|
https://github.com/llvm/llvm-project/issues/147218
|
crash
|
6daf2b956d0b805cb5b617170d137fecc33b062c
| 2025-07-06T23:28:37 |
[
"llvm/test/Transforms/VectorCombine"
] |
{
"fix_commit": "1113224f9444f5c2cf69784cd3c110b8dd560897",
"components": [
"VectorCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [
[
563,
569
]
],
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [
"translateExtract"
],
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 1113224f9444f5c2cf69784cd3c110b8dd560897
Author: Florian Hahn <flo@fhahn.com>
Date: Mon Jul 7 13:23:39 2025 +0200
[VectorCombine] Account for IRBuilder simplification in translateExt.
After https://github.com/llvm/llvm-project/pull/146350,
CreateExtractElement may return a folded value and not create an
ExtractElement instruction.
Replace cast with dyn_cast. Note that the function returns nullptr
already earlier if the extract may be constant folded.
Fixes https://github.com/llvm/llvm-project/issues/147218
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index b9ce20ebd3e6..fe8d74c43dfd 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -563,7 +563,8 @@ static ExtractElementInst *translateExtract(ExtractElementInst *ExtElt,
Value *Shuf = createShiftShuffle(X, cast<ConstantInt>(C)->getZExtValue(),
NewIndex, Builder);
- return cast<ExtractElementInst>(Builder.CreateExtractElement(Shuf, NewIndex));
+ return dyn_cast<ExtractElementInst>(
+ Builder.CreateExtractElement(Shuf, NewIndex));
}
/// Try to reduce extract element costs by converting scalar compares to vector
|
[
{
"file": "llvm/test/Transforms/VectorCombine/X86/extract-binop.ll",
"commands": [
"opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=SSE2",
"opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=AVX2"
],
"tests": [
{
"test_name": "instsimplify_folder_crash",
"test_body": "define i64 @instsimplify_folder_crash(<4 x i64> %in) {\nentry:\n %shuffle.1 = shufflevector <4 x i64> %in, <4 x i64> zeroinitializer, <4 x i32> <i32 4, i32 5, i32 2, i32 3>\n %e.0 = extractelement <4 x i64> zeroinitializer, i64 0\n %e.1 = extractelement <4 x i64> %shuffle.1, i64 1\n %shift = shufflevector <4 x i64> %shuffle.1, <4 x i64> poison, <4 x i32> <i32 1, i32 poison, i32 poison, i32 poison>\n %or = or i64 %e.1, %e.0\n ret i64 %or\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "constant_fold_crash_commute",
"test_body": "define float @constant_fold_crash_commute(<4 x float> %x) {\n %a = extractelement <4 x float> <float 1.600000e+01, float 1.700000e+01, float 1.800000e+01, float 1.900000e+01>, i32 3\n %b = extractelement <4 x float> %x, i32 1\n %c = fadd float %b, %a\n ret float %c\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "recent \"cast<Ty>() argument of incompatible type!\" failure in vector-combine",
"body": "Bisected to 777d6b5de90b7e0d1ceaa1424c6da4590539c007 (#146350)\nConfirmed still present as of 01c97b4953e87ae455bd4c41e3de3f0f0f29c61c\n\nhttps://godbolt.org/z/7qhKaavjs\nhttps://godbolt.org/z/EdP1T5nxM\n\n```\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-unknown\"\n\ndefine i64 @_Z2akv(<4 x i64> %call.i.i) {\nentry:\n %0 = bitcast <4 x i64> %call.i.i to <8 x i32>\n %insert.i.i = shufflevector <8 x i32> %0, <8 x i32> zeroinitializer, <8 x i32> <i32 8, i32 9, i32 10, i32 11, i32 4, i32 5, i32 6, i32 7>\n %bc3.i = bitcast <8 x i32> %insert.i.i to <4 x i64>\n %1 = extractelement <4 x i64> zeroinitializer, i64 0\n %2 = extractelement <4 x i64> %bc3.i, i64 1\n %add.1.i.i = or i64 %2, %1\n ret i64 %add.1.i.i\n}\n```\n\n```\nopt: /root/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From*) [with To = llvm::ExtractElementInst; From = llvm::Value]: Assertion `isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=vector-combine <source>\n1.\tRunning pass \"function(vector-combine)\" on module \"<source>\"\n2.\tRunning pass \"vector-combine\" on function \"_Z2akv\"\n #0 0x000000000560a898 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x560a898)\n #1 0x0000000005607774 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x000073ae71e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x000073ae71e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x000073ae71e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x000073ae71e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x000073ae71e2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x000073ae71e39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x0000000003563e41 (anonymous namespace)::VectorCombine::foldExtractExtract(llvm::Instruction&) (.part.0) VectorCombine.cpp:0:0\n #9 0x000000000357e963 (anonymous namespace)::VectorCombine::run()::'lambda'(llvm::Instruction&)::operator()(llvm::Instruction&) const (.isra.0) VectorCombine.cpp:0:0\n#10 0x000000000357f65b llvm::VectorCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x357f65b)\n#11 0x0000000002d6387e llvm::detail::PassModel<llvm::Function, llvm::VectorCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2d6387e)\n#12 0x0000000005402ba1 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5402ba1)\n#13 0x0000000000ea794e 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+0xea794e)\n#14 0x0000000005403074 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5403074)\n#15 0x0000000000ea677e 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+0xea677e)\n#16 0x0000000005400c41 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5400c41)\n#17 0x0000000000961fda llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x961fda)\n#18 0x000000000095576c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x95576c)\n#19 0x000073ae71e29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#20 0x000073ae71e29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#21 0x000000000094d355 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x94d355)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```\n\n\n\n",
"author": "gregbedwell",
"labels": [
"crash-on-valid",
"llvm::vectorcombine"
],
"comments": [
{
"author": "RKSimon",
"body": "```\nVECTORCOMBINE on _Z2akv\nVC: Visiting: %0 = bitcast <4 x i64> %call.i.i to <8 x i32>\nVC: Visiting: %insert.i.i = shufflevector <8 x i32> %0, <8 x i32> zeroinitializer, <8 x i32> <i32 8, i32 9, i32 10, i32 11, i32 4, i32 5, i32 6, i32 7>\nVC: Visiting: %bc3.i = bitcast <8 x i32> %insert.i.i to <4 x i64>\nFound a bitcasted shuffle: %bc3.i = bitcast <8 x i32> %insert.i.i to <4 x i64>\n OldCost: 0 vs NewCost: 0\nVC: Replacing: %bc3.i = bitcast <8 x i32> %insert.i.i to <4 x i64>\n With: %1 = shufflevector <4 x i64> %call.i.i, <4 x i64> zeroinitializer, <4 x i32> <i32 4, i32 5, i32 2, i32 3>\nADD: %3 = extractelement <4 x i64> %bc3.i, i64 1\nADD: %bc3.i = shufflevector <4 x i64> %call.i.i, <4 x i64> zeroinitializer, <4 x i32> <i32 4, i32 5, i32 2, i32 3>\nADD: %1 = bitcast <8 x i32> %insert.i.i to <4 x i64>\nVC: Visiting: %2 = extractelement <4 x i64> zeroinitializer, i64 0\nVC: Visiting: %3 = extractelement <4 x i64> %bc3.i, i64 1\nVC: Visiting: %add.1.i.i = or i64 %3, %2\nopt: /root/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From*) [with To = llvm::ExtractElementInst; From = llvm::Value]: Assertion `isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=vector-combine -debug <source>\n1.\tRunning pass \"function(vector-combine)\" on module \"<source>\"\n2.\tRunning pass \"vector-combine\" on function \"_Z2akv\"\n #0 0x000000000560a358 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x560a358)\n #1 0x0000000005607234 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007ec36bc42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007ec36bc969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007ec36bc42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007ec36bc287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x00007ec36bc2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x00007ec36bc39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x0000000003563871 (anonymous namespace)::VectorCombine::foldExtractExtract(llvm::Instruction&) (.part.0) VectorCombine.cpp:0:0\n #9 0x000000000357e393 (anonymous namespace)::VectorCombine::run()::'lambda'(llvm::Instruction&)::operator()(llvm::Instruction&) const (.isra.0) VectorCombine.cpp:0:0\n#10 0x000000000357f08b llvm::VectorCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x357f08b)\n#11 0x0000000002d635ce llvm::detail::PassModel<llvm::Function, llvm::VectorCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2d635ce)\n#12 0x0000000005402641 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5402641)\n#13 0x0000000000ea794e 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+0xea794e)\n#14 0x0000000005402b14 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5402b14)\n#15 0x0000000000ea677e 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+0xea677e)\n#16 0x00000000054006e1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x54006e1)\n#17 0x0000000000961fda llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x961fda)\n#18 0x000000000095576c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x95576c)\n#19 0x00007ec36bc29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#20 0x00007ec36bc29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#21 0x000000000094d355 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x94d355)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
80597
|
https://github.com/llvm/llvm-project/issues/80597
|
crash
|
8f4d8945536e9fc45db0e349b91c2f4b3a9cae29
| 2024-02-04T14:06:35 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "cb8d83a77c25e529f58eba17bb1ec76069a04e90",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": [
[
802,
807
]
],
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": [
"InstCombinerImpl::SimplifyDemandedUseBits"
],
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit cb8d83a77c25e529f58eba17bb1ec76069a04e90
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Tue Feb 6 01:29:38 2024 +0800
[InstCombine] Fix assertion failure in issue80597 (#80614)
The assertion in #80597 failed when we were trying to compute known bits
of a value in an unreachable BB.
https://github.com/llvm/llvm-project/blob/859b09da08c2a47026ba0a7d2f21b7dca705864d/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp#L749-L810
In this case, `SignBits` is 30 (deduced from instr info), but `Known` is
`10000101010111010011110101000?0?00000000000000000000000000000000`
(deduced from dom cond). Setting high bits of `lshr Known, 1` will lead
to conflict.
This patch masks out high bits of `Known.Zero` to address this problem.
Fixes #80597.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index a8a5f9831e15..79873a9b4cbb 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -802,6 +802,9 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
return InsertNewInstWith(LShr, I->getIterator());
} else if (Known.One[BitWidth-ShiftAmt-1]) { // New bits are known one.
Known.One |= HighBits;
+ // SignBits may be out-of-sync with Known.countMinSignBits(). Mask out
+ // high bits of Known.Zero to avoid conflicts.
+ Known.Zero &= ~HighBits;
}
} else {
computeKnownBits(I, Known, Depth, CxtI);
|
[
{
"file": "llvm/test/Transforms/InstCombine/pr80597.ll",
"commands": [
"opt -S -passes=instcombine < %s"
],
"tests": [
{
"test_name": "pr80597",
"test_body": "define i64 @pr80597(i1 %cond) {\nentry:\n %add = select i1 %cond, i64 0, i64 4294967293\n %add8 = shl i64 %add, 32\n %sext1 = add i64 %add8, 8836839514384105472\n %cmp = icmp ult i64 %sext1, -34359738368\n br i1 %cmp, label %if.then, label %if.else\n\nif.else: ; preds = %entry\n %sext2 = or i64 %add8, 8836839522974040064\n %ashr = ashr i64 %sext2, 1\n ret i64 %ashr\n\nif.then: ; preds = %entry\n ret i64 0\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "llvm crash: Assertion `!LHSKnown.hasConflict() && \"Bits known to be one AND zero?\"' failed.",
"body": "llvm crashes in `instcombine`\r\n\r\nBisected to d77067d08a3f56dc2d0e6c95bd2852c943df743a, which was committed by @nikic \r\n\r\nCompiler explorer: https://godbolt.org/z/e4jrvf5Wr\r\n\r\n```console\r\n% cat reduced.ll\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine i32 @main(i1 %.b.i) {\r\nentry:\r\n %add.i = select i1 %.b.i, i64 0, i64 4294967293\r\n %add8.i = shl i64 %add.i, 32\r\n %sext.2.i = add i64 %add8.i, 8836839514384105472\r\n %cmp11.2.i = icmp ult i64 %sext.2.i, -34359738368\r\n br i1 %cmp11.2.i, label %return.loopexit.i, label %for.inc.2.i\r\n\r\nfor.inc.2.i: ; preds = %entry\r\n %sext.4.i = or i64 %add8.i, 8836839522974040064\r\n %conv9.4.i = ashr i64 %sext.4.i, 1\r\n %cmp11.4.i = icmp ult i64 %conv9.4.i, 0\r\n br i1 %cmp11.4.i, label %return.loopexit.i, label %return.loopexit.i\r\n\r\nreturn.loopexit.i: ; preds = %for.inc.2.i, %for.inc.2.i, %entry\r\n ret i32 0\r\n}\r\n%\r\n% opt -disable-output -passes=instcombine reduced.ll\r\nopt: /tmp/tmpzoi34eaf/tmporhhh5ti/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp:246: llvm::Value* llvm::InstCombinerImpl::SimplifyDemandedUseBits(llvm::Value*, llvm::APInt, llvm::KnownBits&, unsigned int, llvm::Instruction*): Assertion `!LHSKnown.hasConflict() && \"Bits known to be one AND zero?\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /zdata/shaoli/compilers/ccbuilder-compilers/clang-d77067d08a3f56dc2d0e6c95bd2852c943df743a/bin/opt -disable-output -passes=instcombine reduced.ll\r\n #0 0x00007f7698f4558f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-d77067d08a3f56dc2d0e6c95bd2852c943df743a/bin/../lib/libLLVM-18git.so+0x93858f)\r\n #1 0x00007f7698f42ab4 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007f7698222090 (/lib/x86_64-linux-gnu/libc.so.6+0x43090)\r\n #3 0x00007f769822200b raise /build/glibc-wuryBv/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #4 0x00007f7698201859 abort /build/glibc-wuryBv/glibc-2.31/stdlib/abort.c:81:7\r\n #5 0x00007f7698201729 get_sysdep_segment_value /build/glibc-wuryBv/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #6 0x00007f7698201729 _nl_load_domain /build/glibc-wuryBv/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #7 0x00007f7698212fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #8 0x00007f769a44445d llvm::InstCombinerImpl::SimplifyDemandedUseBits(llvm::Value*, llvm::APInt, llvm::KnownBits&, unsigned int, llvm::Instruction*) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-d77067d08a3f56dc2d0e6c95bd2852c943df743a/bin/../lib/libLLVM-18git.so+0x1e3745d)\r\n #9 0x00007f769a444d25 llvm::InstCombinerImpl::SimplifyDemandedInstructionBits(llvm::Instruction&, llvm::KnownBits&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-d77067d08a3f56dc2d0e6c95bd2852c943df743a/bin/../lib/libLLVM-18git.so+0x1e37d25)\r\n#10 0x00007f769a4459c5 llvm::InstCombinerImpl::SimplifyDemandedInstructionBits(llvm::Instruction&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-d77067d08a3f56dc2d0e6c95bd2852c943df743a/bin/../lib/libLLVM-18git.so+0x1e389c5)\r\n#11 0x00007f769a38cdc3 llvm::InstCombinerImpl::visitOr(llvm::BinaryOperator&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-d77067d08a3f56dc2d0e6c95bd2852c943df743a/bin/../lib/libLLVM-18git.so+0x1d7fdc3)\r\n#12 0x00007f769a3537b1 llvm::InstCombinerImpl::run() (/zdata/shaoli/compilers/ccbuilder-compilers/clang-d77067d08a3f56dc2d0e6c95bd2852c943df743a/bin/../lib/libLLVM-18git.so+0x1d467b1)\r\n#13 0x00007f769a355002 combineInstructionsOverFunction(llvm::Function&, llvm::InstructionWorklist&, llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::ProfileSummaryInfo*, llvm::LoopInfo*, llvm::InstCombineOptions const&) (.isra.0) InstructionCombining.cpp:0:0\r\n#14 0x00007f769a355fbb llvm::InstCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-d77067d08a3f56dc2d0e6c95bd2852c943df743a/bin/../lib/libLLVM-18git.so+0x1d48fbb)\r\n#15 0x00007f769bea5916 llvm::detail::PassModel<llvm::Function, llvm::InstCombinePass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-d77067d08a3f56dc2d0e6c95bd2852c943df743a/bin/../lib/libLLVM-18git.so+0x3898916)\r\n#16 0x00007f769916239d llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-d77067d08a3f56dc2d0e6c95bd2852c943df743a/bin/../lib/libLLVM-18git.so+0xb5539d)\r\n#17 0x00007f769be9e506 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-d77067d08a3f56dc2d0e6c95bd2852c943df743a/bin/../lib/libLLVM-18git.so+0x3891506)\r\n#18 0x00007f7699160c2d llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-d77067d08a3f56dc2d0e6c95bd2852c943df743a/bin/../lib/libLLVM-18git.so+0xb53c2d)\r\n#19 0x00007f769bea5556 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-d77067d08a3f56dc2d0e6c95bd2852c943df743a/bin/../lib/libLLVM-18git.so+0x3898556)\r\n#20 0x00007f769915eb5d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-d77067d08a3f56dc2d0e6c95bd2852c943df743a/bin/../lib/libLLVM-18git.so+0xb51b5d)\r\n#21 0x000055c7b779e395 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-d77067d08a3f56dc2d0e6c95bd2852c943df743a/bin/opt+0x26395)\r\n#22 0x000055c7b7791e8a main (/zdata/shaoli/compilers/ccbuilder-compilers/clang-d77067d08a3f56dc2d0e6c95bd2852c943df743a/bin/opt+0x19e8a)\r\n#23 0x00007f7698203083 __libc_start_main /build/glibc-wuryBv/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#24 0x000055c7b7792a5e _start (/zdata/shaoli/compilers/ccbuilder-compilers/clang-d77067d08a3f56dc2d0e6c95bd2852c943df743a/bin/opt+0x1aa5e)\r\n[1] 880216 abort -disable-output -passes=instcombine reduced.ll\r\n%\r\n```\r\n\r\nThe above test case was reduced from\r\n```C\r\nlong a, i;\r\nstatic long b = -4;\r\nchar c;\r\nint d;\r\nstatic int *e = &d, *h = &d;\r\nstatic long *f = &b, *g = &b;\r\nint j() {\r\n for (; a;) {\r\n c = 0;\r\n for (; c <= 6; c++) {\r\n unsigned long k = 1;\r\n i = -8;\r\n *h = i >= (int)k + (int)*f + c + 2057487030 + k;\r\n if (*e)\r\n break;\r\n }\r\n return 0;\r\n }\r\n *g = 0;\r\n return 0;\r\n}\r\nint main() { j(); }\r\n```",
"author": "shao-hua-li",
"labels": [
"release:backport",
"llvm:instcombine",
"crash-on-valid"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Minimal reproduction: https://godbolt.org/z/5bzaqP65P"
},
{
"author": "dtcxzyw",
"body": "Reopen this issue to backport the fix to the 18.X release.\r\n"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
91127
|
https://github.com/llvm/llvm-project/issues/91127
|
miscompilation
|
30367cb5982dfdab2655401f020711311e7d78b9
| 2024-05-05T15:35:24 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "d3dad7a74be50d90754bf5c072e1a2330e92712c",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": [
[
1510,
1515
]
],
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": [
"InstCombinerImpl::foldICmpTruncWithTruncOrExt"
],
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit d3dad7a74be50d90754bf5c072e1a2330e92712c
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Mon May 6 16:30:07 2024 +0800
[InstCombine] Fix miscompilation caused by #90436 (#91133)
Proof: https://alive2.llvm.org/ce/z/iRnJ4i
Fixes https://github.com/llvm/llvm-project/issues/91127.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index c60a290ce72e..7092fb5e509b 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -1510,6 +1510,7 @@ InstCombinerImpl::foldICmpTruncWithTruncOrExt(ICmpInst &Cmp,
std::swap(X, Y);
Pred = Cmp.getSwappedPredicate(Pred);
}
+ YIsSExt = !(NoWrapFlags & TruncInst::NoUnsignedWrap);
}
// Try to match icmp (trunc nuw X), (zext Y)
else if (!Cmp.isSigned() &&
|
[
{
"file": "llvm/test/Transforms/InstCombine/icmp-of-trunc-ext.ll",
"commands": [
"opt -S -passes=instcombine < %s"
],
"tests": [
{
"test_name": "trunc_equality_both_sext",
"test_body": "define i1 @trunc_equality_both_sext(i32 %x, i8 %y) {\n %xt = trunc nuw nsw i32 %x to i16\n %ye = sext i8 %y to i16\n %c = icmp ne i16 %xt, %ye\n ret i1 %c\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_slt_nuw",
"test_body": "define i1 @test_slt_nuw(i32 %x, i16 %y) {\n %conv1 = trunc nuw nsw i32 %x to i8\n %conv2 = trunc nuw nsw i16 %y to i8\n %cond = icmp slt i8 %conv1, %conv2\n ret i1 %cond\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_slt",
"test_body": "define i1 @test_slt(i32 %x, i16 %y) {\n %conv1 = trunc nsw i32 %x to i8\n %conv2 = trunc nsw i16 %y to i8\n %cond = icmp slt i8 %conv1, %conv2\n ret i1 %cond\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_ult_nuw",
"test_body": "define i1 @test_ult_nuw(i32 %x, i16 %y) {\n %conv1 = trunc nuw nsw i32 %x to i8\n %conv2 = trunc nuw nsw i16 %y to i8\n %cond = icmp ult i8 %conv1, %conv2\n ret i1 %cond\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_ult",
"test_body": "define i1 @test_ult(i32 %x, i16 %y) {\n %conv1 = trunc nsw i32 %x to i8\n %conv2 = trunc nsw i16 %y to i8\n %cond = icmp ult i8 %conv1, %conv2\n ret i1 %cond\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_eq1",
"test_body": "define i1 @test_eq1(i32 %x, i16 %y) {\n %conv1 = trunc nsw i32 %x to i8\n %conv2 = trunc nsw i16 %y to i8\n %cond = icmp eq i8 %conv1, %conv2\n ret i1 %cond\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_eq2",
"test_body": "define i1 @test_eq2(i32 %x, i16 %y) {\n %conv1 = trunc nsw i32 %x to i8\n %conv2 = trunc nsw i16 %y to i8\n %cond = icmp eq i8 %conv2, %conv1\n ret i1 %cond\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstCombine] Miscompilation which converts `icmp eq (trunc nsw i64 X), (trunc nsw i32 Y)` into `icmp eq (zext i32 Y), X`",
"body": "Reduced test case: https://alive2.llvm.org/ce/z/MLgA5x\r\n```\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine i32 @src() {\r\nentry:\r\n br label %for.cond\r\n\r\nfor.cond: ; preds = %if.end, %entry\r\n %storemerge = phi i32 [ 3, %entry ], [ %dec, %if.end ]\r\n %h = phi i32 [ 1, %entry ], [ %hres, %if.end ]\r\n %e = phi i32 [ 0, %entry ], [ -1, %if.end ]\r\n %tobool.not = icmp eq i32 %storemerge, 0\r\n br i1 %tobool.not, label %for.end9, label %for.body\r\n\r\nfor.body: ; preds = %for.cond\r\n %cmp = icmp eq i32 %h, 5\r\n %conv1 = zext i1 %cmp to i64\r\n %conv2 = sext i32 %e to i64\r\n %cond.i = call i64 @llvm.umax.i64(i64 %conv1, i64 %conv2)\r\n %conv3 = trunc nsw i64 %cond.i to i16\r\n %conv4 = trunc nsw i32 %e to i16\r\n %sub.i = sub i16 %conv3, %conv4\r\n %tobool6.not = icmp eq i16 %sub.i, 0\r\n br i1 %tobool6.not, label %if.end, label %if.then\r\n\r\nif.then: ; preds = %for.body\r\n br label %if.end\r\n\r\nif.end: ; preds = %if.then, %for.body\r\n %hres = phi i32 [ 0, %if.then ], [ %h, %for.body ]\r\n %dec = add nsw i32 %storemerge, -1\r\n br label %for.cond\r\n\r\nfor.end9: ; preds = %for.cond\r\n ret i32 %h\r\n}\r\n\r\ndefine i32 @tgt() {\r\nentry:\r\n br label %for.cond\r\n\r\nfor.cond: ; preds = %if.end, %entry\r\n %storemerge = phi i32 [ 3, %entry ], [ %dec, %if.end ]\r\n %h = phi i32 [ 1, %entry ], [ %hres, %if.end ]\r\n %e = phi i32 [ 0, %entry ], [ -1, %if.end ]\r\n %tobool.not = icmp eq i32 %storemerge, 0\r\n br i1 %tobool.not, label %for.end9, label %for.body\r\n\r\nfor.body: ; preds = %for.cond\r\n %cmp = icmp eq i32 %h, 5\r\n %conv1 = zext i1 %cmp to i64\r\n %conv2 = sext i32 %e to i64\r\n %cond.i = call i64 @llvm.umax.i64(i64 %conv1, i64 %conv2)\r\n %0 = zext i32 %e to i64\r\n %tobool6.not = icmp eq i64 %cond.i, %0\r\n br i1 %tobool6.not, label %if.end, label %if.then\r\n\r\nif.then: ; preds = %for.body\r\n br label %if.end\r\n\r\nif.end: ; preds = %if.then, %for.body\r\n %hres = phi i32 [ 0, %if.then ], [ %h, %for.body ]\r\n %dec = add nsw i32 %storemerge, -1\r\n br label %for.cond\r\n\r\nfor.end9: ; preds = %for.cond\r\n ret i32 %h\r\n}\r\n```\r\n\r\nllvm version: de9b386f84b58ad0ffc12e221bc6d9161ca5b62d",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Reduced test case: https://alive2.llvm.org/ce/z/ndR8PQ\r\n```\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine i1 @src(i64 %x, i32 %y) {\r\n %conv1 = trunc nsw i64 %x to i16\r\n %conv2 = trunc nsw i32 %y to i16\r\n %cond = icmp eq i16 %conv1, %conv2\r\n ret i1 %cond\r\n}\r\n\r\ndefine i1 @tgt(i64 %x, i32 %y) {\r\n %1 = zext i32 %y to i64\r\n %cond = icmp eq i64 %1, %x\r\n ret i1 %cond\r\n}\r\n```\r\n\r\nIt should be caused by https://github.com/llvm/llvm-project/pull/90436.\r\n\r\nI will post a fix later. cc @nikic\r\n"
},
{
"author": "dtcxzyw",
"body": "POC without DataLayout:\r\n```\r\ndefine i1 @test_eq(i32 %x, i16 %y) {\r\n %conv1 = trunc nsw i32 %x to i8\r\n %conv2 = trunc nsw i16 %y to i8\r\n %cond = icmp eq i8 %conv1, %conv2\r\n ret i1 %cond\r\n}\r\n\r\ndefine i1 @test_ult(i32 %x, i16 %y) {\r\n %conv1 = trunc nsw i32 %x to i8\r\n %conv2 = trunc nsw i16 %y to i8\r\n %cond = icmp ult i8 %conv1, %conv2\r\n ret i1 %cond\r\n}\r\n\r\ndefine i1 @test_slt(i32 %x, i16 %y) {\r\n %conv1 = trunc nsw i32 %x to i8\r\n %conv2 = trunc nsw i16 %y to i8\r\n %cond = icmp slt i8 %conv1, %conv2\r\n ret i1 %cond\r\n}\r\n```"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
99701
|
https://github.com/llvm/llvm-project/issues/99701
|
crash
|
9a258664024d12a06ba8eb9344e270a9bb5f5d87
| 2024-07-19T20:27:53 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "ba8126b6fef79bd344a247f6291aaec7b67bdff0",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
[
137,
142
],
[
6681,
6686
],
[
6690,
6695
],
[
6717,
6722
]
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"LoopVectorizationCostModel::collectValuesToIgnore"
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit ba8126b6fef79bd344a247f6291aaec7b67bdff0
Author: Florian Hahn <flo@fhahn.com>
Date: Wed Jul 24 09:31:32 2024 +0100
[LV] Mark dead instructions in loop as free.
Update collectValuesToIgnore to also ignore dead instructions in the
loop. Such instructions will be removed by VPlan-based DCE and won't be
considered by the VPlan-based cost model.
This closes a gap between the legacy and VPlan-based cost model. In
practice with the default pipelines, there shouldn't be any dead
instructions in loops reaching LoopVectorize, but it is easy to generate
such cases by hand or automatically via fuzzers.
Fixes https://github.com/llvm/llvm-project/issues/99701.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 8fa1a57177d9..e4477f96aa62 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -137,6 +137,7 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/InjectTLIMappings.h"
+#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/LoopSimplify.h"
#include "llvm/Transforms/Utils/LoopUtils.h"
#include "llvm/Transforms/Utils/LoopVersioning.h"
@@ -6681,6 +6682,7 @@ void LoopVectorizationCostModel::collectValuesToIgnore() {
CodeMetrics::collectEphemeralValues(TheLoop, AC, ValuesToIgnore);
SmallVector<Value *, 4> DeadInterleavePointerOps;
+ SmallVector<Value *, 4> DeadOps;
for (BasicBlock *BB : TheLoop->blocks())
for (Instruction &I : *BB) {
// Find all stores to invariant variables. Since they are going to sink
@@ -6690,6 +6692,17 @@ void LoopVectorizationCostModel::collectValuesToIgnore() {
Legal->isInvariantAddressOfReduction(SI->getPointerOperand()))
ValuesToIgnore.insert(&I);
+ if (VecValuesToIgnore.contains(&I) || ValuesToIgnore.contains(&I))
+ continue;
+
+ // Add instructions that would be trivially dead and are only used by
+ // values already ignored to DeadOps to seed worklist.
+ if (wouldInstructionBeTriviallyDead(&I, TLI) &&
+ all_of(I.users(), [this](User *U) {
+ return VecValuesToIgnore.contains(U) || ValuesToIgnore.contains(U);
+ }))
+ DeadOps.push_back(&I);
+
// For interleave groups, we only create a pointer for the start of the
// interleave group. Queue up addresses of group members except the insert
// position for further processing.
@@ -6717,6 +6730,29 @@ void LoopVectorizationCostModel::collectValuesToIgnore() {
DeadInterleavePointerOps.append(Op->op_begin(), Op->op_end());
}
+ // Mark ops that would be trivially dead and are only used by ignored
+ // instructions as free.
+ for (unsigned I = 0; I != DeadOps.size(); ++I) {
+ auto *Op = dyn_cast<Instruction>(DeadOps[I]);
+ // Skip any op that shouldn't be considered dead.
+ if (!Op || !TheLoop->contains(Op) ||
+ !wouldInstructionBeTriviallyDead(Op, TLI) ||
+ any_of(Op->users(), [this](User *U) {
+ return !VecValuesToIgnore.contains(U) && !ValuesToIgnore.contains(U);
+ }))
+ continue;
+
+ // If all of Op's users are in ValuesToIgnore, add it to ValuesToIgnore
+ // which applies for both scalar and vector versions. Otherwise it is only
+ // dead in vector versions, so only add it to VecValuesToIgnore.
+ if (all_of(Op->users(),
+ [this](User *U) { return ValuesToIgnore.contains(U); }))
+ ValuesToIgnore.insert(Op);
+
+ VecValuesToIgnore.insert(Op);
+ DeadOps.append(Op->op_begin(), Op->op_end());
+ }
+
// Ignore type-promoting instructions we identified during reduction
// detection.
for (const auto &Reduction : Legal->getReductionVars()) {
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/RISCV/dead-ops-cost.ll",
"commands": [
"opt -p loop-vectorize -mtriple riscv64-linux-gnu -mattr=+v,+f -S %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\n; Test with a dead load in the loop, from\n; https://github.com/llvm/llvm-project/issues/99701\ndefine void @dead_load(ptr %p, i16 %start) {\n;\nentry:\n %start.ext = sext i16 %start to i64\n br label %loop\n\nloop:\n %iv = phi i64 [ %start.ext, %entry ], [ %iv.next, %loop ]\n %gep = getelementptr i16, ptr %p, i64 %iv\n store i16 0, ptr %gep, align 2\n %l = load i16, ptr %gep, align 2\n %iv.next = add i64 %iv, 3\n %cmp = icmp slt i64 %iv, 111\n br i1 %cmp, label %loop, label %exit\n\nexit:\n ret void\n}\n;.\n;.",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[VPlan] Assertion `VF.Width == Width && \"VPlan cost model and legacy cost model disagreed\"' failed.",
"body": "I have a few finds by the fuzzer that affect LLVM (tested using a1d77caaabbb5279b734c061dab36b2138ec476d).\r\nI think they're all duplicates but I'm attaching them all in a .zip so it can be confirmed.\r\n\r\nTestcase:\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 void @e(i64 %0) #0 {\r\nentry:\r\n br label %for.body\r\n\r\nfor.cond.for.cond.cleanup_crit_edge: ; preds = %for.body\r\n ret void\r\n\r\nfor.body: ; preds = %for.body, %entry\r\n %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]\r\n %arrayidx = getelementptr i16, ptr null, i64 %indvars.iv\r\n %1 = load i16, ptr %arrayidx, align 2\r\n %arrayidx5 = getelementptr [0 x i8], ptr null, i64 0, i64 %indvars.iv\r\n store i8 0, ptr %arrayidx5, align 1\r\n %indvars.iv.next = add nsw i64 %indvars.iv, 4\r\n %cmp = icmp ult i64 %indvars.iv, %0\r\n br i1 %cmp, label %for.body, label %for.cond.for.cond.cleanup_crit_edge\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-b,-e,-experimental-smmpm,-experimental-smnpm,-experimental-ssnpm,-experimental-sspm,-experimental-ssqosid,-experimental-supm,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zacas,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\n\r\n```\r\n\r\nCommand/backtrace:\r\n```bash\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize reduced.ll -S\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10444: bool llvm::LoopVectorizePass::processLoop(llvm::Loop*): Assertion `VF.Width == Width && \"VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize reduced.ll -S\r\n1. Running pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"reduced.ll\"\r\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"e\"\r\n #0 0x000055b365fe4a60 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2f0ea60)\r\n #1 0x000055b365fe1e7f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2f0be7f)\r\n #2 0x000055b365fe1fd5 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007612a3042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007612a30969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007612a30969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007612a30969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x00007612a3042476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007612a30287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x00007612a302871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x00007612a3039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x000055b365005ba8 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f2fba8)\r\n#12 0x000055b365008761 llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f32761)\r\n#13 0x000055b365008ee0 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f32ee0)\r\n#14 0x000055b363e81296 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xdab296)\r\n#15 0x000055b365dfd4be llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2d274be)\r\n#16 0x000055b363e84426 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xdae426)\r\n#17 0x000055b365dfc24b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2d2624b)\r\n#18 0x000055b363e80776 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xdaa776)\r\n#19 0x000055b365dfa39d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2d2439d)\r\n#20 0x000055b3636cbdc6 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5f5dc6)\r\n#21 0x000055b3636bda11 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5e7a11)\r\n#22 0x00007612a3029d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#23 0x00007612a3029e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#24 0x00007612a3029e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#25 0x000055b3636b3855 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5dd855)\r\nzsh: IOT instruction /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\n\r\nGodbolt: https://godbolt.org/z/a7KPnMh94\r\n\r\nZip with all finds reduced: \r\n[finds.zip](https://github.com/user-attachments/files/16316789/finds.zip)\r\n\r\nRelated: https://github.com/llvm/llvm-project/pull/92555 @fhahn \r\n\r\nFound via fuzzer.",
"author": "patrick-rivos",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "JonPsson1",
"body": "I'm seeing this as well with a multitude of hits with csmith. One reduced test case:\r\n\r\nclang -O3 -march=z16 crash0.i -o a.out -w -mllvm -disable-licm-promotion -mllvm -force-target-instruction-cost=1 -mllvm -unroll-count=4\r\nLoopVectorize.cpp:10071: bool llvm::LoopVectorizePass::processLoop(llvm::Loop*): Assertion `VF.Width == Width && \"VPlan cost model and legacy cost model disagreed\"' failed.\r\n#9 0x0000000004749e30 llvm::LoopVectorizePass::processLoop()\r\n\r\n[tc_lv.i.tar.gz](https://github.com/user-attachments/files/16337463/tc_lv.i.tar.gz)\r\n\r\n"
},
{
"author": "fhahn",
"body": "Thanks @patrick-rivos, it looks like all test cases had dead instructions, which would be considered by the legacy cost model but not the VPlan-based one (because VPlan-based DCE would clean them up before). Should be fixed now.\r\n\r\n@JonPsson1's case was a different issue and should also be fixed."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
131360
|
https://github.com/llvm/llvm-project/issues/131360
|
crash
|
dccc0a836c20914549fa375905615db49d2f813b
| 2025-03-14T17:22:16 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "fbf0276b6a7a7a4508c373cf87fc349569652659",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
6665,
6670
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::reorderBottomToTop"
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit fbf0276b6a7a7a4508c373cf87fc349569652659
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Fri Mar 14 14:07:01 2025 -0700
[SLP] Reorder reuses mask, if it is not empty, for subvector operands
If the subvector operands has reuses mask, need to reorder the mask, not
the scalars, to prevent compiler crash due to mask/scalars size
mismatch.
Fixes #131360
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 708dda9bd7f8..d450336cbc3c 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -6665,6 +6665,8 @@ void BoUpSLP::reorderBottomToTop(bool IgnoreReorder) {
// Clear ordering of the operand.
if (!OpTE.ReorderIndices.empty()) {
OpTE.ReorderIndices.clear();
+ } else if (!OpTE.ReuseShuffleIndices.empty()) {
+ reorderReuses(OpTE.ReuseShuffleIndices, Mask);
} else {
assert(OpTE.isGather() && "Expected only gather/buildvector node.");
reorderScalars(OpTE.Scalars, Mask);
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/reorder-reused-subvector.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-100 < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @test(i32 %j.6, i32 %m.4, i8 %v.5, ptr %a, i1 %tobool14.not) {\n;\nentry:\n br label %n\n\nentry.o_crit_edge:\n br label %o\n\nn:\n %i.0 = phi i32 [ 0, %entry ], [ 1, %if.end18 ]\n %j.0 = phi i32 [ 0, %entry ], [ %j.6, %if.end18 ]\n %m.0 = phi i32 [ 0, %entry ], [ %m.4, %if.end18 ]\n %l.0 = phi i8 [ 0, %entry ], [ %l.4, %if.end18 ]\n %u.0 = phi i32 [ 0, %entry ], [ %u.5, %if.end18 ]\n store i32 %j.0, ptr %a, align 4\n %cmp.not.not = icmp eq i8 %l.0, 0\n br i1 %cmp.not.not, label %o.sink.split, label %p\n\np:\n %0 = phi i32 [ %r.3, %if.end18 ], [ 0, %n ]\n %i.1 = phi i32 [ %s.3, %if.end18 ], [ 1, %n ]\n %j.1 = phi i32 [ %j.65, %if.end18 ], [ %j.0, %n ]\n %k.1 = phi i32 [ %t.3, %if.end18 ], [ %i.0, %n ]\n %m.1 = phi i32 [ %m.46, %if.end18 ], [ %m.0, %n ]\n %l.1 = phi i8 [ 1, %if.end18 ], [ 0, %n ]\n %s.1 = phi i32 [ %s.3, %if.end18 ], [ 0, %n ]\n %t.1 = phi i32 [ %t.3, %if.end18 ], [ 0, %n ]\n %u.12 = phi i32 [ %u.5, %if.end18 ], [ 0, %n ]\n %v.1 = phi i8 [ 0, %if.end18 ], [ %v.5, %n ]\n %tobool4.not = icmp eq i32 %m.1, 0\n %spec.select = select i1 %tobool4.not, i32 %j.1, i32 0\n %tobool7.not = icmp eq i32 %0, 0\n br i1 %tobool7.not, label %o.sink.split, label %q\n\no.sink.split:\n %spec.select.sink = phi i32 [ %j.0, %n ], [ %spec.select, %p ]\n %i.3.ph = phi i32 [ 0, %n ], [ %i.1, %p ]\n %k.3.ph = phi i32 [ %i.0, %n ], [ %k.1, %p ]\n %m.3.ph = phi i32 [ %m.0, %n ], [ 0, %p ]\n %l.3.ph = phi i8 [ 0, %n ], [ %l.1, %p ]\n %u.3.ph = phi i32 [ %u.0, %n ], [ 1, %p ]\n %conv10 = zext i32 %spec.select.sink to i64\n %call11 = tail call i32 (ptr, ...) @printf(ptr null, i64 %conv10)\n br label %o\n\no:\n %j.4 = phi i32 [ 0, %entry.o_crit_edge ], [ %spec.select.sink, %o.sink.split ]\n %k.3 = phi i32 [ 0, %entry.o_crit_edge ], [ %k.3.ph, %o.sink.split ]\n %m.3 = phi i32 [ 0, %entry.o_crit_edge ], [ %m.3.ph, %o.sink.split ]\n %u.3 = phi i32 [ 0, %entry.o_crit_edge ], [ %u.3.ph, %o.sink.split ]\n %sub = sub i32 0, %j.6\n %div = sdiv i32 %sub, %i.3.ph\n %sub13 = sub i32 0, %div\n br i1 %tobool14.not, label %if.end18, label %q\n\nq:\n %s.2 = phi i32 [ %s.1, %p ], [ 0, %o ]\n %t.2 = phi i32 [ %t.1, %p ], [ %k.3, %o ]\n %u.4 = phi i32 [ %u.12, %p ], [ 0, %o ]\n %v.44 = phi i8 [ %v.1, %p ], [ 0, %o ]\n %conv17 = sext i8 %v.44 to i32\n %rem = mul i32 %u.4, %conv17\n br label %if.end18\n\nif.end18:\n %j.65 = phi i32 [ 0, %q ], [ %j.4, %o ]\n %m.46 = phi i32 [ %rem, %q ], [ %m.3, %o ]\n %l.4 = phi i8 [ 0, %q ], [ %l.3.ph, %o ]\n %r.3 = phi i32 [ 0, %q ], [ %k.3, %o ]\n %s.3 = phi i32 [ %s.2, %q ], [ %sub, %o ]\n %t.3 = phi i32 [ %t.2, %q ], [ %sub13, %o ]\n %u.5 = phi i32 [ 0, %q ], [ %u.3, %o ]\n br i1 %tobool14.not, label %n, label %p\n\n}\ndeclare i32 @printf(ptr, ...)",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "clang crashes at -O{s,2,3} on x86_64-linux-gnu: Assertion `idx < size()' failed",
"body": "It appears to be a recent regression as it doesn't reproduce with 20.1.0. \n\nCompiler Explorer: https://godbolt.org/z/31z58Pqnf\n\n```\n[507] % clangtk -v\nclang version 21.0.0git (https://github.com/llvm/llvm-project.git da3ee9763266f9adedaac1b1b3162d14f951fc55)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\nBuild config: +assertions\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\nCandidate multilib: .;@m64\nSelected multilib: .;@m64\n[508] % \n[508] % clangtk -Os small.c\nclang-21: /local/suz-local/software/clangbuild/llvm-project/llvm/include/llvm/ADT/SmallVector.h:291: T& llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::operator[](llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::size_type) [with T = llvm::Value*; <template-parameter-1-2> = void; llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::reference = llvm::Value*&; llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::size_type = long unsigned int]: Assertion `idx < size()' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\nStack dump:\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-21 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/20250314-clangtk-m64-O3-build-143933/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20250314-clangtk-m64-O3-build-143933/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/21 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Os -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-fb79f4.o -x c small.c\n1.\t<eof> parser at end of file\n2.\tOptimizer\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"small.c\"\n4.\tRunning pass \"slp-vectorizer\" on function \"g\"\n #0 0x0000559c00edefcf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x4577fcf)\n #1 0x0000559c00edc7a4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007f26a38b4420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\n #3 0x00007f26a32eb00b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\n #4 0x00007f26a32ca859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\n #5 0x00007f26a32ca729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\n #6 0x00007f26a32ca729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\n #7 0x00007f26a32dbfd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\n #8 0x0000559c0296f55e llvm::reorderScalars(llvm::SmallVectorImpl<llvm::Value*>&, llvm::ArrayRef<int>) SLPVectorizer.cpp:0:0\n #9 0x0000559c02a36719 llvm::slpvectorizer::BoUpSLP::reorderBottomToTop(bool) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60cf719)\n#10 0x0000559c02a41c60 llvm::SLPVectorizerPass::tryToVectorizeList(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60dac60)\n#11 0x0000559c02a4712d bool tryToVectorizeSequence<llvm::Value>(llvm::SmallVectorImpl<llvm::Value*>&, llvm::function_ref<bool (llvm::Value*, llvm::Value*)>, llvm::function_ref<bool (llvm::Value*, llvm::Value*)>, llvm::function_ref<bool (llvm::ArrayRef<llvm::Value*>, bool)>, bool, llvm::slpvectorizer::BoUpSLP&) (.constprop.0) SLPVectorizer.cpp:0:0\n#12 0x0000559c02a48b21 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60e1b21)\n#13 0x0000559c02a50b66 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\n#14 0x0000559c02a51733 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60ea733)\n#15 0x0000559c024c7cf6 llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5b60cf6)\n#16 0x0000559c0084f7c9 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x3ee87c9)\n#17 0x0000559bfe1397a6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x17d27a6)\n#18 0x0000559c0084e032 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x3ee7032)\n#19 0x0000559bfe1373b6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x17d03b6)\n#20 0x0000559c0084da51 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x3ee6a51)\n#21 0x0000559c0119ce4a (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\n#22 0x0000559c011a08a1 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x48398a1)\n#23 0x0000559c018e0d91 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x4f79d91)\n#24 0x0000559c0326e6dc clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x69076dc)\n#25 0x0000559c018e11b8 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x4f7a1b8)\n#26 0x0000559c01bb7bc9 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5250bc9)\n#27 0x0000559c01b38ece clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x51d1ece)\n#28 0x0000559c01cac996 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5345996)\n#29 0x0000559bfdccc9ed cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x13659ed)\n#30 0x0000559bfdcc415a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#31 0x0000559bfdcc83c7 clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x13613c7)\n#32 0x0000559bfdbad0db main (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x12460db)\n#33 0x00007f26a32cc083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\n#34 0x0000559bfdcc3bee _start (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x135cbee)\nclangtk: error: unable to execute command: Aborted\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\nclang version 21.0.0git (https://github.com/llvm/llvm-project.git da3ee9763266f9adedaac1b1b3162d14f951fc55)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\nBuild config: +assertions\nclangtk: note: diagnostic msg: \n********************\n\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\nPreprocessed source(s) and associated run script(s) are located at:\nclangtk: note: diagnostic msg: /tmp/small-d812eb.c\nclangtk: note: diagnostic msg: /tmp/small-d812eb.sh\nclangtk: note: diagnostic msg: \n\n********************\n[509] % \n[509] % cat small.c\nint printf(const char *, ...);\nint a, b, c, d, e, f;\nvoid g() {\n int i = 1, j = 0, k = 0, m;\n char l = 1;\n if (d)\n n : {\n a = j;\n if (e >= l) {\n printf(\"%ld\", (long) j);\n goto o;\n }\n p:\n if (m)\n j = 1;\n if (b)\n goto q;\n printf(\"%ld\", (long) j);\n }\n o : ;\n int r = k, s = -f, t = -(s / i);\n if (c) {\n t = k;\n int u = a;\n char v = u;\n q:\n m = u % v;\n l = 0;\n }\n i = s;\n k = t;\n b = r;\n if (a)\n goto p;\n goto n;\n}\n```\n",
"author": "zhendongsu",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
87394
|
https://github.com/llvm/llvm-project/issues/87394
|
crash
|
d5022d9ad4aec250f77d21c819a9810a97b8b6a8
| 2024-04-02T18:48:53 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "adb0126ef11b0083d5a78be1534ccefa53def1cf",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": [
[
35,
40
],
[
44,
49
]
],
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": [
"VPTypeAnalysis::inferScalarTypeForRecipe"
],
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit adb0126ef11b0083d5a78be1534ccefa53def1cf
Author: Patrick O'Neill <patrick@rivosinc.com>
Date: Tue Apr 23 07:48:43 2024 -0700
[VPlan] Add scalar inferencing support for Not and Or insns (#89160)
Fixes #87394.
PR: https://github.com/llvm/llvm-project/pull/89160
diff --git a/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp b/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp
index ad4ea648cd61..5f93339083f0 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp
@@ -35,6 +35,7 @@ Type *VPTypeAnalysis::inferScalarTypeForRecipe(const VPInstruction *R) {
CachedTypes[OtherV] = ResTy;
return ResTy;
}
+ case Instruction::Or:
case Instruction::ICmp:
case VPInstruction::FirstOrderRecurrenceSplice: {
Type *ResTy = inferScalarType(R->getOperand(0));
@@ -44,6 +45,12 @@ Type *VPTypeAnalysis::inferScalarTypeForRecipe(const VPInstruction *R) {
CachedTypes[OtherV] = ResTy;
return ResTy;
}
+ case VPInstruction::Not: {
+ Type *ResTy = inferScalarType(R->getOperand(0));
+ assert(IntegerType::get(Ctx, 1) == ResTy &&
+ "unexpected scalar type inferred for operand");
+ return ResTy;
+ }
case VPInstruction::PtrAdd:
// Return the type based on the pointer argument (i.e. first operand).
return inferScalarType(R->getOperand(0));
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/vplan-infer-not-or-type.ll",
"commands": [
"opt < %s -passes=loop-vectorize -S"
],
"tests": [
{
"test_name": "foo",
"test_body": "define void @foo(i8 %arg.0, i8 %arg.1) {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %latch, %entry\n %incrementor = phi i8 [ %add, %latch ], [ 0, %entry ]\n %and = and i8 %arg.0, %arg.1\n %extract.t = trunc i8 %and to i1\n br i1 %extract.t, label %latch, label %indirect.latch\n\nindirect.latch: ; preds = %loop.header\n br label %latch\n\nlatch: ; preds = %indirect.latch, %loop.header\n %add = add i8 %incrementor, 1\n %conv = zext i8 %incrementor to i32\n %cmp = icmp ult i32 %conv, 1\n br i1 %cmp, label %loop.header, label %loop.exit\n\nloop.exit: ; preds = %latch\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[LoopVectorize][VPlan] Unreachable executed \"Unhandled opcode!\"",
"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\r\n\r\nfor.cond.cleanup.loopexit: ; preds = %cond.end\r\n ret i32 0\r\n\r\nfor.body: ; preds = %cond.end, %entry\r\n %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %cond.end ]\r\n %conv3 = zext i1 false to i64\r\n %conv4 = trunc i64 %conv3 to i16\r\n br i1 false, label %cond.false, label %cond.end\r\n\r\ncond.false: ; preds = %for.body\r\n br label %cond.end\r\n\r\ncond.end: ; preds = %cond.false, %for.body\r\n %indvars.iv.next = add i64 %indvars.iv, 1\r\n %cmp = icmp ult i64 %indvars.iv, 1\r\n br i1 %cmp, label %for.body, label %for.cond.cleanup.loopexit\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\r\n```\r\n\r\nBacktrace:\r\n```\r\nUnhandled opcode!\r\nUNREACHABLE executed at /scratch/tc-testing/tc-apr-2/llvm/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp:58!\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 0x00005f05c836eb60 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2d84b60)\r\n #1 0x00005f05c836bf6f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2d81f6f)\r\n #2 0x00005f05c836c0c5 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x000071a702442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x000071a7024969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x000071a7024969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x000071a7024969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x000071a702442476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x000071a7024287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x00005f05c82a2afe (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2cb8afe)\r\n#10 0x00005f05c74dfe67 llvm::VPTypeAnalysis::inferScalarTypeForRecipe(llvm::VPInstruction const*) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1ef5e67)\r\n#11 0x00005f05c74dc88c llvm::VPTypeAnalysis::inferScalarType(llvm::VPValue const*) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1ef288c)\r\n#12 0x00005f05c750790e simplifyRecipes(llvm::VPlan&, llvm::LLVMContext&) VPlanTransforms.cpp:0:0\r\n#13 0x00005f05c750e606 llvm::VPlanTransforms::optimize(llvm::VPlan&, llvm::ScalarEvolution&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1f24606)\r\n#14 0x00005f05c73ded66 llvm::LoopVectorizationPlanner::buildVPlansWithVPRecipes(llvm::ElementCount, llvm::ElementCount) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1df4d66)\r\n#15 0x00005f05c73e5319 llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1dfb319)\r\n#16 0x00005f05c73e88a9 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1dfe8a9)\r\n#17 0x00005f05c73eb73e llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1e0173e)\r\n#18 0x00005f05c73ec88d llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1e0288d)\r\n#19 0x00005f05c62f3276 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0xd09276)\r\n#20 0x00005f05c8195141 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2bab141)\r\n#21 0x00005f05c62eabd6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0xd00bd6)\r\n#22 0x00005f05c8193e3b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2ba9e3b)\r\n#23 0x00005f05c62f2dc6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0xd08dc6)\r\n#24 0x00005f05c8191cb1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2ba7cb1)\r\n#25 0x00005f05c5b6cce5 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x582ce5)\r\n#26 0x00005f05c5b5f316 optMain (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x575316)\r\n#27 0x000071a702429d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#28 0x000071a702429e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#29 0x000071a702429e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#30 0x00005f05c5b54f95 _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/bvY138WfG\r\n\r\nTriggered assertion: https://github.com/llvm/llvm-project/blob/f5991161529511ca6ebc058da2a0507c2fc5283e/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp#L58\r\n\r\nFound via fuzzer",
"author": "patrick-rivos",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
136646
|
https://github.com/llvm/llvm-project/issues/136646
|
miscompilation
|
2ae9a74bf1421950bd404fec099b1f9998093916
| 2025-04-22T02:58:58 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "3e1e4062e1e95031c32c0ed9786647ef1a4141aa",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": [
[
2793,
2799
]
],
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": [
"foldSelectWithFCmpToFabs"
],
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 3e1e4062e1e95031c32c0ed9786647ef1a4141aa
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Sat Apr 26 14:03:12 2025 +0800
[InstCombine] Preserve signbit semantics of NaN with fold to fabs (#136648)
As per the LangRef and IEEE 754-2008 standard, the sign bit of NaN is
preserved if there is no floating-point operation being performed.
See also
https://github.com/llvm/llvm-project/commit/862e35e25a68502433da0a8d0819448ff5745339
for reference.
Alive2: https://alive2.llvm.org/ce/z/QYtEGj
Closes https://github.com/llvm/llvm-project/issues/136646
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index 4bba2f406b4c..5a42a5c996da 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -2793,7 +2793,14 @@ static Instruction *foldSelectWithFCmpToFabs(SelectInst &SI,
// fold (X <= +/-0.0) ? (0.0 - X) : X to fabs(X), when 'Swap' is false
// fold (X > +/-0.0) ? X : (0.0 - X) to fabs(X), when 'Swap' is true
- if (match(TrueVal, m_FSub(m_PosZeroFP(), m_Specific(X)))) {
+ // Note: We require "nnan" for this fold because fcmp ignores the signbit
+ // of NAN, but IEEE-754 specifies the signbit of NAN values with
+ // fneg/fabs operations.
+ if (match(TrueVal, m_FSub(m_PosZeroFP(), m_Specific(X))) &&
+ (cast<FPMathOperator>(CondVal)->hasNoNaNs() || SI.hasNoNaNs() ||
+ isKnownNeverNaN(X, /*Depth=*/0,
+ IC.getSimplifyQuery().getWithInstruction(
+ cast<Instruction>(CondVal))))) {
if (!Swap && (Pred == FCmpInst::FCMP_OLE || Pred == FCmpInst::FCMP_ULE)) {
Value *Fabs = IC.Builder.CreateUnaryIntrinsic(Intrinsic::fabs, X, &SI);
return IC.replaceInstUsesWith(SI, Fabs);
|
[
{
"file": "llvm/test/Transforms/InstCombine/fabs.ll",
"commands": [
"opt -mtriple=x86_64-unknown-linux-gnu < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "select_fcmp_ogt_zero",
"test_body": "define half @select_fcmp_ogt_zero(half %x) {\n %gtzero = fcmp nnan ogt half %x, 0.000000e+00\n %negx = fsub half 0.000000e+00, %x\n %fabs = select i1 %gtzero, half %x, half %negx\n ret half %fabs\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "select_fcmp_ole_zero_no_nnan",
"test_body": "define half @select_fcmp_ole_zero_no_nnan(half %x) {\n %lezero = fcmp ole half %x, 0.000000e+00\n %negx = fsub half 0.000000e+00, %x\n %fabs = select i1 %lezero, half %negx, half %x\n ret half %fabs\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "select_fcmp_nnan_ule_zero",
"test_body": "define half @select_fcmp_nnan_ule_zero(half %x) {\n %lezero = fcmp nnan ule half %x, 0.000000e+00\n %negx = fsub nnan half 0.000000e+00, %x\n %fabs = select i1 %lezero, half %negx, half %x\n ret half %fabs\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "select_fcmp_ole_zero_select_nnan",
"test_body": "define half @select_fcmp_ole_zero_select_nnan(half %x) {\n %lezero = fcmp ole half %x, 0.000000e+00\n %negx = fsub half 0.000000e+00, %x\n %fabs = select nnan i1 %lezero, half %negx, half %x\n ret half %fabs\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "select_fcmp_ole_zero",
"test_body": "define half @select_fcmp_ole_zero(half %x) {\n %lezero = fcmp nnan ole half %x, 0.000000e+00\n %negx = fsub half 0.000000e+00, %x\n %fabs = select i1 %lezero, half %negx, half %x\n ret half %fabs\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "select_fcmp_nnan_ogt_zero",
"test_body": "define half @select_fcmp_nnan_ogt_zero(half %x) {\n %gtzero = fcmp nnan ogt half %x, 0.000000e+00\n %negx = fsub nnan half 0.000000e+00, %x\n %fabs = select i1 %gtzero, half %x, half %negx\n ret half %fabs\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "select_nnan_fcmp_nnan_ole_zero",
"test_body": "define half @select_nnan_fcmp_nnan_ole_zero(half %x) {\n %lezero = fcmp nnan ole half %x, 0.000000e+00\n %negx = fsub nnan half 0.000000e+00, %x\n %fabs = select nnan i1 %lezero, half %negx, half %x\n ret half %fabs\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "select_fcmp_nnan_ogt_negzero",
"test_body": "define half @select_fcmp_nnan_ogt_negzero(half %x) {\n %gtzero = fcmp nnan ogt half %x, 0xH8000\n %negx = fsub nnan half 0xH0000, %x\n %fabs = select i1 %gtzero, half %x, half %negx\n ret half %fabs\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "select_fcmp_nnan_ugt_negzero",
"test_body": "define half @select_fcmp_nnan_ugt_negzero(half %x) {\n %gtzero = fcmp nnan ugt half %x, 0xH8000\n %negx = fsub nnan half 0xH0000, %x\n %fabs = select i1 %gtzero, half %x, half %negx\n ret half %fabs\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "select_nnan_fcmp_nnan_ole_negzero",
"test_body": "define <2 x float> @select_nnan_fcmp_nnan_ole_negzero(<2 x float> %x) {\n %lezero = fcmp nnan ole <2 x float> %x, splat (float -0.000000e+00)\n %negx = fsub nnan <2 x float> <float 0.000000e+00, float poison>, %x\n %fabs = select nnan <2 x i1> %lezero, <2 x float> %negx, <2 x float> %x\n ret <2 x float> %fabs\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "select_nnan_fcmp_nnan_ogt_negzero",
"test_body": "define half @select_nnan_fcmp_nnan_ogt_negzero(half %x) {\n %gtzero = fcmp nnan ogt half %x, 0xH8000\n %negx = fsub nnan half 0xH0000, %x\n %fabs = select nnan i1 %gtzero, half %x, half %negx\n ret half %fabs\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "select_fcmp_nnan_ole_zero",
"test_body": "define half @select_fcmp_nnan_ole_zero(half %x) {\n %lezero = fcmp nnan ole half %x, 0.000000e+00\n %negx = fsub nnan half 0.000000e+00, %x\n %fabs = select i1 %lezero, half %negx, half %x\n ret half %fabs\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "select_fcmp_nnan_ole_negzero",
"test_body": "define <2 x float> @select_fcmp_nnan_ole_negzero(<2 x float> %x) {\n %lezero = fcmp nnan ole <2 x float> %x, splat (float -0.000000e+00)\n %negx = fsub nnan <2 x float> <float 0.000000e+00, float poison>, %x\n %fabs = select <2 x i1> %lezero, <2 x float> %negx, <2 x float> %x\n ret <2 x float> %fabs\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "select_nnan_fcmp_nnan_ogt_zero",
"test_body": "define half @select_nnan_fcmp_nnan_ogt_zero(half %x) {\n %gtzero = fcmp nnan ogt half %x, 0.000000e+00\n %negx = fsub nnan half 0.000000e+00, %x\n %fabs = select nnan i1 %gtzero, half %x, half %negx\n ret half %fabs\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "select_fcmp_ole_zero_no_nnan_input_nofpclass_nan",
"test_body": "define half @select_fcmp_ole_zero_no_nnan_input_nofpclass_nan(half nofpclass(nan) %x) {\n %lezero = fcmp ole half %x, 0.000000e+00\n %negx = fsub half 0.000000e+00, %x\n %fabs = select i1 %lezero, half %negx, half %x\n ret half %fabs\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstCombine] The sign bit of NaN is not preserved when folding `(X <= +/-0.0) ? (0.0 - X) : X to fabs(X)`",
"body": "Reproducer: https://alive2.llvm.org/ce/z/2JaLU9\n```\n\n----------------------------------------\ndefine half @src(half %x) {\n#0:\n %gtzero = fcmp ugt half %x, 0x0000\n %negx = fsub half 0x0000, %x\n %fabs = select i1 %gtzero, half %x, half %negx\n ret half %fabs\n}\n=>\ndefine half @src(half %x) nofree willreturn memory(none) {\n#0:\n %fabs = fabs half %x\n ret half %fabs\n}\nTransformation doesn't verify!\n\nERROR: Value mismatch\n\nExample:\nhalf %x = #xfd00 (SNaN)\n\nSource:\ni1 %gtzero = #x1 (1)\nhalf %negx = #xff00 (QNaN)\nhalf %fabs = #xfd00 (SNaN)\n\nTarget:\nhalf %fabs = #x7d00 (SNaN)\nSource value: #xfd00 (SNaN)\nTarget value: #x7d00 (SNaN)\n\nSummary:\n 0 correct transformations\n 1 incorrect transformations\n 0 failed-to-prove transformations\n 0 Alive2 errors\n```\nRelated issues:\nhttps://github.com/AliveToolkit/alive2/pull/1155\nhttps://github.com/llvm/llvm-project/issues/59279\n",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.