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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|
114860
|
https://github.com/llvm/llvm-project/issues/114860
|
crash
|
7dffc96a54f90569d6226dd5713c80fc8f30c76f
| 2024-11-04T20:12:18 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "144bdf3eb7128518ed162c5a168e3ec90922cd9e",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
7521,
7526
]
],
"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"
],
"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 144bdf3eb7128518ed162c5a168e3ec90922cd9e
Author: Florian Hahn <flo@fhahn.com>
Date: Fri Nov 8 20:53:03 2024 +0000
[VPlan] Also check if plan for best legacy VF contains simplifications.
The plan for the VF chosen by the legacy cost model could also contain
additional simplifications that cause cost differences. Also check if it
contains simplifications.
Fixes https://github.com/llvm/llvm-project/issues/114860.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index c07af8519049..82d85b112397 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7521,6 +7521,8 @@ VectorizationFactor LoopVectorizationPlanner::computeBestVF() {
precomputeCosts(BestPlan, BestFactor.Width, CostCtx);
assert((BestFactor.Width == LegacyVF.Width ||
planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width),
+ CostCtx, OrigLoop) ||
+ planContainsAdditionalSimplifications(getPlanFor(LegacyVF.Width),
CostCtx, OrigLoop)) &&
" VPlan cost model and legacy cost model disagreed");
assert((BestFactor.Width.isScalar() || BestFactor.ScalarCost > 0) &&
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/RISCV/select-invariant-cond-cost.ll",
"commands": [
"opt -p loop-vectorize -S %s"
],
"tests": [
{
"test_name": "test_invariant_cond_for_select",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @test_invariant_cond_for_select(ptr %dst, i8 %x) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %c.1 = icmp eq i8 %x, 0\n %c.2 = icmp sgt i64 %iv, 0\n %c.2.ext = zext i1 %c.2 to i64\n %sel = select i1 %c.1, i64 %c.2.ext, i64 0\n %sel.trunc = trunc i64 %sel to i8\n %gep = getelementptr inbounds i8, ptr %dst, i64 %iv\n store i8 %sel.trunc, ptr %gep, align 1\n %iv.next = add i64 %iv, 4\n %ec = icmp ult i64 %iv, 14\n br i1 %ec, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[VPlan] Assertion \" VPlan cost model and legacy cost model disagreed\"' failed.",
"body": "Testcase:\r\n```c\r\nextern char a[];\r\nchar *b;\r\nint c = 40502824327348188;\r\nlong d[9][9];\r\nint main() {\r\n for (long e = 0; e < 9; ++e)\r\n for (long f = 0; f < 9; ++f)\r\n d[e][f] = 6032102684657866;\r\n for (unsigned char f = b[4]; f < 18; f += c - 216)\r\n a[f] = f % 2 ? d[f][f] : d[f][f] + 2036854775807 > 0;\r\n}\r\n```\r\n```\r\n/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/clang -I/scratch/tc-testing/compiler-fuzz-ci/csmith-build/include -fsigned-char -fno-strict-aliasing -fwrapv -march=rv64gcv -flto -O3 -fuse-ld=lld red.c -o rv64gcv.out\r\n```\r\n\r\n\r\nReduced testcase:\r\n```llvm ir\r\n; ModuleID = 'reduced.bc'\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine i32 @main() #0 {\r\nentry:\r\n br label %for.body15\r\n\r\nfor.cond.cleanup14.loopexit: ; preds = %for.body15\r\n ret i32 0\r\n\r\nfor.body15: ; preds = %for.body15, %entry\r\n %indvars.iv1 = phi i64 [ %indvars.iv.next, %for.body15 ], [ 0, %entry ]\r\n %tobool.not = icmp eq i8 0, 0\r\n %cmp24 = icmp sgt i64 %indvars.iv1, 0\r\n %conv26 = zext i1 %cmp24 to i64\r\n %cond = select i1 %tobool.not, i64 %conv26, i64 0\r\n %conv27 = trunc i64 %cond to i8\r\n store i8 %conv27, ptr null, align 1\r\n %indvars.iv.next = add i64 %indvars.iv1, 4\r\n %cmp12 = icmp ult i64 %indvars.iv1, 14\r\n br i1 %cmp12, label %for.body15, label %for.cond.cleanup14.loopexit\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-b,-e,-experimental-smctr,-experimental-ssctr,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-experimental-zvbc32e,-experimental-zvkgs,-h,-sha,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smmpm,-smnpm,-smrnmi,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssnpm,-sspm,-ssqosid,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-supm,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-svvptc,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zacas,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\n```\r\n\r\nCommand/backtrace:\r\n```\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt --passes \"loop-vectorize\" reduced.ll -f\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7519: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt --passes loop-vectorize reduced.ll -f\r\n1. Running pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"reduced.ll\"\r\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\r\n #0 0x00005f3d9fc9dc00 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x3169c00)\r\n #1 0x00005f3d9fc9b00f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x316700f)\r\n #2 0x00005f3d9fc9b165 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007abb28242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007abb282969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007abb282969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007abb282969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x00007abb28242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007abb282287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x00007abb2822871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x00007abb28239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x00005f3d9ebfb878 llvm::LoopVectorizationPlanner::computeBestVF() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20c7878)\r\n#12 0x00005f3d9ec12dec llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20dedec)\r\n#13 0x00005f3d9ec15f01 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20e1f01)\r\n#14 0x00005f3d9ec16577 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20e2577)\r\n#15 0x00005f3d9da0cba6 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xed8ba6)\r\n#16 0x00005f3d9faa518f llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2f7118f)\r\n#17 0x00005f3d9da0fdd6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xedbdd6)\r\n#18 0x00005f3d9faa351b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2f6f51b)\r\n#19 0x00005f3d9da0bc66 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xed7c66)\r\n#20 0x00005f3d9faa407d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2f7007d)\r\n#21 0x00005f3d9d20ca8d llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x6d8a8d)\r\n#22 0x00005f3d9d1fe911 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x6ca911)\r\n#23 0x00007abb28229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#24 0x00007abb28229e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#25 0x00007abb28229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#26 0x00005f3d9d1f4e65 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x6c0e65)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\n\r\nFound via fuzzer on Oct 24th\r\n\r\nGodbolt: https://godbolt.org/z/zhseEjTso\r\n\r\ncc @fhahn ",
"author": "patrick-rivos",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
101213
|
https://github.com/llvm/llvm-project/issues/101213
|
crash
|
8364a6e108faea1a6f05f7bb53720a6fc101fed2
| 2024-07-30T18:00:09 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "f70f1228035c9610de38e0e376afdacb647c4ad9",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
13909,
13919
]
],
"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 f70f1228035c9610de38e0e376afdacb647c4ad9
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Tue Jul 30 14:02:51 2024 -0700
[SLP]Fix PR101213: Reuse extractelement, only if its vector operand comes before new vector value.
When trying to reuse extractelement instruction, need to check that it
is inserted into proper position. Its original vector operand should
come before new vector value, otherwise new extractelement instruction
must be generated.
Fixes https://github.com/llvm/llvm-project/issues/101213
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 6501a14d8778..cf87b8621027 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -13909,11 +13909,16 @@ Value *BoUpSLP::vectorizeTree(
}
if (!Ex) {
// "Reuse" the existing extract to improve final codegen.
- if (auto *ES = dyn_cast<ExtractElementInst>(Scalar)) {
+ if (auto *ES = dyn_cast<ExtractElementInst>(Scalar);
+ ES && isa<Instruction>(Vec)) {
Value *V = ES->getVectorOperand();
if (const TreeEntry *ETE = getTreeEntry(V))
V = ETE->VectorizedValue;
- Ex = Builder.CreateExtractElement(V, ES->getIndexOperand());
+ if (auto *IV = dyn_cast<Instruction>(V);
+ !IV || IV == Vec || IV->comesBefore(cast<Instruction>(Vec)))
+ Ex = Builder.CreateExtractElement(V, ES->getIndexOperand());
+ else
+ Ex = Builder.CreateExtractElement(Vec, Lane);
} else if (ReplaceGEP) {
// Leave the GEPs as is, they are free in most cases and better to
// keep them as GEPs.
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/extract-vectorized-operand.ll",
"commands": [
"opt -S --passes=slp-vectorizer -slp-threshold=-99999 < %s -mtriple=x86_64-unknown-linux-gnu"
],
"tests": [
{
"test_name": "test",
"test_body": "define void @test() {\nbb:\n %0 = shufflevector <2 x ptr addrspace(1)> zeroinitializer, <2 x ptr addrspace(1)> zeroinitializer, <2 x i32> <i32 1, i32 0>\n %1 = extractelement <2 x ptr addrspace(1)> %0, i32 0\n %2 = extractelement <2 x ptr addrspace(1)> %0, i32 1\n br label %bb43\n\nbb20: ; No predecessors!\n br label %bb105\n\nbb43: ; preds = %bb51, %bb\n %phi441 = phi ptr addrspace(1) [ %4, %bb51 ], [ %2, %bb ]\n %phi452 = phi ptr addrspace(1) [ %5, %bb51 ], [ %1, %bb ]\n br i1 false, label %bb105, label %bb51\n\nbb51: ; preds = %bb54, %bb43\n %3 = phi <2 x ptr addrspace(1)> [ poison, %bb54 ], [ zeroinitializer, %bb43 ]\n %4 = extractelement <2 x ptr addrspace(1)> %3, i32 0\n %5 = extractelement <2 x ptr addrspace(1)> %3, i32 1\n br label %bb43\n\nbb54: ; No predecessors!\n br label %bb51\n\nbb105: ; preds = %bb43, %bb20\n %phi106 = phi ptr addrspace(1) [ %1, %bb20 ], [ null, %bb43 ]\n ret void\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 the following test with -passes slp-vectorizer -slp-threshold=-99999\r\n[Test.ll.tgz](https://github.com/user-attachments/files/16431764/Test.ll.tgz)\r\n\r\nReproducer : https://godbolt.org/z/GW41a7WP6\r\n\r\nStack dump:\r\n```\r\nInstruction does not dominate all uses!\r\n %2 = shufflevector <2 x ptr addrspace(1)> %0, <2 x ptr addrspace(1)> poison, <2 x i32> <i32 1, i32 0>\r\n %1 = extractelement <2 x ptr addrspace(1)> %2, i32 0\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 -slp-threshold=-99999 <source>\r\n1.\tRunning pass \"verify\" on module \"<source>\"\r\n #0 0x0000000004eff778 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4eff778)\r\n #1 0x0000000004efceec SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007c0269e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x00007c0269e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x00007c0269e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x00007c0269e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00000000007b3ff7 llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0\r\n #7 0x0000000004e396a8 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e396a8)\r\n #8 0x0000000004d360f0 llvm::VerifierPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d360f0)\r\n #9 0x00000000008d865e 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+0x8d865e)\r\n#10 0x0000000004cf9c90 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4cf9c90)\r\n#11 0x00000000008e33d2 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+0x8e33d2)\r\n#12 0x00000000008d62fc optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8d62fc)\r\n#13 0x00007c0269e29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#14 0x00007c0269e29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#15 0x00000000008cd75e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8cd75e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```\r\n",
"author": "TatyanaDoubts",
"labels": [
"llvm:SLPVectorizer",
"llvm:crash"
],
"comments": [
{
"author": "Zentrik",
"body": "@alexey-bataev Hi, is there a way to backport this fix for llvm 19, I tried just cherry picking f70f1228035c9610de38e0e376afdacb647c4ad9 but I ended up getting assertion failures of the form `/workspace/srcdir/llvm-project/llvm/lib/IR/Instruction.cpp:321: bool llvm::Instruction::comesBefore(const llvm::Instruction*) const: Assertion 'getParent() == Other->getParent() && \"cross-BB instruction order comparison\"' failed.'`. \r\nI can create an IR reproducer for that failure if need be.\r\nThank you.\r\n\r\nEDIT: Would just adding a check that they're in the same basic block work?"
},
{
"author": "alexey-bataev",
"body": "> @alexey-bataev Hi, is there a way to backport this fix for llvm 19, I tried just cherry picking [f70f122](https://github.com/llvm/llvm-project/commit/f70f1228035c9610de38e0e376afdacb647c4ad9) but I ended up getting assertion failures of the form `/workspace/srcdir/llvm-project/llvm/lib/IR/Instruction.cpp:321: bool llvm::Instruction::comesBefore(const llvm::Instruction*) const: Assertion 'getParent() == Other->getParent() && \"cross-BB instruction order comparison\"' failed.'`. I can create an IR reproducer for that failure if need be. Thank you.\r\n> \r\n> EDIT: Would just adding a check that they're in the same basic block work?\r\n\r\nYes, check for the same parent should fix it"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
98675
|
https://github.com/llvm/llvm-project/issues/98675
|
crash
|
22b7b84860d39da71964c9b329937f2ee1d875ba
| 2024-07-12T18:26:47 |
[
"llvm/test/Transforms/MemCpyOpt"
] |
{
"fix_commit": "99685a54d1322694847f59386a548b3696a43fc3",
"components": [
"MemCpyOptimizer"
],
"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": [
[
1188,
1196
]
],
"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": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": [
"MemCpyOptPass::processMemCpyMemCpyDependence"
],
"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 99685a54d1322694847f59386a548b3696a43fc3
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Sat Jul 13 04:27:07 2024 +0800
[MemCpyOpt] Use `dyn_cast` to fix assertion failure in `processMemCpyMemCpyDependence` (#98686)
Fixes https://github.com/llvm/llvm-project/issues/98675.
diff --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
index 1c65219585e5..4063762c88a2 100644
--- a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -1188,9 +1188,9 @@ bool MemCpyOptPass::processMemCpyMemCpyDependence(MemCpyInst *M,
if (MDestOffset == MForwardOffset)
CopySource = M->getDest();
else {
- NewCopySource = cast<Instruction>(Builder.CreateInBoundsPtrAdd(
- CopySource, Builder.getInt64(MForwardOffset)));
- CopySource = NewCopySource;
+ CopySource = Builder.CreateInBoundsPtrAdd(
+ CopySource, Builder.getInt64(MForwardOffset));
+ NewCopySource = dyn_cast<Instruction>(CopySource);
}
// We need to update `MCopyLoc` if an offset exists.
MCopyLoc = MCopyLoc.getWithNewPtr(CopySource);
|
[
{
"file": "llvm/test/Transforms/MemCpyOpt/memcpy-memcpy-offset.ll",
"commands": [
"opt < %s -passes=memcpyopt -S -verify-memoryssa"
],
"tests": [
{
"test_name": "do_not_forward_offset_and_store",
"test_body": "define void @do_not_forward_offset_and_store(ptr %src, ptr %dest) {\n %cpy_tmp = alloca [9 x i8], align 1\n call void @llvm.memcpy.p0.p0.i64(ptr align 1 %cpy_tmp, ptr align 1 %src, i64 7, i1 false)\n %src_offset = getelementptr inbounds i8, ptr %src, i64 1\n store i8 1, ptr %src_offset, align 1\n %cpy_tmp_offset = getelementptr inbounds i8, ptr %cpy_tmp, i64 1\n call void @llvm.memcpy.p0.p0.i64(ptr align 1 %dest, ptr align 1 %cpy_tmp_offset, i64 5, i1 false)\n ret void\n}\n\n; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)\ndeclare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "pr98675",
"test_body": "@buf = external global [32 x i8]\n\ndefine void @pr98675(ptr noalias %p1, ptr noalias %p2) {\n call void @llvm.memcpy.p0.p0.i64(ptr %p1, ptr @buf, i64 26, i1 false)\n %gep = getelementptr i8, ptr %p1, i64 10\n call void @llvm.memmove.p0.p0.i64(ptr %p2, ptr %gep, i64 1, i1 false)\n ret void\n}\n\n; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)\ndeclare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0\n\n; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)\ndeclare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #0\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[MemCpyOpt] Assertion `isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"' failed.",
"body": "Detected by https://github.com/dtcxzyw/llvm-opt-benchmark/issues/935.\r\n\r\nReproducer: \r\n```\r\n; bin/opt -passes=memcpyopt -S test.ll\r\n@b = external global [32 x i8]\r\n\r\ndefine void @_Z15TestBasicStringIN5eastl12basic_stringIc17CountingAllocatorEEEiv(ptr %call.i.i.i12866) {\r\n %a = alloca [32 x i8], align 1\r\n call void @llvm.memcpy.p0.p0.i64(ptr %call.i.i.i12866, ptr @b, i64 26, i1 false)\r\n %.sroa.gep22184 = getelementptr i8, ptr %call.i.i.i12866, i64 10\r\n call void @llvm.memmove.p0.p0.i64(ptr %a, ptr %.sroa.gep22184, i64 1, i1 false)\r\n ret void\r\n}\r\n```\r\n```\r\nopt: /home/dtcxzyw/WorkSpace/Projects/compilers/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From*) [with To = Instruction; From = Value]: Assertion `isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: bin/opt -passes=memcpyopt reduced.ll\r\n1. Running pass \"function(memcpyopt)\" on module \"reduced.ll\"\r\n2. Running pass \"memcpyopt\" on function \"_Z15TestBasicStringIN5eastl12basic_stringIc17CountingAllocatorEEEiv\"\r\n #0 0x00007e04ebe0c9c2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.19.0git+0x20c9c2)\r\n #1 0x00007e04ebe0988f llvm::sys::RunSignalHandlers() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.19.0git+0x20988f)\r\n #2 0x00007e04ebe099d5 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007e04eb842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007e04eb8969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007e04eb8969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007e04eb8969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x00007e04eb842476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007e04eb8287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x00007e04eb82871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x00007e04eb839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x00007e04e5ab5dfa llvm::MemCpyOptPass::processMemCpyMemCpyDependence(llvm::MemCpyInst*, llvm::MemCpyInst*, llvm::BatchAAResults&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMScalarOpts.so.19.0git+0x2b5dfa)\r\n#12 0x00007e04e5abd2aa llvm::MemCpyOptPass::processMemCpy(llvm::MemCpyInst*, llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>, false, false>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMScalarOpts.so.19.0git+0x2bd2aa)\r\n#13 0x00007e04e5abd9c4 llvm::MemCpyOptPass::iterateOnFunction(llvm::Function&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMScalarOpts.so.19.0git+0x2bd9c4)\r\n#14 0x00007e04e5abdcce llvm::MemCpyOptPass::runImpl(llvm::Function&, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::AssumptionCache*, llvm::DominatorTree*, llvm::PostDominatorTree*, llvm::MemorySSA*) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMScalarOpts.so.19.0git+0x2bdcce)\r\n#15 0x00007e04e5abe15c llvm::MemCpyOptPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMScalarOpts.so.19.0git+0x2be15c)\r\n#16 0x00007e04e74cde55 llvm::detail::PassModel<llvm::Function, llvm::MemCpyOptPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMPasses.so.19.0git+0xcde55)\r\n#17 0x00007e04e474b7b2 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.19.0git+0x34b7b2)\r\n#18 0x00007e04eaad5065 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.19.0git+0xd5065)\r\n#19 0x00007e04e474a40e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.19.0git+0x34a40e)\r\n#20 0x00007e04eaad5985 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.19.0git+0xd5985)\r\n#21 0x00007e04e47483da llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.19.0git+0x3483da)\r\n#22 0x00007e04ec103267 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.19.0git+0x2d267)\r\n#23 0x00007e04ec10f212 optMain (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.19.0git+0x39212)\r\n#24 0x00007e04eb829d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#25 0x00007e04eb829e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#26 0x00007e04eb829e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#27 0x00005df852081095 _start (bin/opt+0x1095)\r\nAborted (core dumped)\r\n```\r\n\r\nThis issue is caused by https://github.com/llvm/llvm-project/commit/fa2421392802025e842454a31ed50dbfab643130.\r\nhttps://github.com/llvm/llvm-project/blob/d1dc5047f1127d64eb82eec976fabaa2d9d20c11/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp#L1191-L1192\r\n`Builder.CreateInBoundsPtrAdd` may return `GetElementPtrConstantExpr`.\r\n\r\ncc @nikic @DianQK \r\n\r\n",
"author": "dtcxzyw",
"labels": [
"crash-on-valid",
"llvm:transforms"
],
"comments": [
{
"author": "DianQK",
"body": "It looks similar to https://lab.llvm.org/buildbot/#/builders/41/builds/587. I really shouldn't have merged the code before going to bed :3"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
98753
|
https://github.com/llvm/llvm-project/issues/98753
|
miscompilation
|
c30ce8b9d33d1050ead549705702c1472b7a7d3f
| 2024-07-13T17:35:41 |
[
"llvm/test/Transforms/InstSimplify"
] |
{
"fix_commit": "de29b850f03092195bf21f3a39402adb4ed3c216",
"components": [
"InstructionSimplify"
],
"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": [
[
1975,
1987
],
[
4300,
4305
],
[
4347,
4352
],
[
4467,
4472
],
[
4606,
4612
]
],
"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": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": [
"llvm::simplifyWithOpReplaced",
"simplifyAndOrWithICmpEq",
"simplifySelectWithICmpEq"
],
"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 de29b850f03092195bf21f3a39402adb4ed3c216
Author: Nikita Popov <npopov@redhat.com>
Date: Tue Jul 16 11:40:04 2024 +0200
[InstSimplify] Fix simplifyAndOrWithICmpEq with undef refinement (#98898)
The final case in Simplify (where Res == Absorber and the predicate is
inverted) is not generally safe when the simplification is a refinement.
In particular, we may simplify assuming a specific value for undef, but
then chose a different one later.
However, it *is* safe to refine poison in this context, unlike in the
equivalent select folds. This is the reason why this fold did not use
AllowRefinement=false in the first place, and using that option would
introduce a lot of test regressions.
This patch takes the middle path of disabling undef refinements in
particular using the getWithoutUndef() SimplifyQuery option. However,
this option doesn't actually work in this case, because the problematic
fold is inside constant folding, and we currently don't propagate this
option all the way from InstSimplify over ConstantFolding to
ConstantFold. Work around this by explicitly checking for undef operands
in simplifyWithOpReplaced().
Finally, make sure that places where AllowRefinement=false also use
Q.getWithoutUndef(). I don't have a specific test case for this (the
original one does not work because we don't simplify selects with
constant condition in this mode in the first place) but this seems like
the correct thing to do to be conservative.
Fixes https://github.com/llvm/llvm-project/issues/98753.
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 242c200f7ef1..3a7ae577bb06 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -1975,13 +1975,16 @@ static Value *simplifyAndOrWithICmpEq(unsigned Opcode, Value *Op0, Value *Op1,
return nullptr;
};
- if (Value *Res =
- simplifyWithOpReplaced(Op1, A, B, Q, /* AllowRefinement */ true,
- /* DropFlags */ nullptr, MaxRecurse))
+ // In the final case (Res == Absorber with inverted predicate), it is safe to
+ // refine poison during simplification, but not undef. For simplicity always
+ // disable undef-based folds here.
+ if (Value *Res = simplifyWithOpReplaced(Op1, A, B, Q.getWithoutUndef(),
+ /* AllowRefinement */ true,
+ /* DropFlags */ nullptr, MaxRecurse))
return Simplify(Res);
- if (Value *Res =
- simplifyWithOpReplaced(Op1, B, A, Q, /* AllowRefinement */ true,
- /* DropFlags */ nullptr, MaxRecurse))
+ if (Value *Res = simplifyWithOpReplaced(Op1, B, A, Q.getWithoutUndef(),
+ /* AllowRefinement */ true,
+ /* DropFlags */ nullptr, MaxRecurse))
return Simplify(Res);
return nullptr;
@@ -4300,6 +4303,9 @@ static Value *simplifyWithOpReplaced(Value *V, Value *Op, Value *RepOp,
bool AllowRefinement,
SmallVectorImpl<Instruction *> *DropFlags,
unsigned MaxRecurse) {
+ assert((AllowRefinement || !Q.CanUseUndef) &&
+ "If AllowRefinement=false then CanUseUndef=false");
+
// Trivial replacement.
if (V == Op)
return RepOp;
@@ -4347,6 +4353,11 @@ static Value *simplifyWithOpReplaced(Value *V, Value *Op, Value *RepOp,
} else {
NewOps.push_back(InstOp);
}
+
+ // Bail out if any operand is undef and SimplifyQuery disables undef
+ // simplification. Constant folding currently doesn't respect this option.
+ if (isa<UndefValue>(NewOps.back()) && !Q.CanUseUndef)
+ return nullptr;
}
if (!AnyReplaced)
@@ -4467,6 +4478,11 @@ Value *llvm::simplifyWithOpReplaced(Value *V, Value *Op, Value *RepOp,
const SimplifyQuery &Q,
bool AllowRefinement,
SmallVectorImpl<Instruction *> *DropFlags) {
+ // If refinement is disabled, also disable undef simplifications (which are
+ // always refinements) in SimplifyQuery.
+ if (!AllowRefinement)
+ return ::simplifyWithOpReplaced(V, Op, RepOp, Q.getWithoutUndef(),
+ AllowRefinement, DropFlags, RecursionLimit);
return ::simplifyWithOpReplaced(V, Op, RepOp, Q, AllowRefinement, DropFlags,
RecursionLimit);
}
@@ -4606,7 +4622,7 @@ static Value *simplifySelectWithICmpEq(Value *CmpLHS, Value *CmpRHS,
Value *TrueVal, Value *FalseVal,
const SimplifyQuery &Q,
unsigned MaxRecurse) {
- if (simplifyWithOpReplaced(FalseVal, CmpLHS, CmpRHS, Q,
+ if (simplifyWithOpReplaced(FalseVal, CmpLHS, CmpRHS, Q.getWithoutUndef(),
/* AllowRefinement */ false,
/* DropFlags */ nullptr, MaxRecurse) == TrueVal)
return FalseVal;
|
[
{
"file": "llvm/test/Transforms/InstSimplify/and-or-implied-cond.ll",
"commands": [
"opt -S -passes=instsimplify < %s"
],
"tests": [
{
"test_name": "and_is_constant",
"test_body": "define i1 @and_is_constant(ptr %arg, ptr %arg2) {\n %icmp = icmp eq ptr %arg, %arg2\n %call = call i1 @llvm.is.constant.i1(i1 %icmp)\n %and = and i1 %call, %icmp\n ret i1 %and\n}\n\n; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)\ndeclare i1 @llvm.is.constant.i1(i1) #0\n\nattributes #0 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "pr98753",
"test_body": "define i1 @pr98753(i32 noundef %x, i32 %y) {\n %cmp1 = icmp ne i32 %x, 0\n %sel = select i1 %cmp1, i32 %y, i32 undef\n %cmp2 = icmp sgt i32 %sel, 0\n %and = and i1 %cmp1, %cmp2\n ret i1 %and\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Miscompilation with libstdc++'s std::optional<int> and -O1",
"body": "https://godbolt.org/z/KjEreWf57\r\n\r\nWith Clang 18.1 and libstdc++, we get different behavior when compared to Clang 17 in the code below.\r\nEDIT: requires at least -O1.\r\n\r\n```cpp\r\n#include <optional>\r\n#include <iostream>\r\n\r\n// defined in a separate compilation unit\r\nint takeIntRefAndReturn0(int&);\r\n\r\nstd::optional<int> shouldReturnEmptyOptional() {\r\n int v = 5;\r\n if (takeIntRefAndReturn0(v))\r\n return v;\r\n return std::nullopt;\r\n}\r\n\r\nint main() {\r\n auto opt = shouldReturnEmptyOptional();\r\n if (opt && *opt > 0) {\r\n std::cout << \"SHOULD NOT BE PRINTED: *opt = \" << *opt << std::endl;\r\n return 1;\r\n }\r\n std::cout << \"SHOULD BE PRINTED\" << std::endl;\r\n}\r\n```\r\n\r\nWith Clang 17, we get `SHOULD BE PRINTED`, while with with Clang 18.1 we get `SHOULD NOT BE PRINTED: *opt = 5`.\r\n\r\nWith git-bisect, I found that this is caused by https://github.com/llvm/llvm-project/commit/060de415af335fdd82910f409e2be3b8457eaa43.\r\n\r\nAn isomorphic example to reproduce this (https://godbolt.org/z/9PsjY17sT):\r\n```cpp\r\nint takeIntRefReturn0(int &);\r\nvoid assertNotReached(int);\r\n\r\nstatic bool logicalAnd(bool a, bool b) { return a && b; }\r\n\r\nint main() {\r\n int v4;\r\n bool v3;\r\n {\r\n int v1 = 5;\r\n int v2 = takeIntRefReturn0(v1);\r\n v3 = v2 != 0;\r\n if (v3)\r\n v4 = v1;\r\n }\r\n // Move to a function so that && is not short cutted.\r\n // v4 will be undefined if v2 == 0, but v3 is false, so the branch shouldn't be entered.\r\n if (logicalAnd(v3, v4 > 0))\r\n assertNotReached(v4);\r\n\r\n return 0;\r\n}\r\n```\r\nNote in the generated LLVM IR that\r\n```llvm\r\n%6 = icmp sgt i32 %5, 0\r\n%7 = and i1 %3, %6\r\nbr i1 %7, label %8, label %9\r\n``` \r\nwas reduced to only\r\n```llvm\r\n%6 = icmp sgt i32 %5, 0\r\nbr i1 %6, label %7, label %8\r\n```",
"author": "cadubentzen",
"labels": [
"regression",
"miscompilation",
"llvm:analysis"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Reproducer: https://alive2.llvm.org/ce/z/p4ZGxe\r\n```\r\n; bin/opt -passes=instcombine test.ll -S\r\ndefine i1 @src(i32 noundef %x, i32 %y) {\r\n %3 = icmp ne i32 %x, 0\r\n %5 = select i1 %3, i32 %y, i32 undef\r\n %6 = icmp sgt i32 %5, 0\r\n %7 = and i1 %3, %6\r\n br i1 %7, label %if.then, label %if.else\r\n\r\nif.then:\r\n call void @use(i32 noundef %5)\r\n ret i1 true\r\n\r\nif.else:\r\n ret i1 false\r\n}\r\n\r\ndefine i1 @tgt(i32 noundef %x, i32 %y) {\r\n %.not = icmp eq i32 %x, 0\r\n %1 = select i1 %.not, i32 undef, i32 %y\r\n %2 = icmp sgt i32 %1, 0\r\n br i1 %2, label %if.then, label %if.else\r\n\r\nif.then: ; preds = %0\r\n call void @use(i32 noundef %1)\r\n ret i1 true\r\n\r\nif.else: ; preds = %0\r\n ret i1 false\r\n}\r\n\r\ndeclare void @use(i32 %x)\r\n```\r\ncc @nikic"
},
{
"author": "nikic",
"body": "A bit simpler using just instsimplify: https://alive2.llvm.org/ce/z/tnkf6A"
},
{
"author": "nikic",
"body": "I expect the fix here is to perform replacements with `Q.getWithoutUndef()`. But probably not just here, but also in other places using simplifyWithOpReplaced(). (Possibly making it always use that mode.)"
},
{
"author": "cadubentzen",
"body": "Thanks a lot for fixing this so quickly! I wonder if this should be included in 18.1.9?"
},
{
"author": "nikic",
"body": "The LLVM 18 branch is already closed, there will be no further releases."
},
{
"author": "thesamesam",
"body": "I'll add the milestone anyway as it's easier to track for downstream backports then."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
111887
|
https://github.com/llvm/llvm-project/issues/111887
|
crash
|
195486950fa64938e62f6d85d31222fa41d0ee09
| 2024-10-10T18:31:43 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "4b5018d2311596778cade4db5177e2ab879cc218",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
1293,
1300
],
[
6322,
6328
],
[
18820,
18826
],
[
18916,
18921
],
[
18936,
18941
],
[
19015,
19031
],
[
19054,
19074
]
],
"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::buildExternalUses",
"tryToReduce"
],
"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 4b5018d2311596778cade4db5177e2ab879cc218
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Thu Oct 10 13:40:22 2024 -0700
[SLP]Track repeated reduced value as it might be vectorized
Need to track changes with the repeated reduced value, since it might be
vectorized in the next attempt for reduction vectorization, to correctly
generate the code and avoid compiler crash.
Fixes #111887
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 94de520a2715..e2958c49b8ca 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -1293,8 +1293,7 @@ public:
using InstrList = SmallVector<Instruction *, 16>;
using ValueSet = SmallPtrSet<Value *, 16>;
using StoreList = SmallVector<StoreInst *, 8>;
- using ExtraValueToDebugLocsMap =
- MapVector<Value *, SmallVector<Instruction *, 2>>;
+ using ExtraValueToDebugLocsMap = SmallDenseSet<Value *, 4>;
using OrdersType = SmallVector<unsigned, 4>;
BoUpSLP(Function *Func, ScalarEvolution *Se, TargetTransformInfo *Tti,
@@ -6322,7 +6321,7 @@ void BoUpSLP::buildExternalUses(
continue;
// Check if the scalar is externally used as an extra arg.
- const auto *ExtI = ExternallyUsedValues.find(Scalar);
+ const auto ExtI = ExternallyUsedValues.find(Scalar);
if (ExtI != ExternallyUsedValues.end()) {
int FoundLane = Entry->findLaneForValue(Scalar);
LLVM_DEBUG(dbgs() << "SLP: Need to extract: Extra arg from lane "
@@ -18820,7 +18819,7 @@ public:
// List of the values that were reduced in other trees as part of gather
// nodes and thus requiring extract if fully vectorized in other trees.
SmallPtrSet<Value *, 4> RequiredExtract;
- Value *VectorizedTree = nullptr;
+ WeakTrackingVH VectorizedTree = nullptr;
bool CheckForReusedReductionOps = false;
// Try to vectorize elements based on their type.
SmallVector<InstructionsState> States;
@@ -18916,6 +18915,7 @@ public:
bool SameScaleFactor = false;
bool OptReusedScalars = IsSupportedHorRdxIdentityOp &&
SameValuesCounter.size() != Candidates.size();
+ BoUpSLP::ExtraValueToDebugLocsMap ExternallyUsedValues;
if (OptReusedScalars) {
SameScaleFactor =
(RdxKind == RecurKind::Add || RdxKind == RecurKind::FAdd ||
@@ -18936,6 +18936,7 @@ public:
emitScaleForReusedOps(Candidates.front(), Builder, Cnt);
VectorizedTree = GetNewVectorizedTree(VectorizedTree, RedVal);
VectorizedVals.try_emplace(OrigV, Cnt);
+ ExternallyUsedValues.insert(OrigV);
continue;
}
}
@@ -19015,17 +19016,18 @@ public:
V.reorderBottomToTop(/*IgnoreReorder=*/true);
// Keep extracted other reduction values, if they are used in the
// vectorization trees.
- BoUpSLP::ExtraValueToDebugLocsMap LocalExternallyUsedValues;
+ BoUpSLP::ExtraValueToDebugLocsMap LocalExternallyUsedValues(
+ ExternallyUsedValues);
// The reduction root is used as the insertion point for new
// instructions, so set it as externally used to prevent it from being
// deleted.
- LocalExternallyUsedValues[ReductionRoot];
+ LocalExternallyUsedValues.insert(ReductionRoot);
for (unsigned Cnt = 0, Sz = ReducedVals.size(); Cnt < Sz; ++Cnt) {
if (Cnt == I || (ShuffledExtracts && Cnt == I - 1))
continue;
for (Value *V : ReducedVals[Cnt])
if (isa<Instruction>(V))
- LocalExternallyUsedValues[TrackedVals[V]];
+ LocalExternallyUsedValues.insert(TrackedVals[V]);
}
if (!IsSupportedHorRdxIdentityOp) {
// Number of uses of the candidates in the vector of values.
@@ -19054,21 +19056,21 @@ public:
// Check if the scalar was vectorized as part of the vectorization
// tree but not the top node.
if (!VLScalars.contains(RdxVal) && V.isVectorized(RdxVal)) {
- LocalExternallyUsedValues[RdxVal];
+ LocalExternallyUsedValues.insert(RdxVal);
continue;
}
Value *OrigV = TrackedToOrig.at(RdxVal);
unsigned NumOps =
VectorizedVals.lookup(OrigV) + At(SameValuesCounter, OrigV);
if (NumOps != ReducedValsToOps.at(OrigV).size())
- LocalExternallyUsedValues[RdxVal];
+ LocalExternallyUsedValues.insert(RdxVal);
}
// Do not need the list of reused scalars in regular mode anymore.
if (!IsSupportedHorRdxIdentityOp)
SameValuesCounter.clear();
for (Value *RdxVal : VL)
if (RequiredExtract.contains(RdxVal))
- LocalExternallyUsedValues[RdxVal];
+ LocalExternallyUsedValues.insert(RdxVal);
V.buildExternalUses(LocalExternallyUsedValues);
V.computeMinimumValueSizes();
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/RISCV/reduced-value-repeated-and-vectorized.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=riscv64-unknown-linux-gnu -mattr=+v < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define void @test() {\nentry:\n %0 = load i16, ptr null, align 2\n %1 = xor i16 %0, 0\n %2 = tail call i16 @llvm.smax.i16(i16 %1, i16 %0)\n %3 = tail call i16 @llvm.smax.i16(i16 0, i16 %2)\n %4 = load i16, ptr getelementptr inbounds (i8, ptr null, i64 6), align 2\n %5 = xor i16 %4, 0\n %6 = tail call i16 @llvm.smax.i16(i16 %5, i16 %0)\n %7 = tail call i16 @llvm.smax.i16(i16 %3, i16 %6)\n %8 = load i16, ptr getelementptr (i8, ptr null, i64 12), align 2\n %9 = xor i16 %8, 0\n %10 = tail call i16 @llvm.smax.i16(i16 %9, i16 %0)\n %11 = tail call i16 @llvm.smax.i16(i16 %7, i16 %10)\n %12 = load i16, ptr getelementptr (i8, ptr null, i64 18), align 2\n %13 = xor i16 %12, 0\n %14 = tail call i16 @llvm.smax.i16(i16 %13, i16 %0)\n %15 = tail call i16 @llvm.smax.i16(i16 %11, i16 %14)\n %16 = tail call i16 @llvm.smax.i16(i16 %15, i16 0)\n ret void\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i16 @llvm.smax.i16(i16, i16) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SLP-Vectorizer] Segfault in `HorizontalReduction::matchAssociativeReduction`",
"body": "Testcase:\r\n```llvm ir\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine i32 @main() #0 {\r\nfor.body.preheader:\r\n %0 = load i16, ptr null, align 2\r\n %1 = xor i16 %0, 0\r\n %2 = tail call i16 @llvm.smax.i16(i16 %1, i16 %0)\r\n %3 = tail call i16 @llvm.smax.i16(i16 0, i16 %2)\r\n %4 = load i16, ptr getelementptr inbounds (i8, ptr null, i64 6), align 2\r\n %5 = xor i16 %4, 0\r\n %6 = tail call i16 @llvm.smax.i16(i16 %5, i16 %0)\r\n %7 = tail call i16 @llvm.smax.i16(i16 %3, i16 %6)\r\n %8 = load i16, ptr getelementptr (i8, ptr null, i64 12), align 2\r\n %9 = xor i16 %8, 0\r\n %10 = tail call i16 @llvm.smax.i16(i16 %9, i16 %0)\r\n %11 = tail call i16 @llvm.smax.i16(i16 %7, i16 %10)\r\n %12 = load i16, ptr getelementptr (i8, ptr null, i64 18), align 2\r\n %13 = xor i16 %12, 0\r\n %14 = tail call i16 @llvm.smax.i16(i16 %13, i16 %0)\r\n %15 = tail call i16 @llvm.smax.i16(i16 %11, i16 %14)\r\n %16 = tail call i16 @llvm.smax.i16(i16 %15, i16 0)\r\n ret i32 0\r\n}\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\r\ndeclare i16 @llvm.smax.i16(i16, i16) #1\r\n\r\n; uselistorder directives\r\nuselistorder ptr null, { 3, 2, 1, 0 }\r\nuselistorder ptr @llvm.smax.i16, { 8, 7, 6, 5, 4, 3, 2, 1, 0 }\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-b,-e,-experimental-smctr,-experimental-smmpm,-experimental-smnpm,-experimental-ssctr,-experimental-ssnpm,-experimental-sspm,-experimental-supm,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-experimental-zvbc32e,-experimental-zvkgs,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssqosid,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zacas,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\nattributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\r\n```\r\n\r\nCommand/backtrace:\r\n```\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=slp-vectorizer reduced.ll\r\nWARNING: You're attempting to print out a bitcode file.\r\nThis is inadvisable as it may cause display problems. If\r\nyou REALLY want to taste LLVM bitcode first-hand, you\r\ncan force output with the `-f' option.\r\n\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=slp-vectorizer reduced.ll\r\n1. Running pass \"function(slp-vectorizer)\" on module \"reduced.ll\"\r\n2. Running pass \"slp-vectorizer\" on function \"main\"\r\n #0 0x0000602da32b35e0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x30fe5e0)\r\n #1 0x0000602da32b09ef llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x30fb9ef)\r\n #2 0x0000602da32b0b45 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007ea045842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x0000602da29cea64 llvm::getUnderlyingObject(llvm::Value const*, unsigned int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2819a64)\r\n #5 0x0000602da22d706d (anonymous namespace)::HorizontalReduction::matchAssociativeReduction(llvm::slpvectorizer::BoUpSLP&, llvm::Instruction*, llvm::ScalarEvolution&, llvm::DataLayout const&, llvm::TargetLibraryInfo const&)::'lambda0'(unsigned long, llvm::LoadInst*)::operator()(unsigned long, llvm::LoadInst*) const SLPVectorizer.cpp:0:0\r\n #6 0x0000602da22d797e generateKeySubkey(llvm::Value*, llvm::TargetLibraryInfo const*, llvm::function_ref<llvm::hash_code (unsigned long, llvm::LoadInst*)>, bool) (.constprop.0) SLPVectorizer.cpp:0:0\r\n #7 0x0000602da230d085 (anonymous namespace)::HorizontalReduction::matchAssociativeReduction(llvm::slpvectorizer::BoUpSLP&, llvm::Instruction*, llvm::ScalarEvolution&, llvm::DataLayout const&, llvm::TargetLibraryInfo const&) SLPVectorizer.cpp:0:0\r\n #8 0x0000602da231f7cc llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x216a7cc)\r\n #9 0x0000602da2323ec2 llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*) (.constprop.0) SLPVectorizer.cpp:0:0\r\n#10 0x0000602da2327dfb llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2172dfb)\r\n#11 0x0000602da232e400 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\r\n#12 0x0000602da232ef62 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2179f62)\r\n#13 0x0000602da1071366 llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xebc366)\r\n#14 0x0000602da30bc88f llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2f0788f)\r\n#15 0x0000602da1073bb6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xebebb6)\r\n#16 0x0000602da30bac1b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2f05c1b)\r\n#17 0x0000602da106fcc6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xebacc6)\r\n#18 0x0000602da30bb77d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2f0677d)\r\n#19 0x0000602da088061b llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x6cb61b)\r\n#20 0x0000602da0872331 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x6bd331)\r\n#21 0x00007ea045829d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#22 0x00007ea045829e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#23 0x00007ea045829e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#24 0x0000602da0868855 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x6b3855)\r\nzsh: segmentation fault (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\n\r\nGodbolt: https://godbolt.org/z/nbar8q6ej\r\n\r\nFound via fuzzer (C program before reduction).",
"author": "patrick-rivos",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
131818
|
https://github.com/llvm/llvm-project/issues/131818
|
crash
|
84909d797782a0dcf240f79a8e5e863d8165c03f
| 2025-03-18T15:06:59 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "45090b3059562b32723cd25679db75d1574ab04e",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
14086,
14096
]
],
"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 45090b3059562b32723cd25679db75d1574ab04e
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Tue Mar 18 09:32:23 2025 -0700
[SLP]Check the whole def-use chain in the tree to find proper dominance, if the last instruction is the same
If the insertion point (last instruction) of the user nodes is the same,
need to check the whole def-use chain in the tree to find proper
dominance to prevent a compiler crash.
Fixes #131818
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 24171f1d9a06..4a835bc797ab 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -14086,11 +14086,18 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
auto CheckParentNodes = [&](const TreeEntry *User1, const TreeEntry *User2,
unsigned EdgeIdx) {
const TreeEntry *Ptr1 = User1;
+ const TreeEntry *Ptr2 = User2;
+ SmallDenseMap<const TreeEntry *, unsigned> PtrToIdx;
+ while (Ptr2) {
+ PtrToIdx.try_emplace(Ptr2, EdgeIdx);
+ EdgeIdx = Ptr2->UserTreeIndex.EdgeIdx;
+ Ptr2 = Ptr2->UserTreeIndex.UserTE;
+ }
while (Ptr1) {
unsigned Idx = Ptr1->UserTreeIndex.EdgeIdx;
Ptr1 = Ptr1->UserTreeIndex.UserTE;
- if (Ptr1 == User2)
- return Idx < EdgeIdx;
+ if (auto It = PtrToIdx.find(Ptr1); It != PtrToIdx.end())
+ return Idx < It->second;
}
return false;
};
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/same-last-instruction-different-parents.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine i32 @test(i32 %0, i1 %1) {\n;\n %3 = sitofp i32 %0 to double\n %4 = sitofp i32 %0 to double\n %5 = sitofp i32 %0 to double\n br i1 %1, label %6, label %9\n\n6:\n %7 = tail call double @llvm.fmuladd.f64(double %4, double 0.000000e+00, double 0.000000e+00)\n %8 = tail call double @llvm.fmuladd.f64(double %5, double 0.000000e+00, double 0.000000e+00)\n br label %18\n\n9:\n br i1 false, label %15, label %10\n\n10:\n %11 = call double @llvm.copysign.f64(double 0.000000e+00, double %3)\n %12 = tail call double @llvm.fmuladd.f64(double %11, double %4, double 0.000000e+00)\n %13 = call double @llvm.copysign.f64(double 0.000000e+00, double %5)\n %14 = tail call double @llvm.fmuladd.f64(double %13, double 0.000000e+00, double 0.000000e+00)\n br label %15\n\n15:\n %16 = phi double [ %12, %10 ], [ 0.000000e+00, %9 ]\n %17 = phi double [ %14, %10 ], [ 0.000000e+00, %9 ]\n br label %18\n\n18:\n %19 = phi double [ %17, %15 ], [ %8, %6 ]\n %20 = phi double [ %16, %15 ], [ %7, %6 ]\n %21 = fmul double %20, %19\n %22 = fptosi double %21 to i32\n ret i32 %22\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[clang] Crash at -O3: Instruction does not dominate all uses!",
"body": "This code crashes at `-O3`:\n\n```c\nint a;\ndouble b;\nlong c;\nint d(long f, long g) {\n if (f + g)\n return 1;\n for (long e = 0; e < g; e++)\n *(char *)e = 5;\n return 0;\n}\nint h(int f) {\n double i = 0.270112271089232341485679099e4;\n b = 0.1e1;\n for (; c; c--) {\n i = i * (80 + f) * (9 + f) + a;\n a = 0;\n b = b * f * (d(-42, f) + f) + 0.11623987080032122878585294e22;\n }\n return i / b;\n}\nvoid main() {}\n```\n\nCompiler Explorer: https://godbolt.org/z/b4YEsPMrq\n\nBisected to https://github.com/llvm/llvm-project/commit/d57884011e8c57b118b831614b692ba4bc8b5aca, which was committed by @alexey-bataev \n\nCrash:\n\n```console\nInstruction does not dominate all uses!\n %3 = insertelement <2 x i32> %2, i32 %f, i64 1\n %0 = insertelement <2 x i32> %3, i32 %add1, i64 0\nin function h\nfatal error: error in backend: Broken function found, compilation aborted!\n```\n\nBacktrace:\n\n```console\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O3 -Wall -Wextra <source>\n1.\t<eof> parser at end of file\n2.\tCode generation\n3.\tRunning pass 'Function Pass Manager' on module '<source>'.\n4.\tRunning pass 'Module Verifier' on function '@h'\n #0 0x0000000003e87c38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e87c38)\n #1 0x0000000003e858c4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e858c4)\n #2 0x0000000003dcacb6 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dcacb6)\n #3 0x0000000003e7cfee llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e7cfee)\n #4 0x0000000000d4e5a0 LLVMErrorHandler(void*, char const*, bool) cc1_main.cpp:0:0\n #5 0x0000000003dd5443 llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dd5443)\n #6 0x0000000003dd55a8 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dd55a8)\n #7 0x0000000003887952 (anonymous namespace)::VerifierLegacyPass::runOnFunction(llvm::Function&) Verifier.cpp:0:0\n #8 0x00000000037d28df llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x37d28df)\n #9 0x00000000037d2c91 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x37d2c91)\n#10 0x00000000037d3531 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x37d3531)\n#11 0x000000000413d67e clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x413d67e)\n#12 0x00000000048429a0 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x48429a0)\n#13 0x00000000064aecac clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x64aecac)\n#14 0x0000000004842da8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4842da8)\n#15 0x0000000004b127f5 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4b127f5)\n#16 0x0000000004a94a2e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4a94a2e)\n#17 0x0000000004c024fe clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4c024fe)\n#18 0x0000000000d50baf cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd50baf)\n#19 0x0000000000d4836a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#20 0x000000000488b309 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0\n#21 0x0000000003dcabf4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dcabf4)\n#22 0x000000000488b91f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0\n#23 0x000000000484e38d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x484e38d)\n#24 0x000000000484f41e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x484f41e)\n#25 0x0000000004856af5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4856af5)\n#26 0x0000000000d4d9a8 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd4d9a8)\n#27 0x0000000000c146c4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc146c4)\n#28 0x00007acc03029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#29 0x00007acc03029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#30 0x0000000000d47e15 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd47e15)\n```",
"author": "cardigan1008",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
129242
|
https://github.com/llvm/llvm-project/issues/129242
|
crash
|
5faa5f848a35de13196f2f516f51aa970da942b4
| 2025-02-28T13:35:26 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "a36a67c79afaa1fdd0dbe0440ec852fd4eb3a532",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
11425,
11435
]
],
"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::getEntryCost"
],
"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 a36a67c79afaa1fdd0dbe0440ec852fd4eb3a532
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Fri Feb 28 13:15:46 2025 -0800
[SLP]Fix the analysis of the user buildvector nodes for minbitwidth
If the user node is a buildvector/gather node and it has no internal
instructions state, need to check properly for this state and check the
type of the node itself, not its operands.
Fixes #129242
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 4a68e0ee5989..4f3fd6d53909 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -11425,11 +11425,14 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
E->Idx != 0 &&
(E->getOpcode() != Instruction::Load || E->UserTreeIndex)) {
const EdgeInfo &EI = E->UserTreeIndex;
- if (EI.UserTE->getOpcode() != Instruction::Select ||
+ if (!EI.UserTE->hasState() ||
+ EI.UserTE->getOpcode() != Instruction::Select ||
EI.EdgeIdx != 0) {
auto UserBWIt = MinBWs.find(EI.UserTE);
Type *UserScalarTy =
- EI.UserTE->getOperand(EI.EdgeIdx).front()->getType();
+ EI.UserTE->isGather()
+ ? EI.UserTE->Scalars.front()->getType()
+ : EI.UserTE->getOperand(EI.EdgeIdx).front()->getType();
if (UserBWIt != MinBWs.end())
UserScalarTy = IntegerType::get(ScalarTy->getContext(),
UserBWIt->second.first);
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/user-buildvector-with-minbiwidth.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine i32 @test(i8 %0, i32 %conv2, i1 %cmp.i, i64 %shl.i) {\n;\nentry:\n %conv21 = sext i8 %0 to i32\n %conv7 = zext i32 %conv2 to i64\n %cond.i = shl i64 %conv7, %shl.i\n %1 = and i64 %cond.i, 4294967295\n %.not = icmp eq i64 %1, 1\n %conv7.1 = zext i32 %conv2 to i64\n %cond.i.1 = shl i64 %conv7.1, %shl.i\n %2 = and i64 %cond.i.1, 4294967295\n %.not.1 = icmp eq i64 %2, 1\n %sub.2 = or i32 %conv21, 1\n %cond.2 = select i1 %cmp.i, i32 %sub.2, i32 0\n %conv7.2 = zext i32 %cond.2 to i64\n %cmp.i.2 = icmp slt i32 %cond.2, 1\n %shl.i.2 = zext i1 %cmp.i.2 to i64\n %cond.i.2 = shl i64 %conv7.2, %shl.i.2\n %3 = and i64 %cond.i.2, 4294967295\n %.not.2 = icmp eq i64 %3, 1\n %sub.3 = or i32 %conv21, 1\n %cond.3 = select i1 %cmp.i, i32 %sub.3, i32 0\n %conv7.3 = zext i32 %cond.3 to i64\n %cmp.i.3 = icmp slt i32 %cond.3, 1\n %shl.i.3 = zext i1 %cmp.i.3 to i64\n %cond.i.3 = shl i64 %conv7.3, %shl.i.3\n %4 = and i64 %cond.i.3, 4294967295\n %.not.3 = icmp eq i64 %4, 1\n %sub.4 = or i32 %conv21, 1\n %cond.4 = select i1 %cmp.i, i32 %sub.4, i32 0\n %conv7.4 = zext i32 %cond.4 to i64\n %cmp.i.4 = icmp slt i32 %cond.4, 1\n %shl.i.4 = zext i1 %cmp.i.4 to i64\n %cond.i.4 = shl i64 %conv7.4, %shl.i.4\n %5 = and i64 %cond.i.4, 4294967295\n %.not.4 = icmp eq i64 %5, 1\n %sub.5 = or i32 %conv21, 1\n %cond.5 = select i1 %cmp.i, i32 %sub.5, i32 0\n %conv7.5 = zext i32 %cond.5 to i64\n %cmp.i.5 = icmp slt i32 %cond.5, 1\n %shl.i.5 = zext i1 %cmp.i.5 to i64\n %cond.i.5 = shl i64 %conv7.5, %shl.i.5\n %6 = and i64 %cond.i.5, 4294967295\n %.not.5 = icmp eq i64 %6, 1\n %sub.6 = or i32 %conv21, 1\n %cond.6 = select i1 %cmp.i, i32 %sub.6, i32 0\n %conv7.6 = zext i32 %cond.6 to i64\n %cmp.i.6 = icmp slt i32 %cond.6, 1\n %shl.i.6 = zext i1 %cmp.i.6 to i64\n %cond.i.6 = shl i64 %conv7.6, %shl.i.6\n %7 = and i64 %cond.i.6, 4294967295\n %.not.6 = icmp eq i64 %7, 1\n %sub.7 = or i32 %conv21, 1\n %cond.7 = select i1 %cmp.i, i32 %sub.7, i32 0\n %conv7.7 = zext i32 %cond.7 to i64\n %cmp.i.7 = icmp slt i32 %cond.7, 1\n %shl.i.7 = zext i1 %cmp.i.7 to i64\n %cond.i.7 = shl i64 %conv7.7, %shl.i.7\n %8 = and i64 %cond.i.7, 4294967295\n %.not.7 = icmp eq i64 %8, 1\n %sub.8 = or i32 %conv21, 1\n %cond.8 = select i1 %cmp.i, i32 %sub.8, i32 0\n %conv7.8 = zext i32 %cond.8 to i64\n %cmp.i.8 = icmp slt i32 %cond.8, 1\n %shl.i.8 = zext i1 %cmp.i.8 to i64\n %cond.i.8 = shl i64 %conv7.8, %shl.i.8\n %9 = and i64 %cond.i.8, 4294967295\n %.not.8 = icmp eq i64 %9, 1\n %sub.9 = or i32 %conv21, 1\n %cond.9 = select i1 %cmp.i, i32 %sub.9, i32 0\n %conv7.9 = zext i32 %cond.9 to i64\n %cmp.i.9 = icmp slt i32 %cond.9, 1\n %shl.i.9 = zext i1 %cmp.i.9 to i64\n %cond.i.9 = shl i64 %conv7.9, %shl.i.9\n %10 = and i64 %cond.i.9, 4294967295\n %.not.9 = icmp eq i64 %10, 1\n br label %while.body\n\nwhile.body:\n br i1 %.not, label %for.inc, label %if.then10\n\nif.then10:\n br label %for.inc\n\nfor.inc:\n br i1 %.not.1, label %for.inc.1, label %if.then10.1\n\nif.then10.1:\n br label %for.inc.1\n\nfor.inc.1:\n br i1 %.not.2, label %for.inc.2, label %if.then10.2\n\nif.then10.2:\n br label %for.inc.2\n\nfor.inc.2:\n br i1 %.not.3, label %for.inc.3, label %if.then10.3\n\nif.then10.3:\n br label %for.inc.3\n\nfor.inc.3:\n br i1 %.not.4, label %for.inc.4, label %if.then10.4\n\nif.then10.4:\n br label %for.inc.4\n\nfor.inc.4:\n br i1 %.not.5, label %for.inc.5, label %if.then10.5\n\nif.then10.5:\n br label %for.inc.5\n\nfor.inc.5:\n br i1 %.not.6, label %for.inc.6, label %if.then10.6\n\nif.then10.6:\n br label %for.inc.6\n\nfor.inc.6:\n br i1 %.not.7, label %for.inc.7, label %if.then10.7\n\nif.then10.7:\n br label %for.inc.7\n\nfor.inc.7:\n br i1 %.not.8, label %for.inc.8, label %if.then10.8\n\nif.then10.8:\n br label %for.inc.8\n\nfor.inc.8:\n br i1 %.not.9, label %while.body, label %if.then10.9\n\nif.then10.9:\n br label %while.body\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "clang crashes on valid code at -O{2,3} on x86_64-linux-gnu: Assertion `valid() && \"InstructionsState is invalid.\"' failed",
"body": "It appears to be a recent regression as it doesn't reproduce with 19.1.0 and earlier.\n\nCompiler Explorer: https://godbolt.org/z/8KTq9hGv9\n\n```\n[516] % clangtk -v\nclang version 21.0.0git (https://github.com/llvm/llvm-project.git d0edd931bcc328b9502289d346f2b2219341f853)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\nBuild config: +assertions\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\nCandidate multilib: .;@m64\nSelected multilib: .;@m64\n[517] % \n[517] % clangtk -O2 -w small.c\nclang-21: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:821: llvm::Instruction* {anonymous}::InstructionsState::getMainOp() const: Assertion `valid() && \"InstructionsState is invalid.\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\nStack dump:\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-21 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/20250227-clangtk-m64-O3-build-235136/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20250227-clangtk-m64-O3-build-235136/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/21 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -w -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-933a0f.o -x c small.c\n1.\t<eof> parser at end of file\n2.\tOptimizer\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"small.c\"\n4.\tRunning pass \"slp-vectorizer\" on function \"main\"\n #0 0x00005597e9b142df llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x455e2df)\n #1 0x00005597e9b11ab4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007fa06c8aa420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\n #3 0x00007fa06c2e100b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\n #4 0x00007fa06c2c0859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\n #5 0x00007fa06c2c0729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\n #6 0x00007fa06c2c0729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\n #7 0x00007fa06c2d1fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\n #8 0x00005597eb591745 (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5fdb745)\n #9 0x00005597eb62a4e5 llvm::slpvectorizer::BoUpSLP::getEntryCost(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallPtrSetImpl<llvm::Value*>&)::'lambda0'(llvm::function_ref<llvm::InstructionCost (unsigned int)>, llvm::function_ref<llvm::InstructionCost (llvm::InstructionCost)>)::operator()(llvm::function_ref<llvm::InstructionCost (unsigned int)>, llvm::function_ref<llvm::InstructionCost (llvm::InstructionCost)>) const SLPVectorizer.cpp:0:0\n#10 0x00005597eb633034 llvm::slpvectorizer::BoUpSLP::getEntryCost(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallPtrSetImpl<llvm::Value*>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x607d034)\n#11 0x00005597eb668741 llvm::slpvectorizer::BoUpSLP::getTreeCost(llvm::ArrayRef<llvm::Value*>) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60b2741)\n#12 0x00005597eb672691 llvm::SLPVectorizerPass::tryToVectorizeList(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60bc691)\n#13 0x00005597eb676e5e bool llvm::SLPVectorizerPass::vectorizeCmpInsts<std::reverse_iterator<llvm::CmpInst* const*>>(llvm::iterator_range<std::reverse_iterator<llvm::CmpInst* const*>>, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60c0e5e)\n#14 0x00005597eb6773db llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&)::'lambda3'(bool)::operator()(bool) const SLPVectorizer.cpp:0:0\n#15 0x00005597eb67ac20 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60c4c20)\n#16 0x00005597eb681396 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\n#17 0x00005597eb681ef3 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60cbef3)\n#18 0x00005597eb104166 llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5b4e166)\n#19 0x00005597e948caf9 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x3ed6af9)\n#20 0x00005597e6d6c406 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x17b6406)\n#21 0x00005597e948b362 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x3ed5362)\n#22 0x00005597e6d6a4b6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x17b44b6)\n#23 0x00005597e948ad81 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x3ed4d81)\n#24 0x00005597e9ddb283 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\n#25 0x00005597e9ddf573 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x4829573)\n#26 0x00005597ea51bba0 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x4f65ba0)\n#27 0x00005597ebe39acc clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x6883acc)\n#28 0x00005597ea51bfc8 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x4f65fc8)\n#29 0x00005597ea7f2779 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x523c779)\n#30 0x00005597ea77325e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x51bd25e)\n#31 0x00005597ea8e7626 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5331626)\n#32 0x00005597e68fefb7 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x1348fb7)\n#33 0x00005597e68f66ea ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#34 0x00005597e68fa97a clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x134497a)\n#35 0x00005597e67edccb main (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x1237ccb)\n#36 0x00007fa06c2c2083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\n#37 0x00005597e68f617e _start (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x134017e)\nclangtk: error: unable to execute command: Aborted\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\nclang version 21.0.0git (https://github.com/llvm/llvm-project.git d0edd931bcc328b9502289d346f2b2219341f853)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\nBuild config: +assertions\nclangtk: note: diagnostic msg: \n********************\n\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\nPreprocessed source(s) and associated run script(s) are located at:\nclangtk: note: diagnostic msg: /tmp/small-fd80bc.c\nclangtk: note: diagnostic msg: /tmp/small-fd80bc.sh\nclangtk: note: diagnostic msg: \n\n********************\n[518] % \n[518] % cat small.c\nint a[1], g;\nchar b, c;\nvolatile int d;\nlong e, f;\nlong h(long i) { return i > 1 ? i : i << 1; }\nint main() {\n if (g)\n while (1) {\n b = 0;\n for (; b < 10; b++) {\n e = c & b ? 0 : c - b;\n f = h(e);\n g = (a != 0) % (unsigned)f;\n if (g)\n d;\n }\n }\n return 0;\n}\n```\n\n",
"author": "zhendongsu",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
124518
|
https://github.com/llvm/llvm-project/issues/124518
|
crash
|
2ec88374e07f8ec395b7bf414bf1bdda88cebfc6
| 2025-01-27T07:58:41 |
[
"llvm/test/Transforms/LoopUnrollAndJam"
] |
{
"fix_commit": "3ef33066bb32a9d9b76d72c6de6a7ae9ff72ddcc",
"components": [
"LoopUnrollAndJamPass"
],
"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": [
[
425,
431
],
[
441,
448
],
[
457,
467
]
],
"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": 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": [
"LoopUnrollAndJamPass::run",
"tryToUnrollAndJamLoop"
],
"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 3ef33066bb32a9d9b76d72c6de6a7ae9ff72ddcc
Author: David Green <david.green@arm.com>
Date: Sat Mar 29 19:21:34 2025 +0000
[UnrollAndJam] Do not preserve loop nests if a loop was fully unrolled. (#133510)
If UnJ completely unrolls a loop and removes it entirely, the loop
remains in the current loop nest. If the loop nest gets reused the loops
will no longer be valid. As there is no way to remove a loop from a
LoopNest, this patch removes the preserve of the LoopNestAnalysis so
that it will be regenerated.
Fixes #124518
diff --git a/llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp
index f1d1f3bc1e30..4fe74c7c3bbc 100644
--- a/llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp
@@ -425,7 +425,7 @@ static bool tryToUnrollAndJamLoop(LoopNest &LN, DominatorTree &DT, LoopInfo &LI,
const TargetTransformInfo &TTI,
AssumptionCache &AC, DependenceInfo &DI,
OptimizationRemarkEmitter &ORE, int OptLevel,
- LPMUpdater &U) {
+ LPMUpdater &U, bool &AnyLoopRemoved) {
bool DidSomething = false;
ArrayRef<Loop *> Loops = LN.getLoops();
Loop *OutmostLoop = &LN.getOutermostLoop();
@@ -441,8 +441,11 @@ static bool tryToUnrollAndJamLoop(LoopNest &LN, DominatorTree &DT, LoopInfo &LI,
tryToUnrollAndJamLoop(L, DT, &LI, SE, TTI, AC, DI, ORE, OptLevel);
if (Result != LoopUnrollResult::Unmodified)
DidSomething = true;
- if (L == OutmostLoop && Result == LoopUnrollResult::FullyUnrolled)
- U.markLoopAsDeleted(*L, LoopName);
+ if (Result == LoopUnrollResult::FullyUnrolled) {
+ if (L == OutmostLoop)
+ U.markLoopAsDeleted(*L, LoopName);
+ AnyLoopRemoved = true;
+ }
}
return DidSomething;
@@ -457,11 +460,13 @@ PreservedAnalyses LoopUnrollAndJamPass::run(LoopNest &LN,
DependenceInfo DI(&F, &AR.AA, &AR.SE, &AR.LI);
OptimizationRemarkEmitter ORE(&F);
+ bool AnyLoopRemoved = false;
if (!tryToUnrollAndJamLoop(LN, AR.DT, AR.LI, AR.SE, AR.TTI, AR.AC, DI, ORE,
- OptLevel, U))
+ OptLevel, U, AnyLoopRemoved))
return PreservedAnalyses::all();
auto PA = getLoopPassPreservedAnalyses();
- PA.preserve<LoopNestAnalysis>();
+ if (!AnyLoopRemoved)
+ PA.preserve<LoopNestAnalysis>();
return PA;
}
|
[
{
"file": "llvm/test/Transforms/LoopUnrollAndJam/delete_middle_loop.ll",
"commands": [
"opt -passes=\"loop(invalidate<all>,loop-unroll-and-jam,loop-unroll-and-jam)\" -allow-unroll-and-jam -unroll-and-jam-count=4 < %s -S"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n; This test completely unrolls the middle loop out of a 3-deep loop nest.\n\ndefine i16 @test_it() {\n;\nentry:\n br label %for.cond\n\nfor.cond: ; preds = %do.cond, %entry\n br label %do.body2\n\ndo.body2: ; preds = %do.cond, %for.cond\n br label %while.cond3\n\nwhile.cond3: ; preds = %while.cond3, %do.body2\n br i1 true, label %do.cond, label %while.cond3\n\ndo.cond: ; preds = %while.cond3\n br i1 true, label %for.cond, label %do.body2\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "LoopUnrollAndJamPass crash: GenericLoopInfo.h:146: [...] Assertion `!isInvalid() && \"Loop not in a valid state!\"' failed.",
"body": "llvm commit: 6805d7e8aa5f\n\nReproduce with:\n```opt -passes=\"loop(invalidate<all>,loop-unroll-and-jam,loop-unroll-and-jam)\" bbi-103085.ll -o /dev/null -S -unroll-and-jam-count=4 -mcpu=cortex-a55 -mtriple=aarch64```\n\nResult:\n```\nopt: ../include/llvm/Support/GenericLoopInfo.h:146: const std::vector<LoopT *> &llvm::LoopBase<llvm::BasicBlock, llvm::Loop>::getSubLoops() const [BlockT = llvm::BasicBlock, LoopT = llvm::Loop]: Assertion `!isInvalid() && \"Loop not in a valid state!\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0.\tProgram arguments: build-all/bin/opt -passes=loop(invalidate<all>,loop-unroll-and-jam,loop-unroll-and-jam) bbi-103085.ll -o /dev/null -S -unroll-and-jam-count=4 -mcpu=cortex-a55 -mtriple=aarch64\n1.\tRunning pass \"function(loop(invalidate<all>,loop-unroll-and-jam,loop-unroll-and-jam))\" on module \"bbi-103085.ll\"\n2.\tRunning pass \"loop(invalidate<all>,loop-unroll-and-jam,loop-unroll-and-jam)\" on function \"test_it\"\n #0 0x0000564cc1e14ac6 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (build-all/bin/opt+0x45ceac6)\n #1 0x0000564cc1e1250e llvm::sys::RunSignalHandlers() (build-all/bin/opt+0x45cc50e)\n #2 0x0000564cc1e15379 SignalHandler(int) Signals.cpp:0:0\n #3 0x00007fafbeb0bd10 __restore_rt (/lib64/libpthread.so.0+0x12d10)\n #4 0x00007fafbc4ab52f raise (/lib64/libc.so.6+0x4e52f)\n #5 0x00007fafbc47ee65 abort (/lib64/libc.so.6+0x21e65)\n #6 0x00007fafbc47ed39 _nl_load_domain.cold.0 (/lib64/libc.so.6+0x21d39)\n #7 0x00007fafbc4a3e86 (/lib64/libc.so.6+0x46e86)\n #8 0x0000564cc274b6cb void llvm::appendReversedLoopsToWorklist<llvm::iterator_range<std::reverse_iterator<llvm::Loop* const*>>>(llvm::iterator_range<std::reverse_iterator<llvm::Loop* const*>>&&, llvm::SmallPriorityWorklist<llvm::Loop*, 4u>&) (build-all/bin/opt+0x4f056cb)\n #9 0x0000564cc274b42e void llvm::appendLoopsToWorklist<llvm::ArrayRef<llvm::Loop*>&>(llvm::ArrayRef<llvm::Loop*>&, llvm::SmallPriorityWorklist<llvm::Loop*, 4u>&) (build-all/bin/opt+0x4f0542e)\n#10 0x0000564cc381dfce llvm::LoopUnrollAndJamPass::run(llvm::LoopNest&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (build-all/bin/opt+0x5fd7fce)\n#11 0x0000564cc328d01d llvm::detail::PassModel<llvm::LoopNest, llvm::LoopUnrollAndJamPass, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::LoopNest&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) PassBuilderPipelines.cpp:0:0\n#12 0x0000564cc34ff5ed std::optional<llvm::PreservedAnalyses> llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::runSinglePass<llvm::LoopNest, std::unique_ptr<llvm::detail::PassConcept<llvm::LoopNest, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, std::default_delete<llvm::detail::PassConcept<llvm::LoopNest, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>>>>(llvm::LoopNest&, std::unique_ptr<llvm::detail::PassConcept<llvm::LoopNest, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, std::default_delete<llvm::detail::PassConcept<llvm::LoopNest, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>>>&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&, llvm::PassInstrumentation&) (build-all/bin/opt+0x5cb95ed)\n#13 0x0000564cc34fe8e5 llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::runWithLoopNestPasses(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (build-all/bin/opt+0x5cb88e5)\n#14 0x0000564cc34fe480 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&) (build-all/bin/opt+0x5cb8480)\n#15 0x0000564cc327a8bd llvm::detail::PassModel<llvm::Loop, llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) PassBuilderPipelines.cpp:0:0\n#16 0x0000564cc35001a1 llvm::FunctionToLoopPassAdaptor::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (build-all/bin/opt+0x5cba1a1)\n#17 0x0000564cc327eedd llvm::detail::PassModel<llvm::Function, llvm::FunctionToLoopPassAdaptor, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) PassBuilderPipelines.cpp:0:0\n#18 0x0000564cc2035a27 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (build-all/bin/opt+0x47efa27)\n#19 0x0000564cc32846cd llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) PassBuilderPipelines.cpp:0:0\n#20 0x0000564cc203a5fe llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (build-all/bin/opt+0x47f45fe)\n#21 0x0000564cc327c19d llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) PassBuilderPipelines.cpp:0:0\n#22 0x0000564cc2034717 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (build-all/bin/opt+0x47ee717)\n#23 0x0000564cc320468c 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) (build-all/bin/opt+0x59be68c)\n#24 0x0000564cc1dd7712 optMain (build-all/bin/opt+0x4591712)\n#25 0x00007fafbc4977e5 __libc_start_main (/lib64/libc.so.6+0x3a7e5)\n#26 0x0000564cc1dd532e _start (build-all/bin/opt+0x458f32e)\nAbort\n```\n\n[bbi-103085.ll.gz](https://github.com/user-attachments/files/18556221/bbi-103085.ll.gz)",
"author": "mikaelholmen",
"labels": [
"crash",
"llvm:transforms",
"generated by fuzzer"
],
"comments": [
{
"author": "mikaelholmen",
"body": "The opt pipeline used to triggered this is non-standard and generated by a fuzzer, so I'm labelling this with \"generated by fuzzer\". I don't know if that the intended use. If not, please let me know."
},
{
"author": "davemgreen",
"body": "Do you have the IR reproducer too? Thanks"
},
{
"author": "mikaelholmen",
"body": "> Do you have the IR reproducer too? Thanks\n\nBah, sorry. Attached it to the original post now.\nThanks!"
},
{
"author": "mikaelholmen",
"body": "I noticed that if we build opt with ASAN and run the bbi-103085.ll testcase we get\n```\n==3349467==ERROR: AddressSanitizer: use-after-poison on address 0x521000007a40 at pc 0x55713d205877 bp 0x7ffdd1999e50 sp 0x7ffdd1999e48\nREAD of size 1 at 0x521000007a40 thread T0\n #0 0x55713d205876 in isInvalid /repo/llvm/build-all-bbisdk-asan/../include/llvm/Support/GenericLoopInfo.h:219:12\n #1 0x55713d205876 in getSubLoops /repo/llvm/build-all-bbisdk-asan/../include/llvm/Support/GenericLoopInfo.h:146:5\n #2 0x55713d205876 in begin /repo/llvm/build-all-bbisdk-asan/../include/llvm/Support/GenericLoopInfo.h:156:35\n #3 0x55713d205876 in void llvm::appendReversedLoopsToWorklist<llvm::iterator_range<std::__1::reverse_iterator<llvm::Loop* const*>>>(llvm::iterator_range<std::__1::reverse_iterator<llvm::Loop* const*>>&&, llvm::SmallPriorityWorklist<llvm::Loop*, 4u>&) /repo/llvm/build-all-bbisdk-asan/../lib/Transforms/Utils/LoopUtils.cpp:1808:34\n #4 0x55713d204ad9 in void llvm::appendLoopsToWorklist<llvm::ArrayRef<llvm::Loop*>&>(llvm::ArrayRef<llvm::Loop*>&, llvm::SmallPriorityWorklist<llvm::Loop*, 4u>&) /repo/llvm/build-all-bbisdk-asan/../lib/Transforms/Utils/LoopUtils.cpp:1820:3\n #5 0x55714083fe1b in tryToUnrollAndJamLoop /repo/llvm/build-all-bbisdk-asan/../lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp:436:3\n #6 0x55714083fe1b in llvm::LoopUnrollAndJamPass::run(llvm::LoopNest&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) /repo/llvm/build-all-bbisdk-asan/../lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp:460:8\n #7 0x55713f72db11 in llvm::detail::PassModel<llvm::LoopNest, llvm::LoopUnrollAndJamPass, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::LoopNest&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerInternal.h:91:17\n #8 0x55713fec0dd7 in std::__1::optional<llvm::PreservedAnalyses> llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::runSinglePass<llvm::LoopNest, std::__1::unique_ptr<llvm::detail::PassConcept<llvm::LoopNest, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, std::__1::default_delete<llvm::detail::PassConcept<llvm::LoopNest, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>>>>(llvm::LoopNest&, std::__1::unique_ptr<llvm::detail::PassConcept<llvm::LoopNest, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, std::__1::default_delete<llvm::detail::PassConcept<llvm::LoopNest, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>>>&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&, llvm::PassInstrumentation&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/Transforms/Scalar/LoopPassManager.h:375:32\n #9 0x55713febe67c in llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::runWithLoopNestPasses(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) /repo/llvm/build-all-bbisdk-asan/../lib/Transforms/Scalar/LoopPassManager.cpp:112:16\n #10 0x55713febdd61 in 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&) /repo/llvm/build-all-bbisdk-asan/../lib/Transforms/Scalar/LoopPassManager.cpp:30:32\n #11 0x55713f719901 in llvm::detail::PassModel<llvm::Loop, llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerInternal.h:91:17\n #12 0x55713fec3348 in llvm::FunctionToLoopPassAdaptor::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /repo/llvm/build-all-bbisdk-asan/../lib/Transforms/Scalar/LoopPassManager.cpp:302:38\n #13 0x55713f722991 in llvm::detail::PassModel<llvm::Function, llvm::FunctionToLoopPassAdaptor, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerInternal.h:91:17\n #14 0x55713ba254c9 in llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerImpl.h:81:38\n #15 0x55713f728871 in llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerInternal.h:91:17\n #16 0x55713ba34d25 in llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /repo/llvm/build-all-bbisdk-asan/../lib/IR/PassManager.cpp:124:38\n #17 0x55713f71d491 in llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerInternal.h:91:17\n #18 0x55713ba218f9 in llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerImpl.h:81:38\n #19 0x55713f5eda5d in 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::__1::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) /repo/llvm/build-all-bbisdk-asan/../tools/opt/NewPMDriver.cpp:552:7\n #20 0x55713b2721b3 in optMain /repo/llvm/build-all-bbisdk-asan/../tools/opt/optdriver.cpp:725:12\n #21 0x7f6c3bae47e4 in __libc_start_main (/lib64/libc.so.6+0x3a7e4) (BuildId: 37e4ac6a7fb96950b0e6bf72d73d94f3296c77eb)\n #22 0x55713b1823ad in _start (/repo/llvm/build-all-bbisdk-asan/bin/opt+0x8cfe3ad)\n\n0x521000007a40 is located 320 bytes inside of 4096-byte region [0x521000007900,0x521000008900)\nallocated by thread T0 here:\n #0 0x55713b25a992 in operator new(unsigned long, std::align_val_t, std::nothrow_t const&) asan_new_delete.cpp:113:3\n #1 0x55713b346d4f in llvm::allocate_buffer(unsigned long, unsigned long) /repo/llvm/build-all-bbisdk-asan/../lib/Support/MemAlloc.cpp:16:18\n #2 0x55713b34a30a in Allocate /repo/llvm/build-all-bbisdk-asan/../include/llvm/Support/AllocatorBase.h:92:12\n #3 0x55713b34a30a in StartNewSlab /repo/llvm/build-all-bbisdk-asan/../include/llvm/Support/Allocator.h:346:42\n #4 0x55713b34a30a in llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul, 128ul>::AllocateSlow(unsigned long, unsigned long, llvm::Align) /repo/llvm/build-all-bbisdk-asan/../include/llvm/Support/Allocator.h:202:5\n #5 0x55713cb12443 in Allocate /repo/llvm/build-all-bbisdk-asan/../include/llvm/Support/Allocator.h:178:12\n #6 0x55713cb12443 in Allocate /repo/llvm/build-all-bbisdk-asan/../include/llvm/Support/Allocator.h:216:12\n #7 0x55713cb12443 in Allocate /repo/llvm/build-all-bbisdk-asan/../include/llvm/Support/AllocatorBase.h:53:43\n #8 0x55713cb12443 in Allocate<llvm::Loop> /repo/llvm/build-all-bbisdk-asan/../include/llvm/Support/AllocatorBase.h:76:29\n #9 0x55713cb12443 in llvm::Loop* llvm::LoopInfoBase<llvm::BasicBlock, llvm::Loop>::AllocateLoop<llvm::BasicBlock*&>(llvm::BasicBlock*&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/Support/GenericLoopInfo.h:571:36\n #10 0x55713cb0ff50 in llvm::LoopInfoBase<llvm::BasicBlock, llvm::Loop>::analyze(llvm::DominatorTreeBase<llvm::BasicBlock, false> const&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/Support/GenericLoopInfoImpl.h:594:18\n #11 0x55713cb23dbc in llvm::LoopAnalysis::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /repo/llvm/build-all-bbisdk-asan/../lib/Analysis/LoopInfo.cpp:977:6\n #12 0x55714109e4e7 in llvm::detail::AnalysisPassModel<llvm::Function, llvm::LoopAnalysis, llvm::AnalysisManager<llvm::Function>::Invalidator>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerInternal.h:321:14\n #13 0x55713ba300ab in llvm::AnalysisManager<llvm::Function>::getResultImpl(llvm::AnalysisKey*, llvm::Function&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerImpl.h:156:35\n #14 0x55713d1e67b4 in getResult<llvm::LoopAnalysis> /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManager.h:414:9\n #15 0x55713d1e67b4 in llvm::LoopSimplifyPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /repo/llvm/build-all-bbisdk-asan/../lib/Transforms/Utils/LoopSimplify.cpp:825:22\n #16 0x55713f719f11 in llvm::detail::PassModel<llvm::Function, llvm::LoopSimplifyPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerInternal.h:91:17\n #17 0x55713ba254c9 in llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerImpl.h:81:38\n #18 0x55713fec1dce in llvm::FunctionToLoopPassAdaptor::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /repo/llvm/build-all-bbisdk-asan/../lib/Transforms/Scalar/LoopPassManager.cpp:209:34\n #19 0x55713f722991 in llvm::detail::PassModel<llvm::Function, llvm::FunctionToLoopPassAdaptor, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerInternal.h:91:17\n #20 0x55713ba254c9 in llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerImpl.h:81:38\n #21 0x55713f728871 in llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerInternal.h:91:17\n #22 0x55713ba34d25 in llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /repo/llvm/build-all-bbisdk-asan/../lib/IR/PassManager.cpp:124:38\n #23 0x55713f71d491 in llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerInternal.h:91:17\n #24 0x55713ba218f9 in llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /repo/llvm/build-all-bbisdk-asan/../include/llvm/IR/PassManagerImpl.h:81:38\n #25 0x55713f5eda5d in 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::__1::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) /repo/llvm/build-all-bbisdk-asan/../tools/opt/NewPMDriver.cpp:552:7\n #26 0x55713b2721b3 in optMain /repo/llvm/build-all-bbisdk-asan/../tools/opt/optdriver.cpp:725:12\n #27 0x7f6c3bae47e4 in __libc_start_main (/lib64/libc.so.6+0x3a7e4) (BuildId: 37e4ac6a7fb96950b0e6bf72d73d94f3296c77eb)\n\nSUMMARY: AddressSanitizer: use-after-poison /repo/llvm/build-all-bbisdk-asan/../include/llvm/Support/GenericLoopInfo.h:219:12 in isInvalid\nShadow bytes around the buggy address:\n 0x521000007780: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\n 0x521000007800: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\n 0x521000007880: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\n 0x521000007900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n 0x521000007980: 00 00 00 00 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7\n=>0x521000007a00: f7 f7 f7 f7 f7 f7 f7 f7[f7]f7 00 00 00 00 00 00\n 0x521000007a80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f7 f7\n 0x521000007b00: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7\n 0x521000007b80: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7\n 0x521000007c00: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7\n 0x521000007c80: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7\nShadow byte legend (one shadow byte represents 8 application bytes):\n Addressable: 00\n Partially addressable: 01 02 03 04 05 06 07 \n Heap left redzone: fa\n Freed heap region: fd\n Stack left redzone: f1\n Stack mid redzone: f2\n Stack right redzone: f3\n Stack after return: f5\n Stack use after scope: f8\n Global redzone: f9\n Global init order: f6\n Poisoned by user: f7\n Container overflow: fc\n Array cookie: ac\n Intra object redzone: bb\n ASan internal: fe\n Left alloca redzone: ca\n Right alloca redzone: cb\n==3349467==ABORTING\n```\n"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
126581
|
https://github.com/llvm/llvm-project/issues/126581
|
crash
|
c81139f417a209dbd2a4e06465483d4b0951a9ac
| 2025-02-10T19:26:42 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "d18b1ebef5f5e355d6cee2b2f48789a159a5d616",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
18467,
18474
]
],
"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::computeMinimumValueSizes"
],
"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 d18b1ebef5f5e355d6cee2b2f48789a159a5d616
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Thu Feb 13 09:39:56 2025 -0800
[SLP]Check if vector user exist before accessing it
Need to check if vector user exist before accessing it to avoid compiler
crash.
Fixes #126581
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index a337ab7410f7..fb72a112b9ac 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -18467,8 +18467,8 @@ void BoUpSLP::computeMinimumValueSizes() {
any_of(
VectorizableTree[NodeIdx]->UserTreeIndices,
[&](const EdgeInfo &EI) {
- return (EI.UserTE->hasState() &&
- EI.UserTE->getOpcode() == Instruction::ICmp) &&
+ return EI.UserTE && EI.UserTE->hasState() &&
+ EI.UserTE->getOpcode() == Instruction::ICmp &&
any_of(EI.UserTE->Scalars, [&](Value *V) {
auto *IC = dyn_cast<ICmpInst>(V);
return IC &&
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/RISCV/check-node-without-vector-user.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=riscv64-unknown-linux-gnu -mattr=+v < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n@r = external global [8 x i8]\n\ndefine void @test(i64 %0, ptr %1) {\n;\n %3 = load i8, ptr @r, align 1\n %4 = trunc i8 %3 to i1\n %5 = select i1 %4, i64 %0, i64 0\n %6 = getelementptr i8, ptr @r, i64 %5\n %7 = load i8, ptr %6, align 1\n %8 = icmp ule i8 %3, %7\n %9 = sext i1 %8 to i32\n %10 = load i8, ptr getelementptr (i8, ptr @r, i64 -8049), align 1\n %11 = trunc i8 %10 to i1\n %12 = select i1 %11, i64 %0, i64 0\n %13 = getelementptr i8, ptr @r, i64 %12\n %14 = load i8, ptr %13, align 1\n %15 = icmp ule i8 %10, %14\n %16 = sext i1 %15 to i32\n %17 = add i32 %9, %16\n %18 = load i8, ptr getelementptr (i8, ptr @r, i64 -16098), align 1\n %19 = trunc i8 %18 to i1\n %20 = select i1 %19, i64 %0, i64 0\n %21 = getelementptr i8, ptr @r, i64 %20\n %22 = load i8, ptr %21, align 1\n %23 = icmp ule i8 %18, %22\n %24 = sext i1 %23 to i32\n %25 = add i32 %17, %24\n %26 = load i8, ptr getelementptr (i8, ptr @r, i64 -24147), align 1\n %27 = trunc i8 %26 to i1\n %28 = select i1 %27, i64 %0, i64 0\n %29 = getelementptr i8, ptr @r, i64 %28\n %30 = load i8, ptr %29, align 1\n %31 = icmp ule i8 %26, %30\n %32 = sext i1 %31 to i32\n %33 = add i32 %25, %32\n store i32 %33, ptr %1, align 4\n ret void\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SLPVectorizer] Segmentation Fault using opt \"-passes=lto<O3>\"",
"body": "Testcase:\n```llvm ir\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\n@a = external global i32\n@g = internal global i16 -8049\n@r = external global [8 x i8]\n\ndefine internal void @c(i16 %g, ptr %r) #0 {\nentry:\n br label %for.cond16.preheader.us.us.us.us\n\nfor.cond16.preheader.us.us.us.us: ; preds = %for.cond.cleanup20.split.us.us.us.us.us, %entry\n %indvars.iv133 = phi i64 [ %indvars.iv.next134, %for.cond.cleanup20.split.us.us.us.us.us ], [ 0, %entry ]\n br label %for.body21.us.us.us.us.us\n\nfor.body21.us.us.us.us.us: ; preds = %for.body21.us.us.us.us.us, %for.cond16.preheader.us.us.us.us\n %sub74.us.us.us.us124.us = phi i32 [ 0, %for.cond16.preheader.us.us.us.us ], [ %sub74.us.us.us.us.us, %for.body21.us.us.us.us.us ]\n %w.0109.us.us.us.us.us = phi i16 [ 0, %for.cond16.preheader.us.us.us.us ], [ %add77.us.us.us.us.us, %for.body21.us.us.us.us.us ]\n %idxprom38.us.us.us.us.us = sext i16 %w.0109.us.us.us.us.us to i64\n %arrayidx48.us.us.us.us.us = getelementptr i8, ptr %r, i64 %idxprom38.us.us.us.us.us\n %0 = load i8, ptr %arrayidx48.us.us.us.us.us, align 1\n %loadedv49.us.us.us.us.us = trunc i8 %0 to i1\n %cond71.in.in.v.us.us.us.us.us = select i1 %loadedv49.us.us.us.us.us, i64 %indvars.iv133, i64 0\n %cond71.in.in.us.us.us.us.us = getelementptr i8, ptr %r, i64 %cond71.in.in.v.us.us.us.us.us\n %cond71.in.us.us.us.us.us = load i8, ptr %cond71.in.in.us.us.us.us.us, align 1\n %cmp72.us.us.us.us.us = icmp ule i8 %0, %cond71.in.us.us.us.us.us\n %conv73.neg.us.us.us.us.us = sext i1 %cmp72.us.us.us.us.us to i32\n %sub74.us.us.us.us.us = add i32 %sub74.us.us.us.us124.us, %conv73.neg.us.us.us.us.us\n store i32 %sub74.us.us.us.us124.us, ptr @a, align 4\n %add77.us.us.us.us.us = add i16 %w.0109.us.us.us.us.us, %g\n %cmp18.us.us.us.us.us = icmp slt i16 %add77.us.us.us.us.us, 0\n br i1 %cmp18.us.us.us.us.us, label %for.body21.us.us.us.us.us, label %for.cond.cleanup20.split.us.us.us.us.us\n\nfor.cond.cleanup20.split.us.us.us.us.us: ; preds = %for.body21.us.us.us.us.us\n %indvars.iv.next134 = add i64 %indvars.iv133, 1\n %1 = and i64 %indvars.iv133, 2147483648\n %cmp12.us.us.us.us = icmp eq i64 %1, 0\n br i1 %cmp12.us.us.us.us, label %for.cond16.preheader.us.us.us.us, label %for.cond5.loopexit.split.us.us.us.us\n\nfor.cond5.loopexit.split.us.us.us.us: ; preds = %for.cond.cleanup20.split.us.us.us.us.us\n ret void\n}\n\ndefine i32 @main() {\nentry:\n %0 = load i16, ptr @g, align 2\n call void @c(i16 %0, ptr @r)\n ret i32 0\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zaamo,+zalrsc,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl256b,+zvl32b,+zvl64b,-b,-e,-experimental-sdext,-experimental-sdtrig,-experimental-smctr,-experimental-ssctr,-experimental-svukte,-experimental-xqcia,-experimental-xqciac,-experimental-xqcicli,-experimental-xqcicm,-experimental-xqcics,-experimental-xqcicsr,-experimental-xqciint,-experimental-xqcilo,-experimental-xqcilsm,-experimental-xqcisls,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-experimental-zvbc32e,-experimental-zvkgs,-h,-sha,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smdbltrp,-smepmp,-smmpm,-smnpm,-smrnmi,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssdbltrp,-ssnpm,-sspm,-ssqosid,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-supm,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-svvptc,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xmipscmove,-xmipslsp,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zabha,-zacas,-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\" }\n```\n\n\nCommand/backtrace:\n```\n$ /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt \"-passes=lto<O3>\" reduced.ll\nWARNING: You're attempting to print out a bitcode file.\nThis is inadvisable as it may cause display problems. If\nyou REALLY want to taste LLVM bitcode first-hand, you\ncan force output with the `-f' option.\n\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0. Program arguments: /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt -passes=lto<O3> reduced.ll\n1. Running pass \"function<eager-inv>(loop-mssa(licm<allowspeculation>),gvn<>,memcpyopt,dse,move-auto-init,mldst-motion<no-split-footer-bb>,loop(indvars,loop-deletion,loop-unroll-full),loop-distribute,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,sccp,instcombine<max-iterations=1;no-verify-fixpoint>,bdce,slp-vectorizer,vector-combine,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,jump-threading)\" on module \"reduced.ll\"\n2. Running pass \"slp-vectorizer\" on function \"c\"\n #0 0x000064a320d6dd02 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x34a8d02)\n #1 0x000064a320d6ad3f llvm::sys::RunSignalHandlers() (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x34a5d3f)\n #2 0x000064a320d6ae84 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #3 0x00007fe3fee45330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)\n #4 0x000064a31fc28b80 llvm::slpvectorizer::BoUpSLP::computeMinimumValueSizes()::'lambda1'(llvm::slpvectorizer::BoUpSLP::EdgeInfo const&)::operator()(llvm::slpvectorizer::BoUpSLP::EdgeInfo const&) const (.isra.0) SLPVectorizer.cpp:0:0\n #5 0x000064a31fcdc0bb llvm::slpvectorizer::BoUpSLP::computeMinimumValueSizes() (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x24170bb)\n #6 0x000064a31fcf9808 (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&, llvm::AssumptionCache*) SLPVectorizer.cpp:0:0\n #7 0x000064a31fcfc9ae llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x24379ae)\n #8 0x000064a31fd00c41 llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x243bc41)\n #9 0x000064a31fd04e32 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x243fe32)\n#10 0x000064a31fd0c6e0 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x24476e0)\n#11 0x000064a31fd0d336 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x2448336)\n#12 0x000064a31e87b285 llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0xfb6285)\n#13 0x000064a320b5976a llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x329476a)\n#14 0x000064a31e87d0d5 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0xfb80d5)\n#15 0x000064a320b5807c llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x329307c)\n#16 0x000064a31e879675 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0xfb4675)\n#17 0x000064a320b5865d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x329365d)\n#18 0x000064a31e01d465 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/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x758465)\n#19 0x000064a31e00d6ee optMain (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x7486ee)\n#20 0x00007fe3fee2a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3\n#21 0x00007fe3fee2a28b call_init ./csu/../csu/libc-start.c:128:20\n#22 0x00007fe3fee2a28b __libc_start_main ./csu/../csu/libc-start.c:347:5\n#23 0x000064a31e003f45 _start (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x73ef45)\nSegmentation fault (core dumped)\n```\n\nGodbolt: https://godbolt.org/z/P3sGYsGYc\n\nFound via fuzzer (C program before reduction)",
"author": "ewlu",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
157277
|
https://github.com/llvm/llvm-project/issues/157277
|
crash
|
5d550bf41ca52348bf11a0fb357df01a5b1684c8
| 2025-09-06T14:41:23 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "d0ea176ccea8bdcd60aacc2753734294b9eec71f",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
21889,
21894
]
],
"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::collectValuesToDemote"
],
"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 d0ea176ccea8bdcd60aacc2753734294b9eec71f
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Mon Sep 8 06:43:04 2025 -0700
[SLP]Do not consider SExt/ZExt profitable for demotion, if the user is a bitcast to float
If the user node of the SExt/ZExt node is a bitcast to a float point
type, the node itself should not be considered legal to demote, since
still the casting is required to match the size of the float point type.
Fixes #157277
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 4e90c1d5b9e1..1cfcd3ffbd66 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -21889,6 +21889,10 @@ bool BoUpSLP::collectValuesToDemote(
return TryProcessInstruction(BitWidth);
case Instruction::ZExt:
case Instruction::SExt:
+ if (E.UserTreeIndex.UserTE && E.UserTreeIndex.UserTE->hasState() &&
+ E.UserTreeIndex.UserTE->getOpcode() == Instruction::BitCast &&
+ E.UserTreeIndex.UserTE->getMainOp()->getType()->isFPOrFPVectorTy())
+ return false;
IsProfitableToDemote = true;
return TryProcessInstruction(BitWidth);
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/parent-bitcast-with-fp.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine i1 @test(i32 %0) {\n;\nentry:\n %conv22.i.i = sext i32 %0 to i64\n %1 = bitcast i64 %conv22.i.i to double\n %2 = fadd double %1, 0.000000e+00\n %add.i.i.i = select i1 false, double 0.000000e+00, double %2\n %3 = bitcast double %add.i.i.i to i64\n %cmp3998.i.i = icmp ne i64 %3, %conv22.i.i\n %conv22.1.i.i = sext i32 0 to i64\n %4 = bitcast i64 %conv22.1.i.i to double\n %5 = fadd double %4, 0.000000e+00\n %add.i.1.i.i = select i1 false, double 0.000000e+00, double %5\n %6 = bitcast double %add.i.1.i.i to i64\n %cmp3998.1.i.i = icmp ne i64 %6, %conv22.1.i.i\n ret i1 %cmp3998.1.i.i\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SLPVectorizer] Assertion `castIsValid(op, S, Ty) && \"Invalid cast!\"' failed.",
"body": "Reproducer: https://godbolt.org/z/YMb7ovEoc\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 i1 @main(i32 %0) {\nentry:\n %conv22.i.i = sext i32 %0 to i64\n %1 = bitcast i64 %conv22.i.i to double\n %2 = fadd double %1, 0.000000e+00\n %add.i.i.i = select i1 false, double 0.000000e+00, double %2\n %3 = bitcast double %add.i.i.i to i64\n %cmp3998.i.i = icmp ne i64 %3, %conv22.i.i\n %conv22.1.i.i = sext i32 0 to i64\n %4 = bitcast i64 %conv22.1.i.i to double\n %5 = fadd double %4, 0.000000e+00\n %add.i.1.i.i = select i1 false, double 0.000000e+00, double %5\n %6 = bitcast double %add.i.1.i.i to i64\n %cmp3998.1.i.i = icmp ne i64 %6, %conv22.1.i.i\n ret i1 %cmp3998.1.i.i\n}\n```\n```\nopt: /root/llvm-project/llvm/lib/IR/Instructions.cpp:3041: static llvm::CastInst* llvm::CastInst::Create(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, const llvm::Twine&, llvm::InsertPosition): Assertion `castIsValid(op, S, Ty) && \"Invalid cast!\"' 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 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 0x00007338d1c42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007338d1c969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007338d1c42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007338d1c287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x00007338d1c2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x00007338d1c39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x0000000005504776 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5504776)\n #9 0x0000000000baea43 llvm::IRBuilderBase::CreateCast(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, llvm::Twine const&, llvm::MDNode*, llvm::FMFSource) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xbaea43)\n#10 0x00000000035f04d1 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x35f04d1)\n#11 0x00000000035edb63 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x35edb63)\n#12 0x00000000035ee647 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x35ee647)\n#13 0x00000000035edddc llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x35edddc)\n#14 0x00000000035edec5 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x35edec5)\n#15 0x0000000003624cc4 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::SmallDenseSet<llvm::Value*, 4u, llvm::DenseMapInfo<llvm::Value*, void>> const&, llvm::Instruction*, llvm::ArrayRef<std::tuple<llvm::Value*, unsigned int, bool>>) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3624cc4)\n#16 0x0000000003628d42 llvm::slpvectorizer::BoUpSLP::vectorizeTree() (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3628d42)\n#17 0x000000000364a4e5 llvm::SLPVectorizerPass::tryToVectorizeList(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x364a4e5)\n#18 0x000000000364e6ff bool llvm::SLPVectorizerPass::vectorizeCmpInsts<std::reverse_iterator<llvm::CmpInst* const*>>(llvm::iterator_range<std::reverse_iterator<llvm::CmpInst* const*>>, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x364e6ff)\n#19 0x0000000003652191 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3652191)\n#20 0x00000000036586e6 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#21 0x00000000036591fb llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x36591fb)\n#22 0x0000000002e2b4be 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+0x2e2b4be)\n#23 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#24 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#25 0x000000000558ea3a llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x558ea3a)\n#26 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#27 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#28 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#29 0x000000000096b917 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x96b917)\n#30 0x00007338d1c29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#31 0x00007338d1c29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#32 0x0000000000962a35 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x962a35)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```\n\ncc @alexey-bataev ",
"author": "dtcxzyw",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid",
"generated by fuzzer"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
116553
|
https://github.com/llvm/llvm-project/issues/116553
|
miscompilation
|
c25e09e238c6f872a116d10bbefba0beff145a57
| 2024-11-17T18:49:16 |
[
"llvm/test/Transforms/ConstraintElimination"
] |
{
"fix_commit": "52361d0368b79841be12156bf03cf8c1851e5df7",
"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": [
[
1034,
1042
],
[
1044,
1051
]
],
"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::addInfoForInductions"
],
"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 52361d0368b79841be12156bf03cf8c1851e5df7
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Mon Nov 18 23:41:04 2024 +0800
[ConstraintElim] Bail out on non-dedicated exits when adding exiting conditions (#116627)
This patch bails out non-dedicated exits to avoid adding exiting
conditions to invalid context.
Closes https://github.com/llvm/llvm-project/issues/116553.
diff --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
index d2e532d29d07..64433cb9216c 100644
--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -1034,9 +1034,9 @@ void State::addInfoForInductions(BasicBlock &BB) {
DTN, CmpInst::ICMP_SLT, PN, B,
ConditionTy(CmpInst::ICMP_SLE, StartValue, B)));
- // Try to add condition from header to the exit blocks. When exiting either
- // with EQ or NE in the header, we know that the induction value must be u<=
- // B, as other exits may only exit earlier.
+ // Try to add condition from header to the dedicated exit blocks. When exiting
+ // either with EQ or NE in the header, we know that the induction value must
+ // be u<= B, as other exits may only exit earlier.
assert(!StepOffset.isNegative() && "induction must be increasing");
assert((Pred == CmpInst::ICMP_EQ || Pred == CmpInst::ICMP_NE) &&
"unsupported predicate");
@@ -1044,8 +1044,11 @@ void State::addInfoForInductions(BasicBlock &BB) {
SmallVector<BasicBlock *> ExitBBs;
L->getExitBlocks(ExitBBs);
for (BasicBlock *EB : ExitBBs) {
- WorkList.emplace_back(FactOrCheck::getConditionFact(
- DT.getNode(EB), CmpInst::ICMP_ULE, A, B, Precond));
+ // Bail out on non-dedicated exits.
+ if (DT.dominates(&BB, EB)) {
+ WorkList.emplace_back(FactOrCheck::getConditionFact(
+ DT.getNode(EB), CmpInst::ICMP_ULE, A, B, Precond));
+ }
}
}
|
[
{
"file": "llvm/test/Transforms/ConstraintElimination/induction-condition-in-loop-exit.ll",
"commands": [
"opt -p constraint-elimination -S %s"
],
"tests": [
{
"test_name": "test_non_dedicated_exit",
"test_body": "define i1 @test_non_dedicated_exit(i16 %n) {\nentry:\n %cond = icmp slt i16 %n, 1\n br i1 %cond, label %exit, label %loop.preheader\n\nloop.preheader: ; preds = %entry\n %sub = add nsw i16 %n, -1\n %ext = zext nneg i16 %sub to i32\n br label %loop\n\nloop: ; preds = %loop.latch, %loop.preheader\n %indvar = phi i32 [ %indvar.inc, %loop.latch ], [ 0, %loop.preheader ]\n %exitcond = icmp eq i32 %indvar, %ext\n br i1 %exitcond, label %exit, label %loop.latch\n\nloop.latch: ; preds = %loop\n %indvar.inc = add nuw nsw i32 %indvar, 1\n br label %loop\n\nexit: ; preds = %loop, %entry\n %cmp = icmp sgt i16 %n, 0\n ret i1 %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[clang] Miscompile at O3 with SIGKILL",
"body": "When I compiled this code with O3, it triggered SIGKILL. With O0/1/2, it returned 0.\r\n\r\nBisected to https://github.com/llvm/llvm-project/commit/5b927130b0e15a442a6ed171f43a612e6a40bbcd, which was committed by @fhahn \r\n\r\nCompiler Explorer: https://godbolt.org/z/q9j75feYG\r\n\r\nCode:\r\n```c\r\nint printf(const char *, ...);\r\nint a, c, d;\r\nint *b;\r\nchar e;\r\nshort f;\r\nint g(int i) {\r\n if (i <= 0)\r\n return 1;\r\n int h = 0;\r\n for (; h < i - 1; h++) {\r\n for (; d - h - 1;)\r\n if (c)\r\n b[d] = e = 1;\r\n if (e)\r\n break;\r\n }\r\n return 0;\r\n}\r\nvoid j() { g(f); }\r\nint main(int i, char *k[]) {\r\n j();\r\n while (0 < f)\r\n ;\r\n printf(\"%X\\n\", a);\r\n}\r\n```",
"author": "cardigan1008",
"labels": [
"miscompilation",
"confirmed",
"llvm:transforms"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Reproducer: https://alive2.llvm.org/ce/z/fLN5gw\r\n```\r\n; bin/opt -passes=constraint-elimination test.ll -S\r\ndefine i1 @test(i16 %n) {\r\nentry:\r\n %cond = icmp slt i16 %n, 1\r\n br i1 %cond, label %exit, label %loop.preheader\r\n\r\nloop.preheader:\r\n %sub = add nsw i16 %n, -1\r\n %ext = zext nneg i16 %sub to i32\r\n br label %loop\r\n\r\nloop:\r\n %indvar = phi i32 [ %indvar.inc, %loop.latch ], [ 0, %loop.preheader ]\r\n %12 = icmp eq i32 %indvar, %ext\r\n br i1 %12, label %exit, label %loop.latch\r\n\r\nloop.latch:\r\n %indvar.inc = add nuw nsw i32 %indvar, 1\r\n br label %loop\r\n\r\nexit:\r\n %cmp = icmp sgt i16 %n, 0\r\n ret i1 %cmp\r\n}\r\n\r\n```\r\nI will post a fix later.\r\n"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
106667
|
https://github.com/llvm/llvm-project/issues/106667
|
crash
|
5500e21942f7047344b6fee62d3e08c0ba2f9182
| 2024-08-30T05:59:16 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "a4aa6bc8fc2130761b8db5db4748059127662785",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
2864,
2869
],
[
6964,
6969
],
[
7095,
7149
],
[
9362,
9383
],
[
12521,
12530
],
[
12532,
12640
]
],
"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",
"BoUpSLP::getOperandEntry",
"BoUpSLP::vectorizeOperand"
],
"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 a4aa6bc8fc2130761b8db5db4748059127662785
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Fri Aug 30 10:17:31 2024 -0700
[SLP]Fix PR106667: carefully look for operand nodes.
If the operand node has the same scalars as one of the vectorized nodes,
the compiler could miss this and incorrectly request minbitwidth data
for the wrong node. It may lead to a compiler crash, because the
vectorized node might have different minbw result.
Fixes https://github.com/llvm/llvm-project/issues/106667
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 4c0a1c4c094b..e9785ef9ded2 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -2864,6 +2864,12 @@ private:
/// avoid issues with def-use order.
Value *vectorizeTree(TreeEntry *E, bool PostponedPHIs);
+ TreeEntry *getMatchedVectorizedOperand(const TreeEntry *E, unsigned NodeIdx);
+ const TreeEntry *getMatchedVectorizedOperand(const TreeEntry *E,
+ unsigned NodeIdx) const {
+ return const_cast<BoUpSLP *>(this)->getMatchedVectorizedOperand(E, NodeIdx);
+ }
+
/// Vectorize a single entry in the tree, the \p Idx-th operand of the entry
/// \p E.
/// \param PostponedPHIs true, if need to postpone emission of phi nodes to
@@ -6964,6 +6970,55 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
}
}
+ // Check if this is a duplicate of another entry.
+ if (TreeEntry *E = getTreeEntry(S.OpValue)) {
+ LLVM_DEBUG(dbgs() << "SLP: \tChecking bundle: " << *S.OpValue << ".\n");
+ if (!E->isSame(VL)) {
+ auto It = MultiNodeScalars.find(S.OpValue);
+ if (It != MultiNodeScalars.end()) {
+ auto *TEIt = find_if(It->getSecond(),
+ [&](TreeEntry *ME) { return ME->isSame(VL); });
+ if (TEIt != It->getSecond().end())
+ E = *TEIt;
+ else
+ E = nullptr;
+ } else {
+ E = nullptr;
+ }
+ }
+ if (!E) {
+ if (!doesNotNeedToBeScheduled(S.OpValue)) {
+ LLVM_DEBUG(dbgs() << "SLP: Gathering due to partial overlap.\n");
+ if (TryToFindDuplicates(S))
+ newTreeEntry(VL, std::nullopt /*not vectorized*/, S, UserTreeIdx,
+ ReuseShuffleIndices);
+ return;
+ }
+ SmallPtrSet<const TreeEntry *, 4> Nodes;
+ Nodes.insert(getTreeEntry(S.OpValue));
+ for (const TreeEntry *E : MultiNodeScalars.lookup(S.OpValue))
+ 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); });
+ })) {
+ LLVM_DEBUG(dbgs() << "SLP: Gathering due to full overlap.\n");
+ if (TryToFindDuplicates(S))
+ newTreeEntry(VL, std::nullopt /*not vectorized*/, S, UserTreeIdx,
+ ReuseShuffleIndices);
+ return;
+ }
+ } else {
+ // Record the reuse of the tree node. FIXME, currently this is only used
+ // to properly draw the graph rather than for the actual vectorization.
+ E->UserTreeIndices.push_back(UserTreeIdx);
+ LLVM_DEBUG(dbgs() << "SLP: Perfect diamond merge at " << *S.OpValue
+ << ".\n");
+ return;
+ }
+ }
+
// Gather if we hit the RecursionMaxDepth, unless this is a load (or z/sext of
// a load), in which case peek through to include it in the tree, without
// ballooning over-budget.
@@ -7095,55 +7150,6 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
// We now know that this is a vector of instructions of the same type from
// the same block.
- // Check if this is a duplicate of another entry.
- if (TreeEntry *E = getTreeEntry(S.OpValue)) {
- LLVM_DEBUG(dbgs() << "SLP: \tChecking bundle: " << *S.OpValue << ".\n");
- if (!E->isSame(VL)) {
- auto It = MultiNodeScalars.find(S.OpValue);
- if (It != MultiNodeScalars.end()) {
- auto *TEIt = find_if(It->getSecond(),
- [&](TreeEntry *ME) { return ME->isSame(VL); });
- if (TEIt != It->getSecond().end())
- E = *TEIt;
- else
- E = nullptr;
- } else {
- E = nullptr;
- }
- }
- if (!E) {
- if (!doesNotNeedToBeScheduled(S.OpValue)) {
- LLVM_DEBUG(dbgs() << "SLP: Gathering due to partial overlap.\n");
- if (TryToFindDuplicates(S))
- newTreeEntry(VL, std::nullopt /*not vectorized*/, S, UserTreeIdx,
- ReuseShuffleIndices);
- return;
- }
- SmallPtrSet<const TreeEntry *, 4> Nodes;
- Nodes.insert(getTreeEntry(S.OpValue));
- for (const TreeEntry *E : MultiNodeScalars.lookup(S.OpValue))
- 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); });
- })) {
- LLVM_DEBUG(dbgs() << "SLP: Gathering due to full overlap.\n");
- if (TryToFindDuplicates(S))
- newTreeEntry(VL, std::nullopt /*not vectorized*/, S, UserTreeIdx,
- ReuseShuffleIndices);
- return;
- }
- } else {
- // Record the reuse of the tree node. FIXME, currently this is only used
- // to properly draw the graph rather than for the actual vectorization.
- E->UserTreeIndices.push_back(UserTreeIdx);
- LLVM_DEBUG(dbgs() << "SLP: Perfect diamond merge at " << *S.OpValue
- << ".\n");
- return;
- }
- }
-
// Check that none of the instructions in the bundle are already in the tree.
for (Value *V : VL) {
if ((!IsScatterVectorizeUserTE && !isa<Instruction>(V)) ||
@@ -9362,22 +9368,8 @@ public:
const BoUpSLP::TreeEntry *BoUpSLP::getOperandEntry(const TreeEntry *E,
unsigned Idx) const {
- Value *Op = E->getOperand(Idx).front();
- if (const TreeEntry *TE = getTreeEntry(Op)) {
- if (find_if(TE->UserTreeIndices, [&](const EdgeInfo &EI) {
- return EI.EdgeIdx == Idx && EI.UserTE == E;
- }) != TE->UserTreeIndices.end())
- return TE;
- auto MIt = MultiNodeScalars.find(Op);
- if (MIt != MultiNodeScalars.end()) {
- for (const TreeEntry *TE : MIt->second) {
- if (find_if(TE->UserTreeIndices, [&](const EdgeInfo &EI) {
- return EI.EdgeIdx == Idx && EI.UserTE == E;
- }) != TE->UserTreeIndices.end())
- return TE;
- }
- }
- }
+ if (const TreeEntry *VE = getMatchedVectorizedOperand(E, Idx))
+ return VE;
const auto *It =
find_if(VectorizableTree, [&](const std::unique_ptr<TreeEntry> &TE) {
return TE->isGather() &&
@@ -12521,10 +12513,9 @@ public:
}
};
-Value *BoUpSLP::vectorizeOperand(TreeEntry *E, unsigned NodeIdx,
- bool PostponedPHIs) {
- ValueList &VL = E->getOperand(NodeIdx);
- const unsigned VF = VL.size();
+BoUpSLP::TreeEntry *BoUpSLP::getMatchedVectorizedOperand(const TreeEntry *E,
+ unsigned NodeIdx) {
+ ArrayRef<Value *> VL = E->getOperand(NodeIdx);
InstructionsState S = getSameOpcode(VL, *TLI);
// Special processing for GEPs bundle, which may include non-gep values.
if (!S.getOpcode() && VL.front()->getType()->isPointerTy()) {
@@ -12532,109 +12523,113 @@ Value *BoUpSLP::vectorizeOperand(TreeEntry *E, unsigned NodeIdx,
if (It != VL.end())
S = getSameOpcode(*It, *TLI);
}
- if (S.getOpcode()) {
- auto CheckSameVE = [&](const TreeEntry *VE) {
- return VE->isSame(VL) &&
- (any_of(VE->UserTreeIndices,
- [E, NodeIdx](const EdgeInfo &EI) {
- return EI.UserTE == E && EI.EdgeIdx == NodeIdx;
- }) ||
- any_of(VectorizableTree,
- [E, NodeIdx, VE](const std::unique_ptr<TreeEntry> &TE) {
- return TE->isOperandGatherNode({E, NodeIdx}) &&
- VE->isSame(TE->Scalars);
- }));
+ if (!S.getOpcode())
+ return nullptr;
+ auto CheckSameVE = [&](const TreeEntry *VE) {
+ return VE->isSame(VL) &&
+ (any_of(VE->UserTreeIndices,
+ [E, NodeIdx](const EdgeInfo &EI) {
+ return EI.UserTE == E && EI.EdgeIdx == NodeIdx;
+ }) ||
+ any_of(VectorizableTree,
+ [E, NodeIdx, VE](const std::unique_ptr<TreeEntry> &TE) {
+ return TE->isOperandGatherNode(
+ {const_cast<TreeEntry *>(E), NodeIdx}) &&
+ VE->isSame(TE->Scalars);
+ }));
+ };
+ TreeEntry *VE = getTreeEntry(S.OpValue);
+ if (VE && CheckSameVE(VE))
+ return VE;
+ auto It = MultiNodeScalars.find(S.OpValue);
+ if (It != MultiNodeScalars.end()) {
+ auto *I = find_if(It->getSecond(), [&](const TreeEntry *TE) {
+ return TE != VE && CheckSameVE(TE);
+ });
+ if (I != It->getSecond().end())
+ return *I;
+ }
+ return nullptr;
+}
+
+Value *BoUpSLP::vectorizeOperand(TreeEntry *E, unsigned NodeIdx,
+ bool PostponedPHIs) {
+ ValueList &VL = E->getOperand(NodeIdx);
+ const unsigned VF = VL.size();
+ if (TreeEntry *VE = getMatchedVectorizedOperand(E, NodeIdx)) {
+ auto FinalShuffle = [&](Value *V, ArrayRef<int> Mask) {
+ // V may be affected by MinBWs.
+ // We want ShuffleInstructionBuilder to correctly support REVEC. The key
+ // factor is the number of elements, not their type.
+ Type *ScalarTy = cast<VectorType>(V->getType())->getElementType();
+ unsigned NumElements = getNumElements(VL.front()->getType());
+ ShuffleInstructionBuilder ShuffleBuilder(
+ NumElements != 1 ? FixedVectorType::get(ScalarTy, NumElements)
+ : ScalarTy,
+ Builder, *this);
+ ShuffleBuilder.add(V, Mask);
+ SmallVector<std::pair<const TreeEntry *, unsigned>> SubVectors(
+ E->CombinedEntriesWithIndices.size());
+ transform(E->CombinedEntriesWithIndices, SubVectors.begin(),
+ [&](const auto &P) {
+ return std::make_pair(VectorizableTree[P.first].get(),
+ P.second);
+ });
+ return ShuffleBuilder.finalize(std::nullopt, SubVectors);
};
- TreeEntry *VE = getTreeEntry(S.OpValue);
- bool IsSameVE = VE && CheckSameVE(VE);
- if (!IsSameVE) {
- auto It = MultiNodeScalars.find(S.OpValue);
- if (It != MultiNodeScalars.end()) {
- auto *I = find_if(It->getSecond(), [&](const TreeEntry *TE) {
- return TE != VE && CheckSameVE(TE);
- });
- if (I != It->getSecond().end()) {
- VE = *I;
- IsSameVE = true;
- }
- }
- }
- if (IsSameVE) {
- auto FinalShuffle = [&](Value *V, ArrayRef<int> Mask) {
- // V may be affected by MinBWs.
- // We want ShuffleInstructionBuilder to correctly support REVEC. The key
- // factor is the number of elements, not their type.
- Type *ScalarTy = cast<VectorType>(V->getType())->getElementType();
- unsigned NumElements = getNumElements(VL.front()->getType());
- ShuffleInstructionBuilder ShuffleBuilder(
- NumElements != 1 ? FixedVectorType::get(ScalarTy, NumElements)
- : ScalarTy,
- Builder, *this);
- ShuffleBuilder.add(V, Mask);
- SmallVector<std::pair<const TreeEntry *, unsigned>> SubVectors(
- E->CombinedEntriesWithIndices.size());
- transform(E->CombinedEntriesWithIndices, SubVectors.begin(),
- [&](const auto &P) {
- return std::make_pair(VectorizableTree[P.first].get(),
- P.second);
- });
- return ShuffleBuilder.finalize(std::nullopt, SubVectors);
- };
- Value *V = vectorizeTree(VE, PostponedPHIs);
- if (VF * getNumElements(VL[0]->getType()) !=
- cast<FixedVectorType>(V->getType())->getNumElements()) {
- if (!VE->ReuseShuffleIndices.empty()) {
- // Reshuffle to get only unique values.
- // If some of the scalars are duplicated in the vectorization
- // tree entry, we do not vectorize them but instead generate a
- // mask for the reuses. But if there are several users of the
- // same entry, they may have different vectorization factors.
- // This is especially important for PHI nodes. In this case, we
- // need to adapt the resulting instruction for the user
- // vectorization factor and have to reshuffle it again to take
- // only unique elements of the vector. Without this code the
- // function incorrectly returns reduced vector instruction with
- // the same elements, not with the unique ones.
-
- // block:
- // %phi = phi <2 x > { .., %entry} {%shuffle, %block}
- // %2 = shuffle <2 x > %phi, poison, <4 x > <1, 1, 0, 0>
- // ... (use %2)
- // %shuffle = shuffle <2 x> %2, poison, <2 x> {2, 0}
- // br %block
- SmallVector<int> Mask(VF, PoisonMaskElem);
- for (auto [I, V] : enumerate(VL)) {
- if (isa<PoisonValue>(V))
- continue;
- Mask[I] = VE->findLaneForValue(V);
- }
- V = FinalShuffle(V, Mask);
- } else {
- assert(VF < cast<FixedVectorType>(V->getType())->getNumElements() &&
- "Expected vectorization factor less "
- "than original vector size.");
- SmallVector<int> UniformMask(VF, 0);
- std::iota(UniformMask.begin(), UniformMask.end(), 0);
- V = FinalShuffle(V, UniformMask);
+ Value *V = vectorizeTree(VE, PostponedPHIs);
+ if (VF * getNumElements(VL[0]->getType()) !=
+ cast<FixedVectorType>(V->getType())->getNumElements()) {
+ if (!VE->ReuseShuffleIndices.empty()) {
+ // Reshuffle to get only unique values.
+ // If some of the scalars are duplicated in the vectorization
+ // tree entry, we do not vectorize them but instead generate a
+ // mask for the reuses. But if there are several users of the
+ // same entry, they may have different vectorization factors.
+ // This is especially important for PHI nodes. In this case, we
+ // need to adapt the resulting instruction for the user
+ // vectorization factor and have to reshuffle it again to take
+ // only unique elements of the vector. Without this code the
+ // function incorrectly returns reduced vector instruction with
+ // the same elements, not with the unique ones.
+
+ // block:
+ // %phi = phi <2 x > { .., %entry} {%shuffle, %block}
+ // %2 = shuffle <2 x > %phi, poison, <4 x > <1, 1, 0, 0>
+ // ... (use %2)
+ // %shuffle = shuffle <2 x> %2, poison, <2 x> {2, 0}
+ // br %block
+ SmallVector<int> Mask(VF, PoisonMaskElem);
+ for (auto [I, V] : enumerate(VL)) {
+ if (isa<PoisonValue>(V))
+ continue;
+ Mask[I] = VE->findLaneForValue(V);
}
- }
- // Need to update the operand gather node, if actually the operand is not a
- // vectorized node, but the buildvector/gather node, which matches one of
- // the vectorized nodes.
- if (find_if(VE->UserTreeIndices, [&](const EdgeInfo &EI) {
- return EI.UserTE == E && EI.EdgeIdx == NodeIdx;
- }) == VE->UserTreeIndices.end()) {
- auto *It = find_if(
- VectorizableTree, [&](const std::unique_ptr<TreeEntry> &TE) {
- return TE->isGather() &&
- TE->UserTreeIndices.front().UserTE == E &&
- TE->UserTreeIndices.front().EdgeIdx == NodeIdx;
- });
- assert(It != VectorizableTree.end() && "Expected gather node operand.");
- (*It)->VectorizedValue = V;
- }
- return V;
+ V = FinalShuffle(V, Mask);
+ } else {
+ assert(VF < cast<FixedVectorType>(V->getType())->getNumElements() &&
+ "Expected vectorization factor less "
+ "than original vector size.");
+ SmallVector<int> UniformMask(VF, 0);
+ std::iota(UniformMask.begin(), UniformMask.end(), 0);
+ V = FinalShuffle(V, UniformMask);
+ }
+ }
+ // Need to update the operand gather node, if actually the operand is not a
+ // vectorized node, but the buildvector/gather node, which matches one of
+ // the vectorized nodes.
+ if (find_if(VE->UserTreeIndices, [&](const EdgeInfo &EI) {
+ return EI.UserTE == E && EI.EdgeIdx == NodeIdx;
+ }) == VE->UserTreeIndices.end()) {
+ auto *It =
+ find_if(VectorizableTree, [&](const std::unique_ptr<TreeEntry> &TE) {
+ return TE->isGather() && TE->UserTreeIndices.front().UserTE == E &&
+ TE->UserTreeIndices.front().EdgeIdx == NodeIdx;
+ });
+ assert(It != VectorizableTree.end() && "Expected gather node operand.");
+ (*It)->VectorizedValue = V;
}
+ return V;
}
// Find the corresponding gather entry and vectorize it.
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/multi-nodes-bv-vectorized.ll",
"commands": [
"opt -passes=slp-vectorizer -S -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define void @test(ptr %p) {\nentry:\n %conv548.2.i.13 = zext i32 0 to i64\n %and551.2.i.13 = and i64 0, %conv548.2.i.13\n %conv548.3.i.13 = zext i32 0 to i64\n %and551.3.i.13 = and i64 0, %conv548.3.i.13\n %0 = trunc i64 %and551.2.i.13 to i32\n %conv54.2.i.14 = and i32 %0, 0\n %conv548.2.i.14 = zext i32 %conv54.2.i.14 to i64\n %and551.2.i.14 = and i64 %and551.2.i.13, %conv548.2.i.14\n %1 = trunc i64 %and551.3.i.13 to i32\n %conv54.3.i.14 = and i32 %1, 0\n %conv548.3.i.14 = zext i32 %conv54.3.i.14 to i64\n %and551.3.i.14 = and i64 %and551.3.i.13, %conv548.3.i.14\n %and551.2.i.15 = and i64 %and551.2.i.14, 0\n %and551.3.i.15 = and i64 %and551.3.i.14, 0\n %and551.2.i.16 = and i64 %and551.2.i.15, 0\n %and551.3.i.16 = and i64 %and551.3.i.15, 0\n %and551.2.i.17 = and i64 %and551.2.i.16, 0\n %and551.3.i.17 = and i64 %and551.3.i.16, 0\n %and551.2.i.18 = and i64 %and551.2.i.17, 0\n %and551.3.i.18 = and i64 %and551.3.i.17, 0\n %and551.2.i.19 = and i64 %and551.2.i.18, 0\n %and551.3.i.19 = and i64 %and551.3.i.18, 0\n %and551.2.i.20 = and i64 %and551.2.i.19, 0\n %and551.3.i.20 = and i64 %and551.3.i.19, 0\n %and551.2.i.21 = and i64 %and551.2.i.20, 0\n %and551.3.i.21 = and i64 %and551.3.i.20, 0\n %gep1 = getelementptr inbounds i8, ptr %p, i64 16\n %gep2 = getelementptr inbounds i8, ptr %p, i64 24\n store i64 %and551.2.i.21, ptr %gep1, align 16\n store i64 %and551.3.i.21, ptr %gep2, align 8\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SLPVectorizer] Assertion `CastInst::castIsValid(opc, C, Ty) && \"Invalid constantexpr cast!\"' failed.",
"body": "Reproducer: https://godbolt.org/z/PeoMv3Tsn\r\n```\r\n; bin/opt -passes=slp-vectorizer reduced.ll -S\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine void @main(ptr %p) {\r\nentry:\r\n %conv548.2.i.13 = zext i32 0 to i64\r\n %and551.2.i.13 = and i64 0, %conv548.2.i.13\r\n %conv548.3.i.13 = zext i32 0 to i64\r\n %and551.3.i.13 = and i64 0, %conv548.3.i.13\r\n %0 = trunc i64 %and551.2.i.13 to i32\r\n %conv54.2.i.14 = and i32 %0, 0\r\n %conv548.2.i.14 = zext i32 %conv54.2.i.14 to i64\r\n %and551.2.i.14 = and i64 %and551.2.i.13, %conv548.2.i.14\r\n %1 = trunc i64 %and551.3.i.13 to i32\r\n %conv54.3.i.14 = and i32 %1, 0\r\n %conv548.3.i.14 = zext i32 %conv54.3.i.14 to i64\r\n %and551.3.i.14 = and i64 %and551.3.i.13, %conv548.3.i.14\r\n %and551.2.i.15 = and i64 %and551.2.i.14, 0\r\n %and551.3.i.15 = and i64 %and551.3.i.14, 0\r\n %and551.2.i.16 = and i64 %and551.2.i.15, 0\r\n %and551.3.i.16 = and i64 %and551.3.i.15, 0\r\n %and551.2.i.17 = and i64 %and551.2.i.16, 0\r\n %and551.3.i.17 = and i64 %and551.3.i.16, 0\r\n %and551.2.i.18 = and i64 %and551.2.i.17, 0\r\n %and551.3.i.18 = and i64 %and551.3.i.17, 0\r\n %and551.2.i.19 = and i64 %and551.2.i.18, 0\r\n %and551.3.i.19 = and i64 %and551.3.i.18, 0\r\n %and551.2.i.20 = and i64 %and551.2.i.19, 0\r\n %and551.3.i.20 = and i64 %and551.3.i.19, 0\r\n %and551.2.i.21 = and i64 %and551.2.i.20, 0\r\n %and551.3.i.21 = and i64 %and551.3.i.20, 0\r\n %gep1 = getelementptr inbounds i8, ptr %p, i64 16\r\n %gep2 = getelementptr inbounds i8, ptr %p, i64 24\r\n store i64 %and551.2.i.21, ptr %gep1, align 16\r\n store i64 %and551.3.i.21, ptr %gep2, align 8\r\n ret void\r\n}\r\n```\r\n```\r\nopt: /home/dtcxzyw/WorkSpace/Projects/compilers/llvm-project/llvm/lib/IR/Constants.cpp:2202: static llvm::Constant* llvm::ConstantExpr::getCast(unsigned int, llvm::Constant*, llvm::Type*, bool): Assertion `CastInst::castIsValid(opc, C, Ty) && \"Invalid constantexpr cast!\"' 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: bin/opt -passes=slp-vectorizer reduced.ll -S\r\n1. Running pass \"function(slp-vectorizer)\" on module \"reduced.ll\"\r\n2. Running pass \"slp-vectorizer\" on function \"main\"\r\n #0 0x00007c5d3e8138d2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.20.0git+0x2138d2)\r\n #1 0x00007c5d3e81079f llvm::sys::RunSignalHandlers() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.20.0git+0x21079f)\r\n #2 0x00007c5d3e8108e5 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007c5d3e242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007c5d3e2969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007c5d3e2969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007c5d3e2969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x00007c5d3e242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007c5d3e2287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x00007c5d3e22871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x00007c5d3e239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x00007c5d36fb0c4d llvm::ConstantExpr::getCast(unsigned int, llvm::Constant*, llvm::Type*, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.20.0git+0x1b0c4d)\r\n#12 0x00007c5d394573b5 llvm::IRBuilderBase::CreateCast(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, llvm::Twine const&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x573b5)\r\n#13 0x00007c5d395ab173 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1ab173)\r\n#14 0x00007c5d395acf1e llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1acf1e)\r\n#15 0x00007c5d395a7a13 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1a7a13)\r\n#16 0x00007c5d395acf1e llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1acf1e)\r\n#17 0x00007c5d395a7cbb llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1a7cbb)\r\n#18 0x00007c5d395acf1e llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1acf1e)\r\n#19 0x00007c5d395a7a41 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1a7a41)\r\n#20 0x00007c5d395acf1e llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1acf1e)\r\n#21 0x00007c5d395a7a13 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1a7a13)\r\n#22 0x00007c5d395acf1e llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1acf1e)\r\n#23 0x00007c5d395a7a13 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1a7a13)\r\n#24 0x00007c5d395acf1e llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1acf1e)\r\n#25 0x00007c5d395a7a13 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1a7a13)\r\n#26 0x00007c5d395acf1e llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1acf1e)\r\n#27 0x00007c5d395a7a13 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1a7a13)\r\n#28 0x00007c5d395acf1e llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1acf1e)\r\n#29 0x00007c5d395a7a13 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1a7a13)\r\n#30 0x00007c5d395acf1e llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1acf1e)\r\n#31 0x00007c5d395a7a13 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1a7a13)\r\n#32 0x00007c5d395acf1e llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1acf1e)\r\n#33 0x00007c5d395a7a13 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1a7a13)\r\n#34 0x00007c5d395acf1e llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1acf1e)\r\n#35 0x00007c5d395a8f65 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1a8f65)\r\n#36 0x00007c5d395ae278 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::MapVector<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>, llvm::DenseMap<llvm::Value*, unsigned int, llvm::DenseMapInfo<llvm::Value*, void>, llvm::detail::DenseMapPair<llvm::Value*, unsigned int>>, llvm::SmallVector<std::pair<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>>, 0u>> const&, llvm::SmallVectorImpl<std::pair<llvm::Value*, llvm::Value*>>&, llvm::Instruction*) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1ae278)\r\n#37 0x00007c5d395b207c llvm::slpvectorizer::BoUpSLP::vectorizeTree() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1b207c)\r\n#38 0x00007c5d395c7cac llvm::SLPVectorizerPass::vectorizeStoreChain(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, unsigned int, unsigned int, unsigned int&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1c7cac)\r\n#39 0x00007c5d395c9637 llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&)::'lambda'(std::set<std::pair<unsigned int, int>, llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&)::StoreDistCompare, std::allocator<std::pair<unsigned int, int>>> const&)::operator()(std::set<std::pair<unsigned int, int>, llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&)::StoreDistCompare, std::allocator<std::pair<unsigned int, int>>> const&) const SLPVectorizer.cpp:0:0\r\n#40 0x00007c5d395cb92c llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1cb92c)\r\n#41 0x00007c5d395cc20f llvm::SLPVectorizerPass::vectorizeStoreChains(llvm::slpvectorizer::BoUpSLP&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1cc20f)\r\n#42 0x00007c5d395cd30f llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1cd30f)\r\n#43 0x00007c5d395cdf86 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1cdf86)\r\n#44 0x00007c5d39ed4015 llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMPasses.so.20.0git+0xd4015)\r\n#45 0x00007c5d371546ed llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.20.0git+0x3546ed)\r\n#46 0x00007c5d3d4d7f35 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.20.0git+0xd7f35)\r\n#47 0x00007c5d37153256 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.20.0git+0x353256)\r\n#48 0x00007c5d3d4d88f5 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.20.0git+0xd88f5)\r\n#49 0x00007c5d3715121a llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.20.0git+0x35121a)\r\n#50 0x00007c5d3eb12fc7 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.20.0git+0x2cfc7)\r\n#51 0x00007c5d3eb1e962 optMain (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.20.0git+0x38962)\r\n#52 0x00007c5d3e229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#53 0x00007c5d3e229e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#54 0x00007c5d3e229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#55 0x00005949b291d095 _start (bin/opt+0x1095)\r\nAborted (core dumped)\r\n```\r\n\r\ncc @alexey-bataev ",
"author": "dtcxzyw",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Related PR: https://github.com/llvm/llvm-project/pull/103216\r\n"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
89516
|
https://github.com/llvm/llvm-project/issues/89516
|
miscompilation
|
18bb175428f520aaa4a5e388bd3b680a1a7c60c0
| 2024-04-20T22:58:16 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "6309440c218778db027306826993e484eab2be17",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
2720,
2726
]
],
"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": [
"foldSelectWithSRem"
],
"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 6309440c218778db027306826993e484eab2be17
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Sun Apr 21 22:41:32 2024 +0800
[InstCombine] Fix unexpected overwriting in `foldSelectWithSRem` (#89539)
Fixes #89516
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index 0262af28068b..73600206a55c 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -2720,7 +2720,7 @@ static Instruction *foldSelectWithSRem(SelectInst &SI, InstCombinerImpl &IC,
// %cnd = icmp slt i32 %rem, 0
// %add = add i32 %rem, %n
// %sel = select i1 %cnd, i32 %add, i32 %rem
- if (match(TrueVal, m_Add(m_Value(RemRes), m_Value(Remainder))) &&
+ if (match(TrueVal, m_Add(m_Specific(RemRes), m_Value(Remainder))) &&
match(RemRes, m_SRem(m_Value(Op), m_Specific(Remainder))) &&
IC.isKnownToBeAPowerOfTwo(Remainder, /*OrZero*/ true) &&
FalseVal == RemRes)
|
[
{
"file": "llvm/test/Transforms/InstCombine/select-divrem.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "rem_euclid_pow2_false_arm_folded",
"test_body": "define i32 @rem_euclid_pow2_false_arm_folded(i32 %n) {\n %rem = srem i32 %n, 2\n %nonneg = icmp sge i32 %rem, 0\n %res = select i1 %nonneg, i32 %rem, i32 1\n ret i32 %res\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "pr89516",
"test_body": "define i8 @pr89516(i8 %n, i8 %x) {\n %cond = icmp slt i8 %x, 0\n %pow2 = shl nuw i8 1, %n\n %srem = srem i8 1, %pow2\n %add = add nuw i8 %srem, %pow2\n %res = select i1 %cond, i8 %add, i8 %srem\n ret i8 %res\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "miscompile of vanilla integer code by InstCombine",
"body": "https://alive2.llvm.org/ce/z/jRfVLr\r\n\r\nthis function:\r\n```llvm\r\ndefine i8 @f(i8 %0, i8 %1) {\r\n %3 = icmp slt i8 %1, 0\r\n %4 = shl i8 1, %0\r\n %5 = srem i8 1, %4\r\n %6 = add i8 %5, %4\r\n %7 = select i1 %3, i8 %6, i8 %5\r\n ret i8 %7\r\n}\r\n```\r\nis getting mis-optimized to:\r\n```llvm\r\ndefine i8 @f(i8 %0, i8 %1) {\r\n %3 = icmp ne i8 %0, 0\r\n %4 = zext i1 %3 to i8\r\n ret i8 %4\r\n}\r\n```\r\nhere I'll just give Alive's work:\r\n```\r\nExample:\r\ni8 %#0 = #x00 (0)\r\ni8 %#1 = #xff (255, -1)\r\n\r\nSource:\r\ni1 %#3 = #x1 (1)\r\ni8 %#4 = #x01 (1)\r\ni8 %#5 = #x00 (0)\r\ni8 %#6 = #x01 (1)\r\ni8 %#7 = #x01 (1)\r\n\r\nTarget:\r\ni1 %#3 = #x0 (0)\r\ni8 %#4 = #x00 (0)\r\nSource value: #x01 (1)\r\nTarget value: #x00 (0)\r\n```\r\n\r\ncc @nunoplopes @hatsunespica",
"author": "regehr",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
91691
|
https://github.com/llvm/llvm-project/issues/91691
|
miscompilation
|
1fadb2b0c881ced247931f442fdee6c4ed96dccb
| 2024-05-10T02:43:43 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "b5f4210e9f51f938ae517f219f04f9ab431a2684",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
3343,
3349
],
[
3366,
3371
],
[
3379,
3384
],
[
3448,
3461
]
],
"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": [
"foldBitCeil",
"isSafeToRemoveBitCeilSelect"
],
"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 b5f4210e9f51f938ae517f219f04f9ab431a2684
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Mon May 13 14:27:59 2024 +0800
[InstCombine] Drop nuw flag when CtlzOp is a sub nuw (#91776)
See the following case:
```
define i32 @src1(i32 %x) {
%dec = sub nuw i32 -2, %x
%ctlz = tail call i32 @llvm.ctlz.i32(i32 %dec, i1 false)
%sub = sub nsw i32 32, %ctlz
%shl = shl i32 1, %sub
%ugt = icmp ult i32 %x, -2
%sel = select i1 %ugt, i32 %shl, i32 1
ret i32 %sel
}
define i32 @tgt1(i32 %x) {
%dec = sub nuw i32 -2, %x
%ctlz = tail call i32 @llvm.ctlz.i32(i32 %dec, i1 false)
%sub = sub nsw i32 32, %ctlz
%and = and i32 %sub, 31
%shl = shl nuw i32 1, %and
ret i32 %shl
}
```
`nuw` in `%dec` should be dropped after the select instruction is
eliminated.
Alive2: https://alive2.llvm.org/ce/z/7S9529
Fixes https://github.com/llvm/llvm-project/issues/91691.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index ee090e012508..a3ddb402bf66 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -3343,7 +3343,8 @@ Instruction *InstCombinerImpl::foldSelectOfBools(SelectInst &SI) {
// pattern.
static bool isSafeToRemoveBitCeilSelect(ICmpInst::Predicate Pred, Value *Cond0,
const APInt *Cond1, Value *CtlzOp,
- unsigned BitWidth) {
+ unsigned BitWidth,
+ bool &ShouldDropNUW) {
// The challenge in recognizing std::bit_ceil(X) is that the operand is used
// for the CTLZ proper and select condition, each possibly with some
// operation like add and sub.
@@ -3366,6 +3367,8 @@ static bool isSafeToRemoveBitCeilSelect(ICmpInst::Predicate Pred, Value *Cond0,
ConstantRange CR = ConstantRange::makeExactICmpRegion(
CmpInst::getInversePredicate(Pred), *Cond1);
+ ShouldDropNUW = false;
+
// Match the operation that's used to compute CtlzOp from CommonAncestor. If
// CtlzOp == CommonAncestor, return true as no operation is needed. If a
// match is found, execute the operation on CR, update CR, and return true.
@@ -3379,6 +3382,7 @@ static bool isSafeToRemoveBitCeilSelect(ICmpInst::Predicate Pred, Value *Cond0,
return true;
}
if (match(CtlzOp, m_Sub(m_APInt(C), m_Specific(CommonAncestor)))) {
+ ShouldDropNUW = true;
CR = ConstantRange(*C).sub(CR);
return true;
}
@@ -3448,14 +3452,20 @@ static Instruction *foldBitCeil(SelectInst &SI, IRBuilderBase &Builder) {
Pred = CmpInst::getInversePredicate(Pred);
}
+ bool ShouldDropNUW;
+
if (!match(FalseVal, m_One()) ||
!match(TrueVal,
m_OneUse(m_Shl(m_One(), m_OneUse(m_Sub(m_SpecificInt(BitWidth),
m_Value(Ctlz)))))) ||
!match(Ctlz, m_Intrinsic<Intrinsic::ctlz>(m_Value(CtlzOp), m_Zero())) ||
- !isSafeToRemoveBitCeilSelect(Pred, Cond0, Cond1, CtlzOp, BitWidth))
+ !isSafeToRemoveBitCeilSelect(Pred, Cond0, Cond1, CtlzOp, BitWidth,
+ ShouldDropNUW))
return nullptr;
+ if (ShouldDropNUW)
+ cast<Instruction>(CtlzOp)->setHasNoUnsignedWrap(false);
+
// Build 1 << (-CTLZ & (BitWidth-1)). The negation likely corresponds to a
// single hardware instruction as opposed to BitWidth - CTLZ, where BitWidth
// is an integer constant. Masking with BitWidth-1 comes free on some
|
[
{
"file": "llvm/test/Transforms/InstCombine/bit_ceil.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "pr91691",
"test_body": "define i32 @pr91691(i32 %0) {\n %2 = sub nuw i32 -2, %0\n %3 = tail call i32 @llvm.ctlz.i32(i32 %2, i1 false)\n %4 = sub i32 32, %3\n %5 = shl i32 1, %4\n %6 = icmp ult i32 %0, -2\n %7 = select i1 %6, i32 %5, i32 1\n ret i32 %7\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctlz.i32(i32, i1 immarg) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "bit_ceil_v4i32",
"test_body": "define <4 x i32> @bit_ceil_v4i32(<4 x i32> %x) {\n %dec = add <4 x i32> %x, splat (i32 -1)\n %ctlz = tail call <4 x i32> @llvm.ctlz.v4i32(<4 x i32> %dec, i1 false)\n %sub = sub <4 x i32> splat (i32 32), %ctlz\n %shl = shl <4 x i32> splat (i32 1), %sub\n %ugt = icmp ugt <4 x i32> %x, splat (i32 1)\n %sel = select <4 x i1> %ugt, <4 x i32> %shl, <4 x i32> splat (i32 1)\n ret <4 x i32> %sel\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x i32> @llvm.ctlz.v4i32(<4 x i32>, i1 immarg) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "pr91691_keep_nsw",
"test_body": "define i32 @pr91691_keep_nsw(i32 %0) {\n %2 = sub nsw i32 -2, %0\n %3 = tail call i32 @llvm.ctlz.i32(i32 %2, i1 false)\n %4 = sub i32 32, %3\n %5 = shl i32 1, %4\n %6 = icmp ult i32 %0, -2\n %7 = select i1 %6, i32 %5, i32 1\n ret i32 %7\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctlz.i32(i32, i1 immarg) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "instcombine removes a select, making code more poisonous",
"body": "https://alive2.llvm.org/ce/z/c__jy8\r\n\r\nthis function:\r\n```llvm\r\ndefine i32 @f(i32 %0) {\r\n %2 = sub nuw i32 -2, %0\r\n %3 = tail call i32 @llvm.ctlz.i32(i32 %2, i1 false)\r\n %4 = sub i32 32, %3\r\n %5 = shl i32 1, %4\r\n %6 = icmp ult i32 %0, -2\r\n %7 = select i1 %6, i32 %5, i32 1\r\n ret i32 %7\r\n}\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\r\ndeclare i32 @llvm.ctlz.i32(i32, i1 immarg) #0\r\n\r\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\r\n```\r\n\r\nis getting rewritten to not have the select, but the select was blocking a poison value. the bad thing happens when -1 is passed as an argument, see the Alive link for a detailed execution trace\r\n\r\n```llvm\r\ndefine i32 @f(i32 %0) {\r\n %2 = sub nuw i32 -2, %0\r\n %3 = tail call range(i32 0, 33) i32 @llvm.ctlz.i32(i32 %2, i1 false)\r\n %4 = sub nsw i32 0, %3\r\n %5 = and i32 %4, 31\r\n %6 = shl nuw i32 1, %5\r\n ret i32 %6\r\n}\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\r\ndeclare i32 @llvm.ctlz.i32(i32, i1 immarg) #0\r\n\r\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\r\n```\r\n\r\ncc @nunoplopes ",
"author": "regehr",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
142447
|
https://github.com/llvm/llvm-project/issues/142447
|
crash
|
4b2cb118bc5825c309724d536053c6f9817e2eb9
| 2025-06-02T17:50:28 |
[
"llvm/test/Transforms/InstSimplify"
] |
{
"fix_commit": "d9a5f7b118bfc9ab4b7325fae25073729d8e08be",
"components": [
"IR"
],
"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": [
[
1149,
1158
]
],
"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": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": [
"llvm::ConstantFoldCompareInstruction"
],
"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 d9a5f7b118bfc9ab4b7325fae25073729d8e08be
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Tue Jun 3 19:51:21 2025 +0800
[ConstantFold] Constant fold icmp of boolean scalable vectors (#142528)
Closes https://github.com/llvm/llvm-project/issues/142447.
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index 7e5fda229b85..b9db402fe956 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -1149,10 +1149,10 @@ Constant *llvm::ConstantFoldCompareInstruction(CmpInst::Predicate Predicate,
}
// If the comparison is a comparison between two i1's, simplify it.
- if (C1->getType()->isIntegerTy(1)) {
+ if (C1->getType()->isIntOrIntVectorTy(1)) {
switch (Predicate) {
case ICmpInst::ICMP_EQ:
- if (isa<ConstantInt>(C2))
+ if (isa<ConstantExpr>(C1))
return ConstantExpr::getXor(C1, ConstantExpr::getNot(C2));
return ConstantExpr::getXor(ConstantExpr::getNot(C1), C2);
case ICmpInst::ICMP_NE:
|
[
{
"file": "llvm/test/Transforms/InstSimplify/compare.ll",
"commands": [
"opt < %s -passes=instcombine<no-verify-fixpoint> -S"
],
"tests": [
{
"test_name": "icmp_ne_i1_vec_constant_expr",
"test_body": "target datalayout = \"p:32:32-p1:64:64\"\n\ndefine <vscale x 8 x i1> @icmp_ne_i1_vec_constant_expr() {\nentry:\n %cmp = icmp ne <vscale x 8 x i1> insertelement (<vscale x 8 x i1> poison, i1 true, i64 0), zeroinitializer\n ret <vscale x 8 x i1> %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "icmp_eq_i1_vec_constant_expr_commuted",
"test_body": "target datalayout = \"p:32:32-p1:64:64\"\n\ndefine <vscale x 8 x i1> @icmp_eq_i1_vec_constant_expr_commuted() {\nentry:\n %cmp = icmp eq <vscale x 8 x i1> zeroinitializer, insertelement (<vscale x 8 x i1> poison, i1 true, i64 0)\n ret <vscale x 8 x i1> %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "icmp_eq_false_by_trunc",
"test_body": "target datalayout = \"p:32:32-p1:64:64\"\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #0\n\ndefine i1 @icmp_eq_false_by_trunc(i8 %x) {\n %trunc = trunc i8 %x to i1\n %not = xor i1 %trunc, true\n call void @llvm.assume(i1 %not)\n %cmp = icmp eq i8 %x, 1\n ret i1 %cmp\n}\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstCombine] ICmp i1 X, C not simplified as expected. with opt \"-passes=lto<O3>\"",
"body": "Full error message:\n```\nICmp i1 X, C not simplified as expected.\nUNREACHABLE executed at /scratch/ewlu/daily-upstream-build/llvm/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:7182!\n```\n\nTestcase:\n```llvm ir\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\n@a = external global i8\n\ndefine void @c() #0 {\nentry:\n %0 = zext <vscale x 8 x i1> insertelement (<vscale x 8 x i1> poison, i1 true, i64 0) to <vscale x 8 x i32>\n %1 = icmp ne <vscale x 8 x i32> %0, zeroinitializer\n %2 = zext <vscale x 8 x i1> %1 to <vscale x 8 x i8>\n %3 = call i8 @llvm.vector.reduce.xor.nxv8i8(<vscale x 8 x i8> %2)\n store i8 %3, ptr @a, align 1\n ret void\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(read)\ndeclare <vscale x 8 x i16> @llvm.masked.gather.nxv8i16.nxv8p0(<vscale x 8 x ptr>, i32 immarg, <vscale x 8 x i1>, <vscale x 8 x i16>) #1\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <vscale x 8 x i32> @llvm.smin.nxv8i32(<vscale x 8 x i32>, <vscale x 8 x i32>) #2\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i8 @llvm.vector.reduce.xor.nxv8i8(<vscale x 8 x i8>) #2\n\ndefine i32 @main() {\nentry:\n ret i32 0\n}\n\nattributes #0 = { \"target-features\"=\"+v\" }\nattributes #1 = { nocallback nofree nosync nounwind willreturn memory(read) }\nattributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n```\nThis might not be the fully reduced version. `llvm-reduce` aborted mid reduce for me\n\nCommands/backtrace:\n```\n$ /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt \"-passes=lto<O3>\" reduced.ll\nWARNING: You're attempting to print out a bitcode file.\nThis is inadvisable as it may cause display problems. If\nyou REALLY want to taste LLVM bitcode first-hand, you\ncan force output with the `-f' option.\n\nICmp i1 X, C not simplified as expected.\nUNREACHABLE executed at /scratch/ewlu/daily-upstream-build/llvm/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:7182!\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0. Program arguments: /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt -passes=lto<O3> reduced.ll\n1. Running pass \"function<eager-inv>(instcombine<max-iterations=1;no-verify-fixpoint>,aggressive-instcombine)\" on module \"reduced.ll\"\n2. Running pass \"instcombine<max-iterations=1;no-verify-fixpoint>\" on function \"c\"\n #0 0x000058be7f45a172 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x35a5172)\n #1 0x000058be7f4571df llvm::sys::RunSignalHandlers() (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x35a21df)\n #2 0x000058be7f457324 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #3 0x000077fe5fe45330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)\n #4 0x000077fe5fe9eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #5 0x000077fe5fe9eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #6 0x000077fe5fe9eb2c pthread_kill ./nptl/pthread_kill.c:89:10\n #7 0x000077fe5fe4527e raise ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x000077fe5fe288ff abort ./stdlib/abort.c:81:7\n #9 0x000058be7f38585e (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x34d085e)\n#10 0x000058be7e3f2501 llvm::InstCombinerImpl::visitICmpInst(llvm::ICmpInst&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x253d501)\n#11 0x000058be7e3464fa llvm::InstCombinerImpl::run() (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x24914fa)\n#12 0x000058be7e347d90 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&) InstructionCombining.cpp:0:0\n#13 0x000058be7e3491e2 llvm::InstCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x24941e2)\n#14 0x000058be7c9bb605 llvm::detail::PassModel<llvm::Function, llvm::InstCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0xb06605)\n#15 0x000058be7f2430fa llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x338e0fa)\n#16 0x000058be7c9bdc55 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0xb08c55)\n#17 0x000058be7f2435e4 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x338e5e4)\n#18 0x000058be7c9b9895 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0xb04895)\n#19 0x000058be7f241f6d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x338cf6d)\n#20 0x000058be7c66b241 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/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x7b6241)\n#21 0x000058be7c65cd7c optMain (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x7a7d7c)\n#22 0x000077fe5fe2a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3\n#23 0x000077fe5fe2a28b call_init ./csu/../csu/libc-start.c:128:20\n#24 0x000077fe5fe2a28b __libc_start_main ./csu/../csu/libc-start.c:347:5\n#25 0x000058be7c6533d5 _start (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x79e3d5)\nAborted (core dumped)\n```\n\nGodbolt: https://godbolt.org/z/5cxdvhhGK\n\nFound via fuzzer (C program before reduction)",
"author": "ewlu",
"labels": [
"crash-on-valid",
"llvm:ir"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
155738
|
https://github.com/llvm/llvm-project/issues/155738
|
crash
|
78b45b489559cd44437af4eac6c10188eb0cec3c
| 2025-08-28T03:01:57 |
[
"llvm/test/Transforms/FunctionSpecialization"
] |
{
"fix_commit": "0ace96cca79c03c668b260dd01996e3d693e3f4f",
"components": [
"SCCP"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
330,
341
]
],
"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": 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": [
"runIPSCCP"
],
"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 0ace96cca79c03c668b260dd01996e3d693e3f4f
Author: XChy <xxs_chy@outlook.com>
Date: Thu Aug 28 19:13:27 2025 +0800
[SCCP][FuncSpec] Poison unreachable constant global variable user (#155753)
Fixes #155738.
The original assumption "we already replaced its users with a constant"
for the global variable becomes incorrect after #154668. The users in
the dead function are not simplified, in fact.
This patch poisons all the unsimplified constant global variable users.
diff --git a/llvm/lib/Transforms/IPO/SCCP.cpp b/llvm/lib/Transforms/IPO/SCCP.cpp
index e98a70f228ad..f4961faf7ad1 100644
--- a/llvm/lib/Transforms/IPO/SCCP.cpp
+++ b/llvm/lib/Transforms/IPO/SCCP.cpp
@@ -330,12 +330,15 @@ static bool runIPSCCP(
LLVM_DEBUG(dbgs() << "Found that GV '" << GV->getName()
<< "' is constant!\n");
for (User *U : make_early_inc_range(GV->users())) {
- // We can remove LoadInst here, because we already replaced its users
- // with a constant.
+ // We can remove LoadInst here. The LoadInsts in dead functions marked by
+ // FuncSpec are not simplified to constants, thus poison them.
assert((isa<StoreInst>(U) || isa<LoadInst>(U)) &&
"Only Store|Load Instruction can be user of GlobalVariable at "
"reaching here.");
- cast<Instruction>(U)->eraseFromParent();
+ Instruction *I = cast<Instruction>(U);
+ if (isa<LoadInst>(I))
+ I->replaceAllUsesWith(PoisonValue::get(I->getType()));
+ I->eraseFromParent();
}
// Try to create a debug constant expression for the global variable
|
[
{
"file": "llvm/test/Transforms/FunctionSpecialization/dead-gv-load.ll",
"commands": [
"opt -passes=ipsccp --funcspec-min-function-size=1 -S < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n@gv = internal global ptr null\n\ndefine i8 @caller() {\n;\nentry:\n %call1 = call i8 @callee(i32 1)\n %call2 = call i8 @callee(i32 0)\n ret i8 %call2\n}\n\ndefine internal i8 @callee(i32 %arg) {\nentry:\n %useless = icmp ne i32 %arg, 0\n br label %loop\n\nloop: ; preds = %loop, %entry\n br label %loop\n\ndead_bb: ; No predecessors!\n %l1 = load ptr, ptr @gv, align 8\n %l2 = load ptr, ptr %l1, align 8\n ret i8 0\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[IPSCCP] Use still stuck around after Def is destroyed",
"body": "Reproducer:\n```\n; bin/opt -passes=ipsccp --funcspec-min-function-size=1 reduced.ll -S\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@g_315 = internal global ptr null\n\ndefine i8 @func_123() {\nentry:\n %call2 = call i8 @func_152(i32 1)\n %call2991 = call i8 @func_152(i32 0)\n ret i8 %call2991\n}\n\ndefine internal i8 @func_152(i32 %p_153) {\nentry:\n %tobool268 = icmp ne i32 %p_153, 0\n br label %cleanup424\n\ncleanup424: ; preds = %cleanup424, %entry\n br label %cleanup424\n\nfor.end453: ; No predecessors!\n %0 = load ptr, ptr @g_315, align 8\n %1 = load ptr, ptr %0, align 8\n ret i8 0\n}\n```\n```\nWhile deleting: ptr %\nUse still stuck around after Def is destroyed: %0 = load ptr, ptr <badref>, align 8\nUses remain when a value is destroyed!\nUNREACHABLE executed at /home/dtcxzyw/WorkSpace/Projects/compilers/llvm-project/llvm/lib/IR/Value.cpp:102!\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0. Program arguments: bin/opt -passes=ipsccp --funcspec-min-function-size=1 reduced.ll -S\n1. Running pass \"ipsccp\" on module \"reduced.ll\"\n #0 0x000078deeee306f2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.22.0git+0x2306f2)\n #1 0x000078deeee2ccbf llvm::sys::RunSignalHandlers() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.22.0git+0x22ccbf)\n #2 0x000078deeee2ce0c SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #3 0x000078deee845330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)\n #4 0x000078deee89eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #5 0x000078deee89eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #6 0x000078deee89eb2c pthread_kill ./nptl/pthread_kill.c:89:10\n #7 0x000078deee84527e raise ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x000078deee8288ff abort ./stdlib/abort.c:81:7\n #9 0x000078deeed2a33e (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.22.0git+0x12a33e)\n#10 0x000078dee6761699 llvm::Value::~Value() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.22.0git+0x361699)\n#11 0x000078dee6761882 llvm::Value::deleteValue() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.22.0git+0x361882)\n#12 0x000078dee667ffce llvm::Instruction::eraseFromParent() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.22.0git+0x27ffce)\n#13 0x000078dee97c0d45 runIPSCCP(llvm::Module&, llvm::DataLayout const&, llvm::AnalysisManager<llvm::Function>*, std::function<llvm::TargetLibraryInfo const& (llvm::Function&)>, std::function<llvm::TargetTransformInfo& (llvm::Function&)>, std::function<llvm::AssumptionCache& (llvm::Function&)>, std::function<llvm::DominatorTree& (llvm::Function&)>, std::function<llvm::BlockFrequencyInfo& (llvm::Function&)>, bool) SCCP.cpp:0:0\n#14 0x000078dee97c122b llvm::IPSCCPPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMipo.so.22.0git+0x3c122b)\n#15 0x000078dee9aec7f5 llvm::detail::PassModel<llvm::Module, llvm::IPSCCPPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMPasses.so.22.0git+0xec7f5)\n#16 0x000078dee6724ddd llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.22.0git+0x324ddd)\n#17 0x000078deef124185 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.22.0git+0x2d185)\n#18 0x000078deef12f5ea optMain (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.22.0git+0x385ea)\n#19 0x000078deee82a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3\n#20 0x000078deee82a28b call_init ./csu/../csu/libc-start.c:128:20\n#21 0x000078deee82a28b __libc_start_main ./csu/../csu/libc-start.c:347:5\n#22 0x0000641d94919095 _start (bin/opt+0x1095)\nAborted (core dumped)\n```\nllvm version: 3c94613ae98fd9e9846fa77268b59d884b35cf60\n\nReverting 6bd844812385dd5cb65e08fe9561be9f91ace876 solves the issue. cc @XChy \n",
"author": "dtcxzyw",
"labels": [
"ipo",
"crash-on-valid",
"generated by fuzzer"
],
"comments": [
{
"author": "XChy",
"body": "The assumption is incorrect after https://github.com/llvm/llvm-project/commit/6bd844812385dd5cb65e08fe9561be9f91ace876:\nhttps://github.com/llvm/llvm-project/blob/5a9f1039c7732920dd1f4374074fdf09b58184ea/llvm/lib/Transforms/IPO/SCCP.cpp#L332-L339\nThe users in the dead functions are not replaced."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
97586
|
https://github.com/llvm/llvm-project/issues/97586
|
crash
|
be7239e5a60927f5b4932f995dc4b57423ea8534
| 2024-07-03T14:47:17 |
[
"llvm/test/Transforms/LoopUnroll"
] |
{
"fix_commit": "cff8d716bdf017a2af8eb8623257fd33ee43f30e",
"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": [
[
8412,
8418
]
],
"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::visitAndClearUsers"
],
"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 cff8d716bdf017a2af8eb8623257fd33ee43f30e
Author: v01dXYZ <14996868+v01dXYZ@users.noreply.github.com>
Date: Tue Jul 9 09:14:33 2024 +0200
[SCEV] forgetValue: support (with-overflow-inst op0, op1) (#98015)
The use-def walk in forgetValue() was skipping instructions with
non-SCEVable types. However, SCEV may look past with.overflow
intrinsics returning aggregates.
Fixes #97586.
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 430e1c6d8f8c..51cffac80876 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -8412,7 +8412,7 @@ void ScalarEvolution::visitAndClearUsers(
SmallVectorImpl<const SCEV *> &ToForget) {
while (!Worklist.empty()) {
Instruction *I = Worklist.pop_back_val();
- if (!isSCEVable(I->getType()))
+ if (!isSCEVable(I->getType()) && !isa<WithOverflowInst>(I))
continue;
ValueExprMapType::iterator It =
|
[
{
"file": "llvm/test/Transforms/LoopUnroll/peel-loop-scev-invalidate-with-overflow-inst.ll",
"commands": [
"opt < %s -S -passes='print<scalar-evolution>,loop-unroll<peeling;full-unroll-max=0>,print<scalar-evolution>' 2>&1"
],
"tests": [
{
"test_name": "<module>",
"test_body": ";\n; This test ensures that (extractvalue 0 (with-overflow-inst op0, op1))\n; is invalidated by LoopPeel when the operands of with-overflow-inst\n; are changed.\n;\n; In the following case, LoopPeel modifies the CFG into another one\n; with %bb7 not dominating %bb2 and %bb3 although %extractvalue is\n; still the step for the %bb3 loop. %call has been modified and uses\n; different operands but the SCEV value for %extractvalue has not been\n; invalidated and still refers to %load in its SCEV operands\n; (SCEV(%extractvalue) := -2 + -2 * %load).\n;\n; When LoopUnroll tries to compute the SCEV for the %bb3 Phi, the\n; stale data for %extractvalue is used whereas %load is not available\n; in %bb3 which is wrong.\n;\n; for more details and nice pictures: https://github.com/llvm/llvm-project/issues/97586\n;\n; Although the reason for the bug was in forgetValue, it is still relevant to\n; test if LoopPeel invalidates %extractvalue after changing %call.\n;\n; forgetValue only walks the users, so calling it on the IV Phis does not\n; invalidate %extractvalue (thus forgetLoop does not invalidate it too).\n; It has to be done by LoopPeel itself.\n\n\ndefine void @loop_peeling_smul_with_overflow() {\n; before loop-unroll\n; after loop-unroll\n;\nbb:\n br label %bb1\n\nbb1: ; preds = %bb3, %bb\n %phi = phi i32 [ 0, %bb ], [ %phi4, %bb3 ]\n br label %bb5\n\nbb2: ; preds = %bb7\n %call = call { i32, i1 } @llvm.smul.with.overflow.i32(i32 %add8, i32 -2)\n %extractvalue = extractvalue { i32, i1 } %call, 0\n br label %bb3\n\nbb3: ; preds = %bb3, %bb2\n %phi4 = phi i32 [ %add, %bb3 ], [ 0, %bb2 ]\n %add = add i32 %extractvalue, %phi4\n br i1 false, label %bb3, label %bb1\n\nbb5: ; preds = %bb7, %bb1\n %phi6 = phi i32 [ 1, %bb1 ], [ 0, %bb7 ]\n %icmp = icmp eq i32 %phi, 0\n br i1 %icmp, label %bb9, label %bb7\n\nbb7: ; preds = %bb5\n %load = load i32, ptr addrspace(1) null, align 4\n %add8 = add i32 %load, 1\n br i1 false, label %bb2, label %bb5\n\nbb9: ; preds = %bb5\n ret void\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Assertion Failure in `getSCEV` during loop unroll",
"body": "```\r\n; ModuleID = '<stdin>'\r\nsource_filename = \"<stdin>\"\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 @ham() {\r\nbb:\r\n br label %bb1\r\n\r\nbb1: ; preds = %bb3, %bb\r\n %phi = phi i32 [ 0, %bb ], [ %phi4, %bb3 ]\r\n br label %bb5\r\n\r\nbb2: ; preds = %bb7\r\n %call = call { i32, i1 } @llvm.smul.with.overflow.i32(i32 %add8, i32 -2)\r\n %extractvalue = extractvalue { i32, i1 } %call, 0\r\n br label %bb3\r\n\r\nbb3: ; preds = %bb3, %bb2\r\n %phi4 = phi i32 [ %add, %bb3 ], [ 0, %bb2 ]\r\n %add = add i32 %extractvalue, %phi4\r\n br i1 false, label %bb3, label %bb1\r\n\r\nbb5: ; preds = %bb7, %bb1\r\n %phi6 = phi i32 [ 1, %bb1 ], [ 0, %bb7 ]\r\n %icmp = icmp eq i32 %phi, 0\r\n br i1 %icmp, label %bb9, label %bb7\r\n\r\nbb7: ; preds = %bb5\r\n %load = load i32, ptr addrspace(1) null, align 4\r\n %add8 = add i32 %load, 1\r\n br i1 false, label %bb2, label %bb5\r\n\r\nbb9: ; preds = %bb5\r\n ret void\r\n}\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\r\ndeclare { i32, i1 } @llvm.smul.with.overflow.i32(i32, i32) #0\r\n\r\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\r\n```\r\ncrashes with the below backtrace when run with `opt --passes=\"print<scalar-evolution>,loop-unroll<no-partial;peeling;no-runtime;no-upperbound;no-profile-peeling;full-unroll-max=0;O3> <filename.ll>\"` \r\n```\r\nopt: /home/manishkh/Workspace7/orca/llvm/lib/Analysis/ScalarEvolution.cpp:3678: const llvm::SCEV* llvm::ScalarEvolution::getAddRecExpr(llvm::SmallVectorImpl<const llvm::SCEV*>&, const llvm::Loop*, llvm::SCEV::NoWrapFlags): Assertion `isAvailableAtLoopEntry(Operands[i], L) && \"SCEVAddRecExpr operand is not available at loop entry!\"' 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: /home/manishkh/Workspace7/orcaInstall/installDA/bin/opt --passes=print<scalar-evolution>,loop-unroll<no-partial;peeling;no-runtime;no-upperbound;no-profile-peeling;full-unroll-max=0;O3> reduced2.ll -disable-output\r\n #0 0x00007f272f49aa72 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/manishkh/Workspace7/orca/llvm/lib/Support/Unix/Signals.inc:723:0\r\n #1 0x00007f272f49aeaf PrintStackTraceSignalHandler(void*) /home/manishkh/Workspace7/orca/llvm/lib/Support/Unix/Signals.inc:798:0\r\n #2 0x00007f272f498793 llvm::sys::RunSignalHandlers() /home/manishkh/Workspace7/orca/llvm/lib/Support/Signals.cpp:105:0\r\n #3 0x00007f272f49a459 SignalHandler(int) /home/manishkh/Workspace7/orca/llvm/lib/Support/Unix/Signals.inc:413:0\r\n #4 0x00007f2738fd7630 __restore_rt sigaction.c:0:0\r\n #5 0x00007f272b893387 raise (/lib64/libc.so.6+0x36387)\r\n #6 0x00007f272b894a78 abort (/lib64/libc.so.6+0x37a78)\r\n #7 0x00007f272b88c1a6 __assert_fail_base (/lib64/libc.so.6+0x2f1a6)\r\n #8 0x00007f272b88c252 (/lib64/libc.so.6+0x2f252)\r\n #9 0x00007f2732031da6 llvm::ScalarEvolution::getAddRecExpr(llvm::SmallVectorImpl<llvm::SCEV const*>&, llvm::Loop const*, llvm::SCEV::NoWrapFlags) /home/manishkh/Workspace7/orca/llvm/lib/Analysis/ScalarEvolution.cpp:3677:0\r\n#10 0x00007f2732031b29 llvm::ScalarEvolution::getAddRecExpr(llvm::SCEV const*, llvm::SCEV const*, llvm::Loop const*, llvm::SCEV::NoWrapFlags) /home/manishkh/Workspace7/orca/llvm/lib/Analysis/ScalarEvolution.cpp:3660:0\r\n#11 0x00007f2732039c11 llvm::ScalarEvolution::createSimpleAffineAddRec(llvm::PHINode*, llvm::Value*, llvm::Value*) /home/manishkh/Workspace7/orca/llvm/lib/Analysis/ScalarEvolution.cpp:5776:0\r\n#12 0x00007f2732039f65 llvm::ScalarEvolution::createAddRecFromPHI(llvm::PHINode*) /home/manishkh/Workspace7/orca/llvm/lib/Analysis/ScalarEvolution.cpp:5831:0\r\n#13 0x00007f273203aadf llvm::ScalarEvolution::createNodeForPHI(llvm::PHINode*) /home/manishkh/Workspace7/orca/llvm/lib/Analysis/ScalarEvolution.cpp:6025:0\r\n#14 0x00007f273204562a llvm::ScalarEvolution::createSCEV(llvm::Value*) /home/manishkh/Workspace7/orca/llvm/lib/Analysis/ScalarEvolution.cpp:8069:0\r\n#15 0x00007f2732042338 llvm::ScalarEvolution::createSCEVIter(llvm::Value*) /home/manishkh/Workspace7/orca/llvm/lib/Analysis/ScalarEvolution.cpp:7447:0\r\n#16 0x00007f2732035a05 llvm::ScalarEvolution::getSCEV(llvm::Value*) /home/manishkh/Workspace7/orca/llvm/lib/Analysis/ScalarEvolution.cpp:4572:0\r\n#17 0x00007f273203ab71 llvm::ScalarEvolution::createNodeForPHI(llvm::PHINode*) /home/manishkh/Workspace7/orca/llvm/lib/Analysis/ScalarEvolution.cpp:6029:0\r\n#18 0x00007f273204562a llvm::ScalarEvolution::createSCEV(llvm::Value*) /home/manishkh/Workspace7/orca/llvm/lib/Analysis/ScalarEvolution.cpp:8069:0\r\n#19 0x00007f2732042338 llvm::ScalarEvolution::createSCEVIter(llvm::Value*) /home/manishkh/Workspace7/orca/llvm/lib/Analysis/ScalarEvolution.cpp:7447:0\r\n#20 0x00007f2732035a05 llvm::ScalarEvolution::getSCEV(llvm::Value*) /home/manishkh/Workspace7/orca/llvm/lib/Analysis/ScalarEvolution.cpp:4572:0\r\n#21 0x00007f2732039fcf llvm::ScalarEvolution::createAddRecFromPHI(llvm::PHINode*) /home/manishkh/Workspace7/orca/llvm/lib/Analysis/ScalarEvolution.cpp:5840:0\r\n#22 0x00007f273203aadf llvm::ScalarEvolution::createNodeForPHI(llvm::PHINode*) /home/manishkh/Workspace7/orca/llvm/lib/Analysis/ScalarEvolution.cpp:6025:0\r\n#23 0x00007f273204562a llvm::ScalarEvolution::createSCEV(llvm::Value*) /home/manishkh/Workspace7/orca/llvm/lib/Analysis/ScalarEvolution.cpp:8069:0\r\n#24 0x00007f2732042338 llvm::ScalarEvolution::createSCEVIter(llvm::Value*) /home/manishkh/Workspace7/orca/llvm/lib/Analysis/ScalarEvolution.cpp:7447:0\r\n#25 0x00007f2732035a05 llvm::ScalarEvolution::getSCEV(llvm::Value*) /home/manishkh/Workspace7/orca/llvm/lib/Analysis/ScalarEvolution.cpp:4572:0\r\n#26 0x00007f273204a26a llvm::ScalarEvolution::computeExitLimitFromICmp(llvm::Loop const*, llvm::ICmpInst*, bool, bool, bool) /home/manishkh/Workspace7/orca/llvm/lib/Analysis/ScalarEvolution.cpp:9117:0\r\n#27 0x00007f273204971e llvm::ScalarEvolution::computeExitLimitFromCondImpl(llvm::ScalarEvolution::ExitLimitCache&, llvm::Loop const*, llvm::Value*, bool, bool, bool) /home/manishkh/Workspace7/orca/llvm/lib/Analysis/ScalarEvolution.cpp:8975:0\r\n#28 0x00007f273204955b llvm::ScalarEvolution::computeExitLimitFromCondCached(llvm::ScalarEvolution::ExitLimitCache&, llvm::Loop const*, llvm::Value*, bool, bool, bool) /home/manishkh/Workspace7/orca/llvm/lib/Analysis/ScalarEvolution.cpp:8958:0\r\n#29 0x00007f27320491a4 llvm::ScalarEvolution::computeExitLimitFromCond(llvm::Loop const*, llvm::Value*, bool, bool, bool) /home/manishkh/Workspace7/orca/llvm/lib/Analysis/ScalarEvolution.cpp:8914:0\r\n#30 0x00007f2732048f49 llvm::ScalarEvolution::computeExitLimit(llvm::Loop const*, llvm::BasicBlock*, bool) /home/manishkh/Workspace7/orca/llvm/lib/Analysis/ScalarEvolution.cpp:8888:0\r\n#31 0x00007f27320488db llvm::ScalarEvolution::computeBackedgeTakenCount(llvm::Loop const*, bool) /home/manishkh/Workspace7/orca/llvm/lib/Analysis/ScalarEvolution.cpp:8797:0\r\n#32 0x00007f27320469fb llvm::ScalarEvolution::getBackedgeTakenInfo(llvm::Loop const*) /home/manishkh/Workspace7/orca/llvm/lib/Analysis/ScalarEvolution.cpp:8358:0\r\n#33 0x00007f27320464ab llvm::ScalarEvolution::getExitCount(llvm::Loop const*, llvm::BasicBlock const*, llvm::ScalarEvolution::ExitCountKind) /home/manishkh/Workspace7/orca/llvm/lib/Analysis/ScalarEvolution.cpp:8270:0\r\n#34 0x00007f27320460c6 llvm::ScalarEvolution::getSmallConstantTripCount(llvm::Loop const*, llvm::BasicBlock const*) /home/manishkh/Workspace7/orca/llvm/lib/Analysis/ScalarEvolution.cpp:8203:0\r\n#35 0x00007f273146141a 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*) /home/manishkh/Workspace7/orca/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp:1259:0\r\n#36 0x00007f2731462e2c llvm::LoopUnrollPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/manishkh/Workspace7/orca/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp:1658:0\r\n#37 0x00007f27339727ac llvm::detail::PassModel<llvm::Function, llvm::LoopUnrollPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/manishkh/Workspace7/orca/llvm/include/llvm/IR/PassManagerInternal.h:91:0\r\n#38 0x00007f272f831f82 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/manishkh/Workspace7/orca/llvm/include/llvm/IR/PassManager.h:228:0\r\n#39 0x00007f27331d1e32 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/manishkh/Workspace7/orca/llvm/include/llvm/IR/PassManagerInternal.h:91:0\r\n#40 0x00007f272f830d12 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /home/manishkh/Workspace7/orca/llvm/lib/IR/PassManager.cpp:128:0\r\n#41 0x00007f27331d1d96 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /home/manishkh/Workspace7/orca/llvm/include/llvm/IR/PassManagerInternal.h:91:0\r\n#42 0x00007f272f831c5a llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /home/manishkh/Workspace7/orca/llvm/include/llvm/IR/PassManager.h:228:0\r\n#43 0x00000000004acc3e llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) /home/manishkh/Workspace7/orca/llvm/tools/opt/NewPMDriver.cpp:559:0\r\n#44 0x0000000000477a33 optMain /home/manishkh/Workspace7/orca/llvm/tools/opt/optdriver.cpp:756:0\r\n#45 0x000000000047540f main /home/manishkh/Workspace7/orca/llvm/tools/opt/opt.cpp:25:0\r\n#46 0x00007f272b87f555 __libc_start_main (/lib64/libc.so.6+0x22555)\r\n#47 0x00000000004752c9 _start (/home/manishkh/Workspace7/orcaInstall/installDA/bin/opt+0x4752c9)\r\n```\r\n\r\nas demonstrated by this godbolt example: https://godbolt.org/z/be3a4Yr9e",
"author": "Nirhar",
"labels": [
"llvm:crash",
"llvm:SCEV"
],
"comments": [
{
"author": "Nirhar",
"body": "I did some preliminary analysis on this bug, and here is what I found:\r\nThe IR at the point of crash looks like this:\r\n```\r\ndefine zing void @ham() {\r\nbb:\r\n br label %bb1\r\n\r\nbb1.loopexit: ; preds = %bb3\r\n %phi4.lcssa = phi i32 [ %phi4, %bb3 ]\r\n br label %bb1\r\n\r\nbb1: ; preds = %bb1.loopexit, %bb\r\n %phi = phi i32 [ 0, %bb ], [ %phi4.lcssa, %bb1.loopexit ]\r\n br label %bb5.peel.begin\r\n\r\nbb5.peel.begin: ; preds = %bb1\r\n br label %bb5.peel\r\n\r\nbb5.peel: ; preds = %bb5.peel.begin, exiting\r\n %icmp.peel = icmp eq i32 %phi, 0\r\n br i1 %icmp.peel, label %bb9.loopexit2, label %bb7.peel\r\n\r\nbb7.peel: ; preds = %bb5.peel\r\n %load.peel = load i32, ptr addrspace(1) null, align 4\r\n %add8.peel = add i32 %load.peel, 1\r\n br i1 false, label %bb2, label %bb5.peel.next\r\n\r\nbb5.peel.next: ; preds = %bb7.peel\r\n br label %bb5.peel.next1\r\n\r\nbb5.peel.next1: ; preds = %bb5.peel.next\r\n br label %bb1.peel.newph\r\n\r\nbb1.peel.newph: ; preds = %bb5.peel.next1\r\n br label %bb5\r\n\r\nbb2.loopexit: ; preds = %bb7\r\n %add8.lcssa.ph = phi i32 [ %add8, %bb7 ]\r\n br label %bb2\r\n\r\nbb2: ; preds = %bb2.loopexit, %bb7.peel\r\n %add8.lcssa = phi i32 [ %add8.peel, %bb7.peel ], [ %add8.lcssa.ph, %bb2.loopexit ]\r\n %call = call { i32, i1 } @llvm.smul.with.overflow.i32(i32 %add8.lcssa, i32 -2)\r\n %extractvalue = extractvalue { i32, i1 } %call, 0\r\n br label %bb3\r\n\r\nbb3: ; preds = %bb3, %bb2\r\n %phi4 = phi i32 [ %add, %bb3 ], [ 0, %bb2 ]\r\n %add = add i32 %extractvalue, %phi4\r\n br i1 false, label %bb3, label %bb1.loopexit\r\n\r\nbb5: ; preds = %bb7, %bb1.peel.newph, exiting\r\n br i1 false, label %bb9.loopexit, label %bb7\r\n\r\nbb7: ; preds = %bb5\r\n %load = load i32, ptr addrspace(1) null, align 4 \r\n %add8 = add i32 %load, 1\r\n br i1 false, label %bb2.loopexit, label %bb5, !llvm.loop !0\r\n\r\nbb9.loopexit: ; preds = %bb5\r\n br label %bb9\r\n\r\nbb9.loopexit2: ; preds = %bb5.peel\r\n br label %bb9\r\n\r\nbb9: ; preds = %bb9.loopexit2, %bb9.loopexit\r\n ret void\r\n}\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\r\ndeclare { i32, i1 } @llvm.smul.with.overflow.i32(i32, i32) #0\r\n\r\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\r\n```\r\nWe have 3 loops in this this IR(1 outer and 2 inner, out of which the bb5-bb7 loop has been peeled.):\r\n```\r\nLoop at depth 1 containing: %bb1<header>,%bb5<exiting>,%bb7,%bb2,%bb3,%bb1.loopexit<latch>,%bb5.peel.begin,%bb5.peel.next,%bb1.peel.newph,%bb5.peel<exiting>,%bb7.peel,%bb5.peel.next1\r\n Loop at depth 2 containing: %bb5<header><exiting>,%bb7<latch><exiting>\r\n Loop at depth 2 containing: %bb3<header><latch><exiting>\r\n``` \r\nHere is the CFG for this IR:\r\n\r\n\r\nThe assertion fails because SCEV expects bb7 to properly dominate bb3, which it does in the old IR, but after peeling, it does not. This seems to arise from the fact that SCEVs in %bb2 have not been invalidated after the peeling. I see that the SCEV for `%extractvalue` comes from the ValueExprMap instead of being recomputed, following the peel, and the use of this invalid SCEV is what I think is causing the problem.\r\n\r\n\r\n"
},
{
"author": "Nirhar",
"body": "Perhaps these updates to SE are not enough?\r\nhttps://github.com/llvm/llvm-project/blob/86d456ad8f2aef6edcc36d44d26119025331981e/llvm/lib/Transforms/Utils/LoopPeel.cpp#L1088-L1090"
},
{
"author": "Nirhar",
"body": "@nikic @fhahn @RKSimon is `forgetTopmostLoop` supposed to forget SCEV of all SSA values inside the loop(ie, header, latch and other blocks) ? I see that its implementation does not do that currently."
},
{
"author": "nikic",
"body": "@Nirhar Generally no. It forgets information about induction variables (things based on loop header phis), as well as information pertaining to the loop (such as BECounts, exit values etc), but not of literally everything defined in the loop."
},
{
"author": "nikic",
"body": "From a super quick look, the issue here might be that the exit phi forgetValue() calls don't invalidate enough values due to the condition at https://github.com/llvm/llvm-project/blob/e55585fd7bddf5bb3824a53cbe2971206d3c20c6/llvm/lib/Analysis/ScalarEvolution.cpp#L8415, which means that we will stop at the aggregate results of with.overflow intrinsics, even though SCEV can look through them. It might be that they need special handling."
},
{
"author": "v01dXYZ",
"body": "When replacing the `smul.with.overflow + extractvalue` by a `mul`, it doesn't abort.\r\nWhen removing the SCEVable check, it doesn't abort.\r\n\r\nThe function that allows to traverse unSCEVable when creating the SCEV is `MatchBinaryOp` (cf `createSimpleAffineRec`). We could make this function returns a subset of the use-def to SCEVable or have another function that do the reverse with a def-use matching."
},
{
"author": "Nirhar",
"body": "I think that the issue might be something else. From my analysis, here is how the control flow goes:\r\n1. When we hit `forgetTopmostLoop`, we try to forget the SCEV values of the loop:\r\n```\r\nLoop at depth 1 containing: %bb1<header>,%bb5<exiting>,%bb7,%bb2,%bb3,%bb1.loopexit<latch>,%bb5.peel.begin,%bb5.peel.next,%bb1.peel.newph,%bb5.peel<exiting>,%bb7.peel,%bb5.peel.next1\r\n Loop at depth 2 containing: %bb5<header><exiting>,%bb7<latch><exiting>\r\n Loop at depth 2 containing: %bb3<header><latch><exiting>\r\n```\r\nWe first take the phi node in the header `%phi = phi i32 [ 0, %bb ], [ %phi4.lcssa, %bb1.loopexit ]` and start the DFS from there. From here, we go to the following nodes:(` %icmp.peel = icmp eq i32 %phi, 0` , ` br i1 %icmp.peel, label %bb9.loopexit2, label %bb7.peel` and now non existent `%icmp = icmp eq i32 %phi, 0` , `br i1 %icmp, label %bb9, label %bb7`. The DFS for the outer loop ends here.\r\n\r\n2. Next we traverse the inner loop:\r\n```\r\nLoop at depth 2 containing: %bb3<header><latch><exiting>\r\n```\r\nHere we start with phi node in the header `%phi4 = phi i32 [ %add, %bb3 ], [ 0, %bb2 ]` and then traverse through the nodes: `%add = add i32 %extractvalue, %phi4` and `%phi4.lcssa = phi i32 [ %phi4, %bb3 ]`, after which we quit traversal.\r\n\r\n3. Finally we visit the inner loop:\r\n```\r\nLoop at depth 2 containing: %bb5<header><exiting>,%bb7<latch><exiting>\r\n```\r\nWe start and end DFS at (now non-existent)`%phi6 = phi i32 [ 0, %bb1.peel.newph ], [ 0, %bb7 ]`.\r\n\r\n**_TLDR_**; Throughout the entire traversal, we never visit the basic block bb2, and never invalidate its SCEV values. We don't even visit smul intrinsic call to forget its SCEV. Perhaps one needs to consider use-def chains to forget SCEV values, similar to the now considered def-use chain.\r\n\r\nNote: The IR at the point of crash is slightly different from the IR after the previous loop-peel. I've used the term `now non-existent` to mean that that node is not present in the IR at the crash point."
},
{
"author": "nikic",
"body": "@Nirhar The forgetTopmostLoop() call is not what is responsible for the invalidation here, it's the forgetValue() call on the LCSSA phis in https://github.com/llvm/llvm-project/blob/27ccc8835e5163484234549fa6128eeb00d7432d/llvm/lib/Transforms/Utils/LoopPeel.cpp#L862"
},
{
"author": "Nirhar",
"body": "Aah sorry, I missed that. Thanks for pointing it out!"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
80289
|
https://github.com/llvm/llvm-project/issues/80289
|
miscompilation
|
f7b05e055fa63e1c4b5ae5e391b654b57161a0e4
| 2024-02-01T13:14:59 |
[
"llvm/test/Transforms/LoopUnroll"
] |
{
"fix_commit": "62ae7d976f494f3dbd297331b19cd1204750de6f",
"components": [
"LoopUnrollRuntime"
],
"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": [
[
776,
782
]
],
"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": 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": [
"llvm::UnrollRuntimeLoopRemainder"
],
"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 62ae7d976f494f3dbd297331b19cd1204750de6f
Author: Nikita Popov <npopov@redhat.com>
Date: Thu Feb 1 16:06:58 2024 +0100
[LoopUnroll] Fix missing sign extension
For integers larger than 64-bit, this would zero-extend a -1
value, instead of sign-extending it.
Fixes https://github.com/llvm/llvm-project/issues/80289.
diff --git a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
index 612f69970881..650f055356c0 100644
--- a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
@@ -776,7 +776,7 @@ bool llvm::UnrollRuntimeLoopRemainder(
!isGuaranteedNotToBeUndefOrPoison(TripCount, AC, PreHeaderBR, DT)) {
TripCount = B.CreateFreeze(TripCount);
BECount =
- B.CreateAdd(TripCount, ConstantInt::get(TripCount->getType(), -1));
+ B.CreateAdd(TripCount, Constant::getAllOnesValue(TripCount->getType()));
} else {
// If we don't need to freeze, use SCEVExpander for BECount as well, to
// allow slightly better value reuse.
|
[
{
"file": "llvm/test/Transforms/LoopUnroll/runtime-i128.ll",
"commands": [
"opt -S -passes=loop-unroll -unroll-runtime < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "declare void @foo()\n\ndefine void @test(i128 %n, i128 %m) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i128 [ 0, %entry ], [ %iv.next, %loop ]\n call void @foo()\n %iv.next = add i128 %iv, 1\n %cmp = icmp ne i128 %iv.next, %n\n br i1 %cmp, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "WRONG code: LoopUnroll / SCEVExpander with i128 induction variable.",
"body": "This reduced (csmith) test case seems well-defined, and should print '6':\r\n\r\n```\r\nchar C = 0;\r\n__int128 IW = 0;\r\nint *IPtr1, *IPtr2;\r\n\r\nstruct S2 { int f3; };\r\nvolatile struct S2 g_1100;\r\n\r\nint main() {\r\n for (; C <= 5; C += 1)\r\n for (; IW <= 5; IW += 1) {\r\n IPtr1 = IPtr2;\r\n g_1100;\r\n }\r\n int crc = IW;\r\n printf(\"checksum = %d\\n\", crc);\r\n}\r\n```\r\n```\r\n\r\nclang -target s390x-linux-gnu -march=z16 -O3 -mllvm -enable-load-pre=false -o ./a.out -mllvm -unroll-max-count=3; ./a.out\r\nchecksum = 7\r\nclang -target s390x-linux-gnu -march=z16 -O3 -mllvm -enable-load-pre=false -o ./a.out -mllvm -unroll-max-count=2; ./a.out\r\nchecksum = 6\r\n```\r\n\r\nHowever, when unrolled 3 times (not 2 or 4), the LoopUnroller creates a prologue loop, which is supposed to run extra iterations, as computed in the preheader (LoopUnrollRuntime.cpp:766):\r\n\r\n```\r\nfor.body5.preheader: ; preds = %for.cond2thread-pre-split\r\n %2 = sub i128 6, %.pr121517\r\n %3 = freeze i128 %2\r\n %4 = add i128 %3, 18446744073709551615\r\n %5 = urem i128 %4, 3\r\n %6 = add i128 %5, 1\r\n %xtraiter = urem i128 %6, 3\r\n %lcmp.mod = icmp ne i128 %xtraiter, 0\r\n br i1 %lcmp.mod, label %for.body5.prol.preheader, label %for.body5.prol.loopexit\r\n```\r\n\r\nThe constant used for %4 is actually is supposed to be i128 '-1', so UINT64_MAX (i64 -1) doesn't make sense.\r\n\r\ni128 <> i64, after LoopUnroller:\r\n```\r\n\r\nfor.body5.preheader: for.body5.preheader: \r\n %2 = sub i128 6, %.pr121517 | %2 = sub i64 6, %.pr121517\r\n %3 = freeze i128 %2 | %3 = freeze i64 %2\r\n %4 = add i128 %3, 18446744073709551615 | %4 = add i64 %3, -1\r\n %5 = urem i128 %4, 3 | %5 = urem i64 %4, 3\r\n %6 = add i128 %5, 1 | %6 = add i64 %5, 1\r\n %xtraiter = urem i128 %6, 3 | %xtraiter = urem i64 %6, 3\r\n %lcmp.mod = icmp ne i128 %xtraiter, 0 | %lcmp.mod = icmp ne i64 %xtraiter, 0\r\n br i1 %lcmp.mod, label %for.body5.prol.preh br i1 %lcmp.mod, label %for.body5.prol.preh\r\n```\r\n\r\n%4 is later optimized to a sub i128 with a folded constant of 18446744073709551621, which really should be '5'.\r\n\r\n@nikic @boxu-zhang @xiangzh1 @preames @uweigand \r\n\r\n\r\n",
"author": "JonPsson1",
"labels": [
"miscompilation",
"loopoptim"
],
"comments": [
{
"author": "nikic",
"body": "Classic mistake, https://github.com/llvm/llvm-project/blob/f956e7fbf161447b9236f7c4448a9d02d3564261/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp#L779 create an unsigned `-1` value."
},
{
"author": "nikic",
"body": "As this is a recurring problem, I've started working on some sanity checks for APInt to solve this once and for all: https://github.com/llvm/llvm-project/pull/80309"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
121428
|
https://github.com/llvm/llvm-project/issues/121428
|
miscompilation
|
b5f21671ef04984bc00770263234dfb94833a274
| 2025-01-01T09:27:44 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "a37dbc1f51c70d92fd209c2e52a9d794eb15e4e7",
"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": [
[
1225,
1232
]
],
"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": [
"foldSelectCttzCtlz"
],
"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 a37dbc1f51c70d92fd209c2e52a9d794eb15e4e7
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Mon Jan 6 00:04:28 2025 +0800
[InstCombine] Drop noundef in `foldSelectCttzCtlz` (#121692)
Close https://github.com/llvm/llvm-project/issues/121428
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index e7a8e947705f..a18b927678ef 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -1225,8 +1225,12 @@ static Value *foldSelectCttzCtlz(ICmpInst *ICI, Value *TrueVal, Value *FalseVal,
// zext/trunc) have one use (ending at the select), the cttz/ctlz result will
// not be used if the input is zero. Relax to 'zero is poison' for that case.
if (II->hasOneUse() && SelectArg->hasOneUse() &&
- !match(II->getArgOperand(1), m_One()))
+ !match(II->getArgOperand(1), m_One())) {
II->setArgOperand(1, ConstantInt::getTrue(II->getContext()));
+ // noundef attribute on the intrinsic may no longer be valid.
+ II->dropUBImplyingAttrsAndMetadata();
+ IC.addToWorklist(II);
+ }
return nullptr;
}
|
[
{
"file": "llvm/test/Transforms/InstCombine/select-cmp-cttz-ctlz.ll",
"commands": [
"opt -passes=instcombine -S < %s"
],
"tests": [
{
"test_name": "test_cttz_not_bw_multiuse",
"test_body": "define i32 @test_cttz_not_bw_multiuse(i32 %x) {\n %ct = tail call i32 @llvm.cttz.i32(i32 %x, i1 false)\n %cmp = icmp ne i32 %x, 0\n %sel = select i1 %cmp, i32 %ct, i32 123\n %res = or i32 %sel, %ct\n ret i32 %res\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.cttz.i32(i32, i1 immarg) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_cttz_not_bw",
"test_body": "define i32 @test_cttz_not_bw(i32 %x) {\n %ct = tail call i32 @llvm.cttz.i32(i32 %x, i1 false)\n %cmp = icmp ne i32 %x, 0\n %res = select i1 %cmp, i32 %ct, i32 123\n ret i32 %res\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.cttz.i32(i32, i1 immarg) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_cttz_not_bw_noundef",
"test_body": "define i32 @test_cttz_not_bw_noundef(i32 %x) {\n %ct = tail call noundef i32 @llvm.cttz.i32(i32 %x, i1 false)\n %cmp = icmp ne i32 %x, 0\n %res = select i1 %cmp, i32 %ct, i32 123\n ret i32 %res\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.cttz.i32(i32, i1 immarg) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstCombine] `noundef` attribute should be dropped",
"body": "Alive2: https://alive2.llvm.org/ce/z/wKsUWK\n```\ndefine i32 @src(i32 noundef %x) {\n %ct = call noundef i32 @llvm.cttz.i32(i32 %x, i1 false)\n %cmp = icmp ne i32 %x, 0\n %res = select i1 %cmp, i32 %ct, i32 123\n ret i32 %res\n}\ndefine i32 @tgt(i32 noundef %x) {\n %ct = call noundef range(i32 0, 33) i32 @llvm.cttz.i32(i32 %x, i1 true)\n %cmp.not = icmp eq i32 %x, 0\n %res = select i1 %cmp.not, i32 123, i32 %ct\n ret i32 %res\n}\n```\n",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
89958
|
https://github.com/llvm/llvm-project/issues/89958
|
miscompilation
|
e913a33fcfbd667e4e3a35919b6bd9c5876a90a3
| 2024-04-24T17:36:34 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "b060661da8b3b53db55644e5e358bb2dca8b56d7",
"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": 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": [
[
681,
687
],
[
1376,
1386
],
[
1395,
1400
]
],
"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": [
[
126,
131
]
],
"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": [
"SCEVExpander::expandMinMaxExpr",
"SCEVExpander::visitSMaxExpr",
"SCEVExpander::visitUDivExpr"
],
"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 b060661da8b3b53db55644e5e358bb2dca8b56d7
Author: Florian Hahn <flo@fhahn.com>
Date: Thu Oct 17 13:55:20 2024 -0700
[SCEVExpander] Expand UDiv avoiding UB when in seq_min/max. (#92177)
Update SCEVExpander to introduce an SafeUDivMode, which is set
when expanding operands of SCEVSequentialMinMaxExpr. In this mode,
the expander will make sure that the divisor of the expanded UDiv is
neither 0 nor poison.
Fixes https://github.com/llvm/llvm-project/issues/89958.
PR https://github.com/llvm/llvm-project/pull/92177
diff --git a/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h b/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h
index 5697d983c9ad..7dd754a2bc0d 100644
--- a/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h
+++ b/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h
@@ -126,6 +126,11 @@ class SCEVExpander : public SCEVVisitor<SCEVExpander, Value *> {
/// "expanded" form.
bool LSRMode;
+ /// When true, rewrite any divisors of UDiv expressions that may be 0 to
+ /// umax(Divisor, 1) to avoid introducing UB. If the divisor may be poison,
+ /// freeze it first.
+ bool SafeUDivMode = false;
+
typedef IRBuilder<InstSimplifyFolder, IRBuilderCallbackInserter> BuilderType;
BuilderType Builder;
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index c412d0398b95..39da38e49181 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -681,7 +681,21 @@ Value *SCEVExpander::visitUDivExpr(const SCEVUDivExpr *S) {
SCEV::FlagAnyWrap, /*IsSafeToHoist*/ true);
}
- Value *RHS = expand(S->getRHS());
+ const SCEV *RHSExpr = S->getRHS();
+ Value *RHS = expand(RHSExpr);
+ if (SafeUDivMode) {
+ bool GuaranteedNotPoison =
+ ScalarEvolution::isGuaranteedNotToBePoison(RHSExpr);
+ if (!GuaranteedNotPoison)
+ RHS = Builder.CreateFreeze(RHS);
+
+ // We need an umax if either RHSExpr is not known to be zero, or if it is
+ // not guaranteed to be non-poison. In the later case, the frozen poison may
+ // be 0.
+ if (!SE.isKnownNonZero(RHSExpr) || !GuaranteedNotPoison)
+ RHS = Builder.CreateIntrinsic(RHS->getType(), Intrinsic::umax,
+ {RHS, ConstantInt::get(RHS->getType(), 1)});
+ }
return InsertBinop(Instruction::UDiv, LHS, RHS, SCEV::FlagAnyWrap,
/*IsSafeToHoist*/ SE.isKnownNonZero(S->getRHS()));
}
@@ -1376,11 +1390,14 @@ Value *SCEVExpander::visitSignExtendExpr(const SCEVSignExtendExpr *S) {
Value *SCEVExpander::expandMinMaxExpr(const SCEVNAryExpr *S,
Intrinsic::ID IntrinID, Twine Name,
bool IsSequential) {
+ bool PrevSafeMode = SafeUDivMode;
+ SafeUDivMode |= IsSequential;
Value *LHS = expand(S->getOperand(S->getNumOperands() - 1));
Type *Ty = LHS->getType();
if (IsSequential)
LHS = Builder.CreateFreeze(LHS);
for (int i = S->getNumOperands() - 2; i >= 0; --i) {
+ SafeUDivMode = (IsSequential && i != 0) || PrevSafeMode;
Value *RHS = expand(S->getOperand(i));
if (IsSequential && i != 0)
RHS = Builder.CreateFreeze(RHS);
@@ -1395,6 +1412,7 @@ Value *SCEVExpander::expandMinMaxExpr(const SCEVNAryExpr *S,
}
LHS = Sel;
}
+ SafeUDivMode = PrevSafeMode;
return LHS;
}
|
[
{
"file": "<issue>",
"commands": [
"opt -p loop-vectorize -force-vector-width=4 -S %s"
],
"tests": [
{
"test_name": "f",
"test_body": "define i64 @f(i64 %0) {\n br label %2\n\n2: ; preds = %5, %1\n %3 = phi i64 [ 0, %1 ], [ %6, %5 ]\n %4 = icmp slt i64 %3, %0\n br i1 %4, label %5, label %9\n\n5: ; preds = %2\n %6 = add i64 %3, 1\n %7 = udiv i64 42, %0\n %8 = icmp slt i64 %3, %7\n br i1 %8, label %2, label %9\n\n9: ; preds = %5, %2\n %10 = phi i64 [ 1, %2 ], [ 0, %5 ]\n ret i64 %10\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "miscompilation due to LoopVectorize making a function vulnerable to integer divide-by-zero",
"body": "https://alive2.llvm.org/ce/z/Kx2anL\r\n\r\nthis function:\r\n```llvm\r\ndefine i64 @f(i64 %0) {\r\n br label %2\r\n\r\n2: ; preds = %5, %1\r\n %3 = phi i64 [ 0, %1 ], [ %6, %5 ]\r\n %4 = icmp slt i64 %3, %0\r\n br i1 %4, label %5, label %9\r\n\r\n5: ; preds = %2\r\n %6 = add i64 %3, 1\r\n %7 = udiv i64 42, %0\r\n %8 = icmp slt i64 %3, %7\r\n br i1 %8, label %2, label %9\r\n\r\n9: ; preds = %5, %2\r\n %10 = phi i64 [ 1, %2 ], [ 0, %5 ]\r\n ret i64 %10\r\n}\r\n```\r\nis getting optimized to:\r\n```lllvm\r\ndefine noundef i64 @f(i64 %0) local_unnamed_addr #0 {\r\n %smax = tail call i64 @llvm.smax.i64(i64 %0, i64 0)\r\n %2 = udiv i64 42, %0\r\n %umin = tail call i64 @llvm.umin.i64(i64 %smax, i64 %2)\r\n %min.iters.check = icmp ult i64 %umin, 4\r\n br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph\r\n\r\nvector.ph: ; preds = %1\r\n %3 = add nuw nsw i64 %umin, 1\r\n %n.mod.vf = and i64 %3, 3\r\n %4 = icmp eq i64 %n.mod.vf, 0\r\n %5 = select i1 %4, i64 4, i64 %n.mod.vf\r\n %n.vec = sub nsw i64 %3, %5\r\n br label %vector.body\r\n\r\nvector.body: ; preds = %vector.body, %vector.ph\r\n %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]\r\n %index.next = add nuw i64 %index, 4\r\n %6 = icmp eq i64 %index.next, %n.vec\r\n br i1 %6, label %scalar.ph.preheader, label %vector.body, !llvm.loop !0\r\n\r\nscalar.ph.preheader: ; preds = %vector.body, %1\r\n %.ph = phi i64 [ 0, %1 ], [ %n.vec, %vector.body ]\r\n br label %scalar.ph\r\n\r\nscalar.ph: ; preds = %scalar.ph.preheader, %9\r\n %7 = phi i64 [ %10, %9 ], [ %.ph, %scalar.ph.preheader ]\r\n %8 = icmp slt i64 %7, %0\r\n br i1 %8, label %9, label %13\r\n\r\n9: ; preds = %scalar.ph\r\n %10 = add nuw nsw i64 %7, 1\r\n %11 = udiv i64 42, %0\r\n %12 = icmp ult i64 %7, %11\r\n br i1 %12, label %scalar.ph, label %13, !llvm.loop !3\r\n\r\n13: ; preds = %9, %scalar.ph\r\n %14 = phi i64 [ 1, %scalar.ph ], [ 0, %9 ]\r\n ret i64 %14\r\n}\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\r\ndeclare i64 @llvm.smax.i64(i64, i64) #1\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\r\ndeclare i64 @llvm.umin.i64(i64, i64) #1\r\n\r\nattributes #0 = { nofree norecurse nosync nounwind memory(none) }\r\nattributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\r\n\r\n!0 = distinct !{!0, !1, !2}\r\n!1 = !{!\"llvm.loop.isvectorized\", i32 1}\r\n!2 = !{!\"llvm.loop.unroll.runtime.disable\"}\r\n!3 = distinct !{!3, !2, !1}\r\n```\r\n\r\nthe problem is that the optimized code can divide by zero even when the original code doesn't. to see this, pass 0 as an argument to `f`. I also independently verified on an x64-64 that the optimized code traps out with an FPE while the original code does not. it's LoopVectorize that's the culprit.\r\n\r\ncc @nunoplopes @hatsunespica\r\n",
"author": "regehr",
"labels": [
"miscompilation",
"llvm:SCEV"
],
"comments": [
{
"author": "dtcxzyw",
"body": "cc @fhahn "
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
128401
|
https://github.com/llvm/llvm-project/issues/128401
|
crash
|
22a5bb32b787443b70476cc1359709b6c888b591
| 2025-02-23T05:19:16 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "eb14d2a1d48fe76c5faed71a08547135a35ee742",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
13320,
13328
],
[
13874,
13888
]
],
"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::isGatherShuffledEntry",
"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 eb14d2a1d48fe76c5faed71a08547135a35ee742
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Mon Feb 24 06:02:56 2025 -0800
[SLP]Fix check for matched gather node, if it is a subvector node
If the gather node is a subvector node, it may match the existing
vector/gather node in the graph, but still may require reordering. in
this case need to fully check its dependencies to prevent a compiler
crash.
Fixes #128401
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index bf256d82ae17..5fc5fb10fad5 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -13320,9 +13320,16 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
Entries.clear();
// TODO: currently checking only for Scalars in the tree entry, need to count
// reused elements too for better cost estimation.
- const EdgeInfo &TEUseEI = TE == VectorizableTree.front().get()
- ? EdgeInfo(const_cast<TreeEntry *>(TE), 0)
- : TE->UserTreeIndex;
+ auto GetUserEntry = [&](const TreeEntry *TE) {
+ while (TE->UserTreeIndex && TE->UserTreeIndex.EdgeIdx == UINT_MAX)
+ TE = TE->UserTreeIndex.UserTE;
+ if (TE == VectorizableTree.front().get())
+ return EdgeInfo(const_cast<TreeEntry *>(TE), 0);
+ return TE->UserTreeIndex;
+ };
+ const EdgeInfo TEUseEI = GetUserEntry(TE);
+ if (!TEUseEI)
+ return std::nullopt;
const Instruction *TEInsertPt = &getLastInstructionInBundle(TEUseEI.UserTE);
const BasicBlock *TEInsertBlock = nullptr;
// Main node of PHI entries keeps the correct order of operands/incoming
@@ -13874,15 +13881,13 @@ BoUpSLP::isGatherShuffledEntry(
assert(VL.size() % NumParts == 0 &&
"Number of scalars must be divisible by NumParts.");
if (TE->UserTreeIndex && TE->UserTreeIndex.UserTE->isGather() &&
- TE->UserTreeIndex.EdgeIdx == UINT_MAX) {
- assert(
- (TE->Idx == 0 ||
- (TE->hasState() && TE->getOpcode() == Instruction::ExtractElement) ||
- isSplat(TE->Scalars) ||
- getSameValuesTreeEntry(TE->getMainOp(), TE->Scalars)) &&
- "Expected splat or extractelements only node.");
+ TE->UserTreeIndex.EdgeIdx == UINT_MAX &&
+ (TE->Idx == 0 ||
+ (TE->hasState() && TE->getOpcode() == Instruction::ExtractElement) ||
+ isSplat(TE->Scalars) ||
+ (TE->hasState() &&
+ getSameValuesTreeEntry(TE->getMainOp(), TE->Scalars))))
return {};
- }
unsigned SliceSize = getPartNumElems(VL.size(), NumParts);
SmallVector<std::optional<TTI::ShuffleKind>> Res;
for (unsigned Part : seq<unsigned>(NumParts)) {
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/bv-matched-node-reorder.ll",
"commands": [
"opt -passes=slp-vectorizer -S -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n@g = global [8 x i8] zeroinitializer\n\ndefine i32 @main() {\n;\nentry:\n %l2.i.i.i.i = load i8, ptr getelementptr inbounds nuw (i8, ptr @g, i64 5), align 1\n %li.i.i.i = load i8, ptr getelementptr inbounds nuw (i8, ptr @g, i64 4), align 1\n %l1.i.i.i.i = load i8, ptr getelementptr inbounds nuw (i8, ptr @g, i64 7), align 1\n %l6.i.i.i.i = load i8, ptr getelementptr inbounds nuw (i8, ptr @g, i64 6), align 1\n br i1 false, label %if.end151.1.i.i.1.i.i.i, label %end\n\npre:\n br label %end\n\nend:\n %0 = phi i8 [ 0, %pre ], [ %li.i.i.i, %entry ]\n %1 = phi i8 [ 0, %pre ], [ %l2.i.i.i.i, %entry ]\n %2 = phi i8 [ 0, %pre ], [ %l6.i.i.i.i, %entry ]\n %3 = phi i8 [ 0, %pre ], [ %l1.i.i.i.i, %entry ]\n %4 = phi i8 [ 0, %pre ], [ %l1.i.i.i.i, %entry ]\n %5 = phi i8 [ 0, %pre ], [ %l6.i.i.i.i, %entry ]\n %6 = phi i8 [ 0, %pre ], [ %l2.i.i.i.i, %entry ]\n %7 = phi i8 [ 0, %pre ], [ %li.i.i.i, %entry ]\n br label %if.end151.1.i.i.1.i.i.i\n\nif.end151.1.i.i.1.i.i.i:\n %8 = phi i8 [ %li.i.i.i, %entry ], [ %7, %end ]\n %9 = phi i8 [ %l2.i.i.i.i, %entry ], [ %6, %end ]\n %10 = phi i8 [ %l6.i.i.i.i, %entry ], [ %5, %end ]\n %11 = phi i8 [ %l1.i.i.i.i, %entry ], [ %4, %end ]\n %12 = phi i8 [ %l1.i.i.i.i, %entry ], [ %3, %end ]\n %13 = phi i8 [ 0, %entry ], [ %2, %end ]\n %14 = phi i8 [ %l2.i.i.i.i, %entry ], [ %1, %end ]\n %15 = phi i8 [ %li.i.i.i, %entry ], [ %0, %end ]\n %16 = phi i8 [ 0, %entry ], [ %6, %end ]\n %17 = phi i8 [ %l1.i.i.i.i, %entry ], [ %4, %end ]\n %18 = phi i8 [ %l6.i.i.i.i, %entry ], [ %5, %end ]\n %19 = phi i8 [ %l1.i.i.i.i, %entry ], [ %4, %end ]\n %20 = phi i8 [ %l6.i.i.i.i, %entry ], [ %5, %end ]\n %21 = phi i8 [ %l2.i.i.i.i, %entry ], [ %6, %end ]\n %22 = phi i8 [ %li.i.i.i, %entry ], [ %7, %end ]\n %tobool.not.i.1121.i.1.i.i.i = icmp ne i8 %18, 0\n %c1.1.1117.i.1.i9.i.i = icmp eq i8 %17, 0\n %c1.i.1.i.i.i = icmp eq i8 %16, 0\n %c1.1.i.i.i.i = icmp eq i8 %12, 0\n %cmp258.i.1.i.i.i.i = icmp eq i8 %13, 0\n %c1.i.i.i.i = icmp eq i8 %14, 0\n %cmp258.i.i.i.i.i = icmp eq i8 %15, 0\n %c1.1.1.i.i.i.i = icmp eq i8 %11, 0\n %cmp258.i.1.1.i.i.i.i = icmp eq i8 %10, 0\n %c1.187.i.i.i.i = icmp eq i8 %9, 0\n %cmp258.i.185.i.i.i.i = icmp eq i8 %8, 0\n %c1.1.1117.i.i.i.i = icmp eq i8 %19, 0\n %cmp258.i.1.1115.i.i.i.i = icmp eq i8 %20, 0\n %c1.1113.i.i.i.i = icmp eq i8 %21, 0\n %cmp258.i.1111.i.i.i.i = icmp eq i8 %22, 0\n %c1.187.1.i.i.i.i = icmp eq i8 %16, 0\n ret i32 0\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SLPVectorizer] Assertion `\"Expected splat or extractelements only node.\"' failed.",
"body": "Reproducer: https://godbolt.org/z/9jx1xejoe\n```\n; bin/opt -passes=slp-vectorizer test.ll -S\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@g = global [8 x i8] zeroinitializer\n\ndefine i32 @main() {\nentry:\n %.promoted42.i.i.i.i = load i8, ptr getelementptr inbounds nuw (i8, ptr @g, i64 5), align 1\n %.promoted.i.i.i.i = load i8, ptr getelementptr inbounds nuw (i8, ptr @g, i64 4), align 1\n %.promoted51.i.i.i.i = load i8, ptr getelementptr inbounds nuw (i8, ptr @g, i64 7), align 1\n %.promoted56.i.i.i.i = load i8, ptr getelementptr inbounds nuw (i8, ptr @g, i64 6), align 1\n br i1 false, label %if.end151.1.i.i.1.i.i.i, label %if.end151.1.i.1.i.i.i.i\n\nfor.cond79.preheader.us.preheader.1.i.1.i.i.i.i:\n br label %if.end151.1.i.1.i.i.i.i\n\nif.end151.1.i.1.i.i.i.i:\n %0 = phi i8 [ 0, %for.cond79.preheader.us.preheader.1.i.1.i.i.i.i ], [ %.promoted.i.i.i.i, %entry ]\n %1 = phi i8 [ 0, %for.cond79.preheader.us.preheader.1.i.1.i.i.i.i ], [ %.promoted42.i.i.i.i, %entry ]\n %2 = phi i8 [ 0, %for.cond79.preheader.us.preheader.1.i.1.i.i.i.i ], [ %.promoted56.i.i.i.i, %entry ]\n %3 = phi i8 [ 0, %for.cond79.preheader.us.preheader.1.i.1.i.i.i.i ], [ %.promoted51.i.i.i.i, %entry ]\n %4 = phi i8 [ 0, %for.cond79.preheader.us.preheader.1.i.1.i.i.i.i ], [ %.promoted51.i.i.i.i, %entry ]\n %5 = phi i8 [ 0, %for.cond79.preheader.us.preheader.1.i.1.i.i.i.i ], [ %.promoted56.i.i.i.i, %entry ]\n %6 = phi i8 [ 0, %for.cond79.preheader.us.preheader.1.i.1.i.i.i.i ], [ %.promoted42.i.i.i.i, %entry ]\n %7 = phi i8 [ 0, %for.cond79.preheader.us.preheader.1.i.1.i.i.i.i ], [ %.promoted.i.i.i.i, %entry ]\n br label %if.end151.1.i.i.1.i.i.i\n\nif.end151.1.i.i.1.i.i.i:\n %8 = phi i8 [ %.promoted.i.i.i.i, %entry ], [ %7, %if.end151.1.i.1.i.i.i.i ]\n %9 = phi i8 [ %.promoted42.i.i.i.i, %entry ], [ %6, %if.end151.1.i.1.i.i.i.i ]\n %10 = phi i8 [ %.promoted56.i.i.i.i, %entry ], [ %5, %if.end151.1.i.1.i.i.i.i ]\n %11 = phi i8 [ %.promoted51.i.i.i.i, %entry ], [ %4, %if.end151.1.i.1.i.i.i.i ]\n %12 = phi i8 [ %.promoted51.i.i.i.i, %entry ], [ %3, %if.end151.1.i.1.i.i.i.i ]\n %13 = phi i8 [ 0, %entry ], [ %2, %if.end151.1.i.1.i.i.i.i ]\n %14 = phi i8 [ %.promoted42.i.i.i.i, %entry ], [ %1, %if.end151.1.i.1.i.i.i.i ]\n %15 = phi i8 [ %.promoted.i.i.i.i, %entry ], [ %0, %if.end151.1.i.1.i.i.i.i ]\n %16 = phi i8 [ 0, %entry ], [ %6, %if.end151.1.i.1.i.i.i.i ]\n %17 = phi i8 [ %.promoted51.i.i.i.i, %entry ], [ %4, %if.end151.1.i.1.i.i.i.i ]\n %18 = phi i8 [ %.promoted56.i.i.i.i, %entry ], [ %5, %if.end151.1.i.1.i.i.i.i ]\n %19 = phi i8 [ %.promoted51.i.i.i.i, %entry ], [ %4, %if.end151.1.i.1.i.i.i.i ]\n %20 = phi i8 [ %.promoted56.i.i.i.i, %entry ], [ %5, %if.end151.1.i.1.i.i.i.i ]\n %21 = phi i8 [ %.promoted42.i.i.i.i, %entry ], [ %6, %if.end151.1.i.1.i.i.i.i ]\n %22 = phi i8 [ %.promoted.i.i.i.i, %entry ], [ %7, %if.end151.1.i.1.i.i.i.i ]\n %tobool.not.i.1121.i.1.i.i.i = icmp ne i8 %18, 0\n %cmp258.1.i.1.1117.i.1.i9.i.i = icmp eq i8 %17, 0\n %cmp258.1.i.i.1.i.i.i = icmp eq i8 %16, 0\n %cmp258.1.i.1.i.i.i.i = icmp eq i8 %12, 0\n %cmp258.i.1.i.i.i.i = icmp eq i8 %13, 0\n %cmp258.1.i.i.i.i.i = icmp eq i8 %14, 0\n %cmp258.i.i.i.i.i = icmp eq i8 %15, 0\n %cmp258.1.i.1.1.i.i.i.i = icmp eq i8 %11, 0\n %cmp258.i.1.1.i.i.i.i = icmp eq i8 %10, 0\n %cmp258.1.i.187.i.i.i.i = icmp eq i8 %9, 0\n %cmp258.i.185.i.i.i.i = icmp eq i8 %8, 0\n %cmp258.1.i.1.1117.i.i.i.i = icmp eq i8 %19, 0\n %cmp258.i.1.1115.i.i.i.i = icmp eq i8 %20, 0\n %cmp258.1.i.1113.i.i.i.i = icmp eq i8 %21, 0\n %cmp258.i.1111.i.i.i.i = icmp eq i8 %22, 0\n %cmp258.1.i.187.1.i.i.i.i = icmp eq i8 %16, 0\n ret i32 0\n}\n```\n```\nopt: /root/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:13878: llvm::SmallVector<std::optional<llvm::TargetTransformInfo::ShuffleKind> > llvm::slpvectorizer::BoUpSLP::isGatherShuffledEntry(const llvm::slpvectorizer::BoUpSLP::TreeEntry*, llvm::ArrayRef<llvm::Value*>, llvm::SmallVectorImpl<int>&, llvm::SmallVectorImpl<llvm::SmallVector<const llvm::slpvectorizer::BoUpSLP::TreeEntry*> >&, unsigned int, bool): Assertion `(TE->Idx == 0 || (TE->hasState() && TE->getOpcode() == Instruction::ExtractElement) || isSplat(TE->Scalars) || getSameValuesTreeEntry(TE->getMainOp(), TE->Scalars)) && \"Expected splat or extractelements only node.\"' 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 0x0000000005447b18 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5447b18)\n #1 0x00000000054454d4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x000072c4b8a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x000072c4b8a969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x000072c4b8a42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x000072c4b8a287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x000072c4b8a2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x000072c4b8a39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x000000000447b405 llvm::slpvectorizer::BoUpSLP::isGatherShuffledEntry(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallVectorImpl<int>&, llvm::SmallVectorImpl<llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, 6u>>&, unsigned int, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x447b405)\n #9 0x000000000447c786 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+0x447c786)\n#10 0x000000000447ec37 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+0x447ec37)\n#11 0x00000000044b3879 llvm::slpvectorizer::BoUpSLP::getTreeCost(llvm::ArrayRef<llvm::Value*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x44b3879)\n#12 0x00000000044bd45d llvm::SLPVectorizerPass::tryToVectorizeList(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x44bd45d)\n#13 0x00000000044c1701 bool llvm::SLPVectorizerPass::vectorizeCmpInsts<std::reverse_iterator<llvm::CmpInst* const*>>(llvm::iterator_range<std::reverse_iterator<llvm::CmpInst* const*>>, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x44c1701)\n#14 0x00000000044c1fab llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&)::'lambda3'(bool)::operator()(bool) const SLPVectorizer.cpp:0:0\n#15 0x00000000044c575f llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x44c575f)\n#16 0x00000000044cbef6 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 0x00000000044cca4b llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x44cca4b)\n#18 0x0000000003182e1e 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+0x3182e1e)\n#19 0x00000000052431d0 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x52431d0)\n#20 0x0000000000e6e03e 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+0xe6e03e)\n#21 0x0000000005241aeb llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5241aeb)\n#22 0x0000000000e6d34e 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+0xe6d34e)\n#23 0x00000000052414f0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x52414f0)\n#24 0x0000000000935a5a 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+0x935a5a)\n#25 0x00000000009290cc optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9290cc)\n#26 0x000072c4b8a29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#27 0x000072c4b8a29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#28 0x00000000009209a5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9209a5)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```\nllvm version: dbd219aef4be56754c793589c60bd787b7de60c2\n",
"author": "dtcxzyw",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid",
"generated by fuzzer"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
121110
|
https://github.com/llvm/llvm-project/issues/121110
|
miscompilation
|
f68dbbbd57dd0947730300d1e827ad16c2dfffb5
| 2024-12-25T13:57:11 |
[
"llvm/test/Transforms/VectorCombine"
] |
{
"fix_commit": "f2f02b21cd581057e3c9b4a7a27e0014eeb9ba15",
"components": [
"VectorCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
1669,
1675
],
[
1677,
1684
],
[
1727,
1740
],
[
1750,
1759
]
],
"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::foldShuffleOfBinops"
],
"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 f2f02b21cd581057e3c9b4a7a27e0014eeb9ba15
Author: Simon Pilgrim <llvm-dev@redking.me.uk>
Date: Sat Dec 28 09:21:22 2024 +0000
[VectorCombine] foldShuffleOfBinops - only accept exact matching cmp predicates
m_SpecificCmp allowed equivalent predicate+flags which don't necessarily work after being folded from "shuffle (cmpop), (cmpop)" into "cmpop (shuffle), (shuffle)"
Fixes #121110
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index ecbc13d489eb..2460ccc61d84 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -1669,7 +1669,8 @@ bool VectorCombine::foldShuffleOfBinops(Instruction &I) {
Value *X, *Y, *Z, *W;
bool IsCommutative = false;
- CmpPredicate Pred = CmpInst::BAD_ICMP_PREDICATE;
+ CmpPredicate PredLHS = CmpInst::BAD_ICMP_PREDICATE;
+ CmpPredicate PredRHS = CmpInst::BAD_ICMP_PREDICATE;
if (match(LHS, m_BinOp(m_Value(X), m_Value(Y))) &&
match(RHS, m_BinOp(m_Value(Z), m_Value(W)))) {
auto *BO = cast<BinaryOperator>(LHS);
@@ -1677,8 +1678,9 @@ bool VectorCombine::foldShuffleOfBinops(Instruction &I) {
if (llvm::is_contained(OldMask, PoisonMaskElem) && BO->isIntDivRem())
return false;
IsCommutative = BinaryOperator::isCommutative(BO->getOpcode());
- } else if (match(LHS, m_Cmp(Pred, m_Value(X), m_Value(Y))) &&
- match(RHS, m_SpecificCmp(Pred, m_Value(Z), m_Value(W)))) {
+ } else if (match(LHS, m_Cmp(PredLHS, m_Value(X), m_Value(Y))) &&
+ match(RHS, m_Cmp(PredRHS, m_Value(Z), m_Value(W))) &&
+ (CmpInst::Predicate)PredLHS == (CmpInst::Predicate)PredRHS) {
IsCommutative = cast<CmpInst>(LHS)->isCommutative();
} else
return false;
@@ -1727,14 +1729,14 @@ bool VectorCombine::foldShuffleOfBinops(Instruction &I) {
TTI.getShuffleCost(SK0, BinOpTy, NewMask0, CostKind, 0, nullptr, {X, Z}) +
TTI.getShuffleCost(SK1, BinOpTy, NewMask1, CostKind, 0, nullptr, {Y, W});
- if (Pred == CmpInst::BAD_ICMP_PREDICATE) {
+ if (PredLHS == CmpInst::BAD_ICMP_PREDICATE) {
NewCost +=
TTI.getArithmeticInstrCost(LHS->getOpcode(), ShuffleDstTy, CostKind);
} else {
auto *ShuffleCmpTy =
FixedVectorType::get(BinOpTy->getElementType(), ShuffleDstTy);
NewCost += TTI.getCmpSelInstrCost(LHS->getOpcode(), ShuffleCmpTy,
- ShuffleDstTy, Pred, CostKind);
+ ShuffleDstTy, PredLHS, CostKind);
}
LLVM_DEBUG(dbgs() << "Found a shuffle feeding two binops: " << I
@@ -1750,10 +1752,10 @@ bool VectorCombine::foldShuffleOfBinops(Instruction &I) {
Value *Shuf0 = Builder.CreateShuffleVector(X, Z, NewMask0);
Value *Shuf1 = Builder.CreateShuffleVector(Y, W, NewMask1);
- Value *NewBO = Pred == CmpInst::BAD_ICMP_PREDICATE
+ Value *NewBO = PredLHS == CmpInst::BAD_ICMP_PREDICATE
? Builder.CreateBinOp(
cast<BinaryOperator>(LHS)->getOpcode(), Shuf0, Shuf1)
- : Builder.CreateCmp(Pred, Shuf0, Shuf1);
+ : Builder.CreateCmp(PredLHS, Shuf0, Shuf1);
// Intersect flags from the old binops.
if (auto *NewInst = dyn_cast<Instruction>(NewBO)) {
|
[
{
"file": "llvm/test/Transforms/VectorCombine/X86/shuffle-of-cmps.ll",
"commands": [
"opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=sse2",
"opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=sse4.2",
"opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=avx2",
"opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=avx512vl"
],
"tests": [
{
"test_name": "shuf_icmp_ugt_v4i32_use",
"test_body": "declare void @use(<4 x i1>)\n\ndefine <4 x i32> @shuf_icmp_ugt_v4i32_use(<4 x i32> %x, <4 x i32> %y, <4 x i32> %z, <4 x i32> %w) {\n %c0 = icmp ugt <4 x i32> %x, %y\n %c1 = icmp ugt <4 x i32> %z, %w\n call void @use(<4 x i1> %c0)\n %s = shufflevector <4 x i1> %c0, <4 x i1> %c1, <4 x i32> <i32 1, i32 3, i32 5, i32 7>\n %r = sext <4 x i1> %s to <4 x i32>\n ret <4 x i32> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "PR121110",
"test_body": "define <2 x i1> @PR121110() {\n %ugt = icmp samesign ugt <2 x i32> zeroinitializer, zeroinitializer\n %sgt = icmp sgt <2 x i32> zeroinitializer, <i32 6, i32 -4>\n %res = shufflevector <2 x i1> %ugt, <2 x i1> %sgt, <2 x i32> <i32 0, i32 3>\n ret <2 x i1> %res\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[clang] Miscompilation at -Os",
"body": "This code prints 9 at `-Os` and 0 at `-O0/1/2/3`:\n\n```c\nint printf(const char *, ...);\nchar a = 9, c, d;\nint b, e;\nunsigned short f;\nchar *g = &a;\nvoid h(int i) {\n for (; b; b++)\n c &= 0 <= i;\n}\nstatic short j(unsigned long i) {\n int k;\n for (; e + d + 4 > 0;) {\n k = i + 49;\n h(k + i - 52 + i);\n *g = 0;\n return 0;\n }\n return 0;\n}\nint main() {\n j(6 < (unsigned short)(f - 7) + f);\n printf(\"%d\\n\", a);\n}\n```\n\nCompiler Explorer: https://godbolt.org/z/Mo5TEKh8r\n\nBisected to https://github.com/llvm/llvm-project/commit/5287299f8809ae927a0acafb179c4b37ce9ff21d, which was committed by @RKSimon ",
"author": "cardigan1008",
"labels": [
"miscompilation",
"vectorizers"
],
"comments": [
{
"author": "RKSimon",
"body": "I'm not convinced the patch is responsible, it's more likely exposed something else. I'll take a look after the Christmas break."
},
{
"author": "dtcxzyw",
"body": "Reproducer: https://alive2.llvm.org/ce/z/jdkwFh\n```\n; bin/opt -passes=vector-combine test.ll -S\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine <2 x i1> @src() {\nentry:\n %0 = icmp samesign ugt <2 x i32> zeroinitializer, zeroinitializer\n %1 = icmp sgt <2 x i32> zeroinitializer, <i32 6, i32 -4>\n %2 = shufflevector <2 x i1> %0, <2 x i1> %1, <2 x i32> <i32 0, i32 3>\n ret <2 x i1> %2\n}\n```\n```\ndefine <2 x i1> @tgt() {\nentry:\n ret <2 x i1> zeroinitializer\n}\n```\n```\n\n----------------------------------------\ndefine <2 x i1> @src() {\nentry:\n %#0 = icmp samesign ugt <2 x i32> { 0, 0 }, { 0, 0 }\n %#1 = icmp sgt <2 x i32> { 0, 0 }, { 6, 4294967292 }\n %#2 = shufflevector <2 x i1> %#0, <2 x i1> %#1, 0, 3\n ret <2 x i1> %#2\n}\n=>\ndefine <2 x i1> @tgt() {\nentry:\n ret <2 x i1> { 0, 0 }\n}\nTransformation doesn't verify!\n\nERROR: Value mismatch\n\nExample:\n\nSource:\n<2 x i1> %#0 = < #x0 (0), #x0 (0) >\n<2 x i1> %#1 = < #x0 (0), #x1 (1) >\n<2 x i1> %#2 = < #x0 (0), #x1 (1) >\n\nTarget:\nSource value: < #x0 (0), #x1 (1) >\nTarget value: < #x0 (0), #x0 (0) >\n```\n"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
105120
|
https://github.com/llvm/llvm-project/issues/105120
|
crash
|
6ec3130a38e6982a61e7fa74bd5223c95c0bb918
| 2024-08-20T17:04:34 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "e31252bf54dedadfe78b36d07ea6084156faa38a",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
7227,
7232
],
[
7238,
7247
]
],
"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 e31252bf54dedadfe78b36d07ea6084156faa38a
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Wed Aug 21 11:47:00 2024 -0700
[SLP]Fix PR105120: fix the order of phi nodes vectorization.
The operands of the phi nodes should be vectorized in the same order, in
which they were created, otherwise the compiler may crash when trying
to correctly build dependency for nodes with non-schedulable
instructions for gather/buildvector nodes.
Fixes https://github.com/llvm/llvm-project/issues/105120
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index dee6d688b1b9..848e0de20e7b 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -7227,6 +7227,22 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
unsigned ShuffleOrOp = S.isAltShuffle() ?
(unsigned) Instruction::ShuffleVector : S.getOpcode();
+ auto CreateOperandNodes = [&](TreeEntry *TE, const auto &Operands) {
+ // Postpone PHI nodes creation
+ SmallVector<unsigned> PHIOps;
+ for (unsigned I : seq<unsigned>(Operands.size())) {
+ ArrayRef<Value *> Op = Operands[I];
+ if (Op.empty())
+ continue;
+ InstructionsState S = getSameOpcode(Op, *TLI);
+ if (S.getOpcode() != Instruction::PHI || S.isAltShuffle())
+ buildTree_rec(Op, Depth + 1, {TE, I});
+ else
+ PHIOps.push_back(I);
+ }
+ for (unsigned I : PHIOps)
+ buildTree_rec(Operands[I], Depth + 1, {TE, I});
+ };
switch (ShuffleOrOp) {
case Instruction::PHI: {
auto *PH = cast<PHINode>(VL0);
@@ -7238,10 +7254,12 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
// Keeps the reordered operands to avoid code duplication.
PHIHandler Handler(*DT, PH, VL);
Handler.buildOperands();
- for (unsigned I : seq<unsigned>(0, PH->getNumOperands()))
+ for (unsigned I : seq<unsigned>(PH->getNumOperands()))
TE->setOperand(I, Handler.getOperands(I));
- for (unsigned I : seq<unsigned>(0, PH->getNumOperands()))
- buildTree_rec(Handler.getOperands(I), Depth + 1, {TE, I});
+ SmallVector<ArrayRef<Value *>> Operands(PH->getNumOperands());
+ for (unsigned I : seq<unsigned>(PH->getNumOperands()))
+ Operands[I] = Handler.getOperands(I);
+ CreateOperandNodes(TE, Operands);
return;
}
case Instruction::ExtractValue:
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/phi-nodes-as-operand-reorder.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-99999 < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define void @test() {\nbb:\n br label %bb1\n\nbb1: ; preds = %bb3, %bb\n %phi = phi i32 [ 0, %bb ], [ %add5, %bb3 ]\n %phi2 = phi i32 [ 0, %bb ], [ %add, %bb3 ]\n br i1 false, label %bb6, label %bb3\n\nbb3: ; preds = %bb1\n %add = add i32 0, 0\n %add4 = add i32 0, 0\n %add5 = add i32 %phi, 0\n br i1 false, label %bb6, label %bb1\n\nbb6: ; preds = %bb3, %bb1\n %phi7 = phi i32 [ %phi2, %bb1 ], [ %add4, %bb3 ]\n %phi8 = phi i32 [ %phi, %bb1 ], [ %add5, %bb3 ]\n ret void\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 the test below with -passes slp-vectorizer -slp-threshold=-99999\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() #0 gc \"statepoint-example\" {\r\nbb:\r\n br label %bb1\r\n\r\nbb1: ; preds = %bb3, %bb\r\n %phi = phi i32 [ 0, %bb ], [ %add5, %bb3 ]\r\n %phi2 = phi i32 [ 0, %bb ], [ %add, %bb3 ]\r\n br i1 false, label %bb6, label %bb3\r\n\r\nbb3: ; preds = %bb1\r\n %add = add i32 0, 0\r\n %add4 = add i32 0, 0\r\n %add5 = add i32 %phi, 0\r\n br i1 false, label %bb6, label %bb1\r\n\r\nbb6: ; preds = %bb3, %bb1\r\n %phi7 = phi i32 [ %phi2, %bb1 ], [ %add4, %bb3 ]\r\n %phi8 = phi i32 [ %phi, %bb1 ], [ %add5, %bb3 ]\r\n ret void\r\n}\r\n```\r\nReproducer: https://godbolt.org/z/W96s5a1cb\r\n\r\n```\r\nInstruction does not dominate all uses!\r\n %2 = shufflevector <2 x i32> %0, <2 x i32> <i32 0, i32 poison>, <2 x i32> <i32 2, i32 1>\r\n %1 = add <2 x i32> zeroinitializer, %2\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 -slp-threshold=-99999 <source>\r\n1.\tRunning pass \"verify\" on module \"<source>\"\r\n #0 0x0000000004f84b88 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f84b88)\r\n #1 0x0000000004f822fc SignalHandler(int) Signals.cpp:0:0\r\n #2 0x000074dcb3642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x000074dcb36969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x000074dcb3642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x000074dcb36287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00000000007b7cc5 llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0\r\n #7 0x0000000004ebea18 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4ebea18)\r\n #8 0x0000000004dbae20 llvm::VerifierPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4dbae20)\r\n #9 0x00000000008dbbde 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+0x8dbbde)\r\n#10 0x0000000004d7ebb0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d7ebb0)\r\n#11 0x00000000008e6912 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+0x8e6912)\r\n#12 0x00000000008d97ec optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8d97ec)\r\n#13 0x000074dcb3629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#14 0x000074dcb3629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#15 0x00000000008d127e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8d127e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```",
"author": "TatyanaDoubts",
"labels": [
"llvm:SLPVectorizer",
"llvm:crash"
],
"comments": [
{
"author": "alexey-bataev",
"body": "Yes"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
78049
|
https://github.com/llvm/llvm-project/issues/78049
|
crash
|
de8f782355842a5d3ad44ad8861c53e3ef6fa73a
| 2024-01-13T16:38:44 |
[
"llvm/test/Transforms/MoveAutoInit"
] |
{
"fix_commit": "26d3cd1d07ae3fc8312feb2ab3a3a86414f28c70",
"components": [
"MoveAutoInit"
],
"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": [
[
164,
169
],
[
178,
186
]
],
"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": 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": [
"runMoveAutoInit"
],
"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 26d3cd1d07ae3fc8312feb2ab3a3a86414f28c70
Author: XChy <xxs_chy@outlook.com>
Date: Tue Jan 16 18:45:44 2024 +0800
[MoveAutoInit] Ignore unreachable basicblocks and handle catchswitch (#78232)
Fixes #78049
This patch has done:
- Ignore unreachable predecessors when looking for nearest common
dominator.
- Check catchswitch with `getFirstNonPHI`, instead of
`getFirstInsertionPt`. The latter skips EHPad.
diff --git a/llvm/lib/Transforms/Utils/MoveAutoInit.cpp b/llvm/lib/Transforms/Utils/MoveAutoInit.cpp
index a977ad87b79f..9a5dba219cee 100644
--- a/llvm/lib/Transforms/Utils/MoveAutoInit.cpp
+++ b/llvm/lib/Transforms/Utils/MoveAutoInit.cpp
@@ -164,6 +164,9 @@ static bool runMoveAutoInit(Function &F, DominatorTree &DT, MemorySSA &MSSA) {
if (TransitiveSuccessors.count(Pred))
continue;
+ if (!DT.isReachableFromEntry(Pred))
+ continue;
+
DominatingPredecessor =
DominatingPredecessor
? DT.findNearestCommonDominator(DominatingPredecessor, Pred)
@@ -178,9 +181,10 @@ static bool runMoveAutoInit(Function &F, DominatorTree &DT, MemorySSA &MSSA) {
// CatchSwitchInst blocks can only have one instruction, so they are not
// good candidates for insertion.
- while (isa<CatchSwitchInst>(UsersDominator->getFirstInsertionPt())) {
+ while (isa<CatchSwitchInst>(UsersDominator->getFirstNonPHI())) {
for (BasicBlock *Pred : predecessors(UsersDominator))
- UsersDominator = DT.findNearestCommonDominator(UsersDominator, Pred);
+ if (DT.isReachableFromEntry(Pred))
+ UsersDominator = DT.findNearestCommonDominator(UsersDominator, Pred);
}
// We finally found a place where I can be moved while not introducing extra
|
[
{
"file": "llvm/test/Transforms/MoveAutoInit/catchswitch.ll",
"commands": [
"opt < %s -S -passes='move-auto-init' -verify-memoryssa"
],
"tests": [
{
"test_name": "test",
"test_body": "declare void @dummy()\n\ndeclare void @dummy1()\n\ndefine void @test() personality ptr @dummy {\nentry:\n %p = alloca [2 x i16], i32 0, align 2\n store i32 0, ptr %p, align 2, !annotation !0\n br label %middle\n\nmiddle: ; preds = %entry\n %call = invoke ptr @dummy()\n to label %clean unwind label %catchbb\n\nclean: ; preds = %middle\n ret void\n\ncatchbb: ; preds = %middle\n %cs = catchswitch within none [label %pad, label %pad1] unwind to caller\n\npad: ; preds = %catchbb\n %c = catchpad within %cs [i32 0]\n call void @dummy1()\n ret void\n\npad1: ; preds = %catchbb\n %c1 = catchpad within %cs [i32 0]\n call void @dummy1()\n ret void\n}\n\n!0 = !{!\"auto-init\"}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/MoveAutoInit/loop.ll",
"commands": [
"opt < %s -S -passes='move-auto-init' -verify-memoryssa"
],
"tests": [
{
"test_name": "foo",
"test_body": "target datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine void @foo(i32 %x) {\nentry:\n %buffer = alloca [80 x i32], align 16\n call void @llvm.memset.p0.i64(ptr align 16 %buffer, i8 -86, i64 320, i1 false), !annotation !0\n br label %do.body\n\ndo.body: ; preds = %do.cond, %entry\n %x.addr.0 = phi i32 [ %x, %entry ], [ %dec, %do.cond ]\n %arrayidx = getelementptr inbounds [80 x i32], ptr %buffer, i64 0, i64 0\n call void @dump(ptr %arrayidx)\n br label %do.cond\n\ndo.cond: ; preds = %do.body\n %dec = add nsw i32 %x.addr.0, -1\n %tobool = icmp ne i32 %x.addr.0, 0\n br i1 %tobool, label %do.body, label %do.end\n\ndo.end: ; preds = %do.cond\n ret void\n}\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\ndeclare void @dump(ptr)\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\n\n!0 = !{!\"auto-init\"}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "bar",
"test_body": "target datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128\"\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\ndeclare void @dump(ptr)\n\ndefine void @bar(i32 %x, i32 %y) {\nentry:\n %buffer = alloca [80 x i32], align 16\n call void @llvm.memset.p0.i64(ptr align 16 %buffer, i8 -86, i64 320, i1 false), !annotation !0\n %tobool = icmp ne i32 %y, 0\n br i1 %tobool, label %if.then, label %if.end\n\nif.then: ; preds = %entry\n %add = add nsw i32 %x, %y\n br label %do.body\n\ndo.body: ; preds = %do.cond, %if.then\n %x.addr.0 = phi i32 [ %add, %if.then ], [ %dec, %do.cond ]\n %arrayidx = getelementptr inbounds [80 x i32], ptr %buffer, i64 0, i64 0\n call void @dump(ptr %arrayidx)\n br label %do.cond\n\ndo.cond: ; preds = %do.body\n %dec = add nsw i32 %x.addr.0, -1\n %tobool1 = icmp ne i32 %x.addr.0, 0\n br i1 %tobool1, label %do.body, label %do.end\n\ndo.end: ; preds = %do.cond\n br label %if.end\n\nif.end: ; preds = %do.end, %entry\n ret void\n}\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\n\n!0 = !{!\"auto-init\"}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[MoveAutoInit] Assertion `NodeB && \"B must be in the tree\"' failed.",
"body": "opt -O3 -sroa-skip-mem2reg -enable-dfa-jump-thread tc_dt.ll\r\n[tc_dt.tar.gz](https://github.com/llvm/llvm-project/files/13928836/tc_dt.tar.gz)\r\n\r\nGenericDomTree.h:501: NodeT* llvm::DominatorTreeBase<NodeT, IsPostDom>::findNearestCommonDominator(NodeT*, NodeT*) const [with NodeT = llvm::BasicBlock; \r\nbool IsPostDom = false]: Assertion `NodeB && \"B must be in the tree\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\n\r\nReduced test case attached, but have not looked into it. Adding people high in the log...\r\n",
"author": "JonPsson1",
"labels": [
"crash",
"llvm:transforms"
],
"comments": [
{
"author": "bjope",
"body": "Reduced the test case and pipeline a bit more:\r\n\r\nopt -S -o - -passes='dfa-jump-threading,move-auto-init' reduced.ll \r\n\r\nWith reduced.ll being\r\n```\r\ndefine void @func_1() {\r\nentry:\r\n %l_2586 = alloca [2 x i16], i32 0, align 2\r\n store i32 0, ptr %l_2586, align 2, !annotation !0\r\n br label %lbl_2844.preheader\r\n\r\nlbl_2844.preheader: ; preds = %entry\r\n br label %lbl_2844\r\n\r\nlbl_2844: ; preds = %cleanup1473, %lbl_2844.preheader\r\n call void null()\r\n br label %cleanup1473\r\n\r\nfor.end516: ; No predecessors!\r\n br label %cleanup1473\r\n\r\ncleanup1473: ; preds = %for.end516, %lbl_2844\r\n %cleanup.dest.slot.0 = phi i32 [ 0, %for.end516 ], [ 17, %lbl_2844 ]\r\n switch i32 %cleanup.dest.slot.0, label %cleanup1829 [\r\n i32 0, label %if.end1787\r\n i32 17, label %lbl_2844\r\n ]\r\n\r\nif.end1787: ; preds = %cleanup1473\r\n %cmp1789.not = icmp ult ptr null, %l_2586\r\n unreachable\r\n\r\ncleanup1829: ; preds = %cleanup1473\r\n ret void\r\n}\r\n\r\n!0 = !{!\"auto-init\"}\r\n\r\n```"
},
{
"author": "XChy",
"body": "It seems that DFAJumpThreading broke the dominator tree analysis."
},
{
"author": "XChy",
"body": "> It seems that DFAJumpThreading broke the dominator tree analysis.\r\n\r\nIn fact, *MoveAutoInit* should be to blame. This pass doesn't handle unreachable predecessors correctly. A reduced version without `DFAJumpThreading`: \r\n```llvm\r\ndeclare void @dummy()\r\n\r\ndefine void @func_1() {\r\nentry:\r\n %p = alloca [2 x i16], i32 0, align 2\r\n store i32 0, ptr %p, align 2, !annotation !0\r\n br i1 true, label %loop, label %usebb\r\n\r\nloop:\r\n call void @dummy()\r\n br label %loop\r\n\r\na:\r\n br label %loop\r\n\r\nb:\r\n br label %loop\r\n\r\nusebb:\r\n %use_p = icmp ult ptr null, %p\r\n ret void\r\n}\r\n\r\n!0 = !{!\"auto-init\"}\r\n```\r\n\r\nAnd after looking into the source, I found that this pass doesn't handle `catchswitch` well too. For example:\r\n```llvm\r\ndeclare void @dummy()\r\n\r\ndeclare void @dummy1()\r\n\r\ndefine void @func_1() personality ptr @dummy {\r\nentry:\r\n %p = alloca [2 x i16], i32 0, align 2\r\n store i32 0, ptr %p, align 2, !annotation !0\r\n %call = invoke ptr @dummy() to label %clean unwind label %catchbb\r\n\r\nunreachable:\r\n %call1 = invoke ptr @dummy() to label %clean unwind label %catchbb\r\n\r\nclean:\r\n ret void\r\n\r\ncatchbb:\r\n %cs = catchswitch within none [label %pad, label %pad1] unwind to caller\r\n\r\npad:\r\n %c = catchpad within %cs [ptr null, i32 0, ptr null]\r\n call void @dummy1()\r\n ret void\r\n\r\npad1:\r\n %c1 = catchpad within %cs [ptr null, i32 0, ptr null]\r\n call void @dummy1()\r\n ret void\r\n}\r\n\r\n!0 = !{!\"auto-init\"}\r\n```\r\n"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
113423
|
https://github.com/llvm/llvm-project/issues/113423
|
miscompilation
|
a1c6dc223ee1eedc049890676992b508ebd6b623
| 2024-10-23T07:13:21 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "cf1963afad335cf74a9411f106d1f2fe80dbed2f",
"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": [
[
529,
537
],
[
564,
569
]
],
"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::foldSelectIntoOp"
],
"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 cf1963afad335cf74a9411f106d1f2fe80dbed2f
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Thu Oct 31 23:26:45 2024 +0800
[InstCombine] Fix FMF propagation in `foldSelectIntoOp` (#114356)
Closes https://github.com/llvm/llvm-project/issues/113423.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index c5f39a4c381e..9e193e7faa8a 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -529,9 +529,6 @@ Instruction *InstCombinerImpl::foldSelectIntoOp(SelectInst &SI, Value *TrueVal,
if (!OpToFold)
return nullptr;
- // TODO: We probably ought to revisit cases where the select and FP
- // instructions have different flags and add tests to ensure the
- // behaviour is correct.
FastMathFlags FMF;
if (isa<FPMathOperator>(&SI))
FMF = SI.getFastMathFlags();
@@ -564,6 +561,8 @@ Instruction *InstCombinerImpl::foldSelectIntoOp(SelectInst &SI, Value *TrueVal,
BinaryOperator *BO =
BinaryOperator::Create(TVI->getOpcode(), FalseVal, NewSel);
BO->copyIRFlags(TVI);
+ if (isa<FPMathOperator>(&SI))
+ BO->andIRFlags(NewSel);
return BO;
};
|
[
{
"file": "llvm/test/Transforms/InstCombine/fold-select-fmul-if-zero.ll",
"commands": [
"opt -S -passes=instcombine < %s"
],
"tests": [
{
"test_name": "fmul_by_self_if_0_oeq_zero_f32_fmul_nnan_ninf_nsz",
"test_body": "define float @fmul_by_self_if_0_oeq_zero_f32_fmul_nnan_ninf_nsz(float %x) {\n %x.is.zero = fcmp oeq float %x, 0.000000e+00\n %scaled.x = fmul nnan ninf nsz float %x, %x\n %scaled.if.denormal = select nnan i1 %x.is.zero, float %scaled.x, float %x\n ret float %scaled.if.denormal\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Wrong folding of `select` into floating number ops",
"body": "https://github.com/llvm/llvm-project/blob/ae618d360456c5ccf6c8cf2294e708ac6625950e/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp#L559-L568\r\n\r\nThe compiler explorer's alive2 times out for this case.\r\nBut I post a proof that the optimization actually happens: https://alive2.llvm.org/ce/z/7MRSu5\r\n\r\n\r\nThis is the Alive2 report on my machine:\r\n```llvm\r\n----------------------------------------\r\ndefine float @fmul_by_self_if_0_oeq_zero_f32_fmul_nnan_ninf_nsz.2(float %x) {\r\n#0:\r\n %#1 = fcmp ule float %x, 0.000000\r\n %scaled.x = fmul nnan ninf nsz float %x, %x\r\n %scaled.if.denormal = select nnan i1 %#1, float %x, float %scaled.x\r\n ret float %scaled.if.denormal\r\n}\r\n=>\r\ndefine float @fmul_by_self_if_0_oeq_zero_f32_fmul_nnan_ninf_nsz.2(float %x) {\r\n#0:\r\n %#1 = fcmp ule float %x, 0.000000\r\n %scaled.x = select nnan i1 %#1, float 1.000000, float %x\r\n %scaled.if.denormal = fmul nnan ninf nsz float %scaled.x, %x\r\n ret float %scaled.if.denormal\r\n}\r\nTransformation doesn't verify!\r\n\r\nERROR: Target is more poisonous than source\r\n\r\nExample:\r\nfloat %x = #xff800000 (-oo)\r\n\r\nSource:\r\ni1 %#1 = #x1 (1)\r\nfloat %scaled.x = poison\r\nfloat %scaled.if.denormal = #xff800000 (-oo)\r\n\r\nTarget:\r\ni1 %#1 = #x1 (1)\r\nfloat %scaled.x = #x3f800000 (1)\r\nfloat %scaled.if.denormal = poison\r\nSource value: #xff800000 (-oo)\r\nTarget value: poison\r\n\r\nSummary:\r\n 0 correct transformations\r\n 1 incorrect transformations\r\n 0 failed-to-prove transformations\r\n 0 Alive2 errors\r\n```",
"author": "bongjunj",
"labels": [
"miscompilation",
"llvm:instcombine",
"floating-point"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
135182
|
https://github.com/llvm/llvm-project/issues/135182
|
miscompilation
|
77db154cf9383fa20685fca56633601ce0ea47fa
| 2025-04-10T13:51:31 |
[
"llvm/test/Transforms/IndVarSimplify"
] |
{
"fix_commit": "d14acb78065bdd331019924feaaef52e5e744529",
"components": [
"SimplifyIndVar"
],
"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": [
[
1743,
1748
]
],
"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": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": [
"WidenIV::widenWithVariantUse"
],
"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 d14acb78065bdd331019924feaaef52e5e744529
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Fri Apr 11 09:03:06 2025 +0800
[IndVarSimplify] Handle the case where both operands are the same when widening IV (#135207)
`WidenIV::widenWithVariantUse` assumes that exactly one of the binop
operands is the IV to be widened. This miscompilation happens when it
tries to sign-extend the "NonIV" operand while the IV is zero-extended.
Closes https://github.com/llvm/llvm-project/issues/135182.
diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
index 7b9c5c77cbe9..5a76bec01765 100644
--- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
@@ -1743,6 +1743,9 @@ bool WidenIV::widenWithVariantUse(WidenIV::NarrowIVDefUse DU) {
// TODO: Support case for NarrowDef = NarrowUse->getOperand(1).
if (NarrowUse->getOperand(0) != NarrowDef)
return false;
+ // We cannot use a different extend kind for the same operand.
+ if (NarrowUse->getOperand(1) == NarrowDef)
+ return false;
if (!SE->isKnownNegative(RHS))
return false;
bool ProvedSubNUW = SE->isKnownPredicateAt(ICmpInst::ICMP_UGE, LHS,
|
[
{
"file": "llvm/test/Transforms/IndVarSimplify/pr135182.ll",
"commands": [
"opt -S -passes=indvars < %s"
],
"tests": [
{
"test_name": "pr135182",
"test_body": "target datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine i32 @pr135182() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %indvar = phi i16 [ -12, %entry ], [ %indvar.next, %for.body ]\n %add = add i16 %indvar, %indvar\n %ext = zext i16 %add to i32\n %indvar.next = add i16 %indvar, 1\n br i1 false, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret i32 %ext\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[IndVarSimplify] Miscompilation at -O3",
"body": "Reproducer: https://alive2.llvm.org/ce/z/fvxiS3\n```\n; bin/opt -passes=indvars test.ll -S\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @src(ptr %p) {\nentry:\n br label %for.body21\n\nfor.body21:\n %storemerge629 = phi i8 [ -12, %entry ], [ %dec, %for.body21 ]\n %conv29 = sext i8 %storemerge629 to i16\n %conv1.i = sext i8 %storemerge629 to i16\n %add.i = add i16 %conv29, %conv1.i\n %conv55 = zext i16 %add.i to i32\n store i32 %conv55, ptr %p, align 4\n %dec = add i8 %storemerge629, 1\n br i1 false, label %for.body21, label %for.end234\n\nfor.end234:\n ret void\n}\n```\nOutput:\n```\ndefine void @tgt(ptr %p) {\n br label %for.body21\n\nfor.body21: ; preds = %for.body21, %entry\n store i32 131048, ptr %p, align 4\n br i1 false, label %for.body21, label %for.end234\n\nfor.end234: ; preds = %for.body21\n ret void\n}\n```\n`store i32 131048, ptr @g_150, align 4` should be `store i32 65512, ptr @g_150, align 4`\nllvm version: f819f46284f2a79790038e1f6649172789734ae8\n",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:transforms"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
108620
|
https://github.com/llvm/llvm-project/issues/108620
|
crash
|
03618ceabd003be94190b068db11b607fd1108ef
| 2024-09-13T18:15:02 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "1e3536ef3141d6429f3616af624b81b6d6ab2959",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
1283,
1293
],
[
14222,
14235
],
[
14373,
14378
],
[
14426,
14436
],
[
14530,
14537
],
[
14757,
14762
],
[
17660,
17666
],
[
17956,
17961
],
[
18024,
18031
]
],
"llvm/lib/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",
"tryToReduce"
],
"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 1e3536ef3141d6429f3616af624b81b6d6ab2959
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Fri Sep 13 15:40:22 2024 -0700
[SLP]Fix PR108620: Need to check, if the reduced value was transformed
Before trying to include the scalar into the list of
ExternallyUsedValues, need to check, if it was transformed in previous
iteration and use the transformed value, not the original one, to avoid
compiler crash when building external uses.
Fixes https://github.com/llvm/llvm-project/issues/108620
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 0afe02fc08ff..5f2bf082fb87 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -1283,11 +1283,8 @@ public:
/// Vectorize the tree but with the list of externally used values \p
/// ExternallyUsedValues. Values in this MapVector can be replaced but the
/// generated extractvalue instructions.
- /// \param ReplacedExternals containd list of replaced external values
- /// {scalar, replace} after emitting extractelement for external uses.
Value *
vectorizeTree(const ExtraValueToDebugLocsMap &ExternallyUsedValues,
- SmallVectorImpl<std::pair<Value *, Value *>> &ReplacedExternals,
Instruction *ReductionRoot = nullptr);
/// \returns the cost incurred by unwanted spills and fills, caused by
@@ -14222,14 +14219,12 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
Value *BoUpSLP::vectorizeTree() {
ExtraValueToDebugLocsMap ExternallyUsedValues;
- SmallVector<std::pair<Value *, Value *>> ReplacedExternals;
- return vectorizeTree(ExternallyUsedValues, ReplacedExternals);
+ return vectorizeTree(ExternallyUsedValues);
}
-Value *BoUpSLP::vectorizeTree(
- const ExtraValueToDebugLocsMap &ExternallyUsedValues,
- SmallVectorImpl<std::pair<Value *, Value *>> &ReplacedExternals,
- Instruction *ReductionRoot) {
+Value *
+BoUpSLP::vectorizeTree(const ExtraValueToDebugLocsMap &ExternallyUsedValues,
+ Instruction *ReductionRoot) {
// All blocks must be scheduled before any instructions are inserted.
for (auto &BSIter : BlocksSchedules) {
scheduleBlock(BSIter.second.get());
@@ -14373,6 +14368,7 @@ Value *BoUpSLP::vectorizeTree(
SmallDenseSet<Value *, 4> UsedInserts;
DenseMap<std::pair<Value *, Type *>, Value *> VectorCasts;
SmallDenseSet<Value *, 4> ScalarsWithNullptrUser;
+ SmallDenseSet<ExtractElementInst *, 4> IgnoredExtracts;
// Extract all of the elements with the external uses.
for (const auto &ExternalUse : ExternalUses) {
Value *Scalar = ExternalUse.Scalar;
@@ -14426,11 +14422,16 @@ Value *BoUpSLP::vectorizeTree(
if (ReplaceInst) {
// Leave the instruction as is, if it cheaper extracts and all
// operands are scalar.
- auto *CloneInst = Inst->clone();
- CloneInst->insertBefore(Inst);
- if (Inst->hasName())
- CloneInst->takeName(Inst);
- Ex = CloneInst;
+ if (auto *EE = dyn_cast<ExtractElementInst>(Inst)) {
+ IgnoredExtracts.insert(EE);
+ Ex = EE;
+ } else {
+ auto *CloneInst = Inst->clone();
+ CloneInst->insertBefore(Inst);
+ if (Inst->hasName())
+ CloneInst->takeName(Inst);
+ Ex = CloneInst;
+ }
} else if (auto *ES = dyn_cast<ExtractElementInst>(Scalar);
ES && isa<Instruction>(Vec)) {
Value *V = ES->getVectorOperand();
@@ -14530,8 +14531,12 @@ Value *BoUpSLP::vectorizeTree(
}
Value *NewInst = ExtractAndExtendIfNeeded(Vec);
// Required to update internally referenced instructions.
- Scalar->replaceAllUsesWith(NewInst);
- ReplacedExternals.emplace_back(Scalar, NewInst);
+ if (Scalar != NewInst) {
+ assert((!isa<ExtractElementInst>(Scalar) ||
+ !IgnoredExtracts.contains(cast<ExtractElementInst>(Scalar))) &&
+ "Extractelements should not be replaced.");
+ Scalar->replaceAllUsesWith(NewInst);
+ }
continue;
}
@@ -14757,6 +14762,9 @@ Value *BoUpSLP::vectorizeTree(
if (Entry->getOpcode() == Instruction::GetElementPtr &&
!isa<GetElementPtrInst>(Scalar))
continue;
+ if (auto *EE = dyn_cast<ExtractElementInst>(Scalar);
+ EE && IgnoredExtracts.contains(EE))
+ continue;
#ifndef NDEBUG
Type *Ty = Scalar->getType();
if (!Ty->isVoidTy()) {
@@ -17660,7 +17668,6 @@ public:
// because of the vectorization.
DenseMap<Value *, WeakTrackingVH> TrackedVals(ReducedVals.size() *
ReducedVals.front().size());
- SmallVector<std::pair<Value *, Value *>> ReplacedExternals;
// The compare instruction of a min/max is the insertion point for new
// instructions and may be replaced with a new compare instruction.
@@ -17956,6 +17963,8 @@ public:
if (Cnt >= Pos && Cnt < Pos + ReduxWidth)
continue;
Value *RdxVal = Candidates[Cnt];
+ if (auto It = TrackedVals.find(RdxVal); It != TrackedVals.end())
+ RdxVal = It->second;
if (!Visited.insert(RdxVal).second)
continue;
// Check if the scalar was vectorized as part of the vectorization
@@ -18024,8 +18033,8 @@ public:
InsertPt = GetCmpForMinMaxReduction(RdxRootInst);
// Vectorize a tree.
- Value *VectorizedRoot = V.vectorizeTree(LocalExternallyUsedValues,
- ReplacedExternals, InsertPt);
+ Value *VectorizedRoot =
+ V.vectorizeTree(LocalExternallyUsedValues, InsertPt);
Builder.SetInsertPoint(InsertPt);
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/reduced-val-extracted-and-externally-used.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define void @test(i32 %arg) {\nbb:\n br label %bb1\n\nbb1: ; preds = %bb1, %bb\n %phi = phi i32 [ 0, %bb ], [ %add27, %bb1 ]\n %phi2 = phi i32 [ 0, %bb ], [ %add24, %bb1 ]\n %phi3 = phi i32 [ 0, %bb ], [ %xor26, %bb1 ]\n %add = add i32 %phi2, 0\n %add4 = add i32 %phi2, 0\n %xor = xor i32 %add, %add4\n %add5 = add i32 %phi, 0\n %add6 = add i32 %phi2, 0\n %add7 = add i32 %phi2, 0\n %xor8 = xor i32 %add6, %xor\n %xor9 = xor i32 %xor8, %add5\n %xor10 = xor i32 %xor9, %add7\n %add11 = add i32 %phi, 0\n %add12 = add i32 %phi2, 0\n %add13 = add i32 %phi2, 0\n %xor14 = xor i32 %add12, %xor10\n %xor15 = xor i32 %xor14, %add11\n %xor16 = xor i32 %xor15, %add13\n %add17 = add i32 %phi, 0\n %add18 = add i32 %phi2, 0\n %add19 = add i32 %phi2, 0\n %xor20 = xor i32 %add18, %xor16\n %xor21 = xor i32 %xor20, %add17\n %xor22 = xor i32 %xor21, %add19\n %add23 = add i32 %phi2, 0\n %add24 = add i32 %arg, 0\n %xor25 = xor i32 %add23, %xor22\n %xor26 = xor i32 %xor25, %add24\n %add27 = add i32 1, 0\n %icmp = icmp ult i32 %add27, 0\n br label %bb1\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Assertion `(I->use_empty() || all_of(I->uses(), [&](Use &U) { return isDeleted( cast<Instruction>(U.getUser())); })) && \"trying to erase instruction with users.\"' failed.",
"body": "To reproduce run the following test with -passes=slp-vectorizer\r\n```\r\n; ModuleID = './reduced.ll'\r\nsource_filename = \"./reduced.ll\"\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine void @wombat(i32 %arg) gc \"statepoint-example\" {\r\nbb:\r\n br label %bb1\r\n\r\nbb1: ; preds = %bb1, %bb\r\n %phi = phi i32 [ 0, %bb ], [ %add27, %bb1 ]\r\n %phi2 = phi i32 [ 0, %bb ], [ %add24, %bb1 ]\r\n %phi3 = phi i32 [ 0, %bb ], [ %xor26, %bb1 ]\r\n %add = add i32 %phi2, 0\r\n %add4 = add i32 %phi2, 0\r\n %xor = xor i32 %add, %add4\r\n %add5 = add i32 %phi, 0\r\n %add6 = add i32 %phi2, 0\r\n %add7 = add i32 %phi2, 0\r\n %xor8 = xor i32 %add6, %xor\r\n %xor9 = xor i32 %xor8, %add5\r\n %xor10 = xor i32 %xor9, %add7\r\n %add11 = add i32 %phi, 0\r\n %add12 = add i32 %phi2, 0\r\n %add13 = add i32 %phi2, 0\r\n %xor14 = xor i32 %add12, %xor10\r\n %xor15 = xor i32 %xor14, %add11\r\n %xor16 = xor i32 %xor15, %add13\r\n %add17 = add i32 %phi, 0\r\n %add18 = add i32 %phi2, 0\r\n %add19 = add i32 %phi2, 0\r\n %xor20 = xor i32 %add18, %xor16\r\n %xor21 = xor i32 %xor20, %add17\r\n %xor22 = xor i32 %xor21, %add19\r\n %add23 = add i32 %phi2, 0\r\n %add24 = add i32 %arg, 0\r\n %xor25 = xor i32 %add23, %xor22\r\n %xor26 = xor i32 %xor25, %add24\r\n %add27 = add i32 1, 0\r\n %icmp = icmp ult i32 %add27, 0\r\n br label %bb1\r\n}\r\n```\r\nReproducer: https://godbolt.org/z/77hKre61P\r\n\r\nStack dump:\r\n```\r\nopt: /root/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:2663: void llvm::slpvectorizer::BoUpSLP::removeInstructionsAndOperands(llvm::ArrayRef<U*>) [with T = llvm::Instruction]: Assertion `(I->use_empty() || all_of(I->uses(), [&](Use &U) { return isDeleted( cast<Instruction>(U.getUser())); })) && \"trying to erase instruction with users.\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer <source>\r\n1.\tRunning pass \"function(slp-vectorizer)\" on module \"<source>\"\r\n2.\tRunning pass \"slp-vectorizer\" on function \"wombat\"\r\n #0 0x00000000050106b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x50106b8)\r\n #1 0x000000000500ddfc SignalHandler(int) Signals.cpp:0:0\r\n #2 0x0000737fffa42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x0000737fffa969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x0000737fffa42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x0000737fffa287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x0000737fffa2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x0000737fffa39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x00000000040b91cf void llvm::slpvectorizer::BoUpSLP::removeInstructionsAndOperands<llvm::Instruction>(llvm::ArrayRef<llvm::Instruction*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40b91cf)\r\n #9 0x000000000410b80a llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::MapVector<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>, llvm::DenseMap<llvm::Value*, unsigned int, llvm::DenseMapInfo<llvm::Value*, void>, llvm::detail::DenseMapPair<llvm::Value*, unsigned int>>, llvm::SmallVector<std::pair<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>>, 0u>> const&, llvm::SmallVectorImpl<std::pair<llvm::Value*, llvm::Value*>>&, llvm::Instruction*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x410b80a)\r\n#10 0x0000000004115bed (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&) SLPVectorizer.cpp:0:0\r\n#11 0x0000000004118321 llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4118321)\r\n#12 0x000000000411cb18 llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x411cb18)\r\n#13 0x00000000041212fa llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41212fa)\r\n#14 0x0000000004127719 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\r\n#15 0x00000000041283cb llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41283cb)\r\n#16 0x0000000002efda4e llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2efda4e)\r\n#17 0x0000000004e12948 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e12948)\r\n#18 0x0000000000e06f8e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe06f8e)\r\n#19 0x0000000004e1136e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e1136e)\r\n#20 0x0000000000e0679e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe0679e)\r\n#21 0x0000000004e10da0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e10da0)\r\n#22 0x00000000008fb642 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8fb642)\r\n#23 0x00000000008ee4cc optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8ee4cc)\r\n#24 0x0000737fffa29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#25 0x0000737fffa29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#26 0x00000000008e5f9e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8e5f9e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```",
"author": "TatyanaDoubts",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
155184
|
https://github.com/llvm/llvm-project/issues/155184
|
crash
|
d0246fe1e79c6ea06b6b72f66a71a96a3342aa42
| 2025-08-24T17:14:04 |
[
"llvm/test/Transforms/LICM"
] |
{
"fix_commit": "d1408667de830da8817c24cb9788da6caae551c7",
"components": [
"MemorySSAUpdater"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": [
[
411,
427
],
[
504,
514
]
],
"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": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": [
"MemorySSAUpdater::fixupDefs",
"MemorySSAUpdater::insertDef"
],
"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 d1408667de830da8817c24cb9788da6caae551c7
Author: Nikita Popov <npopov@redhat.com>
Date: Thu Sep 4 10:23:29 2025 +0200
[MemorySSA] Don't create phi nodes in fixupDefs() (#156021)
The general flow when inserting MemoryDefs is:
* Insert the def and set it's defining access (may insert phis)
* Insert IDF phis
* Update defining access for defs after the new one (fixupDefs)
* Rename uses if requested
fixupDefs() uses getPreviousDef() which can create new MemoryPHIs, but
for which we're not going to insert IDF phis, so the required dominance
property may not hold.
I believe this is a leftover from a time before the "Insert IDF phis"
step existed. Now that step should already ensure that all necessary
MemoryPhis have been inserted, and we only need to update them.
The fixupDefs() implementation was also returning after updating a
single access, which is not right.
Fixes https://github.com/llvm/llvm-project/issues/47875.
Fixes https://github.com/llvm/llvm-project/issues/117157.
Fixes https://github.com/llvm/llvm-project/issues/152998.
Fixes https://github.com/llvm/llvm-project/issues/155161.
Fixes https://github.com/llvm/llvm-project/issues/155184.
diff --git a/llvm/lib/Analysis/MemorySSAUpdater.cpp b/llvm/lib/Analysis/MemorySSAUpdater.cpp
index ecfecb03c375..bb3e679219ae 100644
--- a/llvm/lib/Analysis/MemorySSAUpdater.cpp
+++ b/llvm/lib/Analysis/MemorySSAUpdater.cpp
@@ -411,17 +411,11 @@ void MemorySSAUpdater::insertDef(MemoryDef *MD, bool RenameUses) {
FixupList.push_back(MD);
}
- // Remember the index where we stopped inserting new phis above, since the
- // fixupDefs call in the loop below may insert more, that are already minimal.
+ // Update defining access of following defs.
unsigned NewPhiIndexEnd = InsertedPHIs.size();
-
- while (!FixupList.empty()) {
- unsigned StartingPHISize = InsertedPHIs.size();
- fixupDefs(FixupList);
- FixupList.clear();
- // Put any new phis on the fixup list, and process them
- FixupList.append(InsertedPHIs.begin() + StartingPHISize, InsertedPHIs.end());
- }
+ fixupDefs(FixupList);
+ assert(NewPhiIndexEnd == InsertedPHIs.size() &&
+ "Should not insert new phis during fixupDefs()");
// Optimize potentially non-minimal phis added in this method.
unsigned NewPhiSize = NewPhiIndexEnd - NewPhiIndex;
@@ -504,11 +498,8 @@ void MemorySSAUpdater::fixupDefs(const SmallVectorImpl<WeakVH> &Vars) {
assert(MSSA->dominates(NewDef, FirstDef) &&
"Should have dominated the new access");
- // This may insert new phi nodes, because we are not guaranteed the
- // block we are processing has a single pred, and depending where the
- // store was inserted, it may require phi nodes below it.
- cast<MemoryDef>(FirstDef)->setDefiningAccess(getPreviousDef(FirstDef));
- return;
+ cast<MemoryDef>(FirstDef)->setDefiningAccess(NewDef);
+ continue;
}
// We didn't find a def, so we must continue.
for (const auto *S : successors(FixupBlock)) {
|
[
{
"file": "llvm/test/Transforms/LICM/pr117157.ll",
"commands": [
"opt -S -passes=licm -verify-memoryssa < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @test(ptr %p) {\n;\nentry:\n br label %loop0\n\nloop0: ; preds = %loop0.latch, %entry\n br label %loop1\n\nloop1: ; preds = %loop1, %loop0\n %dec10 = phi i64 [ 0, %loop0 ], [ 1, %loop1 ]\n store i64 %dec10, ptr %p\n br i1 false, label %loop1.exit, label %loop1\n\nloop1.exit: ; preds = %loop1\n switch i32 0, label %loop0.latch [\n i32 0, label %loop0.latch\n i32 2, label %loop3.preheader\n i32 1, label %loop2\n ]\n\nloop2: ; preds = %loop2.latch, %loop1.exit\n br i1 false, label %loop0.latch, label %loop3.preheader\n\nloop3.preheader: ; preds = %loop1.exit, %loop2\n br label %loop3\n\nloop3: ; preds = %loop3.preheader, %loop3\n switch i32 0, label %exit [\n i32 0, label %loop3\n i32 1, label %loop2.latch\n ]\n\nloop2.latch: ; preds = %loop3\n br label %loop2\n\nloop0.latch: ; preds = %loop2, %loop1.exit, %loop1.exit\n store i64 0, ptr %p\n br label %loop0\n\nexit: ; preds = %loop3\n store i64 1, ptr %p\n ret void\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "clang crashes at -O3 with \"-mllvm -enable-gvn-sink\" on x86_64-linux-gnu: Assertion `MSSA->dominates(NewDef, FirstDef) && \"Should have dominated the new access\"' failed",
"body": "Compiler Explorer: https://godbolt.org/z/fKdo8vGE8\n\nNote:\n- works: 20.1.0 and earlier\n- fails: trunk\n\n```\n[504] % clangtk -v\nclang version 22.0.0git (https://github.com/llvm/llvm-project.git 285fd29f941c031d44c6ecd63efdac795c67adc4)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /local/home/suz/suz-local/software/local/clang-trunk/bin\nBuild config: +assertions\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12\nCandidate multilib: .;@m64\nCandidate multilib: 32;@m32\nCandidate multilib: x32;@mx32\nSelected multilib: .;@m64\nFound CUDA installation: /usr/local/cuda, version 12.1\n[505] % \n[505] % clangtk -O3 small.c; ./a.out\n[506] % clangtk -O3 -mllvm -enable-gvn-sink small.c\nclang-22: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Analysis/MemorySSAUpdater.cpp:504: void llvm::MemorySSAUpdater::fixupDefs(const llvm::SmallVectorImpl<llvm::WeakVH>&): Assertion `MSSA->dominates(NewDef, FirstDef) && \"Should have dominated the new access\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\nStack dump:\n0.\tProgram arguments: /local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22 -cc1 -triple x86_64-unknown-linux-gnu -O3 -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/bug178 -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/bug178 -resource-dir /local/home/suz/suz-local/software/local/clang-trunk/lib/clang/22 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/home/suz/suz-local/software/local/clang-trunk/lib/clang/22/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -ferror-limit 19 -fmessage-length=130 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -mllvm -enable-gvn-sink -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-3fcc24.o -x c small.c\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>,argpromotion,openmp-opt-cgscc,function<eager-inv;no-rerun>(sroa<modify-cfg>,early-cse<memssa>,gvn-sink,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>,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<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 \"small.c\"\n4.\tRunning pass \"cgscc(devirt<4>(inline,function-attrs<skip-non-recursive-function-attrs>,argpromotion,openmp-opt-cgscc,function<eager-inv;no-rerun>(sroa<modify-cfg>,early-cse<memssa>,gvn-sink,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>,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<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 \"small.c\"\n5.\tRunning pass \"loop-mssa(loop-instsimplify,loop-simplifycfg,licm<no-allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-unswitch<nontrivial;trivial>)\" on function \"main\"\n #0 0x0000564e70634000 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4291000)\n #1 0x0000564e70630caf llvm::sys::RunSignalHandlers() (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x428dcaf)\n #2 0x0000564e70630e02 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #3 0x00007f82700fb520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #4 0x00007f827014f9fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #5 0x00007f827014f9fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #6 0x00007f827014f9fc pthread_kill ./nptl/pthread_kill.c:89:10\n #7 0x00007f82700fb476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x00007f82700e17f3 abort ./stdlib/abort.c:81:7\n #9 0x00007f82700e171b _nl_load_domain ./intl/loadmsgcat.c:1177:9\n#10 0x00007f82700f2e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n#11 0x0000564e6f527574 llvm::MemorySSAUpdater::fixupDefs(llvm::SmallVectorImpl<llvm::WeakVH> const&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3184574)\n#12 0x0000564e6f52774f llvm::MemorySSAUpdater::insertDef(llvm::MemoryDef*, bool) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x318474f)\n#13 0x0000564e704292cf (anonymous namespace)::LoopPromoter::doExtraRewritesBeforeFinalDeletion() LICM.cpp:0:0\n#14 0x0000564e707bf787 llvm::LoadAndStorePromoter::run(llvm::SmallVectorImpl<llvm::Instruction*> const&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x441c787)\n#15 0x0000564e70425be8 llvm::promoteLoopAccessesToScalars(llvm::SmallSetVector<llvm::Value*, 8u> const&, llvm::SmallVectorImpl<llvm::BasicBlock*>&, llvm::SmallVectorImpl<llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>, false, false>>&, llvm::SmallVectorImpl<llvm::MemoryAccess*>&, llvm::PredIteratorCache&, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::TargetLibraryInfo const*, llvm::TargetTransformInfo*, llvm::Loop*, llvm::MemorySSAUpdater&, llvm::ICFLoopSafetyInfo*, llvm::OptimizationRemarkEmitter*, bool, bool) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4082be8)\n#16 0x0000564e70433943 (anonymous namespace)::LoopInvariantCodeMotion::runOnLoop(llvm::Loop*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::TargetLibraryInfo*, llvm::TargetTransformInfo*, llvm::ScalarEvolution*, llvm::MemorySSA*, llvm::OptimizationRemarkEmitter*, bool) (.part.0) LICM.cpp:0:0\n#17 0x0000564e70435773 llvm::LICMPass::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4092773)\n#18 0x0000564e6d6b0b46 llvm::detail::PassModel<llvm::Loop, llvm::LICMPass, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x130db46)\n#19 0x0000564e7043b4ef 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&) (.isra.0) LoopPassManager.cpp:0:0\n#20 0x0000564e7043cae0 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&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4099ae0)\n#21 0x0000564e7043cecc 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&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4099ecc)\n#22 0x0000564e7043dfa1 llvm::FunctionToLoopPassAdaptor::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x409afa1)\n#23 0x0000564e6d6b09f6 llvm::detail::PassModel<llvm::Function, llvm::FunctionToLoopPassAdaptor, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x130d9f6)\n#24 0x0000564e6ff6d2d2 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3bca2d2)\n#25 0x0000564e6d6b0c96 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x130dc96)\n#26 0x0000564e6f3b5584 llvm::CGSCCToFunctionPassAdaptor::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3012584)\n#27 0x0000564e6d6adf66 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&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x130af66)\n#28 0x0000564e6f3acb5c 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&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3009b5c)\n#29 0x0000564e716eaeb6 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&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5347eb6)\n#30 0x0000564e6f3b682d llvm::DevirtSCCRepeatedPass::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x301382d)\n#31 0x0000564e716eaf06 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&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5347f06)\n#32 0x0000564e6f3b14a8 llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x300e4a8)\n#33 0x0000564e6d6adf16 llvm::detail::PassModel<llvm::Module, llvm::ModuleToPostOrderCGSCCPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x130af16)\n#34 0x0000564e6ff6b575 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3bc8575)\n#35 0x0000564e71e16128 llvm::ModuleInlinerWrapperPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5a73128)\n#36 0x0000564e716ea556 llvm::detail::PassModel<llvm::Module, llvm::ModuleInlinerWrapperPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5347556)\n#37 0x0000564e6ff6b575 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3bc8575)\n#38 0x0000564e708dbe53 (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#39 0x0000564e708dff83 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x453cf83)\n#40 0x0000564e70fa5e3f clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4c02e3f)\n#41 0x0000564e72a1a32c clang::ParseAST(clang::Sema&, bool, bool) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x667732c)\n#42 0x0000564e712c6869 clang::FrontendAction::Execute() (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4f23869)\n#43 0x0000564e71241dd5 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4e9edd5)\n#44 0x0000564e713b8248 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5015248)\n#45 0x0000564e6d225bd8 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xe82bd8)\n#46 0x0000564e6d21c1da ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#47 0x0000564e6d220c94 clang_main(int, char**, llvm::ToolContext const&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xe7dc94)\n#48 0x0000564e6d0ec14b main (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xd4914b)\n#49 0x00007f82700e2d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\n#50 0x00007f82700e2e40 call_init ./csu/../csu/libc-start.c:128:20\n#51 0x00007f82700e2e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\n#52 0x0000564e6d21b905 _start (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xe78905)\nclangtk: error: unable to execute command: Aborted\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\nclang version 22.0.0git (https://github.com/llvm/llvm-project.git 285fd29f941c031d44c6ecd63efdac795c67adc4)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /local/home/suz/suz-local/software/local/clang-trunk/bin\nBuild config: +assertions\nclangtk: note: diagnostic msg: \n********************\n\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\nPreprocessed source(s) and associated run script(s) are located at:\nclangtk: note: diagnostic msg: /tmp/small-03afae.c\nclangtk: note: diagnostic msg: /tmp/small-03afae.sh\nclangtk: note: diagnostic msg: \n\n********************\n[507] % \n[507] % cat small.c\nint a, b, d, g, ab, ae, af, h, i, j, l, n = 1;\nint aa(int u[]) {\n for (int c = 0; c < 3; c++) {\n for (int e = 0; e < 11; e++)\n if (u[c + e]) {\n n = 0;\n break;\n }\n if (n)\n return a;\n }\n __builtin_abort();\n}\nvoid f(int u, int x, int y) {\n int v, o = 0, p, q;\n p = u;\n if (j)\n goto r;\n do {\n v = u = x = 0;\n if (o)\n break;\n r:\n o = x;\n } while (j);\n q = 0;\n int t[] = {u, h, x, i, q, v, j, l, y, o, p};\n aa(t);\n}\nint main() {\n ab = 1;\n for (; ab; ab = 0)\n for (; ae; ae++)\n while (1) {\n int m = 0;\n goto w;\n ac:\n m = 3;\n ad:\n if (1 % m)\n goto ac;\n w:\n if (g)\n goto ad;\n if (d)\n goto ac;\n int k = b;\n while (1)\n if (k)\n break;\n f(af, 1, af - 1);\n break;\n }\n return 0;\n}\n```",
"author": "zhendongsu",
"labels": [
"loopoptim",
"crash"
],
"comments": [
{
"author": "nikic",
"body": "Likely all the same issue: https://github.com/llvm/llvm-project/issues/47875 https://github.com/llvm/llvm-project/issues/117157 https://github.com/llvm/llvm-project/issues/152998 https://github.com/llvm/llvm-project/issues/155161"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
88297
|
https://github.com/llvm/llvm-project/issues/88297
|
crash
|
9ec6c5d26321f5d32d97218f850ae7cafda32b2e
| 2024-04-10T16:52:41 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "34777c238b117b52dd41a9d12e8b54fb83677a12",
"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": [
[
361,
368
],
[
376,
382
]
],
"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": 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 34777c238b117b52dd41a9d12e8b54fb83677a12
Author: Florian Hahn <flo@fhahn.com>
Date: Tue Apr 16 21:24:24 2024 +0100
[VPlan] Don't mark VPBlendRecipe as phi-like.
VPBlendRecipes don't get lowered to phis and usually do not appear at
the beginning of blocks, due to their masks appearing before them.
This effectively relaxes an over-eager verifier message.
Fixes https://github.com/llvm/llvm-project/issues/88297.
Fixes https://github.com/llvm/llvm-project/issues/88804.
diff --git a/llvm/lib/Transforms/Vectorize/VPlanValue.h b/llvm/lib/Transforms/Vectorize/VPlanValue.h
index da3a768552fc..3f8d4f4fe7d6 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanValue.h
+++ b/llvm/lib/Transforms/Vectorize/VPlanValue.h
@@ -361,8 +361,8 @@ public:
VPWidenMemoryInstructionSC,
VPWidenSC,
VPWidenSelectSC,
- // START: Phi-like recipes. Need to be kept together.
VPBlendSC,
+ // START: Phi-like recipes. Need to be kept together.
VPWidenPHISC,
VPPredInstPHISC,
// START: SubclassID for recipes that inherit VPHeaderPHIRecipe.
@@ -376,7 +376,7 @@ public:
VPReductionPHISC,
// END: SubclassID for recipes that inherit VPHeaderPHIRecipe
// END: Phi-like recipes
- VPFirstPHISC = VPBlendSC,
+ VPFirstPHISC = VPWidenPHISC,
VPFirstHeaderPHISC = VPCanonicalIVPHISC,
VPLastHeaderPHISC = VPReductionPHISC,
VPLastPHISC = VPReductionPHISC,
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/blend-in-header.ll",
"commands": [
"opt -p loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -S %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\n\n; Test with blend recipe in header VPBB, from\n; https://github.com/llvm/llvm-project/issues/88297.\ndefine i64 @pr88297() {\n;\nentry:\n br label %loop.header\n\nloop.header:\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]\n br i1 false, label %loop.latch, label %then\n\nthen:\n br label %loop.latch\n\nloop.latch:\n %r = phi i64 [ 1, %then ], [ 0, %loop.header ]\n %iv.next = add i32 %iv, 1\n %icmp = icmp sgt i32 %iv, 1000\n br i1 %icmp, label %exit, label %loop.header\n\nexit:\n %r.lcssa = phi i64 [ %r, %loop.latch ]\n ret i64 %r.lcssa\n}\n\ndefine i64 @pr88297_incoming_ops_reordered() {\n;\nentry:\n br label %loop.header\n\nloop.header:\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]\n br i1 false, label %loop.latch, label %then\n\nthen:\n br label %loop.latch\n\nloop.latch:\n %r = phi i64 [ 0, %loop.header ], [ 1, %then ]\n %iv.next = add i32 %iv, 1\n %icmp = icmp sgt i32 %iv, 1000\n br i1 %icmp, label %exit, label %loop.header\n\nexit:\n %r.lcssa = phi i64 [ %r, %loop.latch ]\n ret i64 %r.lcssa\n}\n\ndefine i64 @invar_cond(i1 %c) {\n;\nentry:\n br label %loop.header\n\nloop.header:\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]\n br i1 %c, label %loop.latch, label %then\n\nthen:\n br label %loop.latch\n\nloop.latch:\n %r = phi i64 [ 1, %then ], [ 0, %loop.header ]\n %iv.next = add i32 %iv, 1\n %icmp = icmp sgt i32 %iv, 1000\n br i1 %icmp, label %exit, label %loop.header\n\nexit:\n %r.lcssa = phi i64 [ %r, %loop.latch ]\n ret i64 %r.lcssa\n}\n\ndefine i64 @invar_cond_incoming_ops_reordered(i1 %c) {\n;\nentry:\n br label %loop.header\n\nloop.header:\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]\n br i1 %c, label %loop.latch, label %then\n\nthen:\n br label %loop.latch\n\nloop.latch:\n %r = phi i64 [ 0, %loop.header ], [ 1, %then ]\n %iv.next = add i32 %iv, 1\n %icmp = icmp sgt i32 %iv, 1000\n br i1 %icmp, label %exit, label %loop.header\n\nexit:\n %r.lcssa = phi i64 [ %r, %loop.latch ]\n ret i64 %r.lcssa\n}\n;.\n;.",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Assertion `verifyVPlanIsValid(*Plan) && \"VPlan is invalid\"' failed",
"body": "The following test fails when run opt 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 = %bb2, %bb\r\n %phi = phi i32 [ %add, %bb2 ], [ 0, %bb ]\r\n br i1 false, label %bb2, label %bb4\r\n\r\nbb2: ; preds = %bb4, %bb1\r\n %phi3 = phi i64 [ 1, %bb4 ], [ 0, %bb1 ]\r\n %add = add i32 %phi, 1\r\n %icmp = icmp sgt i32 %phi, 0\r\n br i1 %icmp, label %bb5, label %bb1\r\n\r\nbb4: ; preds = %bb1\r\n br label %bb2\r\n\r\nbb5: ; preds = %bb2\r\n %phi6 = phi i64 [ %phi3, %bb2 ]\r\n ret void\r\n}\r\n```\r\nReproducer https://godbolt.org/z/9YW1o7qo6\r\nStack dump:\r\n```\r\nFound non-header PHI recipe in header VPBB: BLEND ir<%phi3> = ir<1> ir<0>/ir<false>\r\nopt: /root/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:8555: void llvm::LoopVectorizationPlanner::buildVPlansWithVPRecipes(llvm::ElementCount, llvm::ElementCount): Assertion `verifyVPlanIsValid(*Plan) && \"VPlan is invalid\"' 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\n #0 0x0000000004d05ee8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d05ee8)\r\n #1 0x0000000004d0363c SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007f7623242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x00007f76232969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x00007f7623242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x00007f76232287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00007f762322871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x00007f7623239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x0000000003de70b8 llvm::LoopVectorizationPlanner::buildVPlansWithVPRecipes(llvm::ElementCount, llvm::ElementCount) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3de70b8)\r\n #9 0x0000000003dee731 llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3dee731)\r\n#10 0x0000000003df18fe llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3df18fe)\r\n#11 0x0000000003df4c6d llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3df4c6d)\r\n#12 0x0000000003df5e7b llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3df5e7b)\r\n#13 0x0000000002d67f0e 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+0x2d67f0e)\r\n#14 0x0000000000db3554 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+0xdb3554)\r\n#15 0x0000000004b1663e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4b1663e)\r\n#16 0x0000000000d97cce 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+0xd97cce)\r\n#17 0x0000000004b1454c llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4b1454c)\r\n#18 0x00000000008c74f2 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+0x8c74f2)\r\n#19 0x00000000008bad45 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8bad45)\r\n#20 0x00007f7623229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#21 0x00007f7623229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#22 0x00000000008b1aee _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8b1aee)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```",
"author": "TatyanaDoubts",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
| null |
81561
|
https://github.com/llvm/llvm-project/issues/81561
|
crash
|
e79ad7bb94611666a23764459098574bc0394d56
| 2024-02-13T01:36:19 |
[
"llvm/test/DebugInfo/Generic"
] |
{
"fix_commit": "97088b2ab2184ad4bd64f59fba0b92b70468b10d",
"components": [
"ValueMapper"
],
"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": [
[
552,
557
]
],
"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": 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": [
"Mapper::remapDPValue"
],
"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 97088b2ab2184ad4bd64f59fba0b92b70468b10d
Author: Orlando Cazalet-Hyams <orlando.hyams@sony.com>
Date: Tue Feb 13 11:35:28 2024 +0000
[RemoveDIs][ValueMapper] Remap DIAssignIDs in DPValues (#81595)
Fix crash raised in comments for 5c9f7682b090124d9a8b69f92d3f7c269dca25fc
diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp
index a8ae3ee3b251..93a4c829df06 100644
--- a/llvm/lib/Transforms/Utils/ValueMapper.cpp
+++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp
@@ -552,6 +552,7 @@ void Mapper::remapDPValue(DPValue &V) {
V.setKillAddress();
else if (NewAddr)
V.setAddress(NewAddr);
+ V.setAssignId(cast<DIAssignID>(mapMetadata(V.getAssignID())));
}
// Find Value operands and remap those.
|
[
{
"file": "llvm/test/DebugInfo/Generic/ipsccp-remap-assign-id.ll",
"commands": [
"opt -passes=ipsccp %s -S -o -",
"opt --try-experimental-debuginfo-iterators -passes=ipsccp %s -S -o -"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n;; Check the dbg.assign DIAssignID operand gets remapped after cloning.\n\n;\n\n; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare void @llvm.dbg.declare(metadata, metadata, metadata)\n\ndefine void @inv_txfm_add_dct_dct_4x4_c() {\nentry:\n call void @inv_txfm_add_c(ptr @dav1d_inv_dct4_1d_c)\n ret void\n}\n\ndeclare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg)\n\n; Function Attrs: noinline\ndefine void @inv_txfm_add_c(ptr %first_1d_fn) #2 {\nentry:\n %tmp = alloca [4096 x i32], i32 0, align 16, !DIAssignID !5\n tail call void @llvm.dbg.assign(metadata i1 undef, metadata !6, metadata !DIExpression(), metadata !5, metadata ptr %tmp, metadata !DIExpression()), !dbg !16\n call void @llvm.memset.p0.i64(ptr %tmp, i8 0, i64 0, i1 false), !DIAssignID !17\n call void %first_1d_fn(ptr null, i64 0, i32 0, i32 0)\n ret void\n}\n\ndeclare void @dav1d_inv_dct4_1d_c(ptr, i64, i32, i32)\n\ndeclare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)\n\nattributes #2 = { noinline }\n\n!llvm.dbg.cu = !{!0}\n!llvm.module.flags = !{!3, !4}\n\n!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2, splitDebugInlining: false, nameTableKind: GNU)\n!1 = !DIFile(filename: \"itx_tmpl.c\", directory: \".\")\n!2 = !{}\n!3 = !{i32 2, !\"Debug Info Version\", i32 3}\n!4 = !{i32 7, !\"debug-info-assignment-tracking\", i1 true}\n!5 = distinct !DIAssignID()\n!6 = !DILocalVariable(name: \"tmp\", scope: !7, file: !1, line: 78, type: !10)\n!7 = distinct !DISubprogram(name: \"inv_txfm_add_c\", scope: !1, file: !1, line: 41, type: !8, scopeLine: 45, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)\n!8 = distinct !DISubroutineType(types: !9)\n!9 = !{null}\n!10 = !DICompositeType(tag: DW_TAG_array_type, baseType: !11, size: 131072, elements: !2)\n!11 = !DIDerivedType(tag: DW_TAG_typedef, name: \"int32_t\", file: !12, line: 26, baseType: !13)\n!12 = !DIFile(filename: \"stdint-intn.h\", directory: \".\")\n!13 = !DIDerivedType(tag: DW_TAG_typedef, name: \"__int32_t\", file: !14, line: 41, baseType: !15)\n!14 = !DIFile(filename: \"types.h\", directory: \".\")\n!15 = !DIBasicType(name: \"int\", size: 32, encoding: DW_ATE_signed)\n!16 = !DILocation(line: 0, scope: !7)\n!17 = distinct !DIAssignID()",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Clang frontend command failed to build lib/vsprintf.c in Linux kernel",
"body": "```\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: clang -Wp,-MMD,lib/.vsprintf.o.d -nostdinc -I./arch/x86/include -I./arch/x86/include/generated -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ --target=x86_64-linux-gnu -fintegrated-as -Werror=unknown-warning-option -Werror=ignored-optimization-argument -Werror=option-ignored -Werror=unused-command-line-argument -fmacro-prefix-map=./= -std=gnu11 -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=none -m64 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mstack-alignment=8 -mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -Wno-sign-compare -fno-asynchronous-unwind-tables -mretpoline-external-thunk -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -mharden-sls=all -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fstack-protector-strong -fno-omit-frame-pointer -fno-optimize-sibling-calls -ftrivial-auto-var-init=zero -fno-stack-clash-protection -fzero-call-used-regs=used-gpr -DCC_USING_NOP_MCOUNT -DCC_USING_FENTRY -falign-functions=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -Wall -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=1024 -Wno-gnu -Wno-unused-but-set-variable -Wno-unused-const-variable -Wvla -Wno-pointer-sign -Wcast-function-type -Wimplicit-fallthrough -Werror=date-time -Werror=incompatible-pointer-types -Wenum-conversion -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-format-overflow -Wno-format-truncation -Wno-pointer-to-enum-cast -Wno-tautological-constant-out-of-range-compare -Wno-unaligned-access -Wno-cast-function-type-strict -Wno-missing-field-initializers -Wno-type-limits -Wno-shift-negative-value -Wno-initializer-overrides -Wno-sign-compare -g -gdwarf-5 -fsanitize=array-bounds -fsanitize=shift -fsanitize=bool -fsanitize=enum -DKBUILD_MODFILE=\\\"lib/vsprintf\\\" -DKBUILD_BASENAME=\\\"vsprintf\\\" -DKBUILD_MODNAME=\\\"vsprintf\\\" -D__KBUILD_MODNAME=kmod_vsprintf -c -o lib/vsprintf.o lib/vsprintf.c\r\n1.\t<eof> parser at end of file\r\n2.\tCode generation\r\n3.\tRunning pass 'Function Pass Manager' on module 'lib/vsprintf.c'.\r\n4.\tRunning pass 'Assignment Tracking Analysis' on function '@ip4_string'\r\n #0 0x000055fc39a6be88 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/eve/Downloads/llvm-project/build2/bin/clang-19+0x2d82e88)\r\n #1 0x000055fc39a69c6e llvm::sys::RunSignalHandlers() (/home/eve/Downloads/llvm-project/build2/bin/clang-19+0x2d80c6e)\r\n #2 0x000055fc399e7729 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0\r\n #3 0x00007f7639a42990 (/lib/x86_64-linux-gnu/libc.so.6+0x42990)\r\n #4 0x000055fc39484775 (anonymous namespace)::AssignmentTrackingLowering::run(FunctionVarLocsBuilder*) AssignmentTrackingAnalysis.cpp:0:0\r\n #5 0x000055fc3947f3fe analyzeFunction(llvm::Function&, llvm::DataLayout const&, FunctionVarLocsBuilder*) AssignmentTrackingAnalysis.cpp:0:0\r\n #6 0x000055fc3947fdcd llvm::AssignmentTrackingAnalysis::runOnFunction(llvm::Function&) (/home/eve/Downloads/llvm-project/build2/bin/clang-19+0x2796dcd)\r\n #7 0x000055fc395bab96 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/eve/Downloads/llvm-project/build2/bin/clang-19+0x28d1b96)\r\n #8 0x000055fc395c1a23 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/eve/Downloads/llvm-project/build2/bin/clang-19+0x28d8a23)\r\n #9 0x000055fc395bb807 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/eve/Downloads/llvm-project/build2/bin/clang-19+0x28d2807)\r\n#10 0x000055fc39c161b6 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/home/eve/Downloads/llvm-project/build2/bin/clang-19+0x2f2d1b6)\r\n#11 0x000055fc3a09fed5 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/eve/Downloads/llvm-project/build2/bin/clang-19+0x33b6ed5)\r\n#12 0x000055fc3b7248f6 clang::ParseAST(clang::Sema&, bool, bool) (/home/eve/Downloads/llvm-project/build2/bin/clang-19+0x4a3b8f6)\r\n#13 0x000055fc3a316d86 clang::FrontendAction::Execute() (/home/eve/Downloads/llvm-project/build2/bin/clang-19+0x362dd86)\r\n#14 0x000055fc3a28c654 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/eve/Downloads/llvm-project/build2/bin/clang-19+0x35a3654)\r\n#15 0x000055fc3a3d293e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/eve/Downloads/llvm-project/build2/bin/clang-19+0x36e993e)\r\n#16 0x000055fc37b20c3c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/eve/Downloads/llvm-project/build2/bin/clang-19+0xe37c3c)\r\n#17 0x000055fc37b1dc71 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#18 0x000055fc3a0e9eb9 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::$_0>(long) Job.cpp:0:0\r\n#19 0x000055fc399e750c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/eve/Downloads/llvm-project/build2/bin/clang-19+0x2cfe50c)\r\n#20 0x000055fc3a0e9906 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/home/eve/Downloads/llvm-project/build2/bin/clang-19+0x3400906)\r\n#21 0x000055fc3a0abd57 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/home/eve/Downloads/llvm-project/build2/bin/clang-19+0x33c2d57)\r\n#22 0x000055fc3a0ac1fe clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/home/eve/Downloads/llvm-project/build2/bin/clang-19+0x33c31fe)\r\n#23 0x000055fc3a0ca5df clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/home/eve/Downloads/llvm-project/build2/bin/clang-19+0x33e15df)\r\n#24 0x000055fc37b1d338 clang_main(int, char**, llvm::ToolContext const&) (/home/eve/Downloads/llvm-project/build2/bin/clang-19+0xe34338)\r\n#25 0x000055fc37b2b8d7 main (/home/eve/Downloads/llvm-project/build2/bin/clang-19+0xe428d7)\r\n#26 0x00007f7639a28150 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3\r\n#27 0x00007f7639a28209 call_init ./csu/../csu/libc-start.c:128:20\r\n#28 0x00007f7639a28209 __libc_start_main ./csu/../csu/libc-start.c:347:5\r\n#29 0x000055fc37b1a4b5 _start (/home/eve/Downloads/llvm-project/build2/bin/clang-19+0xe314b5)\r\nclang: error: clang frontend command failed with exit code 139 (use -v to see invocation)\r\nclang version 19.0.0git (https://github.com/llvm/llvm-project.git 3bdc4c702dfdd1f2fb513943f034d49bb79ded29)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /home/eve/Downloads/llvm-project/build2/bin\r\nclang: note: diagnostic msg: \r\n********************\r\n\r\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\r\nPreprocessed source(s) and associated run script(s) are located at:\r\nclang: note: diagnostic msg: /tmp/vsprintf-e230c3.c\r\nclang: note: diagnostic msg: /tmp/vsprintf-e230c3.sh\r\nclang: note: diagnostic msg: \r\n\r\n********************\r\n\r\n```\r\n[vsprintf-e230c3.zip](https://github.com/llvm/llvm-project/files/14254556/vsprintf-e230c3.zip)\r\n\r\nThis issue occurs at commit:\r\n```\r\ncommit 3bdc4c702dfdd1f2fb513943f034d49bb79ded29 (HEAD -> main, origin/main, origin/HEAD)\r\nAuthor: Kevin Frei <kevinfrei@users.noreply.github.com>\r\nDate: Mon Feb 12 16:57:02 2024 -0800\r\n```\r\n\r\nThis issue does not occur at commit:\r\n```\r\ncommit 63b414e4977d6e19f05947c88f57cd127fa328e3\r\nAuthor: Vlad Serebrennikov <serebrennikov.vladislav@gmail.com>\r\nDate: Sun Feb 11 15:01:18 2024 +0300\r\n```\r\nEdit: this issue also occurs at commit:\r\n```\r\ncommit 13d60ce2f262ef9055389908b63824e53b3054a1 (HEAD)\r\nAuthor: Amir Ayupov <aaupov@fb.com>\r\nDate: Mon Feb 12 14:51:15 2024 -0800\r\n```\r\nThis issue does not occur at commit:\r\n```\r\ncommit f5fd0deb2371d0bae3bef2563f50e005a140fc6d (HEAD)\r\nAuthor: Joseph Huber <huberjn@outlook.com>\r\nDate: Mon Feb 12 08:14:54 2024 -0600\r\n```",
"author": "eve2023",
"labels": [
"crash",
"llvm:transforms"
],
"comments": [
{
"author": "ms178",
"body": "CC'ing @nathanchance for awareness."
},
{
"author": "nathanchance",
"body": "Caused by 5c9f7682b090124d9a8b69f92d3f7c269dca25fc, which was reverted in bc66e0cf9feb8f3c38fa2e33850b6c6e5477fb21 and forward fixed by 97088b2ab2184ad4bd64f59fba0b92b70468b10d. I can confirm that there is no crash at 5e3c7e3aa48356a62a4b70d5d9d3e4ddd055a390."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
142462
|
https://github.com/llvm/llvm-project/issues/142462
|
crash
|
4c6449044a943441adf160cb77010c855dcee73c
| 2025-06-02T19:36:30 |
[
"llvm/test/Transforms/EarlyCSE"
] |
{
"fix_commit": "9a0197c3a443caf275a9b1b86669b398ea615c9f",
"components": [
"EarlyCSE"
],
"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": [
[
400,
406
]
],
"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": 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": [
"isEqualImpl"
],
"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 9a0197c3a443caf275a9b1b86669b398ea615c9f
Author: Nikita Popov <npopov@redhat.com>
Date: Wed Jun 4 09:04:27 2025 +0200
[EarlyCSE] Check attributes for commutative intrinsics (#142610)
Commutative intrinsics go through a separate code path, which did not
check for attribute compatibility, resulting in a later assertion
failure.
Fixes https://github.com/llvm/llvm-project/issues/142462.
diff --git a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
index 09cb2f4cb010..5c62a2cf526e 100644
--- a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
+++ b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
@@ -400,7 +400,9 @@ static bool isEqualImpl(SimpleValue LHS, SimpleValue RHS) {
return LII->getArgOperand(0) == RII->getArgOperand(1) &&
LII->getArgOperand(1) == RII->getArgOperand(0) &&
std::equal(LII->arg_begin() + 2, LII->arg_end(),
- RII->arg_begin() + 2, RII->arg_end());
+ RII->arg_begin() + 2, RII->arg_end()) &&
+ LII->hasSameSpecialState(RII, /*IgnoreAlignment=*/false,
+ /*IntersectAttrs=*/true);
}
// See comment above in `getHashValue()`.
|
[
{
"file": "llvm/test/Transforms/EarlyCSE/replace-calls-def-attrs.ll",
"commands": [
"opt -S -passes=early-cse < %s"
],
"tests": [
{
"test_name": "same_parent_combine_diff_attrs_needs_intersect2",
"test_body": "declare ptr @baz.ptr(i8, i8)\n\ndeclare i8 @buz.ptr(ptr, ptr)\n\ndefine i8 @same_parent_combine_diff_attrs_needs_intersect2(i8 %x, i8 %y) {\n %c1 = call nonnull ptr @baz.ptr(i8 noundef %x, i8 noundef %y) #0\n %c0 = call ptr @baz.ptr(i8 %x, i8 noundef %y) #0\n %r = call i8 @buz.ptr(ptr %c0, ptr %c1)\n ret i8 %r\n}\n\nattributes #0 = { memory(read) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "diff_parent_combine_diff_attrs_todo",
"test_body": "declare i8 @baz(i8, i8)\n\ndeclare i8 @buz(i8, i8)\n\ndefine i8 @diff_parent_combine_diff_attrs_todo(i1 %c, i8 %x, i8 %y) {\n %c1 = call i8 @baz(i8 %x, i8 noundef %y) #0\n br i1 %c, label %T, label %F\n\nT: ; preds = %0\n %c0 = call i8 @baz(i8 noundef %x, i8 noundef %y) #1\n %r = call i8 @buz(i8 %c0, i8 %c1)\n ret i8 %r\n\nF: ; preds = %0\n %r2 = add i8 %c1, 4\n ret i8 %r2\n}\n\nattributes #0 = { memory(none) }\nattributes #1 = { noinline optnone memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "same_parent_combine_diff_attrs",
"test_body": "declare i8 @baz(i8, i8)\n\ndeclare i8 @buz(i8, i8)\n\ndefine i8 @same_parent_combine_diff_attrs(i8 %x, i8 %y) {\n %c1 = call i8 @baz(i8 noundef %x, i8 noundef %y) #0\n %c0 = call i8 @baz(i8 %x, i8 noundef %y) #0\n %r = call i8 @buz(i8 %c0, i8 %c1)\n ret i8 %r\n}\n\nattributes #0 = { memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "same_parent_combine_diff_attrs_needs_intersect",
"test_body": "declare ptr @baz.ptr(i8, i8)\n\ndeclare i8 @buz.ptr(ptr, ptr)\n\ndefine i8 @same_parent_combine_diff_attrs_needs_intersect(i8 %x, i8 %y) {\n %c1 = call nonnull ptr @baz.ptr(i8 noundef %x, i8 noundef %y) #0\n %c0 = call ptr @baz.ptr(i8 %x, i8 noundef %y) #0\n %r = call i8 @buz.ptr(ptr %c0, ptr %c1)\n ret i8 %r\n}\n\nattributes #0 = { memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "diff_parent_combine_diff_attrs",
"test_body": "declare i8 @baz(i8, i8)\n\ndeclare i8 @buz(i8, i8)\n\ndefine i8 @diff_parent_combine_diff_attrs(i1 %c, i8 %x, i8 %y) {\n %c1 = call i8 @baz(i8 %x, i8 noundef %y) #0\n br i1 %c, label %T, label %F\n\nT: ; preds = %0\n %c0 = call i8 @baz(i8 noundef %x, i8 noundef %y) #1\n %r = call i8 @buz(i8 %c0, i8 %c1)\n ret i8 %r\n\nF: ; preds = %0\n %r2 = add i8 %c1, 4\n ret i8 %r2\n}\n\nattributes #0 = { memory(none) }\nattributes #1 = { memory(read) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "same_parent_combine_diff_attrs_fail_side_effects",
"test_body": "declare i8 @baz(i8, i8)\n\ndeclare i8 @buz(i8, i8)\n\ndefine i8 @same_parent_combine_diff_attrs_fail_side_effects(i8 %x, i8 %y) {\n %c1 = call i8 @baz(i8 noundef %x, i8 noundef %y)\n %c0 = call i8 @baz(i8 %x, i8 noundef %y)\n %r = call i8 @buz(i8 %c0, i8 %c1)\n ret i8 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "same_parent_combine_diff_attrs_todo",
"test_body": "declare i8 @baz(i8, i8)\n\ndeclare i8 @buz(i8, i8)\n\ndefine i8 @same_parent_combine_diff_attrs_todo(i8 %x, i8 %y) {\n %c1 = call i8 @baz(i8 %x, i8 noundef %y) #0\n %c0 = call i8 @baz(i8 noundef %x, i8 noundef %y) #1\n %r = call i8 @buz(i8 %c0, i8 %c1)\n ret i8 %r\n}\n\nattributes #0 = { memory(none) }\nattributes #1 = { alwaysinline memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "same_parent_combine_diff_attrs_fmf2",
"test_body": "declare float @baz.fp(float, float)\n\ndeclare i8 @buz.fp(float, float)\n\ndefine i8 @same_parent_combine_diff_attrs_fmf2(float %x, float %y) {\n %c1 = call nnan float @baz.fp(float noundef %x, float noundef %y) #0\n %c0 = call nnan nsz float @baz.fp(float %x, float noundef %y) #0\n %r = call i8 @buz.fp(float %c0, float %c1)\n ret i8 %r\n}\n\nattributes #0 = { memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "same_parent_combine_diff_attrs_fmf",
"test_body": "declare float @baz.fp(float, float)\n\ndeclare i8 @buz.fp(float, float)\n\ndefine i8 @same_parent_combine_diff_attrs_fmf(float %x, float %y) {\n %c1 = call nnan nsz float @baz.fp(float noundef %x, float noundef %y) #0\n %c0 = call nnan float @baz.fp(float %x, float noundef %y) #0\n %r = call i8 @buz.fp(float %c0, float %c1)\n ret i8 %r\n}\n\nattributes #0 = { memory(read) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "commutative_intrinsic_intersection_failure",
"test_body": "define i32 @commutative_intrinsic_intersection_failure(i32 %arg, i32 %arg1) {\n %call = call i32 @llvm.smin.i32(i32 %arg, i32 %arg1) #1\n %call2 = call i32 @llvm.smin.i32(i32 %arg1, i32 %arg)\n %or = or i32 %call2, %call\n ret i32 %or\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) }\nattributes #1 = { strictfp }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "diff_parent_combine_diff_attrs_fail",
"test_body": "declare i8 @baz(i8, i8)\n\ndeclare i8 @buz(i8, i8)\n\ndefine i8 @diff_parent_combine_diff_attrs_fail(i1 %c, i8 %x, i8 %y) {\n %c1 = call i8 @baz(i8 %x, i8 noundef %y) #0\n br i1 %c, label %T, label %F\n\nT: ; preds = %0\n %c0 = call i8 @baz(i8 noundef %x, i8 noundef %y) #1\n %r = call i8 @buz(i8 %c0, i8 %c1)\n ret i8 %r\n\nF: ; preds = %0\n %r2 = add i8 %c1, 4\n ret i8 %r2\n}\n\nattributes #0 = { memory(none) }\nattributes #1 = { strictfp memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "same_parent_combine_diff_attrs_really_needs_intersect",
"test_body": "declare ptr @baz.ptr(i8, i8)\n\ndeclare i8 @buz.ptr(ptr, ptr)\n\ndefine i8 @same_parent_combine_diff_attrs_really_needs_intersect(i8 %x, i8 %y) {\n %c1 = call nonnull ptr @baz.ptr(i8 noundef %x, i8 noundef %y) #0\n %c0 = call ptr @baz.ptr(i8 %x, i8 noundef %y) #0\n %r = call i8 @buz.ptr(ptr %c0, ptr noundef %c1)\n ret i8 %r\n}\n\nattributes #0 = { memory(read) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "diff_parent_combine_diff_attrs_preserves_return_attrs",
"test_body": "declare ptr @baz.ptr(i8, i8)\n\ndeclare i8 @buz.ptr(ptr, ptr)\n\ndefine i8 @diff_parent_combine_diff_attrs_preserves_return_attrs(i1 %c, i8 %x, i8 %y) {\n %c1 = call nonnull ptr @baz.ptr(i8 %x, i8 noundef %y) #0\n br i1 %c, label %T, label %F\n\nT: ; preds = %0\n %c0 = call nonnull ptr @baz.ptr(i8 noundef %x, i8 noundef %y) #0\n %r = call i8 @buz.ptr(ptr %c0, ptr noundef %c1)\n ret i8 %r\n\nF: ; preds = %0\n ret i8 9\n}\n\nattributes #0 = { memory(read) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "same_parent_combine_diff_attrs_fail",
"test_body": "declare i8 @baz(i8, i8)\n\ndeclare i8 @buz(i8, i8)\n\ndefine i8 @same_parent_combine_diff_attrs_fail(i8 %x, i8 %y) {\n %c1 = call i8 @baz(i8 %x, i8 noundef %y) #0\n %c0 = call i8 @baz(i8 noundef %x, i8 noundef %y) #1\n %r = call i8 @buz(i8 %c0, i8 %c1)\n ret i8 %r\n}\n\nattributes #0 = { memory(none) }\nattributes #1 = { strictfp memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "same_parent_combine_diff_attrs_quasi_side_effects2",
"test_body": "declare i8 @baz(i8, i8)\n\ndeclare i8 @buz(i8, i8)\n\ndefine i8 @same_parent_combine_diff_attrs_quasi_side_effects2(i8 %x, i8 %y) {\n %c1 = call i8 @baz(i8 noundef %x, i8 noundef %y) #0\n %c0 = call i8 @baz(i8 %x, i8 noundef %y)\n %r = call i8 @buz(i8 %c0, i8 %c1)\n ret i8 %r\n}\n\nattributes #0 = { memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Compiler asserts running pass \"early-cse<memssa>\"",
"body": "Consider a testcase like that:\n```\n; ModuleID = 'test.bc'\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-sie-ps5\"\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.smin.i32(i32, i32) #0\n\n; Function Attrs: strictfp\ndefine i32 @baz(i32 %arg, i32 %arg1) local_unnamed_addr #1 {\nbb:\n %call = call i32 @llvm.smin.i32(i32 %arg, i32 %arg1) #1\n %call2 = call i32 @llvm.smin.i32(i32 %arg1, i32 %arg)\n %or = or i32 %call2, %call\n ret i32 %or\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\nattributes #1 = { strictfp }\n```\n\nIf you run early-cse test, it triggers the assertion (note: make sure to reproduce with version of the compiler with assertions enabled):\n```\nopt.exe -f test.ll --passes=early-cse\n```\n\n```\nopt.exe -f test.ll --passes=early-cse \nAssertion failed: Success && \"Failed to intersect attributes in callsites that \" \"passed identical check\", file D:\\Dev\\UPSTREAM\\llvm-project\\llvm\\lib\\Transforms\\Scalar\\EarlyCSE.cpp, line 1312 PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. Stack dump: 0. Program arguments: opt.exe -f test.ll --passes=early-cse 1. Running pass \"function(early-cse<>)\" on module \"test.ll\" 2. Running pass \"early-cse<>\" on function \"baz\" Exception Code: 0x80000003 0x00007FF77F8639BC, D:\\Dev\\Testing\\TOOLCHAIN-19080\\opt.exe(0x00007FF778600000) + 0x72639BC byte(s)\n```\n\nHere is the analysis why the failure happens.\n\nFunction EarlyCSE::processNode determines that these two instructions are common subexpression and one of them could be replaced with another.\n\n```\n %call = call i32 @llvm.smin.i32(i32 %arg, i32 %arg1) #1\n %call2 = call i32 @llvm.smin.i32(i32 %arg1, i32 %arg)\n\n attributes #1 ={ strictfp }\n```\nThe piece of code below determines that these two instructions have the same value.\n\n```\n// See if the instruction has an available value. If so, use it.\nif (Value *V = AvailableValues.lookup(&Inst))\n```\nHowever, one of these instructions has 'strictfp' attribute, which signifies that optimizations to libm function calls should be prevented. \nI think that because of this attribute is present, these two instructions should have had different values. Hence the bug. \n\nThe actual failure happens later in the function combineIRFlags(Inst, V) that is trying to combine attributes for these two function calls. \nFunction tryIntersectAttributes determines the intersection of attributes for these two function calls. This intersection is empty, so it returns false.\nLater, the assertion is triggered.\n\n```\nbool Success =\n cast<CallBase>(To)->tryIntersectAttributes(cast<CallBase>(&From));\n assert(Success && \"Failed to intersect attributes in callsites that \"\n \"passed identical check\"); \n```\n",
"author": "romanova-ekaterina",
"labels": [
"crash",
"llvm:transforms"
],
"comments": [
{
"author": "nikic",
"body": "Using strictfp at a call-site should probably be a verifier error."
},
{
"author": "gregbedwell",
"body": "Just to add some extra context to this, the original reproducer here is a large C++ project compiled with clang, and encountering this crash during ThinLTO (and in terms of that project the crash is a recent regression from the last week or two). Let us know if this example is over-reduced and the bug is actually an earlier pass allowing this state to occur in the first place, and I'll work on another small reproducer."
},
{
"author": "nikic",
"body": "> Using strictfp at a call-site should probably be a verifier error.\n\nLooks like I'm wrong about that. Apparently clang places strictfp on all call-sites in a strictfp function.\n\nIn any case, I think the problem here is that we have some special handling for commutative intrinsics, which does not use the usual attribute comparison logic."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
120361
|
https://github.com/llvm/llvm-project/issues/120361
|
miscompilation
|
c6967efe780d6cc5d70fc8cadbd227353b6768f1
| 2024-12-18T05:27:30 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "6f68010f9123aae9f6f105d7a11af22458518ad7",
"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": [
[
455,
468
]
],
"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": [
"foldLogOpOfMaskedICmps_NotAllZeros_BMask_Mixed"
],
"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 6f68010f9123aae9f6f105d7a11af22458518ad7
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Wed Dec 18 20:40:33 2024 +0800
[InstCombine] Drop samesign flags in `foldLogOpOfMaskedICmps_NotAllZeros_BMask_Mixed` (#120373)
Counterexamples: https://alive2.llvm.org/ce/z/6Ks8Qz
Closes https://github.com/llvm/llvm-project/issues/120361.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index dff9304be64d..e576eea4ca36 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -455,14 +455,20 @@ static Value *foldLogOpOfMaskedICmps_NotAllZeros_BMask_Mixed(
// RHS. For example,
// (icmp ne (A & 255), 0) & (icmp eq (A & 15), 8) -> (icmp eq (A & 15), 8).
// (icmp ne (A & 15), 0) & (icmp eq (A & 15), 8) -> (icmp eq (A & 15), 8).
- if (IsSuperSetOrEqual(BCst, DCst))
+ if (IsSuperSetOrEqual(BCst, DCst)) {
+ // We can't guarantee that samesign hold after this fold.
+ RHS->setSameSign(false);
return RHS;
+ }
// Otherwise, B is a subset of D. If B and E have a common bit set,
// ie. (B & E) != 0, then LHS is subsumed by RHS. For example.
// (icmp ne (A & 12), 0) & (icmp eq (A & 15), 8) -> (icmp eq (A & 15), 8).
assert(IsSubSetOrEqual(BCst, DCst) && "Precondition due to above code");
- if ((*BCst & ECst) != 0)
+ if ((*BCst & ECst) != 0) {
+ // We can't guarantee that samesign hold after this fold.
+ RHS->setSameSign(false);
return RHS;
+ }
// Otherwise, LHS and RHS contradict and the whole expression becomes false
// (or true if negated.) For example,
// (icmp ne (A & 7), 0) & (icmp eq (A & 15), 8) -> false.
|
[
{
"file": "llvm/test/Transforms/InstCombine/icmp-logical.ll",
"commands": [
"opt -passes=instcombine -S -o - %s"
],
"tests": [
{
"test_name": "pr120361",
"test_body": "define i1 @pr120361(i8 %x, i8 %y) {\n %cmp1 = icmp samesign eq i8 %x, -1\n %cmp2 = icmp ne i8 %x, 0\n %result = select i1 %cmp2, i1 %cmp1, i1 false\n ret i1 %result\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "pr120361_v2",
"test_body": "define i1 @pr120361_v2(i32 %x) {\n %and1 = and i32 %x, 15\n %cmp1 = icmp ne i32 %and1, 0\n %and2 = and i32 %x, -113\n %cmp2 = icmp samesign eq i32 %and2, 15\n %and = select i1 %cmp1, i1 %cmp2, i1 false\n ret i1 %and\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "masked_icmps_bmask_notmixed_not_subset_notoptimized",
"test_body": "define i1 @masked_icmps_bmask_notmixed_not_subset_notoptimized(i32 %A) {\n %mask1 = and i32 %A, 254\n %tst1 = icmp ne i32 %mask1, 252\n %mask2 = and i32 %A, 253\n %tst2 = icmp ne i32 %mask2, 252\n %res = and i1 %tst1, %tst2\n ret i1 %res\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstCombine] `samesign` should be dropped when folding logical and of icmps",
"body": "Reproducer: https://alive2.llvm.org/ce/z/YSW_NC\n```\ndefine i1 @src(i8 %0, i8 %1) {\nstart:\n %2 = icmp samesign eq i8 %0, -1\n %3 = icmp ne i8 %0, 0\n %4 = icmp ugt i8 %0, %0\n %result = select i1 %3, i1 %2, i1 %4\n ret i1 %result\n}\n\ndefine i1 @tgt(i8 %0, i8 %1) {\nstart:\n %2 = icmp samesign eq i8 %0, -1\n ret i1 %2\n}\n```\n```\n\n----------------------------------------\ndefine i1 @src(i8 %#0, i8 %#1) {\nstart:\n %#2 = icmp samesign eq i8 %#0, 255\n %#3 = icmp ne i8 %#0, 0\n %#4 = icmp ugt i8 %#0, %#0\n %result = select i1 %#3, i1 %#2, i1 %#4\n ret i1 %result\n}\n=>\ndefine i1 @tgt(i8 %#0, i8 %#1) {\nstart:\n %#2 = icmp samesign eq i8 %#0, 255\n ret i1 %#2\n}\nTransformation doesn't verify!\n\nERROR: Target is more poisonous than source\n\nExample:\ni8 %#0 = #x00 (0)\ni8 %#1 = poison\n\nSource:\ni1 %#2 = poison\ni1 %#3 = #x0 (0)\ni1 %#4 = #x0 (0)\ni1 %result = #x0 (0)\n\nTarget:\ni1 %#2 = poison\nSource value: #x0 (0)\nTarget value: poison\n```\nReported by https://github.com/dtcxzyw/llvm-mutation-based-fuzz-service/issues/14 while reviewing https://github.com/llvm/llvm-project/pull/120177.\n\n\n",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
87378
|
https://github.com/llvm/llvm-project/issues/87378
|
crash
|
d8db13edd60b195e6692deb04d63e633319e486a
| 2024-04-02T17:38:53 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "6261c53c6f9c82bfca5df2ed5917876d748ed079",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/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": [
[
175,
181
]
],
"llvm/lib/Transforms/Vectorize/VPlan.h": [
[
913,
918
],
[
920,
928
],
[
1016,
1021
],
[
1221,
1226
]
],
"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": [
"createOr",
"createSelect"
],
"llvm/lib/Transforms/Vectorize/VPlan.h": [
"GEPFlagsTy",
"VPInstruction",
"VPRecipeWithIRFlags"
],
"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 6261c53c6f9c82bfca5df2ed5917876d748ed079
Author: Florian Hahn <flo@fhahn.com>
Date: Tue Apr 2 21:48:35 2024 +0100
[VPlan] Make sure OR VPInstructions are treated as disjoint ops.
Make sure that VPInstructions with OR opcodes are properly registered as
disjoint ops.
Fixes https://github.com/llvm/llvm-project/issues/87378.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h b/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
index 5d03b66b0ce3..ebca2d855a46 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
@@ -175,7 +175,10 @@ public:
VPValue *createOr(VPValue *LHS, VPValue *RHS, DebugLoc DL = {},
const Twine &Name = "") {
- return createInstruction(Instruction::BinaryOps::Or, {LHS, RHS}, DL, Name);
+
+ return tryInsertInstruction(new VPInstruction(
+ Instruction::BinaryOps::Or, {LHS, RHS},
+ VPRecipeWithIRFlags::DisjointFlagsTy(false), DL, Name));
}
VPValue *createSelect(VPValue *Cond, VPValue *TrueVal, VPValue *FalseVal,
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 3baca43f7276..707a826ecdc2 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -913,6 +913,11 @@ public:
WrapFlagsTy(bool HasNUW, bool HasNSW) : HasNUW(HasNUW), HasNSW(HasNSW) {}
};
+ struct DisjointFlagsTy {
+ char IsDisjoint : 1;
+ DisjointFlagsTy(bool IsDisjoint) : IsDisjoint(IsDisjoint) {}
+ };
+
protected:
struct GEPFlagsTy {
char IsInBounds : 1;
@@ -920,9 +925,6 @@ protected:
};
private:
- struct DisjointFlagsTy {
- char IsDisjoint : 1;
- };
struct ExactFlagsTy {
char IsExact : 1;
};
@@ -1016,6 +1018,12 @@ public:
: VPSingleDefRecipe(SC, Operands, DL), OpType(OperationType::FPMathOp),
FMFs(FMFs) {}
+ template <typename IterT>
+ VPRecipeWithIRFlags(const unsigned char SC, IterT Operands,
+ DisjointFlagsTy DisjointFlags, DebugLoc DL = {})
+ : VPSingleDefRecipe(SC, Operands, DL), OpType(OperationType::DisjointOp),
+ DisjointFlags(DisjointFlags) {}
+
protected:
template <typename IterT>
VPRecipeWithIRFlags(const unsigned char SC, IterT Operands,
@@ -1221,6 +1229,14 @@ public:
: VPRecipeWithIRFlags(VPDef::VPInstructionSC, Operands, WrapFlags, DL),
Opcode(Opcode), Name(Name.str()) {}
+ VPInstruction(unsigned Opcode, std::initializer_list<VPValue *> Operands,
+ DisjointFlagsTy DisjointFlag, DebugLoc DL = {},
+ const Twine &Name = "")
+ : VPRecipeWithIRFlags(VPDef::VPInstructionSC, Operands, DisjointFlag, DL),
+ Opcode(Opcode), Name(Name.str()) {
+ assert(Opcode == Instruction::Or && "only OR opcodes can be disjoint");
+ }
+
VPInstruction(unsigned Opcode, std::initializer_list<VPValue *> Operands,
FastMathFlags FMFs, DebugLoc DL = {}, const Twine &Name = "");
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/pr87378-vpinstruction-or-drop-poison-generating-flags.ll",
"commands": [
"opt -p loop-vectorize -mattr=\"+v\" -S %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\n; Test case for https://github.com/llvm/llvm-project/issues/87378.\ndefine void @pr87378_vpinstruction_or_drop_poison_generating_flags(ptr %arg, i64 %a, i64 %b, i64 %c) {\n;\nentry:\n br label %loop.header\n\nloop.header:\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %c.1 = icmp ule i64 %iv, %a\n br i1 %c.1, label %then.1, label %else.1\n\nthen.1:\n %c.2 = icmp ule i64 %iv, %b\n br i1 %c.2, label %else.1, label %merge\n\nelse.1:\n %c.3 = icmp ule i64 %iv, %c\n br i1 %c.3, label %then.2, label %loop.latch\n\nthen.2:\n br label %merge\n\nmerge:\n %idx = phi i64 [ poison, %then.1 ], [ %iv, %then.2 ]\n %getelementptr = getelementptr i16, ptr %arg, i64 %idx\n store i16 0, ptr %getelementptr, align 2\n br label %loop.latch\n\nloop.latch:\n %iv.next = add i64 %iv, 1\n %icmp = icmp eq i64 %iv, 1000\n br i1 %icmp, label %exit, label %loop.header\n\nexit:\n ret void\n}\n;.\n;.",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[LoopVectorize] Assertion `OpType == OperationType::DisjointOp && \"recipe cannot have a disjoing flag\"' failed.",
"body": "Reduced LLVM IR:\r\n``` llvm ir\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine i32 @main() #0 {\r\nentry:\r\n br label %for.body300.us.us.i\r\n\r\nfor.body300.us.us.i: ; preds = %if.end559.us.us.i, %entry\r\n br label %for.body326.us.us.i\r\n\r\nfor.body326.us.us.i: ; preds = %if.end559.us.us.i, %for.body300.us.us.i\r\n %indvars.iv18 = phi i64 [ 0, %for.body300.us.us.i ], [ %indvars.iv.next19, %if.end559.us.us.i ]\r\n br i1 false, label %cond.end339.us.us.i, label %cond.end354.us.us.i\r\n\r\ncond.end339.us.us.i: ; preds = %for.body326.us.us.i\r\n br i1 false, label %cond.end339.us.us.i.if.then357.us.us.i_crit_edge, label %cond.end339.us.us.i.cond.end354.us.us.i_crit_edge\r\n\r\ncond.end339.us.us.i.cond.end354.us.us.i_crit_edge: ; preds = %cond.end339.us.us.i\r\n br label %cond.end354.us.us.i\r\n\r\ncond.end339.us.us.i.if.then357.us.us.i_crit_edge: ; preds = %cond.end339.us.us.i\r\n br label %if.then357.us.us.i\r\n\r\ncond.end354.us.us.i: ; preds = %cond.end339.us.us.i.cond.end354.us.us.i_crit_edge, %for.body326.us.us.i\r\n br i1 false, label %cond.end354.us.us.i.if.then357.us.us.i_crit_edge, label %if.end559.us.us.i\r\n\r\ncond.end354.us.us.i.if.then357.us.us.i_crit_edge: ; preds = %cond.end354.us.us.i\r\n br label %if.then357.us.us.i\r\n\r\nif.then357.us.us.i: ; preds = %cond.end354.us.us.i.if.then357.us.us.i_crit_edge, %cond.end339.us.us.i.if.then357.us.us.i_crit_edge\r\n %.pre1143.i7 = phi i64 [ poison, %cond.end339.us.us.i.if.then357.us.us.i_crit_edge ], [ %indvars.iv18, %cond.end354.us.us.i.if.then357.us.us.i_crit_edge ]\r\n %arrayidx429.us.us.i = getelementptr [14 x i16], ptr null, i64 0, i64 %.pre1143.i7\r\n store i16 0, ptr %arrayidx429.us.us.i, align 2\r\n br label %if.end559.us.us.i\r\n\r\nif.end559.us.us.i: ; preds = %if.then357.us.us.i, %cond.end354.us.us.i\r\n %indvars.iv.next19 = add i64 %indvars.iv18, 1\r\n %0 = trunc i64 %indvars.iv18 to i32\r\n %cmp323.us.us.i = icmp slt i32 %0, 1\r\n br i1 %cmp323.us.us.i, label %for.body326.us.us.i, label %for.body300.us.us.i\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl256b,+zvl32b,+zvl64b,-e,-experimental-smmpm,-experimental-smnpm,-experimental-ssnpm,-experimental-sspm,-experimental-ssqosid,-experimental-supm,-experimental-zaamo,-experimental-zabha,-experimental-zalasr,-experimental-zalrsc,-experimental-zcmop,-experimental-zfbfmin,-experimental-zicfilp,-experimental-zicfiss,-experimental-zimop,-experimental-ztso,-experimental-zvfbfmin,-experimental-zvfbfwma,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smepmp,-ssaia,-ssccptr,-sscofpmf,-sscounterenw,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-za128rs,-za64rs,-zacas,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmp,-zcmt,-zdinx,-zfa,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-zmmul,-zvbb,-zvbc,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\n```\r\n\r\nBacktrace:\r\n```\r\nopt: /scratch/tc-testing/tc-apr-2/llvm/llvm/lib/Transforms/Vectorize/VPlan.h:1131: bool llvm::VPRecipeWithIRFlags::isDisjoint() const: Assertion `OpType == OperationType::DisjointOp && \"recipe cannot have a disjoing flag\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt reduced.ll --passes=loop-vectorize\r\n #0 0x00005bd204995b60 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2d84b60)\r\n #1 0x00005bd204992f6f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2d81f6f)\r\n #2 0x00005bd2049930c5 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x000076eef1a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x000076eef1a969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x000076eef1a969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x000076eef1a969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x000076eef1a42476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x000076eef1a287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x000076eef1a2871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x000076eef1a39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x00005bd203b25ea2 llvm::VPlanTransforms::dropPoisonGeneratingRecipes(llvm::VPlan&, llvm::function_ref<bool (llvm::BasicBlock*)>)::'lambda'(llvm::VPRecipeBase*)::operator()(llvm::VPRecipeBase*) const VPlanTransforms.cpp:0:0\r\n#12 0x00005bd203b2c77d llvm::VPlanTransforms::dropPoisonGeneratingRecipes(llvm::VPlan&, llvm::function_ref<bool (llvm::BasicBlock*)>) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1f1b77d)\r\n#13 0x00005bd203a05435 llvm::LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(llvm::VFRange&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1df4435)\r\n#14 0x00005bd203a05c9e llvm::LoopVectorizationPlanner::buildVPlansWithVPRecipes(llvm::ElementCount, llvm::ElementCount) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1df4c9e)\r\n#15 0x00005bd203a0c319 llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1dfb319)\r\n#16 0x00005bd203a0f8a9 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1dfe8a9)\r\n#17 0x00005bd203a1273e llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1e0173e)\r\n#18 0x00005bd203a1388d llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1e0288d)\r\n#19 0x00005bd20291a276 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0xd09276)\r\n#20 0x00005bd2047bc141 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2bab141)\r\n#21 0x00005bd202911bd6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0xd00bd6)\r\n#22 0x00005bd2047bae3b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2ba9e3b)\r\n#23 0x00005bd202919dc6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0xd08dc6)\r\n#24 0x00005bd2047b8cb1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2ba7cb1)\r\n#25 0x00005bd202193ce5 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x582ce5)\r\n#26 0x00005bd202186316 optMain (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x575316)\r\n#27 0x000076eef1a29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#28 0x000076eef1a29e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#29 0x000076eef1a29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#30 0x00005bd20217bf95 _start (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x56af95)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt reduced.l\r\n```\r\n\r\nGodbolt: https://godbolt.org/z/jj39h3z7M\r\n\r\nMinor spelling nit: `disjoing -> disjoint`\r\n\r\nFound via fuzzer.\r\n\r\nLikely caused/exposed by https://github.com/llvm/llvm-project/commit/6ef829941b38f7e8a28c4cba1ff25cd0ae9f7d3d https://github.com/llvm/llvm-project/pull/83821 @fhahn ",
"author": "patrick-rivos",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
| null |
96012
|
https://github.com/llvm/llvm-project/issues/96012
|
hang
|
aad27bf534b59645f47a92f072af798687b1dd0d
| 2024-06-19T02:31:53 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "48ae61470104e9d7a8be5beb8739c24f52cc33c0",
"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": [
[
780,
790
]
],
"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": [
[
90,
102
],
[
309,
314
],
[
537,
543
]
],
"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": 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": [
"Negator::Negate",
"Negator::Negator",
"Negator::visitImpl",
"Negator::~Negator"
],
"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 48ae61470104e9d7a8be5beb8739c24f52cc33c0
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Sat Aug 17 16:48:29 2024 +0800
[InstCombine] Avoid infinite loop when negating phi nodes (#104581)
Closes https://github.com/llvm/llvm-project/issues/96012
---------
Co-authored-by: Nikita Popov <github@npopov.com>
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
index 16f1c3ba15eb..a0f2399972b5 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
+++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
@@ -780,11 +780,14 @@ class Negator final {
using BuilderTy = IRBuilder<TargetFolder, IRBuilderCallbackInserter>;
BuilderTy Builder;
+ const DominatorTree &DT;
+
const bool IsTrulyNegation;
SmallDenseMap<Value *, Value *> NegationsCache;
- Negator(LLVMContext &C, const DataLayout &DL, bool IsTrulyNegation);
+ Negator(LLVMContext &C, const DataLayout &DL, const DominatorTree &DT,
+ bool IsTrulyNegation);
#if LLVM_ENABLE_STATS
unsigned NumValuesVisitedInThisNegator = 0;
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp b/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp
index 2dd1db6a4a75..92293ef40146 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp
@@ -90,13 +90,14 @@ static cl::opt<unsigned>
cl::desc("What is the maximal lookup depth when trying to "
"check for viability of negation sinking."));
-Negator::Negator(LLVMContext &C, const DataLayout &DL, bool IsTrulyNegation_)
+Negator::Negator(LLVMContext &C, const DataLayout &DL, const DominatorTree &DT_,
+ bool IsTrulyNegation_)
: Builder(C, TargetFolder(DL),
IRBuilderCallbackInserter([&](Instruction *I) {
++NegatorNumInstructionsCreatedTotal;
NewInstructions.push_back(I);
})),
- IsTrulyNegation(IsTrulyNegation_) {}
+ DT(DT_), IsTrulyNegation(IsTrulyNegation_) {}
#if LLVM_ENABLE_STATS
Negator::~Negator() {
@@ -309,6 +310,9 @@ std::array<Value *, 2> Negator::getSortedOperandsOfBinOp(Instruction *I) {
auto *PHI = cast<PHINode>(I);
SmallVector<Value *, 4> NegatedIncomingValues(PHI->getNumOperands());
for (auto I : zip(PHI->incoming_values(), NegatedIncomingValues)) {
+ // Don't negate indvars to avoid infinite loops.
+ if (DT.dominates(PHI->getParent(), std::get<0>(I)))
+ return nullptr;
if (!(std::get<1>(I) =
negate(std::get<0>(I), IsNSW, Depth + 1))) // Early return.
return nullptr;
@@ -537,7 +541,8 @@ std::array<Value *, 2> Negator::getSortedOperandsOfBinOp(Instruction *I) {
if (!NegatorEnabled || !DebugCounter::shouldExecute(NegatorCounter))
return nullptr;
- Negator N(Root->getContext(), IC.getDataLayout(), LHSIsZero);
+ Negator N(Root->getContext(), IC.getDataLayout(), IC.getDominatorTree(),
+ LHSIsZero);
std::optional<Result> Res = N.run(Root, IsNSW);
if (!Res) { // Negation failed.
LLVM_DEBUG(dbgs() << "Negator: failed to sink negation into " << *Root
|
[
{
"file": "llvm/test/Transforms/InstCombine/pr96012.ll",
"commands": [
"opt -S -passes=instcombine < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\n; Make sure we don't hang here.\ndefine i32 @pr96012() {\n;\nentry:\n br label %for.cond\n\nfor.cond:\n %indvar = phi i32 [ 1, %entry ], [ %shl, %for.cond ]\n %conv1 = trunc i32 %indvar to i8\n %neg = sub i8 0, %conv1\n %conv2 = zext i8 %neg to i32\n %shl = shl nuw i32 %conv2, 24\n br label %for.cond\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "InstCombine gets stuck when sinking negation",
"body": "Minimal reproducer (It looks over-reduced): https://godbolt.org/z/9zj5K8seP\r\n```\r\n; opt -passes=instcombine test.ll -S -debug\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 @func_112() {\r\nentry:\r\n br label %for.cond\r\n\r\nfor.cond: ; preds = %for.cond, %entry\r\n %l_139.0 = phi i32 [ 1, %entry ], [ %0, %for.cond ]\r\n %conv5 = trunc i32 %l_139.0 to i8\r\n %call6 = sub i8 0, %conv5\r\n %conv7 = zext i8 %call6 to i32\r\n %0 = shl nuw i32 %conv7, 24\r\n br label %for.cond\r\n}\r\n```\r\n\r\n```\r\nINSTCOMBINE ITERATION #1 on func_112\r\nADD: br label %for.cond\r\nADD: %0 = shl nuw i32 %conv7, 24\r\nADD: %conv7 = zext i8 %call6 to i32\r\nADD: %call6 = sub i8 0, %conv5\r\nADD: %conv5 = trunc i32 %l_139.0 to i8\r\nADD: %l_139.0 = phi i32 [ 1, %entry ], [ %0, %for.cond ]\r\nADD: br label %for.cond\r\nIC: Visiting: br label %for.cond\r\nIC: Visiting: %l_139.0 = phi i32 [ 1, %entry ], [ %0, %for.cond ]\r\nIC: Visiting: %conv5 = trunc i32 %l_139.0 to i8\r\nIC: Visiting: %call6 = sub i8 0, %conv5\r\nNegator: attempting to sink negation into %conv5 = trunc i32 %l_139.0 to i8\r\nNegator: successfully sunk negation into %conv5 = trunc i32 %l_139.0 to i8\r\n NEW: %conv5.neg = trunc i32 %l_139.0.neg to i8\r\nNegator: Propagating 3 instrs to InstCombine\r\nADD DEFERRED: %.neg = mul i32 %conv7, -16777216\r\nADD DEFERRED: %l_139.0.neg = phi i32 [ -1, %entry ], [ %.neg, %for.cond ]\r\nADD DEFERRED: %conv5.neg = trunc i32 %l_139.0.neg to i8\r\nIC: Old = %call6 = sub i8 0, %conv5\r\n New = <badref> = add i8 %conv5.neg, 0\r\nADD: %call6 = add i8 %conv5.neg, 0\r\nIC: ERASE %0 = sub i8 0, %conv5\r\nADD DEFERRED: %conv5 = trunc i32 %l_139.0 to i8\r\nIC: ERASE %conv5 = trunc i32 %l_139.0 to i8\r\nADD DEFERRED: %l_139.0 = phi i32 [ 1, %entry ], [ %0, %for.cond ]\r\nIC: ERASE %l_139.0 = phi i32 [ 1, %entry ], [ %0, %for.cond ]\r\nADD DEFERRED: %0 = shl nuw i32 %conv7, 24\r\nIC: ERASE %0 = shl nuw i32 %conv7, 24\r\nADD DEFERRED: %conv7 = zext i8 %call6 to i32\r\nADD: %conv5.neg = trunc i32 %l_139.0.neg to i8\r\nADD: %l_139.0.neg = phi i32 [ -1, %entry ], [ %.neg, %for.cond ]\r\nADD: %.neg = mul i32 %conv7, -16777216\r\nIC: Visiting: %.neg = mul i32 %conv7, -16777216\r\nNegator: attempting to sink negation into %conv7 = zext i8 %call6 to i32\r\nNegator: failed to sink negation into %conv7 = zext i8 %call6 to i32\r\nADD DEFERRED: %call6.neg = sub i8 0, %call6\r\nADD DEFERRED: %call6.neg.z = zext i8 %call6.neg to i32\r\nIC: Old = %.neg = mul i32 %conv7, -16777216\r\n New = <badref> = shl i32 %call6.neg.z, 24\r\nADD: %.neg = shl i32 %call6.neg.z, 24\r\nIC: ERASE %0 = mul i32 %conv7, -16777216\r\nADD DEFERRED: %conv7 = zext i8 %call6 to i32\r\nIC: ERASE %conv7 = zext i8 %call6 to i32\r\nADD DEFERRED: %call6 = add i8 %conv5.neg, 0\r\nADD: %call6.neg.z = zext i8 %call6.neg to i32\r\nADD: %call6.neg = sub i8 0, %call6\r\nIC: Visiting: %call6.neg = sub i8 0, %call6\r\nIC: Old = %call6.neg = sub i8 0, %call6\r\n New = <badref> = sub i8 0, %conv5.neg\r\nADD: %call6.neg = sub i8 0, %conv5.neg\r\nIC: ERASE %0 = sub i8 0, %call6\r\nADD DEFERRED: %call6 = add i8 %conv5.neg, 0\r\nIC: ERASE %call6 = add i8 %conv5.neg, 0\r\nADD DEFERRED: %conv5.neg = trunc i32 %l_139.0.neg to i8\r\nADD DEFERRED: %call6.neg = sub i8 0, %conv5.neg\r\nIC: Visiting: %call6.neg = sub i8 0, %conv5.neg\r\nNegator: attempting to sink negation into %conv5.neg = trunc i32 %l_139.0.neg to i8\r\nNegator: successfully sunk negation into %conv5.neg = trunc i32 %l_139.0.neg to i8\r\n NEW: %conv5.neg.neg = trunc i32 %l_139.0.neg.neg to i8\r\nNegator: Propagating 3 instrs to InstCombine\r\nADD DEFERRED: %.neg.neg = mul i32 %call6.neg.z, -16777216\r\nADD DEFERRED: %l_139.0.neg.neg = phi i32 [ 1, %entry ], [ %.neg.neg, %for.cond ]\r\nADD DEFERRED: %conv5.neg.neg = trunc i32 %l_139.0.neg.neg to i8\r\nIC: Old = %call6.neg = sub i8 0, %conv5.neg\r\n New = <badref> = add i8 %conv5.neg.neg, 0\r\nADD: %call6.neg = add i8 %conv5.neg.neg, 0\r\nIC: ERASE %0 = sub i8 0, %conv5.neg\r\nADD DEFERRED: %conv5.neg = trunc i32 %l_139.0.neg to i8\r\nIC: ERASE %conv5.neg = trunc i32 %l_139.0.neg to i8\r\nADD DEFERRED: %l_139.0.neg = phi i32 [ -1, %entry ], [ %.neg, %for.cond ]\r\nIC: ERASE %l_139.0.neg = phi i32 [ -1, %entry ], [ %.neg, %for.cond ]\r\nADD DEFERRED: %.neg = shl i32 %call6.neg.z, 24\r\nIC: ERASE %.neg = shl i32 %call6.neg.z, 24\r\nADD DEFERRED: %call6.neg.z = zext i8 %call6.neg to i32\r\nADD: %conv5.neg.neg = trunc i32 %l_139.0.neg.neg to i8\r\nADD: %l_139.0.neg.neg = phi i32 [ 1, %entry ], [ %.neg.neg, %for.cond ]\r\nADD: %.neg.neg = mul i32 %call6.neg.z, -16777216\r\nIC: Visiting: %.neg.neg = mul i32 %call6.neg.z, -16777216\r\nNegator: attempting to sink negation into %call6.neg.z = zext i8 %call6.neg to i32\r\nNegator: failed to sink negation into %call6.neg.z = zext i8 %call6.neg to i32\r\nADD DEFERRED: %call6.neg.neg = sub i8 0, %call6.neg\r\nADD DEFERRED: %call6.neg.neg.z = zext i8 %call6.neg.neg to i32\r\nIC: Old = %.neg.neg = mul i32 %call6.neg.z, -16777216\r\n New = <badref> = shl i32 %call6.neg.neg.z, 24\r\nADD: %.neg.neg = shl i32 %call6.neg.neg.z, 24\r\nIC: ERASE %0 = mul i32 %call6.neg.z, -16777216\r\nADD DEFERRED: %call6.neg.z = zext i8 %call6.neg to i32\r\nIC: ERASE %call6.neg.z = zext i8 %call6.neg to i32\r\nADD DEFERRED: %call6.neg = add i8 %conv5.neg.neg, 0\r\nADD: %call6.neg.neg.z = zext i8 %call6.neg.neg to i32\r\nADD: %call6.neg.neg = sub i8 0, %call6.neg\r\nIC: Visiting: %call6.neg.neg = sub i8 0, %call6.neg\r\nIC: Old = %call6.neg.neg = sub i8 0, %call6.neg\r\n New = <badref> = sub i8 0, %conv5.neg.neg\r\nADD: %call6.neg.neg = sub i8 0, %conv5.neg.neg\r\nIC: ERASE %0 = sub i8 0, %call6.neg\r\nADD DEFERRED: %call6.neg = add i8 %conv5.neg.neg, 0\r\nIC: ERASE %call6.neg = add i8 %conv5.neg.neg, 0\r\nADD DEFERRED: %conv5.neg.neg = trunc i32 %l_139.0.neg.neg to i8\r\nADD DEFERRED: %call6.neg.neg = sub i8 0, %conv5.neg.neg\r\nIC: Visiting: %call6.neg.neg = sub i8 0, %conv5.neg.neg\r\nNegator: attempting to sink negation into %conv5.neg.neg = trunc i32 %l_139.0.neg.neg to i8\r\nNegator: successfully sunk negation into %conv5.neg.neg = trunc i32 %l_139.0.neg.neg to i8\r\n NEW: %conv5.neg.neg.neg = trunc i32 %l_139.0.neg.neg.neg to i8\r\nNegator: Propagating 3 instrs to InstCombine\r\nADD DEFERRED: %.neg.neg.neg = mul i32 %call6.neg.neg.z, -16777216\r\nADD DEFERRED: %l_139.0.neg.neg.neg = phi i32 [ -1, %entry ], [ %.neg.neg.neg, %for.cond ]\r\nADD DEFERRED: %conv5.neg.neg.neg = trunc i32 %l_139.0.neg.neg.neg to i8\r\nIC: Old = %call6.neg.neg = sub i8 0, %conv5.neg.neg\r\n New = <badref> = add i8 %conv5.neg.neg.neg, 0\r\nADD: %call6.neg.neg = add i8 %conv5.neg.neg.neg, 0\r\nIC: ERASE %0 = sub i8 0, %conv5.neg.neg\r\nADD DEFERRED: %conv5.neg.neg = trunc i32 %l_139.0.neg.neg to i8\r\nIC: ERASE %conv5.neg.neg = trunc i32 %l_139.0.neg.neg to i8\r\nADD DEFERRED: %l_139.0.neg.neg = phi i32 [ 1, %entry ], [ %.neg.neg, %for.cond ]\r\nIC: ERASE %l_139.0.neg.neg = phi i32 [ 1, %entry ], [ %.neg.neg, %for.cond ]\r\nADD DEFERRED: %.neg.neg = shl i32 %call6.neg.neg.z, 24\r\nIC: ERASE %.neg.neg = shl i32 %call6.neg.neg.z, 24\r\nADD DEFERRED: %call6.neg.neg.z = zext i8 %call6.neg.neg to i32\r\nADD: %conv5.neg.neg.neg = trunc i32 %l_139.0.neg.neg.neg to i8\r\nADD: %l_139.0.neg.neg.neg = phi i32 [ -1, %entry ], [ %.neg.neg.neg, %for.cond ]\r\nADD: %.neg.neg.neg = mul i32 %call6.neg.neg.z, -16777216\r\nIC: Visiting: %.neg.neg.neg = mul i32 %call6.neg.neg.z, -16777216\r\nNegator: attempting to sink negation into %call6.neg.neg.z = zext i8 %call6.neg.neg to i32\r\nNegator: failed to sink negation into %call6.neg.neg.z = zext i8 %call6.neg.neg to i32\r\nADD DEFERRED: %call6.neg.neg.neg = sub i8 0, %call6.neg.neg\r\nADD DEFERRED: %call6.neg.neg.neg.z = zext i8 %call6.neg.neg.neg to i32\r\nIC: Old = %.neg.neg.neg = mul i32 %call6.neg.neg.z, -16777216\r\n New = <badref> = shl i32 %call6.neg.neg.neg.z, 24\r\nADD: %.neg.neg.neg = shl i32 %call6.neg.neg.neg.z, 24\r\nIC: ERASE %0 = mul i32 %call6.neg.neg.z, -16777216\r\nADD DEFERRED: %call6.neg.neg.z = zext i8 %call6.neg.neg to i32\r\nIC: ERASE %call6.neg.neg.z = zext i8 %call6.neg.neg to i32\r\nADD DEFERRED: %call6.neg.neg = add i8 %conv5.neg.neg.neg, 0\r\nADD: %call6.neg.neg.neg.z = zext i8 %call6.neg.neg.neg to i32\r\nADD: %call6.neg.neg.neg = sub i8 0, %call6.neg.neg\r\nIC: Visiting: %call6.neg.neg.neg = sub i8 0, %call6.neg.neg\r\nIC: Old = %call6.neg.neg.neg = sub i8 0, %call6.neg.neg\r\n New = <badref> = sub i8 0, %conv5.neg.neg.neg\r\nADD: %call6.neg.neg.neg = sub i8 0, %conv5.neg.neg.neg\r\nIC: ERASE %0 = sub i8 0, %call6.neg.neg\r\nADD DEFERRED: %call6.neg.neg = add i8 %conv5.neg.neg.neg, 0\r\nIC: ERASE %call6.neg.neg = add i8 %conv5.neg.neg.neg, 0\r\nADD DEFERRED: %conv5.neg.neg.neg = trunc i32 %l_139.0.neg.neg.neg to i8\r\nADD DEFERRED: %call6.neg.neg.neg = sub i8 0, %conv5.neg.neg.neg\r\nIC: Visiting: %call6.neg.neg.neg = sub i8 0, %conv5.neg.neg.neg\r\nNegator: attempting to sink negation into %conv5.neg.neg.neg = trunc i32 %l_139.0.neg.neg.neg to i8\r\nNegator: successfully sunk negation into %conv5.neg.neg.neg = trunc i32 %l_139.0.neg.neg.neg to i8\r\n NEW: %conv5.neg.neg.neg.neg = trunc i32 %l_139.0.neg.neg.neg.neg to i8\r\n...\r\n```",
"author": "dtcxzyw",
"labels": [
"llvm:instcombine",
"llvm:hang"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
100464
|
https://github.com/llvm/llvm-project/issues/100464
|
crash
|
ba461f8c6278a7b2fd7695454c1f184c38897ecd
| 2024-07-24T20:37:49 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "b72689a5cbd8645c183476cd87e32948308c5b64",
"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": [
[
6678,
6683
],
[
6693,
6700
],
[
6727,
6742
]
],
"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 b72689a5cbd8645c183476cd87e32948308c5b64
Author: Florian Hahn <flo@fhahn.com>
Date: Thu Jul 25 11:16:09 2024 +0100
[LV] Ignore live-out users in cost model if scalar epilogue is required.
Follow-up to ba8126b6fef79.
If a scalar epilogue is required, users outside the loop won't use
live-outs from the vector loop but from the scalar epilogue. Ignore them if
that is the case.
This fixes another case where the VPlan-based cost-model more accurately
computes cost.
Fixes https://github.com/llvm/llvm-project/issues/100464.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index b709ccc3c35a..224d98d5c4f9 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -6678,6 +6678,15 @@ void LoopVectorizationCostModel::collectValuesToIgnore() {
SmallVector<Value *, 4> DeadInterleavePointerOps;
SmallVector<Value *, 4> DeadOps;
+
+ // If a scalar epilogue is required, users outside the loop won't use
+ // live-outs from the vector loop but from the scalar epilogue. Ignore them if
+ // that is the case.
+ bool RequiresScalarEpilogue = requiresScalarEpilogue(true);
+ auto IsLiveOutDead = [this, RequiresScalarEpilogue](User *U) {
+ return RequiresScalarEpilogue &&
+ !TheLoop->contains(cast<Instruction>(U)->getParent());
+ };
for (BasicBlock *BB : TheLoop->blocks())
for (Instruction &I : *BB) {
// Find all stores to invariant variables. Since they are going to sink
@@ -6693,8 +6702,9 @@ void LoopVectorizationCostModel::collectValuesToIgnore() {
// 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);
+ all_of(I.users(), [this, IsLiveOutDead](User *U) {
+ return VecValuesToIgnore.contains(U) ||
+ ValuesToIgnore.contains(U) || IsLiveOutDead(U);
}))
DeadOps.push_back(&I);
@@ -6727,16 +6737,22 @@ void LoopVectorizationCostModel::collectValuesToIgnore() {
// Mark ops that would be trivially dead and are only used by ignored
// instructions as free.
+ BasicBlock *Header = TheLoop->getHeader();
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) ||
+ (isa<PHINode>(Op) && Op->getParent() == Header) ||
!wouldInstructionBeTriviallyDead(Op, TLI) ||
- any_of(Op->users(), [this](User *U) {
- return !VecValuesToIgnore.contains(U) && !ValuesToIgnore.contains(U);
+ any_of(Op->users(), [this, IsLiveOutDead](User *U) {
+ return !VecValuesToIgnore.contains(U) && ValuesToIgnore.contains(U) &&
+ !IsLiveOutDead(U);
}))
continue;
+ if (!TheLoop->contains(Op->getParent()))
+ 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.
|
[
{
"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": "dead_live_out_due_to_scalar_epilogue_required",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine i8 @dead_live_out_due_to_scalar_epilogue_required(ptr %src, ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %idxprom = sext i32 %iv to i64\n %gep.src = getelementptr i8, ptr %src, i64 %idxprom\n %l = load i8, ptr %gep.src, align 1\n %gep.dst = getelementptr i8, ptr %dst, i64 %idxprom\n store i8 0, ptr %gep.dst, align 1\n %iv.next = add i32 %iv, 4\n %cmp = icmp ult i32 %iv, 1001\n br i1 %cmp, label %loop, label %exit\n\nexit: ; preds = %loop\n %r = phi i8 [ %l, %loop ]\n ret i8 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "dead_load",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine void @dead_load(ptr %p, i16 %start) {\nentry:\n %start.ext = sext i16 %start to i64\n br label %loop\n\nloop: ; preds = %loop, %entry\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: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/RISCV/riscv-vector-reverse.ll",
"commands": [
"opt -passes=loop-vectorize,dce,instcombine -mtriple riscv64-linux-gnu -mattr=+v -debug-only=loop-vectorize -scalable-vectorization=on -riscv-v-vector-bits-min=128 -disable-output < %s 2>&1"
],
"tests": [
{
"test_name": "vector_reverse_i64",
"test_body": "define void @vector_reverse_i64(ptr nocapture noundef writeonly %A, ptr nocapture noundef readonly %B, i32 noundef signext %n) {\nentry:\n %cmp7 = icmp sgt i32 %n, 0\n br i1 %cmp7, label %for.body.preheader, label %for.cond.cleanup\n\nfor.body.preheader: ; preds = %entry\n %0 = zext i32 %n to i64\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 %indvars.iv = phi i64 [ %0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]\n %i.0.in8 = phi i32 [ %n, %for.body.preheader ], [ %i.0, %for.body ]\n %i.0 = add nsw i32 %i.0.in8, -1\n %idxprom = zext i32 %i.0 to i64\n %arrayidx = getelementptr inbounds i32, ptr %B, i64 %idxprom\n %1 = load i32, ptr %arrayidx, align 4\n %add9 = add i32 %1, 1\n %arrayidx3 = getelementptr inbounds i32, ptr %A, i64 %idxprom\n store i32 %add9, ptr %arrayidx3, align 4\n %cmp = icmp ugt i64 %indvars.iv, 1\n %indvars.iv.next = add nsw i64 %indvars.iv, -1\n br i1 %cmp, label %for.body, label %for.cond.cleanup, !llvm.loop !0\n}\n\n!0 = distinct !{!0, !1, !2, !3, !4}\n!1 = !{!\"llvm.loop.mustprogress\"}\n!2 = !{!\"llvm.loop.vectorize.width\", i32 4}\n!3 = !{!\"llvm.loop.vectorize.scalable.enable\", i1 true}\n!4 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "vector_reverse_f32",
"test_body": "define void @vector_reverse_f32(ptr nocapture noundef writeonly %A, ptr nocapture noundef readonly %B, i32 noundef signext %n) {\nentry:\n %cmp7 = icmp sgt i32 %n, 0\n br i1 %cmp7, label %for.body.preheader, label %for.cond.cleanup\n\nfor.body.preheader: ; preds = %entry\n %0 = zext i32 %n to i64\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 %indvars.iv = phi i64 [ %0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]\n %i.0.in8 = phi i32 [ %n, %for.body.preheader ], [ %i.0, %for.body ]\n %i.0 = add nsw i32 %i.0.in8, -1\n %idxprom = zext i32 %i.0 to i64\n %arrayidx = getelementptr inbounds float, ptr %B, i64 %idxprom\n %1 = load float, ptr %arrayidx, align 4\n %conv1 = fadd float %1, 1.000000e+00\n %arrayidx3 = getelementptr inbounds float, ptr %A, i64 %idxprom\n store float %conv1, ptr %arrayidx3, align 4\n %cmp = icmp ugt i64 %indvars.iv, 1\n %indvars.iv.next = add nsw i64 %indvars.iv, -1\n br i1 %cmp, label %for.body, label %for.cond.cleanup, !llvm.loop !0\n}\n\n!0 = distinct !{!0, !1, !2, !3, !4}\n!1 = !{!\"llvm.loop.mustprogress\"}\n!2 = !{!\"llvm.loop.vectorize.width\", i32 4}\n!3 = !{!\"llvm.loop.vectorize.scalable.enable\", i1 true}\n!4 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[VPlan] VPlan cost model and legacy cost model disagreed",
"body": "Related: #99701, #92555. @fhahn Please let me know if you'd prefer these assert triggering testcases to be all in the same issue or prefer a new issue when a new testcase is found.\r\n\r\nTested using llvm f719a339a89b\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 i32 @main(ptr %0) #0 {\r\nentry:\r\n br label %for.body\r\n\r\nfor.cond.cleanup: ; preds = %for.body\r\n %.lcssa = phi i8 [ %1, %for.body ]\r\n ret i32 0\r\n\r\nfor.body: ; preds = %for.body, %entry\r\n %l.011 = phi i32 [ 0, %entry ], [ %add, %for.body ]\r\n %idxprom = sext i32 %l.011 to i64\r\n %arrayidx1 = getelementptr [15 x i8], ptr %0, i64 0, i64 %idxprom\r\n %1 = load i8, ptr %arrayidx1, align 1\r\n %arrayidx3 = getelementptr [0 x i8], ptr null, i64 0, i64 %idxprom\r\n store i8 0, ptr %arrayidx3, align 1\r\n %add = add i32 %l.011, 4\r\n %cmp = icmp ult i32 %l.011, -9\r\n br i1 %cmp, label %for.body, label %for.cond.cleanup\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-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,-zvl256b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\n```\r\n\r\nCommand/backtrace:\r\n```\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes loop-vectorize reduced.ll -S\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10098: 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 \"main\"\r\n #0 0x0000647de5790dd0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2f1ddd0)\r\n #1 0x0000647de578e1ef llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2f1b1ef)\r\n #2 0x0000647de578e345 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007b2a02842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007b2a028969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007b2a028969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007b2a028969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x00007b2a02842476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007b2a028287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x00007b2a0282871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x00007b2a02839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x0000647de47acc98 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f39c98)\r\n#12 0x0000647de47af851 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+0x1f3c851)\r\n#13 0x0000647de47affd0 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f3cfd0)\r\n#14 0x0000647de3621ff6 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+0xdaeff6)\r\n#15 0x0000647de55a8e7e 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+0x2d35e7e)\r\n#16 0x0000647de3625186 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+0xdb2186)\r\n#17 0x0000647de55a7c0b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2d34c0b)\r\n#18 0x0000647de36214d6 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+0xdae4d6)\r\n#19 0x0000647de55a5d5d 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+0x2d32d5d)\r\n#20 0x0000647de2e6b5d6 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+0x5f85d6)\r\n#21 0x0000647de2e5d211 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5ea211)\r\n#22 0x00007b2a02829d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#23 0x00007b2a02829e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#24 0x00007b2a02829e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#25 0x0000647de2e530a5 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5e00a5)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\n\r\nGodbolt: https://godbolt.org/z/z7ee8hWWP",
"author": "patrick-rivos",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "fhahn",
"body": "@patrick-rivos thanks for the report. I think it would be best to keep filing separate issues, as the underlying issues usually are different. Although the fuzzers may generate many instances of the same issue as was the case for https://github.com/llvm/llvm-project/issues/99701. Not sure if there's an easy way to catch that other than waiting for a day or so after filing the first issue."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
99899
|
https://github.com/llvm/llvm-project/issues/99899
|
crash
|
9a8b0407fc16af4ca6f79a2583297318a645d88a
| 2024-07-22T17:02:03 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "3cb82f49dc990dc20a765856c0e126193992fe44",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
9699,
9705
]
],
"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::getEntryCost"
],
"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 3cb82f49dc990dc20a765856c0e126193992fe44
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Mon Jul 22 12:45:28 2024 -0700
[SLP]Fix PR99899: Use canonical type instead of original vector of ptr.
Use adjusted canonical integer type instead of the original ptr type to
fix the crash in the TTI.
Fixes https://github.com/llvm/llvm-project/issues/99899
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 667c4eb311c2..cca9eeebaa53 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -9699,7 +9699,8 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
CanonicalType = CanonicalType->getWithNewType(IntegerType::get(
CanonicalType->getContext(),
DL->getTypeSizeInBits(CanonicalType->getScalarType())));
- IntrinsicCostAttributes CostAttrs(MinMaxID, VecTy, {VecTy, VecTy});
+ IntrinsicCostAttributes CostAttrs(MinMaxID, CanonicalType,
+ {CanonicalType, CanonicalType});
InstructionCost IntrinsicCost =
TTI->getIntrinsicInstrCost(CostAttrs, CostKind);
// If the selects are the only uses of the compares, they will be
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/SystemZ/cmp-ptr-minmax.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=s390x-unknown-linux-gnu -mcpu=z16 -slp-threshold=-10 < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine i1 @test(i64 %0, i64 %1, ptr %2) {\n;\nentry:\n %gep44 = getelementptr i8, ptr null, i64 %0\n %gep45 = getelementptr i8, ptr null, i64 %1\n %4 = icmp ult ptr %gep44, %gep45\n %umin = select i1 %4, ptr %gep44, ptr %gep45\n %gep48 = getelementptr i8, ptr null, i64 %0\n %gep49 = getelementptr i8, ptr null, i64 %1\n %5 = icmp ult ptr %gep48, %gep49\n %umin50 = select i1 %5, ptr %gep48, ptr %gep49\n %b095 = icmp ult ptr %umin, %2\n %b196 = icmp ult ptr %umin50, %2\n %res = and i1 %b095, %b196\n ret i1 %res\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SLP] crash after 8ff233f",
"body": "8ff233f \"[SLP]Correctly detect minnum/maxnum patterns for select/cmp operations on floats.\" seems to have introduced a problem when building SPEC on SystemZ.\r\n\r\nopt -mtriple=s390x-linux-gnu -mcpu=z16 -O3 ./tc_slp.ll -o /dev/null\r\nopt: /home/ijonpan/llvm-project/llvm/include/llvm/IR/DerivedTypes.h:704: llvm::Type* llvm::Type::getWithNewBitWidth(unsigned int) const: Assertion `isIntOrIntVectorTy() && \"Original type expected to be a vector of integers or a scalar integer.\"' failed.\r\n...\r\n#15 0x000000000519c8f8 llvm::slpvectorizer::BoUpSLP::getEntryCost\r\n\r\n[tc_slp.ll.tar.gz](https://github.com/user-attachments/files/16337301/tc_slp.ll.tar.gz)\r\n",
"author": "JonPsson1",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
85536
|
https://github.com/llvm/llvm-project/issues/85536
|
miscompilation
|
f84980570d3f85bdf5c9432647c05bae04a735a0
| 2024-03-16T15:33:21 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "252d01952c087cf0d141f7f281cf60efeb98be41",
"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": [
[
1650,
1655
]
],
"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": [
"foldOperationIntoSelectOperand"
],
"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 252d01952c087cf0d141f7f281cf60efeb98be41
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Sun Mar 17 14:15:27 2024 +0800
[InstCombine] Drop UB-implying attrs/metadata after speculating an instruction (#85542)
When speculating an instruction in `InstCombinerImpl::FoldOpIntoSelect`,
the call may result in undefined behavior. This patch drops all
UB-implying attrs/metadata to fix this.
Fixes #85536.
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index edb046defbc1..5d3e41fb5f29 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -1650,6 +1650,7 @@ static Value *foldOperationIntoSelectOperand(Instruction &I, SelectInst *SI,
Value *NewOp, InstCombiner &IC) {
Instruction *Clone = I.clone();
Clone->replaceUsesOfWith(SI, NewOp);
+ Clone->dropUBImplyingAttrsAndMetadata();
IC.InsertNewInstBefore(Clone, SI->getIterator());
return Clone;
}
|
[
{
"file": "llvm/test/Transforms/InstCombine/intrinsic-select.ll",
"commands": [
"opt -passes=instcombine -S < %s"
],
"tests": [
{
"test_name": "test_drop_noundef",
"test_body": "define i8 @test_drop_noundef(i1 %cond, i8 %val) {\nentry:\n %sel = select i1 %cond, i8 -1, i8 %val\n %ret = call noundef i8 @llvm.smin.i8(i8 %sel, i8 0)\n ret i8 %ret\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
},
{
"test_name": "pr85536",
"test_body": "define i1 @pr85536(i32 %a) {\nentry:\n %cmp1 = icmp ugt i32 %a, 30\n %shl1 = shl nsw i32 -1, %a\n %zext = zext i32 %shl1 to i64\n %shl2 = shl i64 %zext, 48\n %shr = ashr exact i64 %shl2, 48\n %sel = select i1 %cmp1, i64 -1, i64 %shr\n %smin = call noundef i64 @llvm.smin.i64(i64 %sel, i64 0)\n %masked = and i64 %smin, 65535\n %ret = icmp eq i64 %masked, 0\n ret i1 %ret\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i64 @llvm.smin.i64(i64, i64) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "vec_to_scalar_select_vector",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.vector.reduce.add.v2i32(<2 x i32>) #0\n\ndefine i32 @vec_to_scalar_select_vector(<2 x i1> %b) {\n %s = select <2 x i1> %b, <2 x i32> <i32 1, i32 2>, <2 x i32> <i32 3, i32 4>\n %c = call i32 @llvm.vector.reduce.add.v2i32(<2 x i32> %s)\n ret i32 %c\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstCombine] Miscompile at -O1",
"body": "Reduced test case: https://godbolt.org/z/z1a3665hd\r\n```\r\n#include <stdio.h>\r\n#include <stdint.h>\r\nstatic uint16_t\r\n(safe_lshift_func_uint16_t_u_s)(uint16_t left, int right )\r\n{\r\n return\r\n ((((int)right) < 0) || (((int)right) >= 32) || (left > ((65535) >> ((int)right)))) ?\r\n ((left)) :\r\n (left << ((int)right));\r\n}\r\nstatic int16_t\r\n(safe_unary_minus_func_int16_t_s)(int16_t si )\r\n{\r\n return\r\n -si;\r\n}\r\nstatic int32_t\r\n(safe_lshift_func_int32_t_s_u)(int32_t left, unsigned int right )\r\n{\r\n return\r\n ((left < 0) || (((unsigned int)right) >= 32) || (left > ((2147483647) >> ((unsigned int)right)))) ?\r\n ((left)) :\r\n (left << ((unsigned int)right));\r\n}\r\nlong smin(long d, long p) { return d < p ? d : p; }\r\nstruct e { uint32_t f; } static g[] = {1, 36};\r\nint64_t h, i;\r\nuint8_t j(uint64_t m) {\r\n if (safe_lshift_func_uint16_t_u_s(\r\n smin(m, safe_unary_minus_func_int16_t_s(\r\n safe_lshift_func_int32_t_s_u(1, g[1].f))),\r\n 3))\r\n h = 0;\r\n return m;\r\n}\r\nint8_t k() {\r\n j(0);\r\n struct e *l[] = {&g[1], &g[1], &g[1], &g[1], &g[1],\r\n &g[1], &g[1], &g[1], &g[1]};\r\n return i;\r\n}\r\nint main() {\r\n printf(\"%d\\n\", k());\r\n return 0;\r\n}\r\n```\r\n\r\n```\r\n> gcc -O0 -fsanitize=address,undefined -w test.c && ./a.out\r\n0\r\n> clang -O3 -w test.c && ./a.out\r\n; no output\r\n```\r\n\r\nReduced LLVM IR: https://alive2.llvm.org/ce/z/hWuhFG\r\n```\r\n%struct.e = type { i32 }\r\n\r\n@g = internal global [2 x %struct.e] [%struct.e { i32 1 }, %struct.e { i32 36 }], align 4\r\n@h = dso_local local_unnamed_addr global i64 0, align 8\r\n@i = dso_local local_unnamed_addr global i64 0, align 8\r\n\r\ndefine i8 @src() {\r\nentry:\r\n %0 = load i32, ptr getelementptr inbounds ([2 x %struct.e], ptr @g, i64 0, i64 1), align 4\r\n %or.cond.i.i = icmp ult i32 %0, 31\r\n %shl.i.neg.i = shl nsw i32 -1, %0\r\n %.neg.i = zext i32 %shl.i.neg.i to i64\r\n %sext.i = shl i64 %.neg.i, 48\r\n %1 = ashr exact i64 %sext.i, 48\r\n %2 = call i64 @llvm.smin.i64(i64 %1, i64 0)\r\n %3 = and i64 %2, 65535\r\n %tobool.not9.i1 = icmp eq i64 %3, 0\r\n %tobool.not9.i = and i1 %or.cond.i.i, %tobool.not9.i1\r\n br i1 %tobool.not9.i, label %j.exit, label %if.then.i\r\n\r\nif.then.i:\r\n store i64 0, ptr @h, align 8\r\n br label %j.exit\r\n\r\nj.exit:\r\n %4 = load i64, ptr @i, align 8\r\n %conv = trunc i64 %4 to i8\r\n ret i8 %conv\r\n}\r\n\r\n==>\r\n\r\ndefine i8 @tgt() {\r\n ret i8 poison\r\n}\r\n```\r\n\r\nLLVM version: 74d1a40915834cbf0629f8d34a7265734d4d9073\r\n\r\ncc @nikic ",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Reduced IR: https://alive2.llvm.org/ce/z/Gv9zkm\r\n```\r\n@g = internal global [1 x i32] [i32 1], align 4\r\n\r\ndefine i32 @k() {\r\nentry:\r\n %ret = load i32, ptr getelementptr inbounds ([1 x i32], ptr @g, i64 0), align 4\r\n ret i32 %ret\r\n}\r\n\r\n==>\r\ndefine i32 @k() {\r\nentry:\r\n ret i32 1\r\n}\r\n```\r\n"
},
{
"author": "nikic",
"body": "@dtcxzyw That last transform is correct for GlobalOpt, alive2 does not support IPO transforms."
},
{
"author": "dtcxzyw",
"body": "> @dtcxzyw That last transform is correct for GlobalOpt, alive2 does not support IPO transforms.\r\n\r\nOh, sorry about my mistake. I will provide a godbolt link.\r\n\r\n\r\n"
},
{
"author": "dtcxzyw",
"body": "The root cause: https://alive2.llvm.org/ce/z/ThJs3Y\r\n```\r\ndefine i1 @src(i32 %a) {\r\nentry:\r\n %or.cond.i.i = icmp ugt i32 %a, 30\r\n %shl.i.neg.i = shl nsw i32 -1, %a\r\n %.neg.i = zext i32 %shl.i.neg.i to i64\r\n %sext.i = shl i64 %.neg.i, 48\r\n %1 = ashr exact i64 %sext.i, 48\r\n %conv2.i = select i1 %or.cond.i.i, i64 -1, i64 %1\r\n %cond.i8.i = call noundef i64 @llvm.smin.i64(i64 0, i64 %conv2.i)\r\n %2 = and i64 %cond.i8.i, 65535\r\n %tobool.not9.i = icmp eq i64 %2, 0\r\n ret i1 %tobool.not9.i\r\n}\r\n\r\n==> \r\n\r\ndefine i1 @tgt(i32 %a) {\r\nentry:\r\n %or.cond.i.i = icmp ult i32 %a, 31\r\n %shl.i.neg.i = shl nsw i32 -1, %a\r\n %.neg.i = zext i32 %shl.i.neg.i to i64\r\n %sext.i = shl i64 %.neg.i, 48\r\n %0 = ashr exact i64 %sext.i, 48\r\n %1 = call noundef i64 @llvm.smin.i64(i64 %0, i64 0)\r\n %2 = and i64 %1, 65535\r\n %tobool.not9.i1 = icmp eq i64 %2, 0\r\n %tobool.not9.i = and i1 %or.cond.i.i, %tobool.not9.i1\r\n ret i1 %tobool.not9.i\r\n}\r\n```"
},
{
"author": "dtcxzyw",
"body": "We forget to drop the `noundef` attribute for `smin` :(\r\n"
},
{
"author": "dtcxzyw",
"body": "Minimal reproducer: https://alive2.llvm.org/ce/z/aBubZ4\r\n```\r\ndefine i8 @src(i1 %cond, i8 %val) {\r\nentry:\r\n %sel = select i1 %cond, i8 -1, i8 %val\r\n %ret = call noundef i8 @llvm.smin.i8(i8 %sel, i8 0)\r\n ret i8 %ret\r\n}\r\n\r\n==>\r\n\r\ndefine i8 @tgt(i1 %cond, i8 %val) {\r\n %min = call noundef i8 @llvm.smin.i8(i8 %val, i8 0)\r\n %ret = select i1 %cond, i8 -1, i8 %min\r\n ret i8 %ret\r\n}\r\n```\r\n\r\n"
},
{
"author": "nikic",
"body": "@dtcxzyw We're probably missing a call to dropUBImplyingAttrsAndMetadata in FoldOpIntoSelect."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
91417
|
https://github.com/llvm/llvm-project/issues/91417
|
miscompilation
|
d9507a3e10d1750d88dd518c14b9a9a62b9eefcd
| 2024-05-08T01:40:37 |
[
"llvm/test/Transforms/Reassociate"
] |
{
"fix_commit": "645fb04a3389e69801d401e669eae9ee42d70217",
"components": [
"Reassociate"
],
"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": [
[
302,
399
],
[
475,
481
],
[
490,
497
],
[
509,
515
],
[
518,
525
],
[
528,
534
],
[
562,
568
],
[
625,
634
],
[
642,
648
],
[
1188,
1195
],
[
2368,
2374
]
],
"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": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": [
"CarmichaelShift",
"IncorporateWeight",
"LinearizeExprTree",
"LowerNegateToMultiply",
"ReassociatePass::ReassociateExpression",
"ReassociatePass::RemoveFactorFromExpression"
],
"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 645fb04a3389e69801d401e669eae9ee42d70217
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Sat Jun 8 22:28:56 2024 +0800
[Reassociate] Use uint64_t for repeat count (#94232)
This patch relands #91469 and uses `uint64_t` for repeat count to avoid
a miscompilation caused by overflow
https://github.com/llvm/llvm-project/pull/91469#discussion_r1623925158.
diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp
index c73d7c8d83be..f36e21b296bd 100644
--- a/llvm/lib/Transforms/Scalar/Reassociate.cpp
+++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp
@@ -302,98 +302,7 @@ static BinaryOperator *LowerNegateToMultiply(Instruction *Neg) {
return Res;
}
-/// Returns k such that lambda(2^Bitwidth) = 2^k, where lambda is the Carmichael
-/// function. This means that x^(2^k) === 1 mod 2^Bitwidth for
-/// every odd x, i.e. x^(2^k) = 1 for every odd x in Bitwidth-bit arithmetic.
-/// Note that 0 <= k < Bitwidth, and if Bitwidth > 3 then x^(2^k) = 0 for every
-/// even x in Bitwidth-bit arithmetic.
-static unsigned CarmichaelShift(unsigned Bitwidth) {
- if (Bitwidth < 3)
- return Bitwidth - 1;
- return Bitwidth - 2;
-}
-
-/// Add the extra weight 'RHS' to the existing weight 'LHS',
-/// reducing the combined weight using any special properties of the operation.
-/// The existing weight LHS represents the computation X op X op ... op X where
-/// X occurs LHS times. The combined weight represents X op X op ... op X with
-/// X occurring LHS + RHS times. If op is "Xor" for example then the combined
-/// operation is equivalent to X if LHS + RHS is odd, or 0 if LHS + RHS is even;
-/// the routine returns 1 in LHS in the first case, and 0 in LHS in the second.
-static void IncorporateWeight(APInt &LHS, const APInt &RHS, unsigned Opcode) {
- // If we were working with infinite precision arithmetic then the combined
- // weight would be LHS + RHS. But we are using finite precision arithmetic,
- // and the APInt sum LHS + RHS may not be correct if it wraps (it is correct
- // for nilpotent operations and addition, but not for idempotent operations
- // and multiplication), so it is important to correctly reduce the combined
- // weight back into range if wrapping would be wrong.
-
- // If RHS is zero then the weight didn't change.
- if (RHS.isMinValue())
- return;
- // If LHS is zero then the combined weight is RHS.
- if (LHS.isMinValue()) {
- LHS = RHS;
- return;
- }
- // From this point on we know that neither LHS nor RHS is zero.
-
- if (Instruction::isIdempotent(Opcode)) {
- // Idempotent means X op X === X, so any non-zero weight is equivalent to a
- // weight of 1. Keeping weights at zero or one also means that wrapping is
- // not a problem.
- assert(LHS == 1 && RHS == 1 && "Weights not reduced!");
- return; // Return a weight of 1.
- }
- if (Instruction::isNilpotent(Opcode)) {
- // Nilpotent means X op X === 0, so reduce weights modulo 2.
- assert(LHS == 1 && RHS == 1 && "Weights not reduced!");
- LHS = 0; // 1 + 1 === 0 modulo 2.
- return;
- }
- if (Opcode == Instruction::Add || Opcode == Instruction::FAdd) {
- // TODO: Reduce the weight by exploiting nsw/nuw?
- LHS += RHS;
- return;
- }
-
- assert((Opcode == Instruction::Mul || Opcode == Instruction::FMul) &&
- "Unknown associative operation!");
- unsigned Bitwidth = LHS.getBitWidth();
- // If CM is the Carmichael number then a weight W satisfying W >= CM+Bitwidth
- // can be replaced with W-CM. That's because x^W=x^(W-CM) for every Bitwidth
- // bit number x, since either x is odd in which case x^CM = 1, or x is even in
- // which case both x^W and x^(W - CM) are zero. By subtracting off multiples
- // of CM like this weights can always be reduced to the range [0, CM+Bitwidth)
- // which by a happy accident means that they can always be represented using
- // Bitwidth bits.
- // TODO: Reduce the weight by exploiting nsw/nuw? (Could do much better than
- // the Carmichael number).
- if (Bitwidth > 3) {
- /// CM - The value of Carmichael's lambda function.
- APInt CM = APInt::getOneBitSet(Bitwidth, CarmichaelShift(Bitwidth));
- // Any weight W >= Threshold can be replaced with W - CM.
- APInt Threshold = CM + Bitwidth;
- assert(LHS.ult(Threshold) && RHS.ult(Threshold) && "Weights not reduced!");
- // For Bitwidth 4 or more the following sum does not overflow.
- LHS += RHS;
- while (LHS.uge(Threshold))
- LHS -= CM;
- } else {
- // To avoid problems with overflow do everything the same as above but using
- // a larger type.
- unsigned CM = 1U << CarmichaelShift(Bitwidth);
- unsigned Threshold = CM + Bitwidth;
- assert(LHS.getZExtValue() < Threshold && RHS.getZExtValue() < Threshold &&
- "Weights not reduced!");
- unsigned Total = LHS.getZExtValue() + RHS.getZExtValue();
- while (Total >= Threshold)
- Total -= CM;
- LHS = Total;
- }
-}
-
-using RepeatedValue = std::pair<Value*, APInt>;
+using RepeatedValue = std::pair<Value *, uint64_t>;
/// Given an associative binary expression, return the leaf
/// nodes in Ops along with their weights (how many times the leaf occurs). The
@@ -475,7 +384,6 @@ static bool LinearizeExprTree(Instruction *I,
assert((isa<UnaryOperator>(I) || isa<BinaryOperator>(I)) &&
"Expected a UnaryOperator or BinaryOperator!");
LLVM_DEBUG(dbgs() << "LINEARIZE: " << *I << '\n');
- unsigned Bitwidth = I->getType()->getScalarType()->getPrimitiveSizeInBits();
unsigned Opcode = I->getOpcode();
assert(I->isAssociative() && I->isCommutative() &&
"Expected an associative and commutative operation!");
@@ -490,8 +398,8 @@ static bool LinearizeExprTree(Instruction *I,
// with their weights, representing a certain number of paths to the operator.
// If an operator occurs in the worklist multiple times then we found multiple
// ways to get to it.
- SmallVector<std::pair<Instruction*, APInt>, 8> Worklist; // (Op, Weight)
- Worklist.push_back(std::make_pair(I, APInt(Bitwidth, 1)));
+ SmallVector<std::pair<Instruction *, uint64_t>, 8> Worklist; // (Op, Weight)
+ Worklist.push_back(std::make_pair(I, 1));
bool Changed = false;
// Leaves of the expression are values that either aren't the right kind of
@@ -509,7 +417,7 @@ static bool LinearizeExprTree(Instruction *I,
// Leaves - Keeps track of the set of putative leaves as well as the number of
// paths to each leaf seen so far.
- using LeafMap = DenseMap<Value *, APInt>;
+ using LeafMap = DenseMap<Value *, uint64_t>;
LeafMap Leaves; // Leaf -> Total weight so far.
SmallVector<Value *, 8> LeafOrder; // Ensure deterministic leaf output order.
const DataLayout DL = I->getModule()->getDataLayout();
@@ -518,8 +426,8 @@ static bool LinearizeExprTree(Instruction *I,
SmallPtrSet<Value *, 8> Visited; // For checking the iteration scheme.
#endif
while (!Worklist.empty()) {
- std::pair<Instruction*, APInt> P = Worklist.pop_back_val();
- I = P.first; // We examine the operands of this binary operator.
+ // We examine the operands of this binary operator.
+ auto [I, Weight] = Worklist.pop_back_val();
if (isa<OverflowingBinaryOperator>(I)) {
Flags.HasNUW &= I->hasNoUnsignedWrap();
@@ -528,7 +436,6 @@ static bool LinearizeExprTree(Instruction *I,
for (unsigned OpIdx = 0; OpIdx < I->getNumOperands(); ++OpIdx) { // Visit operands.
Value *Op = I->getOperand(OpIdx);
- APInt Weight = P.second; // Number of paths to this operand.
LLVM_DEBUG(dbgs() << "OPERAND: " << *Op << " (" << Weight << ")\n");
assert(!Op->use_empty() && "No uses, so how did we get to it?!");
@@ -562,7 +469,8 @@ static bool LinearizeExprTree(Instruction *I,
"In leaf map but not visited!");
// Update the number of paths to the leaf.
- IncorporateWeight(It->second, Weight, Opcode);
+ It->second += Weight;
+ assert(It->second >= Weight && "Weight overflows");
// If we still have uses that are not accounted for by the expression
// then it is not safe to modify the value.
@@ -625,10 +533,7 @@ static bool LinearizeExprTree(Instruction *I,
// Node initially thought to be a leaf wasn't.
continue;
assert(!isReassociableOp(V, Opcode) && "Shouldn't be a leaf!");
- APInt Weight = It->second;
- if (Weight.isMinValue())
- // Leaf already output or weight reduction eliminated it.
- continue;
+ uint64_t Weight = It->second;
// Ensure the leaf is only output once.
It->second = 0;
Ops.push_back(std::make_pair(V, Weight));
@@ -642,7 +547,7 @@ static bool LinearizeExprTree(Instruction *I,
if (Ops.empty()) {
Constant *Identity = ConstantExpr::getBinOpIdentity(Opcode, I->getType());
assert(Identity && "Associative operation without identity!");
- Ops.emplace_back(Identity, APInt(Bitwidth, 1));
+ Ops.emplace_back(Identity, 1);
}
return Changed;
@@ -1188,8 +1093,7 @@ Value *ReassociatePass::RemoveFactorFromExpression(Value *V, Value *Factor) {
Factors.reserve(Tree.size());
for (unsigned i = 0, e = Tree.size(); i != e; ++i) {
RepeatedValue E = Tree[i];
- Factors.append(E.second.getZExtValue(),
- ValueEntry(getRank(E.first), E.first));
+ Factors.append(E.second, ValueEntry(getRank(E.first), E.first));
}
bool FoundFactor = false;
@@ -2368,7 +2272,7 @@ void ReassociatePass::ReassociateExpression(BinaryOperator *I) {
SmallVector<ValueEntry, 8> Ops;
Ops.reserve(Tree.size());
for (const RepeatedValue &E : Tree)
- Ops.append(E.second.getZExtValue(), ValueEntry(getRank(E.first), E.first));
+ Ops.append(E.second, ValueEntry(getRank(E.first), E.first));
LLVM_DEBUG(dbgs() << "RAIn:\t"; PrintOps(I, Ops); dbgs() << '\n');
|
[
{
"file": "llvm/test/Transforms/Reassociate/repeats.ll",
"commands": [
"opt < %s -passes=reassociate -S"
],
"tests": [
{
"test_name": "foo4x11",
"test_body": "define i4 @foo4x11(i4 %x) {\n %tmp1 = mul i4 %x, %x\n %tmp2 = mul i4 %tmp1, %x\n %tmp3 = mul i4 %tmp2, %x\n %tmp4 = mul i4 %tmp3, %x\n %tmp5 = mul i4 %tmp4, %x\n %tmp6 = mul i4 %tmp5, %x\n %tmp7 = mul i4 %tmp6, %x\n %tmp8 = mul i4 %tmp7, %x\n %tmp9 = mul i4 %tmp8, %x\n %tmp10 = mul i4 %tmp9, %x\n ret i4 %tmp10\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "foo3x5_nsw",
"test_body": "define i3 @foo3x5_nsw(i3 %x) {\n %tmp1 = mul i3 %x, %x\n %tmp2 = mul i3 %tmp1, %x\n %tmp3 = mul i3 %tmp2, %x\n %tmp4 = mul nsw i3 %tmp3, %x\n ret i3 %tmp4\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "foo3x5",
"test_body": "define i3 @foo3x5(i3 %x) {\n %tmp1 = mul i3 %x, %x\n %tmp2 = mul i3 %tmp1, %x\n %tmp3 = mul i3 %tmp2, %x\n %tmp4 = mul i3 %tmp3, %x\n ret i3 %tmp4\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "foo4x10",
"test_body": "define i4 @foo4x10(i4 %x) {\n %tmp1 = mul i4 %x, %x\n %tmp2 = mul i4 %tmp1, %x\n %tmp3 = mul i4 %tmp2, %x\n %tmp4 = mul i4 %tmp3, %x\n %tmp5 = mul i4 %tmp4, %x\n %tmp6 = mul i4 %tmp5, %x\n %tmp7 = mul i4 %tmp6, %x\n %tmp8 = mul i4 %tmp7, %x\n %tmp9 = mul i4 %tmp8, %x\n ret i4 %tmp9\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "foo4x13",
"test_body": "define i4 @foo4x13(i4 %x) {\n %tmp1 = mul i4 %x, %x\n %tmp2 = mul i4 %tmp1, %x\n %tmp3 = mul i4 %tmp2, %x\n %tmp4 = mul i4 %tmp3, %x\n %tmp5 = mul i4 %tmp4, %x\n %tmp6 = mul i4 %tmp5, %x\n %tmp7 = mul i4 %tmp6, %x\n %tmp8 = mul i4 %tmp7, %x\n %tmp9 = mul i4 %tmp8, %x\n %tmp10 = mul i4 %tmp9, %x\n %tmp11 = mul i4 %tmp10, %x\n %tmp12 = mul i4 %tmp11, %x\n ret i4 %tmp12\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "foo4x8",
"test_body": "define i4 @foo4x8(i4 %x) {\n %tmp1 = mul i4 %x, %x\n %tmp2 = mul i4 %tmp1, %x\n %tmp3 = mul i4 %tmp2, %x\n %tmp4 = mul i4 %tmp3, %x\n %tmp5 = mul i4 %tmp4, %x\n %tmp6 = mul i4 %tmp5, %x\n %tmp7 = mul i4 %tmp6, %x\n ret i4 %tmp7\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "foo4x12",
"test_body": "define i4 @foo4x12(i4 %x) {\n %tmp1 = mul i4 %x, %x\n %tmp2 = mul i4 %tmp1, %x\n %tmp3 = mul i4 %tmp2, %x\n %tmp4 = mul i4 %tmp3, %x\n %tmp5 = mul i4 %tmp4, %x\n %tmp6 = mul i4 %tmp5, %x\n %tmp7 = mul i4 %tmp6, %x\n %tmp8 = mul i4 %tmp7, %x\n %tmp9 = mul i4 %tmp8, %x\n %tmp10 = mul i4 %tmp9, %x\n %tmp11 = mul i4 %tmp10, %x\n ret i4 %tmp11\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "foo4x15",
"test_body": "define i4 @foo4x15(i4 %x) {\n %tmp1 = mul i4 %x, %x\n %tmp2 = mul i4 %tmp1, %x\n %tmp3 = mul i4 %tmp2, %x\n %tmp4 = mul i4 %tmp3, %x\n %tmp5 = mul i4 %tmp4, %x\n %tmp6 = mul i4 %tmp5, %x\n %tmp7 = mul i4 %tmp6, %x\n %tmp8 = mul i4 %tmp7, %x\n %tmp9 = mul i4 %tmp8, %x\n %tmp10 = mul i4 %tmp9, %x\n %tmp11 = mul i4 %tmp10, %x\n %tmp12 = mul i4 %tmp11, %x\n %tmp13 = mul i4 %tmp12, %x\n %tmp14 = mul i4 %tmp13, %x\n ret i4 %tmp14\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "foo4x9",
"test_body": "define i4 @foo4x9(i4 %x) {\n %tmp1 = mul i4 %x, %x\n %tmp2 = mul i4 %tmp1, %x\n %tmp3 = mul i4 %tmp2, %x\n %tmp4 = mul i4 %tmp3, %x\n %tmp5 = mul i4 %tmp4, %x\n %tmp6 = mul i4 %tmp5, %x\n %tmp7 = mul i4 %tmp6, %x\n %tmp8 = mul i4 %tmp7, %x\n ret i4 %tmp8\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "foo4x14",
"test_body": "define i4 @foo4x14(i4 %x) {\n %tmp1 = mul i4 %x, %x\n %tmp2 = mul i4 %tmp1, %x\n %tmp3 = mul i4 %tmp2, %x\n %tmp4 = mul i4 %tmp3, %x\n %tmp5 = mul i4 %tmp4, %x\n %tmp6 = mul i4 %tmp5, %x\n %tmp7 = mul i4 %tmp6, %x\n %tmp8 = mul i4 %tmp7, %x\n %tmp9 = mul i4 %tmp8, %x\n %tmp10 = mul i4 %tmp9, %x\n %tmp11 = mul i4 %tmp10, %x\n %tmp12 = mul i4 %tmp11, %x\n %tmp13 = mul i4 %tmp12, %x\n ret i4 %tmp13\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "foo3x6",
"test_body": "define i3 @foo3x6(i3 %x) {\n %tmp1 = mul i3 %x, %x\n %tmp2 = mul i3 %tmp1, %x\n %tmp3 = mul i3 %tmp2, %x\n %tmp4 = mul i3 %tmp3, %x\n %tmp5 = mul i3 %tmp4, %x\n ret i3 %tmp5\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "foo3x7",
"test_body": "define i3 @foo3x7(i3 %x) {\n %tmp1 = mul i3 %x, %x\n %tmp2 = mul i3 %tmp1, %x\n %tmp3 = mul i3 %tmp2, %x\n %tmp4 = mul i3 %tmp3, %x\n %tmp5 = mul i3 %tmp4, %x\n %tmp6 = mul i3 %tmp5, %x\n ret i3 %tmp6\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "incorrect reassociation at low bitwidth",
"body": "here's a function:\r\n```llvm\r\ndefine i3 @f(i3 %0) {\r\n %2 = mul i3 %0, %0\r\n %3 = mul i3 %2, %0\r\n %4 = mul i3 %3, %0\r\n %5 = mul nsw i3 %4, %0\r\n ret i3 %5\r\n}\r\n```\r\n\r\nreassociate seems to be getting it wrong:\r\n```\r\nJohns-MacBook-Pro:reduce regehr$ ~/alive2-regehr/build/alive-tv reduced.ll -passes=reassociate\r\n\r\n----------------------------------------\r\ndefine i3 @f(i3 %#0) {\r\n#1:\r\n %#2 = mul i3 %#0, %#0\r\n %#3 = mul i3 %#2, %#0\r\n %#4 = mul i3 %#3, %#0\r\n %#5 = mul nsw i3 %#4, %#0\r\n ret i3 %#5\r\n}\r\n=>\r\ndefine i3 @f(i3 %#0) {\r\n#1:\r\n %#2 = mul i3 %#0, %#0\r\n %#3 = mul nsw i3 %#2, %#0\r\n ret i3 %#3\r\n}\r\nTransformation doesn't verify!\r\n\r\nERROR: Target is more poisonous than source\r\n\r\nExample:\r\ni3 %#0 = #x6 (6, -2)\r\n\r\nSource:\r\ni3 %#2 = #x4 (4, -4)\r\ni3 %#3 = #x0 (0)\r\ni3 %#4 = #x0 (0)\r\ni3 %#5 = #x0 (0)\r\n\r\nTarget:\r\ni3 %#2 = #x4 (4, -4)\r\ni3 %#3 = poison\r\nSource value: #x0 (0)\r\nTarget value: poison\r\n\r\nSummary:\r\n 0 correct transformations\r\n 1 incorrect transformations\r\n 0 failed-to-prove transformations\r\n 0 Alive2 errors\r\nJohns-MacBook-Pro:reduce regehr$ \r\n```\r\n\r\ncc @nunoplopes ",
"author": "regehr",
"labels": [
"miscompilation",
"llvm:transforms"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Introduced by https://github.com/llvm/llvm-project/commit/d7aeefebd6b049f017711cd7c6ef5f217a17b673.\r\n"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
98143
|
https://github.com/llvm/llvm-project/issues/98143
|
crash
|
f4be6812e203690073280b9ac8d60092d75bbdce
| 2024-07-09T10:43:20 |
[
"llvm/test/Instrumentation/NumericalStabilitySanitizer"
] |
{
"fix_commit": "70a9535f714e2fdb84af243a1a316012c8019049",
"components": [
"Instrumentation"
],
"bug_location_lineno": {
"llvm/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": [
[
1725,
1730
]
],
"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": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": [
"NumericalStabilitySanitizer::createShadowValueWithOperandsAvailable"
],
"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 70a9535f714e2fdb84af243a1a316012c8019049
Author: Alexander Shaposhnikov <ashaposhnikov@google.com>
Date: Thu Jul 25 21:34:08 2024 -0700
[Instrumentation][nsan] Add support for Freeze instruction (#100490)
Add support for Freeze.
This fixes https://github.com/llvm/llvm-project/issues/98143 .
diff --git a/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp
index b382fedde027..832506f639a7 100644
--- a/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp
@@ -1725,6 +1725,9 @@ Value *NumericalStabilitySanitizer::createShadowValueWithOperandsAvailable(
Map.getShadow(S->getTrueValue()),
Map.getShadow(S->getFalseValue()));
+ if (auto *Freeze = dyn_cast<FreezeInst>(&Inst))
+ return Builder.CreateFreeze(Map.getShadow(Freeze->getOperand(0)));
+
if (auto *Extract = dyn_cast<ExtractElementInst>(&Inst))
return Builder.CreateExtractElement(
Map.getShadow(Extract->getVectorOperand()), Extract->getIndexOperand());
|
[
{
"file": "llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll",
"commands": [
"opt -passes=nsan -nsan-shadow-type-mapping=dqq -nsan-truncate-fcmp-eq=false -S %s",
"opt -passes=nsan -nsan-shadow-type-mapping=dlq -nsan-truncate-fcmp-eq=false -S %s"
],
"tests": [
{
"test_name": "freeze_vector_insert",
"test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\n; Function Attrs: sanitize_numerical_stability\ndefine void @freeze_vector_insert(<2 x float> %vec, i32 %idx, float %scalar) #0 {\nentry:\n %0 = insertelement <2 x float> %vec, float %scalar, i32 %idx\n %frozen = freeze <2 x float> %0\n ret void\n}\n\nattributes #0 = { sanitize_numerical_stability }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "vector_shuffle",
"test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\n; Function Attrs: sanitize_numerical_stability\ndefine void @vector_shuffle(<2 x float> %0) #0 {\nentry:\n %1 = shufflevector <2 x float> %0, <2 x float> splat (float 1.000000e+00), <2 x i32> <i32 1, i32 3>\n ret void\n}\n\nattributes #0 = { sanitize_numerical_stability }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "ICE: Unimplemented support for freeze compiling with numerical sanitizer",
"body": "```\r\nfatal error: error in backend: Unimplemented support for freeze\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0. Program arguments: /afs/cern.ch/user/i/innocent/w5/bin/clang++ -c -DGNU_GCC -D_GNU_SOURCE -DTBB_USE_GLIBCXX_VERSION=120301 -DTBB_SUPPRESS_DEPRECATED_MESSAGES -DTBB_PREVIEW_RESUMABLE_TASKS=1 -DTBB_PREVIEW_TASK_GROUP_EXTENSIONS=1 -DBOOST_SPIRIT_THREADSAFE -DPHOENIX_THREADSAFE -DBOOST_MATH_DISABLE_STD_FPCLASSIFY -DBOOST_UUID_RANDOM_PROVIDER_FORCE_POSIX -DCMSSW_GIT_HASH=\\\"CMSSW_14_1_CLANG_X_2024-07-07-2300\\\" -DPROJECT_NAME=\\\"CMSSW\\\" -DPROJECT_VERSION=\\\"CMSSW_14_1_CLANG_X_2024-07-07-2300\\\" -Isrc -I/cvmfs/cms-ib.cern.ch/sw/x86_64/week1/el8_amd64_gcc12/cms/cmssw/CMSSW_14_1_CLANG_X_2024-07-07-2300/src -I/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/alpaka/1.1.0-0a6641b4bfdf883c8da5b9e8620be504/include -I/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/pcre/8.43-e34796d17981e9b6d174328c69446455/include -isystem/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/boost/1.80.0-a1544032d9d65904ac2112b6d35bba55/include -I/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/bz2lib/1.0.6-d065ccd79984efc6d4660f410e4c81de/include -isystem/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/clhep/2.4.7.1-8e40efd27b7394c1fa4e9c7e432d85cd/include -I/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/gsl/2.6-5e2ce72ea2977ff21a2344bbb52daf5c/include -isystem/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/hls/2019.08-0e37f055a3ed22611ce5edecb14d0695/include -I/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/libuuid/2.34-27ce4c3579b5b1de2808ea9c4cd8ed29/include -isystem/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/lcg/root/6.30.07-5b5d83179d6ed7bc60aa7a5006899eba/include -isystem/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/tbb/v2021.9.0-1dc6d66b4b014f4ae4733b04914ce7d4/include -I/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/cms/vdt/0.4.3-f094bee80112624813c07f9336e08d7d/include -I/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/xz/5.2.5-6f3f49b07db84e10c9be594a1176c114/include -I/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/zlib/1.2.11-1a082fc322b0051b504cc023f21df178/include -I/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/eigen/3bb6a48d8c171cf20b5f8e48bfb4e424fbd4f79e-3ca740c03e68b1a067f3ed0679234a78/include/eigen3 -I/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/fmt/8.0.1-258b4791803c34b7e98cf43693e54d87/include -I/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/md5/1.0.0-5b594b264e04ae51e893b1d69a797ec6/include -I/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/OpenBLAS/0.3.15-c877ab57fa7b04ce290093588c6c5717/include -I/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02845/el8_amd64_gcc12/external/tinyxml2/6.2.0-88fe0ec301baf763fa3c485e5b67ed91/include -O3 -pthread -pipe -Werror=main -Werror=pointer-arith -Werror=overlength-strings -Wno-vla -Werror=overflow -std=c++17 -ftree-vectorize -Werror=array\r\n-bounds -Werror=type-limits -fvisibility-inlines-hidden -fno-math-errno --param vect-max-version-for-alias-checks=50 -Xassembler --compress-debug-sections -Wno-error=array-bounds -Warray-bounds -fuse-ld=bfd -march=x86-\r\n64-v2 -felide-constructors -fmessage-length=0 -Wall -Wno-long-long -Wreturn-type -Wextra -Wpessimizing-move -Wclass-memaccess -Wno-cast-function-type -Wno-unused-but-set-parameter -Wno-ignored-qualifiers -Wno-unused-pa\r\nrameter -Wunused -Wparentheses -Werror=return-type -Werror=missing-braces -Werror=unused-value -Werror=unused-label -Werror=address -Werror=format -Werror=sign-compare -Werror=write-strings -Werror=delete-non-virtual-d\r\ntor -Werror=strict-aliasing -Werror=narrowing -Werror=reorder -Werror=unused-variable -Werror=conversion-null -Wnon-virtual-dtor -Werror=switch -fdiagnostics-show-option -Wno-unused-local-typedefs -Wno-attributes -Wno-\r\npsabi -Wno-c99-extensions -Wno-c++11-narrowing -D__STRICT_ANSI__ -Wno-unused-private-field -Wno-unknown-pragmas -Wno-unused-command-line-argument -Wno-unknown-warning-option -ftemplate-depth=1024 -Wno-error=potentially\r\n-evaluated-expression -Wno-tautological-type-limit-compare -Wno-vla-cxx-extension -fsized-deallocation --gcc-toolchain=/afs/cern.ch/work/i/innocent/public/w5 -Ofast -fno-reciprocal-math -mrecip=none -DEIGEN_DONT_PARALL\r\nELIZE -DEIGEN_MAX_ALIGN_BYTES=64 -Wno-error=unused-variable -DALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT=128 -DALPAKA_DISABLE_VENDOR_RNG -DBOOST_DISABLE_ASSERTS -g -fsanitize=numerical -fPIC -MMD -MF tmp/el8_amd64_gcc12/src/\r\nTrackingTools/TrajectoryState/src/TrackingToolsTrajectoryState/BasicTrajectoryState.cc.d src/TrackingTools/TrajectoryState/src/BasicTrajectoryState.cc -o tmp/el8_amd64_gcc12/src/TrackingTools/TrajectoryState/src/Tracki\r\nngToolsTrajectoryState/BasicTrajectoryState.cc.o\r\n1. <eof> parser at end of file\r\n2. Optimizer\r\n3. Running pass \"nsan\" on module \"src/TrackingTools/TrajectoryState/src/BasicTrajectoryState.cc\"\r\n #0 0x000000000389df7b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x389df7b)\r\n #1 0x000000000389bd04 llvm::sys::CleanupOnSignal(unsigned long) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x389bd04)\r\n #2 0x00000000037dc354 llvm::CrashRecoveryContext::HandleExit(int) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x37dc354)\r\n #3 0x0000000003892523 llvm::sys::Process::Exit(int, bool) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x3892523)\r\n #4 0x0000000000be52a7 (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0xbe52a7)\r\n #5 0x00000000037e7dea llvm::report_fatal_error(llvm::Twine const&, bool) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x37e7dea)\r\n #6 0x0000000004fbbf2c (anonymous namespace)::NumericalStabilitySanitizer::createShadowValueWithOperandsAvailable(llvm::Instruction&, llvm::TargetLibraryInfo const&, (anonymous namespace)::ValueToShadowMap const&) Nume\r\nricalStabilitySanitizer.cpp:0:0\r\n #7 0x0000000004fbcd55 llvm::NumericalStabilitySanitizerPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x4fbcd55)\r\n #8 0x0000000003b38ac2 llvm::detail::PassModel<llvm::Module, llvm::NumericalStabilitySanitizerPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/afs/cern.ch/user/i/in\r\nnocent/w5/bin/clang+++0x3b38ac2)\r\n #9 0x0000000003229bad llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x3229bad)\r\n#10 0x0000000003b46c3e (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<l\r\nlvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#11 0x0000000003b4a1ef (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) Back\r\nendUtil.cpp:0:0\r\n#12 0x0000000003b4acc1 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm:\r\n:Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/afs/cern.ch/user/i/inn\r\nocent/w5/bin/clang+++0x3b4acc1)\r\n#13 0x0000000004168f3b clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x4168f3b)\r\n#14 0x0000000005bd82cc clang::ParseAST(clang::Sema&, bool, bool) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x5bd82cc)\r\n#15 0x0000000004430459 clang::FrontendAction::Execute() (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x4430459)\r\n#16 0x00000000043b1c9b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x43b1c9b)\r\n#17 0x0000000004500ae7 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x4500ae7)\r\n#18 0x0000000000be70c4 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0xbe70c4)\r\n#19 0x0000000000be0aac ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#20 0x00000000041b6519 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allo\r\ncator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0\r\n#21 0x00000000037dc253 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x37dc253)\r\n#22 0x00000000041b6d16 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:\r\n0:0\r\n#23 0x000000000417b1db clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x417b1db)\r\n#24 0x000000000417bbee clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/afs/cern.ch/user/i/innocent/w5/bin/clan\r\ng+++0x417bbee)\r\n#25 0x000000000418e11c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0x418e11\r\nc)\r\n#26 0x0000000000be40ae clang_main(int, char**, llvm::ToolContext const&) (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0xbe40ae)\r\n#27 0x0000000000aad1af main (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0xaad1af)\r\n#28 0x00007f2127913d85 __libc_start_main (/usr/lib64/libc.so.6+0x3ad85)\r\n#29 0x0000000000be04fe _start (/afs/cern.ch/user/i/innocent/w5/bin/clang+++0xbe04fe)\r\nclang++: error: clang frontend command failed with exit code 70 (use -v to see invocation)\r\nclang version 19.0.0git (git@github.com:llvm/llvm-project.git 857700ff6fb9f9f653c3788445df06db07e7bb59)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /afs/cern.ch/work/i/innocent/public/w5/bin\r\nclang++: note: diagnostic msg:\r\n********************\r\n\r\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\r\nPreprocessed source(s) and associated run script(s) are located at:\r\nclang++: note: diagnostic msg: tmp/el8_amd64_gcc12/src/TrackingTools/TrajectoryState/src/TrackingToolsTrajectoryState/BasicTrajectoryState-33393f.cpp\r\nclang++: note: diagnostic msg: tmp/el8_amd64_gcc12/src/TrackingTools/TrajectoryState/src/TrackingToolsTrajectoryState/BasicTrajectoryState-33393f.sh\r\nclang++: note: diagnostic msg:\r\n```\r\n[nsanCrash.tgz](https://github.com/user-attachments/files/16142152/nsanCrash.tgz)\r\n",
"author": "VinInn",
"labels": [
"crash-on-valid",
"compiler-rt:nsan"
],
"comments": [
{
"author": "dtcxzyw",
"body": "cc @alexander-shaposhnikov "
},
{
"author": "VinInn",
"body": "compilation is stiill failing with\r\n```clang version 20.0.0git (git@github.com:llvm/llvm-project.git ba8126b6fef79bd344a247f6291aaec7b67bdff0)```\r\nwith the same error message \"fatal error: error in backend: Unimplemented support for freeze\"\r\n"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
102934
|
https://github.com/llvm/llvm-project/issues/102934
|
crash
|
2913e71865dfc063a47ddfaf1e2ce07763f69614
| 2024-08-12T16:46:46 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "2ab910c08c4ed43d6fd9eb2ef9b3ff52e0293cf9",
"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": [
[
3705,
3711
]
],
"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::collectLoopUniforms"
],
"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 2ab910c08c4ed43d6fd9eb2ef9b3ff52e0293cf9
Author: Florian Hahn <flo@fhahn.com>
Date: Tue Aug 13 09:23:44 2024 +0100
[LV] Check pointer user are in loop when checking for uniform pointers.
Widening decisions are not set for users outside the loop. Avoid
crashing by only calling isVectorizedMemAccessUse for users in the loop.
Fixes https://github.com/llvm/llvm-project/issues/102934.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 5547116133e8..0d1262fa1872 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -3705,7 +3705,8 @@ void LoopVectorizationCostModel::collectLoopUniforms(ElementCount VF) {
auto *I = cast<Instruction>(V);
auto UsersAreMemAccesses =
llvm::all_of(I->users(), [&](User *U) -> bool {
- return isVectorizedMemAccessUse(cast<Instruction>(U), V);
+ auto *UI = cast<Instruction>(U);
+ return TheLoop->contains(UI) && isVectorizedMemAccessUse(UI, V);
});
if (UsersAreMemAccesses)
addToWorklistIfAllowed(I);
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/X86/gep-use-outside-loop.ll",
"commands": [
"opt -p loop-vectorize -mtriple=x86_64-apple-macosx -mcpu=skylake-avx512 -force-vector-width=4 -force-vector-interleave=1 -S %s"
],
"tests": [
{
"test_name": "gep_use_outside_loop",
"test_body": "define void @gep_use_outside_loop(ptr noalias %dst, ptr %src) {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %gep.dst = getelementptr i16, ptr %dst, i64 %iv\n %gep.src = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep.src, align 2\n %c = icmp eq i16 %l, 10\n br i1 %c, label %loop.latch, label %then\n\nthen: ; preds = %loop.header\n store i16 0, ptr %gep.dst, align 2\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv.next, 99\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n store i16 0, ptr %gep.dst, align 2\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "gep_use_in_dead_block",
"test_body": "define void @gep_use_in_dead_block(ptr noalias %dst, ptr %src) {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %gep.src = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep.src, align 2\n %c = icmp eq i16 %l, 10\n br i1 %c, label %loop.latch, label %then\n\nthen: ; preds = %loop.header\n %gep.dst = getelementptr i16, ptr %dst, i64 %iv\n store i16 0, ptr %gep.dst, align 2\n br label %loop.latch\n\ndead: ; preds = %dead\n store i16 0, ptr %gep.dst, align 2\n br label %dead\n\nloop.latch: ; preds = %then, %loop.header\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv.next, 99\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": "[LoopVectorize] Assertion `WideningDecision != CM_Unknown && \"Widening decision should be ready at this moment\"' failed.",
"body": "Reduced LLVM IR:\r\n```llvm ir\r\n; ModuleID = 'reduced.bc'\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine i32 @main(i64 %indvars.iv.i) #0 {\r\nentry:\r\n br label %for.body6.i\r\n\r\nfor.body6.i: ; preds = %for.inc34.i, %entry\r\n %indvars.iv.i1 = phi i64 [ 0, %entry ], [ %indvars.iv.next.i, %for.inc34.i ]\r\n br i1 false, label %for.body6.i.for.inc34.i_crit_edge, label %for.cond7.preheader.i\r\n\r\nfor.body6.i.for.inc34.i_crit_edge: ; preds = %for.body6.i\r\n br label %for.inc34.i\r\n\r\nfor.cond7.preheader.i: ; preds = %for.body6.i\r\n %arrayidx30.i = getelementptr [0 x i16], ptr null, i64 0, i64 %indvars.iv.i\r\n store i16 0, ptr %arrayidx30.i, align 2\r\n br label %for.inc34.i\r\n\r\nfor.body19.1.i: ; preds = %for.body19.1.i\r\n store i16 0, ptr %arrayidx30.i, align 2\r\n br label %for.body19.1.i\r\n\r\nfor.inc34.i: ; preds = %for.cond7.preheader.i, %for.body6.i.for.inc34.i_crit_edge\r\n %indvars.iv.next.i = add i64 %indvars.iv.i1, 1\r\n %exitcond.not.i = icmp eq i64 %indvars.iv.next.i, 0\r\n br i1 %exitcond.not.i, label %q.exit, label %for.body6.i\r\n\r\nq.exit: ; preds = %for.inc34.i\r\n ret i32 0\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\nBacktrace:\r\n```\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=\"loop-vectorize\" -S reduced.ll\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:3631: llvm::LoopVectorizationCostModel::collectLoopUniforms(llvm::ElementCount)::<lambda(llvm::Instruction*, llvm::ElementCount)>: Assertion `WideningDecision != CM_Unknown && \"Widening decision should be ready at this moment\"' 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 -S 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 0x000059f80448a570 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2f4f570)\r\n #1 0x000059f80448798f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2f4c98f)\r\n #2 0x000059f804487ae5 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x0000795355842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007953558969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007953558969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007953558969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x0000795355842476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007953558287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x000079535582871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x0000795355839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x000059f80347d610 llvm::LoopVectorizationCostModel::collectLoopUniforms(llvm::ElementCount) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f42610)\r\n#12 0x000059f80348fa77 llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f54a77)\r\n#13 0x000059f803491b83 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f56b83)\r\n#14 0x000059f803494de1 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+0x1f59de1)\r\n#15 0x000059f803495497 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f5a497)\r\n#16 0x000059f8022ff336 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+0xdc4336)\r\n#17 0x000059f8042a17ff 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+0x2d667ff)\r\n#18 0x000059f8023024c6 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+0xdc74c6)\r\n#19 0x000059f8042a057b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2d6557b)\r\n#20 0x000059f8022fe7c6 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+0xdc37c6)\r\n#21 0x000059f80429e5dd 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+0x2d635dd)\r\n#22 0x000059f801b38c36 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+0x5fdc36)\r\n#23 0x000059f801b2a881 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5ef881)\r\n#24 0x0000795355829d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#25 0x0000795355829e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#26 0x0000795355829e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#27 0x000059f801b206c5 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5e56c5)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\n\r\nFound via fuzzer.",
"author": "patrick-rivos",
"labels": [
"vectorizers",
"crash-on-valid"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
155543
|
https://github.com/llvm/llvm-project/issues/155543
|
crash
|
f3a5c16b9810fc12e7be35ff719be10427338256
| 2025-08-27T02:59:34 |
[
"llvm/test/Transforms/VectorCombine"
] |
{
"fix_commit": "abd2dc90c039cf8b3907f096743fc69380c8b245",
"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": [
[
173,
187
]
],
"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": [
"eraseInstruction"
],
"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 abd2dc90c039cf8b3907f096743fc69380c8b245
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Wed Aug 27 22:28:02 2025 +0800
[VectorCombine] Avoid double deletion in `eraseInstruction` (#155621)
Consider the following pattern:
```
C = op A B
D = op C
E = op D, C
```
As `E` is dead, we call `eraseInstruction(E)` and see if its operands
become dead. `RecursivelyDeleteTriviallyDeadInstructions(D)` also erases
`C`, which causes a UAF crash in the subsequent call
`RecursivelyDeleteTriviallyDeadInstructions(C)`.
This patch also adds deleted ops into the visit list to avoid double
deletion.
Closes https://github.com/llvm/llvm-project/issues/155543.
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index 56a08b843871..c88ed95de294 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -173,15 +173,16 @@ private:
// further folds that were hindered by OneUse limits.
SmallPtrSet<Value *, 4> Visited;
for (Value *Op : Ops) {
- if (Visited.insert(Op).second) {
+ if (!Visited.contains(Op)) {
if (auto *OpI = dyn_cast<Instruction>(Op)) {
if (RecursivelyDeleteTriviallyDeadInstructions(
- OpI, nullptr, nullptr, [this](Value *V) {
+ OpI, nullptr, nullptr, [&](Value *V) {
if (auto *I = dyn_cast<Instruction>(V)) {
LLVM_DEBUG(dbgs() << "VC: Erased: " << *I << '\n');
Worklist.remove(I);
if (I == NextInst)
NextInst = NextInst->getNextNode();
+ Visited.insert(I);
}
}))
continue;
|
[
{
"file": "llvm/test/Transforms/VectorCombine/X86/pr155543.ll",
"commands": [
"opt < %s -passes=vector-combine -S -mtriple=x86_64--"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n; Make sure we don't double delete a dead instruction.\n\ndefine void @pr155543() {\n;\n %shuffle1 = shufflevector <4 x double> poison, <4 x double> poison, <8 x i32> <i32 poison, i32 poison, i32 poison, i32 poison, i32 0, i32 1, i32 2, i32 3>\n %shuffle2 = shufflevector <8 x double> poison, <8 x double> %shuffle1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 12, i32 13, i32 14, i32 15>\n %fadd = fadd <8 x double> %shuffle1, zeroinitializer\n %dead = shufflevector <8 x double> %fadd, <8 x double> %shuffle2, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 12, i32 13, i32 14, i32 15>\n ret void\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[VectorCombine] SIGSEGV at O3",
"body": "```\n; bin/opt -passes=vector-combine reduced.ll -S\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @wombat() {\nbb:\n %alloca.sroa.0.32.vec.expand = shufflevector <4 x double> zeroinitializer, <4 x double> zeroinitializer, <8 x i32> <i32 poison, i32 poison, i32 poison, i32 poison, i32 0, i32 1, i32 2, i32 3>\n %alloca.sroa.0.32.vecblend = shufflevector <8 x double> zeroinitializer, <8 x double> %alloca.sroa.0.32.vec.expand, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 12, i32 13, i32 14, i32 15>\n %0 = fadd <8 x double> zeroinitializer, %alloca.sroa.0.32.vec.expand\n %arg112.sroa.0.0.vecblend.i.i = shufflevector <8 x double> %0, <8 x double> %alloca.sroa.0.32.vecblend, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 12, i32 13, i32 14, i32 15>\n ret void\n}\n```\n```\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0. Program arguments: bin/opt -passes=vector-combine reduced.ll -S\n1. Running pass \"function(vector-combine)\" on module \"reduced.ll\"\n2. Running pass \"vector-combine\" on function \"wombat\"\n #0 0x00007f8472c306e2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.22.0git+0x2306e2)\n #1 0x00007f8472c2ccaf llvm::sys::RunSignalHandlers() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.22.0git+0x22ccaf)\n #2 0x00007f8472c2cdfc SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #3 0x00007f8472645330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)\n #4 0x00007f846c15a554 llvm::Value::assertModuleIsMaterializedImpl() const (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.22.0git+0x35a554)\n #5 0x00007f846cda0400 llvm::RecursivelyDeleteTriviallyDeadInstructions(llvm::SmallVectorImpl<llvm::WeakTrackingVH>&, llvm::TargetLibraryInfo const*, llvm::MemorySSAUpdater*, std::function<void (llvm::Value*)>) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMTransformUtils.so.22.0git+0x1a0400)\n #6 0x00007f846cda0ab0 llvm::RecursivelyDeleteTriviallyDeadInstructions(llvm::Value*, llvm::TargetLibraryInfo const*, llvm::MemorySSAUpdater*, std::function<void (llvm::Value*)>) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMTransformUtils.so.22.0git+0x1a0ab0)\n #7 0x00007f846ea7e821 (anonymous namespace)::VectorCombine::eraseInstruction(llvm::Instruction&) VectorCombine.cpp:0:0\n #8 0x00007f846ea9e05a llvm::VectorCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.22.0git+0x29e05a)\n #9 0x00007f846f4f0eb5 llvm::detail::PassModel<llvm::Function, llvm::VectorCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMPasses.so.22.0git+0xf0eb5)\n#10 0x00007f846c127929 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.22.0git+0x327929)\n#11 0x00007f8471cdd2c5 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.22.0git+0xdd2c5)\n#12 0x00007f846c126792 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.22.0git+0x326792)\n#13 0x00007f8472e02145 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.22.0git+0x20145)\n#14 0x00007f846c12495d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.22.0git+0x32495d)\n#15 0x00007f8472e0f125 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.22.0git+0x2d125)\n#16 0x00007f8472e1a599 optMain (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.22.0git+0x38599)\n#17 0x00007f847262a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3\n#18 0x00007f847262a28b call_init ./csu/../csu/libc-start.c:128:20\n#19 0x00007f847262a28b __libc_start_main ./csu/../csu/libc-start.c:347:5\n#20 0x000061f20c4f8095 _start (bin/opt+0x1095)\nSegmentation fault (core dumped)\n```\nReported by @alexfh https://github.com/llvm/llvm-project/pull/151142#issuecomment-3225370210\n",
"author": "dtcxzyw",
"labels": [
"crash-on-valid",
"llvm::vectorcombine"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
115744
|
https://github.com/llvm/llvm-project/issues/115744
|
crash
|
28002dd50fb7ec97da1770a11f9c6a99dd9aecb9
| 2024-11-11T17:12:17 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "8009c1fd81ad0b6ac65724d2b134a92db48f8fbf",
"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": [
[
7291,
7297
],
[
7311,
7317
]
],
"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::precomputeCosts"
],
"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 8009c1fd81ad0b6ac65724d2b134a92db48f8fbf
Author: Elvis Wang <elvis.wang@sifive.com>
Date: Tue Feb 25 11:09:09 2025 +0800
[LV][VPlan] Prevent calculate cost for skiped instructions in precomputeCosts(). (#127966)
Skip calculating instruction costs for exit conditions in
precomputeCosts() when it should be skipped.
Reported from:
https://github.com/llvm/llvm-project/issues/115744#issuecomment-2670479463
Godbolt for reduced test cases: https://godbolt.org/z/fr4YMeqcv
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 4d2df9179aa3..0bf2d71a63ef 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7291,7 +7291,7 @@ LoopVectorizationPlanner::precomputeCosts(VPlan &Plan, ElementCount VF,
// Collect all exit conditions.
for (BasicBlock *EB : Exiting) {
auto *Term = dyn_cast<BranchInst>(EB->getTerminator());
- if (!Term)
+ if (!Term || CostCtx.skipCostComputation(Term, VF.isVector()))
continue;
if (auto *CondI = dyn_cast<Instruction>(Term->getOperand(0))) {
ExitInstrs.insert(CondI);
@@ -7311,7 +7311,8 @@ LoopVectorizationPlanner::precomputeCosts(VPlan &Plan, ElementCount VF,
Cost += CondICost;
for (Value *Op : CondI->operands()) {
auto *OpI = dyn_cast<Instruction>(Op);
- if (!OpI || any_of(OpI->users(), [&ExitInstrs, this](User *U) {
+ if (!OpI || CostCtx.skipCostComputation(OpI, VF.isVector()) ||
+ any_of(OpI->users(), [&ExitInstrs, this](User *U) {
return OrigLoop->contains(cast<Instruction>(U)->getParent()) &&
!ExitInstrs.contains(cast<Instruction>(U));
}))
|
[
{
"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": "g",
"test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-apple-macosx10.8.0\"\n\ndefine i32 @g(i64 %n) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %select = phi i32 [ 0, %entry ], [ %select.next, %loop ]\n %iv.widen = zext i32 %iv to i64\n %exitcond = icmp eq i64 %n, %iv.widen\n %select.i = select i1 %exitcond, i32 0, i32 2\n %select.next = or i32 %select.i, %select\n %iv.next = add i32 %iv, 1\n br i1 %exitcond, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i32 %select.next\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[VPlan] Assertion \"VPlan cost model and legacy cost model disagreed\"' failed.",
"body": "C program:\r\n```c\r\nsigned char a;\r\nshort b;\r\nint c, g;\r\nlong d, e, f;\r\nvoid h(long i[][2], long j[][2][2], short k[][2]) {\r\n for (unsigned l = g; l; l += 4) {\r\n a *= (signed char)((f ? 0 : k[l][l]) ?: (_Bool)(d << j[8][l][e]) ? i[l][l] : c);\r\n b = ~i[e][l];\r\n }\r\n}\r\n```\r\n`/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/clang -march=rv64gcv -O3 red.c -o rv64gcv.bc -w -emit-llvm -c`\r\n\r\nLLVM IR:\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 @h(ptr %i, ptr %k, i64 %idxprom.us) #0 {\r\nentry:\r\n br label %for.body.us\r\n\r\nfor.body.us: ; preds = %cond.end23.us, %entry\r\n %l.046.us = phi i32 [ %add.us, %cond.end23.us ], [ 0, %entry ]\r\n %conv284345.us = phi i8 [ %conv28.us, %cond.end23.us ], [ 0, %entry ]\r\n %idxprom.us1 = zext i32 %l.046.us to i64\r\n %arrayidx3.us = getelementptr [2 x i16], ptr %k, i64 %idxprom.us1, i64 %idxprom.us\r\n %0 = load i16, ptr %arrayidx3.us, align 2\r\n %tobool4.not.us = icmp eq i16 %0, 0\r\n br i1 %tobool4.not.us, label %cond.false7.us, label %cond.end23.us\r\n\r\ncond.false7.us: ; preds = %for.body.us\r\n %1 = load i64, ptr %i, align 8\r\n %shl.us = shl i64 0, %1\r\n %tobool12.not.us = icmp eq i64 %shl.us, 0\r\n br i1 %tobool12.not.us, label %cond.end23.us, label %cond.true14.us\r\n\r\ncond.true14.us: ; preds = %cond.false7.us\r\n %2 = load i64, ptr %i, align 8\r\n %3 = trunc i64 %2 to i32\r\n br label %cond.end23.us\r\n\r\ncond.end23.us: ; preds = %cond.true14.us, %cond.false7.us, %for.body.us\r\n %cond24.us = phi i32 [ %3, %cond.true14.us ], [ 0, %for.body.us ], [ 0, %cond.false7.us ]\r\n %4 = trunc i32 %cond24.us to i8\r\n %conv28.us = mul i8 0, %4\r\n %arrayidx31.us = getelementptr [2 x i64], ptr %i, i64 0, i64 %idxprom.us1\r\n %5 = load i64, ptr %arrayidx31.us, align 8\r\n %6 = trunc i64 %5 to i16\r\n %conv32.us = xor i16 %6, 0\r\n store i16 %conv32.us, ptr null, align 2\r\n %add.us = add i32 %l.046.us, 4\r\n %tobool.not.us = icmp eq i32 %add.us, 0\r\n br i1 %tobool.not.us, label %for.cond.for.cond.cleanup_crit_edge, label %for.body.us\r\n\r\nfor.cond.for.cond.cleanup_crit_edge: ; preds = %cond.end23.us\r\n store i8 %4, ptr null, align 1\r\n ret void\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-b,-e,-experimental-smctr,-experimental-ssctr,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-experimental-zvbc32e,-experimental-zvkgs,-h,-sha,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smdbltrp,-smepmp,-smmpm,-smnpm,-smrnmi,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssdbltrp,-ssnpm,-sspm,-ssqosid,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-supm,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-svvptc,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zacas,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\n```\r\n\r\nCommand/backtrace:\r\n```\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt --passes \"loop-vectorize\" reduced.ll -f\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7522: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop) || planContainsAdditionalSimplifications(getPlanFor(LegacyVF.Width), CostCtx, OrigLoop)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt --passes loop-vectorize reduced.ll -f\r\n1. Running pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"reduced.ll\"\r\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"h\"\r\n #0 0x000062cc6ec1de70 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x319de70)\r\n #1 0x000062cc6ec1b27f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x319b27f)\r\n #2 0x000062cc6ec1b3d5 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x000074efe9a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x000074efe9a969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x000074efe9a969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x000074efe9a969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x000074efe9a42476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x000074efe9a287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x000074efe9a2871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x000074efe9a39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x000062cc6db65039 llvm::LoopVectorizationPlanner::computeBestVF() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20e5039)\r\n#12 0x000062cc6db7c50c llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20fc50c)\r\n#13 0x000062cc6db7f1e1 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20ff1e1)\r\n#14 0x000062cc6db7f857 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20ff857)\r\n#15 0x000062cc6c963a06 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+0xee3a06)\r\n#16 0x000062cc6ea24b0f 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+0x2fa4b0f)\r\n#17 0x000062cc6c966b96 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+0xee6b96)\r\n#18 0x000062cc6ea22e9b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2fa2e9b)\r\n#19 0x000062cc6c962ac6 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+0xee2ac6)\r\n#20 0x000062cc6ea239fd 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+0x2fa39fd)\r\n#21 0x000062cc6c15c33d 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+0x6dc33d)\r\n#22 0x000062cc6c14e1c1 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x6ce1c1)\r\n#23 0x000074efe9a29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#24 0x000074efe9a29e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#25 0x000074efe9a29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#26 0x000062cc6c144725 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x6c4725)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\n\r\nGodbolt: https://godbolt.org/z/v5K5Wbxcn\r\n\r\nFound via fuzzer\r\n\r\ncc @fhahn ",
"author": "patrick-rivos",
"labels": [
"release:backport",
"vectorizers",
"crash"
],
"comments": [
{
"author": "patrick-rivos",
"body": "Bisected to b3edc764f70f4e56807af60abdcfbef4dbdc5d95\r\ncc @ElvisWang123 "
},
{
"author": "ElvisWang123",
"body": "> Bisected to [b3edc76](https://github.com/llvm/llvm-project/commit/b3edc764f70f4e56807af60abdcfbef4dbdc5d95) cc @ElvisWang123\r\n\r\nI will take a look."
},
{
"author": "ElvisWang123",
"body": "The main difference of this case is that \r\n`LV: Found an estimated cost of 3 for VF vscale x 2 For instruction: %3 = trunc i64 %2 to i32` from legacy cost model and `Cost of 1 for VF vscale x 2: WIDEN-CAST ir<%3> = trunc ir<%2> to i32` from VPlan-based cost model.\r\n\r\nLegacy cost model will consider the new type after MinBW by `canTruncateToMinimalBitwidth()`. And finds that `i32` can further truncate to `i8`. So the legacy cost model will calculate the cost from `i64` to `i8`.\r\n But in the VPTransforms, the result type of this recipe cannot be shrunk from `i32` to `i8`. So the final recipes will only calculate the cost from `i64` to `i32`.\r\n\r\nI think this might be the MinBW transformation issue which cannot further truncate the type.\r\n\r\nBTW, the cost from the VPlan-based cost model is closer to the generated vector loop.\r\n\r\nSome cost model information:\r\nLegacy cost\r\n```\r\nLV: Found an estimated cost of 0 for VF vscale x 2 For instruction: %l.046.us = phi i32 [ %add.us, %cond.end23.us ], [ 0, %entry ]\r\nLV: Found an estimated cost of 2 for VF vscale x 2 For instruction: %conv284345.us = phi i8 [ %conv28.us, %cond.end23.us ], [ 0, %entr\r\ny ]\r\nLV: Found an estimated cost of 2 for VF vscale x 2 For instruction: %idxprom.us1 = zext i32 %l.046.us to i64\r\nLV: Found an estimated cost of 0 for VF vscale x 2 For instruction: %arrayidx3.us = getelementptr [2 x i16], ptr %k, i64 %idxprom.us1,\r\n i64 %idxprom.us\r\nLV: Found an estimated cost of 4 for VF vscale x 2 For instruction: %0 = load i16, ptr %arrayidx3.us, align 2\r\nLV: Found an estimated cost of 1 for VF vscale x 2 For instruction: %tobool4.not.us = icmp eq i16 %0, 0\r\nLV: Found an estimated cost of 0 for VF vscale x 2 For instruction: br i1 %tobool4.not.us, label %cond.false7.us, label %cond.end23.us\r\nLV: Found an estimated cost of 4 for VF vscale x 2 For instruction: %1 = load i64, ptr %i, align 8\r\nLV: Found an estimated cost of 2 for VF vscale x 2 For instruction: %shl.us = shl i64 0, %1\r\nLV: Found an estimated cost of 2 for VF vscale x 2 For instruction: %tobool12.not.us = icmp eq i64 %shl.us, 0\r\nLV: Found an estimated cost of 0 for VF vscale x 2 For instruction: br i1 %tobool12.not.us, label %cond.end23.us, label %cond.true14.u\r\ns\r\nLV: Found an estimated cost of 4 for VF vscale x 2 For instruction: %2 = load i64, ptr %i, align 8\r\n====> LV: Found an estimated cost of 3 for VF vscale x 2 For instruction: %3 = trunc i64 %2 to i32 <=====\r\nLV: Found an estimated cost of 0 for VF vscale x 2 For instruction: br label %cond.end23.us\r\nLV: Found an estimated cost of 2 for VF vscale x 2 For instruction: %cond24.us = phi i32 [ %3, %cond.true14.us ], [ 0, %for.body.us ],\r\n [ 0, %cond.false7.us ]\r\nLV: Found an estimated cost of 2 for VF vscale x 2 For instruction: %4 = trunc i32 %cond24.us to i8\r\nLV: Found an estimated cost of 1 for VF vscale x 2 For instruction: %conv28.us = mul i8 0, %4\r\nLV: Found an estimated cost of 0 for VF vscale x 2 For instruction: %arrayidx31.us = getelementptr [2 x i64], ptr %i, i64 0, i64 %idxp\r\nrom.us1\r\nLV: Found an estimated cost of 4 for VF vscale x 2 For instruction: %5 = load i64, ptr %arrayidx31.us, align 8\r\nLV: Found an estimated cost of 2 for VF vscale x 2 For instruction: %6 = trunc i64 %5 to i16\r\nLV: Found an estimated cost of 1 for VF vscale x 2 For instruction: %conv32.us = xor i16 %6, 0\r\nLV: Found an estimated cost of 3 for VF vscale x 2 For instruction: store i16 %conv32.us, ptr null, align 2\r\nLV: Found an estimated cost of 1 for VF vscale x 2 For instruction: %add.us = add i32 %l.046.us, 4\r\nLV: Found an estimated cost of 1 for VF vscale x 2 For instruction: %tobool.not.us = icmp eq i32 %add.us, 0\r\nLV: Found an estimated cost of 0 for VF vscale x 2 For instruction: br i1 %tobool.not.us, label %for.cond.for.cond.cleanup_crit_edge, \r\nlabel %for.body.us\r\nLV: Vector loop of width vscale x 2 costs: 10 (assuming a minimum vscale of 2).\r\n```\r\n\r\nVPlan-based\r\n```\r\nCost of 1 for VF vscale x 2: induction instruction %add.us = add i32 %l.046.us, 4\r\nCost of 0 for VF vscale x 2: induction instruction %l.046.us = phi i32 [ %add.us, %cond.end23.us ], [ 0, %entry ]\r\nCost of 1 for VF vscale x 2: exit condition instruction %tobool.not.us = icmp eq i32 %add.us, 0\r\nCost of 0 for VF vscale x 2: EMIT vp<%3> = CANONICAL-INDUCTION ir<0>, vp<%index.next>\r\nCost of 0 for VF vscale x 2: WIDEN-INDUCTION %l.046.us = phi %add.us, 0, ir<4>, vp<%0>\r\nCost of 2 for VF vscale x 2: FIRST-ORDER-RECURRENCE-PHI ir<%conv284345.us> = phi ir<0>, ir<%conv28.us>\r\nCost of 2 for VF vscale x 2: WIDEN-CAST ir<%idxprom.us1> = zext ir<%l.046.us> to i64\r\nCost of 0 for VF vscale x 2: WIDEN-GEP Inv[Var][Inv] ir<%arrayidx3.us> = getelementptr ir<%k>, ir<%idxprom.us1>, ir<%idxprom.us>\r\nCost of 4 for VF vscale x 2: WIDEN ir<%0> = load ir<%arrayidx3.us>\r\nCost of 1 for VF vscale x 2: WIDEN ir<%tobool4.not.us> = icmp eq ir<%0>, ir<0>\r\nCost of 4 for VF vscale x 2: WIDEN ir<%1> = load ir<%i>, ir<%tobool4.not.us>\r\nCost of 2 for VF vscale x 2: WIDEN ir<%shl.us> = shl ir<0>, ir<%1>\r\nCost of 2 for VF vscale x 2: WIDEN ir<%tobool12.not.us> = icmp eq ir<%shl.us>, ir<0>\r\nCost of 0 for VF vscale x 2: EMIT vp<%4> = not ir<%tobool12.not.us>\r\nCost of 0 for VF vscale x 2: EMIT vp<%5> = logical-and ir<%tobool4.not.us>, vp<%4>\r\nCost of 4 for VF vscale x 2: WIDEN ir<%2> = load ir<%i>, vp<%5>\r\n====> Cost of 1 for VF vscale x 2: WIDEN-CAST ir<%3> = trunc ir<%2> to i32 <=======\r\nCost of 0 for VF vscale x 2: EMIT vp<%6> = not ir<%tobool4.not.us>\r\nCost of 2 for VF vscale x 2: BLEND ir<%cond24.us> = ir<0> ir<%3>/vp<%5> ir<0>/vp<%6>\r\nCost of 2 for VF vscale x 2: WIDEN-CAST ir<%4> = trunc ir<%cond24.us> to i8\r\nCost of 1 for VF vscale x 2: WIDEN ir<%conv28.us> = mul ir<0>, ir<%4>\r\nCost of 0 for VF vscale x 2: WIDEN-GEP Inv[Inv][Var] ir<%arrayidx31.us> = getelementptr ir<%i>, ir<0>, ir<%idxprom.us1>\r\nCost of 4 for VF vscale x 2: WIDEN ir<%5> = load ir<%arrayidx31.us>\r\nCost of 2 for VF vscale x 2: WIDEN-CAST ir<%6> = trunc ir<%5> to i16\r\nCost of 1 for VF vscale x 2: WIDEN ir<%conv32.us> = xor ir<%6>, ir<0>\r\nCost of 3 for VF vscale x 2: REPLICATE store ir<%conv32.us>, ir<null>\r\nCost of 0 for VF vscale x 2: EMIT vp<%index.next> = add nuw vp<%3>, vp<%1>\r\nCost of 0 for VF vscale x 2: EMIT branch-on-count vp<%index.next>, vp<%2>\r\nCost of 0 for VF vscale x 2: vector loop backedge\r\nCost for VF vscale x 2: 39\r\n```\r\nGenerated vector.body\r\n``` \r\nvector.body: ; preds = %vector.body, %vector.ph\r\n %index = phi i32 [ 0, %vector.ph ]\r\n %vec.ind = phi <vscale x 2 x i32> [ %induction, %vector.ph ], [ %vec.ind.next, %vector.ph ]\r\n %vector.recur = phi <vscale x 2 x i8> [ %vector.recur.init, %vector.ph ]\r\n %vec.ind.next = add <vscale x 2 x i32> %vec.ind, %.splat\r\n %15 = zext <vscale x 2 x i32> %vec.ind to <vscale x 2 x i64>\r\n %16 = getelementptr [2 x i16], ptr %k, <vscale x 2 x i64> %15, i64 %idxprom.us\r\n %wide.masked.gather = call <vscale x 2 x i16> @llvm.masked.gather.nxv2i16.nxv2p0(<vscale x 2 x ptr> %16, i32 2, <vscale x 2 x i1> shufflevector (<vscale x 2 x i1> insertelement (<vscale x 2 x i1> poison, i1 true, i64 0), <vscale x 2 x i1> poison, <vscale x 2 x i32> zeroinitializer), <vscale x 2 x i16> poison)\r\n %17 = icmp eq <vscale x 2 x i16> %wide.masked.gather, zeroinitializer\r\n %wide.masked.gather1 = call <vscale x 2 x i64> @llvm.masked.gather.nxv2i64.nxv2p0(<vscale x 2 x ptr> %broadcast.splat, i32 8, <vscale x 2 x i1> %17, <vscale x 2 x i64> poison)\r\n %18 = shl <vscale x 2 x i64> zeroinitializer, %wide.masked.gather1\r\n %19 = icmp eq <vscale x 2 x i64> %18, zeroinitializer\r\n %20 = xor <vscale x 2 x i1> %19, shufflevector (<vscale x 2 x i1> insertelement (<vscale x 2 x i1> poison, i1 true, i64 0), <vscale x 2 x i1> poison, <vscale x 2 x i32> zeroinitializer)\r\n %21 = select <vscale x 2 x i1> %17, <vscale x 2 x i1> %20, <vscale x 2 x i1> zeroinitializer\r\n %wide.masked.gather2 = call <vscale x 2 x i64> @llvm.masked.gather.nxv2i64.nxv2p0(<vscale x 2 x ptr> %broadcast.splat, i32 8, <vscale x 2 x i1> %21, <vscale x 2 x i64> poison)\r\n %22 = trunc <vscale x 2 x i64> %wide.masked.gather2 to <vscale x 2 x i32> <================\r\n %23 = xor <vscale x 2 x i1> %17, shufflevector (<vscale x 2 x i1> insertelement (<vscale x 2 x i1> poison, i1 true, i64 0), <vscale x 2 x i1> poison, <vscale x 2 x i32> zeroinitializer)\r\n %predphi = select <vscale x 2 x i1> %21, <vscale x 2 x i32> %22, <vscale x 2 x i32> zeroinitializer\r\n %predphi3 = select <vscale x 2 x i1> %23, <vscale x 2 x i32> zeroinitializer, <vscale x 2 x i32> %predphi\r\n %24 = trunc <vscale x 2 x i32> %predphi3 to <vscale x 2 x i8>\r\n %25 = mul <vscale x 2 x i8> zeroinitializer, %24\r\n %26 = getelementptr [2 x i64], ptr %i, i64 0, <vscale x 2 x i64> %15\r\n %wide.masked.gather4 = call <vscale x 2 x i64> @llvm.masked.gather.nxv2i64.nxv2p0(<vscale x 2 x ptr> %26, i32 8, <vscale x 2 x i1> shufflevector (<vscale x 2 x i1> insertelement (<vscale x 2 x i1> poison, i1 true, i64 0), <vscale x 2 x i1> poison, <vscale x 2 x i32> zeroinitializer), <vscale x 2 x i64> poison)\r\n %27 = trunc <vscale x 2 x i64> %wide.masked.gather4 to <vscale x 2 x i16>\r\n %28 = xor <vscale x 2 x i16> %27, zeroinitializer\r\n %29 = call i32 @llvm.vscale.i32()\r\n%30 = mul i32 %29, 2\r\n %31 = sub i32 %30, 1\r\n %32 = extractelement <vscale x 2 x i16> %28, i32 %31\r\n store i16 %32, ptr null, align 2\r\n %index.next = add nuw i32 %index, %7\r\n %33 = icmp eq i32 %index.next, %n.vec\r\n br i1 %33, <null operand!>, label %vector.body\r\n..."
},
{
"author": "ElvisWang123",
"body": "In this case, we can find that all the following recipes can be shrinkage to `i8`.\n```\n====> Cost of 1 for VF vscale x 2: WIDEN-CAST ir<%3> = trunc ir<%2> to i32 <=======\nCost of 0 for VF vscale x 2: EMIT vp<%6> = not ir<%tobool4.not.us>\nCost of 2 for VF vscale x 2: BLEND ir<%cond24.us> = ir<0> ir<%3>/vp<%5> ir<0>/vp<%6>\nCost of 2 for VF vscale x 2: WIDEN-CAST ir<%4> = trunc ir<%cond24.us> to i8\nCost of 1 for VF vscale x 2: WIDEN ir<%conv28.us> = mul ir<0>, ir<%4>\n```\nBut in current minimal-bit-width analysis, there are some checks prevent this type shrinkage.\n1. If any of instructions in the EC (equivalent class) is PHI node, minimal-bit-width wont narrow the type.\n\nTo support type shrinkage for this case. We need to change the MinBW which is the analysis based on the scalar instructions.\n\nModify current minimal-bit-width architecture (Analysis scalar instructions). This implementation may not be accurate since the VPlan may contains some of the recipe without underlying instructions.\n1. Support Phi node in the EC. Although induction phi should not be modified and the recurrence descriptor will handle the type shrinkage. We still need the information from MinBW to shrinkage the non-header phis.\n2. Add the support of `VPBlendRecipe` in `truncateToMinimalBitWidth()` in VPTransform.\n\nOr rewrite a new minimal-bit-width analysis based on Vplan. This implementation will be more accurate than the current analysis but will be more works.\n\n1. To support Vplan-based MinBW, we may need to rewrite a new VPlan-based DemandedBits analysis.\n\n\n@fhahn What do you think about the these two implementations, modify current MinBW or rewrite a new vplan-based MinBW. Or do you have a better implementation to make MinBW more accurate on Vplan?\n\n@patrick-rivos BTW, the C program in this issue is a little bit weird. Without initializing `a`, loop vectorizer cannot recognize the reduction pattern of the `a *= (signed char)((f ? 0 : k[l][l]) ?: (_Bool)(d << j[8][l][e]) ? i[l][l] : c);`. However, we still have some issue on the minimal-bit-width analysis."
},
{
"author": "cardigan1008",
"body": "Hi, there's another case that triggers this crash:\n\n```c\nint a;\nint b(int c) {\n int d = 0;\n for (; d < c; d++) {\n a++;\n if (d != c - 1)\n a++;\n }\n}\nint *e;\nint f;\nvoid g() {\n for (; e[f]; f++)\n e[b(f + 9)];\n}\n```\n\nCompiler Explorer: https://godbolt.org/z/16Tr15KGx\n\nHope this helps :)"
},
{
"author": "ElvisWang123",
"body": "@cardigan1008 Thanks for your test case. I will take a look."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
137196
|
https://github.com/llvm/llvm-project/issues/137196
|
miscompilation
|
be7cf63b4a402ebc5b1dacc6579a693c92e1328e
| 2025-04-24T15:32:53 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "1f69d6354a4b088bda5ee62c31411a75eead8b0c",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
1959,
1967
],
[
1985,
1991
],
[
2013,
2025
]
],
"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::SimplifyDemandedUseFPClass",
"getFPClassConstant"
],
"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 1f69d6354a4b088bda5ee62c31411a75eead8b0c
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Mon Apr 28 17:01:43 2025 +0800
[InstCombine] Preserve the sign bit of NaN in `SimplifyDemandedUseFPClass` (#137287)
Alive2: https://alive2.llvm.org/ce/z/uiUzEf
Closes https://github.com/llvm/llvm-project/issues/137196.
Note: To avoid regression in
`ret_nofpclass_nopositives_copysign_nnan_flag`, the second commit takes
FMF into account.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index 2c8939b5a051..a48854a191ca 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -1959,9 +1959,11 @@ static Constant *getFPClassConstant(Type *Ty, FPClassTest Mask) {
}
}
-Value *InstCombinerImpl::SimplifyDemandedUseFPClass(
- Value *V, const FPClassTest DemandedMask, KnownFPClass &Known,
- unsigned Depth, Instruction *CxtI) {
+Value *InstCombinerImpl::SimplifyDemandedUseFPClass(Value *V,
+ FPClassTest DemandedMask,
+ KnownFPClass &Known,
+ unsigned Depth,
+ Instruction *CxtI) {
assert(Depth <= MaxAnalysisRecursionDepth && "Limit Search Depth");
Type *VTy = V->getType();
@@ -1985,7 +1987,12 @@ Value *InstCombinerImpl::SimplifyDemandedUseFPClass(
if (!I->hasOneUse())
return nullptr;
- // TODO: Should account for nofpclass/FastMathFlags on current instruction
+ if (auto *FPOp = dyn_cast<FPMathOperator>(I)) {
+ if (FPOp->hasNoNaNs())
+ DemandedMask &= ~fcNan;
+ if (FPOp->hasNoInfs())
+ DemandedMask &= ~fcInf;
+ }
switch (I->getOpcode()) {
case Instruction::FNeg: {
if (SimplifyDemandedFPClass(I, 0, llvm::fneg(DemandedMask), Known,
@@ -2013,13 +2020,13 @@ Value *InstCombinerImpl::SimplifyDemandedUseFPClass(
if (SimplifyDemandedFPClass(I, 0, DemandedMaskAnySign, Known, Depth + 1))
return I;
- if ((DemandedMask & fcPositive) == fcNone) {
+ if ((DemandedMask & fcNegative) == DemandedMask) {
// Roundabout way of replacing with fneg(fabs)
I->setOperand(1, ConstantFP::get(VTy, -1.0));
return I;
}
- if ((DemandedMask & fcNegative) == fcNone) {
+ if ((DemandedMask & fcPositive) == DemandedMask) {
// Roundabout way of replacing with fabs
I->setOperand(1, ConstantFP::getZero(VTy));
return I;
|
[
{
"file": "llvm/test/Transforms/InstCombine/simplify-demanded-fpclass.ll",
"commands": [
"opt -S -passes=instcombine < %s"
],
"tests": [
{
"test_name": "ret_nofpclass_nopositives_copysign",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.copysign.f32(float, float) #0\n\ndefine nofpclass(pinf pzero psub pnorm) float @ret_nofpclass_nopositives_copysign(float %x, float %unknown.sign) {\n %copysign = call float @llvm.copysign.f32(float %x, float %unknown.sign)\n ret float %copysign\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "ret_nofpclass_no_negatives__copysign_unknown_select_pinf_rhs",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.copysign.f32(float, float) #0\n\ndefine nofpclass(ninf nzero nsub nnorm) float @ret_nofpclass_no_negatives__copysign_unknown_select_pinf_rhs(i1 %cond, float %x, float %unknown.sign) {\n %select = select i1 %cond, float %x, float 0x7FF0000000000000\n %copysign = call float @llvm.copysign.f32(float %select, float %unknown.sign)\n ret float %copysign\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "ret_nofpclass_nonegatives_copysign",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.copysign.f32(float, float) #0\n\ndefine nofpclass(ninf nzero nsub nnorm) float @ret_nofpclass_nonegatives_copysign(float %x, float %unknown.sign) {\n %copysign = call float @llvm.copysign.f32(float %x, float %unknown.sign)\n ret float %copysign\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "ret_nofpclass_no_negatives_noinf__copysign_unknown_select_pinf_rhs",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.copysign.f32(float, float) #0\n\ndefine nofpclass(inf nzero nsub nnorm) float @ret_nofpclass_no_negatives_noinf__copysign_unknown_select_pinf_rhs(i1 %cond, float %x, float %unknown.sign) {\n %select = select i1 %cond, float %x, float 0x7FF0000000000000\n %copysign = call float @llvm.copysign.f32(float %select, float %unknown.sign)\n ret float %copysign\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "ret_nofpclass_no_positives_noinf__copysign_unknown_select_pinf_rhs",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.copysign.f32(float, float) #0\n\ndefine nofpclass(inf pzero psub pnorm) float @ret_nofpclass_no_positives_noinf__copysign_unknown_select_pinf_rhs(i1 %cond, float %x, float %unknown.sign) {\n %select = select i1 %cond, float %x, float 0x7FF0000000000000\n %copysign = call float @llvm.copysign.f32(float %select, float %unknown.sign)\n ret float %copysign\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "ret_nofpclass_nopositives_nonan_copysign",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.copysign.f32(float, float) #0\n\ndefine nofpclass(nan pinf pzero psub pnorm) float @ret_nofpclass_nopositives_nonan_copysign(float %x, float %unknown.sign) {\n %copysign = call float @llvm.copysign.f32(float %x, float %unknown.sign)\n ret float %copysign\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "ret_nofpclass_no_positives__copysign_unknown_select_pinf_rhs",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.copysign.f32(float, float) #0\n\ndefine nofpclass(pinf pzero psub pnorm) float @ret_nofpclass_no_positives__copysign_unknown_select_pinf_rhs(i1 %cond, float %x, float %unknown.sign) {\n %select = select i1 %cond, float %x, float 0x7FF0000000000000\n %copysign = call float @llvm.copysign.f32(float %select, float %unknown.sign)\n ret float %copysign\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "ret_nofpclass_nopositive_finites_copysign_nnan_ninf_flag",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.copysign.f32(float, float) #0\n\ndefine nofpclass(pzero psub pnorm) float @ret_nofpclass_nopositive_finites_copysign_nnan_ninf_flag(float %x, float %unknown.sign) {\n %copysign = call nnan ninf float @llvm.copysign.f32(float %x, float %unknown.sign)\n ret float %copysign\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "copysign not preserving sign bit of a NaN",
"body": "we're optimizing this:\n```llvm\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.copysign.f32(float, float) #0\n\ndefine nofpclass(ninf nzero nsub nnorm) float @f(float %0) {\n %2 = call float @llvm.copysign.f32(float 0x7FF8000000000000, float %0)\n ret float %2\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n```\n\nto:\n```llvm\n; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)\ndefine noundef nofpclass(ninf nzero nsub nnorm) float @f(float %0) local_unnamed_addr #0 {\n ret float 0x7FF8000000000000\n}\n\nattributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }\n```\n\nAlive complains that the optimized code will flip the sign bit of a NaN, while the unoptimized code preserved it as required by LangRef's specification of the copysign semantics:\n> The returned value is completely identical to the first operand except for the sign bit; in particular, if the input is a NaN, then the quiet/signaling bit and payload are perfectly preserved.\n\nIf any of the individual flags in `nofpclass(ninf nzero nsub nnorm)` are removed, then we don't do this transformation. Am I missing something here where these flags, together, mean that it's legal to flip the sign of a NaN? Obviously the transformation is just fine when `nofpclass(nan)` is there\n\nhttps://alive2.llvm.org/ce/z/ja96Yf\n\ncc @dtcxzyw @nunoplopes ",
"author": "regehr",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
107569
|
https://github.com/llvm/llvm-project/issues/107569
|
crash
|
b0428870dae980af84e50dfa3ee6ed2165998678
| 2024-09-06T11:56:19 |
[
"llvm/test/Transforms/DeadArgElim"
] |
{
"fix_commit": "5978bb2936d9a71d8e6891c640a36be760b569d3",
"components": [
"DeadArgumentElimination"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
106,
118
],
[
131,
142
]
],
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": [
[
87,
97
],
[
280,
286
],
[
496,
502
],
[
504,
510
],
[
522,
550
],
[
555,
562
],
[
564,
577
],
[
610,
620
],
[
628,
646
],
[
680,
693
],
[
696,
701
],
[
710,
716
],
[
734,
741
],
[
807,
813
],
[
1109,
1134
],
[
1149,
1156
]
],
"llvm/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": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": [
"DeadArgumentEliminationPass::isLive",
"DeadArgumentEliminationPass::markLive",
"DeadArgumentEliminationPass::markValue",
"DeadArgumentEliminationPass::propagateVirtMustcallLiveness",
"DeadArgumentEliminationPass::removeDeadArgumentsFromCallers",
"DeadArgumentEliminationPass::removeDeadStuffFromFunction",
"DeadArgumentEliminationPass::run",
"DeadArgumentEliminationPass::surveyFunction",
"isMustTailCalleeAnalyzable"
],
"llvm/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 5978bb2936d9a71d8e6891c640a36be760b569d3
Author: u4f3 <ricoafoat@gmail.com>
Date: Thu Apr 10 22:08:09 2025 +0800
[DeadArgElim] fix verifier failure when changing musttail's function signature (#127366)
This commit is for #107569 and #126817.
Stop changing musttail's caller and callee's function signature when
calling convention is not swifttailcc nor tailcc. Verifier makes sure
musttail's caller and callee shares exactly the same signature, see
commit 9ff2eb1 and #54964.
Otherwise just make sure the return type is the same and then process
musttail like usual calls.
close #107569, #126817
diff --git a/llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h b/llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h
index 63e1ad043d49..efa9c4bdc496 100644
--- a/llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h
+++ b/llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h
@@ -106,13 +106,16 @@ public:
UseMap Uses;
using LiveSet = std::set<RetOrArg>;
- using LiveFuncSet = std::set<const Function *>;
+ using FuncSet = std::set<const Function *>;
/// This set contains all values that have been determined to be live.
LiveSet LiveValues;
- /// This set contains all values that are cannot be changed in any way.
- LiveFuncSet LiveFunctions;
+ /// This set contains all functions that cannot be changed in any way.
+ FuncSet FrozenFunctions;
+
+ /// This set contains all functions that cannot change return type;
+ FuncSet FrozenRetTyFunctions;
using UseVector = SmallVector<RetOrArg, 5>;
@@ -131,12 +134,13 @@ private:
void markValue(const RetOrArg &RA, Liveness L,
const UseVector &MaybeLiveUses);
void markLive(const RetOrArg &RA);
- void markLive(const Function &F);
+ void markFrozen(const Function &F);
+ void markRetTyFrozen(const Function &F);
+ bool markFnOrRetTyFrozenOnMusttail(const Function &F);
void propagateLiveness(const RetOrArg &RA);
bool removeDeadStuffFromFunction(Function *F);
bool deleteDeadVarargs(Function &F);
bool removeDeadArgumentsFromCallers(Function &F);
- void propagateVirtMustcallLiveness(const Module &M);
};
} // end namespace llvm
diff --git a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
index ed93b4491c50..2e2687a5ff6e 100644
--- a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -87,11 +87,6 @@ public:
virtual bool shouldHackArguments() const { return false; }
};
-bool isMustTailCalleeAnalyzable(const CallBase &CB) {
- assert(CB.isMustTailCall());
- return CB.getCalledFunction() && !CB.getCalledFunction()->isDeclaration();
-}
-
} // end anonymous namespace
char DAE::ID = 0;
@@ -280,7 +275,7 @@ bool DeadArgumentEliminationPass::removeDeadArgumentsFromCallers(Function &F) {
// they are fully alive (e.g., called indirectly) and except for the fragile
// (variadic) ones. In these cases, we may still be able to improve their
// statically known call sites.
- if ((F.hasLocalLinkage() && !LiveFunctions.count(&F)) &&
+ if ((F.hasLocalLinkage() && !FrozenFunctions.count(&F)) &&
!F.getFunctionType()->isVarArg())
return false;
@@ -496,7 +491,7 @@ void DeadArgumentEliminationPass::surveyFunction(const Function &F) {
// particular register and memory layout.
if (F.getAttributes().hasAttrSomewhere(Attribute::InAlloca) ||
F.getAttributes().hasAttrSomewhere(Attribute::Preallocated)) {
- markLive(F);
+ markFrozen(F);
return;
}
@@ -504,7 +499,7 @@ void DeadArgumentEliminationPass::surveyFunction(const Function &F) {
// otherwise rely on the frame layout in a way that this analysis will not
// see.
if (F.hasFnAttribute(Attribute::Naked)) {
- markLive(F);
+ markFrozen(F);
return;
}
@@ -522,29 +517,17 @@ void DeadArgumentEliminationPass::surveyFunction(const Function &F) {
// MaybeLive. Initialized to a list of RetCount empty lists.
RetUses MaybeLiveRetUses(RetCount);
- bool HasMustTailCalls = false;
for (const BasicBlock &BB : F) {
- // If we have any returns of `musttail` results - the signature can't
- // change
- if (const auto *TC = BB.getTerminatingMustTailCall()) {
- HasMustTailCalls = true;
- // In addition, if the called function is not locally defined (or unknown,
- // if this is an indirect call), we can't change the callsite and thus
- // can't change this function's signature either.
- if (!isMustTailCalleeAnalyzable(*TC)) {
- markLive(F);
+ if (BB.getTerminatingMustTailCall()) {
+ LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - " << F.getName()
+ << " has musttail calls\n");
+ if (markFnOrRetTyFrozenOnMusttail(F))
return;
- }
}
}
- if (HasMustTailCalls) {
- LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - " << F.getName()
- << " has musttail calls\n");
- }
-
if (!F.hasLocalLinkage() && (!ShouldHackArguments || F.isIntrinsic())) {
- markLive(F);
+ markFrozen(F);
return;
}
@@ -555,8 +538,6 @@ void DeadArgumentEliminationPass::surveyFunction(const Function &F) {
// of them turn out to be live.
unsigned NumLiveRetVals = 0;
- bool HasMustTailCallers = false;
-
// Loop all uses of the function.
for (const Use &U : F.uses()) {
// If the function is PASSED IN as an argument, its address has been
@@ -564,14 +545,16 @@ void DeadArgumentEliminationPass::surveyFunction(const Function &F) {
const auto *CB = dyn_cast<CallBase>(U.getUser());
if (!CB || !CB->isCallee(&U) ||
CB->getFunctionType() != F.getFunctionType()) {
- markLive(F);
+ markFrozen(F);
return;
}
- // The number of arguments for `musttail` call must match the number of
- // arguments of the caller
- if (CB->isMustTailCall())
- HasMustTailCallers = true;
+ if (CB->isMustTailCall()) {
+ LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - " << F.getName()
+ << " has musttail callers\n");
+ if (markFnOrRetTyFrozenOnMusttail(F))
+ return;
+ }
// If we end up here, we are looking at a direct call to our function.
@@ -610,11 +593,6 @@ void DeadArgumentEliminationPass::surveyFunction(const Function &F) {
}
}
- if (HasMustTailCallers) {
- LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - " << F.getName()
- << " has musttail callers\n");
- }
-
// Now we've inspected all callers, record the liveness of our return values.
for (unsigned Ri = 0; Ri != RetCount; ++Ri)
markValue(createRet(&F, Ri), RetValLiveness[Ri], MaybeLiveRetUses[Ri]);
@@ -628,19 +606,12 @@ void DeadArgumentEliminationPass::surveyFunction(const Function &F) {
for (Function::const_arg_iterator AI = F.arg_begin(), E = F.arg_end();
AI != E; ++AI, ++ArgI) {
Liveness Result;
- if (F.getFunctionType()->isVarArg() || HasMustTailCallers ||
- HasMustTailCalls) {
+ if (F.getFunctionType()->isVarArg()) {
// Variadic functions will already have a va_arg function expanded inside
// them, making them potentially very sensitive to ABI changes resulting
// from removing arguments entirely, so don't. For example AArch64 handles
// register and stack HFAs very differently, and this is reflected in the
// IR which has already been generated.
- //
- // `musttail` calls to this function restrict argument removal attempts.
- // The signature of the caller must match the signature of the function.
- //
- // `musttail` calls in this function prevents us from changing its
- // signature
Result = Live;
} else {
// See what the effect of this use is (recording any uses that cause
@@ -680,14 +651,30 @@ void DeadArgumentEliminationPass::markValue(const RetOrArg &RA, Liveness L,
}
}
+/// Return true if we freeze the whole function.
+/// If the calling convention is not swifttailcc or tailcc, the caller and
+/// callee of musttail must have exactly the same signature. Otherwise we
+/// only needs to guarantee they have the same return type.
+bool DeadArgumentEliminationPass::markFnOrRetTyFrozenOnMusttail(
+ const Function &F) {
+ if (F.getCallingConv() != CallingConv::SwiftTail ||
+ F.getCallingConv() != CallingConv::Tail) {
+ markFrozen(F);
+ return true;
+ } else {
+ markRetTyFrozen(F);
+ return false;
+ }
+}
+
/// Mark the given Function as alive, meaning that it cannot be changed in any
/// way. Additionally, mark any values that are used as this function's
/// parameters or by its return values (according to Uses) live as well.
-void DeadArgumentEliminationPass::markLive(const Function &F) {
- LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - Intrinsically live fn: "
+void DeadArgumentEliminationPass::markFrozen(const Function &F) {
+ LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - frozen fn: "
<< F.getName() << "\n");
- // Mark the function as live.
- LiveFunctions.insert(&F);
+ // Mark the function as frozen.
+ FrozenFunctions.insert(&F);
// Mark all arguments as live.
for (unsigned ArgI = 0, E = F.arg_size(); ArgI != E; ++ArgI)
propagateLiveness(createArg(&F, ArgI));
@@ -696,6 +683,12 @@ void DeadArgumentEliminationPass::markLive(const Function &F) {
propagateLiveness(createRet(&F, Ri));
}
+void DeadArgumentEliminationPass::markRetTyFrozen(const Function &F) {
+ LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - frozen return type fn: "
+ << F.getName() << "\n");
+ FrozenRetTyFunctions.insert(&F);
+}
+
/// Mark the given return value or argument as live. Additionally, mark any
/// values that are used by this value (according to Uses) live as well.
void DeadArgumentEliminationPass::markLive(const RetOrArg &RA) {
@@ -710,7 +703,7 @@ void DeadArgumentEliminationPass::markLive(const RetOrArg &RA) {
}
bool DeadArgumentEliminationPass::isLive(const RetOrArg &RA) {
- return LiveFunctions.count(RA.F) || LiveValues.count(RA);
+ return FrozenFunctions.count(RA.F) || LiveValues.count(RA);
}
/// Given that RA is a live value, propagate it's liveness to any other values
@@ -734,8 +727,8 @@ void DeadArgumentEliminationPass::propagateLiveness(const RetOrArg &RA) {
/// Transform the function and all the callees of the function to not have these
/// arguments and return values.
bool DeadArgumentEliminationPass::removeDeadStuffFromFunction(Function *F) {
- // Don't modify fully live functions
- if (LiveFunctions.count(F))
+ // Don't modify frozen functions
+ if (FrozenFunctions.count(F))
return false;
// Start by computing a new prototype for the function, which is the same as
@@ -807,7 +800,8 @@ bool DeadArgumentEliminationPass::removeDeadStuffFromFunction(Function *F) {
// performance win, so the second option can just be used always for now.
//
// This should be revisited if 'returned' is ever applied more liberally.
- if (RetTy->isVoidTy() || HasLiveReturnedArg) {
+ if (RetTy->isVoidTy() || HasLiveReturnedArg ||
+ FrozenRetTyFunctions.count(F)) {
NRetTy = RetTy;
} else {
// Look at each of the original return values individually.
@@ -1109,26 +1103,6 @@ bool DeadArgumentEliminationPass::removeDeadStuffFromFunction(Function *F) {
return true;
}
-void DeadArgumentEliminationPass::propagateVirtMustcallLiveness(
- const Module &M) {
- // If a function was marked "live", and it has musttail callers, they in turn
- // can't change either.
- LiveFuncSet NewLiveFuncs(LiveFunctions);
- while (!NewLiveFuncs.empty()) {
- LiveFuncSet Temp;
- for (const auto *F : NewLiveFuncs)
- for (const auto *U : F->users())
- if (const auto *CB = dyn_cast<CallBase>(U))
- if (CB->isMustTailCall())
- if (!LiveFunctions.count(CB->getParent()->getParent()))
- Temp.insert(CB->getParent()->getParent());
- NewLiveFuncs.clear();
- NewLiveFuncs.insert(Temp.begin(), Temp.end());
- for (const auto *F : Temp)
- markLive(*F);
- }
-}
-
PreservedAnalyses DeadArgumentEliminationPass::run(Module &M,
ModuleAnalysisManager &) {
bool Changed = false;
@@ -1149,8 +1123,6 @@ PreservedAnalyses DeadArgumentEliminationPass::run(Module &M,
for (auto &F : M)
surveyFunction(F);
- propagateVirtMustcallLiveness(M);
-
// Now, remove all dead arguments and return values from each function in
// turn. We use make_early_inc_range here because functions will probably get
// removed (i.e. replaced by new ones).
|
[
{
"file": "llvm/test/Transforms/DeadArgElim/musttail-caller.ll",
"commands": [
"opt -passes=deadargelim -S < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define hidden void @test(i32 %a, i32 %b) {\n musttail call void @foo(i32 %a, i32 0)\n ret void\n}\n\ndeclare hidden void @foo(i32, i32)\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "foo",
"test_body": "define hidden void @foo(i32 %a, i32 %b) {\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/DeadArgElim/musttail-verifier.ll",
"commands": [
"opt -passes=deadargelim -S < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "; Testcases comes from PR126817 and PR107569\n; See PR54964 and langref for more information about how llvm deal with musttail currently\n\ndefine i64 @A() {\n;\nentry:\n %v2660 = musttail call i64 @B()\n ret i64 %v2660\n}\n\ndefine internal i64 @B() {\n;\nentry:\n ret i64 0\n}\n\ndefine internal i64 @C() {\n;\nentry:\n %v30543 = musttail call i64 @B()\n ret i64 %v30543\n}\n\n%struct.S = type { double }\n\ndefine internal %struct.S @F38() {\n;\n ret %struct.S { double 0.0 }\n}\n\ndefine internal %struct.S @F36() {\n;\n %1 = alloca %struct.S, align 8\n %3 = musttail call %struct.S @F38()\n ret %struct.S %3\n}\n\ndefine double @foo() {\n;\n %3 = call %struct.S @F36()\n %5 = extractvalue %struct.S %3, 0\n ret double %5\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "DeadArgumentElimination creates invalid code with musttail calls returning structs",
"body": "The DeadArgumentElimination pass creates code which fails the IR verifier when run on this input:\r\n\r\n```test.ll\r\n%struct.S = type { i32 }\r\n\r\ndefine internal %struct.S @F38() {\r\n ret %struct.S { i32 0 }\r\n}\r\n\r\ndefine %struct.S @F36() {\r\n %3 = musttail call %struct.S @F38()\r\n ret %struct.S %3\r\n}\r\n```\r\n\r\n```\r\n$ /work/llvm/build/bin/opt test.ll -passes=deadargelim -S\r\ncannot guarantee tail call due to mismatched return types\r\n %1 = musttail call i32 @F38()\r\nLLVM ERROR: Broken module found, compilation aborted!\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /work/llvm/build/bin/opt test.ll -passes=deadargelim -S\r\n1. Running pass \"verify\" on module \"test.ll\"\r\n #0 0x000055c16a99ca37 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/work/llvm/build/bin/opt+0x4133a37)\r\n #1 0x000055c16a99a57e llvm::sys::RunSignalHandlers() (/work/llvm/build/bin/opt+0x413157e)\r\n #2 0x000055c16a99d27a SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007f38e3a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007f38e3a969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007f38e3a969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007f38e3a969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x00007f38e3a42476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007f38e3a287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x000055c16a9857a3 llvm::report_fatal_error(llvm::Twine const&, bool) (/work/llvm/build/bin/opt+0x411c7a3)\r\n#10 0x000055c16a9855f6 (/work/llvm/build/bin/opt+0x411c5f6)\r\n#11 0x000055c16afe2d4a (/work/llvm/build/bin/opt+0x4779d4a)\r\n#12 0x000055c16bd1b53d llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) NewPMDriver.cpp:0:0\r\n#13 0x000055c16abad88a llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/work/llvm/build/bin/opt+0x434488a)\r\n#14 0x000055c16bd146eb llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/work/llvm/build/bin/opt+0x54ab6eb)\r\n#15 0x000055c16a964609 optMain (/work/llvm/build/bin/opt+0x40fb609)\r\n#16 0x00007f38e3a29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#17 0x00007f38e3a29e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#18 0x00007f38e3a29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#19 0x000055c16a95e0a5 _start (/work/llvm/build/bin/opt+0x40f50a5)\r\nfish: Job 1, '/work/llvm/build/bin/opt test.l…' terminated by signal SIGABRT (Abort)\r\n```\r\n\r\nFound using a fuzzer while testing #102896.",
"author": "ostannard",
"labels": [
"ipo",
"crash-on-valid"
],
"comments": [
{
"author": "ostannard",
"body": "Related case with a different assertion message:\r\n```test2.ll\r\n%struct.S = type { double }\r\n\r\ndefine internal %struct.S @F38() {\r\n ret %struct.S { double 0.0 }\r\n}\r\n\r\ndefine internal %struct.S @F36() {\r\n %1 = alloca %struct.S, align 8\r\n %3 = musttail call %struct.S @F38()\r\n ret %struct.S %3\r\n}\r\n\r\ndefine double @foo() {\r\n %3 = call %struct.S @F36()\r\n %5 = extractvalue %struct.S %3, 0\r\n ret double %5\r\n}\r\n```\r\n\r\n```\r\n$ /work/llvm/build/bin/opt test2.ll -passes=deadargelim -S -print-after-all\r\n; *** IR Dump After DeadArgumentEliminationPass on [module] ***\r\n; ModuleID = 'test2.ll'\r\nsource_filename = \"test2.ll\"\r\n\r\n%struct.S = type { double }\r\n\r\ndefine internal double @F38() {\r\n %oldret = extractvalue %struct.S zeroinitializer, 0\r\n ret double %oldret\r\n}\r\n\r\ndefine internal double @F36() {\r\n %1 = alloca %struct.S, align 8\r\n %2 = musttail call double @F38()\r\n %oldret = insertvalue %struct.S poison, double %2, 0\r\n %oldret1 = extractvalue %struct.S %oldret, 0\r\n ret double %oldret1\r\n}\r\n\r\ndefine double @foo() {\r\n %1 = call double @F36()\r\n %oldret = insertvalue %struct.S poison, double %1, 0\r\n %2 = extractvalue %struct.S %oldret, 0\r\n ret double %2\r\n}\r\nmusttail call must precede a ret with an optional bitcast\r\n %2 = musttail call double @F38()\r\nLLVM ERROR: Broken module found, compilation aborted!\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /work/llvm/build/bin/opt test2.ll -passes=deadargelim -S -print-after-all\r\n1. Running pass \"verify\" on module \"test2.ll\"\r\n #0 0x000055c5f980ca37 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/work/llvm/build/bin/opt+0x4133a37)\r\n #1 0x000055c5f980a57e llvm::sys::RunSignalHandlers() (/work/llvm/build/bin/opt+0x413157e)\r\n #2 0x000055c5f980d27a SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007faf4da42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007faf4da969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007faf4da969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007faf4da969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x00007faf4da42476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007faf4da287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x000055c5f97f57a3 llvm::report_fatal_error(llvm::Twine const&, bool) (/work/llvm/build/bin/opt+0x411c7a3)\r\n#10 0x000055c5f97f55f6 (/work/llvm/build/bin/opt+0x411c5f6)\r\n#11 0x000055c5f9e52d4a (/work/llvm/build/bin/opt+0x4779d4a)\r\n#12 0x000055c5fab8b53d llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) NewPMDriver.cpp:0:0\r\n#13 0x000055c5f9a1d88a llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/work/llvm/build/bin/opt+0x434488a)\r\n#14 0x000055c5fab846eb llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/work/llvm/build/bin/opt+0x54ab6eb)\r\n#15 0x000055c5f97d4609 optMain (/work/llvm/build/bin/opt+0x40fb609)\r\n#16 0x00007faf4da29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#17 0x00007faf4da29e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#18 0x00007faf4da29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#19 0x000055c5f97ce0a5 _start (/work/llvm/build/bin/opt+0x40f50a5)\r\nfish: Job 1, '/work/llvm/build/bin/opt test2.…' terminated by signal SIGABRT (Abort)\r\n```"
},
{
"author": "ParkHanbum",
"body": "we have the test for second case at musttail-invalid.ll\r\n```declare i32 @not_tail_pos_callee()\r\ndefine i32 @not_tail_pos() {\r\n; CHECK: musttail call must precede a ret with an optional bitcast\r\n %v = musttail call i32 @not_tail_pos_callee()\r\n %w = add i32 %v, 1\r\n ret i32 %w\r\n}\r\n```\r\n\r\nbut first case is not. maybe we need to add this into testcase.\r\n\r\nfirst case \r\n```void Verifier::verifyMustTailCall(CallInst &CI) {\r\n Check(!CI.isInlineAsm(), \"cannot use musttail call with inline asm\", &CI);\r\n\r\n Function *F = CI.getParent()->getParent();\r\n FunctionType *CallerTy = F->getFunctionType();\r\n FunctionType *CalleeTy = CI.getFunctionType();\r\n Check(CallerTy->isVarArg() == CalleeTy->isVarArg(),\r\n \"cannot guarantee tail call due to mismatched varargs\", &CI);\r\n Check(isTypeCongruent(CallerTy->getReturnType(), CalleeTy->getReturnType()),\r\n \"cannot guarantee tail call due to mismatched return types\", F, CallerTy->getReturnType(), &CI, CalleeTy->getReturnType());\r\n```\r\n\r\nCallInst: %1 = musttail call i32 @F38()\r\nReturn type of Caller : %struct.S = type { i32 }\r\nReturn type of Callee: i32\r\n\r\nThis is weird. \r\nI couldn't understand why `%struct.S = type { i32 }` is changed to `i32` at `%3 = musttail call %struct.S @F38()`\r\n\r\nbut after change it to `i32` then it works.\r\n```\r\n%struct.S = type { i32 }\r\n\r\ndefine internal %struct.S @F38() {\r\n ret %struct.S { i32 0 }\r\n}\r\n\r\ndefine i32 @F36() {\r\n %3 = musttail call i32 @F38()\r\n ret i32 %3\r\n}\r\n```\r\n```\r\n% bin/opt --passes=deadargelim test.ll -S \r\n; ModuleID = 'test.ll'\r\nsource_filename = \"test.ll\"\r\n\r\n%struct.S = type { i32 }\r\n\r\ndefine internal %struct.S @F38() {\r\n ret %struct.S zeroinitializer\r\n}\r\n\r\ndefine i32 @F36() {\r\n %1 = musttail call i32 @F38()\r\n ret i32 %1\r\n}\r\n\r\n```\r\n\r\nis this normal?"
},
{
"author": "ParkHanbum",
"body": "I found why it causes, maybe.\r\n```\r\nsource_filename = \"test.ll\"\r\n\r\n%struct.S = type { i32 }\r\n\r\ndefine internal i32 @F38() {\r\n %oldret = extractvalue %struct.S zeroinitializer, 0\r\n ret i32 %oldret\r\n}\r\n\r\ndefine %struct.S @F36() {\r\n %1 = musttail call i32 @F38()\r\n %oldret = insertvalue %struct.S poison, i32 %1, 0\r\n ret %struct.S %oldret\r\n}\r\n\r\n```\r\n\r\n"
},
{
"author": "ParkHanbum",
"body": "we create new return type in here\r\n```\r\n// Look at each of the original return values individually.\r\n for (unsigned Ri = 0; Ri != RetCount; ++Ri) {\r\n RetOrArg Ret = createRet(F, Ri);\r\n if (LiveValues.erase(Ret)) {\r\n RetTypes.push_back(getRetComponentType(F, Ri));\r\n NewRetIdxs[Ri] = RetTypes.size() - 1;\r\n } else {\r\n ++NumRetValsEliminated;\r\n LLVM_DEBUG(\r\n dbgs() << \"DeadArgumentEliminationPass - Removing return value \"\r\n << Ri << \" from \" << F->getName() << \"\\n\");\r\n }\r\n \r\n```\r\n\r\nI tested disabling the code that creates the new return type to see if it would make a quick improvement\r\n```\r\nNRetTy = RetTy;\r\n```\r\n\r\nit seems to work\r\n```\r\n; ModuleID = 'test.ll'\r\nsource_filename = \"test.ll\"\r\n\r\n%struct.S = type { i32 }\r\n\r\ndefine internal %struct.S @F38() {\r\n ret %struct.S zeroinitializer\r\n}\r\n\r\ndefine %struct.S @F36() {\r\n %1 = musttail call %struct.S @F38()\r\n ret %struct.S %1\r\n}\r\n\r\n```\r\n\r\nIf this is a defect,\r\n1. do not change return type if it conflict with caller's return type when CB was musttail call.\r\n2. if caller's return type is conflict with new return type then change all of uses type.\r\n\r\nwe can fix it by choosing one of above. IMO\r\nhow do you think?\r\n\r\nplease let me know this issue need to fix or not~\r\n\r\n@dtcxzyw Can you please review this issue?\r\n"
},
{
"author": "dtcxzyw",
"body": "cc @nikic @efriedma-quic "
},
{
"author": "efriedma-quic",
"body": "I'm not sure why we're trying to run DAE on functions where we can't change the signature; why doesn't the current check for musttail callers handle this?"
},
{
"author": "ParkHanbum",
"body": "@efriedma-quic Don't think it needs to be fix?\r\n"
},
{
"author": "efriedma-quic",
"body": "Not sure what you're saying. I'm asking about the structure of the existing code. There are already checks for musttail calls in DeadArgumentElimination, which at first glance should exclude transforming cases like this. Can those checks be extended to also exclude this case?"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
113997
|
https://github.com/llvm/llvm-project/issues/113997
|
miscompilation
|
bef3b54ea10a564a2de72f658f2efd64f537c079
| 2024-10-29T04:11:49 |
[
"llvm/test/Transforms/GVN",
"llvm/test/Transforms/NewGVN"
] |
{
"fix_commit": "f16bff1261a92169992c6edf6bc6b38d1c815c8d",
"components": [
"GVN",
"NewGVN",
"Local"
],
"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": [
[
3508,
3513
]
],
"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": [
[
2189,
2194
],
[
2734,
2740
],
[
3000,
3006
]
],
"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": [
[
3854,
3859
],
[
3963,
3968
],
[
4069,
4076
],
[
4112,
4128
]
],
"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": [
"llvm::patchReplacementInstruction"
],
"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",
"GVNPass::processAssumeIntrinsic",
"GVNPass::processInstruction",
"patchAndReplaceAllUsesWith"
],
"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": [
"NewGVN::eliminateInstructions",
"NewGVN::findPHIOfOpsLeader"
],
"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 f16bff1261a92169992c6edf6bc6b38d1c815c8d
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Fri Nov 1 12:44:33 2024 +0800
[GVN][NewGVN][Local] Handle attributes for function calls after CSE (#114011)
This patch intersects attributes of two calls to avoid introducing UB.
It also skips incompatible call pairs in GVN/NewGVN. However, I cannot
provide negative tests for these changes.
Fixes https://github.com/llvm/llvm-project/issues/113997.
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index 2ba600497e00..ad9b1217089d 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -2189,6 +2189,16 @@ bool GVNPass::processAssumeIntrinsic(AssumeInst *IntrinsicI) {
return Changed;
}
+// Return true iff V1 can be replaced with V2.
+static bool canBeReplacedBy(Value *V1, Value *V2) {
+ if (auto *CB1 = dyn_cast<CallBase>(V1))
+ if (auto *CB2 = dyn_cast<CallBase>(V2))
+ return CB1->getAttributes()
+ .intersectWith(CB2->getContext(), CB2->getAttributes())
+ .has_value();
+ return true;
+}
+
static void patchAndReplaceAllUsesWith(Instruction *I, Value *Repl) {
patchReplacementInstruction(I, Repl);
I->replaceAllUsesWith(Repl);
@@ -2734,7 +2744,7 @@ bool GVNPass::processInstruction(Instruction *I) {
// Perform fast-path value-number based elimination of values inherited from
// dominators.
Value *Repl = findLeader(I->getParent(), Num);
- if (!Repl) {
+ if (!Repl || !canBeReplacedBy(I, Repl)) {
// Failure, just remember this instance for future use.
LeaderTable.insert(Num, I, I->getParent());
return false;
@@ -3000,7 +3010,7 @@ bool GVNPass::performScalarPRE(Instruction *CurInst) {
uint32_t TValNo = VN.phiTranslate(P, CurrentBlock, ValNo, *this);
Value *predV = findLeader(P, TValNo);
- if (!predV) {
+ if (!predV || !canBeReplacedBy(CurInst, predV)) {
predMap.push_back(std::make_pair(static_cast<Value *>(nullptr), P));
PREPred = P;
++NumWithout;
diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp
index 13d9e8f186b4..6800ad51cc0a 100644
--- a/llvm/lib/Transforms/Scalar/NewGVN.cpp
+++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp
@@ -3854,6 +3854,16 @@ Value *NewGVN::findPHIOfOpsLeader(const Expression *E,
return nullptr;
}
+// Return true iff V1 can be replaced with V2.
+static bool canBeReplacedBy(Value *V1, Value *V2) {
+ if (auto *CB1 = dyn_cast<CallBase>(V1))
+ if (auto *CB2 = dyn_cast<CallBase>(V2))
+ return CB1->getAttributes()
+ .intersectWith(CB2->getContext(), CB2->getAttributes())
+ .has_value();
+ return true;
+}
+
bool NewGVN::eliminateInstructions(Function &F) {
// This is a non-standard eliminator. The normal way to eliminate is
// to walk the dominator tree in order, keeping track of available
@@ -3963,6 +3973,9 @@ bool NewGVN::eliminateInstructions(Function &F) {
MembersLeft.insert(Member);
continue;
}
+ if (!canBeReplacedBy(Member, Leader))
+ continue;
+
LLVM_DEBUG(dbgs() << "Found replacement " << *(Leader) << " for "
<< *Member << "\n");
auto *I = cast<Instruction>(Member);
@@ -4069,8 +4082,11 @@ bool NewGVN::eliminateInstructions(Function &F) {
if (DominatingLeader != Def) {
// Even if the instruction is removed, we still need to update
// flags/metadata due to downstreams users of the leader.
- if (!match(DefI, m_Intrinsic<Intrinsic::ssa_copy>()))
+ if (!match(DefI, m_Intrinsic<Intrinsic::ssa_copy>())) {
+ if (!canBeReplacedBy(DefI, DominatingLeader))
+ continue;
patchReplacementInstruction(DefI, DominatingLeader);
+ }
markInstructionForDeletion(DefI);
}
@@ -4112,17 +4128,21 @@ bool NewGVN::eliminateInstructions(Function &F) {
// Don't replace our existing users with ourselves.
if (U->get() == DominatingLeader)
continue;
- LLVM_DEBUG(dbgs()
- << "Found replacement " << *DominatingLeader << " for "
- << *U->get() << " in " << *(U->getUser()) << "\n");
// If we replaced something in an instruction, handle the patching of
// metadata. Skip this if we are replacing predicateinfo with its
// original operand, as we already know we can just drop it.
auto *ReplacedInst = cast<Instruction>(U->get());
auto *PI = PredInfo->getPredicateInfoFor(ReplacedInst);
- if (!PI || DominatingLeader != PI->OriginalOp)
+ if (!PI || DominatingLeader != PI->OriginalOp) {
+ if (!canBeReplacedBy(ReplacedInst, DominatingLeader))
+ continue;
patchReplacementInstruction(ReplacedInst, DominatingLeader);
+ }
+
+ LLVM_DEBUG(dbgs()
+ << "Found replacement " << *DominatingLeader << " for "
+ << *U->get() << " in " << *(U->getUser()) << "\n");
U->set(DominatingLeader);
// This is now a use of the dominating leader, which means if the
// dominating leader was dead, it's now live!
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 65c1669f92b4..47a704925596 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -3508,6 +3508,17 @@ void llvm::patchReplacementInstruction(Instruction *I, Value *Repl) {
else if (!isa<LoadInst>(I))
ReplInst->andIRFlags(I);
+ // Handle attributes.
+ if (auto *CB1 = dyn_cast<CallBase>(ReplInst)) {
+ if (auto *CB2 = dyn_cast<CallBase>(I)) {
+ bool Success = CB1->tryIntersectAttributes(CB2);
+ assert(Success && "We should not be trying to sink callbases "
+ "with non-intersectable attributes");
+ // For NDEBUG Compile.
+ (void)Success;
+ }
+ }
+
// FIXME: If both the original and replacement value are part of the
// same control-flow region (meaning that the execution of one
// guarantees the execution of the other), then we can combine the
|
[
{
"file": "llvm/test/Transforms/GVN/pr113997.ll",
"commands": [
"opt -S -passes=gvn < %s"
],
"tests": [
{
"test_name": "bucket",
"test_body": "define i1 @bucket(i32 noundef %x) {\n %cmp1 = icmp sgt i32 %x, 0\n %ctpop1 = tail call range(i32 1, 32) i32 @llvm.ctpop.i32(i32 %x)\n %cmp2 = icmp samesign ult i32 %ctpop1, 2\n %cond = select i1 %cmp1, i1 %cmp2, i1 false\n br i1 %cond, label %if.then, label %if.else\n\nif.else: ; preds = %0\n %ctpop2 = tail call range(i32 0, 33) i32 @llvm.ctpop.i32(i32 %x)\n %res = icmp eq i32 %ctpop2, 1\n ret i1 %res\n\nif.then: ; preds = %0\n ret i1 false\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.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/NewGVN/pr113997.ll",
"commands": [
"opt -S -passes=newgvn < %s"
],
"tests": [
{
"test_name": "bucket",
"test_body": "define i1 @bucket(i32 noundef %x) {\n %cmp1 = icmp sgt i32 %x, 0\n %ctpop1 = tail call range(i32 1, 32) i32 @llvm.ctpop.i32(i32 %x)\n %cmp2 = icmp samesign ult i32 %ctpop1, 2\n %cond = select i1 %cmp1, i1 %cmp2, i1 false\n br i1 %cond, label %if.then, label %if.else\n\nif.else: ; preds = %0\n %ctpop2 = tail call range(i32 0, 33) i32 @llvm.ctpop.i32(i32 %x)\n %res = icmp eq i32 %ctpop2, 1\n ret i1 %res\n\nif.then: ; preds = %0\n ret i1 false\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[GVNPass] Range attribute should be handled after CSE",
"body": "Reproducer: https://alive2.llvm.org/ce/z/HAnoKn\r\n```\r\ndefine i1 @src(i32 noundef %x) {\r\n %cmp1 = icmp sgt i32 %x, 0\r\n %ctpop1 = tail call range(i32 1, 32) i32 @llvm.ctpop.i32(i32 %x)\r\n %cmp2 = icmp samesign ult i32 %ctpop1, 2\r\n %cond = select i1 %cmp1, i1 %cmp2, i1 false\r\n br i1 %cond, label %if.then, label %if.else\r\n\r\nif.else:\r\n %ctpop2 = tail call range(i32 0, 33) i32 @llvm.ctpop.i32(i32 %x)\r\n %res = icmp eq i32 %ctpop2, 1\r\n ret i1 %res\r\n\r\nif.then:\r\n ret i1 false\r\n}\r\n\r\ndefine i1 @tgt(i32 noundef %x) {\r\n %cmp1 = icmp sgt i32 %x, 0\r\n %ctpop1 = tail call range(i32 1, 32) i32 @llvm.ctpop.i32(i32 %x)\r\n %cmp2 = icmp samesign ult i32 %ctpop1, 2\r\n %cond = select i1 %cmp1, i1 %cmp2, i1 false\r\n br i1 %cond, label %if.then, label %if.else\r\n\r\nif.else:\r\n %res = icmp eq i32 %ctpop1, 1\r\n ret i1 %res\r\n\r\nif.then:\r\n ret i1 false\r\n}\r\n```\r\n```\r\n\r\n----------------------------------------\r\ndefine i1 @src(i32 noundef %x) {\r\n#0:\r\n %cmp1 = icmp sgt i32 noundef %x, 0\r\n %ctpop1 = ctpop i32 noundef %x\r\n %#range_0_%ctpop1 = !range i32 %ctpop1, i32 1, i32 32\r\n %cmp2 = icmp samesign ult i32 %#range_0_%ctpop1, 2\r\n %cond = select i1 %cmp1, i1 %cmp2, i1 0\r\n br i1 %cond, label %if.then, label %if.else\r\n\r\nif.else:\r\n %ctpop2 = ctpop i32 noundef %x\r\n %#range_1_%ctpop2 = !range i32 %ctpop2, i32 0, i32 33\r\n %res = icmp eq i32 %#range_1_%ctpop2, 1\r\n ret i1 %res\r\n\r\nif.then:\r\n ret i1 0\r\n}\r\n=>\r\ndefine i1 @tgt(i32 noundef %x) {\r\n#0:\r\n %cmp1 = icmp sgt i32 noundef %x, 0\r\n %ctpop1 = ctpop i32 noundef %x\r\n %#range_0_%ctpop1 = !range i32 %ctpop1, i32 1, i32 32\r\n %cmp2 = icmp samesign ult i32 %#range_0_%ctpop1, 2\r\n %cond = select i1 %cmp1, i1 %cmp2, i1 0\r\n br i1 %cond, label %if.then, label %if.else\r\n\r\nif.else:\r\n %res = icmp eq i32 %#range_0_%ctpop1, 1\r\n ret i1 %res\r\n\r\nif.then:\r\n ret i1 0\r\n}\r\nTransformation doesn't verify!\r\n\r\nERROR: Target is more poisonous than source\r\n\r\nExample:\r\ni32 noundef %x = #x00000000 (0)\r\n\r\nSource:\r\ni1 %cmp1 = #x0 (0)\r\ni32 %ctpop1 = #x00000000 (0)\r\ni32 %#range_0_%ctpop1 = poison\r\ni1 %cmp2 = poison\r\ni1 %cond = #x0 (0)\r\n >> Jump to %if.else\r\ni32 %ctpop2 = #x00000000 (0)\r\ni32 %#range_1_%ctpop2 = #x00000000 (0)\r\ni1 %res = #x0 (0)\r\n\r\nTarget:\r\ni1 %cmp1 = #x0 (0)\r\ni32 %ctpop1 = #x00000000 (0)\r\ni32 %#range_0_%ctpop1 = poison\r\ni1 %cmp2 = poison\r\ni1 %cond = #x0 (0)\r\n >> Jump to %if.else\r\ni1 %res = poison\r\nSource value: #x0 (0)\r\nTarget value: poison\r\n```\r\n\r\nReported by @pranavk. See https://github.com/llvm/llvm-project/pull/100899#issuecomment-2442780517.\r\n",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:GVN"
],
"comments": []
}
| true |
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
| null |
112922
|
https://github.com/llvm/llvm-project/issues/112922
|
crash
|
b5fa4fee46c1d0046cc395e3338ae13fe6e2cb84
| 2024-10-18T15:25:44 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "2a6b09e0d3d3c1a05d3d5165202a6e68900974b1",
"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": [
[
5738,
5751
],
[
5760,
5767
]
],
"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": [
[
2958,
2968
],
[
2976,
2983
]
],
"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::getInterleaveGroupCost"
],
"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": [
"VPInterleaveRecipe::computeCost"
],
"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 2a6b09e0d3d3c1a05d3d5165202a6e68900974b1
Author: Florian Hahn <flo@fhahn.com>
Date: Fri Oct 18 19:12:39 2024 -0700
[LV] Use type from InsertPos for cost computation of interleave groups.
Previously the legacy cost model would pick the type for the cost
computation depending on the order of the members in the input IR.
This is incompatible with the VPlan-based cost model (independent of
original IR order) and also doesn't match code-gen, which uses the type
of the insert position.
Update the legacy cost model to use the type (and address space) from
the Group's insert position.
This brings the legacy cost model in line with the legacy cost model and
fixes a divergence between both models.
Note that the X86 cost model seems to assign different costs to groups
with i64 and double types. Added a TODO to check.
Fixes https://github.com/llvm/llvm-project/issues/112922.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 857efbdf687c..ce0903b838aa 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -5738,14 +5738,15 @@ LoopVectorizationCostModel::getGatherScatterCost(Instruction *I,
InstructionCost
LoopVectorizationCostModel::getInterleaveGroupCost(Instruction *I,
ElementCount VF) {
- Type *ValTy = getLoadStoreType(I);
- auto *VectorTy = cast<VectorType>(ToVectorTy(ValTy, VF));
- unsigned AS = getLoadStoreAddressSpace(I);
- enum TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
-
const auto *Group = getInterleavedAccessGroup(I);
assert(Group && "Fail to get an interleaved access group.");
+ Instruction *InsertPos = Group->getInsertPos();
+ Type *ValTy = getLoadStoreType(InsertPos);
+ auto *VectorTy = cast<VectorType>(ToVectorTy(ValTy, VF));
+ unsigned AS = getLoadStoreAddressSpace(InsertPos);
+ enum TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
+
unsigned InterleaveFactor = Group->getFactor();
auto *WideVecTy = VectorType::get(ValTy, VF * InterleaveFactor);
@@ -5760,8 +5761,9 @@ LoopVectorizationCostModel::getInterleaveGroupCost(Instruction *I,
(Group->requiresScalarEpilogue() && !isScalarEpilogueAllowed()) ||
(isa<StoreInst>(I) && (Group->getNumMembers() < Group->getFactor()));
InstructionCost Cost = TTI.getInterleavedMemoryOpCost(
- I->getOpcode(), WideVecTy, Group->getFactor(), Indices, Group->getAlign(),
- AS, CostKind, Legal->isMaskRequired(I), UseMaskForGaps);
+ InsertPos->getOpcode(), WideVecTy, Group->getFactor(), Indices,
+ Group->getAlign(), AS, CostKind, Legal->isMaskRequired(I),
+ UseMaskForGaps);
if (Group->isReverse()) {
// TODO: Add support for reversed masked interleaved access.
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index f4a1f58debba..41f13cc2d9a9 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -2958,11 +2958,20 @@ void VPInterleaveRecipe::print(raw_ostream &O, const Twine &Indent,
InstructionCost VPInterleaveRecipe::computeCost(ElementCount VF,
VPCostContext &Ctx) const {
- Instruction *I = getInsertPos();
+ Instruction *InsertPos = getInsertPos();
+ // Find the VPValue index of the interleave group. We need to skip gaps.
+ unsigned InsertPosIdx = 0;
+ for (unsigned Idx = 0; IG->getFactor(); ++Idx)
+ if (auto *Member = IG->getMember(Idx)) {
+ if (Member == InsertPos)
+ break;
+ InsertPosIdx++;
+ }
Type *ValTy = Ctx.Types.inferScalarType(
- getNumDefinedValues() > 0 ? getVPValue(0) : getStoredValues()[0]);
+ getNumDefinedValues() > 0 ? getVPValue(InsertPosIdx)
+ : getStoredValues()[InsertPosIdx]);
auto *VectorTy = cast<VectorType>(ToVectorTy(ValTy, VF));
- unsigned AS = getLoadStoreAddressSpace(I);
+ unsigned AS = getLoadStoreAddressSpace(InsertPos);
enum TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
unsigned InterleaveFactor = IG->getFactor();
@@ -2976,8 +2985,8 @@ InstructionCost VPInterleaveRecipe::computeCost(ElementCount VF,
// Calculate the cost of the whole interleaved group.
InstructionCost Cost = Ctx.TTI.getInterleavedMemoryOpCost(
- I->getOpcode(), WideVecTy, IG->getFactor(), Indices, IG->getAlign(), AS,
- CostKind, getMask(), NeedsMaskForGaps);
+ InsertPos->getOpcode(), WideVecTy, IG->getFactor(), Indices,
+ IG->getAlign(), AS, CostKind, getMask(), NeedsMaskForGaps);
if (!IG->isReverse())
return Cost;
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/X86/interleave-cost.ll",
"commands": [
"opt -p loop-vectorize -S %s"
],
"tests": [
{
"test_name": "geps_feeding_interleave_groups_with_reuse",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-apple-macosx10.15.0\"\n\ndefine void @geps_feeding_interleave_groups_with_reuse(ptr %arg, i64 %arg1, ptr %arg2) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %shl.iv.5 = shl i64 %iv, 5\n %gep.1 = getelementptr i8, ptr %arg, i64 %shl.iv.5\n %add.5 = or disjoint i64 %shl.iv.5, 16\n %gep.2 = getelementptr i8, ptr %arg, i64 %add.5\n %shl.iv.4 = shl i64 %iv, 4\n %gep.3 = getelementptr i8, ptr %arg2, i64 %shl.iv.4\n %l.1 = load float, ptr %gep.1, align 4\n %l.2 = load float, ptr %gep.2, align 4\n %add.1 = fadd float %l.1, %l.2\n %mul.1 = fmul float %add.1, 0.000000e+00\n store float %mul.1, ptr %gep.3, align 4\n %gep.4 = getelementptr i8, ptr %gep.1, i64 4\n %l.3 = load float, ptr %gep.4, align 4\n %gep.5 = getelementptr i8, ptr %gep.2, i64 4\n %l.4 = load float, ptr %gep.5, align 4\n %add.2 = fadd float %l.3, %l.4\n %mul.2 = fmul float %add.2, 0.000000e+00\n %gep.6 = getelementptr i8, ptr %gep.3, i64 4\n store float %mul.2, ptr %gep.6, align 4\n %gep.7 = getelementptr i8, ptr %gep.1, i64 8\n %l.5 = load float, ptr %gep.7, align 4\n %gep.8 = getelementptr i8, ptr %gep.2, i64 8\n %l.6 = load float, ptr %gep.8, align 4\n %add.3 = fadd float %l.5, %l.6\n %mul.3 = fmul float %add.3, 0.000000e+00\n %gep.9 = getelementptr i8, ptr %gep.3, i64 8\n store float %mul.3, ptr %gep.9, align 4\n %i27 = getelementptr i8, ptr %gep.1, i64 12\n %l.7 = load float, ptr %i27, align 4\n %gep.10 = getelementptr i8, ptr %gep.2, i64 12\n %l.8 = load float, ptr %gep.10, align 4\n %add.4 = fadd float %l.7, %l.8\n %mul.4 = fmul float %add.4, 0.000000e+00\n %gep.11 = getelementptr i8, ptr %gep.3, i64 12\n store float %mul.4, ptr %gep.11, align 4\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv, %arg1\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+sse4.2\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "geps_feeding_interleave_groups_with_reuse2",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-apple-macosx10.15.0\"\n\ndefine void @geps_feeding_interleave_groups_with_reuse2(ptr %A, ptr %B, i64 %N) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next.7, %loop ]\n %shr.1 = lshr exact i64 %iv, 1\n %gep.B = getelementptr nusw i32, ptr %B, i64 %shr.1\n %l = load i32, ptr %gep.B, align 4\n %gep.A = getelementptr i32, ptr %A, i64 %iv\n store i32 %l, ptr %gep.A, align 4\n %iv.next = or disjoint i64 %iv, 1\n %gep.A.1 = getelementptr i32, ptr %A, i64 %iv.next\n store i32 0, ptr %gep.A.1, align 4\n %iv.next.1 = or disjoint i64 %iv, 2\n %shr.2 = lshr exact i64 %iv.next.1, 1\n %gep.B.2 = getelementptr i32, ptr %B, i64 %shr.2\n %0 = load i32, ptr %gep.B.2, align 4\n %gep.A.2 = getelementptr i32, ptr %A, i64 %iv.next.1\n store i32 %0, ptr %gep.A.2, align 4\n %iv.next.2 = or disjoint i64 %iv, 3\n %gep.A.3 = getelementptr i32, ptr %A, i64 %iv.next.2\n store i32 0, ptr %gep.A.3, align 4\n %iv.next.3 = or disjoint i64 %iv, 4\n %gep.B.4 = getelementptr i32, ptr %B, i64 %iv\n %1 = load i32, ptr %gep.B.4, align 4\n %gep.A.4 = getelementptr i32, ptr %A, i64 %iv.next.3\n store i32 %1, ptr %gep.A.4, align 4\n %iv.next.4 = or disjoint i64 %iv, 5\n %gep.A.5 = getelementptr i32, ptr %A, i64 %iv.next.4\n store i32 0, ptr %gep.A.5, align 4\n %iv.next.5 = or disjoint i64 %iv, 6\n %gep.A.6 = getelementptr i32, ptr %A, i64 %iv.next.5\n store i32 0, ptr %gep.A.6, align 4\n %iv.next.6 = or disjoint i64 %iv, 7\n %gep.A.7 = getelementptr i32, ptr %A, i64 %iv.next.6\n store i32 0, ptr %gep.A.7, align 4\n %iv.next.7 = add nuw nsw i64 %iv, 8\n %ec = icmp eq i64 %iv, %N\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { \"min-legal-vector-width\"=\"0\" \"target-cpu\"=\"cascadelake\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "interleave_store_double_i64_2",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-apple-macosx10.15.0\"\n\ndefine void @interleave_store_double_i64_2(ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep.1 = getelementptr { i64, double }, ptr %dst, i64 %iv, i32 1\n store double 0.000000e+00, ptr %gep.1, align 8\n %gep.0 = getelementptr { i64, double }, ptr %dst, i64 %iv\n store i64 %iv, ptr %gep.0, align 8\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv, 1\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "interleave_store_i64_double",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-apple-macosx10.15.0\"\n\ndefine void @interleave_store_i64_double(ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep.0 = getelementptr { double, i64 }, ptr %dst, i64 %iv\n store double 0.000000e+00, ptr %gep.0, align 8\n %gep.1 = getelementptr { double, i64 }, ptr %dst, i64 %iv, i32 1\n store i64 %iv, ptr %gep.1, align 8\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv, 1\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_free_instructions_feeding_geps_for_interleave_groups",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-apple-macosx10.15.0\"\n\ndefine void @test_free_instructions_feeding_geps_for_interleave_groups(ptr noalias %p.invar, ptr noalias %dst.1, ptr noalias %dst.2) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %l.0 = load float, ptr %p.invar, align 4\n %iv.mul = shl i64 %iv, 2\n %gep.dst.19 = getelementptr float, ptr %dst.1, i64 %iv.mul\n store float %l.0, ptr %gep.dst.19, align 4\n %l.1 = load float, ptr %p.invar, align 4\n %add.1 = or disjoint i64 %iv.mul, 1\n %gep.dst.119 = getelementptr float, ptr %dst.1, i64 %add.1\n store float %l.1, ptr %gep.dst.119, align 4\n %add.2 = or disjoint i64 %iv.mul, 2\n %gep.dst.129 = getelementptr float, ptr %dst.1, i64 %add.2\n store float 0.000000e+00, ptr %gep.dst.129, align 4\n %add.3 = or disjoint i64 %iv.mul, 3\n %gep.dst.140 = getelementptr float, ptr %dst.1, i64 %add.3\n store float 0.000000e+00, ptr %gep.dst.140, align 4\n %l.2 = load float, ptr %p.invar, align 4\n %gep.dst.247 = getelementptr float, ptr %dst.2, i64 %iv.mul\n store float %l.2, ptr %gep.dst.247, align 4\n %gep.dst.255 = getelementptr float, ptr %dst.2, i64 %add.1\n store float 0.000000e+00, ptr %gep.dst.255, align 4\n %gep.dst.265 = getelementptr float, ptr %dst.2, i64 %add.2\n store float 0.000000e+00, ptr %gep.dst.265, align 4\n %gep.dst.276 = getelementptr float, ptr %dst.2, i64 %add.3\n store float 0.000000e+00, ptr %gep.dst.276, align 4\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv.next, 0\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "interleave_store_double_i64",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-apple-macosx10.15.0\"\n\ndefine void @interleave_store_double_i64(ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep.1 = getelementptr { double, i64 }, ptr %dst, i64 %iv, i32 1\n store i64 %iv, ptr %gep.1, align 8\n %gep.0 = getelementptr { double, i64 }, ptr %dst, i64 %iv\n store double 0.000000e+00, ptr %gep.0, align 8\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv, 1\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "interleave_store_i64_double_2",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-apple-macosx10.15.0\"\n\ndefine void @interleave_store_i64_double_2(ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep.0 = getelementptr { i64, double }, ptr %dst, i64 %iv\n store i64 %iv, ptr %gep.0, align 8\n %gep.1 = getelementptr { i64, double }, ptr %dst, i64 %iv, i32 1\n store double 0.000000e+00, ptr %gep.1, align 8\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv, 1\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[clang] Assertion in `llvm::LoopVectorizationPlanner::computeBestVF()`",
"body": "When building the METIS (v5.1.0) library (GKLib) an assertion is thrown during LoopVectorize. This error was introduced within the past few days (see git sha of broken and working versions below).\r\n\r\n#### Error:\r\n```shell\r\nclang: /mnt/thera/cicd/actions_work/ActionsRunner/ActionsRunner/trunk_repos/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7457: 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\nStack dump:\r\n0. Program arguments: /share/contrib-modules/Core/llvm/2024-10-16/bin/clang -I/home/bcornill/libraries/metis-5.1.0/GKlib/. -I/home/bcornill/libraries/metis-5.1.0/GKlib/test -DLINUX -D_FILE_OFFSET_BITS=64 -DNDEBUG -DNDEBUG2 -DHAVE_EXECINFO_H -DHAVE_GETLINE -O3 -MD -MT CMakeFiles/GKlib.dir/blas.c.o -MF CMakeFiles/GKlib.dir/blas.c.o.d -o CMakeFiles/GKlib.dir/blas.c.o -c /home/bcornill/libraries/metis-5.1.0/GKlib/blas.c\r\n1. <eof> parser at end of file\r\n2. Optimizer\r\n3. 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 \"/home/bcornill/libraries/metis-5.1.0/GKlib/blas.c\"\r\n4. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"gk_dargmax_n\"\r\n #0 0x00007fa15911cc8b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/share/contrib-modules/Core/llvm/2024-10-16_20.0-0/bin/../lib/libLLVMSupport.so.20.0git+0x1c2c8b)\r\n #1 0x00007fa15911a664 llvm::sys::CleanupOnSignal(unsigned long) (/share/contrib-modules/Core/llvm/2024-10-16_20.0-0/bin/../lib/libLLVMSupport.so.20.0git+0x1c0664)\r\n #2 0x00007fa1590227f8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0\r\n #3 0x00007fa1615e0dd0 __restore_rt sigaction.c:0:0\r\n #4 0x00007fa15821e70f raise (/lib64/libc.so.6+0x3770f)\r\n #5 0x00007fa158208b25 abort (/lib64/libc.so.6+0x21b25)\r\n #6 0x00007fa1582089f9 _nl_load_domain.cold.0 loadmsgcat.c:0:0\r\n #7 0x00007fa158216cc6 .annobin___GI___assert_fail.end assert.c:0:0\r\n #8 0x00007fa15db3af1b llvm::LoopVectorizationPlanner::computeBestVF() (/share/contrib-modules/Core/llvm/2024-10-16_20.0-0/bin/../lib/libLLVMVectorize.so.20.0git+0xb5f1b)\r\n #9 0x00007fa15db52d46 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/share/contrib-modules/Core/llvm/2024-10-16_20.0-0/bin/../lib/libLLVMVectorize.so.20.0git+0xcdd46)\r\n#10 0x00007fa15db55ed1 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/share/contrib-modules/Core/llvm/2024-10-16_20.0-0/bin/../lib/libLLVMVectorize.so.20.0git+0xd0ed1)\r\n#11 0x00007fa15db56517 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/share/contrib-modules/Core/llvm/2024-10-16_20.0-0/bin/../lib/libLLVMVectorize.so.20.0git+0xd1517)\r\n#12 0x00007fa155d90a9e llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/share/contrib-modules/Core/llvm/2024-10-16_20.0-0/bin/../lib/../lib/libLLVMPasses.so.20.0git+0x76a9e)\r\n#13 0x00007fa15998eab7 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/share/contrib-modules/Core/llvm/2024-10-16_20.0-0/bin/../lib/libLLVMCore.so.20.0git+0x323ab7)\r\n#14 0x00007fa16434e17e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/share/contrib-modules/Core/llvm/2024-10-16_20.0-0/bin/../lib/libLLVMX86CodeGen.so.20.0git+0xa917e)\r\n#15 0x00007fa15998ce55 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/share/contrib-modules/Core/llvm/2024-10-16_20.0-0/bin/../lib/libLLVMCore.so.20.0git+0x321e55)\r\n#16 0x00007fa16434e56e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/share/contrib-modules/Core/llvm/2024-10-16_20.0-0/bin/../lib/libLLVMX86CodeGen.so.20.0git+0xa956e)\r\n#17 0x00007fa15998d9bc llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/share/contrib-modules/Core/llvm/2024-10-16_20.0-0/bin/../lib/libLLVMCore.so.20.0git+0x3229bc)\r\n#18 0x00007fa15faab288 (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 0x00007fa15faaeb9c 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*) (/share/contrib-modules/Core/llvm/2024-10-16_20.0-0/bin/../lib/libclangCodeGen.so.20.0git+0x111b9c)\r\n#20 0x00007fa15ffdd293 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/share/contrib-modules/Core/llvm/2024-10-16_20.0-0/bin/../lib/libclangCodeGen.so.20.0git+0x640293)\r\n#21 0x00007fa150c5592c clang::ParseAST(clang::Sema&, bool, bool) (/share/contrib-modules/Core/llvm/2024-10-16_20.0-0/bin/../lib/../lib/libclangParse.so.20.0git+0x3c92c)\r\n#22 0x00007fa15d75dee9 clang::FrontendAction::Execute() (/share/contrib-modules/Core/llvm/2024-10-16_20.0-0/bin/../lib/libclangFrontend.so.20.0git+0x138ee9)\r\n#23 0x00007fa15d6ceb05 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/share/contrib-modules/Core/llvm/2024-10-16_20.0-0/bin/../lib/libclangFrontend.so.20.0git+0xa9b05)\r\n#24 0x00007fa1613cad83 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/share/contrib-modules/Core/llvm/2024-10-16_20.0-0/bin/../lib/libclangFrontendTool.so.20.0git+0x4d83)\r\n#25 0x00000000004141c7 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/share/contrib-modules/Core/llvm/2024-10-16/bin/clang+0x4141c7)\r\n#26 0x000000000040b96a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#27 0x00007fa15d135049 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0\r\n#28 0x00007fa159022cb4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/share/contrib-modules/Core/llvm/2024-10-16_20.0-0/bin/../lib/libLLVMSupport.so.20.0git+0xc8cb4)\r\n#29 0x00007fa15d13589e clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0\r\n#30 0x00007fa15d0f22fc clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/share/contrib-modules/Core/llvm/2024-10-16_20.0-0/bin/../lib/libclangDriver.so.20.0git+0x922fc)\r\n#31 0x00007fa15d0f33fd clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/share/contrib-modules/Core/llvm/2024-10-16_20.0-0/bin/../lib/libclangDriver.so.20.0git+0x933fd)\r\n#32 0x00007fa15d1039c4 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/share/contrib-modules/Core/llvm/2024-10-16_20.0-0/bin/../lib/libclangDriver.so.20.0git+0xa39c4)\r\n#33 0x0000000000410b5b clang_main(int, char**, llvm::ToolContext const&) (/share/contrib-modules/Core/llvm/2024-10-16/bin/clang+0x410b5b)\r\n#34 0x000000000040b074 main (/share/contrib-modules/Core/llvm/2024-10-16/bin/clang+0x40b074)\r\n#35 0x00007fa15820a6a3 __libc_start_main (/lib64/libc.so.6+0x236a3)\r\n#36 0x000000000040b0be _start (/share/contrib-modules/Core/llvm/2024-10-16/bin/clang+0x40b0be)\r\nclang: error: clang frontend command failed with exit code 134 (use -v to see invocation)\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project ae68d532f810e217c747b10b26aeea3bb84c3844)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /share/contrib-modules/Core/llvm/2024-10-16_20.0-0/bin\r\nBuild config: +assertions\r\nConfiguration file: /share/contrib-modules/Core/llvm/2024-10-16_20.0-0/bin/clang.cfg\r\nclang: note: diagnostic msg:\r\n********************\r\n\r\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\r\nPreprocessed source(s) and associated run script(s) are located at:\r\nclang: note: diagnostic msg: /tmp/blas-9fe25d.c\r\nclang: note: diagnostic msg: /tmp/blas-9fe25d.sh\r\nclang: note: diagnostic msg:\r\n\r\n********************\r\n```\r\n#### Reproducer:\r\n[gklib-blas.tar.gz](https://github.com/user-attachments/files/17437550/gklib-blas.tar.gz)\r\n\r\n#### Broken Versions:\r\n```shell\r\n>> clang --version\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project ae68d532f810e217c747b10b26aeea3bb84c3844)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /share/contrib-modules/Core/llvm/2024-10-16_20.0-0/bin\r\nBuild config: +assertions\r\nConfiguration file: /share/contrib-modules/Core/llvm/2024-10-16_20.0-0/bin/clang.cfg\r\n\r\n>> clang --version\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project af90e7c5161de9a36af768dd5c9d73464e0eed64)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /share/contrib-modules/Core/llvm/2024-10-18_20.0-0/bin\r\nBuild config: +assertions\r\nConfiguration file: /share/contrib-modules/Core/llvm/2024-10-18_20.0-0/bin/clang.cfg\r\n```\r\n\r\n#### Working version:\r\n```shell\r\n>> clang --version\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project 48deb3568eb2452ff385b04b8f71c34121f47387)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /share/contrib-modules/Core/llvm/2024-10-13_20.0-0/bin\r\nBuild config: +assertions\r\nConfiguration file: /share/contrib-modules/Core/llvm/2024-10-13_20.0-0/bin/clang.cfg\r\n```",
"author": "bcornille",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "fhahn",
"body": "Thanks, taking a look!"
}
]
}
| true |
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
| null |
80113
|
https://github.com/llvm/llvm-project/issues/80113
|
miscompilation
|
24a804101b67676aa9fa7f1097043ddd9e2ac1b6
| 2024-01-31T08:09:28 |
[
"llvm/test/Transforms/BDCE"
] |
{
"fix_commit": "b210cbbd0eb8ef7cd2735e99570474e6e53ee00b",
"components": [
"BDCE"
],
"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": [
[
45,
59
],
[
79,
90
]
],
"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": 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": [
"clearAssumptionsOfUsers"
],
"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 b210cbbd0eb8ef7cd2735e99570474e6e53ee00b
Author: Nikita Popov <npopov@redhat.com>
Date: Wed Jan 31 11:01:03 2024 +0100
[BDCE] Fix clearing of poison-generating flags
If the demanded bits of an instruction are full, we don't have to
recurse to its users, but we may still have to clear flags on the
instruction itself.
Fixes https://github.com/llvm/llvm-project/issues/80113.
diff --git a/llvm/lib/Transforms/Scalar/BDCE.cpp b/llvm/lib/Transforms/Scalar/BDCE.cpp
index e99210ce2f22..6e6fa6c8ffc4 100644
--- a/llvm/lib/Transforms/Scalar/BDCE.cpp
+++ b/llvm/lib/Transforms/Scalar/BDCE.cpp
@@ -45,15 +45,17 @@ static void clearAssumptionsOfUsers(Instruction *I, DemandedBits &DB) {
assert(I->getType()->isIntOrIntVectorTy() &&
"Trivializing a non-integer value?");
+ // If all bits of a user are demanded, then we know that nothing below that
+ // in the def-use chain needs to be changed.
+ if (DB.getDemandedBits(I).isAllOnes())
+ return;
+
// Initialize the worklist with eligible direct users.
SmallPtrSet<Instruction *, 16> Visited;
SmallVector<Instruction *, 16> WorkList;
for (User *JU : I->users()) {
- // If all bits of a user are demanded, then we know that nothing below that
- // in the def-use chain needs to be changed.
- auto *J = dyn_cast<Instruction>(JU);
- if (J && J->getType()->isIntOrIntVectorTy() &&
- !DB.getDemandedBits(J).isAllOnes()) {
+ auto *J = cast<Instruction>(JU);
+ if (J->getType()->isIntOrIntVectorTy()) {
Visited.insert(J);
WorkList.push_back(J);
}
@@ -79,12 +81,14 @@ static void clearAssumptionsOfUsers(Instruction *I, DemandedBits &DB) {
// 1. llvm.assume demands its operand, so trivializing can't change it.
// 2. range metadata only applies to memory accesses which demand all bits.
+ // If all bits of a user are demanded, then we know that nothing below
+ // that in the def-use chain needs to be changed.
+ if (DB.getDemandedBits(J).isAllOnes())
+ continue;
+
for (User *KU : J->users()) {
- // If all bits of a user are demanded, then we know that nothing below
- // that in the def-use chain needs to be changed.
- auto *K = dyn_cast<Instruction>(KU);
- if (K && Visited.insert(K).second && K->getType()->isIntOrIntVectorTy() &&
- !DB.getDemandedBits(K).isAllOnes())
+ auto *K = cast<Instruction>(KU);
+ if (Visited.insert(K).second && K->getType()->isIntOrIntVectorTy())
WorkList.push_back(K);
}
}
|
[
{
"file": "llvm/test/Transforms/BDCE/invalidate-assumptions.ll",
"commands": [
"opt -passes=bdce %s -S"
],
"tests": [
{
"test_name": "disjoint_indirect",
"test_body": "define i32 @disjoint_indirect(i64 %x) {\n %and = and i64 %x, 1\n %trunc = trunc i64 %and to i32\n %or = or disjoint i32 %trunc, -2\n ret i32 %or\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "disjoint",
"test_body": "define i64 @disjoint(i64 %x) {\n %and = and i64 %x, 1\n %or = or disjoint i64 %and, -2\n ret i64 %or\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Wrong code at -O2/3 on x86-64_linux-gnu (recent regression)",
"body": "clang at -O2/3 produced the wrong code. This is a recent regression.\r\n\r\nBisected to 20737825c9122b6e0a8912731cfa7e0558fe025d, which was committed by @antoniofrighetto \r\n\r\nCompiler explorer: https://godbolt.org/z/55z1WT3MM\r\n\r\n```console\r\n% cat reduced.c\r\nint printf(const char *, ...);\r\nshort a, f = 6;\r\nint b, e, g;\r\nint c[7][1];\r\nstatic int *d = &b;\r\nlong h;\r\nint *const *i;\r\nstatic unsigned char j(long k, short *n) {\r\n int *l = &c[5][0];\r\n int *const **m = &i;\r\n i = &l;\r\n *d = 0;\r\n for (; e < 60; e++)\r\n ***m = ((h = *d == (1 ^ k)) & *n + f) - 2;\r\n return 0;\r\n}\r\nint main() {\r\n j(1, &a);\r\n printf(\"%d\\n\", c[5][0]);\r\n}\r\n%\r\n% clang -O0 reduced.c &&./a.out\r\n-2\r\n% clang -O2 reduced.c &&./a.out\r\n4\r\n%\r\n```",
"author": "shao-hua-li",
"labels": [
"miscompilation",
"llvm:transforms"
],
"comments": [
{
"author": "nikic",
"body": "Looks like poison flags don't get cleared as expected."
},
{
"author": "nikic",
"body": "Minimized:\r\n```llvm\r\ndefine i32 @test(i64 %x) {\r\n %and = and i64 %x, 1\r\n %trunc = trunc i64 %and to i32\r\n %or = or disjoint i32 %trunc, -2\r\n ret i32 %or\r\n}\r\n```\r\nThe `%and` gets dropped but `disjoint` is kept."
},
{
"author": "antoniofrighetto",
"body": "@nikic, could you kindly elaborate this? I'm having a hard time getting this, the transformation looks correct with simple `or` (https://alive2.llvm.org/ce/z/ui3yFf). Semantics for `disjoint`:\r\n> If the disjoint flag is set, and the or has a one and the same bit in both arguments, the result is poison.\r\n\r\nHowever, here:\r\n```llvm\r\n %add = add nuw nsw i64 %conv5, %conv4\r\n %and = and i64 %add, 1\r\n %2 = trunc i64 %and to i32\r\n %conv7 = or disjoint i32 %2, -2\r\n```\r\nThe two or operands do not seem to have any same bit in both arguments."
},
{
"author": "antoniofrighetto",
"body": "OK, I got it now, the `disjoint` should not be there at all after the transformation. Makes sense, thank you."
},
{
"author": "nikic",
"body": "Fixed another issue I noticed in this code in https://github.com/llvm/llvm-project/commit/cb6240d247b3419dea29eb99261171ea239b1c5c."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
109333
|
https://github.com/llvm/llvm-project/issues/109333
|
crash
|
c498af71d73e96e95730f3b3caaea08d3edbe62c
| 2024-09-19T20:50:34 |
[
"llvm/test/Transforms/LoopUnroll"
] |
{
"fix_commit": "5bcc82d43388bb0daa122d5fe7ecda5eca27fc16",
"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": [
[
859,
865
]
],
"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": [
"cloneLoopBlocks"
],
"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 5bcc82d43388bb0daa122d5fe7ecda5eca27fc16
Author: Nikita Popov <npopov@redhat.com>
Date: Fri Sep 20 16:57:46 2024 +0200
[LoopPeel] Fix LCSSA phi node invalidation
In the test case, the BECount of the second loop uses %load,
but we only have an LCSSA phi node for %add, so that is what
gets invalidated. Use the forgetLcssaPhiWithNewPredecessor()
API instead, which will invalidate the roots of the expression
instead.
Fixes https://github.com/llvm/llvm-project/issues/109333.
diff --git a/llvm/lib/Transforms/Utils/LoopPeel.cpp b/llvm/lib/Transforms/Utils/LoopPeel.cpp
index 5d7c0d947fac..760f1619e030 100644
--- a/llvm/lib/Transforms/Utils/LoopPeel.cpp
+++ b/llvm/lib/Transforms/Utils/LoopPeel.cpp
@@ -859,7 +859,7 @@ static void cloneLoopBlocks(
if (LatchInst && L->contains(LatchInst))
LatchVal = VMap[LatchVal];
PHI.addIncoming(LatchVal, cast<BasicBlock>(VMap[Edge.first]));
- SE.forgetValue(&PHI);
+ SE.forgetLcssaPhiWithNewPredecessor(L, &PHI);
}
// LastValueMap is updated with the values for the current loop
|
[
{
"file": "llvm/test/Transforms/LoopUnroll/pr109333.ll",
"commands": [
"opt -S -passes=\"print<scalar-evolution>,loop-unroll\" -unroll-runtime < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "define void @test(i1 %c, ptr %p) {\nentry:\n br label %loop.1\n\nloop.1: ; preds = %loop.1, %entry\n %phi = phi ptr [ null, %entry ], [ %p, %loop.1 ]\n %load = load i64, ptr %p, align 8\n %add = add i64 %load, 1\n br i1 %c, label %if, label %loop.1\n\nif: ; preds = %loop.1\n %add.lcssa = phi i64 [ %add, %loop.1 ]\n %gep = getelementptr i64, ptr %p, i64 %add.lcssa\n br label %loop.2\n\nloop.2: ; preds = %loop.2, %if\n %iv = phi ptr [ %p, %if ], [ %iv.next, %loop.2 ]\n %iv.next = getelementptr i8, ptr %iv, i64 8\n %icmp = icmp eq ptr %iv, %gep\n br i1 %icmp, label %exit, label %loop.2\n\nexit: ; preds = %loop.2\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "LTO error: Instruction does not dominate all uses",
"body": "clang crashes while linking\r\n```\r\nclang: error: unable to execute command: Aborted (core dumped)\r\nclang: error: linker command failed due to signal (use -v to see invocation)\r\n```\r\nI followed the instructions [here](https://llvm.org/docs/HowToSubmitABug.html) and narrowed it down to an LTO bug. File to reproduce is attached. [a.out.0.2.internalize-reduced.bc.tar.gz](https://github.com/user-attachments/files/17066318/a.out.0.2.internalize-reduced.bc.tar.gz)\r\n```\r\n$ opt \"-passes=lto<O3>\" a.out.0.2.internalize-reduced.bc\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\nInstruction does not dominate all uses!\r\n %.lcssa16 = phi i64 [ %12, %9 ]\r\n %27 = add i64 %.lcssa16, 2\r\nLLVM ERROR: Broken module found, compilation aborted!\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: opt -passes=lto<O3> reduced-redacted.bc #0 0x00007e899efc4d90 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /usr/src/debug/llvm/llvm-18.1.8.src/lib/Support/Unix/Signals.inc:723:22\r\n #1 0x00007e899efc1d4d llvm::sys::RunSignalHandlers() /usr/src/debug/llvm/llvm-18.1.8.src/lib/Support/Signals.cpp:105:20\r\n #2 0x00007e899efc1d4d SignalHandler /usr/src/debug/llvm/llvm-18.1.8.src/lib/Support/Unix/Signals.inc:403:31\r\n #3 0x00007e899e24c1d0 (/usr/lib/libc.so.6+0x3d1d0)\r\n #4 0x00007e899e2a53f4 __pthread_kill_implementation /usr/src/debug/glibc/glibc/nptl/pthread_kill.c:44:76\r\n #5 0x00007e899e24c120 raise /usr/src/debug/glibc/glibc/signal/../sysdeps/posix/raise.c:27:6\r\n #6 0x00007e899e2334c3 abort /usr/src/debug/glibc/glibc/stdlib/abort.c:81:7\r\n #7 0x00007e899ecaba1b std::mutex::lock() /usr/include/c++/14.1.1/bits/std_mutex.h:117:22\r\n #8 0x00007e899ecaba1b std::lock_guard<std::mutex>::lock_guard(std::mutex&) /usr/include/c++/14.1.1/bits/std_mutex.h:250:23\r\n #9 0x00007e899ecaba1b llvm::install_bad_alloc_error_handler(void (*)(void*, char const*, bool), void*) /usr/src/debug/llvm/llvm-18.1.8.src/lib/Support/ErrorHandling.cpp:131:61\r\n#10 0x00007e899eec070e (/usr/lib/libLLVM.so.18.1+0x6c070e)\r\n#11 0x00007e899f21aa1b (/usr/lib/libLLVM.so.18.1+0xa1aa1b)\r\n#12 0x000055a86e4acf57 llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm:\r\n:Module>&) /usr/src/debug/llvm/llvm-18.1.8.src/include/llvm/IR/PassManagerInternal.h:90:3\r\n#13 0x00007e899f1d767e llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /usr/src/debug/llvm/llvm-18.1.8.src/incl\r\nude/llvm/IR/PassManager.h:547:20\r\n#14 0x000055a86e4b7052 llvm::SmallPtrSetImplBase::isSmall() const /usr/src/debug/llvm/llvm-18.1.8.src/include/llvm/ADT/SmallPtrSet.h:195:33\r\n#15 0x000055a86e4b7052 llvm::SmallPtrSetImplBase::~SmallPtrSetImplBase() /usr/src/debug/llvm/llvm-18.1.8.src/include/llvm/ADT/SmallPtrSet.h:83:17\r\n#16 0x000055a86e4b7052 llvm::SmallPtrSetImpl<llvm::AnalysisKey*>::~SmallPtrSetImpl() /usr/src/debug/llvm/llvm-18.1.8.src/include/llvm/ADT/SmallPtrSet.h:345:7\r\n#17 0x000055a86e4b7052 llvm::SmallPtrSet<llvm::AnalysisKey*, 2u>::~SmallPtrSet() /usr/src/debug/llvm/llvm-18.1.8.src/include/llvm/ADT/SmallPtrSet.h:451:7\r\n#18 0x000055a86e4b7052 llvm::PreservedAnalyses::~PreservedAnalyses() /usr/src/debug/llvm/llvm-18.1.8.src/include/llvm/IR/PassManager.h:172:7\r\n#19 0x000055a86e4b7052 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutpu\r\ntFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) /usr/src/debug/llvm/llvm-18.1.8\r\n.src/tools/opt/NewPMDriver.cpp:527:10\r\n#20 0x000055a86e4ab1ed std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>::~basic_string() /usr/include/c++/14.1.1/bits/basic_string.h:809:19\r\n#21 0x000055a86e4ab1ed main /usr/src/debug/llvm/llvm-18.1.8.src/tools/opt/opt.cpp:747:3\r\n#22 0x00007e899e234e08 __libc_start_call_main /usr/src/debug/glibc/glibc/csu/../sysdeps/nptl/libc_start_call_main.h:74:3\r\n#23 0x00007e899e234ecc call_init /usr/src/debug/glibc/glibc/csu/../csu/libc-start.c:128:20\r\n#24 0x00007e899e234ecc __libc_start_main /usr/src/debug/glibc/glibc/csu/../csu/libc-start.c:347:5\r\n#25 0x000055a86e4abfd5 _start (/usr/bin/opt+0x1cfd5)\r\nAborted (core dumped)\r\n```\r\nThis happened after adding `-fsplit-lto-unit` to some parts of my code base.\r\n",
"author": "googlebleh",
"labels": [
"loopoptim",
"release:backport",
"llvm:crash"
],
"comments": [
{
"author": "googlebleh",
"body": "While bisecting using this reduced test case, I was able to reproduce this crash on several versions of LLVM between 15 and 18.1.8. I was also able to reproduce on the tip of `main` (e439fdf4ea0dbc6f001428f4d4956700bf26bb97). However, this crash did not reproduce on 15.0.7. The commit on 15.0.7 that \"fixed\" the issue is\r\n```\r\ncommit f3c5289e78462fb96015f79c954d95a0d527ba55 \r\nAuthor: Martin Storsjö <martin@martin.st> \r\nDate: Wed Oct 5 14:44:21 2022 +0300 \r\n \r\n Revert \"Recommit \"[SCEV] Look through single value PHIs.\" (take 3)\" \r\n \r\n This reverts commit 20d798bd47ec5191de1b2a8a031da06a04e612e1. \r\n \r\n This commit caused crashes in some cases, see github issue #58152. \r\n This is fixed on main, but backporting it requires multiple \r\n nontrivial cherrypicks. \r\n \r\n Updating llvm/test/Transforms/LoopVectorize/create-induction-resume.ll \r\n with update_test_checks.py, so this isn't an exact automatic revert, \r\n as that test case was added after the reverted commit. \r\n \r\n This fixes #58152 for the release branch. \r\n \r\n llvm/lib/Analysis/ScalarEvolution.cpp | 7 ++-\r\n llvm/test/Analysis/DependenceAnalysis/lcssa.ll | 2 +- \r\n llvm/test/Analysis/ScalarEvolution/cycled_phis.ll | 4 +- \r\n .../ScalarEvolution/incorrect-exit-count.ll | 2 +- \r\n .../Analysis/ScalarEvolution/solve-quadratic-i1.ll | 4 +- \r\n .../ScalarEvolution/solve-quadratic-overflow.ll | 6 +-- \r\n llvm/test/Analysis/ScalarEvolution/trivial-phis.ll | 2 +- \r\n llvm/test/Transforms/LoopStrengthReduce/funclet.ll | 40 +++++++++-------\r\n .../LoopVectorize/create-induction-resume.ll | 24 ++++------\r\n llvm/test/Transforms/LoopVectorize/pr45259.ll | 55 +++++++++++-----------\r\n 10 files changed, 75 insertions(+), 71 deletions(-)\r\n```\r\nspecifically, this (almost) 1-line diff\r\n```diff\r\ndiff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp\r\nindex 4b2db80bc1ec..3b73f9511eca 100644\r\n--- a/llvm/lib/Analysis/ScalarEvolution.cpp\r\n+++ b/llvm/lib/Analysis/ScalarEvolution.cpp\r\n@@ -6023,8 +6023,13 @@ const SCEV *ScalarEvolution::createNodeForPHI(PHINode *PN) {\r\n if (const SCEV *S = createAddRecFromPHI(PN))\r\n return S;\r\n \r\n+ // If the PHI has a single incoming value, follow that value, unless the\r\n+ // PHI's incoming blocks are in a different loop, in which case doing so\r\n+ // risks breaking LCSSA form. Instcombine would normally zap these, but\r\n+ // it doesn't have DominatorTree information, so it may miss cases.\r\n if (Value *V = simplifyInstruction(PN, {getDataLayout(), &TLI, &DT, &AC}))\r\n- return getSCEV(V);\r\n+ if (LI.replacementPreservesLCSSAForm(PN, V))\r\n+ return getSCEV(V);\r\n \r\n if (const SCEV *S = createNodeFromSelectLikePHI(PN))\r\n return S;\r\n```\r\n"
},
{
"author": "nikic",
"body": "Reduced:\r\n```llvm\r\n; RUN: opt -passes=\"print<scalar-evolution>,loop-unroll\" -unroll-runtime\r\ndefine void @test(i1 %c, ptr %p) {\r\nentry:\r\n br label %loop\r\n\r\nloop:\r\n %phi = phi ptr [ null, %entry ], [ %p, %loop ]\r\n %load = load i64, ptr %p, align 8\r\n %add = add i64 %load, 1\r\n br i1 %c, label %bb2, label %loop\r\n\r\nbb2:\r\n %add.lcssa = phi i64 [ %add, %loop ]\r\n %gep = getelementptr i64, ptr %p, i64 %add.lcssa\r\n br label %loop2\r\n\r\nloop2:\r\n %iv = phi ptr [ %p, %bb2 ], [ %iv.next, %loop2 ]\r\n %iv.next = getelementptr i8, ptr %iv, i64 8\r\n %icmp = icmp eq ptr %iv, %gep\r\n br i1 %icmp, label %exit, label %loop2\r\n\r\nexit:\r\n ret void\r\n}\r\n```"
},
{
"author": "nikic",
"body": "From a cursory look, the problem here is that the BECount of `loop2` depends on `%load`, and after peeling it should instead depend on a phi node, but instead still depends on `%load`. As the BECount does not dominate the loop, SCEV is invalid.\r\n\r\nThis issue sounds very familiar, we've fixed variants of this in the past."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
87410
|
https://github.com/llvm/llvm-project/issues/87410
|
crash
|
0bbe953aa3289a32cd816647820c8676bb3a61bc
| 2024-04-02T21:05:28 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "c83698367125703827f1b739393f006c399cb213",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/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": [
[
8233,
8238
]
],
"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": [
[
1513,
1518
]
],
"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": [
[
1932,
1945
],
[
1949,
1963
]
],
"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::tryToBlend"
],
"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": [
"VPBlendRecipe::print"
],
"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": [
"VPBlendRecipe",
"clone",
"getIncomingValue",
"getMask",
"getNumIncomingValues"
],
"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 c83698367125703827f1b739393f006c399cb213
Author: Florian Hahn <flo@fhahn.com>
Date: Tue Apr 9 11:14:05 2024 +0100
[VPlan] Remove unused first mask op from VPBlendRecipe. (#87770)
VPBlendRecipe does not use the first mask operand. Removing it allows
VPlan-based DCE to remove unused mask computations.
This also fixes #87410, where unused Not VPInstructions are considered
having only their first lane demanded, but some of their operands
providing a vector value due to other users.
Fixes https://github.com/llvm/llvm-project/issues/87410
PR: https://github.com/llvm/llvm-project/pull/87770
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index fd54faf17ca3..5535cc55e932 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -8221,6 +8221,8 @@ VPBlendRecipe *VPRecipeBuilder::tryToBlend(PHINode *Phi,
// builder. At this point we generate the predication tree. There may be
// duplications since this is a simple recursive scan, but future
// optimizations will clean it up.
+ // TODO: At the moment the first mask is always skipped, but it would be
+ // better to skip the most expensive mask.
SmallVector<VPValue *, 2> OperandsWithMask;
for (unsigned In = 0; In < NumIncoming; In++) {
@@ -8233,6 +8235,8 @@ VPBlendRecipe *VPRecipeBuilder::tryToBlend(PHINode *Phi,
"Distinct incoming values with one having a full mask");
break;
}
+ if (In == 0)
+ continue;
OperandsWithMask.push_back(EdgeMask);
}
return new VPBlendRecipe(Phi, OperandsWithMask);
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 5f6334b974cf..5dc905a3c407 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -1932,14 +1932,12 @@ public:
class VPBlendRecipe : public VPSingleDefRecipe {
public:
/// The blend operation is a User of the incoming values and of their
- /// respective masks, ordered [I0, M0, I1, M1, ...]. Note that a single value
- /// might be incoming with a full mask for which there is no VPValue.
+ /// respective masks, ordered [I0, I1, M1, I2, M2, ...]. Note that the first
+ /// incoming value does not have a mask associated.
VPBlendRecipe(PHINode *Phi, ArrayRef<VPValue *> Operands)
: VPSingleDefRecipe(VPDef::VPBlendSC, Operands, Phi, Phi->getDebugLoc()) {
- assert(Operands.size() > 0 &&
- ((Operands.size() == 1) || (Operands.size() % 2 == 0)) &&
- "Expected either a single incoming value or a positive even number "
- "of operands");
+ assert((Operands.size() + 1) % 2 == 0 &&
+ "Expected an odd number of operands");
}
VPRecipeBase *clone() override {
@@ -1949,15 +1947,20 @@ public:
VP_CLASSOF_IMPL(VPDef::VPBlendSC)
- /// Return the number of incoming values, taking into account that a single
+ /// Return the number of incoming values, taking into account that the first
/// incoming value has no mask.
unsigned getNumIncomingValues() const { return (getNumOperands() + 1) / 2; }
/// Return incoming value number \p Idx.
- VPValue *getIncomingValue(unsigned Idx) const { return getOperand(Idx * 2); }
+ VPValue *getIncomingValue(unsigned Idx) const {
+ return Idx == 0 ? getOperand(0) : getOperand(Idx * 2 - 1);
+ }
/// Return mask number \p Idx.
- VPValue *getMask(unsigned Idx) const { return getOperand(Idx * 2 + 1); }
+ VPValue *getMask(unsigned Idx) const {
+ assert(Idx > 0 && "First index has no mask associated.");
+ return getOperand(Idx * 2);
+ }
/// Generate the phi/select nodes.
void execute(VPTransformState &State) override;
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index 2438e4dae3eb..625319954e9b 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -1513,6 +1513,8 @@ void VPBlendRecipe::print(raw_ostream &O, const Twine &Indent,
for (unsigned I = 0, E = getNumIncomingValues(); I < E; ++I) {
O << " ";
getIncomingValue(I)->printAsOperand(O, SlotTracker);
+ if (I == 0)
+ continue;
O << "/";
getMask(I)->printAsOperand(O, SlotTracker);
}
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/unused-blend-mask-for-first-operand.ll",
"commands": [
"opt -p loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -S %s"
],
"tests": [
{
"test_name": "test_not_first_lane_only_constant",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine void @test_not_first_lane_only_constant(ptr %A, ptr noalias %B) {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i16 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %gep.A = getelementptr inbounds i16, ptr %A, i16 %iv\n br i1 false, label %loop.latch, label %else.1\n\nelse.1: ; preds = %loop.header\n br i1 false, label %then.2, label %else.2\n\nthen.2: ; preds = %else.1\n br label %else.2\n\nelse.2: ; preds = %then.2, %else.1\n br label %loop.latch\n\nloop.latch: ; preds = %else.2, %loop.header\n %merge = phi ptr [ %B, %else.2 ], [ poison, %loop.header ]\n %l = load i16, ptr %merge, align 2\n %iv.next = add i16 %iv, 1\n store i16 %l, ptr %gep.A, align 2\n %c.2 = icmp eq i16 %iv.next, 1000\n br i1 %c.2, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_not_first_lane_only_wide_compare",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine void @test_not_first_lane_only_wide_compare(ptr %A, ptr noalias %B, i16 %x, i16 %y) {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i16 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %gep.A = getelementptr inbounds i16, ptr %A, i16 %iv\n %l.0 = load i16, ptr %gep.A, align 2\n %c.0 = icmp ult i16 %l.0, %x\n br i1 %c.0, label %loop.latch, label %else.1\n\nelse.1: ; preds = %loop.header\n %c.1 = icmp ult i16 %l.0, %y\n br i1 %c.1, label %then.2, label %else.2\n\nthen.2: ; preds = %else.1\n br label %else.2\n\nelse.2: ; preds = %then.2, %else.1\n br label %loop.latch\n\nloop.latch: ; preds = %else.2, %loop.header\n %merge = phi ptr [ %B, %else.2 ], [ poison, %loop.header ]\n %l = load i16, ptr %merge, align 2\n %iv.next = add i16 %iv, 1\n store i16 %l, ptr %gep.A, align 2\n %c.2 = icmp eq i16 %iv.next, 1000\n br i1 %c.2, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[LoopVectorize][VPlan] Assertion \"Trying to access a single scalar per part but has multiple scalars per part.\" failed.",
"body": "Reduced LLVM IR\r\n```llvm ir\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine i32 @main() #0 {\r\nentry:\r\n br label %for.body.i\r\n\r\nfor.body.i: ; preds = %if.end.i, %entry\r\n %q.0139.i = phi i16 [ 0, %entry ], [ %add.i, %if.end.i ]\r\n %idxprom.i = sext i16 0 to i64\r\n br i1 false, label %if.end.i, label %if.then.i\r\n\r\nif.then.i: ; preds = %for.body.i\r\n br i1 false, label %cond.end41.i, label %cond.end41.i\r\n\r\ncond.end41.i: ; preds = %if.then.i, %if.then.i\r\n br label %if.end.i\r\n\r\nif.end.i: ; preds = %cond.end41.i, %for.body.i\r\n %.in.i = phi ptr [ null, %cond.end41.i ], [ poison, %for.body.i ]\r\n %0 = load i16, ptr %.in.i, align 2\r\n %add.i = add i16 %q.0139.i, 1\r\n %tobool.not.i = icmp eq i16 %add.i, 0\r\n br i1 %tobool.not.i, label %m.exit, label %for.body.i\r\n\r\nm.exit: ; preds = %if.end.i\r\n %.lcssa = phi i16 [ %0, %if.end.i ]\r\n ret i32 0\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\r\n```\r\n\r\nBacktrace:\r\n```\r\nopt: /scratch/tc-testing/tc-apr-2/llvm/llvm/lib/Transforms/Vectorize/VPlan.cpp:249: llvm::Value* llvm::VPTransformState::get(llvm::VPValue*, unsigned int, bool): Assertion `(VF.isScalar() || Def->isLiveIn() || (hasScalarValue(Def, VPIteration(Part, 0)) && Data.PerPartScalars[Def][Part].size() == 1)) && \"Trying to access a single scalar per part but has multiple scalars \" \"per part.\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt --passes=loop-vectorize reduced.ll\r\n #0 0x00005ed60f56eb60 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2d84b60)\r\n #1 0x00005ed60f56bf6f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2d81f6f)\r\n #2 0x00005ed60f56c0c5 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007f973de42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007f973de969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007f973de969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007f973de969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x00007f973de42476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007f973de287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x00007f973de2871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x00007f973de39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x00005ed60e6cbb72 llvm::VPTransformState::get(llvm::VPValue*, unsigned int, bool) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1ee1b72)\r\n#12 0x00005ed60e6fa9a6 llvm::VPInstruction::generatePerPart(llvm::VPTransformState&, unsigned int) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1f109a6)\r\n#13 0x00005ed60e6fbbdf llvm::VPInstruction::execute(llvm::VPTransformState&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1f11bdf)\r\n#14 0x00005ed60e6d74ff llvm::VPBasicBlock::execute(llvm::VPTransformState*) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1eed4ff)\r\n#15 0x00005ed60e6cd9e0 llvm::VPRegionBlock::execute(llvm::VPTransformState*) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1ee39e0)\r\n#16 0x00005ed60e6d90e6 llvm::VPlan::execute(llvm::VPTransformState*) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1eef0e6)\r\n#17 0x00005ed60e5d76f3 llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool, llvm::DenseMap<llvm::SCEV const*, llvm::Value*, llvm::DenseMapInfo<llvm::SCEV const*, void>, llvm::detail::DenseMapPair<llvm::SCEV const*, llvm::Value*>> const*) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1ded6f3)\r\n#18 0x00005ed60e5e9718 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1dff718)\r\n#19 0x00005ed60e5eb73e llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1e0173e)\r\n#20 0x00005ed60e5ec88d llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1e0288d)\r\n#21 0x00005ed60d4f3276 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0xd09276)\r\n#22 0x00005ed60f395141 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2bab141)\r\n#23 0x00005ed60d4eabd6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0xd00bd6)\r\n#24 0x00005ed60f393e3b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2ba9e3b)\r\n#25 0x00005ed60d4f2dc6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0xd08dc6)\r\n#26 0x00005ed60f391cb1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2ba7cb1)\r\n#27 0x00005ed60cd6cce5 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x582ce5)\r\n#28 0x00005ed60cd5f316 optMain (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x575316)\r\n#29 0x00007f973de29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#30 0x00007f973de29e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#31 0x00007f973de29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#32 0x00005ed60cd54f95 _start (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x56af95)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt\r\n```\r\nGodbolt: https://godbolt.org/z/jYWea8z4q\r\n\r\nFound via fuzzer.",
"author": "patrick-rivos",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
| null |
82052
|
https://github.com/llvm/llvm-project/issues/82052
|
miscompilation
|
a45df47375e50914900dcc07abd2fa67bfa0dd3b
| 2024-02-16T22:14:29 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "d2a26a7bd5fc7cc5752337b7f4f999642feb37dc",
"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": [
[
1870,
1883
]
],
"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 d2a26a7bd5fc7cc5752337b7f4f999642feb37dc
Author: Antonio Frighetto <me@antoniofrighetto.com>
Date: Sun Feb 18 18:10:41 2024 +0100
[InstCombine] Do not perform binop-of-shuffle when mask is poison
A miscompilation issue has been addressed with refined checking.
Shuffle masks operand may be turned into `poison` if this does
not lead to observable changes. This however may not guarantee
binop to binop-of-shuffle replacement to be sound anymore.
Fixes: https://github.com/llvm/llvm-project/issues/82052.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index 5f13454089e5..97ae980a7cba 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -1870,14 +1870,16 @@ Value *InstCombinerImpl::SimplifyDemandedVectorElts(Value *V,
Value *ShufOp = MatchShufAsOp0 ? X : Y;
Value *OtherOp = MatchShufAsOp0 ? Y : X;
for (User *U : OtherOp->users()) {
- auto Shuf = m_Shuffle(m_Specific(ShufOp), m_Value(), m_ZeroMask());
+ ArrayRef<int> Mask;
+ auto Shuf = m_Shuffle(m_Specific(ShufOp), m_Value(), m_Mask(Mask));
if (BO->isCommutative()
? match(U, m_c_BinOp(Opcode, Shuf, m_Specific(OtherOp)))
: MatchShufAsOp0
? match(U, m_BinOp(Opcode, Shuf, m_Specific(OtherOp)))
: match(U, m_BinOp(Opcode, m_Specific(OtherOp), Shuf)))
- if (DT.dominates(U, I))
- return U;
+ if (match(Mask, m_ZeroMask()) && Mask[0] != PoisonMaskElem)
+ if (DT.dominates(U, I))
+ return U;
}
return nullptr;
};
|
[
{
"file": "llvm/test/Transforms/InstCombine/vec_demanded_elts.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "common_binop_demand_via_extelt_op0_mismatch_elt1",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\n\ndeclare void @use(<2 x i4>)\n\ndefine i4 @common_binop_demand_via_extelt_op0_mismatch_elt1(<2 x i4> %x, <2 x i4> %y) {\n %xshuf = shufflevector <2 x i4> %x, <2 x i4> poison, <2 x i32> zeroinitializer\n %b_xshuf_y = sub <2 x i4> %xshuf, %y\n %b_xy = sub nsw <2 x i4> %x, %y\n %b_xy0 = extractelement <2 x i4> %b_xy, i32 1\n call void @use(<2 x i4> %b_xshuf_y)\n ret i4 %b_xy0\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "common_binop_demand_via_splat_mask_poison",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine <2 x i8> @common_binop_demand_via_splat_mask_poison(<2 x i8> %x, <2 x i8> %y) {\n %ysplat = shufflevector <2 x i8> %y, <2 x i8> poison, <2 x i32> <i32 0, i32 poison>\n %vv = add <2 x i8> %x, %ysplat\n %m = add <2 x i8> %x, %y\n %msplat = shufflevector <2 x i8> %m, <2 x i8> poison, <2 x i32> zeroinitializer\n %res = add <2 x i8> %vv, %msplat\n ret <2 x i8> %res\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "common_binop_demand_via_splat_mask_poison_2",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine <2 x i8> @common_binop_demand_via_splat_mask_poison_2(<2 x i8> %x, <2 x i8> %y) {\n %ysplat = shufflevector <2 x i8> %y, <2 x i8> poison, <2 x i32> <i32 poison, i32 0>\n %vv = add <2 x i8> %x, %ysplat\n %m = add <2 x i8> %x, %y\n %msplat = shufflevector <2 x i8> %m, <2 x i8> %y, <2 x i32> <i32 0, i32 2>\n %res = add <2 x i8> %vv, %msplat\n ret <2 x i8> %res\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "common_binop_demand_via_splat_mask_poison_3",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine <2 x i8> @common_binop_demand_via_splat_mask_poison_3(<2 x i8> %x, <2 x i8> %y) {\n %ysplat = shufflevector <2 x i8> %y, <2 x i8> poison, <2 x i32> <i32 poison, i32 0>\n %vv = add <2 x i8> %x, %ysplat\n %m = add <2 x i8> %x, %y\n %msplat = shufflevector <2 x i8> %m, <2 x i8> poison, <2 x i32> zeroinitializer\n %res = add <2 x i8> %vv, %msplat\n ret <2 x i8> %res\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstCombine] Replacement of binop with binop-of-shuffle incorrectly adds extra poison value",
"body": "The following IR is a minimal repro when run with `opt -passes=instcombine`:\r\n```llvm\r\ndefine i8 @src(<2 x i8> %x, <2 x i8> %y) {\r\n %xsplat = shufflevector <2 x i8> %x, <2 x i8> poison, <2 x i32> <i32 1, i32 0>\r\n %vv = mul <2 x i8> %xsplat, %y\r\n %m = mul <2 x i8> %x, %y ; <<<< Note that %m is later replaced with %vv in the output\r\n %msplat = shufflevector <2 x i8> %m, <2 x i8> poison, <2 x i32> <i32 0, i32 0>\r\n %res = add <2 x i8> %vv, %msplat\r\n %vget_lane = extractelement <2 x i8> %res, i64 1\r\n ret i8 %vget_lane\r\n}\r\n```\r\nWhich on 17.x or trunk will give:\r\n```llvm\r\ndefine i8 @src(<2 x i8> %x, <2 x i8> %y) {\r\n %xsplat = shufflevector <2 x i8> %x, <2 x i8> poison, <2 x i32> <i32 poison, i32 0>\r\n %vv = mul <2 x i8> %xsplat, %y\r\n %msplat = shufflevector <2 x i8> %vv, <2 x i8> poison, <2 x i32> <i32 poison, i32 0>\r\n %res = add <2 x i8> %vv, %msplat\r\n %vget_lane = extractelement <2 x i8> %res, i64 1\r\n ret i8 %vget_lane\r\n}\r\n```\r\nHowever, this is not correct, because the added poisoned values end up observed in the final output. First, in InstCombine, the first element in each mask for the shuffles are first replaced with `poison` due to not being observed in the final `extractelement`. After that we run into this code in `InstCombineSimplifyDemanded.cpp`:\r\nhttps://github.com/llvm/llvm-project/blob/d8278b682386f51dfba204849c624672a3df40c7/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp#L1866-L1880\r\n\r\nThis is what replaces the `mul <2 x i8> %x, %y` with `mul <2 x i8> %xsplat, %y` (`m_ZeroMask` also matches poison). However in doing so, it introduces the extra poison from `%xsplat`, meaning that `%msplat` has both its elements poisoned, which ends up propagating to `%vget_lane`.\r\n\r\nHere is a Godbolt link showing the test case on 16.x, 17.x, and trunk:\r\nhttps://godbolt.org/z/5eeT7x4s3\r\n\r\nAnd also an Alive2 example showing the bad transformation with a counter-example:\r\nhttps://alive2.llvm.org/ce/z/RpBJEN\r\n\r\nThe code was first introduced in 3b090ff2bdb2828b53d6fec9c06b9d52fed09f42, which a bisect shows is when this first started repro'ing\r\n\r\nI have verified that this still repros on latest trunk, 2de269a641e4ffbb7a44e559c4c0a91bb66df823\r\n\r\nFor priority/triage: this bug was found by a fuzzer meant to test SIMD codegen. It was not from manually written code",
"author": "Benjins",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": [
{
"author": "Benjins",
"body": "A slightly smaller test case:\r\nhttps://alive2.llvm.org/ce/z/6AMPWC\r\n```llvm\r\ndefine <2 x i8> @src(<2 x i8> %x, <2 x i8> %y) {\r\n %xsplat = shufflevector <2 x i8> %x, <2 x i8> poison, <2 x i32> <i32 poison, i32 0>\r\n %vv = mul <2 x i8> %xsplat, %y\r\n %m = mul <2 x i8> %x, %y\r\n %msplat = shufflevector <2 x i8> %m, <2 x i8> poison, <2 x i32> <i32 poison, i32 0>\r\n %res = add <2 x i8> %vv, %msplat\r\n ret <2 x i8> %res\r\n}\r\n```\r\nThis doesn't extract the vector, and instead manually specifies the poisonous elements in the shuffles. As Alive notes, the output for `src(<0, 0>, <0, 0>)` goes from `<poison, 0>` to `<poison, poison>`"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
82243
|
https://github.com/llvm/llvm-project/issues/82243
|
miscompilation
|
fcd6549e5801de938935b93fd2d13020b42eebdb
| 2024-02-19T12:48:24 |
[
"llvm/test/Transforms/IndVarSimplify"
] |
{
"fix_commit": "4db93e5d56440be44d8ad2036e2579208c82ad37",
"components": [
"ScalarEvolution",
"SimplifyIndVar"
],
"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": [
[
771,
776
]
],
"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": [
[
1131,
1137
],
[
1731,
1737
],
[
1825,
1835
],
[
1996,
2006
],
[
2024,
2030
]
],
"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": [
[
258,
263
]
],
"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": [
"SCEVExpander::hoistIVInc"
],
"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": [
"WidenIV::createWideIV",
"WidenIV::widenIVUse"
],
"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 4db93e5d56440be44d8ad2036e2579208c82ad37
Author: Florian Hahn <flo@fhahn.com>
Date: Tue Feb 20 14:03:25 2024 +0000
[IndVars] Recompute flags if needed in widenIVUse of IV increment. (#82352)
widenIVUse may hoist a wide induction increment and introduce new uses,
but does not recompute the wrap flags. In some cases this can make the
new uses of the wide IV inc more poisonous.
Update the code to recompute flags if needed when hoisting an IV. If
both the narrow and wide IV increment's flags match and we can re-use
the flags from the increments, there's no need to recompute the flags,
as the replacement won't make the new uses of the wide IV's increment
more poisonous.
Note that this also updates a stale comment which claimed that the widen
increment is only used if it dominates the new use.
The helper should also be used to guard the code added in da437330be,
which I am planning on doing separately once the helper lands.
Fixes https://github.com/llvm/llvm-project/issues/82243.
diff --git a/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h b/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h
index 035705b7f4b7..fa10443f14bb 100644
--- a/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h
+++ b/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h
@@ -258,6 +258,14 @@ public:
bool hoistIVInc(Instruction *IncV, Instruction *InsertPos,
bool RecomputePoisonFlags = false);
+ /// Return true if both increments directly increment the corresponding IV PHI
+ /// nodes and have the same opcode. It is not safe to re-use the flags from
+ /// the original increment, if it is more complex and SCEV expansion may have
+ /// yielded a more simplified wider increment.
+ static bool canReuseFlagsFromOriginalIVInc(PHINode *OrigPhi, PHINode *WidePhi,
+ Instruction *OrigInc,
+ Instruction *WideInc);
+
/// replace congruent phis with their most canonical representative. Return
/// the number of phis eliminated.
unsigned replaceCongruentIVs(Loop *L, const DominatorTree *DT,
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index 3a28909473d9..fbe1dba5b8d4 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -771,6 +771,15 @@ bool SCEVExpander::hoistIVInc(Instruction *IncV, Instruction *InsertPos,
return true;
}
+bool SCEVExpander::canReuseFlagsFromOriginalIVInc(PHINode *OrigPhi,
+ PHINode *WidePhi,
+ Instruction *OrigInc,
+ Instruction *WideInc) {
+ return match(OrigInc, m_c_BinOp(m_Specific(OrigPhi), m_Value())) &&
+ match(WideInc, m_c_BinOp(m_Specific(WidePhi), m_Value())) &&
+ OrigInc->getOpcode() == WideInc->getOpcode();
+}
+
/// Determine if this cyclic phi is in a form that would have been generated by
/// LSR. We don't care if the phi was actually expanded in this pass, as long
/// as it is in a low-cost form, for example, no implied multiplication. This
diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
index 5aa6df49e7f6..66bba1ca2f1d 100644
--- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
@@ -1131,7 +1131,8 @@ protected:
const SCEV *getSCEVByOpCode(const SCEV *LHS, const SCEV *RHS,
unsigned OpCode) const;
- Instruction *widenIVUse(NarrowIVDefUse DU, SCEVExpander &Rewriter);
+ Instruction *widenIVUse(NarrowIVDefUse DU, SCEVExpander &Rewriter,
+ PHINode *OrigPhi, PHINode *WidePhi);
bool widenLoopCompare(NarrowIVDefUse DU);
bool widenWithVariantUse(NarrowIVDefUse DU);
@@ -1731,7 +1732,9 @@ bool WidenIV::widenWithVariantUse(WidenIV::NarrowIVDefUse DU) {
/// Determine whether an individual user of the narrow IV can be widened. If so,
/// return the wide clone of the user.
-Instruction *WidenIV::widenIVUse(WidenIV::NarrowIVDefUse DU, SCEVExpander &Rewriter) {
+Instruction *WidenIV::widenIVUse(WidenIV::NarrowIVDefUse DU,
+ SCEVExpander &Rewriter, PHINode *OrigPhi,
+ PHINode *WidePhi) {
assert(ExtendKindMap.count(DU.NarrowDef) &&
"Should already know the kind of extension used to widen NarrowDef");
@@ -1825,11 +1828,18 @@ Instruction *WidenIV::widenIVUse(WidenIV::NarrowIVDefUse DU, SCEVExpander &Rewri
if (!WideAddRec.first)
return nullptr;
- // Reuse the IV increment that SCEVExpander created as long as it dominates
- // NarrowUse.
+ // Reuse the IV increment that SCEVExpander created. Recompute flags, unless
+ // the flags for both increments agree and it is safe to use the ones from
+ // the original inc. In that case, the new use of the wide increment won't
+ // be more poisonous.
+ bool NeedToRecomputeFlags =
+ !SCEVExpander::canReuseFlagsFromOriginalIVInc(OrigPhi, WidePhi,
+ DU.NarrowUse, WideInc) ||
+ DU.NarrowUse->hasNoUnsignedWrap() != WideInc->hasNoUnsignedWrap() ||
+ DU.NarrowUse->hasNoSignedWrap() != WideInc->hasNoSignedWrap();
Instruction *WideUse = nullptr;
if (WideAddRec.first == WideIncExpr &&
- Rewriter.hoistIVInc(WideInc, DU.NarrowUse))
+ Rewriter.hoistIVInc(WideInc, DU.NarrowUse, NeedToRecomputeFlags))
WideUse = WideInc;
else {
WideUse = cloneIVUser(DU, WideAddRec.first);
@@ -1996,11 +2006,9 @@ PHINode *WidenIV::createWideIV(SCEVExpander &Rewriter) {
// the same opcode. It is not safe to re-use the flags from the original
// increment, if it is more complex and SCEV expansion may have yielded a
// more simplified wider increment.
- bool MatchingOps =
- match(OrigInc, m_c_BinOp(m_Specific(OrigPhi), m_Value())) &&
- match(WideInc, m_c_BinOp(m_Specific(WidePhi), m_Value())) &&
- OrigInc->getOpcode() == WideInc->getOpcode();
- if (MatchingOps && isa<OverflowingBinaryOperator>(OrigInc) &&
+ if (SCEVExpander::canReuseFlagsFromOriginalIVInc(OrigPhi, WidePhi,
+ OrigInc, WideInc) &&
+ isa<OverflowingBinaryOperator>(OrigInc) &&
isa<OverflowingBinaryOperator>(WideInc)) {
WideInc->setHasNoUnsignedWrap(WideInc->hasNoUnsignedWrap() ||
OrigInc->hasNoUnsignedWrap());
@@ -2024,7 +2032,7 @@ PHINode *WidenIV::createWideIV(SCEVExpander &Rewriter) {
// Process a def-use edge. This may replace the use, so don't hold a
// use_iterator across it.
- Instruction *WideUse = widenIVUse(DU, Rewriter);
+ Instruction *WideUse = widenIVUse(DU, Rewriter, OrigPhi, WidePhi);
// Follow all def-use edges from the previous narrow use.
if (WideUse)
|
[
{
"file": "llvm/test/Transforms/IndVarSimplify/hoist-wide-inc-for-narrow-use-recompute-flags.ll",
"commands": [
"opt -p indvars -S %s"
],
"tests": [
{
"test_name": "test_pr82243",
"test_body": "target datalayout = \"e-m:o-i64:64-i128:128-n32:64-S128\"\n\ndefine void @test_pr82243(ptr %f) {\nentry:\n br label %outer.header\n\nouter.header: ; preds = %outer.latch, %entry\n %iv = phi i32 [ 1, %entry ], [ %iv.next, %outer.latch ]\n %iv.sext = sext i32 %iv to i64\n %gep.iv.ext = getelementptr i32, ptr %f, i64 %iv.sext\n store i32 1, ptr %gep.iv.ext, align 4\n %sub = add i32 %iv, -1\n %shl = shl i32 123, %sub\n %gep.shl = getelementptr i32, ptr %f, i32 %shl\n br label %inner.header\n\ninner.header: ; preds = %inner.latch, %outer.header\n store i32 0, ptr %gep.shl, align 4\n br i1 false, label %inner.latch, label %exit\n\ninner.latch: ; preds = %inner.header\n br i1 false, label %inner.header, label %outer.latch\n\nouter.latch: ; preds = %inner.latch\n %iv.next = add i32 %iv, -1\n br label %outer.header\n\nexit: ; preds = %inner.header\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Wrong code at -Os on x86-64_gnu-linux (recent regression)",
"body": "Clang at -Os produced the wrong code.\r\n\r\nBisected to dce77a357948709e335910ddc07f9c3f2eb2ac4b, which was committed by @fhahn \r\n\r\nCompiler explorer: https://godbolt.org/z/fTrenPK4h\r\n\r\n```console\r\n% cat reduced.c\r\nint printf(const char *, ...);\r\nint a, b, c, d, e;\r\nint f[9];\r\nint g(int i) {\r\n c = 1 << i;\r\n if (b & c)\r\n return 4;\r\n return 0;\r\n}\r\nint j(int i) {\r\n int h = g(i);\r\n return h;\r\n}\r\nint k() {\r\n d = 6;\r\n for (; d; d--) {\r\n e = 0;\r\n for (; e <= 6; e++) {\r\n f[j(d - 1)] = f[d];\r\n for (; e + d;)\r\n return 0;\r\n }\r\n }\r\n return 0;\r\n}\r\nint main() {\r\n k();\r\n printf(\"%d\\n\", a);\r\n}\r\n%\r\n% clang -O3 reduced.c && ./a.out\r\n0\r\n% clang -Os reduced.c && ./a.out\r\n\r\n%\r\n```",
"author": "shao-hua-li",
"labels": [
"miscompilation",
"llvm:SCEV"
],
"comments": [
{
"author": "fhahn",
"body": "The issue is that IndVars doesn't drop poison-generating flags when hoisting the IV to introduce a new use of the widened IV. working on a fix"
},
{
"author": "fhahn",
"body": "Should be fixed, thanks again as always @shao-hua-li "
},
{
"author": "shao-hua-li",
"body": "You're welcome @fhahn "
}
]
}
| true |
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
| null |
107473
|
https://github.com/llvm/llvm-project/issues/107473
|
crash
|
99fb1506a869fa5e82dbd36e1a63cd21450f1502
| 2024-09-05T21:51:36 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "e3c537ff903af9a92ff43bab6d21c0ea759d65e5",
"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": [
[
7314,
7322
]
],
"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": [
"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 e3c537ff903af9a92ff43bab6d21c0ea759d65e5
Author: Florian Hahn <flo@fhahn.com>
Date: Tue Sep 10 21:37:12 2024 +0100
[VPlan] Consider non-header phis in planContainsAdditionalSimp.
Update planContainsAdditionalSimplifications to also check phis not in
the loop header. This ensures we don't miss cases where VPBlendRecipes
(which correspond to such phis) have been simplified.
Fixes https://github.com/llvm/llvm-project/issues/107473.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 2be3b5775292..b821da03c16e 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7314,9 +7314,10 @@ static bool planContainsAdditionalSimplifications(VPlan &Plan,
// 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, &CostCtx](BasicBlock *BB) {
- return any_of(*BB, [&SeenInstrs, &CostCtx](Instruction &I) {
- if (isa<PHINode>(&I))
+ return any_of(TheLoop->blocks(), [&SeenInstrs, &CostCtx,
+ TheLoop](BasicBlock *BB) {
+ return any_of(*BB, [&SeenInstrs, &CostCtx, TheLoop, BB](Instruction &I) {
+ if (isa<PHINode>(&I) && BB == TheLoop->getHeader())
return false;
return !SeenInstrs.contains(&I) && !CostCtx.skipCostComputation(&I, true);
});
|
[
{
"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": "dead_load",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine void @dead_load(ptr %p, i16 %start) {\nentry:\n %start.ext = sext i16 %start to i64\n br label %loop\n\nloop: ; preds = %loop, %entry\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: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "dead_live_out_due_to_scalar_epilogue_required",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine i8 @dead_live_out_due_to_scalar_epilogue_required(ptr %src, ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %idxprom = sext i32 %iv to i64\n %gep.src = getelementptr i8, ptr %src, i64 %idxprom\n %l = load i8, ptr %gep.src, align 1\n %gep.dst = getelementptr i8, ptr %dst, i64 %idxprom\n store i8 0, ptr %gep.dst, align 1\n %iv.next = add i32 %iv, 4\n %cmp = icmp ult i32 %iv, 1001\n br i1 %cmp, label %loop, label %exit\n\nexit: ; preds = %loop\n %r = phi i8 [ %l, %loop ]\n ret i8 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_phi_in_latch_redundant",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine void @test_phi_in_latch_redundant(ptr %dst, i32 %a) {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n br i1 false, label %loop.latch, label %then\n\nthen: ; preds = %loop.header\n %not.a = xor i32 %a, -1\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n %p = phi i32 [ %not.a, %then ], [ 0, %loop.header ]\n %gep = getelementptr i32, ptr %dst, i64 %iv\n store i32 %p, ptr %gep, align 4\n %iv.next = add i64 %iv, 9\n %ec = icmp slt i64 %iv, 322\n br i1 %ec, label %loop.header, label %exit\n\nexit: ; preds = %loop.latch\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "cost_of_exit_branch_and_cond_insts",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i16 @llvm.umax.i16(i16, i16) #0\n\ndefine i32 @cost_of_exit_branch_and_cond_insts(ptr %a, ptr %b, i1 %c, i16 %x) {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]\n br i1 %c, label %then, label %loop.exiting\n\nthen: ; preds = %loop.header\n %gep = getelementptr inbounds i32, ptr %b, i32 %iv\n store i1 false, ptr %a, align 1\n store i32 0, ptr %gep, align 4\n br label %loop.exiting\n\nloop.exiting: ; preds = %then, %loop.header\n %iv.next = add i32 %iv, 1\n %umax = tail call i16 @llvm.umax.i16(i16 %x, i16 111)\n %umax.ext = zext i16 %umax to i32\n %sub = sub i32 770, %umax.ext\n %ec = icmp slt i32 %iv, %sub\n br i1 %ec, label %loop.latch, label %exit\n\nloop.latch: ; preds = %loop.exiting\n br label %loop.header\n\nexit: ; preds = %loop.exiting\n br label %return\n\nreturn: ; preds = %exit\n ret i32 0\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[VPlan] Assertion \" VPlan cost model and legacy cost model disagreed\"' failed.",
"body": "Testing using 0c1500ef05e0a5b25cae79d2bd361dbc6e14e726\r\n\r\nC testcase:\r\n```\r\nint a;\r\nextern int b[][3][3][3][3][3];\r\n_Bool c;\r\nunsigned char d[1][13][13];\r\nunsigned e[1][13][13][13];\r\nint f[6];\r\nunsigned short g[1][13][13][13];\r\nunsigned h[1][13][13], i[1][13][13];\r\nshort j[1][13][13];\r\nunsigned k[3][13][13];\r\nunsigned short l[1][13];\r\nshort m[1][13];\r\nunsigned short n[1][13][13];\r\nunsigned o[1][13];\r\nvoid p(char q, int r, char s, unsigned char z[][13][13],\r\n unsigned aa[][13][13][13], int ab[], unsigned short ac[][13][13][13],\r\n unsigned ad[][13][13], short ae[][13][13], unsigned af[][13][13],\r\n unsigned short ag[][13], short ah[][13], unsigned short ai[][13][13],\r\n unsigned aj[][13][13], unsigned ak[][13]) {\r\n for (unsigned t = 0; t < q; t += 50)\r\n for (unsigned u = 0; u < 2; u = 6)\r\n for (short w = 0; w < 2; w += 42155)\r\n for (signed x = -15; x < r; x += s) {\r\n b[x][x][u][2][x][2] = ab[5] ? ~af[2][1][x] : 0;\r\n a = x ? c ? aj[2][u][x] : 0 : ae[2][w][4];\r\n }\r\n}\r\nint main() {\r\n f[5] = 8;\r\n for (long t = 0; t < 3; ++t)\r\n for (long v = 0; v < 3; ++v)\r\n for (long y = 0; y < 3; ++y)\r\n k[t][v][y] = 3004284279;\r\n p(8, 322, 9, d, e, f, g, h, j, k, l, m, n, i, o);\r\n}\r\n```\r\n\r\nLLVM IR:\r\n```llvm ir\r\n; ModuleID = 'reduced.bc'\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine i32 @main(i64 %indvars.iv) #0 {\r\nentry:\r\n br label %for.body17.us77.us.us.i\r\n\r\nfor.body17.us77.us.us.i: ; preds = %cond.end.us84.us.us.i, %entry\r\n %indvars.iv1 = phi i64 [ %indvars.iv.next, %cond.end.us84.us.us.i ], [ 0, %entry ]\r\n br i1 false, label %cond.end.us84.us.us.i, label %cond.true.us80.us.us.i\r\n\r\ncond.true.us80.us.us.i: ; preds = %for.body17.us77.us.us.i\r\n %not.us83.us.us.i = xor i32 0, 0\r\n br label %cond.end.us84.us.us.i\r\n\r\ncond.end.us84.us.us.i: ; preds = %cond.true.us80.us.us.i, %for.body17.us77.us.us.i\r\n %cond.us85.us.us.i = phi i32 [ %not.us83.us.us.i, %cond.true.us80.us.us.i ], [ 0, %for.body17.us77.us.us.i ]\r\n %arrayidx30.us87.us.us.i = getelementptr [0 x [3 x [3 x [3 x [3 x [3 x i32]]]]]], ptr null, i64 0, i64 %indvars.iv1, i64 %indvars.iv, i64 0, i64 2, i64 %indvars.iv, i64 2\r\n store i32 %cond.us85.us.us.i, ptr %arrayidx30.us87.us.us.i, align 4\r\n %indvars.iv.next = add i64 %indvars.iv1, 9\r\n %cmp14.us95.us.us.i = icmp slt i64 %indvars.iv1, 322\r\n br i1 %cmp14.us95.us.us.i, label %for.body17.us77.us.us.i, label %for.body17.us77.us.us.1.i.preheader\r\n\r\nfor.body17.us77.us.us.1.i.preheader: ; preds = %cond.end.us84.us.us.i\r\n ret i32 0\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-b,-e,-experimental-smctr,-experimental-smmpm,-experimental-smnpm,-experimental-ssctr,-experimental-ssnpm,-experimental-sspm,-experimental-supm,-experimental-zacas,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-experimental-zvbc32e,-experimental-zvkgs,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssqosid,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\n```\r\n\r\nCommand/backtrace:\r\n```\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize reduced.ll -S\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7400: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize reduced.ll -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 \"main\"\r\n #0 0x000059162be7f6e0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x30136e0)\r\n #1 0x000059162be7caef llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x3010aef)\r\n #2 0x000059162be7cc45 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007152dd642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007152dd6969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007152dd6969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007152dd6969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x00007152dd642476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007152dd6287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x00007152dd62871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x00007152dd639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x000059162ae52310 llvm::LoopVectorizationPlanner::computeBestVF() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1fe6310)\r\n#12 0x000059162ae6910b llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1ffd10b)\r\n#13 0x000059162ae6c121 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2000121)\r\n#14 0x000059162ae6c797 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2000797)\r\n#15 0x0000591629cc8756 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+0xe5c756)\r\n#16 0x000059162bc8b67f 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+0x2e1f67f)\r\n#17 0x0000591629ccb8e6 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+0xe5f8e6)\r\n#18 0x000059162bc89a1b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e1da1b)\r\n#19 0x0000591629cc7b36 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+0xe5bb36)\r\n#20 0x000059162bc8a57d 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+0x2e1e57d)\r\n#21 0x00005916294f41b6 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+0x6881b6)\r\n#22 0x00005916294e5f11 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x679f11)\r\n#23 0x00007152dd629d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#24 0x00007152dd629e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#25 0x00007152dd629e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#26 0x00005916294dc2c5 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x6702c5)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\nhttps://godbolt.org/z/qEEqe1exM\r\n\r\nFound via fuzzer\r\n\r\nRelated/prior issue: https://github.com/llvm/llvm-project/issues/107171\r\n\r\ncc @fhahn",
"author": "patrick-rivos",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "patrick-rivos",
"body": "Ping. The C fuzzer is hitting this assertion ~15 times a day since the runs starting sep 6th."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
121897
|
https://github.com/llvm/llvm-project/issues/121897
|
crash
|
3b19e787fc5da27dfcc9ac6552b06a763f12ea03
| 2025-01-07T08:06:43 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "0eaa69eb234798774a08743b64a9aa0cf71c5356",
"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": [
[
49,
55
]
],
"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": 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": [
"isUniformAfterVectorization"
],
"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 0eaa69eb234798774a08743b64a9aa0cf71c5356
Author: Florian Hahn <flo@fhahn.com>
Date: Tue Jan 7 21:26:40 2025 +0000
[VPlan] Handle VPExpandSCEVRecipe in isUniformAfterVectorization.
VPExpandSCEVRecipes must be placed in the entry and are alway uniform.
This fixes a crash by always identifying them as uniform, even if the
main vector loop region has been removed.
Fixes https://github.com/llvm/llvm-project/issues/121897.
diff --git a/llvm/lib/Transforms/Vectorize/VPlanUtils.h b/llvm/lib/Transforms/Vectorize/VPlanUtils.h
index 965777002052..777944264f45 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanUtils.h
+++ b/llvm/lib/Transforms/Vectorize/VPlanUtils.h
@@ -49,7 +49,8 @@ inline bool isUniformAfterVectorization(const VPValue *VPV) {
return all_of(GEP->operands(), isUniformAfterVectorization);
if (auto *VPI = dyn_cast<VPInstruction>(Def))
return VPI->isSingleScalar() || VPI->isVectorToScalar();
- return false;
+ // VPExpandSCEVRecipes must be placed in the entry and are alway uniform.
+ return isa<VPExpandSCEVRecipe>(Def);
}
/// Return true if \p V is a header mask in \p Plan.
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/vector-loop-backedge-elimination.ll",
"commands": [
"opt -passes='loop-vectorize,verify<loops>' -force-vector-width=8 -force-vector-interleave=1 -S %s",
"opt -passes='loop-vectorize,verify<loops>' -force-vector-width=8 -force-vector-interleave=2 -S %s",
"opt -passes='loop-vectorize,verify<loops>' -force-vector-width=16 -force-vector-interleave=1 -S %s"
],
"tests": [
{
"test_name": "scev_expand_step",
"test_body": "target datalayout = \"e-m:o-i64:64-i128:128-n32:64-S128\"\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #0\n\ndefine void @scev_expand_step(i64 %x, ptr %dst) {\nentry:\n %c = icmp eq i64 %x, 65536\n call void @llvm.assume(i1 %c)\n %fr = freeze i64 %x\n %step = add i64 %fr, -65534\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.next = add i64 %iv, %step\n %gep.dst = getelementptr i8, ptr %dst, i64 %iv.next\n store i8 0, ptr %gep.dst, align 1\n %ec = icmp slt i64 %iv.next, 16\n br i1 %ec, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "remove_loop_region_outer_loop",
"test_body": "target datalayout = \"e-m:o-i64:64-i128:128-n32:64-S128\"\n\ndeclare i1 @cond()\n\ndefine void @remove_loop_region_outer_loop(i64 range(i64 8, 17) %N, ptr noalias %src, ptr %dst) {\nentry:\n br label %outer.header\n\nouter.header: ; preds = %outer.latch, %entry\n %outer.iv = phi ptr [ %src, %entry ], [ %outer.iv.next, %outer.latch ]\n br label %inner\n\ninner: ; preds = %inner, %outer.header\n %inner.iv = phi i64 [ 0, %outer.header ], [ %iv.next, %inner ]\n %gep.src = getelementptr i8, ptr %outer.iv, i64 %inner.iv\n %l = load i8, ptr %gep.src, align 1\n %gep.dst = getelementptr i8, ptr %dst, i64 %inner.iv\n store i8 %l, ptr %gep.dst, align 1\n %iv.next = add i64 %inner.iv, 1\n %c.1 = icmp eq i64 %iv.next, %N\n br i1 %c.1, label %outer.latch, label %inner\n\nouter.latch: ; preds = %inner\n %outer.iv.next = getelementptr i8, ptr %outer.iv, i64 1\n %c.2 = call i1 @cond()\n br i1 %c.2, label %outer.header, label %exit\n\nexit: ; preds = %outer.latch\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "remove_loop_region_with_replicate_recipe",
"test_body": "target datalayout = \"e-m:o-i64:64-i128:128-n32:64-S128\"\n\ndefine void @remove_loop_region_with_replicate_recipe(ptr %dst, i64 range(i64 5, 10) %N) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 2, %entry ], [ %iv.next, %loop ]\n %gep.dst = getelementptr i16, ptr %dst, i64 %iv\n store i16 0, ptr %gep.dst, align 2\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv.next, %N\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_tc_less_than_16",
"test_body": "target datalayout = \"e-m:o-i64:64-i128:128-n32:64-S128\"\n\ndefine void @test_tc_less_than_16(ptr %A, i64 %N) {\nentry:\n %and = and i64 %N, 15\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ %and, %entry ], [ %iv.next, %loop ]\n %p.src = phi ptr [ %A, %entry ], [ %p.src.next, %loop ]\n %p.src.next = getelementptr inbounds i8, ptr %p.src, i64 1\n %l = load i8, ptr %p.src, align 1\n %add = add nsw i8 %l, 10\n store i8 %add, ptr %p.src, align 1\n %iv.next = add nsw i64 %iv, -1\n %cmp = icmp eq i64 %iv.next, 0\n br i1 %cmp, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[clang] Crash at -O3: Assertion `hasVectorValue(Def)' failed.",
"body": "This code crashes at `-O3`:\n\n```c\nint *a;\nint b, d;\nstatic int f = 65535;\nchar c[];\nint h(int i) {\n int g = 1;\n for (; b;)\n if (a[0]) {\n g = 0;\n break;\n }\n if (g)\n a;\n else if (i)\n return 1;\n return 0;\n}\nvoid k() {\n int *e[10] = {&f};\n for (;;) {\n d = 0;\n for (; d < 8; d = f - 65535 + d + 1) {\n int j = h(f);\n c[j + f - 65534 + d] = 0;\n }\n }\n}\nvoid main() {}\n```\n\nCompiler Explorer: https://godbolt.org/z/rcGqsE196 \n\nBisected to https://github.com/llvm/llvm-project/commit/f48884ded884d982a7fd13394b0e93e6588f4143, which was comitted by @fhahn \n\nCrash:\n\n```console\nclang: /root/llvm-project/llvm/lib/Transforms/Vectorize/VPlan.cpp:236: llvm::Value* llvm::VPTransformState::get(llvm::VPValue*, const llvm::VPLane&): Assertion `hasVectorValue(Def)' 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 \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"k\"\n #0 0x0000000003c71738 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3c71738)\n #1 0x0000000003c6f444 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3c6f444)\n #2 0x0000000003bbc988 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0\n #3 0x000077fbea242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #4 0x000077fbea2969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #5 0x000077fbea242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #6 0x000077fbea2287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #7 0x000077fbea22871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #8 0x000077fbea239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #9 0x00000000058fd2be llvm::VPTransformState::get(llvm::VPValue*, llvm::VPLane const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x58fd2be)\n#10 0x0000000005790d0d llvm::InnerLoopVectorizer::scalarizeInstruction(llvm::Instruction const*, llvm::VPReplicateRecipe*, llvm::VPLane const&, llvm::VPTransformState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5790d0d)\n#11 0x00000000057916d0 llvm::VPReplicateRecipe::execute(llvm::VPTransformState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x57916d0)\n#12 0x00000000058e3ce7 llvm::VPBasicBlock::executeRecipes(llvm::VPTransformState*, llvm::BasicBlock*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x58e3ce7)\n#13 0x00000000058ef282 llvm::VPBasicBlock::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x58ef282)\n#14 0x00000000058f0ef1 llvm::VPRegionBlock::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x58f0ef1)\n#15 0x00000000058fddb1 llvm::VPlan::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x58fddb1)\n#16 0x00000000057be1eb 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/clang+0x57be1eb)\n#17 0x00000000057d24c3 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x57d24c3)\n#18 0x00000000057d3e19 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x57d3e19)\n#19 0x00000000057d4453 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x57d4453)\n#20 0x00000000052f765e 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+0x52f765e)\n#21 0x000000000361c6e0 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x361c6e0)\n#22 0x00000000011305ce 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+0x11305ce)\n#23 0x000000000361affb llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x361affb)\n#24 0x000000000112fc5e 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+0x112fc5e)\n#25 0x000000000361aa00 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x361aa00)\n#26 0x0000000003f247bf (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\n#27 0x0000000003f28335 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+0x3f28335)\n#28 0x000000000460209e clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x460209e)\n#29 0x000000000660f9cc clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x660f9cc)\n#30 0x0000000004602478 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4602478)\n#31 0x00000000048be799 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x48be799)\n#32 0x0000000004840e2e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4840e2e)\n#33 0x00000000049abb8e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x49abb8e)\n#34 0x0000000000ce93ef cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xce93ef)\n#35 0x0000000000ce0e8a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#36 0x0000000004647ae9 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#37 0x0000000003bbce34 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3bbce34)\n#38 0x00000000046480df 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#39 0x000000000460c1ed clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x460c1ed)\n#40 0x000000000460d26e 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+0x460d26e)\n#41 0x0000000004614d95 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4614d95)\n#42 0x0000000000ce6233 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xce6233)\n#43 0x0000000000bb2524 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbb2524)\n#44 0x000077fbea229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#45 0x000077fbea229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#46 0x0000000000ce0935 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xce0935)\n```",
"author": "cardigan1008",
"labels": [
"vectorizers",
"crash-on-valid"
],
"comments": [
{
"author": "fhahn",
"body": "Reduced repro:\n\n```\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @k() {\nentry:\n %.fr = freeze i32 65535\n %invariant.op = add i32 %.fr, -65534\n br label %for.cond.us\n\nfor.cond.us: ; preds = %for.body.us.us, %entry\n br label %for.body.us.us\n\nfor.body.us.us: ; preds = %for.body.us.us, %for.cond.us\n %storemerge7.us.us = phi i32 [ 0, %for.cond.us ], [ %sub.reass.us.us, %for.body.us.us ]\n %sub.reass.us.us = add i32 %storemerge7.us.us, %invariant.op\n %idxprom.us.us = sext i32 %sub.reass.us.us to i64\n %arrayidx.us.us = getelementptr [0 x i8], ptr null, i64 0, i64 %idxprom.us.us\n store i8 0, ptr %arrayidx.us.us, align 1\n %cmp.us.us = icmp slt i32 %sub.reass.us.us, 8\n br i1 %cmp.us.us, label %for.body.us.us, label %for.cond.us\n}\n```"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
117517
|
https://github.com/llvm/llvm-project/issues/117517
|
crash
|
7e3187e12a2cef8b2552e08ce9423aca9c09d813
| 2024-11-25T05:18:47 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "57bbdbd7ae3698a274edd4dd6ef1b53d9129e552",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
1143,
1151
]
],
"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": [
"addMask"
],
"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 57bbdbd7ae3698a274edd4dd6ef1b53d9129e552
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Mon Nov 25 07:56:45 2024 -0800
[SLP]Relax assertion in mask combine for non-power-of-2 number of elements
The nodes may contain non-power-of-2 number of elements. Need to relax
the assertion to avoid possible compiler crash
Fixes #117517
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index d033b7c2ef4a..73218f377a06 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -1143,9 +1143,7 @@ static void addMask(SmallVectorImpl<int> &Mask, ArrayRef<int> SubMask,
assert(
(!ExtendingManyInputs || SubMask.size() > Mask.size() ||
// Check if input scalars were extended to match the size of other node.
- (SubMask.size() == Mask.size() &&
- std::all_of(std::next(Mask.begin(), Mask.size() / 2), Mask.end(),
- [](int Idx) { return Idx == PoisonMaskElem; }))) &&
+ (SubMask.size() == Mask.size() && Mask.back() == PoisonMaskElem)) &&
"SubMask with many inputs support must be larger than the mask.");
if (Mask.empty()) {
Mask.append(SubMask.begin(), SubMask.end());
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/non-power-2-num-elems-reused.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-10 < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine i64 @test() {\n;\nentry:\n %xor148.2.i = xor i32 0, 0\n %conv193.i = zext i32 %xor148.2.i to i64\n %conv193.1.i = zext i32 %xor148.2.i to i64\n %or194.1.i = or i64 %conv193.i, %conv193.1.i\n %xor148.2.i.1 = xor i32 0, 0\n %conv193.i.1 = zext i32 %xor148.2.i.1 to i64\n %or194.i.1 = or i64 %or194.1.i, %conv193.i.1\n %conv193.1.i.1 = zext i32 %xor148.2.i.1 to i64\n %or194.1.i.1 = or i64 %or194.i.1, %conv193.1.i.1\n %xor148.2.i.2 = xor i32 0, 0\n %conv193.i.2 = zext i32 %xor148.2.i.2 to i64\n %or194.i.2 = or i64 %or194.1.i.1, %conv193.i.2\n %conv193.1.i.2 = zext i32 %xor148.2.i.2 to i64\n %or194.1.i.2 = or i64 %or194.i.2, %conv193.1.i.2\n %xor148.2.i.3 = xor i32 0, 0\n %conv193.i.3 = zext i32 %xor148.2.i.3 to i64\n %or194.i.3 = or i64 %or194.1.i.2, %conv193.i.3\n %conv193.1.i.3 = zext i32 %xor148.2.i.3 to i64\n %or194.1.i.3 = or i64 %or194.i.3, %conv193.1.i.3\n %xor148.2.i.4 = xor i32 0, 0\n %conv193.i.4 = zext i32 %xor148.2.i.4 to i64\n %or194.i.4 = or i64 %or194.1.i.3, %conv193.i.4\n %conv193.1.i.4 = zext i32 %xor148.2.i.4 to i64\n %or194.1.i.4 = or i64 %or194.i.4, %conv193.1.i.4\n %xor148.2.i.5 = xor i32 0, 0\n %conv193.i.5 = zext i32 %xor148.2.i.5 to i64\n %or194.i.5 = or i64 %or194.1.i.4, %conv193.i.5\n %conv193.1.i.5 = zext i32 %xor148.2.i.5 to i64\n %or194.1.i.5 = or i64 %or194.i.5, %conv193.1.i.5\n %xor148.2.i.6 = xor i32 0, 0\n %conv193.i.6 = zext i32 %xor148.2.i.6 to i64\n %or194.i.6 = or i64 %or194.1.i.5, %conv193.i.6\n %or54.i.i.6 = or i32 %xor148.2.i.6, 0\n %conv193.1.i.6 = zext i32 %or54.i.i.6 to i64\n %xor148.2.i.7 = xor i32 0, 0\n %conv193.i.7 = zext i32 %xor148.2.i.7 to i64\n %0 = or i64 %or194.i.6, %conv193.i.7\n %conv193.1.i.7 = zext i32 %xor148.2.i.7 to i64\n %1 = or i64 %0, %conv193.1.i.7\n %or194.1.i.7 = or i64 %1, %conv193.1.i.6\n ret i64 %or194.1.i.7\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SLPVectorizer] Assertion \"SubMask with many inputs support must be larger than the mask.\" failed.",
"body": "Reproducer: https://godbolt.org/z/Mzbe1G875\r\n```\r\n; bin/opt -passes=slp-vectorizer test.ll -S\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine i64 @test() {\r\nentry:\r\n %xor148.2.i = xor i32 0, 0\r\n %conv193.i = zext i32 %xor148.2.i to i64\r\n %conv193.1.i = zext i32 %xor148.2.i to i64\r\n %or194.1.i = or i64 %conv193.i, %conv193.1.i\r\n %xor148.2.i.1 = xor i32 0, 0\r\n %conv193.i.1 = zext i32 %xor148.2.i.1 to i64\r\n %or194.i.1 = or i64 %or194.1.i, %conv193.i.1\r\n %conv193.1.i.1 = zext i32 %xor148.2.i.1 to i64\r\n %or194.1.i.1 = or i64 %or194.i.1, %conv193.1.i.1\r\n %xor148.2.i.2 = xor i32 0, 0\r\n %conv193.i.2 = zext i32 %xor148.2.i.2 to i64\r\n %or194.i.2 = or i64 %or194.1.i.1, %conv193.i.2\r\n %conv193.1.i.2 = zext i32 %xor148.2.i.2 to i64\r\n %or194.1.i.2 = or i64 %or194.i.2, %conv193.1.i.2\r\n %xor148.2.i.3 = xor i32 0, 0\r\n %conv193.i.3 = zext i32 %xor148.2.i.3 to i64\r\n %or194.i.3 = or i64 %or194.1.i.2, %conv193.i.3\r\n %conv193.1.i.3 = zext i32 %xor148.2.i.3 to i64\r\n %or194.1.i.3 = or i64 %or194.i.3, %conv193.1.i.3\r\n %xor148.2.i.4 = xor i32 0, 0\r\n %conv193.i.4 = zext i32 %xor148.2.i.4 to i64\r\n %or194.i.4 = or i64 %or194.1.i.3, %conv193.i.4\r\n %conv193.1.i.4 = zext i32 %xor148.2.i.4 to i64\r\n %or194.1.i.4 = or i64 %or194.i.4, %conv193.1.i.4\r\n %xor148.2.i.5 = xor i32 0, 0\r\n %conv193.i.5 = zext i32 %xor148.2.i.5 to i64\r\n %or194.i.5 = or i64 %or194.1.i.4, %conv193.i.5\r\n %conv193.1.i.5 = zext i32 %xor148.2.i.5 to i64\r\n %or194.1.i.5 = or i64 %or194.i.5, %conv193.1.i.5\r\n %xor148.2.i.6 = xor i32 0, 0\r\n %conv193.i.6 = zext i32 %xor148.2.i.6 to i64\r\n %or194.i.6 = or i64 %or194.1.i.5, %conv193.i.6\r\n %or54.i.i.6 = or i32 %xor148.2.i.6, 0\r\n %conv193.1.i.6 = zext i32 %or54.i.i.6 to i64\r\n %xor148.2.i.7 = xor i32 0, 0\r\n %conv193.i.7 = zext i32 %xor148.2.i.7 to i64\r\n %0 = or i64 %or194.i.6, %conv193.i.7\r\n %conv193.1.i.7 = zext i32 %xor148.2.i.7 to i64\r\n %1 = or i64 %0, %conv193.1.i.7\r\n %or194.1.i.7 = or i64 %1, %conv193.1.i.6\r\n ret i64 %or194.1.i.7\r\n}\r\n```\r\n```\r\nopt: /root/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:1143: void addMask(llvm::SmallVectorImpl<int>&, llvm::ArrayRef<int>, bool): Assertion `(!ExtendingManyInputs || SubMask.size() > Mask.size() || (SubMask.size() == Mask.size() && std::all_of(std::next(Mask.begin(), Mask.size() / 2), Mask.end(), [](int Idx) { return Idx == PoisonMaskElem; }))) && \"SubMask with many inputs support must be larger than the mask.\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer <source>\r\n1.\tRunning pass \"function(slp-vectorizer)\" on module \"<source>\"\r\n2.\tRunning pass \"slp-vectorizer\" on function \"test\"\r\n #0 0x00000000051b7378 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x51b7378)\r\n #1 0x00000000051b4d6c SignalHandler(int) Signals.cpp:0:0\r\n #2 0x0000751221842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x00007512218969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x0000751221842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x00007512218287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x000075122182871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x0000751221839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x00000000041e91f7 llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator::finalize(llvm::ArrayRef<int>, llvm::ArrayRef<std::pair<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, unsigned int>>, llvm::ArrayRef<int>, unsigned int, llvm::function_ref<void (llvm::Value*&, llvm::SmallVectorImpl<int>&)>) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41e91f7)\r\n #9 0x00000000042256f9 llvm::InstructionCost llvm::slpvectorizer::BoUpSLP::processBuildVector<llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator, llvm::InstructionCost, llvm::TargetTransformInfo, llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP, llvm::SmallPtrSetImpl<llvm::Value*>>(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::Type*, llvm::TargetTransformInfo&, llvm::ArrayRef<llvm::Value*>&, llvm::slpvectorizer::BoUpSLP&, llvm::SmallPtrSetImpl<llvm::Value*>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x42256f9)\r\n#10 0x000000000422f707 llvm::slpvectorizer::BoUpSLP::getEntryCost(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallPtrSetImpl<llvm::Value*>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x422f707)\r\n#11 0x00000000042636a1 llvm::slpvectorizer::BoUpSLP::getTreeCost(llvm::ArrayRef<llvm::Value*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x42636a1)\r\n#12 0x00000000042691b0 (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&) SLPVectorizer.cpp:0:0\r\n#13 0x000000000426c681 llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x426c681)\r\n#14 0x0000000004270deb llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (.constprop.0) SLPVectorizer.cpp:0:0\r\n#15 0x00000000042758a6 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x42758a6)\r\n#16 0x000000000427bf86 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\r\n#17 0x000000000427ca9b llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x427ca9b)\r\n#18 0x0000000002fcc5ce llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2fcc5ce)\r\n#19 0x0000000004fb6a68 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4fb6a68)\r\n#20 0x0000000000e3dd4e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe3dd4e)\r\n#21 0x0000000004fb548e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4fb548e)\r\n#22 0x0000000000e3d3fe llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe3d3fe)\r\n#23 0x0000000004fb4ec0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4fb4ec0)\r\n#24 0x000000000090ce7a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x90ce7a)\r\n#25 0x00000000008ff519 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8ff519)\r\n#26 0x0000751221829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#27 0x0000751221829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#28 0x00000000008f6d6e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8f6d6e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```",
"author": "dtcxzyw",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
131359
|
https://github.com/llvm/llvm-project/issues/131359
|
crash
|
e2c43ba981620cf71ce3ccf004db7c0db4caf8a7
| 2025-03-14T16:56:53 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "eef5ea0c42fc07ef2c948be59b57d0df8ec801ca",
"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": [
[
7467,
7472
]
],
"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": [
"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 eef5ea0c42fc07ef2c948be59b57d0df8ec801ca
Author: Luke Lau <luke@igalia.com>
Date: Tue Mar 18 01:00:54 2025 +0900
[VPlan] Account for dead FOR splice simplification in cost model (#131486)
Fixes #131359
After #129645, a first-order recurrence will no longer have it's splice
costed if the VPInstruction::FirstOrderRecurrenceSplice has no users and
is dead.
The legacy cost model didn't account for this, so this accounts for it
in planContainsAdditionalSimplifications to avoid the "VPlan cost model
and legacy cost model disagreed" assertion.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index b26b36f91a39..0e38ccc565ea 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7467,6 +7467,16 @@ static bool planContainsAdditionalSimplifications(VPlan &Plan,
}
continue;
}
+ // Unused FOR splices are removed by VPlan transforms, so the VPlan-based
+ // cost model won't cost it whilst the legacy will.
+ if (auto *FOR = dyn_cast<VPFirstOrderRecurrencePHIRecipe>(&R)) {
+ if (none_of(FOR->users(), [](VPUser *U) {
+ auto *VPI = dyn_cast<VPInstruction>(U);
+ return VPI && VPI->getOpcode() ==
+ VPInstruction::FirstOrderRecurrenceSplice;
+ }))
+ return true;
+ }
// The VPlan-based cost model is more accurate for partial reduction and
// comparing against the legacy cost isn't desirable.
if (isa<VPPartialReductionRecipe>(&R))
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/X86/pr131359-dead-for-splice.ll",
"commands": [
"opt -p loop-vectorize -S %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n; If a FOR isn't used the VPInstruction::FirstOrderRecurrenceSplice will be dead\n; and won't be costed in the VPlan cost model. Make sure we account for this\n; simplifcation in comparison to the legacy cost model.\n\ntarget triple = \"x86_64\"\n\ndefine void @no_use() {\n;\nentry:\n br label %loop\n\nloop:\n %for = phi i32 [ 0, %entry ], [ %iv, %loop ]\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.next = add i32 %iv, 1\n %exitcond.not.i = icmp eq i32 %iv, 43\n br i1 %exitcond.not.i, label %exit, label %loop\n\nexit:\n ret void\n}\n\ndefine void @dead_use() {\n;\nentry:\n br label %loop\n\nloop:\n %for = phi i32 [ 0, %entry ], [ %iv, %loop ]\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %dead = add i32 %for, 1\n %iv.next = add i32 %iv, 1\n %exitcond.not.i = icmp eq i32 %iv, 43\n br i1 %exitcond.not.i, label %exit, label %loop\n\nexit:\n ret void\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "clang crashes at -Os on x86_64-linux-gnu: Assertion `... \" VPlan cost model and legacy cost model disagreed\"' failed",
"body": "It appears to be a regression from 19.1.0 and affects 20.1.0 and later. \n\nCompiler Explorer: https://godbolt.org/z/K3Y3zn4hP\n\n```\n[515] % 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[516] % \n[516] % clangtk -Os small.c\nclang-21: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7574: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || PlanForEarlyExitLoop || 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, 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/20250313-clangtk-m64-Os-build-082148/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20250313-clangtk-m64-Os-build-082148/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-d02bf4.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 \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\n #0 0x0000563ced471fcf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x4577fcf)\n #1 0x0000563ced46f7a4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007f1c5b61c420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\n #3 0x00007f1c5b05300b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\n #4 0x00007f1c5b032859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\n #5 0x00007f1c5b032729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\n #6 0x00007f1c5b032729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\n #7 0x00007f1c5b043fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\n #8 0x0000563ceeecce93 llvm::LoopVectorizationPlanner::computeBestVF() (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5fd2e93)\n #9 0x0000563ceeee48a6 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5fea8a6)\n#10 0x0000563ceeee72a1 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5fed2a1)\n#11 0x0000563ceeee7943 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5fed943)\n#12 0x0000563ceea5a6d6 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-21+0x5b606d6)\n#13 0x0000563cecde27c9 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#14 0x0000563cea6cc7a6 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#15 0x0000563cecde1032 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x3ee7032)\n#16 0x0000563cea6ca3b6 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#17 0x0000563cecde0a51 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#18 0x0000563ced72fe4a (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#19 0x0000563ced7338a1 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#20 0x0000563cede73d91 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x4f79d91)\n#21 0x0000563cef8016dc clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x69076dc)\n#22 0x0000563cede741b8 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x4f7a1b8)\n#23 0x0000563cee14abc9 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5250bc9)\n#24 0x0000563cee0cbece clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x51d1ece)\n#25 0x0000563cee23f996 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5345996)\n#26 0x0000563cea25f9ed cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x13659ed)\n#27 0x0000563cea25715a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#28 0x0000563cea25b3c7 clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x13613c7)\n#29 0x0000563cea1400db main (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x12460db)\n#30 0x00007f1c5b034083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\n#31 0x0000563cea256bee _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-7bdf6a.c\nclangtk: note: diagnostic msg: /tmp/small-7bdf6a.sh\nclangtk: note: diagnostic msg: \n\n********************\n[517] % \n[517] % cat small.c\nint printf(const char *, ...);\nint a, c, d, e;\nstatic int b = 2;\nstatic void f() {\n printf(\"0\\n\");\n for (c = 0; c < 3; c++)\n if (d && c >= b && e)\n a = 0;\n}\nint main() {\n b = 0;\n f();\n return 0;\n}\n```\n\n",
"author": "zhendongsu",
"labels": [
"vectorizers",
"crash",
"regression:20"
],
"comments": [
{
"author": "cardigan1008",
"body": "Here is another case that triggers the same crash at `-O2`:\n\n```c\nint a, b;\nchar c;\nvoid f(int g) {\n int d;\n for (int e = 0; e < g; e++)\n d = e;\n a = d;\n}\nvoid h() {\n if (c)\n b = 0;\n else\n b = 1;\n f(b + 42);\n}\nvoid main() {}\n```\n\nCompiler Explorer: https://godbolt.org/z/zY6GT5eox\n\nBisected to https://github.com/llvm/llvm-project/commit/26324bc1bf397453ce966f56a88245263f7beec5, which was committed by @lukel97 "
},
{
"author": "lukel97",
"body": "Hi @zhendongsu @cardigan1008, thanks for reporting/reducing/bisecting this. Can you confirm that this is fixed now after [eef5ea0](https://github.com/llvm/llvm-project/commit/eef5ea0c42fc07ef2c948be59b57d0df8ec801ca)?"
},
{
"author": "cardigan1008",
"body": "Hi @lukel97 my case has been fixed. But the first case seems to still trigger the same crash at `-Os`.\n\nMy clang version: clang version 21.0.0git (https://github.com/llvm/llvm-project.git b3c5031b07396959c5d4e7f62d516d63de015358)"
},
{
"author": "lukel97",
"body": "@cardigan1008 Looks like that's a separate vplan-legacy cost model mismatch, it seems to be reproducible before 26324bc1bf397453ce966f56a88245263f7beec5. I'll leave this issue open"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
109468
|
https://github.com/llvm/llvm-project/issues/109468
|
crash
|
51039101cf32591782ef564a108db71150a3b7c3
| 2024-09-20T20:22:11 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "a068b974b199b0e7350da2d9506adc7df3995ce3",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
2267,
2272
],
[
2363,
2368
]
],
"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": [
[
2709,
2714
],
[
2787,
2792
]
],
"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": [
"VPWidenLoadEVLRecipe::execute",
"VPWidenLoadEVLRecipe::print",
"VPWidenStoreEVLRecipe::execute",
"VPWidenStoreEVLRecipe::print"
],
"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 a068b974b199b0e7350da2d9506adc7df3995ce3
Author: Elvis Wang <elvis.wang@sifive.com>
Date: Thu Sep 26 07:10:25 2024 +0800
[VPlan] Implement VPWidenLoad/StoreEVLRecipe::computeCost(). (#109644)
Currently the EVL recipes transfer the tail masking to the EVL.
But in the legacy cost model, the mask exist and will calculate the
instruction cost of the mask.
To fix the difference between the VPlan-based cost model and the legacy
cost model, we always calculate the instruction cost for the mask in the
EVL recipes.
Note that we should remove the mask cost in the EVL recipes when we
don't need to compare to the legacy cost model.
This patch also fixes #109468.
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index bbcfaf9e19cd..23a24ce293ef 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -2709,6 +2709,10 @@ struct VPWidenLoadEVLRecipe final : public VPWidenMemoryRecipe, public VPValue {
/// Generate the wide load or gather.
void execute(VPTransformState &State) override;
+ /// Return the cost of this VPWidenLoadEVLRecipe.
+ InstructionCost computeCost(ElementCount VF,
+ VPCostContext &Ctx) const override;
+
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
/// Print the recipe.
void print(raw_ostream &O, const Twine &Indent,
@@ -2787,6 +2791,10 @@ struct VPWidenStoreEVLRecipe final : public VPWidenMemoryRecipe {
/// Generate the wide store or scatter.
void execute(VPTransformState &State) override;
+ /// Return the cost of this VPWidenStoreEVLRecipe.
+ InstructionCost computeCost(ElementCount VF,
+ VPCostContext &Ctx) const override;
+
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
/// Print the recipe.
void print(raw_ostream &O, const Twine &Indent,
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index dacba152611c..9a0aefb898e5 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -2267,6 +2267,31 @@ void VPWidenLoadEVLRecipe::execute(VPTransformState &State) {
State.set(this, Res);
}
+InstructionCost VPWidenLoadEVLRecipe::computeCost(ElementCount VF,
+ VPCostContext &Ctx) const {
+ if (!Consecutive || IsMasked)
+ return VPWidenMemoryRecipe::computeCost(VF, Ctx);
+
+ // We need to use the getMaskedMemoryOpCost() instead of getMemoryOpCost()
+ // here because the EVL recipes using EVL to replace the tail mask. But in the
+ // legacy model, it will always calculate the cost of mask.
+ // TODO: Using getMemoryOpCost() instead of getMaskedMemoryOpCost when we
+ // don't need to compare to the legacy cost model.
+ Type *Ty = ToVectorTy(getLoadStoreType(&Ingredient), VF);
+ const Align Alignment =
+ getLoadStoreAlignment(const_cast<Instruction *>(&Ingredient));
+ unsigned AS =
+ getLoadStoreAddressSpace(const_cast<Instruction *>(&Ingredient));
+ TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
+ InstructionCost Cost = Ctx.TTI.getMaskedMemoryOpCost(
+ Ingredient.getOpcode(), Ty, Alignment, AS, CostKind);
+ if (!Reverse)
+ return Cost;
+
+ return Cost + Ctx.TTI.getShuffleCost(TargetTransformInfo::SK_Reverse,
+ cast<VectorType>(Ty), {}, CostKind, 0);
+}
+
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void VPWidenLoadEVLRecipe::print(raw_ostream &O, const Twine &Indent,
VPSlotTracker &SlotTracker) const {
@@ -2363,6 +2388,31 @@ void VPWidenStoreEVLRecipe::execute(VPTransformState &State) {
State.addMetadata(NewSI, SI);
}
+InstructionCost VPWidenStoreEVLRecipe::computeCost(ElementCount VF,
+ VPCostContext &Ctx) const {
+ if (!Consecutive || IsMasked)
+ return VPWidenMemoryRecipe::computeCost(VF, Ctx);
+
+ // We need to use the getMaskedMemoryOpCost() instead of getMemoryOpCost()
+ // here because the EVL recipes using EVL to replace the tail mask. But in the
+ // legacy model, it will always calculate the cost of mask.
+ // TODO: Using getMemoryOpCost() instead of getMaskedMemoryOpCost when we
+ // don't need to compare to the legacy cost model.
+ Type *Ty = ToVectorTy(getLoadStoreType(&Ingredient), VF);
+ const Align Alignment =
+ getLoadStoreAlignment(const_cast<Instruction *>(&Ingredient));
+ unsigned AS =
+ getLoadStoreAddressSpace(const_cast<Instruction *>(&Ingredient));
+ TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
+ InstructionCost Cost = Ctx.TTI.getMaskedMemoryOpCost(
+ Ingredient.getOpcode(), Ty, Alignment, AS, CostKind);
+ if (!Reverse)
+ return Cost;
+
+ return Cost + Ctx.TTI.getShuffleCost(TargetTransformInfo::SK_Reverse,
+ cast<VectorType>(Ty), {}, CostKind, 0);
+}
+
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void VPWidenStoreEVLRecipe::print(raw_ostream &O, const Twine &Indent,
VPSlotTracker &SlotTracker) const {
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/RISCV/vectorize-force-tail-with-evl-uniform-store.ll",
"commands": [
"opt < %s --prefer-predicate-over-epilogue=predicate-dont-vectorize --passes=loop-vectorize -mcpu=sifive-p470 -mattr=+v,+f -force-tail-folding-style=data-with-evl -S"
],
"tests": [
{
"test_name": "lshift_significand",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @lshift_significand(i32 %n, ptr nocapture writeonly %dst) {\nentry:\n %cmp1.peel = icmp eq i32 %n, 0\n %spec.select = select i1 %cmp1.peel, i64 2, i64 0\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ %spec.select, %entry ], [ %iv.next, %loop ]\n %0 = sub nuw nsw i64 1, %iv\n %arrayidx13 = getelementptr i64, ptr %dst, i64 %0\n store i64 0, ptr %arrayidx13, align 8\n %iv.next = add nuw nsw i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 3\n br i1 %exitcond.not, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[LV][VPlan] Crash due to disagreements on the VPlan cost v.s. legacy cost model",
"body": "Given this input:\r\n``` llvm\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine void @lshift_significand(i32 %n, ptr %0) {\r\nentry:\r\n br label %for.cond\r\n\r\nfor.cond: ; preds = %for.cond, %entry\r\n %i.0 = phi i32 [ 0, %entry ], [ 2, %for.cond ]\r\n %add = or i32 %n, %i.0\r\n %cmp1 = icmp eq i32 %add, 0\r\n br i1 %cmp1, label %for.cond, label %for.cond7\r\n\r\nfor.cond7: ; preds = %for.body9, %for.cond\r\n %i.1 = phi i32 [ %i.0, %for.cond ], [ %inc15, %for.body9 ]\r\n %cmp8 = icmp ult i32 %i.1, 3\r\n br i1 %cmp8, label %for.body9, label %for.end16\r\n\r\nfor.body9: ; preds = %for.cond7\r\n %sub11 = sub nuw i32 1, %i.1\r\n %idxprom12 = zext i32 %sub11 to i64\r\n %arrayidx13 = getelementptr [3 x i64], ptr %0, i64 0, i64 %idxprom12\r\n store i64 0, ptr %arrayidx13, align 8\r\n %inc15 = add i32 %i.1, 1\r\n br label %for.cond7\r\n\r\nfor.end16: ; preds = %for.cond7\r\n ret void\r\n}\r\n```\r\nAnd this command:\r\n``` bash\r\nopt -mcpu=sifive-p470 -O3 -prefer-predicate-over-epilogue=predicate-dont-vectorize -force-tail-folding-style=data-with-evl input.ll -disable-output\r\n```\r\nWe'll get the following assertion:\r\n```\r\nllvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7386: VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\n```\r\n\r\n\r\nPreliminary investigation shows that this is caused by the disagreement on (reverse) widen store's cost. First, this is the trace for VPlan's cost model:\r\n```\r\nLV: Scalar loop costs: 4.\r\nCost of 1 for VF vscale x 1: induction instruction %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1\r\nCost of 0 for VF vscale x 1: induction instruction %indvars.iv = phi i64 [ %spec.select, %entry ], [ %indvars.iv.next, %for.body9 ]\r\nCost of 1 for VF vscale x 1: exit condition instruction %exitcond.not = icmp eq i64 %indvars.iv.next, 3\r\nCost of 0 for VF vscale x 1: EMIT vp<%4> = CANONICAL-INDUCTION ir<0>, vp<%12>\r\nCost of 0 for VF vscale x 1: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI vp<%5> = phi ir<0>, vp<%11>\r\nCost of 0 for VF vscale x 1: EMIT vp<%6> = EXPLICIT-VECTOR-LENGTH vp<%5>, vp<%3>\r\nCost of 0 for VF vscale x 1: vp<%7> = DERIVED-IV ir<%spec.select> + vp<%5> * ir<1>\r\nCost of 0 for VF vscale x 1: vp<%8> = SCALAR-STEPS vp<%7>, ir<1>\r\nCost of 1 for VF vscale x 1: CLONE ir<%1> = sub nuw nsw ir<1>, vp<%8>\r\nCost of 0 for VF vscale x 1: CLONE ir<%arrayidx13> = getelementptr ir<%0>, ir<0>, ir<%1>\r\nCost of 0 for VF vscale x 1: vp<%9> = vector-pointer (reverse) ir<%arrayidx13>\r\nCost of 8 for VF vscale x 1: WIDEN vp.store vp<%9>, ir<0>, vp<%6>\r\nCost of 0 for VF vscale x 1: SCALAR-CAST vp<%10> = zext vp<%6> to i64\r\nCost of 0 for VF vscale x 1: EMIT vp<%11> = add vp<%10>, vp<%5>\r\nCost of 0 for VF vscale x 1: EMIT vp<%12> = add vp<%4>, vp<%0>\r\nCost of 0 for VF vscale x 1: EMIT branch-on-count vp<%12>, vp<%1>\r\nCost of 0 for VF vscale x 1: vector loop backedge\r\nCost for VF vscale x 1: 11\r\nCost of 1 for VF vscale x 2: induction instruction %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1\r\nCost of 0 for VF vscale x 2: induction instruction %indvars.iv = phi i64 [ %spec.select, %entry ], [ %indvars.iv.next, %for.body9 ]\r\nCost of 1 for VF vscale x 2: exit condition instruction %exitcond.not = icmp eq i64 %indvars.iv.next, 3\r\nCost of 0 for VF vscale x 2: EMIT vp<%4> = CANONICAL-INDUCTION ir<0>, vp<%12>\r\nCost of 0 for VF vscale x 2: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI vp<%5> = phi ir<0>, vp<%11>\r\nCost of 0 for VF vscale x 2: EMIT vp<%6> = EXPLICIT-VECTOR-LENGTH vp<%5>, vp<%3>\r\nCost of 0 for VF vscale x 2: vp<%7> = DERIVED-IV ir<%spec.select> + vp<%5> * ir<1>\r\nCost of 0 for VF vscale x 2: vp<%8> = SCALAR-STEPS vp<%7>, ir<1>\r\nCost of 1 for VF vscale x 2: CLONE ir<%1> = sub nuw nsw ir<1>, vp<%8>\r\nCost of 0 for VF vscale x 2: CLONE ir<%arrayidx13> = getelementptr ir<%0>, ir<0>, ir<%1>\r\nCost of 0 for VF vscale x 2: vp<%9> = vector-pointer (reverse) ir<%arrayidx13>\r\nCost of 14 for VF vscale x 2: WIDEN vp.store vp<%9>, ir<0>, vp<%6>\r\nCost of 0 for VF vscale x 2: SCALAR-CAST vp<%10> = zext vp<%6> to i64\r\nCost of 0 for VF vscale x 2: EMIT vp<%11> = add vp<%10>, vp<%5>\r\nCost of 0 for VF vscale x 2: EMIT vp<%12> = add vp<%4>, vp<%0>\r\nCost of 0 for VF vscale x 2: EMIT branch-on-count vp<%12>, vp<%1>\r\nCost of 0 for VF vscale x 2: vector loop backedge\r\nCost for VF vscale x 2: 17\r\n```\r\nWith VPlan's cost model, we will eventually choose scalar loop, because when VF=vscale x 1, the final cost is `ceil(11 / 2) = 6`; when VF=vscale x 2, the final cost is `ceil(17 / 4) = 5`. Both of them are larger than the scalar cost, 4.\r\n\r\nWhile with the legacy cost model:\r\n```\r\nLV: Found an estimated cost of 0 for VF 1 For instruction: %indvars.iv = phi i64 [ %spec.select, %entry ], [ %indvars.iv.next, %for.body9 ]\r\nLV: Found an estimated cost of 1 for VF 1 For instruction: %1 = sub nuw nsw i64 1, %indvars.iv\r\nLV: Found an estimated cost of 0 for VF 1 For instruction: %arrayidx13 = getelementptr [3 x i64], ptr %0, i64 0, i64 %1\r\nLV: Found an estimated cost of 1 for VF 1 For instruction: store i64 0, ptr %arrayidx13, align 8\r\nLV: Found an estimated cost of 1 for VF 1 For instruction: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1\r\nLV: Found an estimated cost of 1 for VF 1 For instruction: %exitcond.not = icmp eq i64 %indvars.iv.next, 3\r\nLV: Found an estimated cost of 0 for VF 1 For instruction: br i1 %exitcond.not, label %for.end16, label %for.body9\r\nLV: Scalar loop costs: 4.\r\nLV: Found an estimated cost of 0 for VF vscale x 1 For instruction: %indvars.iv = phi i64 [ %spec.select, %entry ], [ %indvars.iv.next, %for.body9 ]\r\nLV: Found an estimated cost of 1 for VF vscale x 1 For instruction: %1 = sub nuw nsw i64 1, %indvars.iv\r\nLV: Found an estimated cost of 0 for VF vscale x 1 For instruction: %arrayidx13 = getelementptr [3 x i64], ptr %0, i64 0, i64 %1\r\nLV: Found an estimated cost of 7 for VF vscale x 1 For instruction: store i64 0, ptr %arrayidx13, align 8\r\nLV: Found an estimated cost of 1 for VF vscale x 1 For instruction: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1\r\nLV: Found an estimated cost of 1 for VF vscale x 1 For instruction: %exitcond.not = icmp eq i64 %indvars.iv.next, 3\r\nLV: Found an estimated cost of 0 for VF vscale x 1 For instruction: br i1 %exitcond.not, label %for.end16, label %for.body9\r\nLV: Vector loop of width vscale x 1 costs: 5 (assuming a minimum vscale of 2).\r\nLV: Found an estimated cost of 0 for VF vscale x 2 For instruction: %indvars.iv = phi i64 [ %spec.select, %entry ], [ %indvars.iv.next, %for.body9 ]\r\nLV: Found an estimated cost of 1 for VF vscale x 2 For instruction: %1 = sub nuw nsw i64 1, %indvars.iv\r\nLV: Found an estimated cost of 0 for VF vscale x 2 For instruction: %arrayidx13 = getelementptr [3 x i64], ptr %0, i64 0, i64 %1\r\nLV: Found an estimated cost of 13 for VF vscale x 2 For instruction: store i64 0, ptr %arrayidx13, align 8\r\nLV: Found an estimated cost of 1 for VF vscale x 2 For instruction: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1\r\nLV: Found an estimated cost of 1 for VF vscale x 2 For instruction: %exitcond.not = icmp eq i64 %indvars.iv.next, 3\r\nLV: Found an estimated cost of 0 for VF vscale x 2 For instruction: br i1 %exitcond.not, label %for.end16, label %for.body9\r\nLV: Vector loop of width vscale x 2 costs: 4 (assuming a minimum vscale of 2).\r\nLV: Selecting VF: vscale x 2.\r\n```\r\nWe will eventually choose VF=vscale x 2.\r\n\r\nThe key difference is the cost of `store i64 0, ptr %arrayidx13, align 8` v.s. cost of `WIDEN vp.store vp<%9>, ir<0>, vp<%6>`, where the latter is larger than the former by 1.\r\n\r\nIn both cases (the store instruction in VPlan cost model v.s. legacy cost model) their costs are computed by the base cost of store + the cost of shuffle due to being reverse store. I used debugger to confirm that they used the same shuffle cost, which means that for some reason, VPlan's cost model yield a slightly higher cost for store than that in the legacy cost model.\r\n",
"author": "mshockwave",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "ElvisWang123",
"body": "It seems that the legacy cost model using `getMaskedMemoryOpCost` to query the instruction cost. But in the VPlan-based cost model using `getMemoryOpCost`. \r\n\r\nIn this case, the mask in the `VPWidenStoreEVLRecipe` is false since it is using the EVL recipe.\r\nThe legacy cost model will not check the tail folding type so it will using `getMaskedMemoryOpCost` instead of `getMemoryOpCost` . And the `MaskedMemoryCost` is slightly smaller than non-mask version."
},
{
"author": "ElvisWang123",
"body": "Open a PR to fix this issue. #109644 \r\n\r\nWe remove the shuffle cost when the value stored by reversed vector is loop invariant."
},
{
"author": "mshockwave",
"body": "CC @fhahn "
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
91883
|
https://github.com/llvm/llvm-project/issues/91883
|
crash
|
90109d444839683b09f0aafdc50b749cb4b3203b
| 2024-05-12T12:03:48 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "67d840b60fbd75ca1b52d77bd3353771ec853735",
"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": [
[
246,
252
]
],
"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 67d840b60fbd75ca1b52d77bd3353771ec853735
Author: Florian Hahn <flo@fhahn.com>
Date: Tue May 14 19:10:48 2024 +0100
[VPlan] Relax over-aggressive assertion in VPTransformState::get().
There are cases where a vector value has some users that demand the
the single scalar value only (NeedsScalar), while other users demand the
vector value (see attached test cases). In those cases, the NeedsScalar
users should only demand the first lane.
Fixes https://github.com/llvm/llvm-project/issues/91883.
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index 999236ae8489..27f8e239b1c0 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -246,7 +246,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() ||
+ assert((VF.isScalar() || Def->isLiveIn() || hasVectorValue(Def, Part) ||
(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/X86/widened-value-used-as-scalar-and-first-lane.ll",
"commands": [
"opt -S -passes=loop-vectorize -mcpu=skylake-avx512 -mtriple=x86_64-apple-macosx -S %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\n; Test cases based on https://github.com/llvm/llvm-project/issues/91883.\ndefine void @iv.4_used_as_vector_and_first_lane(ptr %src, ptr noalias %dst) {\n;\nentry:\n br label %loop.header\n\nloop.header:\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %g.src = getelementptr inbounds i64, ptr %src, i64 %iv\n %l = load i64, ptr %g.src\n %iv.4 = add nuw nsw i64 %iv, 4\n %c = icmp ule i64 %l, 128\n br i1 %c, label %loop.then, label %loop.latch\n\nloop.then:\n %or = or disjoint i64 %iv.4, 1\n %g.dst = getelementptr inbounds i64, ptr %dst, i64 %or\n store i64 %iv.4, ptr %g.dst, align 4\n br label %loop.latch\n\nloop.latch:\n %iv.next = add nuw nsw i64 %iv, 1\n %exitcond = icmp eq i64 %iv.next, 32\n br i1 %exitcond, label %exit, label %loop.header\n\nexit:\n ret void\n}\n\ndefine void @iv.4_used_as_first_lane(ptr %src, ptr noalias %dst) {\n;\nentry:\n br label %loop.header\n\nloop.header:\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %g.src = getelementptr inbounds i64, ptr %src, i64 %iv\n %l = load i64, ptr %g.src\n %iv.4 = add nuw nsw i64 %iv, 4\n %c = icmp ule i64 %l, 128\n br i1 %c, label %loop.then, label %loop.latch\n\nloop.then:\n %or = or disjoint i64 %iv.4, 1\n %g.dst = getelementptr inbounds i64, ptr %dst, i64 %or\n store i64 %l, ptr %g.dst, align 4\n br label %loop.latch\n\nloop.latch:\n %iv.next = add nuw nsw i64 %iv, 1\n %exitcond = icmp eq i64 %iv.next, 32\n br i1 %exitcond, label %exit, label %loop.header\n\nexit:\n ret void\n}\n;.\n;.",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "New LLVM vectorizer crash in assertion",
"body": "@fhahn hits an assertion introduced in https://github.com/llvm/llvm-project/pull/80271\r\n\r\nInput file: https://gist.github.com/cheshire/e504c63db9bdb300fbdcc1df2e183bd8\r\n\r\nRepro:\r\n\r\n```\r\nopt -S -passes=loop-vectorize -mattr=+prfchw,-cldemote,+avx,+aes,+sahf,+pclmul,-xop,+crc32,+xsaves,-avx512fp16,-usermsr,-sm4,-egpr,+sse4.1,-avx512ifma,+xsave,+sse4.2,-avx512pf,-tsxldtrk,-ptwrite,-widekl,-sm3,+invpcid,+64bit,+xsavec,-avx10.1-512,-avx512vpopcntdq,+cmov,-avx512vp2intersect,+avx512cd,+movbe,-avxvnniint8,-avx512er,-ccmp,-amx-int8,-kl,-avx10.1-256,+evex512,-avxvnni,+rtm,+adx,+avx2,-hreset,-movdiri,-serialize,-sha512,-vpclmulqdq,+avx512vl,-uintr,-cf,+clflushopt,-raoint,-cmpccxadd,+bmi,-amx-tile,+sse,-gfni,-avxvnniint16,-amx-fp16,-ndd,+xsaveopt,+rdrnd,+avx512f,-amx-bf16,-avx512bf16,-avx512vnni,-push2pop2,+cx8,+avx512bw,+sse3,+pku,+fsgsbase,-clzero,-mwaitx,-lwp,+lzcnt,-sha,-movdir64b,-ppx,-wbnoinvd,-enqcmd,-prefetchwt1,-avxneconvert,-tbm,-pconfig,-amx-complex,+ssse3,+cx16,+bmi2,+fma,+popcnt,-avxifma,+f16c,-avx512bitalg,-rdpru,+clwb,+mmx,+sse2,+rdseed,-avx512vbmi2,-prefetchi,-rdpid,-fma4,-avx512vbmi,-shstk,-vaes,-waitpkg,-sgx,+fxsr,+avx512dq,-sse4a -mcpu=skylake-avx512 /tmp/minimized_crash.ll\r\n```",
"author": "cheshire",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
142957
|
https://github.com/llvm/llvm-project/issues/142957
|
miscompilation
|
5835f1e0a33afcae46a6ca4854373785eb3e7fd6
| 2025-06-05T12:36:31 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "fd97dfbb78e3c9aea16873617b6d61b5b8a64474",
"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": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": [
[
1491,
1500
]
],
"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": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": [
"LoopVectorizationLegality::canVectorizeWithIfConvert"
],
"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 fd97dfbb78e3c9aea16873617b6d61b5b8a64474
Author: Florian Hahn <flo@fhahn.com>
Date: Fri Jun 20 13:05:19 2025 +0100
[LV] Don't mark ptrs as safe to speculate if fed by UB/poison op. (#143204)
Add additional checks before marking pointers safe to load
speculatively. If some computations feeding the pointer may trigger UB,
we cannot load the pointer speculatively, because we cannot compute the
address speculatively. The UB triggering instructions will be
predicated, but if the predicated block does not execute the result is
poison.
Similarly, we also cannot load the pointer speculatively if it may be
poison. The patch also checks if any of the operands defined outside the
loop may be poison when entering the loop. We *don't* need to check if
any operation inside the loop may produce poison due to flags, as those
will be dropped if needed.
There are some types of instructions inside the loop that can produce
poison independent of flags. Currently loads are also checked, not sure
if there's a convenient API to check for all such operands.
Fixes https://github.com/llvm/llvm-project/issues/142957.
PR: https://github.com/llvm/llvm-project/pull/143204
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
index 0c4e5bb3d472..969d225c6ef2 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
@@ -1491,10 +1491,51 @@ bool LoopVectorizationLegality::canVectorizeWithIfConvert() {
SmallVector<const SCEVPredicate *, 4> Predicates;
for (Instruction &I : *BB) {
LoadInst *LI = dyn_cast<LoadInst>(&I);
+
+ // Make sure we can execute all computations feeding into Ptr in the loop
+ // w/o triggering UB and that none of the out-of-loop operands are poison.
+ // We do not need to check if operations inside the loop can produce
+ // poison due to flags (e.g. due to an inbounds GEP going out of bounds),
+ // because flags will be dropped when executing them unconditionally.
+ // TODO: Results could be improved by considering poison-propagation
+ // properties of visited ops.
+ auto CanSpeculatePointerOp = [this](Value *Ptr) {
+ SmallVector<Value *> Worklist = {Ptr};
+ SmallPtrSet<Value *, 4> Visited;
+ while (!Worklist.empty()) {
+ Value *CurrV = Worklist.pop_back_val();
+ if (!Visited.insert(CurrV).second)
+ continue;
+
+ auto *CurrI = dyn_cast<Instruction>(CurrV);
+ if (!CurrI || !TheLoop->contains(CurrI)) {
+ // If operands from outside the loop may be poison then Ptr may also
+ // be poison.
+ if (!isGuaranteedNotToBePoison(CurrV, AC,
+ TheLoop->getLoopPredecessor()
+ ->getTerminator()
+ ->getIterator()))
+ return false;
+ continue;
+ }
+
+ // A loaded value may be poison, independent of any flags.
+ if (isa<LoadInst>(CurrI) && !isGuaranteedNotToBePoison(CurrV, AC))
+ return false;
+
+ // For other ops, assume poison can only be introduced via flags,
+ // which can be dropped.
+ if (!isa<PHINode>(CurrI) && !isSafeToSpeculativelyExecute(CurrI))
+ return false;
+ append_range(Worklist, CurrI->operands());
+ }
+ return true;
+ };
// Pass the Predicates pointer to isDereferenceableAndAlignedInLoop so
// that it will consider loops that need guarding by SCEV checks. The
// vectoriser will generate these checks if we decide to vectorise.
if (LI && !LI->getType()->isVectorTy() && !mustSuppressSpeculation(*LI) &&
+ CanSpeculatePointerOp(LI->getPointerOperand()) &&
isDereferenceableAndAlignedInLoop(LI, TheLoop, SE, *DT, AC,
&Predicates))
SafePointers.insert(LI->getPointerOperand());
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/load-deref-pred-poison-ub-ops-feeding-pointer.ll",
"commands": [
"opt -p loop-vectorize -force-widen-divrem-via-safe-divisor=false -force-vector-width=2 -S %s"
],
"tests": [
{
"test_name": "ptr_depends_on_sdiv",
"test_body": "target datalayout = \"p:16:16\"\n\n@src = external global [16 x i64]\n\ndefine void @ptr_depends_on_sdiv(ptr noalias %dst, i16 noundef %off) {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i16 [ 9, %entry ], [ %iv.next, %loop.latch ]\n %cmp1 = icmp eq i16 %iv, 10\n br i1 %cmp1, label %if.then, label %loop.latch\n\nif.then: ; preds = %loop.header\n %div = sdiv i16 24316, %off\n %add.iv = add i16 %iv, 16383\n %s = shl i16 %div, 14\n %sub6 = sub i16 %add.iv, %s\n %gep.src = getelementptr inbounds i64, ptr @src, i16 %sub6\n %l = load i64, ptr %gep.src, align 1\n %gep.dst = getelementptr inbounds i64, ptr %dst, i16 %iv\n store i64 %l, ptr %gep.dst, align 1\n br label %loop.latch\n\nloop.latch: ; preds = %if.then, %loop.header\n %iv.next = add i16 %iv, 1\n %ec = icmp eq i16 %iv.next, 11\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": "-src-unroll=16 -tgt-unroll=16"
}
]
}
] |
{
"title": "loop-vectorize miscompile",
"body": "llvm commit: 6955a7d134e7\nReproduce with:\n```\nopt -passes=\"loop-vectorize\" bbi-107525_lv.ll -S -o - -mtriple=aarch64-none-linux-gnu --data-layout=\"p:16:16\"\n```\nThe loop-vectorize output contains\n```\npred.sdiv.continue: ; preds = %pred.sdiv.if, %vector.body\n %3 = phi i16 [ poison, %vector.body ], [ %2, %pred.sdiv.if ]\n [...]\n\npred.sdiv.continue2: ; preds = %pred.sdiv.if1, %pred.sdiv.continue\n [...]\n %7 = shl i16 %3, 14\n %8 = sub i16 %6, %7\n %9 = getelementptr [16 x i64], ptr @g_855, i16 0, i16 %8\n %10 = getelementptr i64, ptr %9, i32 0\n %wide.load = load <2 x i64>, ptr %10, align 1\n```\n\nand the problem here is that we will get to the %3 phi from %vector.body and then continue to pred.sdiv.continue2 where the %3 poison value will make %7, %8, %9 and %10 poison, and then we will do a load from %10 which is instant UB.\n\nThe input program has no UB.\n\nBefore 0d61ffd350\n```\n[Loads] Support SCEVAddExpr as start for pointer AddRec.\n```\nthe result is ok. Then with 0d61ffd350 it crashes with\n```\nopt: ../include/llvm/Support/Casting.h:109: static bool llvm::isa_impl_cl<llvm::Instruction, const llvm::Value *>::doit(const From *) [To = llvm::Instruction, From = const llvm::Value *]: Assertion `Val && \"isa<> used on a null pointer\"' failed.\n```\nand that crash goes away with fd82b5b287\n```\n[LV] Support recieps without underlying instr in collectPoisonGenRec.\n\nSupport recipes without underlying instruction in\ncollectPoisonGeneratingRecipes by directly trying to dyn_cast_or_null\nthe underlying value.\n\nFixes https://github.com/llvm/llvm-project/issues/70590.\n```\nbut then we get the miscompile instead.\n\nI also tested to cherry-pick the fd82b5b287 to directly after 0d61ffd350 and we get the miscompile then too, so it doesn't seem to be some other patch between them that causes the miscompile.\n\n[bbi-107525_lv.ll.gz](https://github.com/user-attachments/files/20610502/bbi-107525_lv.ll.gz)",
"author": "mikaelholmen",
"labels": [
"miscompilation",
"vectorizers"
],
"comments": [
{
"author": "fhahn",
"body": "Put up a potential fix: https://github.com/llvm/llvm-project/pull/143204"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
106655
|
https://github.com/llvm/llvm-project/issues/106655
|
crash
|
2d5613afec0f4afeeb03cfd4edac556a65ad0eaf
| 2024-08-30T03:04:59 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "87a988e881ac92e3d87aae01dc632f33c1fb36aa",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
13137,
13143
],
[
13197,
13203
],
[
13249,
13255
],
[
13259,
13265
],
[
13474,
13480
],
[
13518,
13524
],
[
13571,
13577
],
[
13593,
13599
],
[
13611,
13617
],
[
13655,
13661
],
[
13688,
13694
],
[
13780,
13786
],
[
13794,
13800
],
[
13859,
13865
],
[
13941,
13947
],
[
14039,
14044
]
],
"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 87a988e881ac92e3d87aae01dc632f33c1fb36aa
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Fri Aug 30 05:16:57 2024 -0700
[SLP]Fix PR106655: Use FinalShuffle for alternate cast nodes.
Need to use FinalShuffle function for all vectorized results to
correctly produce vectorized value.
Fixes https://github.com/llvm/llvm-project/issues/106655
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index edb2567fa057..345b01b82c6a 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -13137,7 +13137,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
}
bool IsReverseOrder = isReverseOrder(E->ReorderIndices);
- auto FinalShuffle = [&](Value *V, const TreeEntry *E, VectorType *VecTy) {
+ auto FinalShuffle = [&](Value *V, const TreeEntry *E) {
ShuffleInstructionBuilder ShuffleBuilder(ScalarTy, Builder, *this);
if (E->getOpcode() == Instruction::Store &&
E->State == TreeEntry::Vectorize) {
@@ -13197,7 +13197,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
PH->getParent()->getFirstInsertionPt());
Builder.SetCurrentDebugLocation(PH->getDebugLoc());
- V = FinalShuffle(V, E, VecTy);
+ V = FinalShuffle(V, E);
E->VectorizedValue = V;
if (PostponedPHIs)
@@ -13249,7 +13249,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
if (const TreeEntry *TE = getTreeEntry(V))
V = TE->VectorizedValue;
setInsertPointAfterBundle(E);
- V = FinalShuffle(V, E, VecTy);
+ V = FinalShuffle(V, E);
E->VectorizedValue = V;
return V;
}
@@ -13259,7 +13259,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
Value *Ptr = LI->getPointerOperand();
LoadInst *V = Builder.CreateAlignedLoad(VecTy, Ptr, LI->getAlign());
Value *NewV = propagateMetadata(V, E->Scalars);
- NewV = FinalShuffle(NewV, E, VecTy);
+ NewV = FinalShuffle(NewV, E);
E->VectorizedValue = NewV;
return NewV;
}
@@ -13474,7 +13474,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
Value *V = (VecOpcode != ShuffleOrOp && VecOpcode == Instruction::BitCast)
? InVec
: Builder.CreateCast(VecOpcode, InVec, VecTy);
- V = FinalShuffle(V, E, VecTy);
+ V = FinalShuffle(V, E);
E->VectorizedValue = V;
++NumVectorInstructions;
@@ -13518,7 +13518,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
propagateIRFlags(V, E->Scalars, VL0);
// Do not cast for cmps.
VecTy = cast<FixedVectorType>(V->getType());
- V = FinalShuffle(V, E, VecTy);
+ V = FinalShuffle(V, E);
E->VectorizedValue = V;
++NumVectorInstructions;
@@ -13571,7 +13571,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
assert(getNumElements(Cond->getType()) == TrueNumElements &&
"Cannot vectorize Instruction::Select");
Value *V = Builder.CreateSelect(Cond, True, False);
- V = FinalShuffle(V, E, VecTy);
+ V = FinalShuffle(V, E);
E->VectorizedValue = V;
++NumVectorInstructions;
@@ -13593,7 +13593,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
if (auto *I = dyn_cast<Instruction>(V))
V = propagateMetadata(I, E->Scalars);
- V = FinalShuffle(V, E, VecTy);
+ V = FinalShuffle(V, E);
E->VectorizedValue = V;
++NumVectorInstructions;
@@ -13611,7 +13611,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
}
Value *V = Builder.CreateFreeze(Op);
- V = FinalShuffle(V, E, VecTy);
+ V = FinalShuffle(V, E);
E->VectorizedValue = V;
++NumVectorInstructions;
@@ -13655,7 +13655,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
auto *CI = dyn_cast<ConstantInt>(Op);
return CI && CI->getValue().countr_one() >= It->second.first;
})) {
- V = FinalShuffle(I == 0 ? RHS : LHS, E, VecTy);
+ V = FinalShuffle(I == 0 ? RHS : LHS, E);
E->VectorizedValue = V;
++NumVectorInstructions;
return V;
@@ -13688,7 +13688,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
I->setHasNoUnsignedWrap(/*b=*/false);
}
- V = FinalShuffle(V, E, VecTy);
+ V = FinalShuffle(V, E);
E->VectorizedValue = V;
++NumVectorInstructions;
@@ -13780,7 +13780,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
}
Value *V = propagateMetadata(NewLI, E->Scalars);
- V = FinalShuffle(V, E, VecTy);
+ V = FinalShuffle(V, E);
E->VectorizedValue = V;
++NumVectorInstructions;
return V;
@@ -13794,7 +13794,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
if (VecValue->getType() != VecTy)
VecValue =
Builder.CreateIntCast(VecValue, VecTy, GetOperandSignedness(0));
- VecValue = FinalShuffle(VecValue, E, VecTy);
+ VecValue = FinalShuffle(VecValue, E);
Value *Ptr = SI->getPointerOperand();
Instruction *ST;
@@ -13859,7 +13859,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
V = propagateMetadata(I, GEPs);
}
- V = FinalShuffle(V, E, VecTy);
+ V = FinalShuffle(V, E);
E->VectorizedValue = V;
++NumVectorInstructions;
@@ -13941,7 +13941,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
Value *V = Builder.CreateCall(CF, OpVecs, OpBundles);
propagateIRFlags(V, E->Scalars, VL0);
- V = FinalShuffle(V, E, VecTy);
+ V = FinalShuffle(V, E);
E->VectorizedValue = V;
++NumVectorInstructions;
@@ -14039,6 +14039,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
"Expected same type as operand.");
if (auto *I = dyn_cast<Instruction>(LHS))
LHS = propagateMetadata(I, E->Scalars);
+ LHS = FinalShuffle(LHS, E);
E->VectorizedValue = LHS;
++NumVectorInstructions;
return LHS;
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/resized-alt-shuffle-after-minbw.ll",
"commands": [
"opt -S --passes=slp-vectorizer -slp-vectorize-hor=false < %s"
],
"tests": [
{
"test_name": "func",
"test_body": "define void @func(i32 %0) {\n %2 = shl i32 %0, 0\n %3 = sext i32 %2 to i64\n %4 = shl i32 0, 0\n %5 = sext i32 %4 to i64\n %6 = or i32 0, 0\n %7 = or i32 0, 0\n %8 = zext i32 %6 to i64\n %9 = zext i32 %7 to i64\n %10 = zext i32 0 to i64\n %11 = zext i32 0 to i64\n %12 = zext i32 0 to i64\n %13 = zext i32 0 to i64\n %14 = zext i32 0 to i64\n %15 = zext i32 0 to i64\n %16 = zext i32 0 to i64\n %17 = zext i32 0 to i64\n %18 = zext i32 0 to i64\n %19 = zext i32 0 to i64\n %20 = zext i32 0 to i64\n %21 = zext i32 0 to i64\n %22 = zext i32 0 to i64\n %23 = zext i32 0 to i64\n %24 = zext i32 0 to i64\n %25 = zext i32 0 to i64\n %26 = zext i32 0 to i64\n %27 = or i64 %3, 0\n %28 = or i64 %3, %8\n %29 = or i64 %3, %9\n %30 = or i64 %3, %10\n %31 = or i64 %3, %11\n %32 = or i64 %3, %12\n %33 = or i64 %3, %13\n %34 = or i64 %3, %14\n %35 = or i64 %3, %15\n %36 = or i64 %3, %16\n %37 = or i64 %3, %17\n %38 = or i64 %3, %18\n %39 = or i64 %3, %19\n %40 = or i64 %3, %20\n %41 = or i64 %3, %21\n %42 = or i64 %3, %22\n %43 = or i64 %3, %23\n %44 = or i64 %3, %24\n %45 = or i64 %3, %25\n %46 = or i64 %3, 0\n %47 = or i64 %3, 0\n %48 = or i64 %3, 0\n %49 = or i64 %3, 0\n %50 = or i64 %3, 0\n %51 = or i64 %3, 0\n %52 = or i64 %3, 0\n %53 = or i64 %3, 0\n %54 = or i64 %3, 0\n %55 = or i64 %3, 0\n %56 = or i64 %3, 0\n %57 = or i64 %3, 0\n %58 = or i64 %3, 0\n %59 = icmp slt i64 %28, 0\n %60 = icmp slt i64 %29, 0\n %61 = icmp slt i64 %30, 0\n %62 = icmp slt i64 %31, 0\n %63 = icmp slt i64 %32, 0\n %64 = icmp slt i64 %33, 0\n %65 = icmp slt i64 %34, 0\n %66 = icmp slt i64 %35, 0\n %67 = icmp slt i64 %36, 0\n %68 = icmp slt i64 %37, 0\n %69 = icmp slt i64 %38, 0\n %70 = icmp slt i64 %39, 0\n %71 = icmp slt i64 %40, 0\n %72 = icmp slt i64 %41, 0\n %73 = icmp slt i64 %42, 0\n %74 = icmp slt i64 %43, 0\n %75 = icmp slt i64 %44, 0\n %76 = icmp slt i64 %45, 0\n %77 = icmp slt i64 %46, 0\n %78 = icmp slt i64 %47, 0\n %79 = icmp slt i64 %48, 0\n %80 = icmp slt i64 %49, 0\n %81 = icmp slt i64 %50, 0\n %82 = icmp slt i64 %51, 0\n %83 = icmp slt i64 %52, 0\n %84 = icmp slt i64 %53, 0\n %85 = icmp slt i64 %54, 0\n %86 = icmp slt i64 %55, 0\n %87 = icmp slt i64 %56, 0\n %88 = icmp slt i64 %57, 0\n %89 = icmp slt i64 %58, 0\n %90 = and i1 false, %59\n %91 = and i1 false, %60\n %92 = and i1 false, %61\n %93 = and i1 false, %62\n %94 = and i1 false, %63\n %95 = and i1 false, %64\n %96 = and i1 false, %65\n %97 = and i1 false, %66\n %98 = and i1 false, %67\n %99 = and i1 false, %68\n %100 = and i1 false, %69\n %101 = and i1 false, %70\n %102 = and i1 false, %71\n %103 = and i1 false, %72\n %104 = and i1 false, %73\n %105 = and i1 false, %74\n %106 = and i1 false, %75\n %107 = and i1 false, %76\n %108 = icmp eq i32 %2, 0\n %109 = and i1 false, %77\n %110 = and i1 false, %78\n %111 = and i1 false, %79\n %112 = and i1 false, %80\n %113 = and i1 false, %81\n %114 = and i1 false, %82\n %115 = and i1 false, %83\n %116 = and i1 false, %84\n %117 = and i1 false, %85\n %118 = and i1 false, %86\n %119 = or i64 %5, %26\n %120 = getelementptr float, ptr addrspace(1) null, i64 %119\n %121 = icmp slt i64 %119, 0\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SLP] Assertion `I >= 0 && I < (NumOpElts * 2) && \"Out-of-bounds shuffle mask element\"' failed.",
"body": "Live link: https://godbolt.org/z/nePMscjGr\r\n\r\nTest case:\r\n\r\n```ll\r\ndefine void @func(i32 %0) {\r\n %2 = shl i32 %0, 0\r\n %3 = sext i32 %2 to i64\r\n %4 = shl i32 0, 0\r\n %5 = sext i32 %4 to i64\r\n %6 = or i32 0, 0\r\n %7 = or i32 0, 0\r\n %8 = zext i32 %6 to i64\r\n %9 = zext i32 %7 to i64\r\n %10 = zext i32 0 to i64\r\n %11 = zext i32 0 to i64\r\n %12 = zext i32 0 to i64\r\n %13 = zext i32 0 to i64\r\n %14 = zext i32 0 to i64\r\n %15 = zext i32 0 to i64\r\n %16 = zext i32 0 to i64\r\n %17 = zext i32 0 to i64\r\n %18 = zext i32 0 to i64\r\n %19 = zext i32 0 to i64\r\n %20 = zext i32 0 to i64\r\n %21 = zext i32 0 to i64\r\n %22 = zext i32 0 to i64\r\n %23 = zext i32 0 to i64\r\n %24 = zext i32 0 to i64\r\n %25 = zext i32 0 to i64\r\n %26 = zext i32 0 to i64\r\n %27 = or i64 %3, 0\r\n %28 = or i64 %3, %8\r\n %29 = or i64 %3, %9\r\n %30 = or i64 %3, %10\r\n %31 = or i64 %3, %11\r\n %32 = or i64 %3, %12\r\n %33 = or i64 %3, %13\r\n %34 = or i64 %3, %14\r\n %35 = or i64 %3, %15\r\n %36 = or i64 %3, %16\r\n %37 = or i64 %3, %17\r\n %38 = or i64 %3, %18\r\n %39 = or i64 %3, %19\r\n %40 = or i64 %3, %20\r\n %41 = or i64 %3, %21\r\n %42 = or i64 %3, %22\r\n %43 = or i64 %3, %23\r\n %44 = or i64 %3, %24\r\n %45 = or i64 %3, %25\r\n %46 = or i64 %3, 0\r\n %47 = or i64 %3, 0\r\n %48 = or i64 %3, 0\r\n %49 = or i64 %3, 0\r\n %50 = or i64 %3, 0\r\n %51 = or i64 %3, 0\r\n %52 = or i64 %3, 0\r\n %53 = or i64 %3, 0\r\n %54 = or i64 %3, 0\r\n %55 = or i64 %3, 0\r\n %56 = or i64 %3, 0\r\n %57 = or i64 %3, 0\r\n %58 = or i64 %3, 0\r\n %59 = icmp slt i64 %28, 0\r\n %60 = icmp slt i64 %29, 0\r\n %61 = icmp slt i64 %30, 0\r\n %62 = icmp slt i64 %31, 0\r\n %63 = icmp slt i64 %32, 0\r\n %64 = icmp slt i64 %33, 0\r\n %65 = icmp slt i64 %34, 0\r\n %66 = icmp slt i64 %35, 0\r\n %67 = icmp slt i64 %36, 0\r\n %68 = icmp slt i64 %37, 0\r\n %69 = icmp slt i64 %38, 0\r\n %70 = icmp slt i64 %39, 0\r\n %71 = icmp slt i64 %40, 0\r\n %72 = icmp slt i64 %41, 0\r\n %73 = icmp slt i64 %42, 0\r\n %74 = icmp slt i64 %43, 0\r\n %75 = icmp slt i64 %44, 0\r\n %76 = icmp slt i64 %45, 0\r\n %77 = icmp slt i64 %46, 0\r\n %78 = icmp slt i64 %47, 0\r\n %79 = icmp slt i64 %48, 0\r\n %80 = icmp slt i64 %49, 0\r\n %81 = icmp slt i64 %50, 0\r\n %82 = icmp slt i64 %51, 0\r\n %83 = icmp slt i64 %52, 0\r\n %84 = icmp slt i64 %53, 0\r\n %85 = icmp slt i64 %54, 0\r\n %86 = icmp slt i64 %55, 0\r\n %87 = icmp slt i64 %56, 0\r\n %88 = icmp slt i64 %57, 0\r\n %89 = icmp slt i64 %58, 0\r\n %90 = and i1 false, %59\r\n %91 = and i1 false, %60\r\n %92 = and i1 false, %61\r\n %93 = and i1 false, %62\r\n %94 = and i1 false, %63\r\n %95 = and i1 false, %64\r\n %96 = and i1 false, %65\r\n %97 = and i1 false, %66\r\n %98 = and i1 false, %67\r\n %99 = and i1 false, %68\r\n %100 = and i1 false, %69\r\n %101 = and i1 false, %70\r\n %102 = and i1 false, %71\r\n %103 = and i1 false, %72\r\n %104 = and i1 false, %73\r\n %105 = and i1 false, %74\r\n %106 = and i1 false, %75\r\n %107 = and i1 false, %76\r\n %108 = icmp eq i32 %2, 0\r\n %109 = and i1 false, %77\r\n %110 = and i1 false, %78\r\n %111 = and i1 false, %79\r\n %112 = and i1 false, %80\r\n %113 = and i1 false, %81\r\n %114 = and i1 false, %82\r\n %115 = and i1 false, %83\r\n %116 = and i1 false, %84\r\n %117 = and i1 false, %85\r\n %118 = and i1 false, %86\r\n %119 = or i64 %5, %26\r\n %120 = getelementptr float, ptr addrspace(1) null, i64 %119\r\n %121 = icmp slt i64 %119, 0\r\n ret void\r\n}\r\n```\r\n\r\nRunning via `opt --passes=slp-vectorizer -slp-vectorize-hor=false`:\r\n\r\n```sh\r\nopt: /root/llvm-project/llvm/lib/IR/Instructions.cpp:1853: bool isSingleSourceMaskImpl(llvm::ArrayRef<int>, int): Assertion `I >= 0 && I < (NumOpElts * 2) && \"Out-of-bounds shuffle mask element\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S --passes=slp-vectorizer -slp-vectorize-hor=false <source>\r\n1.\tRunning pass \"function(slp-vectorizer)\" on module \"<source>\"\r\n2.\tRunning pass \"slp-vectorizer\" on function \"func\"\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 0x000073f701e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x000073f701e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x000073f701e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x000073f701e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x000073f701e2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x000073f701e39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x0000000004d097f6 isSingleSourceMaskImpl(llvm::ArrayRef<int>, int) Instructions.cpp:0:0\r\n #9 0x0000000004d1097a llvm::ShuffleVectorInst::isExtractSubvectorMask(llvm::ArrayRef<int>, int, int&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d1097a)\r\n#10 0x000000000400fc53 (anonymous namespace)::BaseShuffleAnalysis::isIdentityMask(llvm::ArrayRef<int>, llvm::FixedVectorType const*, bool) SLPVectorizer.cpp:0:0\r\n#11 0x0000000004043781 (anonymous namespace)::BaseShuffleAnalysis::peekThroughShuffles(llvm::Value*&, llvm::SmallVectorImpl<int>&, bool) SLPVectorizer.cpp:0:0\r\n#12 0x000000000405bd21 llvm::Value* (anonymous namespace)::BaseShuffleAnalysis::createShuffle<llvm::Value*, llvm::slpvectorizer::BoUpSLP::ShuffleInstructionBuilder::ShuffleIRBuilder>(llvm::Value*, llvm::Value*, llvm::ArrayRef<int>, llvm::slpvectorizer::BoUpSLP::ShuffleInstructionBuilder::ShuffleIRBuilder&) SLPVectorizer.cpp:0:0\r\n#13 0x000000000405c50a llvm::slpvectorizer::BoUpSLP::ShuffleInstructionBuilder::createShuffle(llvm::Value*, llvm::Value*, llvm::ArrayRef<int>) (.isra.0) SLPVectorizer.cpp:0:0\r\n#14 0x000000000405ce73 llvm::slpvectorizer::BoUpSLP::ShuffleInstructionBuilder::finalize(llvm::ArrayRef<int>, llvm::ArrayRef<std::pair<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, unsigned int>>, unsigned int, llvm::function_ref<void (llvm::Value*&, llvm::SmallVectorImpl<int>&)>) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x405ce73)\r\n#15 0x000000000405d3d9 llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool)::'lambda1'(llvm::Value*, llvm::ArrayRef<int>)::operator()(llvm::Value*, llvm::ArrayRef<int>) const SLPVectorizer.cpp:0:0\r\n#16 0x0000000004095c0a llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4095c0a)\r\n#17 0x0000000004097032 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4097032)\r\n#18 0x0000000004095aa8 llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4095aa8)\r\n#19 0x0000000004097294 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4097294)\r\n#20 0x00000000040b31cc llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::MapVector<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>, llvm::DenseMap<llvm::Value*, unsigned int, llvm::DenseMapInfo<llvm::Value*, void>, llvm::detail::DenseMapPair<llvm::Value*, unsigned int>>, llvm::SmallVector<std::pair<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>>, 0u>> const&, llvm::SmallVectorImpl<std::pair<llvm::Value*, llvm::Value*>>&, llvm::Instruction*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40b31cc)\r\n#21 0x00000000040b6d45 llvm::slpvectorizer::BoUpSLP::vectorizeTree() (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40b6d45)\r\n#22 0x00000000040c3b2a llvm::SLPVectorizerPass::tryToVectorizeList(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40c3b2a)\r\n#23 0x00000000040c78a7 bool llvm::SLPVectorizerPass::vectorizeCmpInsts<std::reverse_iterator<llvm::CmpInst* const*>>(llvm::iterator_range<std::reverse_iterator<llvm::CmpInst* const*>>, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40c78a7)\r\n#24 0x00000000040cb5d0 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40cb5d0)\r\n#25 0x00000000040d1d49 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\r\n#26 0x00000000040d29fb llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40d29fb)\r\n...\r\n```\r\n\r\nBisected to f3d2609af3031ddb54030548e86335f295cf49ca / https://github.com/llvm/llvm-project/pull/104144",
"author": "rupprecht",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid"
],
"comments": [
{
"author": "dklimkin",
"body": "Confirmed this resolved the issue. Thanks!"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
87407
|
https://github.com/llvm/llvm-project/issues/87407
|
crash
|
980d027a3f2fbce173ad813a3f01bb51c2c2bc4b
| 2024-04-02T20:25:12 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "49842426f3fc70af756f9e6fe80ecf829178a1b2",
"components": [
"LoopVectorize",
"VectorUtils"
],
"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": [
[
1639,
1645
],
[
1712,
1718
]
],
"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": [
[
827,
832
],
[
882,
888
]
],
"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": [
"llvm::computeMinimumValueSizes"
],
"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 49842426f3fc70af756f9e6fe80ecf829178a1b2
Author: Ramkumar Ramachandra <ramkumar.ramachandra@codasip.com>
Date: Tue Apr 29 09:47:38 2025 +0100
[LV] Fix MinBWs in WidenIntrinsic case (#137005)
There is a bug in the computation and handling of MinBWs in the case of
VPWidenIntrinsicRecipe: a crash is observed in
VPlanTransforms::truncateToMinimalBitwidths due to a mismatch between
the number of recipes processed and the number of entries in MinBWs. Fix
handling of calls in llvm::computeMinimumValueSizes, and handle
VPWidenIntrinsicRecipe in truncateToMinimalBitwidths, fixing the bug.
Fixes #87407.
diff --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp
index 6448c372f5d5..4d394ea4d99c 100644
--- a/llvm/lib/Analysis/VectorUtils.cpp
+++ b/llvm/lib/Analysis/VectorUtils.cpp
@@ -827,6 +827,11 @@ llvm::computeMinimumValueSizes(ArrayRef<BasicBlock *> Blocks, DemandedBits &DB,
if (isa<PHINode>(I))
continue;
+ // Don't modify the types of operands of a call, as doing that would cause a
+ // signature mismatch.
+ if (isa<CallBase>(I))
+ continue;
+
if (DBits[Leader] == ~0ULL)
// All bits demanded, no point continuing.
continue;
@@ -882,7 +887,9 @@ llvm::computeMinimumValueSizes(ArrayRef<BasicBlock *> Blocks, DemandedBits &DB,
// If any of M's operands demand more bits than MinBW then M cannot be
// performed safely in MinBW.
- if (any_of(MI->operands(), [&DB, MinBW](Use &U) {
+ auto *Call = dyn_cast<CallBase>(MI);
+ auto Ops = Call ? Call->args() : MI->operands();
+ if (any_of(Ops, [&DB, MinBW](Use &U) {
auto *CI = dyn_cast<ConstantInt>(U);
// For constants shift amounts, check if the shift would result in
// poison.
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 8e43d856c277..7093d378d8c3 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -1639,7 +1639,8 @@ void VPlanTransforms::truncateToMinimalBitwidths(
vp_depth_first_deep(Plan.getVectorLoopRegion()))) {
for (VPRecipeBase &R : make_early_inc_range(*VPBB)) {
if (!isa<VPWidenRecipe, VPWidenCastRecipe, VPReplicateRecipe,
- VPWidenSelectRecipe, VPWidenLoadRecipe>(&R))
+ VPWidenSelectRecipe, VPWidenLoadRecipe, VPWidenIntrinsicRecipe>(
+ &R))
continue;
VPValue *ResultVPV = R.getVPSingleValue();
@@ -1712,7 +1713,7 @@ void VPlanTransforms::truncateToMinimalBitwidths(
}
assert(!isa<VPWidenStoreRecipe>(&R) && "stores cannot be narrowed");
- if (isa<VPWidenLoadRecipe>(&R))
+ if (isa<VPWidenLoadRecipe, VPWidenIntrinsicRecipe>(&R))
continue;
// Shrink operands by introducing truncates as needed.
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/pr87407-trunc-with-intrinsic.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-width=4 -S %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine i8 @pr87407(i8 %x, i64 %y, i64 %n) {\n;\nentry:\n %zext.x = zext i8 %x to i64\n br label %loop\n\nloop:\n %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]\n %max = tail call i64 @llvm.umax.i64(i64 %zext.x, i64 %y)\n %cmp.max.0 = icmp ne i64 %max, 0\n %zext.cmp = zext i1 %cmp.max.0 to i64\n %trunc = trunc i64 %zext.cmp to i32\n %shl = shl i32 %trunc, 8\n %res = trunc i32 %shl to i8\n %iv.next = add i64 %iv, 1\n %exit.cond = icmp ne i64 %iv.next, %n\n br i1 %exit.cond, label %loop, label %exit\n\nexit:\n ret i8 %res\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[LoopVectorize][VPlan] Assertion `MinBWs.size() == NumProcessedRecipes && \"some entries in MinBWs haven't been processed\"' failed.",
"body": "Reduced LLVM IR:\r\n``` llvm ir\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine i32 @main() #0 {\r\nentry:\r\n %conv21.us.i = sext i16 0 to i32\r\n br label %for.cond3.preheader.us.i\r\n\r\nfor.cond3.preheader.us.i: ; preds = %for.cond3.preheader.us.i, %entry\r\n %indvars.iv.i = phi i64 [ %indvars.iv.next.i, %for.cond3.preheader.us.i ], [ 0, %entry ]\r\n %add67.lcssa7984.us.i = phi i8 [ %2, %for.cond3.preheader.us.i ], [ 0, %entry ]\r\n %.conv21.us99.i = tail call i32 @llvm.smax.i32(i32 0, i32 %conv21.us.i)\r\n %cmp35.us100.i = icmp eq i32 %.conv21.us99.i, 0\r\n %conv36.us101.i = zext i1 %cmp35.us100.i to i32\r\n %0 = lshr i32 %conv36.us101.i, 1\r\n %1 = trunc i32 %0 to i8\r\n %2 = or i8 %add67.lcssa7984.us.i, %1\r\n %indvars.iv.next.i = add i64 %indvars.iv.i, 1\r\n %cmp.us.i = icmp slt i64 %indvars.iv.i, 1\r\n br i1 %cmp.us.i, label %for.cond3.preheader.us.i, label %for.cond.for.cond.cleanup_crit_edge.split.us.i\r\n\r\nfor.cond.for.cond.cleanup_crit_edge.split.us.i: ; preds = %for.cond3.preheader.us.i\r\n store i8 %2, ptr null, align 1\r\n ret i32 0\r\n}\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\r\ndeclare i32 @llvm.smax.i32(i32, i32) #1\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\r\nattributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\r\n```\r\n\r\nBacktrace:\r\n```\r\nopt: /scratch/tc-testing/tc-apr-2/llvm/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp:1061: static void llvm::VPlanTransforms::truncateToMinimalBitwidths(llvm::VPlan&, const llvm::MapVector<llvm::Instruction*, long unsigned int>&, llvm\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 0x0000596ae80c5b60 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2d84b60)\r\n #1 0x0000596ae80c2f6f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2d81f6f)\r\n #2 0x0000596ae80c30c5 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007a0a45642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007a0a456969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007a0a456969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007a0a456969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x00007a0a45642476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007a0a456287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x00007a0a4562871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x00007a0a45639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x0000596ae7260af2 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&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1f1faf2)\r\n#12 0x0000596ae7135f3e llvm::LoopVectorizationPlanner::buildVPlansWithVPRecipes(llvm::ElementCount, llvm::ElementCount) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1df4f3e)\r\n#13 0x0000596ae713c319 llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1dfb319)\r\n#14 0x0000596ae713f8a9 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1dfe8a9)\r\n#15 0x0000596ae714273e 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#16 0x0000596ae714388d 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#17 0x0000596ae604a276 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#18 0x0000596ae7eec141 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#19 0x0000596ae6041bd6 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#20 0x0000596ae7eeae3b 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#21 0x0000596ae6049dc6 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#22 0x0000596ae7ee8cb1 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#23 0x0000596ae58c3ce5 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#24 0x0000596ae58b6316 optMain (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x575316)\r\n#25 0x00007a0a45629d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#26 0x00007a0a45629e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#27 0x00007a0a45629e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#28 0x0000596ae58abf95 _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\n\r\nGodbolt: https://godbolt.org/z/6TxWGMz6e\r\n\r\nAssert: https://github.com/llvm/llvm-project/blob/c403a478076a16172d9b50e16c288b0d360f42ce/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp#L1061-L1063\r\n\r\nFound via fuzzer.",
"author": "patrick-rivos",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "patrick-rivos",
"body": "Partially cleaned up 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 %sext.0 = sext i16 0 to i32\r\n br label %loop.preheader\r\n\r\nloop.preheader: ; preds = %loop.preheader, %entry\r\n %iv.i = phi i64 [ %iv.next.i, %loop.preheader ], [ 0, %entry ]\r\n %phi.0 = phi i8 [ %or.0, %loop.preheader ], [ 0, %entry ]\r\n %max.0 = tail call i32 @llvm.smax.i32(i32 0, i32 %sext.0)\r\n %cmp = icmp eq i32 %max.0, 0\r\n %zext.true = zext i1 %cmp to i32\r\n %0 = lshr i32 %zext.true, 1\r\n %1 = trunc i32 %0 to i8\r\n %or.0 = or i8 %phi.0, %1\r\n %iv.next.i = add i64 %iv.i, 1\r\n %cmp.us.i = icmp slt i64 %iv.i, 1\r\n br i1 %cmp.us.i, label %loop.preheader, label %loop.exit\r\n\r\nloop.exit: ; preds = %loop.preheader\r\n store i8 %or.0, ptr null, align 1\r\n ret i32 0\r\n}\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\r\ndeclare i32 @llvm.smax.i32(i32, i32) #1\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\r\n```\r\n\r\nBasic analysis:\r\n\r\nThe issue is caused by:\r\nhttps://github.com/llvm/llvm-project/blob/39bfdb7f33f7f53ab662c5cea25129c45a9b4c11/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp#L1074-L1076\r\nwhen `%sext.0 = sext i16 0 to i32` is the only unaccounted for MinBWs entry.\r\n\r\n`Op->getLiveInIRValue()` returns a _Constant_ `i32 0`, so the dynamic cast to _Instruction_ returns a null pointer which does not exist in MinBWs.\r\n\r\nI think the _Constant_ is an optimized `sext i16 0 to i32` so I'll try to find where the constant comes from next."
},
{
"author": "patrick-rivos",
"body": "Alright I _think_ I understand everything that's going on here\r\n\r\nUsing this testcase:\r\n```llvm ir\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\n\r\ndefine i32 @main() #1 {\r\nentry:\r\n %zext.0 = zext i8 0 to i64\r\n br label %loop\r\n\r\nloop: ; preds = %loop, %entry\r\n %phi.0 = phi i64 [ %incrementor, %loop ], [ 0, %entry ]\r\n %incrementor = add i64 %phi.0, 1\r\n %max.0 = tail call i64 @llvm.umax.i64(i64 %zext.0, i64 0)\r\n %cmp.0 = icmp ne i64 %max.0, 0\r\n %zext.1 = zext i1 %cmp.0 to i64\r\n %trunc.0 = trunc i64 %zext.1 to i32\r\n %shl.0 = shl i32 %trunc.0, 8 ; Truncate and shift to make all bits dead\r\n %trunc.1 = trunc i32 %shl.0 to i8\r\n %exitcond6 = icmp ne i64 %phi.0, 16\r\n br i1 %exitcond6, label %loop, label %loop.exit\r\n\r\nloop.exit: ; preds = %loop\r\n store i8 %trunc.1, ptr null, align 1\r\n ret i32 0\r\n}\r\n\r\nattributes #1 = { \"target-features\"=\"+v\" }\r\n```\r\n\r\ncomputeMinimumValueSizes operates on a region, but a chain terminated with one instruction outside the bounds of the region is still considered valid. This compounded with weirdness with WIDEN-CALL causes issues in truncateToMinimalBitwidths where this range is considered:\r\n```\r\n<x1> vector loop: {\r\n vector.body:\r\n EMIT vp<%2> = CANONICAL-INDUCTION ir<0>, vp<%3>\r\n WIDEN-INDUCTION %phi.0 = phi %incrementor, 0, ir<1>\r\n CLONE ir<%incrementor> = add ir<%phi.0>, ir<1>\r\n WIDEN-CALL ir<%max.0> = call @llvm.umax.i64(ir<%zext.0>, ir<0>) (using vector intrinsic)\r\n WIDEN ir<%cmp.0> = icmp ne ir<%max.0>, ir<0>\r\n WIDEN-CAST ir<%zext.1> = zext ir<%cmp.0> to i64\r\n WIDEN-CAST ir<%trunc.0> = trunc ir<%zext.1> to i32\r\n WIDEN ir<%shl.0> = shl ir<%trunc.0>, ir<8>\r\n WIDEN-CAST ir<%trunc.1> = trunc ir<%shl.0> to i8\r\n CLONE ir<%exitcond6> = icmp ne ir<%phi.0>, ir<16>\r\n Successor(s):\r\n\r\n :\r\n Successor(s): vector.latch\r\n\r\n vector.latch:\r\n EMIT vp<%3> = add nuw vp<%2>, vp<%0>\r\n EMIT branch-on-count vp<%3>, vp<%1>\r\n No successors\r\n}\r\nSuccessor(s): middle.block\r\n```\r\n\r\nThe MinBWs are:\r\n```\r\n%cmp.0 = icmp ne i64 %max.0, 0 Size: 1\r\n%zext.0 = zext i8 0 to i64 Size: 1\r\n```\r\n\r\ncomp.0 is found easily but zext.0 isn't in the region. Normally chains outside the region are handled\r\nby [this](https://github.com/llvm/llvm-project/blob/eae7554d3f1fb1546c629a9a2ae0654b1001ab41/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp#L1056) which pulls in arguments.\r\n\r\nWe don't consider WIDEN-CALL since it doesn't have an [entry in MinBW](https://github.com/llvm/llvm-project/blob/eae7554d3f1fb1546c629a9a2ae0654b1001ab41/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp#L984-L986) (and isn't [allowed](https://github.com/llvm/llvm-project/blob/eae7554d3f1fb1546c629a9a2ae0654b1001ab41/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp#L978-L979)).\r\nIt doesn't have an entry since the function call uses a ptr which cannot be truncated so [that op fails to truncate](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Analysis/VectorUtils.cpp#L682-L693).\r\n\r\nDemandedBits understands a [subset of all intrinsics](https://github.com/llvm/llvm-project/blob/49bb993959668b3f319e9ea5fa0c97a41ab0890e/llvm/lib/Analysis/DemandedBits.cpp#L87-L149) while VPlanAnalysis doesn't handle any of them (for the pointer reason).\r\n\r\n## Fix\r\n\r\nThis can be fixed by ignoring the call function pointer argument for all intrinsic cases that DemandedBits handles.\r\n\r\nVPWidenCallRecipe also needs a way to specify a new return type when executed so I added getResultType and setResultType methods.\r\n\r\nI'll submit a PR soon.\r\n"
}
]
}
| true |
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
| null |
109376
|
https://github.com/llvm/llvm-project/issues/109376
|
crash
|
1c47fa9b620d0abb280647b4f361ada43784d00e
| 2024-09-20T05:30:57 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "3db0f8c895d4e814a18b754f9afbb1e03bd839a5",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
18668,
18673
]
],
"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": [
"tryToReduce"
],
"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 3db0f8c895d4e814a18b754f9afbb1e03bd839a5
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Mon Sep 23 10:49:54 2024 -0700
[SLP]Update TrackedToOrig mappings after reduction vectorization
Need to update mappings in TrackedToOrig to correctly provide mapping
between updated reduced value after vectorization and its original
value, otherwise the compiler might miss this update and it may cause
compiler crash later, when it tries to find the original instruction
mapping for the updated value.
Fixes https://github.com/llvm/llvm-project/issues/109376
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index a88702b81096..04b8fc09a724 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -18668,6 +18668,14 @@ public:
// Vectorize a tree.
Value *VectorizedRoot =
V.vectorizeTree(LocalExternallyUsedValues, InsertPt);
+ // Update TrackedToOrig mapping, since the tracked values might be
+ // updated.
+ for (Value *RdxVal : Candidates) {
+ Value *OrigVal = TrackedToOrig.at(RdxVal);
+ Value *TransformedRdxVal = TrackedVals.at(OrigVal);
+ if (TransformedRdxVal != RdxVal)
+ TrackedToOrig.try_emplace(TransformedRdxVal, OrigVal);
+ }
Builder.SetInsertPoint(InsertPt);
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/reduced-value-vectorized-later.ll",
"commands": [
"opt -S -passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define i16 @test() {\nentry:\n %subi = add i16 0, 0\n %sub40.i = add i16 %subi, 0\n %sub41.i = add i16 %subi, 0\n %sub42.i = add i16 %subi, 0\n %sub43.i = add i16 %subi, 0\n %sub44.i = add i16 %subi, 0\n %sub45.i = add i16 %subi, 0\n %sub46.i = add i16 0, 0\n %sub47.i = add i16 0, 0\n %sub48.i = add i16 0, 0\n %sub49.i = add i16 0, 0\n %or40.i = or i16 %sub40.i, %sub41.i\n %or41.i = or i16 %or40.i, %sub42.i\n %or42.i = or i16 %or41.i, %sub43.i\n %or43.i = or i16 %or42.i, %sub44.i\n %or44.i = or i16 %or43.i, %sub45.i\n %or45.i = or i16 %or44.i, %sub46.i\n %or46.i = or i16 %or45.i, %sub47.i\n %or47.i = or i16 %or46.i, %sub48.i\n %or48.i = or i16 %or47.i, %sub49.i\n %or50.i = or i16 %or48.i, %subi\n %subii = add i16 0, 0\n %subi16.i = add i16 %subii, 0\n %subi17.i = add i16 %subii, 0\n %0 = or i16 %subi16.i, %subi17.i\n %1 = or i16 %0, %or50.i\n ret i16 %1\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SLPVectorizer] Assertion `Iter != this->end() && \"DenseMap::at failed due to a missing key\"' failed.",
"body": "Reproducer: https://godbolt.org/z/v5bqhPWqb\r\n```\r\n; bin/opt -passes=slp-vectorizer reduced.ll -S\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine i16 @test() {\r\nentry:\r\n %sub.i487.i.reass.i = add i16 0, 0\r\n %sub.i487.i.reass.40.i = add i16 %sub.i487.i.reass.i, 0\r\n %sub.i487.i.reass.41.i = add i16 %sub.i487.i.reass.i, 0\r\n %sub.i487.i.reass.42.i = add i16 %sub.i487.i.reass.i, 0\r\n %sub.i487.i.reass.43.i = add i16 %sub.i487.i.reass.i, 0\r\n %sub.i487.i.reass.44.i = add i16 %sub.i487.i.reass.i, 0\r\n %sub.i487.i.reass.45.i = add i16 %sub.i487.i.reass.i, 0\r\n %sub.i487.i.reass.46.i = add i16 0, 0\r\n %sub.i487.i.reass.47.i = add i16 0, 0\r\n %sub.i487.i.reass.48.i = add i16 0, 0\r\n %sub.i487.i.reass.49.i = add i16 0, 0\r\n %or374461.i.40.i = or i16 %sub.i487.i.reass.40.i, %sub.i487.i.reass.41.i\r\n %or374461.i.41.i = or i16 %or374461.i.40.i, %sub.i487.i.reass.42.i\r\n %or374461.i.42.i = or i16 %or374461.i.41.i, %sub.i487.i.reass.43.i\r\n %or374461.i.43.i = or i16 %or374461.i.42.i, %sub.i487.i.reass.44.i\r\n %or374461.i.44.i = or i16 %or374461.i.43.i, %sub.i487.i.reass.45.i\r\n %or374461.i.45.i = or i16 %or374461.i.44.i, %sub.i487.i.reass.46.i\r\n %or374461.i.46.i = or i16 %or374461.i.45.i, %sub.i487.i.reass.47.i\r\n %or374461.i.47.i = or i16 %or374461.i.46.i, %sub.i487.i.reass.48.i\r\n %or374461.i.48.i = or i16 %or374461.i.47.i, %sub.i487.i.reass.49.i\r\n %or374461.i.50.i = or i16 %or374461.i.48.i, %sub.i487.i.reass.i\r\n %sub.i487.i96.reass.i = add i16 0, 0\r\n %sub.i487.i96.reass.16.i = add i16 %sub.i487.i96.reass.i, 0\r\n %sub.i487.i96.reass.17.i = add i16 %sub.i487.i96.reass.i, 0\r\n %0 = or i16 %sub.i487.i96.reass.16.i, %sub.i487.i96.reass.17.i\r\n %1 = or i16 %0, %or374461.i.50.i\r\n ret i16 %1\r\n}\r\n```\r\n```\r\nopt: /root/llvm-project/llvm/include/llvm/ADT/DenseMap.h:204: const ValueT& llvm::DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT, BucketT>::at(llvm::DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT, BucketT>::const_arg_type_t<KeyT>) const [with DerivedT = llvm::DenseMap<llvm::Value*, llvm::Value*>; KeyT = llvm::Value*; ValueT = llvm::Value*; KeyInfoT = llvm::DenseMapInfo<llvm::Value*, void>; BucketT = llvm::detail::DenseMapPair<llvm::Value*, llvm::Value*>; llvm::DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT, BucketT>::const_arg_type_t<KeyT> = const llvm::Value*]: Assertion `Iter != this->end() && \"DenseMap::at failed due to a missing key\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer <source>\r\n1.\tRunning pass \"function(slp-vectorizer)\" on module \"<source>\"\r\n2.\tRunning pass \"slp-vectorizer\" on function \"test\"\r\n #0 0x0000000005035d68 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5035d68)\r\n #1 0x00000000050334ac SignalHandler(int) Signals.cpp:0:0\r\n #2 0x0000707bdcc42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x0000707bdcc969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x0000707bdcc42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x0000707bdcc287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x0000707bdcc2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x0000707bdcc39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x000000000409326e llvm::DenseMapBase<llvm::DenseMap<llvm::Value*, llvm::Value*, llvm::DenseMapInfo<llvm::Value*, void>, llvm::detail::DenseMapPair<llvm::Value*, llvm::Value*>>, llvm::Value*, llvm::Value*, llvm::DenseMapInfo<llvm::Value*, void>, llvm::detail::DenseMapPair<llvm::Value*, llvm::Value*>>::at(llvm::Value const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x409326e)\r\n #9 0x000000000413473f (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&) SLPVectorizer.cpp:0:0\r\n#10 0x00000000041370d1 llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41370d1)\r\n#11 0x000000000413b996 llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*) (.constprop.0) SLPVectorizer.cpp:0:0\r\n#12 0x000000000413ff36 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x413ff36)\r\n#13 0x0000000004146401 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\r\n#14 0x000000000414708b llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x414708b)\r\n#15 0x0000000002f1a1ae llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2f1a1ae)\r\n#16 0x0000000004e38158 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e38158)\r\n#17 0x0000000000e0b02e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe0b02e)\r\n#18 0x0000000004e36b7e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e36b7e)\r\n#19 0x0000000000e0a83e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe0a83e)\r\n#20 0x0000000004e365b0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e365b0)\r\n#21 0x00000000008feef2 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8feef2)\r\n#22 0x00000000008f1d7c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8f1d7c)\r\n#23 0x0000707bdcc29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#24 0x0000707bdcc29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#25 0x00000000008e984e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8e984e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```\r\nllvm version: e8a739062490ce1bb30974f216ba187cd7b5a2a4",
"author": "dtcxzyw",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
112577
|
https://github.com/llvm/llvm-project/issues/112577
|
miscompilation
|
76196998e25b98d81abc437708622261810782ca
| 2024-10-16T16:30:23 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "709abacdc350d63c61888607edb28ce272daa0a0",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
17224,
17232
]
],
"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::collectValuesToDemote"
],
"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 709abacdc350d63c61888607edb28ce272daa0a0
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Fri Oct 18 13:54:30 2024 -0700
[SLP]Check that operand of abs does not overflow before making it part of minbitwidth transformation
Need to check that the operand of the abs intrinsic can be safely
truncated before making it part of the minbitwidth transformation.
Fixes #112577
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index e7b52fbdcc3b..e1aa6127ac03 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -17224,9 +17224,25 @@ bool BoUpSLP::collectValuesToDemote(
MaskedValueIsZero(I->getOperand(1), Mask, SimplifyQuery(*DL)));
});
};
+ auto AbsChecker = [&](unsigned BitWidth, unsigned OrigBitWidth) {
+ assert(BitWidth <= OrigBitWidth && "Unexpected bitwidths!");
+ return all_of(E.Scalars, [&](Value *V) {
+ auto *I = cast<Instruction>(V);
+ unsigned SignBits = OrigBitWidth - BitWidth;
+ APInt Mask = APInt::getBitsSetFrom(OrigBitWidth, BitWidth - 1);
+ unsigned Op0SignBits =
+ ComputeNumSignBits(I->getOperand(0), *DL, 0, AC, nullptr, DT);
+ return SignBits <= Op0SignBits &&
+ ((SignBits != Op0SignBits &&
+ !isKnownNonNegative(I->getOperand(0), SimplifyQuery(*DL))) ||
+ MaskedValueIsZero(I->getOperand(0), Mask, SimplifyQuery(*DL)));
+ });
+ };
if (ID != Intrinsic::abs) {
Operands.push_back(getOperandEntry(&E, 1));
CallChecker = CompChecker;
+ } else {
+ CallChecker = AbsChecker;
}
InstructionCost BestCost =
std::numeric_limits<InstructionCost::CostType>::max();
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/abs-overflow-incorrect-minbws.ll",
"commands": [
"opt -S --passes=slp-vectorizer < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define i32 @test(i32 %n) {\nentry:\n %n1 = add i32 %n, 1\n %zn1 = zext nneg i32 %n1 to i64\n %m1 = mul nuw nsw i64 %zn1, 273837369\n %a1 = call i64 @llvm.abs.i64(i64 %m1, i1 true)\n %t1 = trunc i64 %a1 to i32\n %n2 = add i32 %n, 2\n %zn2 = zext nneg i32 %n2 to i64\n %m2 = mul nuw nsw i64 %zn2, 273837369\n %a2 = call i64 @llvm.abs.i64(i64 %m2, i1 true)\n %t2 = trunc i64 %a2 to i32\n %res1 = add i32 %t1, %t2\n ret i32 %res1\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i64 @llvm.abs.i64(i64, i1 immarg) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SLP] SLP Vectorizer miscompile from reducing abs bitwidth",
"body": "Bisected miscompile to this change https://github.com/llvm/llvm-project/commit/4a1c53f9fabbc18d436dcd4d5b572b82656fbbf9\r\n\r\nReduced internal test to this example:\r\nhttps://godbolt.org/z/njWYP9exd\r\n```llvm\r\ndefine dso_local noundef i32 @test(i32 %n) local_unnamed_addr #0 {\r\nentry:\r\n %n1 = add i32 %n, 1\r\n %zn1 = zext nneg i32 %n1 to i64\r\n %m1 = mul nuw nsw i64 %zn1, 273837369\r\n %a1 = call noundef i64 @llvm.abs.i64(i64 %m1, i1 true)\r\n %t1 = trunc i64 %a1 to i32\r\n %n2 = add i32 %n, 2\r\n %zn2 = zext nneg i32 %n2 to i64\r\n %m2 = mul nuw nsw i64 %zn2, 273837369\r\n %a2 = call noundef i64 @llvm.abs.i64(i64 %m2, i1 true)\r\n %t2 = trunc i64 %a2 to i32\r\n\r\n %res1 = add i32 %t1, %t2\r\n ret i32 %res1\r\n}\r\n```\r\nRunning slp vectorizer on it gives\r\n```llvm\r\ndefine dso_local noundef i32 @test(i32 %n) local_unnamed_addr {\r\n %0 = insertelement <2 x i32> poison, i32 %n, i32 0\r\n %1 = shufflevector <2 x i32> %0, <2 x i32> poison, <2 x i32> zeroinitializer\r\n %2 = add <2 x i32> %1, <i32 1, i32 2>\r\n %3 = mul <2 x i32> %2, <i32 273837369, i32 273837369>\r\n %4 = call <2 x i32> @llvm.abs.v2i32(<2 x i32> %3, i1 false)\r\n %5 = extractelement <2 x i32> %4, i32 0\r\n %6 = extractelement <2 x i32> %4, i32 1\r\n %res1 = add i32 %5, %6\r\n ret i32 %res1\r\n}\r\n```\r\nwhich is incorrect. Counterexample by alive2:\r\nhttps://alive2.llvm.org/ce/z/cEcY-u",
"author": "danilaml",
"labels": [
"miscompilation",
"release:backport",
"llvm:SLPVectorizer"
],
"comments": [
{
"author": "AZero13",
"body": "Do we plan on backporting this to 19.x @alexey-bataev "
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
113123
|
https://github.com/llvm/llvm-project/issues/113123
|
miscompilation
|
67ff5ba9af9754261abe11d762af11532a816126
| 2024-10-21T02:18:29 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "a2ba438f3e5635e368333213914c7452a6a6a2da",
"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": [
[
1531,
1538
]
],
"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 a2ba438f3e5635e368333213914c7452a6a6a2da
Author: XChy <xxs_chy@outlook.com>
Date: Mon Oct 21 22:30:31 2024 +0800
[InstCombine] Preserve the flag from RHS only if the `and` is bitwise (#113164)
Fixes #113123
Alive proof: https://alive2.llvm.org/ce/z/hnqeLC
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index d72013ba223d..835eae9f5725 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -1531,8 +1531,10 @@ Value *InstCombinerImpl::foldLogicOfFCmps(FCmpInst *LHS, FCmpInst *RHS,
}
if (IsLessThanOrLessEqual(IsAnd ? PredL : PredR)) {
BuilderTy::FastMathFlagGuard Guard(Builder);
- Builder.setFastMathFlags(LHS->getFastMathFlags() |
- RHS->getFastMathFlags());
+ FastMathFlags NewFlag = LHS->getFastMathFlags();
+ if (!IsLogicalSelect)
+ NewFlag |= RHS->getFastMathFlags();
+ Builder.setFastMathFlags(NewFlag);
Value *FAbs = Builder.CreateUnaryIntrinsic(Intrinsic::fabs, LHS0);
return Builder.CreateFCmp(PredL, FAbs,
|
[
{
"file": "llvm/test/Transforms/InstCombine/fcmp-range-check-idiom.ll",
"commands": [
"opt -S -passes=instcombine %s"
],
"tests": [
{
"test_name": "test_and_olt_fmf_propagation_union_logical_rhs_poison",
"test_body": "define i1 @test_and_olt_fmf_propagation_union_logical_rhs_poison(float %x) {\n %cmp1 = fcmp ninf olt float %x, 0x3C00000000000000\n %cmp2 = fcmp ogt float %x, 0xBC00000000000000\n %cond = select i1 %cmp2, i1 %cmp1, i1 false\n ret i1 %cond\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_and_olt_fmf_propagation_union_logical_both_poison",
"test_body": "define i1 @test_and_olt_fmf_propagation_union_logical_both_poison(float %x) {\n %cmp1 = fcmp ninf olt float %x, 0x3C00000000000000\n %cmp2 = fcmp ninf ogt float %x, 0xBC00000000000000\n %cond = select i1 %cmp2, i1 %cmp1, i1 false\n ret i1 %cond\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_and_olt_fmf_propagation_union",
"test_body": "define i1 @test_and_olt_fmf_propagation_union(float %x) {\n %cmp1 = fcmp nnan ninf olt float %x, 0x3C00000000000000\n %cmp2 = fcmp nnan nsz ogt float %x, 0xBC00000000000000\n %cond = and i1 %cmp1, %cmp2\n ret i1 %cond\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_and_olt_fmf_propagation_union_logical_lhs_poison",
"test_body": "define i1 @test_and_olt_fmf_propagation_union_logical_lhs_poison(float %x) {\n %cmp1 = fcmp olt float %x, 0x3C00000000000000\n %cmp2 = fcmp ninf ogt float %x, 0xBC00000000000000\n %cond = select i1 %cmp2, i1 %cmp1, i1 false\n ret i1 %cond\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Wrong canonicalization of a range check idiom",
"body": "https://github.com/llvm/llvm-project/blob/11dad2fa5138a50d60a5a34a2c7e074b976820e2/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp#L1511-L1527\r\n\r\n\r\nAlive2 report: https://alive2.llvm.org/ce/z/qBHAmS\r\n\r\n```llvm\r\n----------------------------------------\r\ndefine i1 @test_and_olt_fmf_propagation_union.2(float %x) {\r\n#0:\r\n %cmp1 = fcmp nnan ninf olt float %x, 0.000000\r\n %cmp2 = fcmp nnan nsz ogt float %x, -0.000000\r\n %#1 = select i1 %cmp2, i1 %cmp1, i1 %cmp2\r\n %cond = and i1 %#1, %cmp2\r\n ret i1 %cond\r\n}\r\n=>\r\ndefine i1 @test_and_olt_fmf_propagation_union.2(float %x) {\r\n#0:\r\n %#1 = fabs nnan ninf nsz float %x\r\n %#2 = fcmp nnan ninf nsz olt float %#1, 0.000000\r\n ret i1 %#2\r\n}\r\nTransformation doesn't verify!\r\n\r\nERROR: Target is more poisonous than source\r\n\r\nExample:\r\nfloat %x = #xff800000 (-oo)\r\n\r\nSource:\r\ni1 %cmp1 = poison\r\ni1 %cmp2 = #x0 (0)\r\ni1 %#1 = #x0 (0)\r\ni1 %cond = #x0 (0)\r\n\r\nTarget:\r\nfloat %#1 = poison\r\ni1 %#2 = poison\r\nSource value: #x0 (0)\r\nTarget value: poison\r\n\r\nSummary:\r\n 0 correct transformations\r\n 1 incorrect transformations\r\n 0 failed-to-prove transformations\r\n 0 Alive2 errors\r\n```",
"author": "bongjunj",
"labels": [
"miscompilation",
"llvm:instcombine",
"floating-point"
],
"comments": [
{
"author": "XChy",
"body": "Thanks for the report.\r\n\r\nWe preserve `ninf` flag from `cmp1` when folding logical and `select cmp2, cmp1, false` into `fcmp ninf (fabs(x))`. But if `cmp2` equals to `false`, the select won't be poison whatever `cmp1` is. Thus, such fold makes it more poisonous. See https://alive2.llvm.org/ce/z/hnqeLC"
},
{
"author": "XChy",
"body": "And it looks like you are mutating the unit tests to fuzz LLVM. Looks interesting to me. If OK, could you provide some information about it?"
},
{
"author": "bongjunj",
"body": "> And it looks like you are mutating the unit tests to fuzz LLVM. Looks interesting to me. If OK, could you provide some information about it?\r\n\r\n@XChy Yes we are designing a fuzzer on top of LLVM to test the compiler. We can't disclose the full detail at this time. Thank you."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
135800
|
https://github.com/llvm/llvm-project/issues/135800
|
crash
|
a1d52fcdca8bda4fe8c6652b2de83f408f4ad4f2
| 2025-04-15T15:58:08 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "2271f0bebd48c9ed8b16b500886a819c4f269a6a",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
9575,
9580
]
],
"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::canBuildSplitNode"
],
"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 2271f0bebd48c9ed8b16b500886a819c4f269a6a
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Tue Apr 15 13:02:32 2025 -0700
[SLP]Check for perfect/shuffled match for the split node
If the potential split node is a perfect/shuffled match of another split
node, need to skip creation of the another split node with the same
scalars, it should be a buildvector.
Fixes #135800
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 253933a2438c..234cd340ebc1 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -9575,6 +9575,24 @@ bool BoUpSLP::canBuildSplitNode(ArrayRef<Value *> VL,
!SplitAlternateInstructions)
return false;
+ // Check if this is a duplicate of another split entry.
+ LLVM_DEBUG(dbgs() << "SLP: \tChecking bundle: " << *LocalState.getMainOp()
+ << ".\n");
+ for (TreeEntry *E : getSplitTreeEntries(LocalState.getMainOp())) {
+ if (E->isSame(VL)) {
+ LLVM_DEBUG(dbgs() << "SLP: Perfect diamond merge at "
+ << *LocalState.getMainOp() << ".\n");
+ return false;
+ }
+ SmallPtrSet<Value *, 8> Values(llvm::from_range, E->Scalars);
+ if (all_of(VL, [&](Value *V) {
+ return isa<PoisonValue>(V) || Values.contains(V);
+ })) {
+ LLVM_DEBUG(dbgs() << "SLP: Gathering due to full overlap.\n");
+ return false;
+ }
+ }
+
ReorderIndices.assign(VL.size(), VL.size());
SmallBitVector Op1Indices(VL.size());
for (auto [Idx, V] : enumerate(VL)) {
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/split-node-full-match.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @test(double %0) {\n;\n.thread:\n %1 = call double null(ptr null, ptr null, ptr null)\n %2 = call double null(ptr null, ptr null, ptr null)\n br i1 false, label %3, label %5\n\n3:\n %4 = call double null(ptr null, ptr null, ptr null)\n br label %5\n\n5:\n %.1226 = phi double [ %4, %3 ], [ 0.000000e+00, %.thread ]\n %.1222 = phi double [ 0.000000e+00, %3 ], [ 0.000000e+00, %.thread ]\n %.1218 = phi double [ %0, %3 ], [ 0.000000e+00, %.thread ]\n %.1216 = phi double [ 0.000000e+00, %3 ], [ 0.000000e+00, %.thread ]\n br i1 false, label %.lr.ph272.preheader, label %._crit_edge\n\n.lr.ph272.preheader:\n br i1 false, label %._crit_edge, label %6\n\n6:\n %7 = fdiv double 0.000000e+00, 0.000000e+00\n %8 = fsub double 0.000000e+00, %7\n %9 = fdiv double 0.000000e+00, 0.000000e+00\n %10 = fsub double 0.000000e+00, %9\n br i1 false, label %11, label %._crit_edge\n\n11:\n br label %._crit_edge\n\n._crit_edge:\n %.2227.lcssa = phi double [ %.1226, %5 ], [ 0.000000e+00, %11 ], [ %.1226, %6 ], [ %.1226, %.lr.ph272.preheader ]\n %.2223.lcssa = phi double [ %.1222, %5 ], [ 0.000000e+00, %11 ], [ %.1222, %6 ], [ %.1222, %.lr.ph272.preheader ]\n %.2219.lcssa = phi double [ %.1218, %5 ], [ 0.000000e+00, %11 ], [ %.1218, %6 ], [ %.1218, %.lr.ph272.preheader ]\n %.2.lcssa = phi double [ %.1216, %5 ], [ %0, %11 ], [ %.1216, %6 ], [ %.1216, %.lr.ph272.preheader ]\n %.0213.lcssa = phi double [ %2, %5 ], [ 0.000000e+00, %11 ], [ %10, %6 ], [ %2, %.lr.ph272.preheader ]\n %.0211.lcssa = phi double [ %1, %5 ], [ 0.000000e+00, %11 ], [ %8, %6 ], [ %1, %.lr.ph272.preheader ]\n ret void\n}",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/split-node-no-reorder-copy.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-sie-ps5 -mcpu=znver2 < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define i1 @test(ptr %0, ptr %1, <2 x float> %2, <2 x float> %3, <2 x float> %4) {\n %6 = load float, ptr %1, align 4\n %7 = load float, ptr %0, align 4\n %8 = fmul float %6, %6\n %9 = fmul float %7, %7\n %10 = fmul float %7, %7\n %11 = fmul float %7, %7\n %12 = fmul float %7, %7\n %13 = fmul float %7, %7\n %14 = load float, ptr %0, align 4\n %15 = fmul float %14, %14\n %16 = fmul float %14, %14\n %17 = extractelement <2 x float> %2, i64 0\n %18 = extractelement <2 x float> %2, i64 0\n %19 = fmul float %17, %17\n %20 = fmul float %18, %18\n %21 = extractelement <2 x float> %3, i64 0\n %22 = extractelement <2 x float> %2, i64 0\n %23 = fmul float %21, %21\n %24 = fmul float %22, %22\n %25 = extractelement <2 x float> %2, i64 0\n %26 = extractelement <2 x float> %2, i64 0\n %27 = fmul float %25, %25\n %28 = fmul float %26, %26\n %29 = extractelement <2 x float> %2, i64 0\n %30 = extractelement <2 x float> %4, i64 0\n %31 = fmul float %29, %29\n %32 = fmul float %30, %30\n %33 = fadd reassoc nsz float %8, %9\n %34 = fadd reassoc nsz float %33, %10\n %35 = fadd reassoc nsz float %34, %11\n %36 = fadd reassoc nsz float %35, %12\n %37 = fadd reassoc nsz float %36, %13\n %38 = fadd reassoc nsz float %37, %15\n %39 = fadd reassoc nsz float %38, %16\n %40 = fadd reassoc nsz float %39, %19\n %41 = fadd reassoc nsz float %40, %20\n %42 = fadd reassoc nsz float %41, %23\n %43 = fadd reassoc nsz float %42, %24\n %44 = fadd reassoc nsz float %43, %27\n %45 = fadd reassoc nsz float %44, %28\n %46 = fadd reassoc nsz float %45, %31\n %47 = fadd reassoc nsz float %46, %32\n %48 = call float @foo(float %47)\n ret i1 false\n}\n\ndeclare float @foo(float)\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[slp] ICE: Instruction does not dominate all uses!",
"body": "First showed up in 04c38981a9ce3e6225669c0e41cab947e3e7989f, last known good commit was 0283bb3afcc5dc521f6b2e7d541a830a9546ed80.\n\nCommits in this range with SLP in the subject line:\n```\n$ g log 0283bb3afcc5dc521f6b2e7d541a830a9546ed80^1..04c38981a9ce3e6225669c0e41cab947e3e7989f|grep -i slp\n'61d04f1aac96 Thu Apr 10 16:05:01 2025 -0400 [SLP][NFC]Extract preliminary checks from buildTree_rec, NFC'\n'aaaa2a325bd1 Thu Apr 10 12:06:38 2025 -0400 [SLP]Support vectorization of previously vectorized scalars in split nodes'\n'4ea57b3481c0 Thu Apr 10 08:30:43 2025 -0700 [SLP]Fix detection of matching splat vector'\n'396e2ef3b7f4 Thu Apr 10 08:20:28 2025 -0700 [SLP][NFC]Add a test with incorrect identity match for less-defined splat'\n'a693f23ef2fc Thu Apr 10 23:07:45 2025 +0800 [SLP][REVEC] Fix CompressVectorize does not expand mask when REVEC is enabled. (#135174)'\n'd02a704ec952 Thu Apr 10 18:54:45 2025 +0800 [SLP][REVEC] Make getExtractWithExtendCost support FixedVectorType as Dst. (#134822)'\n```\n\n```\n$ opt -passes=slp-vectorizer reduced.ll -disable-output\nInstruction does not dominate all uses!\n %15 = call <6 x double> @llvm.vector.insert.v6f64.v2f64(<6 x double> %14, <2 x double> %13, i64 4)\n %9 = shufflevector <6 x double> %15, <6 x double> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>\nInstruction does not dominate all uses!\n %13 = insertelement <2 x double> %12, double %1, i32 1\n %11 = call <6 x double> @llvm.vector.insert.v6f64.v2f64(<6 x double> %10, <2 x double> %13, i64 4)\nLLVM ERROR: Broken module found, compilation aborted!\n```\n\n```\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @foo(double %0) {\n.thread:\n %1 = call double null(ptr null, ptr null, ptr null)\n %2 = call double null(ptr null, ptr null, ptr null)\n br i1 false, label %3, label %5\n\n3: ; preds = %.thread\n %4 = call double null(ptr null, ptr null, ptr null)\n br label %5\n\n5: ; preds = %3, %.thread\n %.1226 = phi double [ %4, %3 ], [ 0.000000e+00, %.thread ]\n %.1222 = phi double [ 0.000000e+00, %3 ], [ 0.000000e+00, %.thread ]\n %.1218 = phi double [ %0, %3 ], [ 0.000000e+00, %.thread ]\n %.1216 = phi double [ 0.000000e+00, %3 ], [ 0.000000e+00, %.thread ]\n br i1 false, label %.lr.ph272.preheader, label %._crit_edge\n\n.lr.ph272.preheader: ; preds = %5\n br i1 false, label %._crit_edge, label %6\n\n6: ; preds = %.lr.ph272.preheader\n %7 = fdiv double 0.000000e+00, 0.000000e+00\n %8 = fsub double 0.000000e+00, %7\n %9 = fdiv double 0.000000e+00, 0.000000e+00\n %10 = fsub double 0.000000e+00, %9\n br i1 false, label %11, label %._crit_edge\n\n11: ; preds = %6\n br label %._crit_edge\n\n._crit_edge: ; preds = %11, %6, %.lr.ph272.preheader, %5\n %.2227.lcssa = phi double [ %.1226, %5 ], [ 0.000000e+00, %11 ], [ %.1226, %6 ], [ %.1226, %.lr.ph272.preheader ]\n %.2223.lcssa = phi double [ %.1222, %5 ], [ 0.000000e+00, %11 ], [ %.1222, %6 ], [ %.1222, %.lr.ph272.preheader ]\n %.2219.lcssa = phi double [ %.1218, %5 ], [ 0.000000e+00, %11 ], [ %.1218, %6 ], [ %.1218, %.lr.ph272.preheader ]\n %.2.lcssa = phi double [ %.1216, %5 ], [ %0, %11 ], [ %.1216, %6 ], [ %.1216, %.lr.ph272.preheader ]\n %.0213.lcssa = phi double [ %2, %5 ], [ 0.000000e+00, %11 ], [ %10, %6 ], [ %2, %.lr.ph272.preheader ]\n %.0211.lcssa = phi double [ %1, %5 ], [ 0.000000e+00, %11 ], [ %8, %6 ], [ %1, %.lr.ph272.preheader ]\n ret void\n}\n```",
"author": "ashermancinelli",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
122584
|
https://github.com/llvm/llvm-project/issues/122584
|
crash
|
34ba84fe90b3e369c03e695a395ec632ef60e23d
| 2025-01-11T08:32:25 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "af524de1fa94e4b4cee8b745d1b68f4ea0090759",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
14935,
14942
]
],
"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::processBuildVector"
],
"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 af524de1fa94e4b4cee8b745d1b68f4ea0090759
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Mon Jan 13 06:48:56 2025 -0800
[SLP]Do not include subvectors for fully matched buildvectors
If the buildvector node fully matched another node, need to exclude
subvectors, when building final shuffle, just a shuffle of the original
node must be emitted.
Fixes #122584
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index e3487b501534..df46c69ff3ab 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -14935,8 +14935,8 @@ ResTy BoUpSLP::processBuildVector(const TreeEntry *E, Type *ScalarTy,
}
}
ShuffleBuilder.add(*FrontTE, Mask);
- Res = ShuffleBuilder.finalize(E->getCommonMask(), SubVectors,
- SubVectorsMask);
+ // Full matched entry found, no need to insert subvectors.
+ Res = ShuffleBuilder.finalize(E->getCommonMask(), {}, {});
return Res;
}
if (!Resized) {
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/AArch64/vectorizable-selects-uniform-cmps.ll",
"commands": [
"opt -passes=slp-vectorizer -S %s",
"opt -aa-pipeline=basic-aa -passes='slp-vectorizer' -S %s"
],
"tests": [
{
"test_name": "select_uniform_ugt_16xi8",
"test_body": "target datalayout = \"e-m:o-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"arm64-apple-ios5.0.0\"\n\ndefine void @select_uniform_ugt_16xi8(ptr %ptr, i8 %x) {\nentry:\n %l.0 = load i8, ptr %ptr, align 1\n %cmp.0 = icmp ugt i8 %l.0, -1\n %s.0 = select i1 %cmp.0, i8 %l.0, i8 %x\n store i8 %s.0, ptr %ptr, align 2\n %gep.1 = getelementptr inbounds i8, ptr %ptr, i8 1\n %l.1 = load i8, ptr %gep.1, align 1\n %cmp.1 = icmp ugt i8 %l.1, -1\n %s.1 = select i1 %cmp.1, i8 %l.1, i8 %x\n store i8 %s.1, ptr %gep.1, align 2\n %gep.2 = getelementptr inbounds i8, ptr %ptr, i8 2\n %l.2 = load i8, ptr %gep.2, align 1\n %cmp.2 = icmp ugt i8 %l.2, -1\n %s.2 = select i1 %cmp.2, i8 %l.2, i8 %x\n store i8 %s.2, ptr %gep.2, align 2\n %gep.3 = getelementptr inbounds i8, ptr %ptr, i8 3\n %l.3 = load i8, ptr %gep.3, align 1\n %cmp.3 = icmp ugt i8 %l.3, -1\n %s.3 = select i1 %cmp.3, i8 %l.3, i8 %x\n store i8 %s.3, ptr %gep.3, align 2\n %gep.4 = getelementptr inbounds i8, ptr %ptr, i8 4\n %l.4 = load i8, ptr %gep.4, align 1\n %cmp.4 = icmp ugt i8 %l.4, -1\n %s.4 = select i1 %cmp.4, i8 %l.4, i8 %x\n store i8 %s.4, ptr %gep.4, align 2\n %gep.5 = getelementptr inbounds i8, ptr %ptr, i8 5\n %l.5 = load i8, ptr %gep.5, align 1\n %cmp.5 = icmp ugt i8 %l.5, -1\n %s.5 = select i1 %cmp.5, i8 %l.5, i8 %x\n store i8 %s.5, ptr %gep.5, align 2\n %gep.6 = getelementptr inbounds i8, ptr %ptr, i8 6\n %l.6 = load i8, ptr %gep.6, align 1\n %cmp.6 = icmp ugt i8 %l.6, -1\n %s.6 = select i1 %cmp.6, i8 %l.6, i8 %x\n store i8 %s.6, ptr %gep.6, align 2\n %gep.7 = getelementptr inbounds i8, ptr %ptr, i8 7\n %l.7 = load i8, ptr %gep.7, align 1\n %cmp.7 = icmp ugt i8 %l.7, -1\n %s.7 = select i1 %cmp.7, i8 %l.7, i8 %x\n store i8 %s.7, ptr %gep.7, align 2\n %gep.8 = getelementptr inbounds i8, ptr %ptr, i8 8\n %l.8 = load i8, ptr %gep.8, align 1\n %cmp.8 = icmp ugt i8 %l.8, -1\n %s.8 = select i1 %cmp.8, i8 %l.0, i8 %x\n store i8 %s.0, ptr %gep.8, align 2\n %gep.9 = getelementptr inbounds i8, ptr %ptr, i8 9\n %l.9 = load i8, ptr %gep.9, align 1\n %cmp.9 = icmp ugt i8 %l.9, -1\n %s.9 = select i1 %cmp.9, i8 %l.9, i8 %x\n store i8 %s.9, ptr %gep.9, align 2\n %gep.10 = getelementptr inbounds i8, ptr %ptr, i8 10\n %l.10 = load i8, ptr %gep.10, align 1\n %cmp.10 = icmp ugt i8 %l.10, -1\n %s.10 = select i1 %cmp.10, i8 %l.10, i8 %x\n store i8 %s.10, ptr %gep.10, align 2\n %gep.11 = getelementptr inbounds i8, ptr %ptr, i8 11\n %l.11 = load i8, ptr %gep.11, align 1\n %cmp.11 = icmp ugt i8 %l.11, -1\n %s.11 = select i1 %cmp.11, i8 %l.11, i8 %x\n store i8 %s.11, ptr %gep.11, align 2\n %gep.12 = getelementptr inbounds i8, ptr %ptr, i8 12\n %l.12 = load i8, ptr %gep.12, align 1\n %cmp.12 = icmp ugt i8 %l.12, -1\n %s.12 = select i1 %cmp.12, i8 %l.12, i8 %x\n store i8 %s.12, ptr %gep.12, align 2\n %gep.13 = getelementptr inbounds i8, ptr %ptr, i8 13\n %l.13 = load i8, ptr %gep.13, align 1\n %cmp.13 = icmp ugt i8 %l.13, -1\n %s.13 = select i1 %cmp.13, i8 %l.13, i8 %x\n store i8 %s.13, ptr %gep.13, align 2\n %gep.14 = getelementptr inbounds i8, ptr %ptr, i8 14\n %l.14 = load i8, ptr %gep.14, align 1\n %cmp.14 = icmp ugt i8 %l.14, -1\n %s.14 = select i1 %cmp.14, i8 %l.14, i8 %x\n store i8 %s.14, ptr %gep.14, align 2\n %gep.15 = getelementptr inbounds i8, ptr %ptr, i8 15\n %l.15 = load i8, ptr %gep.15, align 1\n %cmp.15 = icmp ugt i8 %l.15, -1\n %s.15 = select i1 %cmp.15, i8 %l.15, i8 %x\n store i8 %s.15, ptr %gep.15, align 2\n ret void\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
}
]
}
] |
{
"title": "clang crashes on valid code at -O{s,2,3} on x86_64-linux-gnu: Assertion `I1 == PoisonMaskElem && \"Expected unused subvectors mask\"' failed",
"body": "It appears to be a recent regression as it doesn't reproduce with 19.1.0 and earlier.\n\nCompiler Explorer: https://godbolt.org/z/vWPhsMfoz\n\n```\n[510] % clangtk -v\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git 24bd9bc0b59d51c82e9a4d84c21d86d58d0ef6ce)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /local/home/suz/suz-local/software/local/clang-trunk/bin\nBuild config: +assertions\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12\nCandidate multilib: .;@m64\nSelected multilib: .;@m64\nFound CUDA installation: /usr/local/cuda, version 12.1\n[511] % \n[511] % clangtk -O2 small.c\nclang-20: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:10936: 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, preprocessed source, and associated run script.\nStack dump:\n0.\tProgram arguments: /local/home/suz/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/20250111-clangtk-m64-Os-build-025751/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20250111-clangtk-m64-Os-build-025751/delta -resource-dir /local/home/suz/suz-local/software/local/clang-trunk/lib/clang/20 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/home/suz/suz-local/software/local/clang-trunk/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -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-2771d7.o -x c small.c\n1.\t<eof> parser at end of file\n2.\tOptimizer\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"small.c\"\n4.\tRunning pass \"slp-vectorizer\" on function \"main\"\n #0 0x0000562bd646d500 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-20+0x4576500)\n #1 0x0000562bd646a91f llvm::sys::RunSignalHandlers() (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-20+0x457391f)\n #2 0x0000562bd646aa75 SignalHandler(int) Signals.cpp:0:0\n #3 0x00007f13d1771520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #4 0x00007f13d17c5a7c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x96a7c)\n #5 0x00007f13d1771476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #6 0x00007f13d17577f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #7 0x00007f13d175771b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #8 0x00007f13d1768e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #9 0x0000562bd7f25a4f 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>&)>) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-20+0x602ea4f)\n#10 0x0000562bd7f9164b llvm::InstructionCost llvm::slpvectorizer::BoUpSLP::processBuildVector<llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator, llvm::InstructionCost, llvm::TargetTransformInfo, llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP, llvm::SmallPtrSetImpl<llvm::Value*>>(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::Type*, llvm::TargetTransformInfo&, llvm::ArrayRef<llvm::Value*>&, llvm::slpvectorizer::BoUpSLP&, llvm::SmallPtrSetImpl<llvm::Value*>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-20+0x609a64b)\n#11 0x0000562bd7f92881 llvm::slpvectorizer::BoUpSLP::getEntryCost(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallPtrSetImpl<llvm::Value*>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-20+0x609b881)\n#12 0x0000562bd7faaa12 llvm::slpvectorizer::BoUpSLP::getTreeCost(llvm::ArrayRef<llvm::Value*>) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-20+0x60b3a12)\n#13 0x0000562bd7fb43e8 llvm::SLPVectorizerPass::tryToVectorizeList(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, bool) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-20+0x60bd3e8)\n#14 0x0000562bd7fb92b0 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#15 0x0000562bd7fbabe9 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-20+0x60c3be9)\n#16 0x0000562bd7fc268e 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 0x0000562bd7fc31d1 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-20+0x60cc1d1)\n#18 0x0000562bd79d6826 llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-20+0x5adf826)\n#19 0x0000562bd5de82ef llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-20+0x3ef12ef)\n#20 0x0000562bd37a5226 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-20+0x18ae226)\n#21 0x0000562bd5de664b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-20+0x3eef64b)\n#22 0x0000562bd37a3b36 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-20+0x18acb36)\n#23 0x0000562bd5de724d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-20+0x3ef024d)\n#24 0x0000562bd67194c7 (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 0x0000562bd671d213 clang::emitBackendOutput(clang::CompilerInstance&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-20+0x4826213)\n#26 0x0000562bd6df1805 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-20+0x4efa805)\n#27 0x0000562bd8a8c2cc clang::ParseAST(clang::Sema&, bool, bool) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-20+0x6b952cc)\n#28 0x0000562bd70d6ca9 clang::FrontendAction::Execute() (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-20+0x51dfca9)\n#29 0x0000562bd7054ad5 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-20+0x515dad5)\n#30 0x0000562bd71bbf73 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-20+0x52c4f73)\n#31 0x0000562bd334425f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-20+0x144d25f)\n#32 0x0000562bd333ab2a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#33 0x0000562bd333efe7 clang_main(int, char**, llvm::ToolContext const&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-20+0x1447fe7)\n#34 0x0000562bd322eb3b main (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-20+0x1337b3b)\n#35 0x00007f13d1758d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#36 0x00007f13d1758e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#37 0x0000562bd333a255 _start (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-20+0x1443255)\nclangtk: error: unable to execute command: Aborted\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git 24bd9bc0b59d51c82e9a4d84c21d86d58d0ef6ce)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /local/home/suz/suz-local/software/local/clang-trunk/bin\nBuild config: +assertions\nclangtk: note: diagnostic msg: \n********************\n\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\nPreprocessed source(s) and associated run script(s) are located at:\nclangtk: note: diagnostic msg: /tmp/small-929da7.c\nclangtk: note: diagnostic msg: /tmp/small-929da7.sh\nclangtk: note: diagnostic msg: \n\n********************\n[512] % \n[512] % cat small.c\nint a, b, d, e, f, i, n;\nlong c, g, h;\nunsigned o;\nint main() {\n unsigned long j;\n long l, m;\n if (0) {\n k:\n h = ~g;\n l = g;\n m = j;\n i = d;\n p:\n b = g = i;\n if (d) {\n q:\n j = a;\n if (i || i >= a)\n r:\n if (f && h > a)\n goto q;\n goto s;\n }\n g = l;\n j = m;\n s:;\n }\n if (c) {\n n = j % -1;\n o = b;\n if (n) {\n g = d ^ j;\n j = ~(1 / o);\n if (!(n - 1))\n goto r;\n if (e)\n goto p;\n }\n goto k;\n }\n}\n```",
"author": "zhendongsu",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid",
"generated by fuzzer"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Reduced reproducer: https://godbolt.org/z/MzcesqWz1\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(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\n```"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
118725
|
https://github.com/llvm/llvm-project/issues/118725
|
crash
|
e3352904309a539eddcf3ddd9fb11ca2aef29d65
| 2024-12-05T01:14:53 |
[
"llvm/test/Transforms/GlobalOpt"
] |
{
"fix_commit": "5013c81b781eb95af8e429956d63c8f9c16a4647",
"components": [
"Evaluator"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
125,
133
]
],
"llvm/lib/Transforms/Utils/Evaluator.cpp": [
[
253,
292
],
[
520,
528
],
[
544,
553
]
],
"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": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": [
"setVal"
],
"llvm/lib/Transforms/Utils/Evaluator.cpp": [
"Evaluator::EvaluateBlock",
"Evaluator::castCallResultIfNeeded",
"Evaluator::getFormalParams"
],
"llvm/lib/Transforms/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 5013c81b781eb95af8e429956d63c8f9c16a4647
Author: Nikita Popov <npopov@redhat.com>
Date: Thu Dec 12 10:44:52 2024 +0100
[GlobalOpt][Evaluator] Don't evaluate calls with signature mismatch (#119548)
The global ctor evaluator tries to evalute function calls where the call
function type and function type do not match, by performing bitcasts.
This currently causes a crash when calling a void function with non-void
return type.
I've opted to remove this functionality entirely rather than fixing this
specific case. With opaque pointers, there shouldn't be a legitimate use
case for this anymore, as we don't need to look through pointer type
casts. Doing other bitcasts is very iffy because it ignores ABI
considerations. We should at least leave adjusting the signatures to
make them line up to InstCombine (which also does some iffy things, but
is at least somewhat more constrained).
Fixes https://github.com/llvm/llvm-project/issues/118725.
diff --git a/llvm/include/llvm/Transforms/Utils/Evaluator.h b/llvm/include/llvm/Transforms/Utils/Evaluator.h
index 5d53773b5d6b..118037625421 100644
--- a/llvm/include/llvm/Transforms/Utils/Evaluator.h
+++ b/llvm/include/llvm/Transforms/Utils/Evaluator.h
@@ -125,9 +125,6 @@ private:
ValueStack.back()[V] = C;
}
- /// Casts call result to a type of bitcast call expression
- Constant *castCallResultIfNeeded(Type *ReturnType, Constant *RV);
-
/// Given call site return callee and list of its formal arguments
Function *getCalleeWithFormalArgs(CallBase &CB,
SmallVectorImpl<Constant *> &Formals);
diff --git a/llvm/lib/Transforms/Utils/Evaluator.cpp b/llvm/lib/Transforms/Utils/Evaluator.cpp
index cf1a8b4af112..2af447aadce2 100644
--- a/llvm/lib/Transforms/Utils/Evaluator.cpp
+++ b/llvm/lib/Transforms/Utils/Evaluator.cpp
@@ -253,40 +253,17 @@ Evaluator::getCalleeWithFormalArgs(CallBase &CB,
bool Evaluator::getFormalParams(CallBase &CB, Function *F,
SmallVectorImpl<Constant *> &Formals) {
- if (!F)
- return false;
-
auto *FTy = F->getFunctionType();
- if (FTy->getNumParams() > CB.arg_size()) {
- LLVM_DEBUG(dbgs() << "Too few arguments for function.\n");
+ if (FTy != CB.getFunctionType()) {
+ LLVM_DEBUG(dbgs() << "Signature mismatch.\n");
return false;
}
- auto ArgI = CB.arg_begin();
- for (Type *PTy : FTy->params()) {
- auto *ArgC = ConstantFoldLoadThroughBitcast(getVal(*ArgI), PTy, DL);
- if (!ArgC) {
- LLVM_DEBUG(dbgs() << "Can not convert function argument.\n");
- return false;
- }
- Formals.push_back(ArgC);
- ++ArgI;
- }
+ for (Value *Arg : CB.args())
+ Formals.push_back(getVal(Arg));
return true;
}
-/// If call expression contains bitcast then we may need to cast
-/// evaluated return value to a type of the call expression.
-Constant *Evaluator::castCallResultIfNeeded(Type *ReturnType, Constant *RV) {
- if (!RV || RV->getType() == ReturnType)
- return RV;
-
- RV = ConstantFoldLoadThroughBitcast(RV, ReturnType, DL);
- if (!RV)
- LLVM_DEBUG(dbgs() << "Failed to fold bitcast call expr\n");
- return RV;
-}
-
/// Evaluate all instructions in block BB, returning true if successful, false
/// if we can't evaluate it. NewBB returns the next BB that control flows into,
/// or null upon return. StrippedPointerCastsForAliasAnalysis is set to true if
@@ -520,9 +497,7 @@ bool Evaluator::EvaluateBlock(BasicBlock::iterator CurInst, BasicBlock *&NextBB,
if (Callee->isDeclaration()) {
// If this is a function we can constant fold, do it.
if (Constant *C = ConstantFoldCall(&CB, Callee, Formals, TLI)) {
- InstResult = castCallResultIfNeeded(CB.getType(), C);
- if (!InstResult)
- return false;
+ InstResult = C;
LLVM_DEBUG(dbgs() << "Constant folded function call. Result: "
<< *InstResult << "\n");
} else {
@@ -544,10 +519,7 @@ bool Evaluator::EvaluateBlock(BasicBlock::iterator CurInst, BasicBlock *&NextBB,
return false;
}
ValueStack.pop_back();
- InstResult = castCallResultIfNeeded(CB.getType(), RetVal);
- if (RetVal && !InstResult)
- return false;
-
+ InstResult = RetVal;
if (InstResult) {
LLVM_DEBUG(dbgs() << "Successfully evaluated function. Result: "
<< *InstResult << "\n\n");
|
[
{
"file": "llvm/test/Transforms/GlobalOpt/evaluate-ret-void-mismatch.ll",
"commands": [
"opt -S -passes=globalopt < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n; Don't evaluate call with return value type mismatch.\n\n@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @__cxx_global_var_init, ptr null }]\n\ndefine void @__cxa_guard_acquire() {\n;\nentry:\n ret void\n}\n\ndefine void @__cxx_global_var_init() {\n;\n %res = call i32 @__cxa_guard_acquire()\n %tobool.not = icmp eq i32 %res, 0\n ret void\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "SIGSEGV with -flto",
"body": "Static linking with -flto on Arch linux with clang 18.1.8\n\nNot able to get a minimal repro at the moment. Other possibly less common options\n\n \"-std=c++20\",\n \"-nostdlib\",\n \"-nostartfiles\",\n \"-fno-exceptions\",\n \"-fno-rtti\",\n\nProgram terminated with signal SIGSEGV, Segmentation fault.\n#0 0x00007ee06170e69c in llvm::ConstantFoldConstant(llvm::Constant const*, llvm::DataLayout const&, llvm::TargetLibraryInfo const*) () from /usr/lib/libLLVM.so.18.1\n#0 0x00007ee06170e69c in llvm::ConstantFoldConstant(llvm::Constant const*, llvm::DataLayout const&, llvm::TargetLibraryInfo const*) () from /usr/lib/libLLVM.so.18.1\n#1 0x00007ee060abea1a in llvm::Evaluator::EvaluateBlock(llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void, true>, false, false>, llvm::BasicBlock*&, bool&) () from /usr/lib/libLLVM.so.18.1\n#2 0x00007ee060ac14e4 in llvm::Evaluator::EvaluateFunction(llvm::Function*, llvm::Constant*&, llvm::SmallVectorImpl<llvm::Constant*> const&) () from /usr/lib/libLLVM.so.18.1\n#3 0x00007ee061307930 in ?? () from /usr/lib/libLLVM.so.18.1\n#4 0x00007ee061308634 in ?? () from /usr/lib/libLLVM.so.18.1\n#5 0x00007ee060aa7649 in llvm::optimizeGlobalCtorsList(llvm::Module&, llvm::function_ref<bool (unsigned int, llvm::Function*)>) () from /usr/lib/libLLVM.so.18.1\n#6 0x00007ee0613135f9 in llvm::GlobalOptPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) () from /usr/lib/libLLVM.so.18.1\n#7 0x00007ee06411d177 in ?? () from /usr/lib/libLLVM.so.18.1\n#8 0x00007ee05fbd767e in llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) () from /usr/lib/libLLVM.so.18.1\n#9 0x00007ee061a57995 in ?? () from /usr/lib/libLLVM.so.18.1\n#10 0x00007ee061a591ff in llvm::lto::opt(llvm::lto::Config const&, llvm::TargetMachine*, unsigned int, llvm::Module&, bool, llvm::ModuleSummaryIndex*, llvm::ModuleSummaryIndex const*, std::vector<unsigned char, std::allocator<unsigned char> > const&) () from /usr/lib/libLLVM.so.18.1\n#11 0x00007ee061a5a582 in llvm::lto::backend(llvm::lto::Config const&, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream> > > (unsigned int, llvm::Twine const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex&) () from /usr/lib/libLLVM.so.18.1\n#12 0x00007ee061a4ed49 in llvm::lto::LTO::runRegularLTO(std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream> > > (unsigned int, llvm::Twine const&)>) () from /usr/lib/libLLVM.so.18.1\n#13 0x00007ee061a4f241 in llvm::lto::LTO::run(std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream> > > (unsigned int, llvm::Twine const&)>, std::function<llvm::Expected<std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream> > > (unsigned int, llvm::Twine const&)> > (unsigned int, llvm::StringRef, llvm::Twine const&)>) () from /usr/lib/libLLVM.so.18.1\n#14 0x00007ee0678ce067 in ?? () from /usr/bin/../lib/LLVMgold.so\n#15 0x00007ee0678cfd12 in ?? () from /usr/bin/../lib/LLVMgold.so\n#16 0x000056f827567837 in ?? ()\n#17 0x000056f82756f75f in ?? ()\n#18 0x00007ee067a00e08 in ?? () from /usr/lib/libc.so.6\n#19 0x00007ee067a00ecc in __libc_start_main () from /usr/lib/libc.so.6\n#20 0x000056f82756ea65 in ?? ()\n",
"author": "illiminable",
"labels": [
"incomplete",
"crash",
"LTO"
],
"comments": [
{
"author": "EugeneZelenko",
"body": "Could you please try 19 or `main` branch?"
},
{
"author": "illiminable",
"body": "I don't think 19 is packaged for arch yet. I'll see if I can build trunk later in the week.\n\nIs it possible to just to disable this optimizeGlobalCtorsList or all of globalopt. I looked through --hidden-help and could not see an option like this."
},
{
"author": "ms178",
"body": "@illiminable While it is not packaged by Arch yet, you could try the linked toolchain instead and use it via an environment variable which points llvm to the new path: https://mirrors.edge.kernel.org/pub/tools/llvm/"
},
{
"author": "illiminable",
"body": "OK thanks I'll try. FWIW this is the approximate code pattern. And presumably its trying to optimize the fact that there are N unique symbols that \"register\" assigns true to but then never get used.\n\n```\n// Header File\nclass Functor {\n virtual void execImpl() = 0;\n void exec() { execImpl(); }\n };\n \n class Info {\n Functor* fn = nullptr;\n };\n \n class Registry {\n array<Info, 1024> fns;\n int count = 0;\n \n void register(Info&& f) {\n fns[count++] = f;\n }\n \n void exec() {\n for i in 0..count { fns[i].fn->exec(); }\n }\n };\n \n inline Registry reg;\n \n inline bool register(Functor* fn) {\n reg.register({.fn = fn});\n return true;\n }\n \n \n // REPEAT approx 10 each copies of the below in 10 different .cpp TU's\n class _uniquesymbol_ : public Functor {\n void execImpl() override;\n };\n \n // Instance of the derived functor class\n _uniquesymbol_ _uniquesymbol__instance;\n \n // _uniquesymbol__flag is always true and never used. Theres probably a better\n // way to do this?\n const bool _uniquesymbol__flag = register(&_uniquesymbol__instance);\n \n void _uniquesymbol_::execImpl() {\n // do stuff\n }\n \n // END REPEAT\n \n \n // Usage...\n reg.exec();\n``` \n"
},
{
"author": "illiminable",
"body": "@ms178 The toolchain didn't work because it doesn't contain LLVMgold.so\n\nI was able to build from the 19.1.5 branch in debug and can repro. It's only on one target. This is the assert output\n\nld.gold: /mnt/local/src/third_party/github/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:109: static bool llvm::isa_impl_cl<To, const From*>::doit(const From*) [with To = llvm::ConstantVector; From = llvm::Constant]: Assertion `Val && \"isa<> used on a null pointer\"' failed.\n\nAnd a better symbolized stack\n\n#0 0x00007c11cae473f4 in ?? () from /usr/lib/libc.so.6\n#0 0x00007c11cae473f4 in ?? () from /usr/lib/libc.so.6\n#1 0x00007c11cadee120 in raise () from /usr/lib/libc.so.6\n#2 0x00007c11cadd54c3 in abort () from /usr/lib/libc.so.6\n#3 0x00007c11cadd53df in ?? () from /usr/lib/libc.so.6\n#4 0x00007c11cade6177 in __assert_fail () from /usr/lib/libc.so.6\n#5 0x00007c11c329c245 in llvm::isa_impl_cl<llvm::ConstantVector, llvm::Constant const*>::doit (Val=0x0) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:109\n#6 0x00007c11c329bd99 in llvm::isa_impl_wrap<llvm::ConstantVector, llvm::Constant const*, llvm::Constant const*>::doit (Val=@0x7ffd009f71a0: 0x0) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:137\n#7 0x00007c11c329b45b in llvm::isa_impl_wrap<llvm::ConstantVector, llvm::Constant const* const, llvm::Constant const*>::doit (Val=@0x7ffd009f71f0: 0x0) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:129\n#8 0x00007c11c329a6b6 in llvm::CastIsPossible<llvm::ConstantVector, llvm::Constant const*, void>::isPossible (f=@0x7ffd009f71f0: 0x0) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:257\n#9 0x00007c11c5ccd903 in llvm::CastInfo<llvm::ConstantVector, llvm::Constant const* const, void>::isPossible (f=@0x7ffd009f7248: 0x0) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:509\n#10 0x00007c11c5ccd3d8 in llvm::isa<llvm::ConstantVector, llvm::Constant const*> (Val=@0x7ffd009f7248: 0x0) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:549\n#11 0x00007c11c5f8be6e in (anonymous namespace)::ConstantFoldConstantImpl (C=0x0, DL=..., TLI=0x5d4a86076c38, FoldedOps=...) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/Analysis/ConstantFolding.cpp:1078\n#12 0x00007c11c5f8c5d3 in llvm::ConstantFoldConstant (C=0x0, DL=..., TLI=0x5d4a86076c38) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/Analysis/ConstantFolding.cpp:1163\n#13 0x00007c11c5cb7bdc in llvm::Evaluator::EvaluateBlock (this=0x7ffd009f7930, CurInst=..., NextBB=@0x7ffd009f76e0: 0x0, StrippedPointerCastsForAliasAnalysis=@0x7ffd009f76d0: false) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/Transforms/Utils/Evaluator.cpp:610\n#14 0x00007c11c5cb7fd8 in llvm::Evaluator::EvaluateFunction (this=0x7ffd009f7930, F=0x5d4a85ccc618, RetVal=@0x7ffd009f78a8: 0x7ffd009f7ae0, ActualArgs=...) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/Transforms/Utils/Evaluator.cpp:660\n#15 0x00007c11c4f410a8 in EvaluateStaticConstructor (F=0x5d4a85ccc618, DL=..., TLI=0x5d4a86076c38) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp:2080\n#16 0x00007c11c4f42bf7 in operator() (__closure=0x7ffd009f7e90, Priority=65535, F=0x5d4a85ccc618) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp:2524\n#17 0x00007c11c4f43f3b in llvm::function_ref<bool(unsigned int, llvm::Function*)>::callback_fn<optimizeGlobalsInModule(llvm::Module&, const llvm::DataLayout&, llvm::function_ref<llvm::TargetLibraryInfo&(llvm::Function&)>, llvm::function_ref<llvm::TargetTransformInfo&(llvm::Function&)>, llvm::function_ref<llvm::BlockFrequencyInfo&(llvm::Function&)>, llvm::function_ref<llvm::DominatorTree&(llvm::Function&)>, llvm::function_ref<void(llvm::Function&)>, llvm::function_ref<void(llvm::Function&)>)::<lambda(uint32_t, llvm::Function*)> >(intptr_t, unsigned int, llvm::Function *) (callable=140724613906064, params#0=65535, params#1=0x5d4a85ccc618) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45\n#18 0x00007c11c5c95103 in llvm::function_ref<bool(unsigned int, llvm::Function*)>::operator() (this=0x7ffd009f7cc0, params#0=65535, params#1=0x5d4a85ccc618) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68\n#19 0x00007c11c5c92754 in llvm::optimizeGlobalCtorsList (M=..., ShouldRemove=...) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/Transforms/Utils/CtorUtils.cpp:138\n#20 0x00007c11c4f4309c in optimizeGlobalsInModule(llvm::Module &, const llvm::DataLayout &, llvm::function_ref<llvm::TargetLibraryInfo&(llvm::Function&)>, llvm::function_ref<llvm::TargetTransformInfo&(llvm::Function&)>, llvm::function_ref<llvm::BlockFrequencyInfo&(llvm::Function&)>, llvm::function_ref<llvm::DominatorTree&(llvm::Function&)>, llvm::function_ref<void(llvm::Function&)>, llvm::function_ref<void(llvm::Function&)>) (M=..., DL=..., GetTLI=..., GetTTI=..., GetBFI=..., LookupDomTree=..., ChangedCFGCallback=..., DeleteFnCallback=...) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp:2520\n#21 0x00007c11c4f435e0 in llvm::GlobalOptPass::run (this=0x5d4a85c13138, M=..., AM=...) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp:2583\n#22 0x00007c11c4366477 in llvm::detail::PassModel<llvm::Module, llvm::GlobalOptPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (this=0x5d4a85c13130, IR=..., AM=...) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:90\n#23 0x00007c11c6e2f349 in llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (this=0x7ffd009f8300, IR=..., AM=...) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/include/llvm/IR/PassManagerImpl.h:81\n#24 0x00007c11c3934968 in runNewPMPasses (Conf=..., Mod=..., TM=0x5d4a85edf0b0, OptLevel=3, IsThinLTO=false, ExportSummary=0x5d4a85bc6d18, ImportSummary=0x0) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/LTO/LTOBackend.cpp:338\n#25 0x00007c11c3934b94 in llvm::lto::opt (Conf=..., TM=0x5d4a85edf0b0, Task=0, Mod=..., IsThinLTO=false, ExportSummary=0x5d4a85bc6d18, ImportSummary=0x0, CmdArgs=std::vector of length 0, capacity 0) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/LTO/LTOBackend.cpp:363\n#26 0x00007c11c3936054 in llvm::lto::backend (C=..., AddStream=..., ParallelCodeGenParallelismLevel=1, Mod=..., CombinedIndex=...) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/LTO/LTOBackend.cpp:517\n#27 0x00007c11c38e855d in llvm::lto::LTO::runRegularLTO (this=0x5d4a85bc6710, AddStream=...) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/LTO/LTO.cpp:1354\n#28 0x00007c11c38e746b in llvm::lto::LTO::run (this=0x5d4a85bc6710, AddStream=..., Cache=...) at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/lib/LTO/LTO.cpp:1186\n#29 0x00007c11c3255536 in runLTO () at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/tools/gold/gold-plugin.cpp:1111\n#30 0x00007c11c3255a0d in allSymbolsReadHook () at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/tools/gold/gold-plugin.cpp:1148\n#31 0x00007c11c3255c19 in all_symbols_read_hook () at /mnt/local/src/third_party/github/llvm/llvm-project/llvm/tools/gold/gold-plugin.cpp:1173\n#32 0x00005d4a6c4d9154 in ?? ()\n#33 0x00005d4a6c5138d0 in ?? ()\n#34 0x00005d4a6c3fc49a in ?? ()\n#35 0x00007c11cadd6e08 in ?? () from /usr/lib/libc.so.6\n#36 0x00007c11cadd6ecc in __libc_start_main () from /usr/lib/libc.so.6\n#37 0x00005d4a6c3ff985 in ?? ()"
},
{
"author": "ms178",
"body": "@illiminable Thanks for letting me know. Unfortunately I am not a developer and cannot help you to debug this problem further."
},
{
"author": "illiminable",
"body": "I debugged a little bit, but I don't fully understand this code.\n\nIn EvaluateBlock the issue is that after the various branches the code falls out to this block at 609 with InstResult still null. All the other branches usually check InstResult and return false. ConstantFoldConstant will assert or crash if the first parameter is null in the call from 610. I also tried just guarding this conditino with !InstResult but that doesn't seem right since it triggers another assert later \"Assertion `R && \"Reference to an uncomputed value!\"'.\n\nhttps://github.com/llvm/llvm-project/blob/llvmorg-19.1.5/llvm/lib/Transforms/Utils/Evaluator.cpp#L610\n\nThe bug only only occurs when the code hits the branch on 556. Strangely the debug log here says both branches of the if are success. I don't know if it's a copy paste error or if maybe the code should just return true after 558, but given the rest of the code this doesn't seem right.\n\nBut returning false in the line 556 branch seems to fix the crash and the resulting program seems to work fine.\n\nhttps://github.com/llvm/llvm-project/blob/llvmorg-19.1.5/llvm/lib/Transforms/Utils/Evaluator.cpp#L556\n\nSomeone who understands the code better should evaluate though.\n"
},
{
"author": "illiminable",
"body": "I used llvm-reduce to reduce the bitcode and when i looked at what was left it was basically __cxa_guard_acquire and I realized that while bootstrapping i defined it with the wrong return type. So since I violated the ABI I guess my fault.\n\nNot sure if there is still an underlying issue here someone wants to fix. ie. would be better to error or ignore than crash. But it seems pretty unlikely someone else will hit at least this specific cause of the problem.\n\nCan probably close if this corner case is not important."
},
{
"author": "nikic",
"body": "Could you please share the reduced bitcode? (Or IR after running it through llvm-dis.)"
},
{
"author": "illiminable",
"body": "[reduced.zip](https://github.com/user-attachments/files/18043521/reduced.zip)\n\nThis is the reduced.bc\n\n"
}
]
}
| true |
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
| null |
106417
|
https://github.com/llvm/llvm-project/issues/106417
|
crash
|
66927fb95abef9327b453d7213c5df7d641269be
| 2024-08-28T16:21:38 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "c4906588ce47de33d59bcd95f3e82ce2c3e61c23",
"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": [
[
7113,
7119
],
[
7121,
7126
]
],
"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::precomputeCosts"
],
"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 c4906588ce47de33d59bcd95f3e82ce2c3e61c23
Author: Florian Hahn <flo@fhahn.com>
Date: Thu Aug 29 21:19:59 2024 +0100
[VPlan] Use skipCostComputation when pre-computing induction costs.
This ensures we skip any instructions identified to be ignored by the
legacy cost model as well. Fixes a divergence between legacy and
VPlan-based cost model.
Fixes https://github.com/llvm/llvm-project/issues/106417.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 4cc75e2e7546..6babfd1eee91 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7113,7 +7113,7 @@ LoopVectorizationPlanner::precomputeCosts(VPlan &Plan, ElementCount VF,
IVInsts.push_back(CI);
}
for (Instruction *IVInst : IVInsts) {
- if (!CostCtx.SkipCostComputation.insert(IVInst).second)
+ if (CostCtx.skipCostComputation(IVInst, VF.isVector()))
continue;
InstructionCost InductionCost = CostCtx.getLegacyCost(IVInst, VF);
LLVM_DEBUG({
@@ -7121,6 +7121,7 @@ LoopVectorizationPlanner::precomputeCosts(VPlan &Plan, ElementCount VF,
<< ": induction instruction " << *IVInst << "\n";
});
Cost += InductionCost;
+ CostCtx.SkipCostComputation.insert(IVInst);
}
}
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/RISCV/induction-costs.ll",
"commands": [
"opt -p loop-vectorize -S %s"
],
"tests": [
{
"test_name": "skip_free_iv_truncate",
"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 @skip_free_iv_truncate(i16 %x, ptr %A) #0 {\nentry:\n %x.i32 = sext i16 %x to i32\n %x.i64 = sext i16 %x to i64\n %invariant.gep = getelementptr i8, ptr %A, i64 -8\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ %x.i64, %entry ], [ %iv.next, %loop ]\n %iv.conv = phi i32 [ %x.i32, %entry ], [ %3, %loop ]\n %gep.i64 = getelementptr i64, ptr %A, i64 %iv\n %0 = load i64, ptr %gep.i64, align 8\n %1 = sext i32 %iv.conv to i64\n %gep.conv = getelementptr i64, ptr %invariant.gep, i64 %1\n %2 = load i64, ptr %gep.conv, align 8\n %gep.i16 = getelementptr i16, ptr %A, i64 %iv\n store i16 0, ptr %gep.i16, align 2\n %iv.next = add i64 %iv, 3\n %3 = trunc i64 %iv.next to i32\n %c = icmp slt i64 %iv, 99\n br i1 %c, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v,+zvl256b\" }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[VPlan] Assertion \" VPlan cost model and legacy cost model disagreed\"' failed.",
"body": "Tested using 190449a5d2a9ddfc2180dce11714a4443f0f29f0\r\n\r\nTestcase:\r\n```c\r\nchar a;\r\nextern short b[][6][6];\r\nshort c;\r\nlong d;\r\nlong *e, *f;\r\nvoid g(char h[][6]) {\r\n for (short i = d + 9; i < 4; i += 3) {\r\n a = ({ f[i]; }) < f[i - 1];\r\n for (int j = c; j; j = ({ h[5][i + 2]; }) ? e[i - 1] : 0)\r\n ;\r\n b[i][i][i] = 0;\r\n }\r\n}\r\n```\r\nhttps://godbolt.org/z/EGdEPbKad\r\n\r\nIR testcase:\r\n```llvm ir\r\n; ModuleID = 'reduced.bc'\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine void @g(i16 %0, i64 %indvars.iv52) #0 {\r\nentry:\r\n %conv146 = sext i16 %0 to i32\r\n %1 = sext i16 %0 to i64\r\n %invariant.gep = getelementptr i8, ptr null, i64 -8\r\n br label %for.body.us\r\n\r\nfor.body.us: ; preds = %for.body.us, %entry\r\n %indvars.iv521 = phi i64 [ %1, %entry ], [ %indvars.iv.next53, %for.body.us ]\r\n %conv149.us = phi i32 [ %conv146, %entry ], [ %5, %for.body.us ]\r\n %arrayidx.us = getelementptr i64, ptr null, i64 %indvars.iv521\r\n %2 = load i64, ptr %arrayidx.us, align 8\r\n %3 = sext i32 %conv149.us to i64\r\n %gep = getelementptr i64, ptr %invariant.gep, i64 %3\r\n %4 = load i64, ptr %gep, align 8\r\n %arrayidx31.us = getelementptr [0 x [6 x [6 x i16]]], ptr null, i64 0, i64 %indvars.iv521, i64 %indvars.iv52, i64 %indvars.iv52\r\n store i16 0, ptr %arrayidx31.us, align 2\r\n %indvars.iv.next53 = add i64 %indvars.iv521, 3\r\n %5 = trunc i64 %indvars.iv.next53 to i32\r\n %cmp.us = icmp slt i64 %indvars.iv521, 0\r\n br i1 %cmp.us, label %for.body.us, label %for.cond.for.cond.cleanup_crit_edge.split.us\r\n\r\nfor.cond.for.cond.cleanup_crit_edge.split.us: ; preds = %for.body.us\r\n ret void\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl256b,+zvl32b,+zvl64b,-b,-e,-experimental-smctr,-experimental-smmpm,-experimental-smnpm,-experimental-ssctr,-experimental-ssnpm,-experimental-sspm,-experimental-supm,-experimental-zacas,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-experimental-zvbc32e,-experimental-zvkgs,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssqosid,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\n```\r\n\r\nCommand/backtrace:\r\n```\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize -S reduced.ll\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/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.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize -S 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 \"g\"\r\n #0 0x0000640a195798f0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x30178f0)\r\n #1 0x0000640a19576d0f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x3014d0f)\r\n #2 0x0000640a19576e65 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007aac19442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007aac194969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007aac194969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007aac194969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x00007aac19442476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007aac194287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x00007aac1942871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x00007aac19439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x0000640a18546ac9 llvm::LoopVectorizationPlanner::computeBestVF() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1fe4ac9)\r\n#12 0x0000640a1855cedb llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1ffaedb)\r\n#13 0x0000640a1855fef1 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1ffdef1)\r\n#14 0x0000640a18560567 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1ffe567)\r\n#15 0x0000640a173c0a96 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+0xe5ea96)\r\n#16 0x0000640a19384d4f 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+0x2e22d4f)\r\n#17 0x0000640a173c3c26 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+0xe61c26)\r\n#18 0x0000640a19383acb llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e21acb)\r\n#19 0x0000640a173bfec6 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+0xe5dec6)\r\n#20 0x0000640a19381b0d 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+0x2e1fb0d)\r\n#21 0x0000640a16be9da6 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+0x687da6)\r\n#22 0x0000640a16bdbb31 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x679b31)\r\n#23 0x00007aac19429d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#24 0x00007aac19429e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#25 0x00007aac19429e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#26 0x0000640a16bd1ee5 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x66fee5)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\nhttps://godbolt.org/z/W3KqbcKrb\r\n\r\nFound via fuzzer\r\nRelated/prior issue: #104714\r\n\r\ncc @fhahn ",
"author": "patrick-rivos",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
99411
|
https://github.com/llvm/llvm-project/issues/99411
|
crash
|
cb3de24b5c0a662ba4a03c6c06a2d765d558bf62
| 2024-07-18T00:03:03 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "b634e057ddecc41dce046887d0f0854fed305374",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
11852,
11859
]
],
"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": [
"castToScalarTyElem"
],
"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 b634e057ddecc41dce046887d0f0854fed305374
Author: Han-Kuan Chen <hankuan.chen@sifive.com>
Date: Thu Jul 18 19:54:46 2024 +0800
[SLP][REVEC] Fix false assumption of the source for castToScalarTyElem. (#99424)
The argument V may come from adjustExtracts, which is the vector operand
of ExtractElementInst. In addition, it is not existed in getTreeEntry.
The vector operand of ExtractElementInst may have a type of <1 x Ty>,
ensuring that the number of elements in ScalarTy and VecTy are equal.
reference: https://github.com/llvm/llvm-project/issues/99411
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index d88c6307b994..b994645cece6 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -11852,8 +11852,7 @@ class BoUpSLP::ShuffleInstructionBuilder final : public BaseShuffleAnalysis {
Value *castToScalarTyElem(Value *V,
std::optional<bool> IsSigned = std::nullopt) {
auto *VecTy = cast<VectorType>(V->getType());
- assert(getNumElements(ScalarTy) < getNumElements(VecTy) &&
- (getNumElements(VecTy) % getNumElements(ScalarTy) == 0));
+ assert(getNumElements(VecTy) % getNumElements(ScalarTy) == 0);
if (VecTy->getElementType() == ScalarTy->getScalarType())
return V;
return Builder.CreateIntCast(
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/revec-fix-99411.ll",
"commands": [
"opt -mtriple x86_64-unknown-linux-gnu -passes=slp-vectorizer -S %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @e() {\n;\nentry:\n %0 = extractelement <1 x i64> zeroinitializer, i64 0\n %bf.value = and i64 %0, 0\n %bf.set = or i64 0, %bf.value\n store i64 %bf.set, ptr getelementptr inbounds (i8, ptr null, i64 8), align 8\n %bf.value2 = and i64 0, 0\n %bf.set4 = or i64 0, %bf.value2\n store i64 %bf.set4, ptr null, align 8\n ret void\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "A/F: `getNumElements(ScalarTy) < getNumElements(VecTy) && (getNumElements(VecTy) % getNumElements(ScalarTy) == 0)' failed after 1813ffd",
"body": "Several of our internal tests started hitting an assertion failure while building, one of which I bisected back to commit 1813ffd. Consider the following code:\r\n```c++\r\ntypedef long long __m64 __attribute__((__vector_size__(8), __aligned__(8)));\r\nstatic __inline__ long long foo(__m64 m) { return (long long) m; }\r\nstruct c {\r\n long a : 43;\r\n long b : 61;\r\n} d;\r\nvoid e() {\r\n volatile __m64 f;\r\n long g, i = d.b = g = foo(f);\r\n d.a = i;\r\n}\r\n```\r\nWhen compiled with optimizations with a compiler that includes 1813ffd, it hits an assertion failure:\r\n```\r\n$ ~/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang -c -O2 repro.cpp \r\nclang: /home/dyung/src/upstream/llvm_clean_git/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:11853: llvm::Value* llvm::slpvectorizer::BoUpSLP::ShuffleInstructionBuilder::castToScalarTyElem(llvm::Value*, std::optional<bool>): Assertion `getNumElements(ScalarTy) < getNumElements(VecTy) && (getNumElements(VecTy) % getNumElements(ScalarTy) == 0)' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0. Program arguments: /home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang -c -O2 repro.cpp\r\n1. <eof> parser at end of file\r\n2. Optimizer\r\n3. Running pass \"function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>)\" on module \"repro.cpp\" \r\n4. Running pass \"slp-vectorizer\" on function \"_Z7test119v\"\r\n #0 0x00005650f775179f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x41a279f) \r\n #1 0x00005650f774f2fc llvm::sys::CleanupOnSignal(unsigned long) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x41a02fc) \r\n #2 0x00005650f76947e8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0 \r\n #3 0x00007ff89a3f9420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420) \r\n #4 0x00007ff899ec600b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1 \r\n #5 0x00007ff899ea5859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7 \r\n #6 0x00007ff899ea5729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8 \r\n #7 0x00007ff899ea5729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34 \r\n #8 0x00007ff899eb6fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6) \r\n #9 0x00005650f903005c llvm::slpvectorizer::BoUpSLP::ShuffleInstructionBuilder::castToScalarTyElem(llvm::Value*, std::optional<bool>) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5a8105c)\r\n#10 0x00005650f9071f00 llvm::slpvectorizer::BoUpSLP::ShuffleInstructionBuilder::adjustExtracts(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::MutableArrayRef<int>, llvm::ArrayRef<std::optional<llvm::TargetTransformInfo::ShuffleKind>>, unsigned int, bool&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5ac2f00) \r\n#11 0x00005650f909dfdd llvm::Value* llvm::slpvectorizer::BoUpSLP::processBuildVector<llvm::slpvectorizer::BoUpSLP::ShuffleInstructionBuilder, llvm::Value*, llvm::IRBuilder<llvm::TargetFolder, llvm::IRBuilderDefaultInserter>, llvm::slpvectorizer::BoUpSLP>(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::Type*, llvm::IRBuilder<llvm::TargetFolder, llvm::IRBuilderDefaultInserter>&, llvm::slpvectorizer::BoUpSLP&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5aeefdd)\r\n#12 0x00005650f90a941a llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5afa41a)\r\n#13 0x00005650f90a80e3 llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5af90e3)\r\n#14 0x00005650f90a9484 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5afa484)\r\n#15 0x00005650f90a7cdf llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5af8cdf)\r\n#16 0x00005650f90ac099 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5afd099)\r\n#17 0x00005650f90a7cdf llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5af8cdf)\r\n#18 0x00005650f90a9e6c llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5afae6c)\r\n#19 0x00005650f90c7263 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::MapVector<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>, llvm::DenseMap<llvm::Value*, unsigned int, llvm::DenseMapInfo<llvm::Value*, void>, llvm::detail::DenseMapPair<llvm::Value*, unsigned int>>, llvm::SmallVector<std::pair<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>>, 0u>> const&, llvm::SmallVectorImpl<std::pair<llvm::Value*, llvm::Value*>>&, llvm::Instruction*) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5b18263)\r\n#20 0x00005650f90cacbc llvm::slpvectorizer::BoUpSLP::vectorizeTree() (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5b1bcbc)\r\n#21 0x00005650f90e045b llvm::SLPVectorizerPass::vectorizeStoreChain(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, unsigned int, unsigned int, unsigned int&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5b3145b) \r\n#22 0x00005650f90e1a5e llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&)::'lambda'(std::set<std::pair<unsigned int, int>, llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&)::StoreDistCompare, std::allocator<std::pair<unsigned int, int>>> const&)::operator()(std::set<std::pair<unsigned int, int>, llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&)::StoreDistCompare, std::allocator<std::pair<unsigned int, int>>> const&) const SLPVectorizer.cpp:0:0\r\n#23 0x00005650f90e39a0 llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5b349a0)\r\n#24 0x00005650f90e42c3 llvm::SLPVectorizerPass::vectorizeStoreChains(llvm::slpvectorizer::BoUpSLP&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5b352c3)\r\n#25 0x00005650f90e57dd llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\r\n#26 0x00005650f90e6253 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x5b37253)\r\n#27 0x00005650f8baedb6 llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x55ffdb6)\r\n#28 0x00005650f70f6421 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x3b47421)\r\n#29 0x00005650f4cb9ca6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x170aca6)\r\n#30 0x00005650f70f4ded llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x3b45ded)\r\n#31 0x00005650f4cbac56 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x170bc56)\r\n#32 0x00005650f70f2f31 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x3b43f31)\r\n#33 0x00005650f7a062c8 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#34 0x00005650f7a09645 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#35 0x00005650f7a09ce6 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x445ace6)\r\n#36 0x00005650f808091c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x4ad191c)\r\n#37 0x00005650f9e7fe6c clang::ParseAST(clang::Sema&, bool, bool) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x68d0e6c)\r\n#38 0x00005650f8080d28 clang::CodeGenAction::ExecuteAction() (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x4ad1d28)\r\n#39 0x00005650f8318339 clang::FrontendAction::Execute() (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x4d69339)\r\n#40 0x00005650f829a98e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x4ceb98e)\r\n#41 0x00005650f8403dc6 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x4e54dc6)\r\n#42 0x00005650f489f105 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x12f0105)\r\n#43 0x00005650f489811a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#44 0x00005650f80c610d void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0\r\n#45 0x00005650f7694cf0 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x40e5cf0)\r\n#46 0x00005650f80c672f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0\r\n#47 0x00005650f808aa6c clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x4adba6c)\r\n#48 0x00005650f808b4fd clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x4adc4fd)\r\n#49 0x00005650f80935d5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x4ae45d5)\r\n#50 0x00005650f489c37b clang_main(int, char**, llvm::ToolContext const&) (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x12ed37b)\r\n#51 0x00005650f478ee1b main (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x11dfe1b)\r\n#52 0x00007ff899ea7083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#53 0x00005650f4897bae _start (/home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin/clang+0x12e8bae)\r\nclang: error: clang frontend command failed with exit code 134 (use -v to see invocation)\r\nclang version 19.0.0 (https://github.com/llvm/llvm-project.git 1813ffd6b2eb04ee2c296a4399a18748740a439d)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /home/dyung/src/upstream/1813ffd6b2eb04ee2c296a4399a18748740a439d-linux/bin\r\nBuild config: +assertions\r\n```\r\nIf built using the a compiler built from fa0e529 (the parent commit of 1813ffd), the compilation succeeds:\r\n```\r\n$ ~/src/upstream/fa0e52995929ab67dfb468d71fe793be5e1c7f03-linux/bin/clang -c -O2 repro.cpp\r\n$\r\n```\r\n",
"author": "dyung",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": [
{
"author": "madhur13490",
"body": "@dyung https://godbolt.org/z/ofneqo6zK I don't see here. Am I missing anything?"
},
{
"author": "dyung",
"body": "> @dyung https://godbolt.org/z/ofneqo6zK I don't see here. Am I missing anything?\r\n\r\nI don't know if it reproduces on an ARM targeting compiler, I used an x86-64 targeting x86-64 compiler. Also the compiler currently used by godbolt was built from commit f56cdd4a45b7bbe84be5d4ba9442eb7071605efc which does not include 1813ffd6b2eb04ee2c296a4399a18748740a439d which introduced the issue."
},
{
"author": "HanKuanChen",
"body": "Close the issue since https://github.com/llvm/llvm-project/commit/b634e057ddecc41dce046887d0f0854fed305374 is merged."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
127128
|
https://github.com/llvm/llvm-project/issues/127128
|
crash
|
1ff5f328d9824694cc356ebf78adad8816a6de86
| 2025-02-13T20:59:01 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "ac217ee389d63124432e5e6890851a678f7a676b",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
13206,
13213
]
],
"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 ac217ee389d63124432e5e6890851a678f7a676b
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Thu Feb 13 14:19:51 2025 -0800
[SLP] Check for PHI nodes (potentially cycles!) when checking dependencies
When checking for dependecies for gather nodes with users with the same
last instruction, cannot rely on the index order, if there is (even
potential!) cycle in the graph, which may cause order not work correctly
and cause compiler crash.
Fixes #127128
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index fb72a112b9ac..780cafe91d6b 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -13206,8 +13206,16 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
continue;
// If the user instruction is used for some reason in different
// vectorized nodes - make it depend on index.
+ // If any vector node is PHI node, this dependency might not work
+ // because of cycle dependencies, so disable it.
if (TEUseEI.UserTE != UseEI.UserTE &&
- TEUseEI.UserTE->Idx < UseEI.UserTE->Idx)
+ (TEUseEI.UserTE->Idx < UseEI.UserTE->Idx ||
+ any_of(
+ VectorizableTree,
+ [](const std::unique_ptr<TreeEntry> &TE) {
+ return TE->State == TreeEntry::Vectorize &&
+ TE->getOpcode() == Instruction::PHI;
+ })))
continue;
}
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/delayed-gather-emission.ll",
"commands": [
"opt -passes=slp-vectorizer -mtriple=x86_64 -mattr=+avx2 -S < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define void @test() {\nentry:\n %.pre.pre = load float, ptr poison, align 4\n br label %bb1\n\nbb1: ; preds = %bb2, %entry\n %.pre = phi float [ %.pre.pre, %entry ], [ %i2, %bb2 ]\n %foxtrot.0 = phi float [ undef, %entry ], [ %gulf.0, %bb2 ]\n br label %bb2\n\nbb2: ; preds = %bb2, %bb1\n %i = phi float [ %.pre, %bb1 ], [ %i2, %bb2 ]\n %gulf.0 = phi float [ %foxtrot.0, %bb1 ], [ %div, %bb2 ]\n %div = fdiv float %i, %gulf.0\n %i1 = load float, ptr poison, align 4\n %div1 = fdiv float %gulf.0, %i1\n %mul = fmul float %div, %div1\n tail call void @foo(float %mul)\n %i2 = load float, ptr poison, align 4\n %tobool = fcmp une float %i2, 0.000000e+00\n br i1 %tobool, label %bb1, label %bb2\n}\n\ndeclare void @foo(float)\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/phi-node-with-cycle.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -mcpu=haswell < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @test(float %0) {\n;\n %2 = fdiv float 0.000000e+00, 0.000000e+00\n %3 = fdiv float 0.000000e+00, 0.000000e+00\n %4 = fdiv float %0, 0.000000e+00\n br label %5\n\n5:\n %6 = fmul float %4, 0.000000e+00\n %7 = fsub float 0.000000e+00, %6\n %8 = fmul float %3, 0.000000e+00\n %9 = fsub float 0.000000e+00, %8\n br label %11\n\n10:\n br label %11\n\n11:\n %12 = phi float [ %7, %5 ], [ 0.000000e+00, %10 ]\n %13 = phi float [ %9, %5 ], [ 0.000000e+00, %10 ]\n br label %14\n\n14:\n %15 = fmul float %2, 0.000000e+00\n %16 = fsub float %12, %15\n %17 = fmul float %4, 0.000000e+00\n %18 = fsub float %13, %17\n %19 = fadd float %16, %18\n %20 = call float @llvm.fabs.f32(float %19)\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "SLPVectorizer miscompilation",
"body": "```llvm\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:10:11:12:13\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine swiftcc { ptr addrspace(10), i8 } @julia__dir2ori_404(float %0) {\n %2 = fdiv float 0.000000e+00, 0.000000e+00\n %3 = fdiv float 0.000000e+00, 0.000000e+00\n %4 = fdiv float %0, 0.000000e+00\n br label %5\n\n5: ; preds = %1\n %6 = fmul float %4, 0.000000e+00\n %7 = fsub float 0.000000e+00, %6\n %8 = fmul float %3, 0.000000e+00\n %9 = fsub float 0.000000e+00, %8\n br label %11\n\n10: ; No predecessors!\n br label %11\n\n11: ; preds = %10, %5\n %12 = phi float [ %7, %5 ], [ 0.000000e+00, %10 ]\n %13 = phi float [ %9, %5 ], [ 0.000000e+00, %10 ]\n br label %14\n\n14: ; preds = %11\n %15 = fmul float %2, 0.000000e+00\n %16 = fsub float %12, %15\n %17 = fmul float %4, 0.000000e+00\n %18 = fsub float %13, %17\n %19 = fadd float %16, %18\n %20 = call float @llvm.fabs.f32(float %19)\n ret { ptr addrspace(10), i8 } zeroinitializer\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.fabs.f32(float) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n```\nproduces \n```\nInstruction does not dominate all uses!\n %4 = insertelement <2 x float> <float poison, float 0.000000e+00>, float %0, i32 0\n %2 = shufflevector <2 x float> %4, <2 x float> <float 0.000000e+00, float poison>, <2 x i32> <i32 2, i32 0>\nLLVM ERROR: Broken module found, compilation aborted!\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer -mcpu=haswell <source>\n1.\tRunning pass \"verify\" on module \"<source>\"\n #0 0x00000000054edec8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x54edec8)\n #1 0x00000000054eb884 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007faaea842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007faaea8969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007faaea842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007faaea8287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x000000000082790d llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0\n #7 0x000000000542b6e8 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x542b6e8)\n #8 0x0000000005329278 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5329278)\n #9 0x000000000095605e llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x95605e)\n#10 0x00000000052e7b50 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x52e7b50)\n#11 0x000000000096174a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x96174a)\n#12 0x0000000000953c7c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x953c7c)\n#13 0x00007faaea829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#14 0x00007faaea829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#15 0x000000000094b555 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x94b555)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```\non 19 and trunk.\nGodbolt: https://godbolt.org/z/qxKP6198T",
"author": "Zentrik",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid"
],
"comments": [
{
"author": "Zentrik",
"body": "Bisected thanks to manyclangs to 66775f8ccdcc8264ef349518e1c59d96d4227823 (8e2b2c4181506efc5b9321c203dd107bbd63392b seemed to be good) @alexey-bataev"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
124267
|
https://github.com/llvm/llvm-project/issues/124267
|
miscompilation
|
9cf52fe1f94fdcd8e27c76f7d33a80eeb2075833
| 2025-01-24T13:05:38 |
[
"llvm/test/Analysis/ValueTracking"
] |
{
"fix_commit": "c546b5317c518987a5f45dd4c4d25321a955c758",
"components": [
"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": [
[
9494,
9500
],
[
9504,
9510
]
],
"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": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": [
"isImpliedCondICmps"
],
"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 c546b5317c518987a5f45dd4c4d25321a955c758
Author: DianQK <dianqk@dianqk.net>
Date: Fri Jan 24 23:02:50 2025 +0800
[ValueTracking] Pass changed predicate `SignedLPred` to `isImpliedByMatchingCmp` (#124271)
Fixes #124267.
Since we are using the new predicate, we should also update the
parameters of `isImpliedByMatchingCmp`.
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 264fedd6b66b..eba728c7c8c3 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -9494,7 +9494,7 @@ isImpliedCondICmps(const ICmpInst *LHS, CmpPredicate RPred, const Value *R0,
SignedLPred == ICmpInst::ICMP_SGE) &&
match(R0, m_NSWSub(m_Specific(L0), m_Specific(L1)))) {
if (match(R1, m_NonPositive()) &&
- ICmpInst::isImpliedByMatchingCmp(LPred, RPred) == false)
+ ICmpInst::isImpliedByMatchingCmp(SignedLPred, RPred) == false)
return false;
}
@@ -9504,7 +9504,7 @@ isImpliedCondICmps(const ICmpInst *LHS, CmpPredicate RPred, const Value *R0,
SignedLPred == ICmpInst::ICMP_SLE) &&
match(R0, m_NSWSub(m_Specific(L0), m_Specific(L1)))) {
if (match(R1, m_NonNegative()) &&
- ICmpInst::isImpliedByMatchingCmp(LPred, RPred) == true)
+ ICmpInst::isImpliedByMatchingCmp(SignedLPred, RPred) == true)
return true;
}
|
[
{
"file": "llvm/test/Analysis/ValueTracking/implied-condition-samesign.ll",
"commands": [
"opt -passes=instsimplify -S %s"
],
"tests": [
{
"test_name": "gt_sub_nsw_ult",
"test_body": "define i1 @gt_sub_nsw_ult(i8 %L0, i8 %L1, i1 %V) {\n %LHS = icmp samesign ugt i8 %L0, %L1\n br i1 %LHS, label %LHS_true, label %LHS_false\n\nLHS_true: ; preds = %0\n %R0 = sub nsw i8 %L0, %L1\n %RHS = icmp ult i8 %R0, -1\n ret i1 %RHS\n\nLHS_false: ; preds = %0\n ret i1 %V\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "lt_sub_nsw_ult",
"test_body": "define i1 @lt_sub_nsw_ult(i8 %L0, i8 %L1, i1 %V) {\n %LHS = icmp samesign ult i8 %L0, %L1\n br i1 %LHS, label %LHS_true, label %LHS_false\n\nLHS_true: ; preds = %0\n %R0 = sub nsw i8 %L0, %L1\n %RHS = icmp ult i8 %R0, 1\n ret i1 %RHS\n\nLHS_false: ; preds = %0\n ret i1 %V\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[ValueTracking] miscompile in samesign compare",
"body": "#122590 and #122700 miscompile the following code:\n\n```llvm\ndefine i1 @src(i8 %L0, i8 %L1, i1 %V) {\n %LHS = icmp samesign ugt i8 %L0, %L1\n %R0 = sub nsw i8 %L0, %L1\n %RHS = icmp ult i8 %R0, -1\n br i1 %LHS, label %LHS_true, label %LHS_false\n\nLHS_true:\n br label %EXIT\n\nLHS_false:\n br label %EXIT\n\nEXIT:\n %RET = phi i1 [ %RHS, %LHS_true ], [ %V, %LHS_false ]\n ret i1 %RET\n}\n```\n\n`%RHS` should be 1: https://alive2.llvm.org/ce/z/RscAzy.",
"author": "DianQK",
"labels": [
"miscompilation",
"llvm:analysis"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
134085
|
https://github.com/llvm/llvm-project/issues/134085
|
crash
|
f475ccd3794ebce22950b707ad390fae7e235b46
| 2025-04-02T13:46:38 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "843ef77dc22afd1923b891acd4c46c8f8c8c93ae",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
14335,
14341
],
[
14552,
14557
],
[
14596,
14601
]
],
"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 843ef77dc22afd1923b891acd4c46c8f8c8c93ae
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Wed Apr 2 11:44:36 2025 -0700
[SLP]Update mapping between values and their matching entries upon selection
Need to update the mapping between gathered values and their matching
entries, if the list of the entries is updated and only some of them are
selected for final shuffling.
Fixes #134085
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 838e952c024c..b82a66ca3b88 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -14335,7 +14335,7 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
// single vector. If we have 2 different sets, we're in situation where we
// have a permutation of 2 input vectors.
SmallVector<SmallPtrSet<const TreeEntry *, 4>> UsedTEs;
- DenseMap<Value *, int> UsedValuesEntry;
+ SmallDenseMap<Value *, int> UsedValuesEntry;
SmallPtrSet<const Value *, 16> VisitedValue;
auto CheckAndUseSameNode = [&](const TreeEntry *TEPtr) {
// The node is reused - exit.
@@ -14552,6 +14552,8 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
// No perfect match, just shuffle, so choose the first tree node from the
// tree.
Entries.push_back(FirstEntries.front());
+ // Update mapping between values and corresponding tree entries.
+ for_each(UsedValuesEntry, [&](auto &P) { P.second = 0; });
VF = FirstEntries.front()->getVectorFactor();
} else {
// Try to find nodes with the same vector factor.
@@ -14596,6 +14598,18 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
} else {
VF = Entries.front()->getVectorFactor();
}
+ SmallVector<SmallPtrSet<Value *, 8>> ValuesToEntries;
+ for (const TreeEntry *E : Entries)
+ ValuesToEntries.emplace_back().insert(E->Scalars.begin(),
+ E->Scalars.end());
+ // Update mapping between values and corresponding tree entries.
+ for_each(UsedValuesEntry, [&](auto &P) {
+ for (unsigned Idx : seq<unsigned>(ValuesToEntries.size()))
+ if (ValuesToEntries[Idx].contains(P.first)) {
+ P.second = Idx;
+ break;
+ }
+ });
}
bool IsSplatOrUndefs = isSplat(VL) || all_of(VL, IsaPred<UndefValue>);
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/matched-nodes-updated.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "target datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i32 @main(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; uselistorder directives\n uselistorder i32 %.pre4053, { 1, 0 }\n uselistorder i32 %i.7, { 1, 0 }\n}\n",
"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/nKW8o5f8a\n\n```\n[516] % clangtk -v\nclang version 21.0.0git (https://github.com/llvm/llvm-project.git 842785adf7349f07a91320d49ff8a10971e04409)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\nBuild config: +assertions\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\nCandidate multilib: .;@m64\nSelected multilib: .;@m64\n[517] % \n[517] % clangtk -O3 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 = const llvm::slpvectorizer::BoUpSLP::TreeEntry*; <template-parameter-1-2> = void; llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::reference = const llvm::slpvectorizer::BoUpSLP::TreeEntry*&; 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/20250402-clangtk-m64-O3-build-141643/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20250402-clangtk-m64-O3-build-141643/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 -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-1ffa5d.o -x c small.c\n1.\t<eof> parser at end of file\n2.\tOptimizer\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,chr,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"small.c\"\n4.\tRunning pass \"slp-vectorizer\" on function \"main\"\n #0 0x000055aa281b4bff llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x459bbff)\n #1 0x000055aa281b23b4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007f3259793420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\n #3 0x00007f32591ca00b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\n #4 0x00007f32591a9859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\n #5 0x00007f32591a9729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\n #6 0x00007f32591a9729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\n #7 0x00007f32591bafd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\n #8 0x000055aa29cd9e82 llvm::slpvectorizer::BoUpSLP::isGatherShuffledSingleRegisterEntry(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::MutableArrayRef<int>, llvm::SmallVectorImpl<llvm::slpvectorizer::BoUpSLP::TreeEntry const*>&, unsigned int, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60c0e82)\n #9 0x000055aa29cda9f8 llvm::slpvectorizer::BoUpSLP::isGatherShuffledEntry(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallVectorImpl<int>&, llvm::SmallVectorImpl<llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, 6u>>&, unsigned int, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60c19f8)\n#10 0x000055aa29cdb803 llvm::slpvectorizer::BoUpSLP::findReusedOrderedScalars(llvm::slpvectorizer::BoUpSLP::TreeEntry const&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60c2803)\n#11 0x000055aa29d11537 llvm::slpvectorizer::BoUpSLP::getReorderingData(llvm::slpvectorizer::BoUpSLP::TreeEntry const&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60f8537)\n#12 0x000055aa29d15fc6 llvm::slpvectorizer::BoUpSLP::reorderBottomToTop(bool) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x60fcfc6)\n#13 0x000055aa29d236d8 llvm::SLPVectorizerPass::tryToVectorizeList(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x610a6d8)\n#14 0x000055aa29d28bdd 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#15 0x000055aa29d2a5d1 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x61115d1)\n#16 0x000055aa29d3268e 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 0x000055aa29d33253 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x611a253)\n#18 0x000055aa2979da56 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+0x5b84a56)\n#19 0x000055aa27b29009 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+0x3f10009)\n#20 0x000055aa253f1e66 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+0x17d8e66)\n#21 0x000055aa27b27882 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x3f0e882)\n#22 0x000055aa253ef826 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+0x17d6826)\n#23 0x000055aa27b272a1 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+0x3f0e2a1)\n#24 0x000055aa28473351 (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 0x000055aa28476c41 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+0x485dc41)\n#26 0x000055aa28b92391 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x4f79391)\n#27 0x000055aa2a56658c clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x694d58c)\n#28 0x000055aa28b927c8 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x4f797c8)\n#29 0x000055aa28e8fcb9 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5276cb9)\n#30 0x000055aa28e0f98e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x51f698e)\n#31 0x000055aa28f86ae6 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x536dae6)\n#32 0x000055aa24f83afd cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x136aafd)\n#33 0x000055aa24f7b08a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#34 0x000055aa24f7f312 clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x1366312)\n#35 0x000055aa24e62f8b main (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x1249f8b)\n#36 0x00007f32591ab083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\n#37 0x000055aa24f7ab1e _start (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x1361b1e)\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 842785adf7349f07a91320d49ff8a10971e04409)\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-a83f08.c\nclangtk: note: diagnostic msg: /tmp/small-a83f08.sh\nclangtk: note: diagnostic msg: \n\n********************\n[518] % \n[518] % cat small.c\nint printf(const char *, ...);\nint a, b, c, d;\nint main() {\n int g = 1, h = 0, i, j;\nk:\n if (g) {\n int l = a, n;\n m:\n n = d;\n if (n)\n goto o;\n j = l;\n }\n int p = a / ~b;\n if (g)\n q:\n b = a;\n c = p;\n int r = g ? 0 : ~i, s = ~h;\n if (g) {\n r = j;\n if (b && 0 <= i) {\n if (h) {\n g = 0;\n goto m;\n }\n i = a = -a;\n if (a)\n printf(\"0\");\n t:\n j = 0;\n if (d)\n goto k;\n }\n }\n h = r;\n j = s;\n if (a) {\n o:\n if (a && i)\n goto t;\n goto q;\n }\n return 0;\n}\n```",
"author": "zhendongsu",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Reduced reproducer: https://godbolt.org/z/E7zsza3bT"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
130250
|
https://github.com/llvm/llvm-project/issues/130250
|
crash
|
3ed4daf9a749fe8590ad291f63fabce48fb4135f
| 2025-03-07T05:51:40 |
[
"llvm/test/Transforms/PhaseOrdering",
"llvm/test/Transforms/VectorCombine"
] |
{
"fix_commit": "0ee8f699780569d7a6b94d61cd833285bb67eca1",
"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": [
[
2037,
2043
],
[
2051,
2074
]
],
"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::foldShuffleOfSelects"
],
"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 0ee8f699780569d7a6b94d61cd833285bb67eca1
Author: hanbeom <kese111@gmail.com>
Date: Sat Mar 8 01:40:26 2025 +0900
[VectorCombine] Fix invalid shuffle cost argument of foldShuffleOfSelects (#130281)
In the previous code (#128032), it specified the destination vector as the
getShuffleCost argument. Because the shuffle mask specifies the indices
of the two vectors specified as elements, the maximum value is twice the
size of the source vector. This causes a problem if the destination
vector is smaller than the source vector and specify an index in the
mask that exceeds the size of the destination vector.
Fix the problem by correcting the previous code, which was using wrong
argument in the Cost calculation.
Fixes #130250
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index 4d4a1a6e04d3..019d79567b4a 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -2037,7 +2037,6 @@ bool VectorCombine::foldShuffleOfSelects(Instruction &I) {
m_Mask(Mask))))
return false;
- auto *DstVecTy = dyn_cast<FixedVectorType>(I.getType());
auto *C1VecTy = dyn_cast<FixedVectorType>(C1->getType());
auto *C2VecTy = dyn_cast<FixedVectorType>(C2->getType());
if (!C1VecTy || !C2VecTy || C1VecTy != C2VecTy)
@@ -2051,24 +2050,26 @@ bool VectorCombine::foldShuffleOfSelects(Instruction &I) {
(SI0FOp->getFastMathFlags() != SI1FOp->getFastMathFlags())))
return false;
+ auto *SrcVecTy = dyn_cast<FixedVectorType>(T1->getType());
+ auto *DstVecTy = dyn_cast<FixedVectorType>(I.getType());
auto SK = TargetTransformInfo::SK_PermuteTwoSrc;
auto SelOp = Instruction::Select;
InstructionCost OldCost = TTI.getCmpSelInstrCost(
- SelOp, T1->getType(), C1VecTy, CmpInst::BAD_ICMP_PREDICATE, CostKind);
- OldCost += TTI.getCmpSelInstrCost(SelOp, T2->getType(), C2VecTy,
+ SelOp, SrcVecTy, C1VecTy, CmpInst::BAD_ICMP_PREDICATE, CostKind);
+ OldCost += TTI.getCmpSelInstrCost(SelOp, SrcVecTy, C2VecTy,
CmpInst::BAD_ICMP_PREDICATE, CostKind);
- OldCost += TTI.getShuffleCost(SK, DstVecTy, Mask, CostKind, 0, nullptr,
+ OldCost += TTI.getShuffleCost(SK, SrcVecTy, Mask, CostKind, 0, nullptr,
{I.getOperand(0), I.getOperand(1)}, &I);
- auto *C1C2VecTy = cast<FixedVectorType>(
- toVectorTy(Type::getInt1Ty(I.getContext()), DstVecTy->getNumElements()));
InstructionCost NewCost =
- TTI.getShuffleCost(SK, C1C2VecTy, Mask, CostKind, 0, nullptr, {C1, C2});
+ TTI.getShuffleCost(SK, C1VecTy, Mask, CostKind, 0, nullptr, {C1, C2});
NewCost +=
- TTI.getShuffleCost(SK, DstVecTy, Mask, CostKind, 0, nullptr, {T1, T2});
+ TTI.getShuffleCost(SK, SrcVecTy, Mask, CostKind, 0, nullptr, {T1, T2});
NewCost +=
- TTI.getShuffleCost(SK, DstVecTy, Mask, CostKind, 0, nullptr, {F1, F2});
- NewCost += TTI.getCmpSelInstrCost(SelOp, DstVecTy, DstVecTy,
+ TTI.getShuffleCost(SK, SrcVecTy, Mask, CostKind, 0, nullptr, {F1, F2});
+ auto *C1C2ShuffledVecTy = cast<FixedVectorType>(
+ toVectorTy(Type::getInt1Ty(I.getContext()), DstVecTy->getNumElements()));
+ NewCost += TTI.getCmpSelInstrCost(SelOp, DstVecTy, C1C2ShuffledVecTy,
CmpInst::BAD_ICMP_PREDICATE, CostKind);
LLVM_DEBUG(dbgs() << "Found a shuffle feeding two selects: " << I
|
[
{
"file": "llvm/test/Transforms/PhaseOrdering/X86/blendv-select.ll",
"commands": [
"opt < %s -O3 -S -mtriple=x86_64-- -mcpu=x86-64-v2",
"opt < %s -O3 -S -mtriple=x86_64-- -mcpu=x86-64-v3",
"opt < %s -O3 -S -mtriple=x86_64-- -mcpu=x86-64-v4"
],
"tests": [
{
"test_name": "x86_pblendvb_v8f32_v4f32",
"test_body": "define <8 x float> @x86_pblendvb_v8f32_v4f32(<8 x float> %a, <8 x float> %b, <8 x float> %c, <8 x float> %d) {\n %a.bc = bitcast <8 x float> %a to <32 x i8>\n %b.bc = bitcast <8 x float> %b to <32 x i8>\n %a.lo = shufflevector <32 x i8> %a.bc, <32 x i8> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>\n %b.lo = shufflevector <32 x i8> %b.bc, <32 x i8> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>\n %a.hi = shufflevector <32 x i8> %a.bc, <32 x i8> poison, <16 x i32> <i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %b.hi = shufflevector <32 x i8> %b.bc, <32 x i8> poison, <16 x i32> <i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %cmp = fcmp olt <8 x float> %c, %d\n %sext = sext <8 x i1> %cmp to <8 x i32>\n %sext.bc = bitcast <8 x i32> %sext to <32 x i8>\n %sext.lo = shufflevector <32 x i8> %sext.bc, <32 x i8> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>\n %sext.hi = shufflevector <32 x i8> %sext.bc, <32 x i8> poison, <16 x i32> <i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %sel.lo = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %a.lo, <16 x i8> %b.lo, <16 x i8> %sext.lo)\n %sel.hi = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %a.hi, <16 x i8> %b.hi, <16 x i8> %sext.hi)\n %concat = shufflevector <16 x i8> %sel.lo, <16 x i8> %sel.hi, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %res = bitcast <32 x i8> %concat to <8 x float>\n ret <8 x float> %res\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)\ndeclare <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8>, <16 x i8>, <16 x i8>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "x86_pblendvb_v32i16_v16i16",
"test_body": "define <8 x i64> @x86_pblendvb_v32i16_v16i16(<8 x i64> %a, <8 x i64> %b, <8 x i64> %c, <8 x i64> %d) {\n %a.bc = bitcast <8 x i64> %a to <64 x i8>\n %b.bc = bitcast <8 x i64> %b to <64 x i8>\n %c.bc = bitcast <8 x i64> %c to <32 x i16>\n %d.bc = bitcast <8 x i64> %d to <32 x i16>\n %a.lo = shufflevector <64 x i8> %a.bc, <64 x i8> poison, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %b.lo = shufflevector <64 x i8> %b.bc, <64 x i8> poison, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %a.hi = shufflevector <64 x i8> %a.bc, <64 x i8> poison, <32 x i32> <i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62, i32 63>\n %b.hi = shufflevector <64 x i8> %b.bc, <64 x i8> poison, <32 x i32> <i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62, i32 63>\n %cmp = icmp slt <32 x i16> %c.bc, %d.bc\n %sext = sext <32 x i1> %cmp to <32 x i16>\n %sext.bc = bitcast <32 x i16> %sext to <64 x i8>\n %sext.lo = shufflevector <64 x i8> %sext.bc, <64 x i8> poison, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %sext.hi = shufflevector <64 x i8> %sext.bc, <64 x i8> poison, <32 x i32> <i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62, i32 63>\n %sel.lo = tail call <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8> %a.lo, <32 x i8> %b.lo, <32 x i8> %sext.lo)\n %sel.hi = tail call <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8> %a.hi, <32 x i8> %b.hi, <32 x i8> %sext.hi)\n %concat = shufflevector <32 x i8> %sel.lo, <32 x i8> %sel.hi, <64 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62, i32 63>\n %res = bitcast <64 x i8> %concat to <8 x i64>\n ret <8 x i64> %res\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)\ndeclare <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8>, <32 x i8>, <32 x i8>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "x86_pblendvb_v64i8_v32i8",
"test_body": "define <8 x i64> @x86_pblendvb_v64i8_v32i8(<8 x i64> %a, <8 x i64> %b, <8 x i64> %c, <8 x i64> %d) {\n %a.bc = bitcast <8 x i64> %a to <64 x i8>\n %b.bc = bitcast <8 x i64> %b to <64 x i8>\n %c.bc = bitcast <8 x i64> %c to <64 x i8>\n %d.bc = bitcast <8 x i64> %d to <64 x i8>\n %a.lo = shufflevector <64 x i8> %a.bc, <64 x i8> poison, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %b.lo = shufflevector <64 x i8> %b.bc, <64 x i8> poison, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %a.hi = shufflevector <64 x i8> %a.bc, <64 x i8> poison, <32 x i32> <i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62, i32 63>\n %b.hi = shufflevector <64 x i8> %b.bc, <64 x i8> poison, <32 x i32> <i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62, i32 63>\n %cmp = icmp slt <64 x i8> %c.bc, %d.bc\n %sext = sext <64 x i1> %cmp to <64 x i8>\n %sext.lo = shufflevector <64 x i8> %sext, <64 x i8> poison, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %sext.hi = shufflevector <64 x i8> %sext, <64 x i8> poison, <32 x i32> <i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62, i32 63>\n %sel.lo = tail call <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8> %a.lo, <32 x i8> %b.lo, <32 x i8> %sext.lo)\n %sel.hi = tail call <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8> %a.hi, <32 x i8> %b.hi, <32 x i8> %sext.hi)\n %concat = shufflevector <32 x i8> %sel.lo, <32 x i8> %sel.hi, <64 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62, i32 63>\n %res = bitcast <64 x i8> %concat to <8 x i64>\n ret <8 x i64> %res\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)\ndeclare <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8>, <32 x i8>, <32 x i8>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "x86_pblendvb_v4f64_v2f64",
"test_body": "define <4 x double> @x86_pblendvb_v4f64_v2f64(<4 x double> %a, <4 x double> %b, <4 x double> %c, <4 x double> %d) {\n %a.bc = bitcast <4 x double> %a to <32 x i8>\n %b.bc = bitcast <4 x double> %b to <32 x i8>\n %a.lo = shufflevector <32 x i8> %a.bc, <32 x i8> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>\n %b.lo = shufflevector <32 x i8> %b.bc, <32 x i8> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>\n %a.hi = shufflevector <32 x i8> %a.bc, <32 x i8> poison, <16 x i32> <i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %b.hi = shufflevector <32 x i8> %b.bc, <32 x i8> poison, <16 x i32> <i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %cmp = fcmp olt <4 x double> %c, %d\n %sext = sext <4 x i1> %cmp to <4 x i64>\n %sext.bc = bitcast <4 x i64> %sext to <32 x i8>\n %sext.lo = shufflevector <32 x i8> %sext.bc, <32 x i8> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>\n %sext.hi = shufflevector <32 x i8> %sext.bc, <32 x i8> poison, <16 x i32> <i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %sel.lo = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %a.lo, <16 x i8> %b.lo, <16 x i8> %sext.lo)\n %sel.hi = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %a.hi, <16 x i8> %b.hi, <16 x i8> %sext.hi)\n %concat = shufflevector <16 x i8> %sel.lo, <16 x i8> %sel.hi, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %res = bitcast <32 x i8> %concat to <4 x double>\n ret <4 x double> %res\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)\ndeclare <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8>, <16 x i8>, <16 x i8>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "x86_pblendvb_v16i16_v8i16",
"test_body": "define <4 x i64> @x86_pblendvb_v16i16_v8i16(<4 x i64> %a, <4 x i64> %b, <4 x i64> %c, <4 x i64> %d) {\n %a.bc = bitcast <4 x i64> %a to <32 x i8>\n %b.bc = bitcast <4 x i64> %b to <32 x i8>\n %c.bc = bitcast <4 x i64> %c to <16 x i16>\n %d.bc = bitcast <4 x i64> %d to <16 x i16>\n %a.lo = shufflevector <32 x i8> %a.bc, <32 x i8> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>\n %b.lo = shufflevector <32 x i8> %b.bc, <32 x i8> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>\n %a.hi = shufflevector <32 x i8> %a.bc, <32 x i8> poison, <16 x i32> <i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %b.hi = shufflevector <32 x i8> %b.bc, <32 x i8> poison, <16 x i32> <i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %cmp = icmp slt <16 x i16> %c.bc, %d.bc\n %sext = sext <16 x i1> %cmp to <16 x i16>\n %sext.bc = bitcast <16 x i16> %sext to <32 x i8>\n %sext.lo = shufflevector <32 x i8> %sext.bc, <32 x i8> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>\n %sext.hi = shufflevector <32 x i8> %sext.bc, <32 x i8> poison, <16 x i32> <i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %sel.lo = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %a.lo, <16 x i8> %b.lo, <16 x i8> %sext.lo)\n %sel.hi = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %a.hi, <16 x i8> %b.hi, <16 x i8> %sext.hi)\n %concat = shufflevector <16 x i8> %sel.lo, <16 x i8> %sel.hi, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %res = bitcast <32 x i8> %concat to <4 x i64>\n ret <4 x i64> %res\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)\ndeclare <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8>, <16 x i8>, <16 x i8>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "x86_pblendvb_v8i32_v4i32",
"test_body": "define <4 x i64> @x86_pblendvb_v8i32_v4i32(<4 x i64> %a, <4 x i64> %b, <4 x i64> %c, <4 x i64> %d) {\n %a.bc = bitcast <4 x i64> %a to <32 x i8>\n %b.bc = bitcast <4 x i64> %b to <32 x i8>\n %c.bc = bitcast <4 x i64> %c to <8 x i32>\n %d.bc = bitcast <4 x i64> %d to <8 x i32>\n %a.lo = shufflevector <32 x i8> %a.bc, <32 x i8> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>\n %b.lo = shufflevector <32 x i8> %b.bc, <32 x i8> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>\n %a.hi = shufflevector <32 x i8> %a.bc, <32 x i8> poison, <16 x i32> <i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %b.hi = shufflevector <32 x i8> %b.bc, <32 x i8> poison, <16 x i32> <i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %cmp = icmp slt <8 x i32> %c.bc, %d.bc\n %sext = sext <8 x i1> %cmp to <8 x i32>\n %sext.bc = bitcast <8 x i32> %sext to <32 x i8>\n %sext.lo = shufflevector <32 x i8> %sext.bc, <32 x i8> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>\n %sext.hi = shufflevector <32 x i8> %sext.bc, <32 x i8> poison, <16 x i32> <i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %sel.lo = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %a.lo, <16 x i8> %b.lo, <16 x i8> %sext.lo)\n %sel.hi = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %a.hi, <16 x i8> %b.hi, <16 x i8> %sext.hi)\n %concat = shufflevector <16 x i8> %sel.lo, <16 x i8> %sel.hi, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %res = bitcast <32 x i8> %concat to <4 x i64>\n ret <4 x i64> %res\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)\ndeclare <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8>, <16 x i8>, <16 x i8>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "x86_pblendvb_v4i64_v2i64",
"test_body": "define <4 x i64> @x86_pblendvb_v4i64_v2i64(<4 x i64> %a, <4 x i64> %b, <4 x i64> %c, <4 x i64> %d) {\n %a.bc = bitcast <4 x i64> %a to <32 x i8>\n %b.bc = bitcast <4 x i64> %b to <32 x i8>\n %a.lo = shufflevector <32 x i8> %a.bc, <32 x i8> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>\n %b.lo = shufflevector <32 x i8> %b.bc, <32 x i8> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>\n %a.hi = shufflevector <32 x i8> %a.bc, <32 x i8> poison, <16 x i32> <i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %b.hi = shufflevector <32 x i8> %b.bc, <32 x i8> poison, <16 x i32> <i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %cmp = icmp slt <4 x i64> %c, %d\n %sext = sext <4 x i1> %cmp to <4 x i64>\n %sext.bc = bitcast <4 x i64> %sext to <32 x i8>\n %sext.lo = shufflevector <32 x i8> %sext.bc, <32 x i8> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>\n %sext.hi = shufflevector <32 x i8> %sext.bc, <32 x i8> poison, <16 x i32> <i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %sel.lo = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %a.lo, <16 x i8> %b.lo, <16 x i8> %sext.lo)\n %sel.hi = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %a.hi, <16 x i8> %b.hi, <16 x i8> %sext.hi)\n %concat = shufflevector <16 x i8> %sel.lo, <16 x i8> %sel.hi, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %res = bitcast <32 x i8> %concat to <4 x i64>\n ret <4 x i64> %res\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)\ndeclare <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8>, <16 x i8>, <16 x i8>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "x86_pblendvb_v32i8_v16i8",
"test_body": "define <4 x i64> @x86_pblendvb_v32i8_v16i8(<4 x i64> %a, <4 x i64> %b, <4 x i64> %c, <4 x i64> %d) {\n %a.bc = bitcast <4 x i64> %a to <32 x i8>\n %b.bc = bitcast <4 x i64> %b to <32 x i8>\n %c.bc = bitcast <4 x i64> %c to <32 x i8>\n %d.bc = bitcast <4 x i64> %d to <32 x i8>\n %a.lo = shufflevector <32 x i8> %a.bc, <32 x i8> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>\n %b.lo = shufflevector <32 x i8> %b.bc, <32 x i8> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>\n %a.hi = shufflevector <32 x i8> %a.bc, <32 x i8> poison, <16 x i32> <i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %b.hi = shufflevector <32 x i8> %b.bc, <32 x i8> poison, <16 x i32> <i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %cmp = icmp slt <32 x i8> %c.bc, %d.bc\n %sext = sext <32 x i1> %cmp to <32 x i8>\n %sext.lo = shufflevector <32 x i8> %sext, <32 x i8> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>\n %sext.hi = shufflevector <32 x i8> %sext, <32 x i8> poison, <16 x i32> <i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %sel.lo = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %a.lo, <16 x i8> %b.lo, <16 x i8> %sext.lo)\n %sel.hi = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %a.hi, <16 x i8> %b.hi, <16 x i8> %sext.hi)\n %concat = shufflevector <16 x i8> %sel.lo, <16 x i8> %sel.hi, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %res = bitcast <32 x i8> %concat to <4 x i64>\n ret <4 x i64> %res\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)\ndeclare <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8>, <16 x i8>, <16 x i8>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "x86_pblendvb_v16i32_v8i32",
"test_body": "define <8 x i64> @x86_pblendvb_v16i32_v8i32(<8 x i64> %a, <8 x i64> %b, <8 x i64> %c, <8 x i64> %d) {\n %a.bc = bitcast <8 x i64> %a to <64 x i8>\n %b.bc = bitcast <8 x i64> %b to <64 x i8>\n %c.bc = bitcast <8 x i64> %c to <16 x i32>\n %d.bc = bitcast <8 x i64> %d to <16 x i32>\n %a.lo = shufflevector <64 x i8> %a.bc, <64 x i8> poison, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %b.lo = shufflevector <64 x i8> %b.bc, <64 x i8> poison, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %a.hi = shufflevector <64 x i8> %a.bc, <64 x i8> poison, <32 x i32> <i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62, i32 63>\n %b.hi = shufflevector <64 x i8> %b.bc, <64 x i8> poison, <32 x i32> <i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62, i32 63>\n %cmp = icmp slt <16 x i32> %c.bc, %d.bc\n %sext = sext <16 x i1> %cmp to <16 x i32>\n %sext.bc = bitcast <16 x i32> %sext to <64 x i8>\n %sext.lo = shufflevector <64 x i8> %sext.bc, <64 x i8> poison, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\n %sext.hi = shufflevector <64 x i8> %sext.bc, <64 x i8> poison, <32 x i32> <i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62, i32 63>\n %sel.lo = tail call <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8> %a.lo, <32 x i8> %b.lo, <32 x i8> %sext.lo)\n %sel.hi = tail call <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8> %a.hi, <32 x i8> %b.hi, <32 x i8> %sext.hi)\n %concat = shufflevector <32 x i8> %sel.lo, <32 x i8> %sel.hi, <64 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62, i32 63>\n %res = bitcast <64 x i8> %concat to <8 x i64>\n ret <8 x i64> %res\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)\ndeclare <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8>, <32 x i8>, <32 x i8>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/VectorCombine/AArch64/shuffletoidentity.ll",
"commands": [
"opt -passes=vector-combine -S %s"
],
"tests": [
{
"test_name": "bitcast_smax_v8i32_v4i32",
"test_body": "target triple = \"aarch64\"\n\ndefine <4 x i64> @bitcast_smax_v8i32_v4i32(<4 x i64> %a, <4 x i64> %b) {\n %a.bc0 = bitcast <4 x i64> %a to <8 x i32>\n %b.bc0 = bitcast <4 x i64> %b to <8 x i32>\n %cmp = icmp slt <8 x i32> %a.bc0, %b.bc0\n %cmp.lo = shufflevector <8 x i1> %cmp, <8 x i1> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>\n %cmp.hi = shufflevector <8 x i1> %cmp, <8 x i1> poison, <4 x i32> <i32 4, i32 5, i32 6, i32 7>\n %a.bc1 = bitcast <4 x i64> %a to <8 x i32>\n %b.bc1 = bitcast <4 x i64> %b to <8 x i32>\n %a.lo = shufflevector <8 x i32> %a.bc1, <8 x i32> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>\n %b.lo = shufflevector <8 x i32> %b.bc1, <8 x i32> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>\n %lo = select <4 x i1> %cmp.lo, <4 x i32> %b.lo, <4 x i32> %a.lo\n %a.bc2 = bitcast <4 x i64> %a to <8 x i32>\n %b.bc2 = bitcast <4 x i64> %b to <8 x i32>\n %a.hi = shufflevector <8 x i32> %a.bc2, <8 x i32> poison, <4 x i32> <i32 4, i32 5, i32 6, i32 7>\n %b.hi = shufflevector <8 x i32> %b.bc2, <8 x i32> poison, <4 x i32> <i32 4, i32 5, i32 6, i32 7>\n %hi = select <4 x i1> %cmp.hi, <4 x i32> %b.hi, <4 x i32> %a.hi\n %concat = shufflevector <4 x i32> %lo, <4 x i32> %hi, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>\n %res = bitcast <8 x i32> %concat to <4 x i64>\n ret <4 x i64> %res\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/VectorCombine/X86/shuffle-of-selects.ll",
"commands": [
"opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mcpu=x86-64-v2",
"opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mcpu=x86-64-v3",
"opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mcpu=x86-64-v4"
],
"tests": [
{
"test_name": "src_v8tov16_i16",
"test_body": "define <16 x i16> @src_v8tov16_i16(<8 x i1> %a, <8 x i1> %b, <8 x i16> %x, <8 x i16> %y, <8 x i16> %z) {\n %select.xz = select <8 x i1> %a, <8 x i16> %x, <8 x i16> %z\n %select.yx = select <8 x i1> %b, <8 x i16> %y, <8 x i16> %x\n %res = shufflevector <8 x i16> %select.xz, <8 x i16> %select.yx, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>\n ret <16 x i16> %res\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "src_v4tov8_float",
"test_body": "define <8 x float> @src_v4tov8_float(<4 x i1> %a, <4 x i1> %b, <4 x float> %x, <4 x float> %y, <4 x float> %z) {\n %select.xz = select <4 x i1> %a, <4 x float> %x, <4 x float> %z\n %select.yx = select <4 x i1> %b, <4 x float> %y, <4 x float> %x\n %res = shufflevector <4 x float> %select.xz, <4 x float> %select.yx, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>\n ret <8 x float> %res\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "src_v4tov8_i16",
"test_body": "define <8 x i16> @src_v4tov8_i16(<4 x i1> %a, <4 x i1> %b, <4 x i16> %x, <4 x i16> %y, <4 x i16> %z) {\n %select.xz = select <4 x i1> %a, <4 x i16> %x, <4 x i16> %z\n %select.yx = select <4 x i1> %b, <4 x i16> %y, <4 x i16> %x\n %res = shufflevector <4 x i16> %select.xz, <4 x i16> %select.yx, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>\n ret <8 x i16> %res\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "src_v2tov4_i64",
"test_body": "define <4 x i64> @src_v2tov4_i64(<2 x i1> %a, <2 x i1> %b, <2 x i64> %x, <2 x i64> %y, <2 x i64> %z) {\n %select.xz = select <2 x i1> %a, <2 x i64> %x, <2 x i64> %z\n %select.yx = select <2 x i1> %b, <2 x i64> %y, <2 x i64> %x\n %res = shufflevector <2 x i64> %select.xz, <2 x i64> %select.yx, <4 x i32> <i32 0, i32 1, i32 2, i32 3>\n ret <4 x i64> %res\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "src_v2tov2_i64",
"test_body": "define <2 x i64> @src_v2tov2_i64(<2 x i1> %a, <2 x i1> %b, <2 x i64> %x, <2 x i64> %y, <2 x i64> %z) {\n %select.xz = select <2 x i1> %a, <2 x i64> %x, <2 x i64> %z\n %select.yx = select <2 x i1> %b, <2 x i64> %y, <2 x i64> %x\n %res = shufflevector <2 x i64> %select.xz, <2 x i64> %select.yx, <2 x i32> <i32 0, i32 3>\n ret <2 x i64> %res\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "src_v2tov4_i32",
"test_body": "define <4 x i32> @src_v2tov4_i32(<2 x i1> %a, <2 x i1> %b, <2 x i32> %x, <2 x i32> %y, <2 x i32> %z) {\n %select.xz = select <2 x i1> %a, <2 x i32> %x, <2 x i32> %z\n %select.yx = select <2 x i1> %b, <2 x i32> %y, <2 x i32> %x\n %res = shufflevector <2 x i32> %select.xz, <2 x i32> %select.yx, <4 x i32> <i32 0, i32 1, i32 2, i32 3>\n ret <4 x i32> %res\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "src_v2tov2_double",
"test_body": "define <2 x double> @src_v2tov2_double(<2 x i1> %a, <2 x i1> %b, <2 x double> %x, <2 x double> %y, <2 x double> %z) {\n %select.xz = select <2 x i1> %a, <2 x double> %x, <2 x double> %z\n %select.yx = select <2 x i1> %b, <2 x double> %y, <2 x double> %x\n %res = shufflevector <2 x double> %select.xz, <2 x double> %select.yx, <2 x i32> <i32 0, i32 3>\n ret <2 x double> %res\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_mask0",
"test_body": "define <2 x float> @test_mask0(<4 x i1> %c, <4 x float> %x, <4 x float> %y, <4 x float> %z) {\n %select.xy = select <4 x i1> %c, <4 x float> %x, <4 x float> %y\n %select.yz = select <4 x i1> %c, <4 x float> %y, <4 x float> %z\n %res = shufflevector <4 x float> %select.xy, <4 x float> %select.yz, <2 x i32> <i32 4, i32 7>\n ret <2 x float> %res\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "src_v2tov4_i16",
"test_body": "define <4 x i16> @src_v2tov4_i16(<2 x i1> %a, <2 x i1> %b, <2 x i16> %x, <2 x i16> %y, <2 x i16> %z) {\n %select.xz = select <2 x i1> %a, <2 x i16> %x, <2 x i16> %z\n %select.yx = select <2 x i1> %b, <2 x i16> %y, <2 x i16> %x\n %res = shufflevector <2 x i16> %select.xz, <2 x i16> %select.yx, <4 x i32> <i32 0, i32 1, i32 2, i32 3>\n ret <4 x i16> %res\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "src_v4tov8_i32",
"test_body": "define <8 x i32> @src_v4tov8_i32(<4 x i1> %a, <4 x i1> %b, <4 x i32> %x, <4 x i32> %y, <4 x i32> %z) {\n %select.xz = select <4 x i1> %a, <4 x i32> %x, <4 x i32> %z\n %select.yx = select <4 x i1> %b, <4 x i32> %y, <4 x i32> %x\n %res = shufflevector <4 x i32> %select.xz, <4 x i32> %select.yx, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>\n ret <8 x i32> %res\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "src_v8tov8_i16",
"test_body": "define <8 x i16> @src_v8tov8_i16(<8 x i1> %a, <8 x i1> %b, <8 x i16> %x, <8 x i16> %y, <8 x i16> %z) {\n %select.xz = select <8 x i1> %a, <8 x i16> %x, <8 x i16> %z\n %select.yx = select <8 x i1> %b, <8 x i16> %y, <8 x i16> %x\n %res = shufflevector <8 x i16> %select.xz, <8 x i16> %select.yx, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>\n ret <8 x i16> %res\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "src_v2tov4_float",
"test_body": "define <4 x float> @src_v2tov4_float(<2 x i1> %a, <2 x i1> %b, <2 x float> %x, <2 x float> %y, <2 x float> %z) {\n %select.xz = select <2 x i1> %a, <2 x float> %x, <2 x float> %z\n %select.yx = select <2 x i1> %b, <2 x float> %y, <2 x float> %x\n %res = shufflevector <2 x float> %select.xz, <2 x float> %select.yx, <4 x i32> <i32 0, i32 1, i32 2, i32 3>\n ret <4 x float> %res\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_mask1",
"test_body": "define <2 x float> @test_mask1(<4 x i1> %c, <4 x float> %x, <4 x float> %y, <4 x float> %z) {\n %select.xy = select <4 x i1> %c, <4 x float> %x, <4 x float> %y\n %select.yz = select <4 x i1> %c, <4 x float> %y, <4 x float> %z\n %res = shufflevector <4 x float> %select.xy, <4 x float> %select.yz, <2 x i32> <i32 7, i32 4>\n ret <2 x float> %res\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "src_v2tov4_double",
"test_body": "define <4 x double> @src_v2tov4_double(<2 x i1> %a, <2 x i1> %b, <2 x double> %x, <2 x double> %y, <2 x double> %z) {\n %select.xz = select <2 x i1> %a, <2 x double> %x, <2 x double> %z\n %select.yx = select <2 x i1> %b, <2 x double> %y, <2 x double> %x\n %res = shufflevector <2 x double> %select.xz, <2 x double> %select.yx, <4 x i32> <i32 0, i32 1, i32 2, i32 3>\n ret <4 x double> %res\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "src_v2tov4_float_nnan",
"test_body": "define <4 x float> @src_v2tov4_float_nnan(<2 x i1> %a, <2 x i1> %b, <2 x float> %x, <2 x float> %y, <2 x float> %z) {\n %select.xz = select nnan <2 x i1> %a, <2 x float> %x, <2 x float> %z\n %select.yx = select nnan <2 x i1> %b, <2 x float> %y, <2 x float> %x\n %res = shufflevector <2 x float> %select.xz, <2 x float> %select.yx, <4 x i32> <i32 0, i32 1, i32 2, i32 3>\n ret <4 x float> %res\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "A/F: `I >= 0 && I < (NumOpElts * 2) && \"Out-of-bounds shuffle mask element\" after upstream commit 5d1029b",
"body": "One of our internal tests recently started hitting an assertion failure when building which I bisected back to 5d1029b4a87f36a394c169b89b26a74d17f7ff01. I was able to reduce the test case to the following code:\n```c++\ntypedef float e __attribute__((__vector_size__(16)));\ne g(e h, e j) { return __builtin_ia32_cmpltps(j, h); }\ne k(float, float l, float n, float) { return {n, l}; }\ne o, p;\ntypedef union q {\n e r;\n} t;\ntypedef union u {\n e r;\n} w;\nunion aa {\n t ab;\n w ac;\n float f[];\n aa(t v) : ab(v) {}\n e ad;\n aa(e v) : ad(v) {}\n};\n#define ae(v) aa(v).ab\n#define af(v) aa(v).ac\n#define ag(a, b, c, d) ae(k(d, c, b, a))\n#define ah(v, ai) aa(v).f[ai]\n#define aj(a, b) af(g(a.r, b.r))\n#define ak(a, b, m) ae(al(a.r, b.r, m.r))\nt am(t an, t abcd) {\n e ao = __builtin_shufflevector(an.r, abcd.r, 0, 4, 1, 5);\n t ap = ae(ao);\n return ap;\n}\ne al(e, e, e aq) {\n e ar = __builtin_ia32_blendvps(o, p, aq);\n return ar;\n}\nfloat as(t v, int s) { return ah(v, s); }\nw at(t a, t b) { return aj(a, b); }\nt au(w aq) {\n t b, a;\n return ak(a, b, aq);\n}\nt av(t an, t abcd) { return am(an, abcd); }\nt aw_x, bl, bq_ay;\nt bf();\nstruct bc {\n t bd;\n bc(t bg) { bd = bg; }\n t be() { return bd; }\n};\nstruct bh {\n t bi;\n int i;\n bh(t bg, int bj) : bi(bg), i(bj) {}\n operator float() {\n float bk = as(bi, i);\n return bk;\n }\n};\nfloat bm_x;\nstruct bm {\n bm(float y, float z) { bl = ag(bm_x, y, z, 0.0f); }\n bm(bc y, bc z) {\n q bn = z.be(), bo(bn), bp = y.be();\n bl = av(bo, bp);\n }\n bh operator[](int bj) { return bh(bl, bj); }\n};\nbc bq() {\n t __trans_tmp_3 = bf();\n u bb = at(bq_ay, aw_x);\n __trans_tmp_3 = au(bb);\n return __trans_tmp_3;\n}\nbm bs() { return bm(bq(), bq()); }\nvoid bx() {\n unsigned char by, bz;\n bm ca = bs();\n bz = ca[1];\n by = ca[2];\n bm(bz, by);\n}\n```\nIf compiled with a compiler that includes 5d1029b4a87f36a394c169b89b26a74d17f7ff01 and with optimizations and AVX enabled, the compiler hits an assertion failure:\n```\n$ ~/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang -c -O2 -mavx repro.cpp\nclang: /home/dyung/src/upstream/llvm_clean_git/llvm/lib/IR/Instructions.cpp:1906: bool isSingleSourceMaskImpl(llvm::ArrayRef<int>, int): Assertion `I >= 0 && I < (NumOpElts * 2) && \"Out-of-bounds shuffle mask element\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\nStack dump:\n0. Program arguments: /home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang -c -O2 repro.cpp -mavx\n1. <eof> parser at end of file\n2. Optimizer\n3. Running pass \"function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-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 \"repro.cpp\"\n4. Running pass \"vector-combine\" on function \"_Z2bxv\"\n #0 0x0000561cf26380ef llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x224f0ef)\n #1 0x0000561cf2635c04 llvm::sys::CleanupOnSignal(unsigned long) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x224cc04)\n #2 0x0000561cf2586258 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0\n #3 0x00007f5f727e6420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\n #4 0x00007f5f722b300b raise /build/glibc-FcRMwW/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\n #5 0x00007f5f72292859 abort /build/glibc-FcRMwW/glibc-2.31/stdlib/abort.c:81:7\n #6 0x00007f5f72292729 get_sysdep_segment_value /build/glibc-FcRMwW/glibc-2.31/intl/loadmsgcat.c:509:8\n #7 0x00007f5f72292729 _nl_load_domain /build/glibc-FcRMwW/glibc-2.31/intl/loadmsgcat.c:970:34\n #8 0x00007f5f722a3fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\n #9 0x0000561cf203aa46 isSingleSourceMaskImpl(llvm::ArrayRef<int>, int) Instructions.cpp:0:0\n#10 0x0000561cf20436e4 llvm::ShuffleVectorInst::isSelectMask(llvm::ArrayRef<int>, int) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x1c5a6e4)\n#11 0x0000561cf116c2b0 llvm::X86TTIImpl::getShuffleCost(llvm::TargetTransformInfo::ShuffleKind, llvm::VectorType*, llvm::ArrayRef<int>, llvm::TargetTransformInfo::TargetCostKind, int, llvm::VectorType*, llvm::ArrayRef<llvm::Value const*>, llvm::Instruction const*) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0xd832b0)\n#12 0x0000561cf17404ed llvm::TargetTransformInfo::getShuffleCost(llvm::TargetTransformInfo::ShuffleKind, llvm::VectorType*, llvm::ArrayRef<int>, llvm::TargetTransformInfo::TargetCostKind, int, llvm::VectorType*, llvm::ArrayRef<llvm::Value const*>, llvm::Instruction const*) const (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x13574ed)\n#13 0x0000561cf42a667a (anonymous namespace)::VectorCombine::foldShuffleOfSelects(llvm::Instruction&) VectorCombine.cpp:0:0\n#14 0x0000561cf42c0e55 (anonymous namespace)::VectorCombine::run()::'lambda'(llvm::Instruction&)::operator()(llvm::Instruction&) const (.isra.0) VectorCombine.cpp:0:0\n#15 0x0000561cf42c1d85 llvm::VectorCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x3ed8d85)\n#16 0x0000561cf3b8f1a6 llvm::detail::PassModel<llvm::Function, llvm::VectorCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x37a61a6)\n#17 0x0000561cf20deb09 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x1cf5b09)\n#18 0x0000561cf11a9906 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0xdc0906)\n#19 0x0000561cf20dd372 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x1cf4372)\n#20 0x0000561cf11aa2c6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0xdc12c6)\n#21 0x0000561cf20dcd91 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x1cf3d91)\n#22 0x0000561cf28d99aa (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 0x0000561cf28dd9db 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*) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x24f49db)\n#24 0x0000561cf3021121 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x2c38121)\n#25 0x0000561cf4a4170c clang::ParseAST(clang::Sema&, bool, bool) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x465870c)\n#26 0x0000561cf3021548 clang::CodeGenAction::ExecuteAction() (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x2c38548)\n#27 0x0000561cf32f80f9 clang::FrontendAction::Execute() (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x2f0f0f9)\n#28 0x0000561cf3278f4e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x2e8ff4e)\n#29 0x0000561cf33ed2b6 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x30042b6)\n#30 0x0000561cf1125ccd cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0xd3cccd)\n#31 0x0000561cf111d5ca ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#32 0x0000561cf306b3cd 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 0x0000561cf2586760 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x219d760)\n#34 0x0000561cf306b9ef 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 0x0000561cf302c9c4 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x2c439c4)\n#36 0x0000561cf302da5e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x2c44a5e)\n#37 0x0000561cf3035ef5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0x2c4cef5)\n#38 0x0000561cf1122aab clang_main(int, char**, llvm::ToolContext const&) (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0xd39aab)\n#39 0x0000561cf10546bb main (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0xc6b6bb)\n#40 0x00007f5f72294083 __libc_start_main /build/glibc-FcRMwW/glibc-2.31/csu/../csu/libc-start.c:342:3\n#41 0x0000561cf111d05e _start (/home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin/clang+0xd3405e)\nclang: error: clang frontend command failed with exit code 134 (use -v to see invocation)\nclang version 21.0.0 (https://github.com/llvm/llvm-project.git 5d1029b4a87f36a394c169b89b26a74d17f7ff01)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /home/dyung/src/upstream/5d1029b4a87f36a394c169b89b26a74d17f7ff01-linux/bin\nBuild config: +assertions\n```",
"author": "dyung",
"labels": [
"crash",
"llvm:transforms"
],
"comments": [
{
"author": "ParkHanbum",
"body": "Can you help me compile the sample?\nnever mind. I get the crash."
},
{
"author": "ParkHanbum",
"body": "```\ndefine void @test(<4 x i1> %z, <4 x float> %1, <4 x float> %2) {\n%a = select <4 x i1> %z, <4 x float> %1, <4 x float> %2\n%b = select <4 x i1> %z, <4 x float> %1, <4 x float> %2\n%c = shufflevector <4 x float> %a, <4 x float> %b, <2 x i32> <i32 0, i32 5>\nret void\n}\n```\nThe problematic IR is shown above.\n\n```\n * frame #4: 0x00000001043d7fe8 clang++`isIdentityMaskImpl(llvm::ArrayRef<int>, int) (.cold.3) + 36\n frame #5: 0x0000000100fd5334 clang++`llvm::ShuffleVectorInst::isSelectMask(llvm::ArrayRef<int>, int) + 256\n frame #6: 0x0000000100095ff8 clang++`llvm::BasicTTIImplBase<llvm::X86TTIImpl>::improveShuffleKindFromMask(llvm::TargetTransformInfo::ShuffleKind, llvm::ArrayRef<int>, llvm::VectorType*, int&, llvm::VectorType*&) const + 184\n frame #7: 0x000000010033e104 clang++`llvm::X86TTIImpl::getShuffleCost(llvm::TargetTransformInfo::ShuffleKind, llvm::VectorType*, llvm::ArrayRef<int>, llvm::TargetTransformInfo::TargetCostKind, int, llvm::VectorType*, llvm::ArrayRef<llvm::Value const*>, llvm::Instruction const*) + 128\n```\n\nThis is where the crash happens.\n\n\n```\n OldCost += TTI.getShuffleCost(SK, DstVecTy, Mask, CostKind, 0, nullptr,\n {I.getOperand(0), I.getOperand(1)}, &I);\n```\n\nThe problematic IR is shown above.\n\nTo calculate the OldCost, call getShuffleCost.\nThe DstVecTy passed as an argument is `<2 x float>` and the Mask is <i32 0, i32 5>.\n\nThe second Mask specifier is 5, which is greater than NumOpElts * 2 of DstVecTy, so this assertion seems to be thrown.\n(If we increase the Mask to <3 x i32> <i32 0, i32 5, i32 5> or decrease the Mask size to <2 x i32> <i32 0, i32 3>, the error will not occur.)\n\nI will add a fix after further analysis.\n\n\n"
},
{
"author": "RKSimon",
"body": "@ParkHanbum You must use the source type not destination type for getShuffleCost"
},
{
"author": "ParkHanbum",
"body": "@RKSimon I'm sorry, I made a mistake. I'll push up the patch quickly.\n"
},
{
"author": "RKSimon",
"body": "You just need the fix + test coverage - no need to revert the existing patch if you are prompt"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
158319
|
https://github.com/llvm/llvm-project/issues/158319
|
crash
|
111de45e838a7d33637da8807212284c988f7fae
| 2025-09-12T16:14:59 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "ef7e03a2d1571e3c651fa9ccd205dbacf1a103c8",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/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": [
[
1272,
1280
]
],
"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 ef7e03a2d1571e3c651fa9ccd205dbacf1a103c8
Author: Florian Hahn <flo@fhahn.com>
Date: Sat Sep 13 18:13:22 2025 +0100
[VPlan] Limit ExtractLastElem fold to recipes guaranteed single-scalar.
vputils::isSingleScalar(A) may return true to recipes that produce only
a single scalar value, but they could still end up as vector
instruction, because the recipe could not be converted to a
single-scalar VPInstruction/VPReplicateRecipe.
For now, only apply the fold for recipes guaranteed to produce a single
value, i.e. single-scalar VPInstructions and VPReplicateRecipes.
Fixes https://github.com/llvm/llvm-project/issues/158319.
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index fcd85ba9ab7f..a193c438e7ea 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -1272,9 +1272,11 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
if (match(Def,
m_VPInstruction<VPInstruction::ExtractLastElement>(m_VPValue(A))) &&
- vputils::isSingleScalar(A) && all_of(A->users(), [Def, A](VPUser *U) {
- return U->usesScalars(A) || Def == U;
- })) {
+ ((isa<VPInstruction>(A) && vputils::isSingleScalar(A)) ||
+ (isa<VPReplicateRecipe>(A) &&
+ cast<VPReplicateRecipe>(A)->isSingleScalar())) &&
+ all_of(A->users(),
+ [Def, A](VPUser *U) { return U->usesScalars(A) || Def == U; })) {
return Def->replaceAllUsesWith(A);
}
}
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/first-order-recurrence-with-uniform-ops.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=2 -S %s",
"opt -passes=loop-vectorize -force-vector-width=1 -force-vector-interleave=2 -S %s",
"opt -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -S %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n; Test case for https://github.com/llvm/llvm-project/issues/95520.\ndefine i32 @recurence_uniform_load(ptr %src, ptr noalias %dst, i64 %n) {\n; UNROLL-NO-IC-LABEL: define i32 @recurence_uniform_load(\n; UNROLL-NO-IC-SAME: ptr [[SRC:%.*]], ptr noalias [[DST:%.*]], i64 [[N:%.*]]) {\n; UNROLL-NO-IC-NEXT: [[ENTRY:.*]]:\n; UNROLL-NO-IC-NEXT: [[TMP0:%.*]] = add i64 [[N]], 1\n; UNROLL-NO-IC-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[TMP0]], 8\n; UNROLL-NO-IC-NEXT: br i1 [[MIN_ITERS_CHECK]], label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]\n; UNROLL-NO-IC: [[VECTOR_PH]]:\n; UNROLL-NO-IC-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[TMP0]], 8\n; UNROLL-NO-IC-NEXT: [[N_VEC:%.*]] = sub i64 [[TMP0]], [[N_MOD_VF]]\n; UNROLL-NO-IC-NEXT: br label %[[VECTOR_BODY:.*]]\n; UNROLL-NO-IC: [[VECTOR_BODY]]:\n; UNROLL-NO-IC-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]\n; UNROLL-NO-IC-NEXT: [[TMP1:%.*]] = load i32, ptr [[SRC]], align 4\n; UNROLL-NO-IC-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 8\n; UNROLL-NO-IC-NEXT: [[TMP2:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]\n; UNROLL-NO-IC-NEXT: br i1 [[TMP2]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]\n; UNROLL-NO-IC: [[MIDDLE_BLOCK]]:\n; UNROLL-NO-IC-NEXT: [[CMP_N:%.*]] = icmp eq i64 [[TMP0]], [[N_VEC]]\n; UNROLL-NO-IC-NEXT: br i1 [[CMP_N]], label %[[EXIT:.*]], label %[[SCALAR_PH]]\n; UNROLL-NO-IC: [[SCALAR_PH]]:\n; UNROLL-NO-IC-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]\n; UNROLL-NO-IC-NEXT: [[SCALAR_RECUR_INIT:%.*]] = phi i32 [ [[TMP1]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]\n; UNROLL-NO-IC-NEXT: br label %[[LOOP:.*]]\n; UNROLL-NO-IC: [[LOOP]]:\n; UNROLL-NO-IC-NEXT: [[PHI:%.*]] = phi i64 [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], [ [[ADD:%.*]], %[[LOOP]] ]\n; UNROLL-NO-IC-NEXT: [[RECUR:%.*]] = phi i32 [ [[SCALAR_RECUR_INIT]], %[[SCALAR_PH]] ], [ [[LOAD:%.*]], %[[LOOP]] ]\n; UNROLL-NO-IC-NEXT: [[ADD]] = add i64 [[PHI]], 1\n; UNROLL-NO-IC-NEXT: [[LOAD]] = load i32, ptr [[SRC]], align 4\n; UNROLL-NO-IC-NEXT: [[ICMP:%.*]] = icmp ult i64 [[PHI]], [[N]]\n; UNROLL-NO-IC-NEXT: br i1 [[ICMP]], label %[[LOOP]], label %[[EXIT]], !llvm.loop [[LOOP3:![0-9]+]]\n; UNROLL-NO-IC: [[EXIT]]:\n; UNROLL-NO-IC-NEXT: [[RECUR_LCSSA:%.*]] = phi i32 [ [[RECUR]], %[[LOOP]] ], [ [[TMP1]], %[[MIDDLE_BLOCK]] ]\n; UNROLL-NO-IC-NEXT: ret i32 [[RECUR_LCSSA]]\n;\n; UNROLL-NO-VF-LABEL: define i32 @recurence_uniform_load(\n; UNROLL-NO-VF-SAME: ptr [[SRC:%.*]], ptr noalias [[DST:%.*]], i64 [[N:%.*]]) {\n; UNROLL-NO-VF-NEXT: [[ENTRY:.*]]:\n; UNROLL-NO-VF-NEXT: [[TMP1:%.*]] = add i64 [[N]], 1\n; UNROLL-NO-VF-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[TMP1]], 2\n; UNROLL-NO-VF-NEXT: br i1 [[MIN_ITERS_CHECK]], label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]\n; UNROLL-NO-VF: [[VECTOR_PH]]:\n; UNROLL-NO-VF-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[TMP1]], 2\n; UNROLL-NO-VF-NEXT: [[N_VEC:%.*]] = sub i64 [[TMP1]], [[N_MOD_VF]]\n; UNROLL-NO-VF-NEXT: br label %[[VECTOR_BODY:.*]]\n; UNROLL-NO-VF: [[VECTOR_BODY]]:\n; UNROLL-NO-VF-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]\n; UNROLL-NO-VF-NEXT: [[TMP0:%.*]] = load i32, ptr [[SRC]], align 4\n; UNROLL-NO-VF-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 2\n; UNROLL-NO-VF-NEXT: [[TMP2:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]\n; UNROLL-NO-VF-NEXT: br i1 [[TMP2]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]\n; UNROLL-NO-VF: [[MIDDLE_BLOCK]]:\n; UNROLL-NO-VF-NEXT: [[CMP_N:%.*]] = icmp eq i64 [[TMP1]], [[N_VEC]]\n; UNROLL-NO-VF-NEXT: br i1 [[CMP_N]], label %[[EXIT:.*]], label %[[SCALAR_PH]]\n; UNROLL-NO-VF: [[SCALAR_PH]]:\n; UNROLL-NO-VF-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]\n; UNROLL-NO-VF-NEXT: [[SCALAR_RECUR_INIT:%.*]] = phi i32 [ [[TMP0]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]\n; UNROLL-NO-VF-NEXT: br label %[[LOOP:.*]]\n; UNROLL-NO-VF: [[LOOP]]:\n; UNROLL-NO-VF-NEXT: [[PHI:%.*]] = phi i64 [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], [ [[ADD:%.*]], %[[LOOP]] ]\n; UNROLL-NO-VF-NEXT: [[RECUR:%.*]] = phi i32 [ [[SCALAR_RECUR_INIT]], %[[SCALAR_PH]] ], [ [[LOAD:%.*]], %[[LOOP]] ]\n; UNROLL-NO-VF-NEXT: [[ADD]] = add i64 [[PHI]], 1\n; UNROLL-NO-VF-NEXT: [[LOAD]] = load i32, ptr [[SRC]], align 4\n; UNROLL-NO-VF-NEXT: [[ICMP:%.*]] = icmp ult i64 [[PHI]], [[N]]\n; UNROLL-NO-VF-NEXT: br i1 [[ICMP]], label %[[LOOP]], label %[[EXIT]], !llvm.loop [[LOOP3:![0-9]+]]\n; UNROLL-NO-VF: [[EXIT]]:\n; UNROLL-NO-VF-NEXT: [[RECUR_LCSSA:%.*]] = phi i32 [ [[RECUR]], %[[LOOP]] ], [ [[TMP0]], %[[MIDDLE_BLOCK]] ]\n; UNROLL-NO-VF-NEXT: ret i32 [[RECUR_LCSSA]]\n;\n; SINK-AFTER-LABEL: define i32 @recurence_uniform_load(\n; SINK-AFTER-SAME: ptr [[SRC:%.*]], ptr noalias [[DST:%.*]], i64 [[N:%.*]]) {\n; SINK-AFTER-NEXT: [[ENTRY:.*]]:\n; SINK-AFTER-NEXT: [[TMP0:%.*]] = add i64 [[N]], 1\n; SINK-AFTER-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[TMP0]], 4\n; SINK-AFTER-NEXT: br i1 [[MIN_ITERS_CHECK]], label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]\n; SINK-AFTER: [[VECTOR_PH]]:\n; SINK-AFTER-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[TMP0]], 4\n; SINK-AFTER-NEXT: [[N_VEC:%.*]] = sub i64 [[TMP0]], [[N_MOD_VF]]\n; SINK-AFTER-NEXT: br label %[[VECTOR_BODY:.*]]\n; SINK-AFTER: [[VECTOR_BODY]]:\n; SINK-AFTER-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]\n; SINK-AFTER-NEXT: [[TMP1:%.*]] = load i32, ptr [[SRC]], align 4\n; SINK-AFTER-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4\n; SINK-AFTER-NEXT: [[TMP2:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]\n; SINK-AFTER-NEXT: br i1 [[TMP2]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]\n; SINK-AFTER: [[MIDDLE_BLOCK]]:\n; SINK-AFTER-NEXT: [[CMP_N:%.*]] = icmp eq i64 [[TMP0]], [[N_VEC]]\n; SINK-AFTER-NEXT: br i1 [[CMP_N]], label %[[EXIT:.*]], label %[[SCALAR_PH]]\n; SINK-AFTER: [[SCALAR_PH]]:\n; SINK-AFTER-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]\n; SINK-AFTER-NEXT: [[SCALAR_RECUR_INIT:%.*]] = phi i32 [ [[TMP1]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]\n; SINK-AFTER-NEXT: br label %[[LOOP:.*]]\n; SINK-AFTER: [[LOOP]]:\n; SINK-AFTER-NEXT: [[PHI:%.*]] = phi i64 [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], [ [[ADD:%.*]], %[[LOOP]] ]\n; SINK-AFTER-NEXT: [[RECUR:%.*]] = phi i32 [ [[SCALAR_RECUR_INIT]], %[[SCALAR_PH]] ], [ [[LOAD:%.*]], %[[LOOP]] ]\n; SINK-AFTER-NEXT: [[ADD]] = add i64 [[PHI]], 1\n; SINK-AFTER-NEXT: [[LOAD]] = load i32, ptr [[SRC]], align 4\n; SINK-AFTER-NEXT: [[ICMP:%.*]] = icmp ult i64 [[PHI]], [[N]]\n; SINK-AFTER-NEXT: br i1 [[ICMP]], label %[[LOOP]], label %[[EXIT]], !llvm.loop [[LOOP3:![0-9]+]]\n; SINK-AFTER: [[EXIT]]:\n; SINK-AFTER-NEXT: [[RECUR_LCSSA:%.*]] = phi i32 [ [[RECUR]], %[[LOOP]] ], [ [[TMP1]], %[[MIDDLE_BLOCK]] ]\n; SINK-AFTER-NEXT: ret i32 [[RECUR_LCSSA]]\n;\nentry:\n br label %loop\n\nloop:\n %phi = phi i64 [ 0, %entry ], [ %add, %loop ]\n %recur = phi i32 [ 0, %entry ], [ %load, %loop ]\n %add = add i64 %phi, 1\n %load = load i32, ptr %src, align 4\n %icmp = icmp ult i64 %phi, %n\n br i1 %icmp, label %loop, label %exit\n\nexit:\n ret i32 %recur\n}\n\n; Test for https://github.com/llvm/llvm-project/issues/158319. The recurrence\n; phi can be removed.\ndefine i16 @for_phi_removed(ptr %src) {\n; UNROLL-NO-IC-LABEL: define i16 @for_phi_removed(\n; UNROLL-NO-IC-SAME: ptr [[SRC:%.*]]) {\n; UNROLL-NO-IC-NEXT: [[ENTRY:.*]]:\n; UNROLL-NO-IC-NEXT: br i1 false, label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]\n; UNROLL-NO-IC: [[VECTOR_PH]]:\n; UNROLL-NO-IC-NEXT: br label %[[VECTOR_BODY:.*]]\n; UNROLL-NO-IC: [[VECTOR_BODY]]:\n; UNROLL-NO-IC-NEXT: [[INDEX:%.*]] = phi i32 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]\n; UNROLL-NO-IC-NEXT: [[TMP0:%.*]] = load i32, ptr [[SRC]], align 4\n; UNROLL-NO-IC-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <4 x i32> poison, i32 [[TMP0]], i64 0\n; UNROLL-NO-IC-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <4 x i32> [[BROADCAST_SPLATINSERT]], <4 x i32> poison, <4 x i32> zeroinitializer\n; UNROLL-NO-IC-NEXT: [[TMP1:%.*]] = icmp eq <4 x i32> [[BROADCAST_SPLAT]], zeroinitializer\n; UNROLL-NO-IC-NEXT: [[TMP2:%.*]] = select <4 x i1> [[TMP1]], <4 x i16> splat (i16 1), <4 x i16> zeroinitializer\n; UNROLL-NO-IC-NEXT: [[INDEX_NEXT]] = add nuw i32 [[INDEX]], 8\n; UNROLL-NO-IC-NEXT: [[TMP3:%.*]] = icmp eq i32 [[INDEX_NEXT]], 104\n; UNROLL-NO-IC-NEXT: br i1 [[TMP3]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP4:![0-9]+]]\n; UNROLL-NO-IC: [[MIDDLE_BLOCK]]:\n; UNROLL-NO-IC-NEXT: [[VECTOR_RECUR_EXTRACT:%.*]] = extractelement <4 x i16> [[TMP2]], i32 3\n; UNROLL-NO-IC-NEXT: br label %[[SCALAR_PH]]\n; UNROLL-NO-IC: [[SCALAR_PH]]:\n; UNROLL-NO-IC-NEXT: [[BC_RESUME_VAL:%.*]] = phi i16 [ 104, %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]\n; UNROLL-NO-IC-NEXT: [[SCALAR_RECUR_INIT:%.*]] = phi i16 [ [[VECTOR_RECUR_EXTRACT]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]\n; UNROLL-NO-IC-NEXT: br label %[[LOOP:.*]]\n; UNROLL-NO-IC: [[LOOP]]:\n; UNROLL-NO-IC-NEXT: [[IV:%.*]] = phi i16 [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], %[[LOOP]] ]\n; UNROLL-NO-IC-NEXT: [[P:%.*]] = phi i16 [ [[SCALAR_RECUR_INIT]], %[[SCALAR_PH]] ], [ [[SEL:%.*]], %[[LOOP]] ]\n; UNROLL-NO-IC-NEXT: [[L:%.*]] = load i32, ptr [[SRC]], align 4\n; UNROLL-NO-IC-NEXT: [[C:%.*]] = icmp eq i32 [[L]], 0\n; UNROLL-NO-IC-NEXT: [[SEL]] = select i1 [[C]], i16 1, i16 0\n; UNROLL-NO-IC-NEXT: [[IV_NEXT]] = add i16 [[IV]], 1\n; UNROLL-NO-IC-NEXT: [[EC:%.*]] = icmp eq i16 [[IV_NEXT]], 111\n; UNROLL-NO-IC-NEXT: br i1 [[EC]], label %[[EXIT:.*]], label %[[LOOP]], !llvm.loop [[LOOP5:![0-9]+]]\n; UNROLL-NO-IC: [[EXIT]]:\n; UNROLL-NO-IC-NEXT: [[P_LCSSA:%.*]] = phi i16 [ [[P]], %[[LOOP]] ]\n; UNROLL-NO-IC-NEXT: ret i16 [[P_LCSSA]]\n;\n; UNROLL-NO-VF-LABEL: define i16 @for_phi_removed(\n; UNROLL-NO-VF-SAME: ptr [[SRC:%.*]]) {\n; UNROLL-NO-VF-NEXT: [[ENTRY:.*]]:\n; UNROLL-NO-VF-NEXT: br i1 false, label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]\n; UNROLL-NO-VF: [[VECTOR_PH]]:\n; UNROLL-NO-VF-NEXT: br label %[[VECTOR_BODY:.*]]\n; UNROLL-NO-VF: [[VECTOR_BODY]]:\n; UNROLL-NO-VF-NEXT: [[INDEX:%.*]] = phi i32 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]\n; UNROLL-NO-VF-NEXT: [[TMP0:%.*]] = load i32, ptr [[SRC]], align 4\n; UNROLL-NO-VF-NEXT: [[TMP1:%.*]] = icmp eq i32 [[TMP0]], 0\n; UNROLL-NO-VF-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i16 1, i16 0\n; UNROLL-NO-VF-NEXT: [[INDEX_NEXT]] = add nuw i32 [[INDEX]], 2\n; UNROLL-NO-VF-NEXT: [[TMP3:%.*]] = icmp eq i32 [[INDEX_NEXT]], 110\n; UNROLL-NO-VF-NEXT: br i1 [[TMP3]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP4:![0-9]+]]\n; UNROLL-NO-VF: [[MIDDLE_BLOCK]]:\n; UNROLL-NO-VF-NEXT: br label %[[SCALAR_PH]]\n; UNROLL-NO-VF: [[SCALAR_PH]]:\n; UNROLL-NO-VF-NEXT: [[BC_RESUME_VAL:%.*]] = phi i16 [ 110, %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]\n; UNROLL-NO-VF-NEXT: [[SCALAR_RECUR_INIT:%.*]] = phi i16 [ [[TMP2]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]\n; UNROLL-NO-VF-NEXT: br label %[[LOOP:.*]]\n; UNROLL-NO-VF: [[LOOP]]:\n; UNROLL-NO-VF-NEXT: [[IV:%.*]] = phi i16 [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], %[[LOOP]] ]\n; UNROLL-NO-VF-NEXT: [[P:%.*]] = phi i16 [ [[SCALAR_RECUR_INIT]], %[[SCALAR_PH]] ], [ [[SEL:%.*]], %[[LOOP]] ]\n; UNROLL-NO-VF-NEXT: [[L:%.*]] = load i32, ptr [[SRC]], align 4\n; UNROLL-NO-VF-NEXT: [[C:%.*]] = icmp eq i32 [[L]], 0\n; UNROLL-NO-VF-NEXT: [[SEL]] = select i1 [[C]], i16 1, i16 0\n; UNROLL-NO-VF-NEXT: [[IV_NEXT]] = add i16 [[IV]], 1\n; UNROLL-NO-VF-NEXT: [[EC:%.*]] = icmp eq i16 [[IV_NEXT]], 111\n; UNROLL-NO-VF-NEXT: br i1 [[EC]], label %[[EXIT:.*]], label %[[LOOP]], !llvm.loop [[LOOP5:![0-9]+]]\n; UNROLL-NO-VF: [[EXIT]]:\n; UNROLL-NO-VF-NEXT: [[P_LCSSA:%.*]] = phi i16 [ [[P]], %[[LOOP]] ]\n; UNROLL-NO-VF-NEXT: ret i16 [[P_LCSSA]]\n;\n; SINK-AFTER-LABEL: define i16 @for_phi_removed(\n; SINK-AFTER-SAME: ptr [[SRC:%.*]]) {\n; SINK-AFTER-NEXT: [[ENTRY:.*]]:\n; SINK-AFTER-NEXT: br i1 false, label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]\n; SINK-AFTER: [[VECTOR_PH]]:\n; SINK-AFTER-NEXT: br label %[[VECTOR_BODY:.*]]\n; SINK-AFTER: [[VECTOR_BODY]]:\n; SINK-AFTER-NEXT: [[INDEX:%.*]] = phi i32 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]\n; SINK-AFTER-NEXT: [[TMP0:%.*]] = load i32, ptr [[SRC]], align 4\n; SINK-AFTER-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <4 x i32> poison, i32 [[TMP0]], i64 0\n; SINK-AFTER-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <4 x i32> [[BROADCAST_SPLATINSERT]], <4 x i32> poison, <4 x i32> zeroinitializer\n; SINK-AFTER-NEXT: [[TMP1:%.*]] = icmp eq <4 x i32> [[BROADCAST_SPLAT]], zeroinitializer\n; SINK-AFTER-NEXT: [[TMP2:%.*]] = select <4 x i1> [[TMP1]], <4 x i16> splat (i16 1), <4 x i16> zeroinitializer\n; SINK-AFTER-NEXT: [[INDEX_NEXT]] = add nuw i32 [[INDEX]], 4\n; SINK-AFTER-NEXT: [[TMP3:%.*]] = icmp eq i32 [[INDEX_NEXT]], 108\n; SINK-AFTER-NEXT: br i1 [[TMP3]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP4:![0-9]+]]\n; SINK-AFTER: [[MIDDLE_BLOCK]]:\n; SINK-AFTER-NEXT: [[VECTOR_RECUR_EXTRACT:%.*]] = extractelement <4 x i16> [[TMP2]], i32 3\n; SINK-AFTER-NEXT: br label %[[SCALAR_PH]]\n; SINK-AFTER: [[SCALAR_PH]]:\n; SINK-AFTER-NEXT: [[BC_RESUME_VAL:%.*]] = phi i16 [ 108, %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]\n; SINK-AFTER-NEXT: [[SCALAR_RECUR_INIT:%.*]] = phi i16 [ [[VECTOR_RECUR_EXTRACT]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]\n; SINK-AFTER-NEXT: br label %[[LOOP:.*]]\n; SINK-AFTER: [[LOOP]]:\n; SINK-AFTER-NEXT: [[IV:%.*]] = phi i16 [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], %[[LOOP]] ]\n; SINK-AFTER-NEXT: [[P:%.*]] = phi i16 [ [[SCALAR_RECUR_INIT]], %[[SCALAR_PH]] ], [ [[SEL:%.*]], %[[LOOP]] ]\n; SINK-AFTER-NEXT: [[L:%.*]] = load i32, ptr [[SRC]], align 4\n; SINK-AFTER-NEXT: [[C:%.*]] = icmp eq i32 [[L]], 0\n; SINK-AFTER-NEXT: [[SEL]] = select i1 [[C]], i16 1, i16 0\n; SINK-AFTER-NEXT: [[IV_NEXT]] = add i16 [[IV]], 1\n; SINK-AFTER-NEXT: [[EC:%.*]] = icmp eq i16 [[IV_NEXT]], 111\n; SINK-AFTER-NEXT: br i1 [[EC]], label %[[EXIT:.*]], label %[[LOOP]], !llvm.loop [[LOOP5:![0-9]+]]\n; SINK-AFTER: [[EXIT]]:\n; SINK-AFTER-NEXT: [[P_LCSSA:%.*]] = phi i16 [ [[P]], %[[LOOP]] ]\n; SINK-AFTER-NEXT: ret i16 [[P_LCSSA]]\n;\nentry:\n br label %loop\n\nloop:\n %iv = phi i16 [ 0, %entry ], [ %iv.next, %loop ]\n %p = phi i16 [ 0, %entry ] , [ %sel, %loop ]\n %l = load i32, ptr %src, align 4\n %c = icmp eq i32 %l, 0\n %sel = select i1 %c, i16 1, i16 0\n %iv.next = add i16 %iv, 1\n %ec = icmp eq i16 %iv.next, 111\n br i1 %ec, label %exit, label %loop\n\nexit:\n ret i16 %p\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[LoopVectorize] Instruction does not dominate all uses!",
"body": "Reproducer: https://godbolt.org/z/P1ea8d1bT\n```\n; bin/opt -passes=loop-vectorize test.ll -S\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i16 @main() {\nentry:\n br label %safe_lshift_func_uint16_t_u_s.exit.i.i\n\nsafe_lshift_func_uint16_t_u_s.exit.i.i: ; preds = %safe_lshift_func_uint16_t_u_s.exit.i.i, %entry\n %l_1488.0377.i.i = phi i16 [ 0, %entry ], [ %l_1488.2.lcssa.2.i.i, %safe_lshift_func_uint16_t_u_s.exit.i.i ]\n %storemerge376.i.i = phi i16 [ 1, %entry ], [ %inc275.i.i, %safe_lshift_func_uint16_t_u_s.exit.i.i ]\n %0 = load i32, ptr null, align 4\n %tobool254.not.2.i.i = icmp eq i32 %0, 0\n %l_1488.2.lcssa.2.i.i = select i1 %tobool254.not.2.i.i, i16 1, i16 0\n %inc275.i.i = add i16 %storemerge376.i.i, 1\n %exitcond.not.i.i = icmp eq i16 %inc275.i.i, 0\n br i1 %exitcond.not.i.i, label %func_210.exit, label %safe_lshift_func_uint16_t_u_s.exit.i.i\n\nfunc_210.exit: ; preds = %safe_lshift_func_uint16_t_u_s.exit.i.i\n ret i16 %l_1488.0377.i.i\n}\n```\n```\nInstruction does not dominate all uses!\n %4 = extractelement <4 x i16> %2, i32 0\n %scalar.recur.init = phi i16 [ %4, %middle.block ], [ 0, %entry ]\nInstruction does not dominate all uses!\n %2 = select <4 x i1> %1, <4 x i16> splat (i16 1), <4 x i16> zeroinitializer\n %4 = extractelement <4 x i16> %2, i32 0\nPHI nodes not grouped at top of basic block!\n %bc.resume.val = phi i16 [ -7, %middle.block ], [ 1, %entry ]\nlabel %scalar.ph\nopt: /root/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10182: bool llvm::LoopVectorizePass::processLoop(llvm::Loop*): Assertion `!verifyFunction(*F, &dbgs())' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=loop-vectorize <source>\n1.\tRunning pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"<source>\"\n2.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\n #0 0x000000000589ea68 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x589ea68)\n #1 0x000000000589b914 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007e16e6e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007e16e6e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007e16e6e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007e16e6e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x00007e16e6e2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x00007e16e6e39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x00000000036379e9 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x36379e9)\n #9 0x0000000003639970 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3639970)\n#10 0x000000000363a055 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x363a055)\n#11 0x0000000002f3481e llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2f3481e)\n#12 0x0000000005687c01 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5687c01)\n#13 0x0000000000eeb6ee llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xeeb6ee)\n#14 0x000000000568616a llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x568616a)\n#15 0x000000000096f08e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x96f08e)\n#16 0x0000000005685b21 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5685b21)\n#17 0x0000000000979388 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x979388)\n#18 0x000000000096d409 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x96d409)\n#19 0x00007e16e6e29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#20 0x00007e16e6e29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#21 0x0000000000964555 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x964555)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```\ncc @fhahn \n",
"author": "dtcxzyw",
"labels": [
"vectorizers",
"crash-on-valid",
"generated by fuzzer"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
157714
|
https://github.com/llvm/llvm-project/issues/157714
|
miscompilation
|
924bf242c8e0ef61544471488eb9e729dda72a50
| 2025-09-09T17:00:35 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "dcdbb39786a56181e1612354ecb8ecf5a7b0f449",
"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": [
[
2115,
2120
],
[
2123,
2129
],
[
2132,
2144
]
],
"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": [
"CommonPointerBase::compute"
],
"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 dcdbb39786a56181e1612354ecb8ecf5a7b0f449
Author: Nikita Popov <npopov@redhat.com>
Date: Wed Sep 10 15:57:27 2025 +0200
[InstCombine] Use intersectForOffsetAdd() in CommonPointerBase (#157851)
Transforms using this helper will add up all the offsets, so we should
use intersectForOffsetAdd() instead of plain intersection.
Annoyingly, this requires specially handling the first GEP to avoid
losing flags in that case.
Fixes https://github.com/llvm/llvm-project/issues/157714.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
index d934638c15e7..f9155cc66031 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
@@ -2115,6 +2115,7 @@ CommonPointerBase CommonPointerBase::compute(Value *LHS, Value *RHS) {
}
// Find common base and collect RHS GEPs.
+ bool First = true;
while (true) {
if (Ptrs.contains(RHS)) {
Base.Ptr = RHS;
@@ -2123,7 +2124,12 @@ CommonPointerBase CommonPointerBase::compute(Value *LHS, Value *RHS) {
if (auto *GEP = dyn_cast<GEPOperator>(RHS)) {
Base.RHSGEPs.push_back(GEP);
- Base.RHSNW &= GEP->getNoWrapFlags();
+ if (First) {
+ First = false;
+ Base.RHSNW = GEP->getNoWrapFlags();
+ } else {
+ Base.RHSNW = Base.RHSNW.intersectForOffsetAdd(GEP->getNoWrapFlags());
+ }
RHS = GEP->getPointerOperand();
} else {
// No common base.
@@ -2132,13 +2138,19 @@ CommonPointerBase CommonPointerBase::compute(Value *LHS, Value *RHS) {
}
// Collect LHS GEPs.
+ First = true;
while (true) {
if (LHS == Base.Ptr)
break;
auto *GEP = cast<GEPOperator>(LHS);
Base.LHSGEPs.push_back(GEP);
- Base.LHSNW &= GEP->getNoWrapFlags();
+ if (First) {
+ First = false;
+ Base.LHSNW = GEP->getNoWrapFlags();
+ } else {
+ Base.LHSNW = Base.LHSNW.intersectForOffsetAdd(GEP->getNoWrapFlags());
+ }
LHS = GEP->getPointerOperand();
}
|
[
{
"file": "llvm/test/Transforms/InstCombine/icmp-gep.ll",
"commands": [
"opt -passes=instcombine -S < %s"
],
"tests": [
{
"test_name": "gep_mugtiple_ugt_not_all_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_mugtiple_ugt_not_all_nuw(ptr %base, i64 %idx, i64 %idx2) {\n %gep1 = getelementptr nuw i32, ptr %base, i64 %idx\n %gep2 = getelementptr i32, ptr %gep1, i64 %idx2\n %cmp = icmp ugt ptr %gep2, %base\n ret i1 %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "gep_mugtiple_ugt_inbounds_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_mugtiple_ugt_inbounds_nusw(ptr %base, i64 %idx, i64 %idx2) {\n %gep1 = getelementptr inbounds i32, ptr %base, i64 %idx\n %gep2 = getelementptr nusw i32, ptr %gep1, i64 %idx2\n %cmp = icmp ugt ptr %gep2, %base\n ret i1 %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstCombine] Miscompilation in foldGEPICmp",
"body": "Reproducer: https://alive2.llvm.org/ce/z/SLybDz\n```\ndefine i1 @gep_mugtiple_ugt_inbounds_nusw(ptr %base, i64 %idx, i64 %idx2) {\n %gep1 = getelementptr inbounds i8, ptr %base, i64 %idx\n %gep2 = getelementptr nusw i8, ptr %gep1, i64 %idx2\n %cmp = icmp ugt ptr %gep2, %base\n ret i1 %cmp\n}\n```\n```\n=>\ndefine i1 @gep_mugtiple_ugt_inbounds_nusw(ptr %base, i64 %idx, i64 %idx2) {\n#0:\n %#1 = add i64 %idx, %idx2\n %cmp = icmp sgt i64 %#1, 0\n ret i1 %cmp\n}\nTransformation doesn't verify!\n\nERROR: Value mismatch\n\nExample:\nptr %base = pointer(non-local, block_id=1, offset=0) / Address=#x000000000000000c\ni64 %idx = #x7ffffffffffffffc (9223372036854775804)\ni64 %idx2 = #x0000000000000005 (5)\n\nSource:\nptr %gep1 = pointer(non-local, block_id=1, offset=9223372036854775804) / Address=#x8000000000000008\nptr %gep2 = pointer(non-local, block_id=1, offset=-9223372036854775807) / Address=#x800000000000000d\ni1 %cmp = #x1 (1)\n\nSOURCE MEMORY STATE\n===================\nNON-LOCAL BLOCKS:\nBlock 0 >\tsize: 0\talign: 1\talloc type: 0\talive: false\taddress: #x0000000000000000\nBlock 1 >\tsize: 9223372036854775804\talign: 1\talloc type: 0\talive: true\taddress: #x000000000000000c\n\nTarget:\ni64 %#1 = #x8000000000000001 (9223372036854775809, -9223372036854775807)\ni1 %cmp = #x0 (0)\nSource value: #x1 (1)\nTarget value: #x0 (0)\n```\ncc @nikic ",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:instcombine",
"generated by fuzzer"
],
"comments": [
{
"author": "nikic",
"body": "Probably CommonPointerBase needs to use intersectForOffsetAdd."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
150479
|
https://github.com/llvm/llvm-project/issues/150479
|
crash
|
8952225d88a5ce58a65c8b8695c610f4499d7181
| 2025-07-24T17:33:31 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "c9cea24fe68e24750b2d479144f839e1c2ec9d2b",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
6861,
6867
],
[
15704,
15710
],
[
15803,
15809
],
[
15816,
15822
],
[
16438,
16461
],
[
16470,
16482
],
[
16512,
16522
],
[
16554,
16560
],
[
16586,
16592
],
[
21001,
21009
],
[
21253,
21258
]
],
"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::computeMinimumValueSizes",
"BoUpSLP::getLastInstructionInBundle",
"BoUpSLP::getReorderingData",
"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 c9cea24fe68e24750b2d479144f839e1c2ec9d2b
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Thu Jul 24 11:40:26 2025 -0700
[SLP] Check if the user node has state before trying getting main instruction/opcode
Need to check if the parent node has state to prevent compiler crashes.
Fixes #150479
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 0adad5a90d31..44dc43d5e77c 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -6861,7 +6861,7 @@ BoUpSLP::getReorderingData(const TreeEntry &TE, bool TopToBottom,
return std::move(ResOrder);
}
if (TE.State == TreeEntry::StridedVectorize && !TopToBottom &&
- (!TE.UserTreeIndex ||
+ (!TE.UserTreeIndex || !TE.UserTreeIndex.UserTE->hasState() ||
!Instruction::isBinaryOp(TE.UserTreeIndex.UserTE->getOpcode())) &&
(TE.ReorderIndices.empty() || isReverseOrder(TE.ReorderIndices)))
return std::nullopt;
@@ -15704,7 +15704,8 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
const BasicBlock *TEInsertBlock = nullptr;
// Main node of PHI entries keeps the correct order of operands/incoming
// blocks.
- if (auto *PHI = dyn_cast<PHINode>(TEUseEI.UserTE->getMainOp());
+ if (auto *PHI = dyn_cast_or_null<PHINode>(
+ TEUseEI.UserTE->hasState() ? TEUseEI.UserTE->getMainOp() : nullptr);
PHI && TEUseEI.UserTE->State != TreeEntry::SplitVectorize) {
TEInsertBlock = PHI->getIncomingBlock(TEUseEI.EdgeIdx);
TEInsertPt = TEInsertBlock->getTerminator();
@@ -15803,7 +15804,8 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
"Expected only single user of a gather node.");
const EdgeInfo &UseEI = TEPtr->UserTreeIndex;
- PHINode *UserPHI = UseEI.UserTE->State != TreeEntry::SplitVectorize
+ PHINode *UserPHI = (UseEI.UserTE->State != TreeEntry::SplitVectorize &&
+ UseEI.UserTE->hasState())
? dyn_cast<PHINode>(UseEI.UserTE->getMainOp())
: nullptr;
Instruction *InsertPt =
@@ -15816,7 +15818,8 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
TEUseEI.UserTE->isAltShuffle()) &&
all_of(TEUseEI.UserTE->Scalars, isUsedOutsideBlock)) {
if (UseEI.UserTE->State != TreeEntry::Vectorize ||
- (UseEI.UserTE->getOpcode() == Instruction::PHI &&
+ (UseEI.UserTE->hasState() &&
+ UseEI.UserTE->getOpcode() == Instruction::PHI &&
!UseEI.UserTE->isAltShuffle()) ||
!all_of(UseEI.UserTE->Scalars, isUsedOutsideBlock))
continue;
@@ -16438,24 +16441,31 @@ Instruction &BoUpSLP::getLastInstructionInBundle(const TreeEntry *E) {
// Get the basic block this bundle is in. All instructions in the bundle
// should be in this block (except for extractelement-like instructions with
// constant indices or gathered loads or copyables).
- auto *Front = E->getMainOp();
+ Instruction *Front;
+ unsigned Opcode;
+ if (E->hasState()) {
+ Front = E->getMainOp();
+ Opcode = E->getOpcode();
+ } else {
+ Front = cast<Instruction>(*find_if(E->Scalars, IsaPred<Instruction>));
+ Opcode = Front->getOpcode();
+ }
auto *BB = Front->getParent();
- assert(((GatheredLoadsEntriesFirst.has_value() &&
- E->getOpcode() == Instruction::Load && E->isGather() &&
- E->Idx < *GatheredLoadsEntriesFirst) ||
- E->State == TreeEntry::SplitVectorize || E->hasCopyableElements() ||
- all_of(E->Scalars,
- [=](Value *V) -> bool {
- if (E->getOpcode() == Instruction::GetElementPtr &&
- !isa<GetElementPtrInst>(V))
- return true;
- auto *I = dyn_cast<Instruction>(V);
- return !I || !E->getMatchingMainOpOrAltOp(I) ||
- I->getParent() == BB ||
- isVectorLikeInstWithConstOps(I);
- })) &&
- "Expected gathered loads or GEPs or instructions from same basic "
- "block.");
+ assert(
+ ((GatheredLoadsEntriesFirst.has_value() && Opcode == Instruction::Load &&
+ E->isGather() && E->Idx < *GatheredLoadsEntriesFirst) ||
+ E->State == TreeEntry::SplitVectorize || E->hasCopyableElements() ||
+ all_of(E->Scalars,
+ [=](Value *V) -> bool {
+ if (Opcode == Instruction::GetElementPtr &&
+ !isa<GetElementPtrInst>(V))
+ return true;
+ auto *I = dyn_cast<Instruction>(V);
+ return !I || !E->getMatchingMainOpOrAltOp(I) ||
+ I->getParent() == BB || isVectorLikeInstWithConstOps(I);
+ })) &&
+ "Expected gathered loads or GEPs or instructions from same basic "
+ "block.");
auto FindLastInst = [&]() {
Instruction *LastInst = Front;
@@ -16470,13 +16480,13 @@ Instruction &BoUpSLP::getLastInstructionInBundle(const TreeEntry *E) {
LastInst = I;
continue;
}
- assert(((E->getOpcode() == Instruction::GetElementPtr &&
+ assert(((Opcode == Instruction::GetElementPtr &&
!isa<GetElementPtrInst>(I)) ||
E->State == TreeEntry::SplitVectorize ||
(isVectorLikeInstWithConstOps(LastInst) &&
isVectorLikeInstWithConstOps(I)) ||
(GatheredLoadsEntriesFirst.has_value() &&
- E->getOpcode() == Instruction::Load && E->isGather() &&
+ Opcode == Instruction::Load && E->isGather() &&
E->Idx < *GatheredLoadsEntriesFirst)) &&
"Expected vector-like or non-GEP in GEP node insts only.");
if (!DT->isReachableFromEntry(LastInst->getParent())) {
@@ -16512,11 +16522,11 @@ Instruction &BoUpSLP::getLastInstructionInBundle(const TreeEntry *E) {
FirstInst = I;
continue;
}
- assert(((E->getOpcode() == Instruction::GetElementPtr &&
- !isa<GetElementPtrInst>(I)) ||
- (isVectorLikeInstWithConstOps(FirstInst) &&
- isVectorLikeInstWithConstOps(I))) &&
- "Expected vector-like or non-GEP in GEP node insts only.");
+ assert(((Opcode == Instruction::GetElementPtr &&
+ !isa<GetElementPtrInst>(I)) ||
+ (isVectorLikeInstWithConstOps(FirstInst) &&
+ isVectorLikeInstWithConstOps(I))) &&
+ "Expected vector-like or non-GEP in GEP node insts only.");
if (!DT->isReachableFromEntry(FirstInst->getParent())) {
FirstInst = I;
continue;
@@ -16554,7 +16564,7 @@ Instruction &BoUpSLP::getLastInstructionInBundle(const TreeEntry *E) {
// Set insertpoint for gathered loads to the very first load.
if (GatheredLoadsEntriesFirst.has_value() &&
E->Idx >= *GatheredLoadsEntriesFirst && !E->isGather() &&
- E->getOpcode() == Instruction::Load) {
+ Opcode == Instruction::Load) {
Res = FindFirstInst();
EntryToLastInstruction.try_emplace(E, Res);
return *Res;
@@ -16586,7 +16596,7 @@ Instruction &BoUpSLP::getLastInstructionInBundle(const TreeEntry *E) {
};
const ScheduleBundle *Bundle = FindScheduleBundle(E);
if (!E->isGather() && !Bundle) {
- if ((E->getOpcode() == Instruction::GetElementPtr &&
+ if ((Opcode == Instruction::GetElementPtr &&
any_of(E->Scalars,
[](Value *V) {
return !isa<GetElementPtrInst>(V) && isa<Instruction>(V);
@@ -21001,9 +21011,10 @@ void BoUpSLP::computeMinimumValueSizes() {
if (!isa<CastInst, BinaryOperator, FreezeInst, PHINode,
SelectInst>(U) ||
isa<SIToFPInst, UIToFPInst>(U) ||
- !isa<CastInst, BinaryOperator, FreezeInst, PHINode,
- SelectInst>(UserTE->getMainOp()) ||
- isa<SIToFPInst, UIToFPInst>(UserTE->getMainOp()))
+ (UserTE->hasState() &&
+ (!isa<CastInst, BinaryOperator, FreezeInst, PHINode,
+ SelectInst>(UserTE->getMainOp()) ||
+ isa<SIToFPInst, UIToFPInst>(UserTE->getMainOp()))))
return true;
unsigned UserTESz = DL->getTypeSizeInBits(
UserTE->Scalars.front()->getType());
@@ -21253,6 +21264,7 @@ void BoUpSLP::computeMinimumValueSizes() {
NodeIdx < VectorizableTree.size() &&
VectorizableTree[NodeIdx]->UserTreeIndex &&
VectorizableTree[NodeIdx]->UserTreeIndex.EdgeIdx == 0 &&
+ VectorizableTree[NodeIdx]->UserTreeIndex.UserTE->hasState() &&
VectorizableTree[NodeIdx]->UserTreeIndex.UserTE->getOpcode() ==
Instruction::Trunc &&
!VectorizableTree[NodeIdx]->UserTreeIndex.UserTE->isAltShuffle();
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/user-node-no-state.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n@g = global [128 x i8] zeroinitializer, align 16\n\ndefine i64 @test() {\n;\nentry:\n %0 = load i64, ptr @g, align 8\n br label %func_154.exit.func_146.exit_crit_edge.i\n\nfunc_154.exit.func_146.exit_crit_edge.i:\n %1 = load i64, ptr getelementptr inbounds nuw (i8, ptr @g, i64 80), align 16\n %2 = load i64, ptr getelementptr inbounds nuw (i8, ptr @g, i64 88), align 8\n %3 = load i64, ptr getelementptr inbounds nuw (i8, ptr @g, i64 32), align 16\n %4 = load i64, ptr @g, align 16\n %5 = load i64, ptr getelementptr inbounds nuw (i8, ptr @g, i64 8), align 8\n %6 = load i64, ptr @g, align 16\n %7 = load i64, ptr getelementptr inbounds nuw (i8, ptr @g, i64 24), align 8\n %8 = xor i64 %1, %2\n %9 = xor i64 %8, %3\n %10 = xor i64 %9, %4\n %11 = xor i64 %10, %5\n %12 = xor i64 %11, %6\n %13 = xor i64 %12, %7\n %14 = xor i64 %13, %0\n ret i64 %14\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SLPVectorizer] Assertion `valid() && \"InstructionsState is invalid.\"' failed.",
"body": "Reproducer: https://godbolt.org/z/Pj96ao9TK\n```\n; bin/opt -passes=slp-vectorizer test.ll -S\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@g = global [128 x i8] zeroinitializer, align 16\n\ndefine i64 @main() {\nentry:\n %0 = load i64, ptr @g, align 8\n br label %func_154.exit.func_146.exit_crit_edge.i\n\nfunc_154.exit.func_146.exit_crit_edge.i: ; preds = %entry\n %1 = load i64, ptr getelementptr inbounds nuw (i8, ptr @g, i64 80), align 16\n %2 = load i64, ptr getelementptr inbounds nuw (i8, ptr @g, i64 88), align 8\n %3 = load i64, ptr getelementptr inbounds nuw (i8, ptr @g, i64 32), align 16\n %4 = load i64, ptr @g, align 16\n %5 = load i64, ptr getelementptr inbounds nuw (i8, ptr @g, i64 8), align 8\n %6 = load i64, ptr @g, align 16\n %7 = load i64, ptr getelementptr inbounds nuw (i8, ptr @g, i64 24), align 8\n %8 = xor i64 %1, %2\n %9 = xor i64 %8, %3\n %10 = xor i64 %9, %4\n %11 = xor i64 %10, %5\n %12 = xor i64 %11, %6\n %13 = xor i64 %12, %7\n %14 = xor i64 %13, %0\n ret i64 %14\n}\n```\n```\nopt: /root/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:1204: llvm::Instruction* {anonymous}::InstructionsState::getMainOp() const: Assertion `valid() && \"InstructionsState is invalid.\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\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 0x0000000005664458 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5664458)\n #1 0x0000000005661304 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x000075a3c1242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x000075a3c12969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x000075a3c1242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x000075a3c12287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x000075a3c122871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x000075a3c1239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x00000000034a0043 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x34a0043)\n #9 0x0000000003513355 llvm::slpvectorizer::BoUpSLP::getLastInstructionInBundle(llvm::slpvectorizer::BoUpSLP::TreeEntry const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3513355)\n#10 0x000000000355424e llvm::slpvectorizer::BoUpSLP::isGatherShuffledSingleRegisterEntry(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::MutableArrayRef<int>, llvm::SmallVectorImpl<llvm::slpvectorizer::BoUpSLP::TreeEntry const*>&, unsigned int, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x355424e)\n#11 0x0000000003558408 llvm::slpvectorizer::BoUpSLP::isGatherShuffledEntry(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallVectorImpl<int>&, llvm::SmallVectorImpl<llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, 6u>>&, unsigned int, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3558408)\n#12 0x000000000355a2de 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+0x355a2de)\n#13 0x000000000355c98f 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+0x355c98f)\n#14 0x000000000359597f llvm::slpvectorizer::BoUpSLP::getTreeCost(llvm::ArrayRef<llvm::Value*>, llvm::InstructionCost) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x359597f)\n#15 0x000000000359ba1b (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&, llvm::AssumptionCache*) SLPVectorizer.cpp:0:0\n#16 0x000000000359ef90 llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x359ef90)\n#17 0x00000000035a430b llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (.constprop.0) SLPVectorizer.cpp:0:0\n#18 0x00000000035a8c0f llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x35a8c0f)\n#19 0x00000000035aef06 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 0x00000000035af9eb llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x35af9eb)\n#21 0x0000000002dab8ce 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+0x2dab8ce)\n#22 0x0000000005456241 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5456241)\n#23 0x0000000000eb675e 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+0xeb675e)\n#24 0x0000000005456714 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5456714)\n#25 0x0000000000eb6a2e 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+0xeb6a2e)\n#26 0x00000000054542e1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x54542e1)\n#27 0x0000000000964bfa 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+0x964bfa)\n#28 0x0000000000958c79 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x958c79)\n#29 0x000075a3c1229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#30 0x000075a3c1229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#31 0x000000000094fd45 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x94fd45)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```\n\nI found this crash when fuzzing the code in https://github.com/llvm/llvm-project/pull/137297.\n",
"author": "dtcxzyw",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid",
"generated by fuzzer"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
76713
|
https://github.com/llvm/llvm-project/issues/76713
|
miscompilation
|
71bcef0b0bf55a96f85b2f323b0beb13ad8e2caa
| 2024-01-02T12:49:15 |
[
"llvm/test/Transforms/ConstraintElimination"
] |
{
"fix_commit": "3c127e83c07c3791e86413c22a414a030d4302e3",
"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": [
[
366,
371
],
[
569,
578
]
],
"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": [
"add",
"decompose",
"mul"
],
"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 3c127e83c07c3791e86413c22a414a030d4302e3
Author: Florian Hahn <flo@fhahn.com>
Date: Tue Jan 2 22:05:57 2024 +0000
[ConstraintElim] Replace NUWSub decomp with recursive decomp of ops.
The current patterns for NUWSub decompositions do not handle negative
constants correctly at the moment (causing #76713).
Replace the incorrect pattern by more general code that recursively
decomposes the operands and then combines the results. This is already
done in most other places that handle operators like add/mul.
This means we fall back to the general constant handling code (fixes the
mis-compile) while also being able to support reasoning about
decomposable expressions in the SUB operands.
Fixes https://github.com/llvm/llvm-project/issues/76713.
diff --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
index 49ac1e96e255..06c87bd6dc37 100644
--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -366,6 +366,13 @@ struct Decomposition {
append_range(Vars, Other.Vars);
}
+ void sub(const Decomposition &Other) {
+ Decomposition Tmp = Other;
+ Tmp.mul(-1);
+ add(Tmp.Offset);
+ append_range(Vars, Tmp.Vars);
+ }
+
void mul(int64_t Factor) {
Offset = multiplyWithOverflow(Offset, Factor);
for (auto &Var : Vars)
@@ -569,10 +576,12 @@ static Decomposition decompose(Value *V,
return Result;
}
- if (match(V, m_NUWSub(m_Value(Op0), m_ConstantInt(CI))) && canUseSExt(CI))
- return {-1 * CI->getSExtValue(), {{1, Op0}}};
- if (match(V, m_NUWSub(m_Value(Op0), m_Value(Op1))))
- return {0, {{1, Op0}, {-1, Op1}}};
+ if (match(V, m_NUWSub(m_Value(Op0), m_Value(Op1)))) {
+ auto ResA = decompose(Op0, Preconditions, IsSigned, DL);
+ auto ResB = decompose(Op1, Preconditions, IsSigned, DL);
+ ResA.sub(ResB);
+ return ResA;
+ }
return {V, IsKnownNonNegative};
}
|
[
{
"file": "llvm/test/Transforms/ConstraintElimination/sub-nuw.ll",
"commands": [
"opt -passes=constraint-elimination -S %s"
],
"tests": [
{
"test_name": "pr76713",
"test_body": "define i1 @pr76713(i16 %i1, i16 %i3) {\nentry:\n %c1 = icmp ult i16 %i1, -1\n %c2 = icmp uge i16 %i1, -3\n %c3 = icmp ult i16 %i3, 2\n %and = and i1 %c1, %c2\n %and.2 = and i1 %and, %c3\n br i1 %and, label %then, label %else\n\nthen: ; preds = %entry\n %sub = sub nuw nsw i16 %i1, -3\n %arrayidx.idx = mul nuw nsw i16 %i3, 4\n %i6 = add nuw nsw i16 %arrayidx.idx, %sub\n %c4 = icmp ult i16 12, %i6\n ret i1 %c4\n\nelse: ; preds = %entry\n ret i1 false\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "sub_nuw_chained_negative_constants",
"test_body": "declare void @use(i1)\n\ndefine void @sub_nuw_chained_negative_constants(i8 %a) {\nentry:\n %sub1 = sub nuw i8 %a, 10\n %sub2 = sub nuw i8 %sub1, -126\n %c.1 = icmp ugt i8 %sub2, 20\n br i1 %c.1, label %exit.1, label %exit.2\n\nexit.1: ; preds = %entry\n %c.2 = icmp ugt i8 %a, -96\n call void @use(i1 %c.2)\n %c.3 = icmp ugt i8 %a, -95\n call void @use(i1 %c.3)\n ret void\n\nexit.2: ; preds = %entry\n %c.4 = icmp ugt i8 %a, -96\n call void @use(i1 %c.4)\n %c.5 = icmp ugt i8 %a, -95\n call void @use(i1 %c.5)\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "sub_nuw_neg_i16",
"test_body": "define i1 @sub_nuw_neg_i16(i16 %a) {\nentry:\n %neg2 = sub nuw i16 %a, -305\n %c.1 = icmp ugt i16 0, %neg2\n br i1 %c.1, label %exit.1, label %exit.2\n\nexit.1: ; preds = %entry\n %c.2 = icmp ugt i16 %a, 0\n ret i1 %c.2\n\nexit.2: ; preds = %entry\n %c.3 = icmp ugt i16 %a, 0\n ret i1 %c.3\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "sub_nuw_chained_positive_constants",
"test_body": "declare void @use(i1)\n\ndefine void @sub_nuw_chained_positive_constants(i16 %a) {\nentry:\n %sub1 = sub nuw i16 %a, 10\n %sub2 = sub nuw i16 %sub1, 20\n %c.1 = icmp ugt i16 %sub2, 90\n br i1 %c.1, label %exit.1, label %exit.2\n\nexit.1: ; preds = %entry\n %c.2 = icmp ugt i16 %a, 120\n call void @use(i1 %c.2)\n %c.3 = icmp ugt i16 %a, 121\n call void @use(i1 %c.3)\n ret void\n\nexit.2: ; preds = %entry\n %c.4 = icmp ugt i16 %a, 120\n call void @use(i1 %c.4)\n %c.5 = icmp ugt i16 %a, 121\n call void @use(i1 %c.5)\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Miscompile with opt -passes=\"constraint-elimination\"",
"body": "llvm commit: 5842dfe34d89\r\nReproduce with: ```opt -passes=\"constraint-elimination\" bbi-90501.ll -S -o -```\r\n[bbi-90501.ll.gz](https://github.com/llvm/llvm-project/files/13810077/bbi-90501.ll.gz)\r\n\r\nThere are two nested loops in the input that should finish and then we should end up at\r\n```\r\nbb.2: ; preds = %bb.1\r\n ret i16 0\r\n```\r\nbut with constraint-elimination the condition in bb.5 is changed to\r\n```\r\n %i10 = or i1 true, %i9\r\n br i1 %i10, label %bb.7, label %bb.6\r\n```\r\nso we will go to\r\n```\r\nbb.7: ; preds = %bb.5\r\n ret i16 1\r\n```\r\ninstead.",
"author": "mikaelholmen",
"labels": [
"miscompilation",
"llvm:transforms"
],
"comments": [
{
"author": "mikaelholmen",
"body": "This starts happening with e6a1657fa30c747f4412fc47f567660ebe861a9e\r\n```\r\n[ConstraintElim] Add A < B if A is an increasing phi for A != B.\r\n```\r\n@fhahn : any idea what's up?"
},
{
"author": "fhahn",
"body": "Looks like an issue with `sub` decomposition with negative constants, preparing a fix."
},
{
"author": "mikaelholmen",
"body": "Thanks for the quick fix! I've verified it solves the problem I saw."
},
{
"author": "fhahn",
"body": "@mikaelholmen thanks for the reproducer!"
},
{
"author": "fhahn",
"body": "(appreciated as always, thanks for your extensive testing)"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
132563
|
https://github.com/llvm/llvm-project/issues/132563
|
crash
|
57530c23a53b5e003d389437637f61c5b9814e22
| 2025-03-22T20:38:57 |
[
"llvm/test/Transforms/VectorCombine"
] |
{
"fix_commit": "f572a5951a664d57e909928d5595285212ad6884",
"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": [
[
1438,
1443
],
[
1445,
1451
]
],
"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": [
"canScalarizeAccess"
],
"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 f572a5951a664d57e909928d5595285212ad6884
Author: Simon Pilgrim <llvm-dev@redking.me.uk>
Date: Thu Apr 24 14:17:46 2025 +0100
[VectorCombine] Ensure canScalarizeAccess handles cases where the index type can't represent all inbounds values
Fixes #132563
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index bd225bcc0635..04c084ffdda9 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -1438,6 +1438,7 @@ static ScalarizationResult canScalarizeAccess(VectorType *VecTy, Value *Idx,
// This is the number of elements of fixed vector types,
// or the minimum number of elements of scalable vector types.
uint64_t NumElements = VecTy->getElementCount().getKnownMinValue();
+ unsigned IntWidth = Idx->getType()->getScalarSizeInBits();
if (auto *C = dyn_cast<ConstantInt>(Idx)) {
if (C->getValue().ult(NumElements))
@@ -1445,7 +1446,10 @@ static ScalarizationResult canScalarizeAccess(VectorType *VecTy, Value *Idx,
return ScalarizationResult::unsafe();
}
- unsigned IntWidth = Idx->getType()->getScalarSizeInBits();
+ // Always unsafe if the index type can't handle all inbound values.
+ if (!llvm::isUIntN(IntWidth, NumElements))
+ return ScalarizationResult::unsafe();
+
APInt Zero(IntWidth, 0);
APInt MaxElts(IntWidth, NumElements);
ConstantRange ValidIndices(Zero, MaxElts);
|
[
{
"file": "llvm/test/Transforms/VectorCombine/pr132563.ll",
"commands": [
"opt -passes=vector-combine -S %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n; Ensure canScalarizeAccess handles cases where the index type can't represent all inbounds values\n\ndefine void @src_1_idx(ptr %q, i8 zeroext %s, i1 %idx) {\n;\n %ld = load <16 x i8>, ptr %q\n %v1 = insertelement <16 x i8> %ld, i8 %s, i1 %idx\n store <16 x i8> %v1, ptr %q\n ret void\n}\n\ndefine void @src_2_idx(ptr %q, i8 zeroext %s, i8 %idx) {\n;\n %ld = load <256 x i8>, ptr %q\n %v1 = insertelement <256 x i8> %ld, i8 %s, i8 %idx\n store <256 x i8> %v1, ptr %q\n ret void\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[VectorCombine] Crash occured while fold load-insertelement-store",
"body": "This is an IR sample that crashes.\n\n```\ndefine void @src_1_idx(ptr %q, i8 zeroext %s, i1 %idx) {\nentry:\n %0 = load <16 x i8>, ptr %q\n %v1 = insertelement <16 x i8> %0, i8 %s, i1 %idx\n store <16 x i8> %v1, ptr %q\n ret void\n}\n\ndefine void @src_2_idx(ptr %q, i8 zeroext %s, i8 %idx) {\nentry:\n %0 = load <256 x i8>, ptr %q\n %v1 = insertelement <256 x i8> %0, i8 %s, i8 %idx\n store <256 x i8> %v1, ptr %q\n ret void\n}\n```\n\nand this is debugging message with crash dump\n```\nVECTORCOMBINE on src_2_idx\nVC: Visiting: %0 = load <16 x i8>, ptr %q, align 16\nVC: Visiting: %v1 = insertelement <16 x i8> %0, i8 %s, i1 %idx\nVC: Visiting: store <16 x i8> %v1, ptr %q, align 16\nAssertion failed: (llvm::isUIntN(BitWidth, val) && \"Value is not an N-bit unsigned value\"), function APInt, file APInt.h, line 128.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0.\tProgram arguments: bin/opt -passes=vector-combine t1.ll -S -debug\n1.\tRunning pass \"function(vector-combine)\" on module \"t1.ll\"\n2.\tRunning pass \"vector-combine\" on function \"src_2_idx\"\n #0 0x00000001026ca6ac llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/Users/b2sy/work/test3/bin/opt+0x1019566ac)\n #1 0x00000001026c8770 llvm::sys::RunSignalHandlers() (/Users/b2sy/work/test3/bin/opt+0x101954770)\n #2 0x00000001026cae7c SignalHandler(int, __siginfo*, void*) (/Users/b2sy/work/test3/bin/opt+0x101956e7c)\n #3 0x000000019733ede4 (/usr/lib/system/libsystem_platform.dylib+0x180482de4)\n #4 0x0000000197307f70 (/usr/lib/system/libsystem_pthread.dylib+0x18044bf70)\n #5 0x0000000197214908 (/usr/lib/system/libsystem_c.dylib+0x180358908)\n #6 0x0000000197213c1c (/usr/lib/system/libsystem_c.dylib+0x180357c1c)\n #7 0x00000001032ad794 isUpperSubvectorUndef(llvm::SDValue, llvm::SDLoc const&, llvm::SelectionDAG&) (.cold.2) (/Users/b2sy/work/test3/bin/opt+0x102539794)\n #8 0x00000001029c4990 canScalarizeAccess(llvm::VectorType*, llvm::Value*, llvm::Instruction*, llvm::AssumptionCache&, llvm::DominatorTree const&) (/Users/b2sy/work/test3/bin/opt+0x101c50990)\n```\n\nproblem occured here \n```\n// VectorCombine.cpp:1447\n unsigned IntWidth = Idx->getType()->getScalarSizeInBits();\n APInt Zero(IntWidth, 0); \n APInt MaxElts(IntWidth, NumElements); <<< crash\n ConstantRange ValidIndices(Zero, MaxElts);\n ConstantRange IdxRange(IntWidth, true);\n```\n\nI think this code is necessary because it checks to see if the index specified by insertelement is in an accessible range on the vector, so I think we need to add exception handling to fix the problem.\n\nWhat do you think?\n\nNote that this is not a real-world issue, but a bug that I discovered while writing the patch and creating the verification code.\n\n",
"author": "ParkHanbum",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "ParkHanbum",
"body": "No. I am trying to verify i8 type for that IR because I was trying to support multiple inserts but alive didn't make it. So i reduce type size then occured this issue."
},
{
"author": "RKSimon",
"body": "I'm not sure whether this should be addressed or not - oddly the langref doesn't say that the index type must be able to dereference all elements, just that its treated as unsigned (so I guess we assume implicit zext?)"
},
{
"author": "RKSimon",
"body": "@dtcxzyw Do you know whether smaller index types are handled anywhere else in the codebase please?"
},
{
"author": "dtcxzyw",
"body": "> [@dtcxzyw](https://github.com/dtcxzyw) Do you know whether smaller index types are handled anywhere else in the codebase please?\n\nI don't know. But this crash can be fixed by passing `implicitTrunc=true` into the APInt constructor, as we did in https://github.com/llvm/llvm-project/pull/80309.\n"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
89672
|
https://github.com/llvm/llvm-project/issues/89672
|
miscompilation
|
b64e483785bfef5ec4977988543ed5cfaf62f306
| 2024-04-22T21:35:16 |
[
"llvm/test/Transforms/SimplifyCFG"
] |
{
"fix_commit": "883887493c882d656d5da100ee637a348e81357c",
"components": [
"SimplifyCFG"
],
"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": [
[
2888,
2894
],
[
2896,
2902
]
],
"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": 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": [
"isSafeToSpeculateStore"
],
"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 883887493c882d656d5da100ee637a348e81357c
Author: Nikita Popov <npopov@redhat.com>
Date: Tue Apr 23 12:36:35 2024 +0900
[SimplifyCFG] Check alignment when speculating stores
When speculating a store based on a preceding load/store, we need
to ensure that the speculated store does not have a higher
alignment (which might only be guaranteed by the branch condition).
There are various ways in which this could be strengthened (we
could get or enforce the alignment), but for now just do the
simple check against the preceding load/store.
Fixes https://github.com/llvm/llvm-project/issues/89672.
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index da3eb229c041..0826d748ba0d 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -2888,7 +2888,8 @@ static Value *isSafeToSpeculateStore(Instruction *I, BasicBlock *BrBB,
// simple, to avoid introducing a spurious non-atomic write after an
// atomic write.
if (SI->getPointerOperand() == StorePtr &&
- SI->getValueOperand()->getType() == StoreTy && SI->isSimple())
+ SI->getValueOperand()->getType() == StoreTy && SI->isSimple() &&
+ SI->getAlign() >= StoreToHoist->getAlign())
// Found the previous store, return its value operand.
return SI->getValueOperand();
return nullptr; // Unknown store.
@@ -2896,7 +2897,7 @@ static Value *isSafeToSpeculateStore(Instruction *I, BasicBlock *BrBB,
if (auto *LI = dyn_cast<LoadInst>(&CurI)) {
if (LI->getPointerOperand() == StorePtr && LI->getType() == StoreTy &&
- LI->isSimple()) {
+ LI->isSimple() && LI->getAlign() >= StoreToHoist->getAlign()) {
// Local objects (created by an `alloca` instruction) are always
// writable, so once we are past a read from a location it is valid to
// also write to that same location.
|
[
{
"file": "llvm/test/Transforms/SimplifyCFG/speculate-store.ll",
"commands": [
"opt -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S < %s"
],
"tests": [
{
"test_name": "wrong_align_store",
"test_body": "define void @wrong_align_store(ptr %A, i32 %B, i32 %C, i32 %D) {\nentry:\n store i32 %B, ptr %A, align 4\n %cmp = icmp sgt i32 %D, 42\n br i1 %cmp, label %if.then, label %ret.end\n\nif.then: ; preds = %entry\n store i32 %C, ptr %A, align 8\n br label %ret.end\n\nret.end: ; preds = %if.then, %entry\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "wrong_align_load",
"test_body": "define void @wrong_align_load(i32 %C, i32 %D) {\nentry:\n %A = alloca i32, align 4\n %0 = load i32, ptr %A, align 4\n %cmp = icmp sgt i32 %D, 42\n br i1 %cmp, label %if.then, label %ret.end\n\nif.then: ; preds = %entry\n store i32 %C, ptr %A, align 8\n br label %ret.end\n\nret.end: ; preds = %if.then, %entry\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "coalescing of redundant vector stores isn't preserving alignment correctly",
"body": "https://alive2.llvm.org/ce/z/-qQphe\r\n\r\noptimizing this code:\r\n```llvm\r\ndefine i32 @f(ptr %0, i1 %1) {\r\n store <2 x i64> zeroinitializer, ptr %0, align 8\r\n br i1 %1, label %4, label %3\r\n\r\n3: ; preds = %2\r\n store <2 x i64> zeroinitializer, ptr %0, align 16\r\n br label %4\r\n\r\n4: ; preds = %3, %2\r\n ret i32 0\r\n}\r\n```\r\n\r\nis mostly doing what we expect, but the coalesced store should retain the smaller alignnment value of the two, not the larger:\r\n```lllvm\r\ndefine noundef i32 @f(ptr nocapture writeonly %0, i1 %1) local_unnamed_addr #0 {\r\n store <2 x i64> zeroinitializer, ptr %0, align 16\r\n ret i32 0\r\n}\r\n\r\nattributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) }\r\n```\r\n\r\ncc @nunoplopes @hatsunespica",
"author": "regehr",
"labels": [
"miscompilation",
"llvm:transforms"
],
"comments": [
{
"author": "nikic",
"body": "The issue is introduced by SimplifyCFG: https://alive2.llvm.org/ce/z/zf-j74"
},
{
"author": "nikic",
"body": "Specifically this is isSafeToSpeculateStore(), which looks for a preceding store to check whether it is safe to speculate, but fails to check alignment."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
79742
|
https://github.com/llvm/llvm-project/issues/79742
|
crash
|
a9689c6029e3078e09e43a4efb2b2ced98e9020f
| 2024-01-28T09:40:40 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "17fb3e82f6c950267bb01cc2fd2a84b0d9e9d0d8",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
1031,
1037
],
[
1040,
1047
]
],
"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 17fb3e82f6c950267bb01cc2fd2a84b0d9e9d0d8
Author: Florian Hahn <flo@fhahn.com>
Date: Tue Apr 23 11:50:25 2024 +0100
[VPlan] Skip extending ICmp results in trunateToMinimalBitwidth.
Results of icmp don't need extending after truncating their operands, as
the result will always be i1. Skip them during extending.
Fixes https://github.com/llvm/llvm-project/issues/79742
Fixes https://github.com/llvm/llvm-project/issues/85185
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 007dc3f89b3f..9580dc4a27f6 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -1031,7 +1031,9 @@ void VPlanTransforms::truncateToMinimalBitwidths(
if (auto *VPW = dyn_cast<VPRecipeWithIRFlags>(&R))
VPW->dropPoisonGeneratingFlags();
- if (OldResSizeInBits != NewResSizeInBits) {
+ using namespace llvm::VPlanPatternMatch;
+ if (OldResSizeInBits != NewResSizeInBits &&
+ !match(&R, m_Binary<Instruction::ICmp>(m_VPValue(), m_VPValue()))) {
// Extend result to original width.
auto *Ext =
new VPWidenCastRecipe(Instruction::ZExt, ResultVPV, OldResTy);
@@ -1040,8 +1042,9 @@ void VPlanTransforms::truncateToMinimalBitwidths(
Ext->setOperand(0, ResultVPV);
assert(OldResSizeInBits > NewResSizeInBits && "Nothing to shrink?");
} else
- assert(cast<VPWidenRecipe>(&R)->getOpcode() == Instruction::ICmp &&
- "Only ICmps should not need extending the result.");
+ assert(
+ match(&R, m_Binary<Instruction::ICmp>(m_VPValue(), m_VPValue())) &&
+ "Only ICmps should not need extending the result.");
assert(!isa<VPWidenStoreRecipe>(&R) && "stores cannot be narrowed");
if (isa<VPWidenLoadRecipe>(&R))
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/trunc-extended-icmps.ll",
"commands": [
"opt -p loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -S %s"
],
"tests": [
{
"test_name": "test_icmp_and_op_zext",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine i32 @test_icmp_and_op_zext(ptr %dst, i64 %a) {\nentry:\n %and = and i64 %a, 7304878031173690989\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i16 [ 1, %entry ], [ %iv.next, %loop ]\n %c = icmp ne i64 %and, 0\n %c.ext = zext i1 %c to i64\n %or = or i64 %and, %c.ext\n %or.trunc = trunc i64 %or to i8\n %gep = getelementptr i8, ptr %dst, i16 %iv\n store i8 %or.trunc, ptr %gep, align 1\n %iv.next = add i16 %iv, 1\n %ec = icmp eq i16 %iv.next, 1000\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i32 0\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "ext_cmp",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine void @ext_cmp(ptr %src.1, ptr %src.2, ptr noalias %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep.src.1 = getelementptr inbounds i16, ptr %src.1, i64 %iv\n %i2 = load i16, ptr %gep.src.1, align 2\n %i3 = sext i16 %i2 to i32\n %c.1 = icmp sgt i32 0, %i3\n %gep.src.2 = getelementptr inbounds i8, ptr %src.2, i64 %iv\n %i4 = load i8, ptr %gep.src.2, align 2\n %i5 = zext i8 %i4 to i32\n %i6 = select i1 %c.1, i32 0, i32 %i5\n %i7 = and i32 %i6, 0\n %i8 = trunc nuw nsw i32 %i7 to i16\n %gep.dst = getelementptr inbounds i16, ptr %dst, i64 %iv\n store i16 %i8, ptr %gep.dst, align 2\n %iv.next = add nsw i64 %iv, 1\n %ec = icmp eq i64 %iv.next, 1000\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_icmp_constant_op_zext",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine i32 @test_icmp_constant_op_zext(ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i16 [ 1, %entry ], [ %iv.next, %loop ]\n %c = icmp ne i64 7304878031173690989, 0\n %c.ext = zext i1 %c to i64\n %or = or i64 7304878031173690989, %c.ext\n %or.trunc = trunc i64 %or to i8\n %gep = getelementptr i8, ptr %dst, i16 %iv\n store i8 %or.trunc, ptr %gep, align 1\n %iv.next = add i16 %iv, 1\n %ec = icmp eq i16 %iv.next, 1000\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i32 0\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "llvm crash on loop-vectorize: Assertion `OldResSizeInBits > NewResSizeInBits && \"Nothing to shrink?\"' failed.",
"body": "llvm crashes on the following IR.\r\n\r\nBisected to 822c749aec69ace75bd3923a4c850e2fd2e34fb1, which was committed by @fhahn \r\n\r\nCompiler explorer: https://godbolt.org/z/rWj9dhvPo\r\n\r\n```llvm\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine void @i(i64 %0) {\r\nentry:\r\n %conv = sext i16 1 to i32\r\n br label %for.body\r\n\r\nfor.body: ; preds = %for.body, %entry\r\n %1 = phi i32 [ 0, %entry ], [ %inc, %for.body ]\r\n %tobool.not.i = icmp eq i64 %0, 0\r\n %..i = select i1 %tobool.not.i, i32 0, i32 0\r\n %cmp = icmp eq i32 %..i, 0\r\n %conv1 = zext i1 %tobool.not.i to i32\r\n %or = or i32 %conv1, %conv\r\n %cmp2 = icmp slt i32 %or, 7\r\n %conv4 = zext i1 %cmp2 to i64\r\n store i64 %conv4, ptr null, align 8\r\n %inc = add i32 %1, 1\r\n %tobool.not = icmp eq i32 %inc, 0\r\n br i1 %tobool.not, label %for.cond.for.end_crit_edge, label %for.body\r\n\r\nfor.cond.for.end_crit_edge: ; preds = %for.body\r\n ret void\r\n}\r\n```\r\n\r\n```console\r\n% opt -passes=loop-vectorize reduced.ll\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/opt -disable-output -passes=loop-vectorize reduced.ll\r\n #0 0x00007f5302fedeff llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/../lib/libLLVM-18git.so+0x902eff)\r\n #1 0x00007f5302feb654 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007f5302300090 (/lib/x86_64-linux-gnu/libc.so.6+0x43090)\r\n #3 0x00007f5304a458f0 llvm::InnerLoopVectorizer::truncateToMinimalBitwidths(llvm::VPTransformState&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/../lib/libLLVM-18git.so+0x235a8f0)\r\n #4 0x00007f5304a49d95 llvm::InnerLoopVectorizer::fixVectorizedLoop(llvm::VPTransformState&, llvm::VPlan&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/../lib/libLLVM-18git.so+0x235ed95)\r\n #5 0x00007f5304a4abb1 llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool, llvm::DenseMap<llvm::SCEV const*, llvm::Value*, llvm::DenseMapInfo<llvm::SCEV const*, void>, llvm::detail::DenseMapPair<llvm::SCEV const*, llvm::Value*>>*) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/../lib/libLLVM-18git.so+0x235fbb1)\r\n #6 0x00007f5304a4d564 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/../lib/libLLVM-18git.so+0x2362564)\r\n #7 0x00007f5304a4fbdd llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/../lib/libLLVM-18git.so+0x2364bdd)\r\n #8 0x00007f5304a50e20 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/../lib/libLLVM-18git.so+0x2365e20)\r\n #9 0x00007f5305e0d916 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/../lib/libLLVM-18git.so+0x3722916)\r\n#10 0x00007f53031fd3fd llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/../lib/libLLVM-18git.so+0xb123fd)\r\n#11 0x00007f5305e069f6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/../lib/libLLVM-18git.so+0x371b9f6)\r\n#12 0x00007f53031fbc8d llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/../lib/libLLVM-18git.so+0xb10c8d)\r\n#13 0x00007f5305e0d696 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/../lib/libLLVM-18git.so+0x3722696)\r\n#14 0x00007f53031f9c0d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/../lib/libLLVM-18git.so+0xb0ec0d)\r\n#15 0x0000555c5281fcb5 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/opt+0x25cb5)\r\n#16 0x0000555c52813876 main (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/opt+0x19876)\r\n#17 0x00007f53022e1083 __libc_start_main /build/glibc-wuryBv/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#18 0x0000555c5281451e _start (/zdata/shaoli/compilers/ccbuilder-compilers/clang-822c749aec69ace75bd3923a4c850e2fd2e34fb1/bin/opt+0x1a51e)\r\n[1] 1975861 segmentation fault -disable-output -passes=loop-vectorize reduced.ll\r\n```\r\n\r\n\r\nThis IR is reduced from \r\n```C\r\nlong a, b;\r\nint c, d, f;\r\nstatic long *e = &b;\r\nstatic short g = 5;\r\nint h() {\r\n if (a)\r\n return 0;\r\n return 5;\r\n}\r\nvoid i() {\r\n int j;\r\n long **k = &e;\r\n for (; d; d++) {\r\n j = h();\r\n *e = 6 >= (g | (j + c == 0));\r\n }\r\n j = &k || 1;\r\n short *l[6];\r\n l[f] = &g;\r\n}\r\nint main() {}\r\n```",
"author": "shao-hua-li",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
98665
|
https://github.com/llvm/llvm-project/issues/98665
|
crash
|
662c6fc74c1ae7fdefd27524dfaeb7f3e9a1f553
| 2024-07-12T17:30:32 |
[
"llvm/test/Transforms/EarlyCSE"
] |
{
"fix_commit": "34bfed63313d1340378fc1be931253333db8c36c",
"components": [
"ConstantFold"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
2754,
2780
]
],
"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": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": [
"ConstantFoldIntrinsicCall2"
],
"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 34bfed63313d1340378fc1be931253333db8c36c
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Mon Jul 15 13:00:25 2024 +0800
[ConstantFold] Fix result type when folding powi.f16 (#98681)
Fixes #98665.
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 962880f68f07..6c52091cd5d7 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -2754,27 +2754,28 @@ static Constant *ConstantFoldIntrinsicCall2(Intrinsic::ID IntrinsicID, Type *Ty,
((Mask & fcPosInf) && Op1V.isPosInfinity());
return ConstantInt::get(Ty, Result);
}
+ case Intrinsic::powi: {
+ int Exp = static_cast<int>(Op2C->getSExtValue());
+ switch (Ty->getTypeID()) {
+ case Type::HalfTyID:
+ case Type::FloatTyID: {
+ APFloat Res(std::pow(Op1V.convertToFloat(), Exp));
+ if (Ty->isHalfTy()) {
+ bool Unused;
+ Res.convert(APFloat::IEEEhalf(), APFloat::rmNearestTiesToEven,
+ &Unused);
+ }
+ return ConstantFP::get(Ty->getContext(), Res);
+ }
+ case Type::DoubleTyID:
+ return ConstantFP::get(Ty, std::pow(Op1V.convertToDouble(), Exp));
+ default:
+ return nullptr;
+ }
+ }
default:
break;
}
-
- if (!Ty->isHalfTy() && !Ty->isFloatTy() && !Ty->isDoubleTy())
- return nullptr;
- if (IntrinsicID == Intrinsic::powi && Ty->isHalfTy())
- return ConstantFP::get(
- Ty->getContext(),
- APFloat((float)std::pow((float)Op1V.convertToDouble(),
- (int)Op2C->getZExtValue())));
- if (IntrinsicID == Intrinsic::powi && Ty->isFloatTy())
- return ConstantFP::get(
- Ty->getContext(),
- APFloat((float)std::pow((float)Op1V.convertToDouble(),
- (int)Op2C->getZExtValue())));
- if (IntrinsicID == Intrinsic::powi && Ty->isDoubleTy())
- return ConstantFP::get(
- Ty->getContext(),
- APFloat((double)std::pow(Op1V.convertToDouble(),
- (int)Op2C->getZExtValue())));
}
return nullptr;
}
|
[
{
"file": "llvm/test/Transforms/EarlyCSE/math-2.ll",
"commands": [
"opt -passes=early-cse -earlycse-debug-hash -S -o - %s"
],
"tests": [
{
"test_name": "i_powi",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare double @llvm.powi.f64.i32(double, i32) #0\n\ndefine double @i_powi() {\n %res = tail call fast double @llvm.powi.f64.i32(double 1.000000e+00, i32 2)\n ret double %res\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "pr98665",
"test_body": "define half @pr98665() {\n %x = call half @llvm.powi.f16.i32(half 0xH3C00, i32 1)\n ret half %x\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare half @llvm.powi.f16.i32(half, i32) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Misoptimization: `EarlyCSEPass` uses replaces `powi.f16` with `float` result",
"body": "It looks like EarlyCSEPass is transformin the following:\r\n\r\n```llvm\r\n %_6 = alloca [48 x i8], align 8\r\n %_3 = alloca [2 x i8], align 2\r\n %0 = call half @llvm.powi.f16.i32(half 0xH3C00, i32 1) ; 0xH3C00 = 1.0f16\r\n store half %0, ptr %_3, align 2\r\n %1 = load half, ptr %_3, align 2\r\n %_4 = fcmp oeq half %1, 0xH3C00\r\n br i1 %_4, label %bb1, label %bb2\r\n```\r\n\r\nInto this:\r\n\r\n```llvm\r\n %_6 = alloca [48 x i8], align 8\r\n %_3 = alloca [2 x i8], align 2\r\n store float 1.000000e+00, ptr %_3, align 2\r\n %0 = load half, ptr %_3, align 2\r\n %_4 = fcmp oeq half %0, 0xH3C00\r\n br i1 %_4, label %bb1, label %bb2\r\n```\r\n\r\nAnd later InstCombine folds further into:\r\n\r\n```llvm\r\n %_6 = alloca [48 x i8], align 8\r\n %_3 = alloca [2 x i8], align 2\r\n store float 1.000000e+00, ptr %_3, align 2\r\n br i1 false, label %bb1, label %bb2\r\n```\r\n\r\nEarlyCSE seems to be doing an incorrect transformation: the result of `powi.f16(1.0, 1)` should be `half` 1.0 (0x3c00), but it is returning `float` 1.0 (0x3f800000). This is incorrect and an OOB write.\r\n\r\nThis comes from the following rust code, which asserts only when optimizations are enabled:\r\n\r\n```rust\r\n#![feature(f16)]\r\n#![allow(unused)]\r\n\r\n#[inline(never)]\r\npub fn check_pow(a: f16) {\r\n assert_eq!(1.0f16.powi(1), 1.0);\r\n}\r\n\r\npub fn main() {\r\n check_pow(1.0);\r\n println!(\"finished\");\r\n}\r\n```\r\n\r\nLink to compiler explorer: https://rust.godbolt.org/z/zsbzzxGvj\r\n\r\nI'm not sure how to reduce to a llc example since the passes appear different. I have been testing on aarch64 since x86 has other f16 ABI bugs, but I don't think this is limited to aarch64.",
"author": "tgross35",
"labels": [
"miscompilation",
"llvm:analysis"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Reproducer: https://godbolt.org/z/jhM834G3z\r\n```\r\ndefine half @test() {\r\n %x = call half @llvm.powi.f16.i32(half 0xH3C00, i32 1)\r\n ret half %x\r\n}\r\n```\r\n```\r\nopt: /root/llvm-project/llvm/lib/IR/Value.cpp:507: void llvm::Value::doRAUW(llvm::Value*, llvm::Value::ReplaceMetadataUses): Assertion `New->getType() == getType() && \"replaceAllUses of value with new value of different type!\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=early-cse <source>\r\n1.\tRunning pass \"function(early-cse<>)\" on module \"<source>\"\r\n2.\tRunning pass \"early-cse<>\" on function \"test\"\r\n #0 0x0000000004e9b948 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e9b948)\r\n #1 0x0000000004e990bc SignalHandler(int) Signals.cpp:0:0\r\n #2 0x000078ad4b442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x000078ad4b4969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x000078ad4b442476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x000078ad4b4287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x000078ad4b42871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x000078ad4b439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x0000000004cce094 llvm::Value::doRAUW(llvm::Value*, llvm::Value::ReplaceMetadataUses) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4cce094)\r\n #9 0x0000000003ae3b58 (anonymous namespace)::EarlyCSE::processNode(llvm::DomTreeNodeBase<llvm::BasicBlock>*) EarlyCSE.cpp:0:0\r\n#10 0x0000000003ae5a85 (anonymous namespace)::EarlyCSE::run() EarlyCSE.cpp:0:0\r\n#11 0x0000000003ae81f8 llvm::EarlyCSEPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3ae81f8)\r\n#12 0x0000000002ac11be llvm::detail::PassModel<llvm::Function, llvm::EarlyCSEPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2ac11be)\r\n#13 0x0000000004c9f2d8 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4c9f2d8)\r\n#14 0x0000000000dc9bee llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xdc9bee)\r\n#15 0x0000000004c9dd46 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4c9dd46)\r\n#16 0x0000000000dca1fe llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xdca1fe)\r\n#17 0x0000000004c9bf10 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4c9bf10)\r\n#18 0x00000000008db1d2 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8db1d2)\r\n#19 0x00000000008ce0fc optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8ce0fc)\r\n#20 0x000078ad4b429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#21 0x000078ad4b429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#22 0x00000000008c556e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8c556e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```\r\n\r\nThere is a bug in constant folding.\r\n\r\n"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
131465
|
https://github.com/llvm/llvm-project/issues/131465
|
miscompilation
|
baab447aadd59b34bd838584b16d11475329853f
| 2025-03-15T18:15:27 |
[
"llvm/test/Analysis/ScalarEvolution",
"llvm/test/Transforms/LoopUnroll"
] |
{
"fix_commit": "c5a491e9ea22014b65664b6e09134b4f055933e2",
"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": [
[
10635,
10644
]
],
"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::howFarToZero"
],
"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 c5a491e9ea22014b65664b6e09134b4f055933e2
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Mon Mar 17 13:59:16 2025 +0800
[SCEV] Check whether the start is non-zero in `ScalarEvolution::howFarToZero` (#131522)
https://github.com/llvm/llvm-project/pull/94525 assumes that the loop
will be infinite when the stride is zero. However, it doesn't hold when
the start value of addrec is also zero.
Closes https://github.com/llvm/llvm-project/issues/131465.
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 8f74c1c398ce..314baa7c7aee 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -10635,10 +10635,11 @@ ScalarEvolution::ExitLimit ScalarEvolution::howFarToZero(const SCEV *V,
if (ControlsOnlyExit && AddRec->hasNoSelfWrap() &&
loopHasNoAbnormalExits(AddRec->getLoop())) {
- // If the stride is zero, the loop must be infinite. In C++, most loops
- // are finite by assumption, in which case the step being zero implies
- // UB must execute if the loop is entered.
- if (!loopIsFiniteByAssumption(L) && !isKnownNonZero(StepWLG))
+ // If the stride is zero and the start is non-zero, the loop must be
+ // infinite. In C++, most loops are finite by assumption, in which case the
+ // step being zero implies UB must execute if the loop is entered.
+ if (!(loopIsFiniteByAssumption(L) && isKnownNonZero(Start)) &&
+ !isKnownNonZero(StepWLG))
return getCouldNotCompute();
const SCEV *Exact =
|
[
{
"file": "llvm/test/Analysis/ScalarEvolution/trip-count-unknown-stride.ll",
"commands": [
"opt < %s -disable-output \"-passes=print<scalar-evolution>\" -scalar-evolution-classify-expressions=0 2>&1"
],
"tests": [
{
"test_name": "ne_nuw_nonneg_step",
"test_body": "target datalayout = \"e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128\"\n\n; Function Attrs: mustprogress\ndefine void @ne_nuw_nonneg_step(ptr captures(none) %A, i32 %n, i32 %s) #0 {\nentry:\n %nonneg_step = icmp sge i32 %s, 0\n call void @llvm.assume(i1 %nonneg_step)\n %cmp4 = icmp sgt i32 %n, 0\n br i1 %cmp4, label %for.body, label %for.end\n\nfor.body: ; preds = %for.body, %entry\n %i.05 = phi i32 [ %add, %for.body ], [ 0, %entry ]\n %arrayidx = getelementptr inbounds i32, ptr %A, i32 %i.05\n %0 = load i32, ptr %arrayidx, align 4\n %inc = add nuw i32 %0, 1\n store i32 %inc, ptr %arrayidx, align 4\n %add = add nuw i32 %i.05, %s\n %cmp = icmp ne i32 %add, %n\n br i1 %cmp, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body, %entry\n ret void\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #1\n\nattributes #0 = { mustprogress }\nattributes #1 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "pr131465",
"test_body": "target datalayout = \"e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128\"\n\n; Function Attrs: mustprogress\ndefine i32 @pr131465(i1 %x) #0 {\nentry:\n %inc = zext i1 %x to i32\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %indvar = phi i32 [ 2, %entry ], [ %next, %for.body ]\n %next = add nsw i32 %indvar, %inc\n %exitcond = icmp eq i32 %next, 2\n br i1 %exitcond, label %for.end, label %for.body\n\nfor.end: ; preds = %for.body\n ret i32 0\n}\n\nattributes #0 = { mustprogress }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "ne_nsw_nonneg_step",
"test_body": "target datalayout = \"e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128\"\n\n; Function Attrs: mustprogress\ndefine void @ne_nsw_nonneg_step(ptr captures(none) %A, i32 %n, i32 %s) #0 {\nentry:\n %nonneg_step = icmp sge i32 %s, 0\n call void @llvm.assume(i1 %nonneg_step)\n %cmp4 = icmp sgt i32 %n, 0\n br i1 %cmp4, label %for.body, label %for.end\n\nfor.body: ; preds = %for.body, %entry\n %i.05 = phi i32 [ %add, %for.body ], [ 0, %entry ]\n %arrayidx = getelementptr inbounds i32, ptr %A, i32 %i.05\n %0 = load i32, ptr %arrayidx, align 4\n %inc = add nsw i32 %0, 1\n store i32 %inc, ptr %arrayidx, align 4\n %add = add nsw i32 %i.05, %s\n %cmp = icmp ne i32 %add, %n\n br i1 %cmp, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body, %entry\n ret void\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #1\n\nattributes #0 = { mustprogress }\nattributes #1 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopUnroll/pr131465.ll",
"commands": [
"opt -S -passes=loop-unroll -unroll-runtime %s"
],
"tests": [
{
"test_name": "pr131465",
"test_body": "; Function Attrs: mustprogress\ndefine i32 @pr131465(i1 %x) #0 {\nentry:\n %inc = zext i1 %x to i32\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %indvar = phi i32 [ 2, %entry ], [ %next, %for.body ]\n %next = add nsw i32 %indvar, %inc\n %exitcond = icmp eq i32 %next, 2\n br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !0\n\nfor.end: ; preds = %for.body\n ret i32 0\n}\n\nattributes #0 = { mustprogress }\n\n!0 = distinct !{!0, !1}\n!1 = !{!\"llvm.loop.unroll.count\", i32 2}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[clang] Miscompilation at -O2/3",
"body": "This code prints 80 at `-O2/3` and 0 at `-O0/1`:\n\n```c\nint printf(const char *, ...);\nint a, b;\nvoid c(char d) { a = d; }\nint main() {\n int e = 82, f = 20;\n for (; 85 + 20 + e - 187 + f; f = 65535 + 20 + e - 65637)\n if (b)\n e++;\n c(e >> 24);\n printf(\"%X\\n\", a);\n}\n```\n\nCompiler Explorer: https://godbolt.org/z/6WP1aT6ba\n\nBisected to https://github.com/llvm/llvm-project/commit/04cd06906288dcb148de37d7c3e6c009c3e3b726, which was committed by @preames ",
"author": "cardigan1008",
"labels": [
"miscompilation",
"llvm:SCEV"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Reduced reproducer: https://godbolt.org/z/bvhdjdMc7 https://alive2.llvm.org/ce/z/sSLNUX\n```\n; bin/opt -passes=loop-unroll 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(i1 %tobool2.not) #0 {\nentry:\n %inc = zext i1 %tobool2.not to i32\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %e.08 = phi i32 [ 2, %entry ], [ %spec.select, %for.body ]\n %spec.select = add nsw i32 %e.08, %inc\n %tobool.not = icmp eq i32 %spec.select, 2\n br i1 %tobool.not, label %for.end, label %for.body, !llvm.loop !0\n\nfor.end: ; preds = %for.body\n ret i32 0\n}\n\nattributes #0 = { \"target-cpu\"=\"x86-64\" }\n\n!0 = distinct !{!0, !1}\n!1 = !{!\"llvm.loop.mustprogress\"}\n\n```"
},
{
"author": "antoniofrighetto",
"body": "@dtcxzyw May I ask whether llubi was used to get such a reduced reproducer? Having a hard time reducing this one, this time: am using [test.sh](https://github.com/dtcxzyw/llvm-ub-aware-interpreter?tab=readme-ov-file#automatic-ub-free-test-case-reduction-for-middle-end-miscompilation-bugs) with:\n1) Custom pipelines & O2 in order to have some proper interestingness test;\n2) `--ir-passes` with the default one, fine-tuning the pipeline by adjusting/removing passes.\n\nHowever, by the time I obtain the reduced IR, it looks already invalid (i.e., unreachable). Any suggestions / idea what I may be missing?"
},
{
"author": "dtcxzyw",
"body": "1. Manually bisect\n```\n#!/usr/bin/bash\n\nFILE=$1\nBISECT=$2\n../../LLVM/llvm-build/bin/clang -O3 -mllvm -inline-threshold=1000000 $FILE -mllvm -opt-bisect-limit=$BISECT -DNDEBUG -g0 -w -emit-llvm -S -I/home/dtcxzyw/WorkSpace/Projects/compilers/csmith/install/include -o test.ll -mllvm -print-changed -mllvm -print-module-scope 2>log\n# ../../LLVM/llvm-build/bin/lli test.ll\n./llubi --max-steps 1000000 test.ll\n# ../../LLVM/llvm-build/bin/opt -O3 $FILE -o out.ll -S -opt-bisect-limit=$BISECT -print-changed -print-module-scope 2>log\n# ./llubi out.ll\n```\n```\n# Correct one\n./bisect.sh test.c 175\n# Miscompilation\n./bisect.sh test.c 174\n```\nAfter the bisection, we got a single-pass reproducer:\n```\n; bin/opt -passes=loop-unroll test.ll -S\n; ModuleID = 'test.c'\nsource_filename = \"test.c\"\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@a = dso_local local_unnamed_addr global i32 0, align 4\n@b = dso_local local_unnamed_addr global i32 0, align 4\n@.str = private unnamed_addr constant [4 x i8] c\"%X\\0A\\00\", align 1\n\n; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: none, inaccessiblemem: none) uwtable\ndefine dso_local void @c(i8 noundef signext %d) local_unnamed_addr #0 {\nentry:\n %conv = sext i8 %d to i32\n store i32 %conv, ptr @a, align 4, !tbaa !5\n ret void\n}\n\n; Function Attrs: nofree nounwind uwtable\ndefine dso_local noundef i32 @main() local_unnamed_addr #1 {\nentry:\n %0 = load i32, ptr @b, align 4, !tbaa !5\n %tobool2.not = icmp ne i32 %0, 0\n %inc = zext i1 %tobool2.not to i32\n br label %for.body\n\nfor.body: ; preds = %entry, %for.body\n %e.08 = phi i32 [ 82, %entry ], [ %spec.select, %for.body ]\n %spec.select = add nuw nsw i32 %e.08, %inc\n %sub = add nsw i32 %spec.select, -82\n %add1 = sub nsw i32 82, %spec.select\n %tobool.not = icmp eq i32 %sub, %add1\n br i1 %tobool.not, label %for.end, label %for.body, !llvm.loop !9\n\nfor.end: ; preds = %for.body\n %shr = lshr i32 %spec.select, 24\n store i32 %shr, ptr @a, align 4, !tbaa !5\n %call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %shr)\n ret i32 0\n}\n\n; Function Attrs: nofree nounwind\ndeclare noundef i32 @printf(ptr noundef readonly captures(none), ...) local_unnamed_addr #2\n\nattributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: none, inaccessiblemem: none) uwtable \"min-legal-vector-width\"=\"0\" \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"x86-64\" \"target-features\"=\"+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87\" \"tune-cpu\"=\"generic\" }\nattributes #1 = { nofree nounwind uwtable \"min-legal-vector-width\"=\"0\" \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"x86-64\" \"target-features\"=\"+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87\" \"tune-cpu\"=\"generic\" }\nattributes #2 = { nofree nounwind \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"x86-64\" \"target-features\"=\"+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87\" \"tune-cpu\"=\"generic\" }\n\n!llvm.module.flags = !{!0, !1, !2, !3}\n!llvm.ident = !{!4}\n\n!0 = !{i32 1, !\"wchar_size\", i32 4}\n!1 = !{i32 8, !\"PIC Level\", i32 2}\n!2 = !{i32 7, !\"PIE Level\", i32 2}\n!3 = !{i32 7, !\"uwtable\", i32 2}\n!4 = !{!\"clang version 21.0.0git\"}\n!5 = !{!6, !6, i64 0}\n!6 = !{!\"int\", !7, i64 0}\n!7 = !{!\"omnipotent char\", !8, i64 0}\n!8 = !{!\"Simple C/C++ TBAA\"}\n!9 = distinct !{!9, !10}\n!10 = !{!\"llvm.loop.mustprogress\"}\n```\n2. reduce\n```\n#!/usr/bin/bash\n# /home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/clang -Os -Xclang -disable-llvm-passes -emit-llvm -S test.c -o test.ll -I/home/dtcxzyw/WorkSpace/Projects/compilers/csmith/install/include -w\n# llvm-reduce --test=ubi_reduce.sh --ir-passes=\"function(sroa,instcombine<no-verify-fixpoint>,gvn,simplifycfg,infer-address-spaces),inline\" test.ll\n\na=$(/home/dtcxzyw/WorkSpace/Projects/compilers/llvm-ub-aware-interpreter/build/llubi --max-steps 1000000 --reduce-mode $1)\nif [ $? -ne 0 ]; then\n exit 1\nfi\n/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/opt -passes=loop-unroll $1 -o $1.tmp -S\nif [ $? -ne 0 ]; then\n exit 1\nfi\nb=$(/home/dtcxzyw/WorkSpace/Projects/compilers/llvm-ub-aware-interpreter/build/llubi --max-steps 1000000 --reduce-mode $1.tmp)\nif [ $? -ne 0 ]; then\n exit 0\n # exit 1\nfi\nif [[ \"$a\" == \"$b\" ]]; then\n exit 2\nfi\n# echo $a\n# echo $b\nexit 0\n```\n```\nllvm-reduce --test=ubi_reduce.sh test.ll\n```\nThen we got the final reproducer.\n\nIn general, I will run `creduce w/ sanitizers` and the bisection first to avoid falling into some long-outstanding undef bugs.\n\nBTW, an automatic reproducer reduction pipeline will be available soon :)\n"
},
{
"author": "antoniofrighetto",
"body": "@dtcxzyw Thanks a lot for clarifying that :)"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
97674
|
https://github.com/llvm/llvm-project/issues/97674
|
crash
|
c67653fbc3dd4ea9ab2a32c481a9ac4411020c7b
| 2024-07-04T04:06:51 |
[
"llvm/test/Transforms/CorrelatedValuePropagation"
] |
{
"fix_commit": "899fe2cf318f6e3c7a183125ff17ef53944b2989",
"components": [
"LazyValueInfo"
],
"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": [
[
1723,
1729
],
[
1758,
1764
]
],
"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": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": [
"LazyValueInfo::getConstantOnEdge"
],
"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 899fe2cf318f6e3c7a183125ff17ef53944b2989
Author: goldsteinn <35538541+goldsteinn@users.noreply.github.com>
Date: Thu Jul 4 15:14:39 2024 +0800
[CVP][LVI] Fix incorrect scalar type when getting constant folded vec (#97682)
Fixes #97674
After #97428 added support for vectors, our constant ranges can now be
from splat vectors so when they reduce to a singe constant value, we
need to return the original type as opposed to just an int.
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp
index b30e6a6a367c..4209ee4a7795 100644
--- a/llvm/lib/Analysis/LazyValueInfo.cpp
+++ b/llvm/lib/Analysis/LazyValueInfo.cpp
@@ -1370,6 +1370,7 @@ LazyValueInfoImpl::getEdgeValueLocal(Value *Val, BasicBlock *BBFrom,
// If V is the condition of the branch itself, then we know exactly what
// it is.
+ // NB: The condition on a `br` can't be a vector type.
if (Condition == Val)
return ValueLatticeElement::get(ConstantInt::get(
Type::getInt1Ty(Val->getContext()), isTrueDest));
@@ -1723,7 +1724,7 @@ Constant *LazyValueInfo::getConstant(Value *V, Instruction *CxtI) {
if (Result.isConstantRange()) {
const ConstantRange &CR = Result.getConstantRange();
if (const APInt *SingleVal = CR.getSingleElement())
- return ConstantInt::get(V->getContext(), *SingleVal);
+ return ConstantInt::get(V->getType(), *SingleVal);
}
return nullptr;
}
@@ -1758,7 +1759,7 @@ Constant *LazyValueInfo::getConstantOnEdge(Value *V, BasicBlock *FromBB,
if (Result.isConstantRange()) {
const ConstantRange &CR = Result.getConstantRange();
if (const APInt *SingleVal = CR.getSingleElement())
- return ConstantInt::get(V->getContext(), *SingleVal);
+ return ConstantInt::get(V->getType(), *SingleVal);
}
return nullptr;
}
|
[
{
"file": "llvm/test/Transforms/CorrelatedValuePropagation/vectors.ll",
"commands": [
"opt -S -passes=correlated-propagation < %s"
],
"tests": [
{
"test_name": "and_with_poison",
"test_body": "define <2 x i16> @and_with_poison(<2 x i8> %a) {\n %zext = zext <2 x i8> %a to <2 x i16>\n %res = and <2 x i16> %zext, <i16 255, i16 poison>\n ret <2 x i16> %res\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "issue_97674_getConstant",
"test_body": "define <4 x i64> @issue_97674_getConstant() {\nentry:\n %folds = add <4 x i64> zeroinitializer, zeroinitializer\n ret <4 x i64> %folds\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "issue_97674_getConstantOnEdge",
"test_body": "define <4 x i64> @issue_97674_getConstantOnEdge(i1 %cond) {\nentry:\n br i1 %cond, label %if.then, label %if.end\n\nif.then: ; preds = %entry\n %folds = add <4 x i64> zeroinitializer, splat (i64 1)\n br label %if.end\n\nif.end: ; preds = %if.then, %entry\n %r = phi <4 x i64> [ %folds, %if.then ], [ zeroinitializer, %entry ]\n ret <4 x i64> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "A/F: `getType() == V->getType() && \"All operands to PHI node must be the same type as the PHI node !\"' after 1eec81a",
"body": "We have an internal test which started to hit an assertion failure when compiled which I bisected back to 1eec81a.\r\n\r\nConsider the following code:\r\n```c++\r\ntemplate <bool, class, class> using c = int;\r\ntypedef long cb __attribute__((__vector_size__(16)));\r\ncb d(cb);\r\ntypedef long e __attribute__((__vector_size__(32)));\r\nenum { f };\r\nstruct g {\r\n enum { h };\r\n};\r\ntemplate <typename> struct i;\r\ntemplate <typename> struct aa;\r\ntemplate <typename> struct j;\r\ntemplate <typename> class k;\r\ntemplate <typename, int l, int m, int = 0, int = l, int = m> class n;\r\ntemplate <typename, typename> class o;\r\ntemplate <typename, int l, int m, int = 0, int = l, int = m> class p;\r\ntemplate <typename> struct q;\r\ntemplate <typename> struct r;\r\ntemplate <typename s> struct t { typedef q<s>::ab ab; };\r\ntemplate <typename ac> struct ad { typedef k<ac> ab; };\r\ntemplate <typename s> struct u {\r\n operator s() { return ae; }\r\n u(s v) : ae(v) {}\r\n s ae;\r\n};\r\ntemplate <typename w> w x(const typename r<w>::ab &);\r\ntemplate <> struct q<int> { typedef u<e> ab; };\r\ntemplate <> struct r<u<e>> {\r\n typedef int ab;\r\n enum { af = 8 };\r\n};\r\ntemplate <> u<e> x(const int &) {\r\n e y{};\r\n return y;\r\n}\r\ne z;\r\ne ag(e a, u<e> b) {\r\n __attribute__((__vector_size__(4 * sizeof(long)))) long ah = b;\r\n z = a + ah;\r\n return z;\r\n}\r\nstruct ai {\r\n u<__attribute__((__vector_size__(4 * sizeof(long)))) long>\r\n aj(u<__attribute__((__vector_size__(4 * sizeof(long)))) long> a,\r\n const u<__attribute__((__vector_size__(4 * sizeof(long)))) long> &b) {\r\n __attribute__((__vector_size__(4 * sizeof(long)))) long ak = a;\r\n return ag(ak, b);\r\n }\r\n};\r\nstruct al {\r\n template <typename am> am aj() { return x<am>(an); }\r\n int an;\r\n};\r\ntemplate <typename ac> long ao(ac);\r\ntemplate <typename ac> class k : j<ac> {\r\npublic:\r\n typedef i<ac>::ap ap;\r\n using j<ac>::aq;\r\n static o<int, c<g::h, ac, p<ac, i<ac>::ar, i<ac>::as>>> at(long, long);\r\n ap au() const;\r\n template <typename av> ap aw(const av &) const;\r\n};\r\ntemplate <typename ac> struct j { ac aq() const; };\r\nstruct ax {\r\n template <typename s, typename ay> s aj(al az, ay) { return az.aj<s>(); }\r\n};\r\ntemplate <typename ba, typename bb> struct aa<o<ba, bb>> {\r\n aa(o<ba, bb>);\r\n template <int, typename am, typename ay> am bc(ay) {\r\n return be.aj<am>(bf, d);\r\n }\r\n ba bf;\r\n ax be;\r\n};\r\ntemplate <typename ac> class bg : public ad<ac>::ab {};\r\ntemplate <typename bh, int l, int m, int bi, int bj, int bk>\r\nstruct i<n<bh, l, m, bi, bj, bk>> {\r\n typedef bh ap;\r\n enum { ar, as };\r\n};\r\ntemplate <typename bh, int l, int m, int bi, int bj, int bk>\r\nstruct i<p<bh, l, m, bi, bj, bk>> : i<n<bh, bj, bk>> {};\r\ntemplate <typename, int, int, int, int bj, int bk>\r\nclass p : public bg<p<int, bj, bk>> {};\r\ntemplate <typename ba, typename bb> struct i<o<ba, bb>> : i<bb> {};\r\ntemplate <typename, typename>\r\nclass o : public ad<o<al, p<int, 0, -1, 1, 0, 1>>>::ab {};\r\ntemplate <typename bl> struct bm {\r\n typedef t<typename bl::ap>::ab am;\r\n enum { bn = r<am>::af };\r\n enum { bo };\r\n};\r\ntemplate <typename, typename bl, int = bm<bl>::bo> struct M;\r\ntemplate <typename bp, typename bl> struct M<bp, bl, f> {\r\n typedef bm<bl>::am bq;\r\n template <typename br> static bl bs(bl bt, bp bu, br bv) {\r\n enum { alignment };\r\n long bw = ao(bv);\r\n bq bx = bt.template bc<alignment, bq>(bw);\r\n if (bw > bm<bl>::bn) {\r\n bq by = bt.template bc<alignment, bq>(bm<bl>::bn);\r\n for (long bd; bd; bd += bm<bl>::bn) {\r\n bx = bu.aj(bx, bt.template bc<alignment, bq>(d));\r\n u bz = bt.template bc<alignment, bq>(bm<bl>::bn);\r\n by = bu.aj(by, bz);\r\n }\r\n bx = bu.aj(bx, by);\r\n }\r\n __attribute__((__vector_size__(4 * sizeof(int)))) int ca =\r\n __builtin_ia32_vextractf128_si256(bx, 0);\r\n __attribute__((__vector_size__(2 * sizeof(long)))) long b = d(ca);\r\n }\r\n};\r\nclass cc : public aa<o<al, p<int, 0, -1, 1, 0, 1>>> {\r\npublic:\r\n typedef int ap;\r\n};\r\ntemplate <typename ac>\r\ntemplate <typename bp>\r\ni<ac>::ap k<ac>::aw(const bp &bu) const {\r\n cc cd(aq());\r\n o<int, int> ce;\r\n M<bp, cc>::bs(cd, bu, ce);\r\n}\r\ntemplate <typename ac> i<ac>::ap k<ac>::au() const { aw(ai()); }\r\nvoid cf() { p<int, 1, 1>::at(0, 0).au(); }\r\n```\r\n\r\nWhen compiled with optimizations and AVX support with a compiler before 1eec81a, the compilation succeeds:\r\n```\r\n$ ~/src/upstream/b76dd4edbfbba5593b691ef92b755f25cf63f445-linux/bin/clang -c -O2 -mavx -Wno-return-type -std=c++20 repro.cpp\r\n$\r\n```\r\n\r\nWhen compiled with the same arguments but with a compiler built from 1eec81a, the compiler hits an assertion failure:\r\n```\r\n$ ~/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang -c -O2 -mavx -Wno-return-type -std=c++20 repro.cpp\r\nclang: /home/dyung/src/upstream/llvm_clean_git/llvm/include/llvm/IR/Instructions.h:2582: void llvm::PHINode::setIncomingValue(unsigned int, llvm::Value*): Assertion `getType() == V->getType() && \"All operands to PHI node must be the same type as the PHI node\r\n!\"' failed. \r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script. \r\nStack dump:\r\n0. Program arguments: /home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang -c -O2 -mavx -Wno-return-type -std=c++20 repro.cpp\r\n1. <eof> parser at end of file\r\n2. Optimizer\r\n3. Running 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-\r\nexecution<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-sink-common-insts;speculate-blocks;simplify-cond-\r\nbranch>,instcombine<max-iterations=1;no-use-loop-info;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-in\r\nsts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,reassociate,constraint-elimination,loop-mssa(loop-instsimplify,loop-simplifycfg,licm<no-allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-un\r\nswitch<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-sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1;no-use\r\n-loop-info;no-verify-fixpoint>,loop(loop-idiom,indvars,simple-loop-unswitch<no-nontrivial;trivial>,loop-deletion,loop-unroll-full),sroa<modify-cfg>,vector-combine,mldst-motion<no-split-footer-bb>,gvn<>,sccp,bdce,instcombine<max-iterations=1;no-use-loop-info;\r\nno-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-commo\r\nn-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>),function-attrs,function(require<should-not-run-function-passes>),coro-split)),function(invalidate<should-not-run-function-pass\r\nes>),cgscc(devirt<4>())\" on module \"repro.cpp\"\r\n4. Running 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-propagat\r\nion,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>,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoi\r\nnt>,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-sink-common-insts;speculate-blocks;simplify-cond-branch>,reasso\r\nciate,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-f\r\norward-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>,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop(loop-idiom,indvars,simple-loop-uns\r\nwitch<no-nontrivial;trivial>,loop-deletion,loop-unroll-full),sroa<modify-cfg>,vector-combine,mldst-motion<no-split-footer-bb>,gvn<>,sccp,bdce,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,jump-threading,correlated-propagation,adce,memcpyo\r\npt,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;sink-common-insts;speculate-blocks;simplify-cond-branch>,instc\r\nombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>),function-attrs,function(require<should-not-run-function-passes>),coro-split))\" on module \"repro.cpp\"\r\n5. Running pass \"correlated-propagation\" on function \"_ZN1MI2ai2ccLi0EE2bsI1oIiiEEES1_S1_S0_T_\"\r\n #0 0x000056411be676af llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x41856af)\r\n #1 0x000056411be6520c llvm::sys::CleanupOnSignal(unsigned long) (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x418320c)\r\n #2 0x000056411bdaa728 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0\r\n #3 0x00007f29a8886420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #4 0x00007f29a835300b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #5 0x00007f29a8332859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\r\n #6 0x00007f29a8332729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #7 0x00007f29a8332729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #8 0x00007f29a8343fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #9 0x00005641200199a5 processPHI(llvm::PHINode*, llvm::LazyValueInfo*, llvm::DominatorTree*, llvm::SimplifyQuery const&) CorrelatedValuePropagation.cpp:0:0\r\n#10 0x000056412002131e runImpl(llvm::Function&, llvm::LazyValueInfo*, llvm::DominatorTree*, llvm::SimplifyQuery const&) CorrelatedValuePropagation.cpp:0:0\r\n#11 0x0000564120022b4b llvm::CorrelatedValuePropagationPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x8340b4b)\r\n#12 0x000056411d2b9866 llvm::detail::PassModel<llvm::Function, llvm::CorrelatedValuePropagationPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x55d7866)\r\n#13 0x000056411b80daf1 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x3b2baf1)\r\n#14 0x00005641193e3d86 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x1701d86)\r\n#15 0x000056411acf6e91 llvm::CGSCCToFunctionPassAdaptor::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x3014e91)\r\n#16 0x00005641193e5326 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&) (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x1703326)\r\n#17 0x000056411aceef7f 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&) (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x300cf7f)\r\n#18 0x000056411d2b71b6 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&) (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x55d51b6)\r\n#19 0x000056411acf370d llvm::DevirtSCCRepeatedPass::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x301170d)\r\n#20 0x000056411d2b7206 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&) (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x55d5206)\r\n#21 0x000056411acf150c llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x300f50c)\r\n#22 0x000056411d2b7166 llvm::detail::PassModel<llvm::Module, llvm::ModuleToPostOrderCGSCCPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x55d5166)\r\n#23 0x000056411b80a601 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x3b28601)\r\n#24 0x000056411d4afdb5 llvm::ModuleInlinerWrapperPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x57cddb5)\r\n#25 0x000056411d2b68f6 llvm::detail::PassModel<llvm::Module, llvm::ModuleInlinerWrapperPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x55d48f6)\r\n#26 0x000056411b80a601 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x3b28601)\r\n#27 0x000056411c11c4d8 (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#28 0x000056411c11f855 (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#29 0x000056411c11fef6 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x443def6)\r\n#30 0x000056411c792bea clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x4ab0bea)\r\n#31 0x000056411e56cb8c clang::ParseAST(clang::Sema&, bool, bool) (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x688ab8c)\r\n#32 0x000056411c793078 clang::CodeGenAction::ExecuteAction() (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x4ab1078)\r\n#33 0x000056411ca26e79 clang::FrontendAction::Execute() (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x4d44e79)\r\n#34 0x000056411c9aa76e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x4cc876e)\r\n#35 0x000056411cb12366 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x4e30366)\r\n#36 0x0000564118fcc89f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x12ea89f)\r\n#37 0x0000564118fc594a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#38 0x000056411c7d833d void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0\r\n#39 0x000056411bdaac30 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x40c8c30)\r\n#40 0x000056411c7d895f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0\r\n#41 0x000056411c79cdbc clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x4abadbc)\r\n#42 0x000056411c79d84d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x4abb84d)\r\n#43 0x000056411c7a5925 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x4ac3925)\r\n#44 0x0000564118fc9bab clang_main(int, char**, llvm::ToolContext const&) (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x12e7bab)\r\n#45 0x0000564118ebcc0b main (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x11dac0b)\r\n#46 0x00007f29a8334083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#47 0x0000564118fc53de _start (/home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin/clang+0x12e33de)\r\nclang: error: clang frontend command failed with exit code 134 (use -v to see invocation)\r\nclang version 19.0.0 (https://github.com/llvm/llvm-project.git 1eec81a831dcf925c0c86c153e8dce019a5b5436)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /home/dyung/src/upstream/1eec81a831dcf925c0c86c153e8dce019a5b5436-linux/bin\r\n```",
"author": "dyung",
"labels": [
"crash",
"llvm:analysis"
],
"comments": [
{
"author": "goldsteinn",
"body": "Seems like when `CVP` finds a constant, its returning the scalar, not the VEC type.\r\n\r\nReducer of exact error:\r\n```\r\ndefine <4 x i64> @reduce(i1 %cond) {\r\nentry:\r\n br i1 %cond, label %if.then, label %if.end\r\n\r\nif.then:\r\n %folds = add <4 x i64> zeroinitializer, <i64 1, i64 1, i64 1, i64 1>\r\n br label %if.end\r\n\r\nif.end:\r\n %r = phi <4 x i64> [ %folds, %if.then ], [ zeroinitializer, %entry ]\r\n ret <4 x i64> %r\r\n}\r\n```\r\nRepro with: `opt -passes=correlated-propagation`\r\n\r\nOr an even simpler version (different assert location):\r\n```\r\ndefine <4 x i64> @reduce() {\r\nentry:\r\n %folds = add <4 x i64> zeroinitializer, zeroinitializer\r\n ret <4 x i64> %folds\r\n}\r\n \r\n```\r\n\r\nSame command as above.\r\n"
},
{
"author": "goldsteinn",
"body": "Ill have a fix up shortly."
},
{
"author": "goldsteinn",
"body": "Fix at: https://github.com/llvm/llvm-project/pull/97682"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
112476
|
https://github.com/llvm/llvm-project/issues/112476
|
miscompilation
|
3ef630ac339f31686290f9460a40eb2a9c9f5bd0
| 2024-10-16T04:35:15 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "09361953116770b646decf5820a9455ada2ba4fc",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": [
[
1738,
1744
],
[
1844,
1850
]
],
"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": [
[
1448,
1453
]
],
"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::foldICmpAndConstConst",
"InstCombinerImpl::foldICmpAndShift"
],
"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::foldSelectEqualityTest"
],
"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 09361953116770b646decf5820a9455ada2ba4fc
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Wed Oct 16 19:13:52 2024 +0800
[InstCombine] Drop `samesign` in InstCombine (#112480)
Closes https://github.com/llvm/llvm-project/issues/112476.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 7129499e0f8f..18a6fdcec172 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -1738,7 +1738,7 @@ Instruction *InstCombinerImpl::foldICmpAndShift(ICmpInst &Cmp,
// Compute X & (C2 << Y).
Value *NewAnd = Builder.CreateAnd(Shift->getOperand(0), NewShift);
- return replaceOperand(Cmp, 0, NewAnd);
+ return new ICmpInst(Cmp.getPredicate(), NewAnd, Cmp.getOperand(1));
}
return nullptr;
@@ -1844,7 +1844,7 @@ Instruction *InstCombinerImpl::foldICmpAndConstConst(ICmpInst &Cmp,
/*HasNUW=*/true),
One, Or->getName());
Value *NewAnd = Builder.CreateAnd(A, NewOr, And->getName());
- return replaceOperand(Cmp, 0, NewAnd);
+ return new ICmpInst(Cmp.getPredicate(), NewAnd, Cmp.getOperand(1));
}
}
}
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index 8be2eeed84ad..623694663aa1 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -1448,6 +1448,7 @@ Instruction *InstCombinerImpl::foldSelectEqualityTest(SelectInst &Sel) {
m_c_SpecificICmp(ICmpInst::ICMP_EQ, m_Specific(X), m_Specific(Y))))
return nullptr;
+ cast<ICmpInst>(XeqY)->setSameSign(false);
return replaceInstUsesWith(Sel, XeqY);
}
|
[
{
"file": "llvm/test/Transforms/InstCombine/icmp-and-shift.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "test_shr_and_1_ne_0",
"test_body": "define i1 @test_shr_and_1_ne_0(i32 %a, i32 %b) {\n %shr = lshr i32 %a, %b\n %and = and i32 %shr, 1\n %cmp = icmp ne i32 %and, 0\n ret i1 %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/InstCombine/icmp-equality-test.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "icmp_equality_test_swift_optional_pointers",
"test_body": "define i1 @icmp_equality_test_swift_optional_pointers(i64 %X, i64 %Y) {\nentry:\n %XeqC = icmp eq i64 %X, 0\n %YeqC = icmp eq i64 %Y, 0\n %either = select i1 %XeqC, i1 true, i1 %YeqC\n %both = select i1 %XeqC, i1 %YeqC, i1 false\n %XeqY = icmp eq i64 %X, %Y\n %equal = select i1 %either, i1 %both, i1 %XeqY\n ret i1 %equal\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "icmp_equality_test_wrong_equal",
"test_body": "define i1 @icmp_equality_test_wrong_equal(i64 %X, i64 %Y, i64 %Z) {\nentry:\n %XeqZ = icmp eq i64 %X, %Z\n %YeqZ = icmp eq i64 %Y, %Z\n %XeqY = icmp eq i64 %X, %Y\n %not.YeqZ = xor i1 %YeqZ, true\n %and = select i1 %not.YeqZ, i1 %XeqY, i1 false\n %equal = select i1 %XeqZ, i1 %and, i1 %YeqZ\n ret i1 %equal\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "icmp_equality_test_commute_icmp1",
"test_body": "define i1 @icmp_equality_test_commute_icmp1(i64 %X, i64 %Y, i64 %Z) {\nentry:\n %XeqZ = icmp eq i64 %Z, %X\n %YeqZ = icmp eq i64 %Z, %Y\n %XeqY = icmp eq i64 %Y, %X\n %not.YeqZ = xor i1 %YeqZ, true\n %and = select i1 %not.YeqZ, i1 %XeqY, i1 false\n %equal = select i1 %XeqZ, i1 %YeqZ, i1 %and\n ret i1 %equal\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "icmp_equality_test_wrong_cmp",
"test_body": "define i1 @icmp_equality_test_wrong_cmp(i64 %X, i64 %Y, i64 %Z) {\nentry:\n %XeqZ = icmp eq i64 %X, %Z\n %YeqZ = icmp eq i64 %Y, %Z\n %XeqY = icmp eq i64 %X, 999\n %not.YeqZ = xor i1 %YeqZ, true\n %and = select i1 %not.YeqZ, i1 %XeqY, i1 false\n %equal = select i1 %XeqZ, i1 %YeqZ, i1 %and\n ret i1 %equal\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "icmp_equality_test_wrong_constant",
"test_body": "define i1 @icmp_equality_test_wrong_constant(i64 %X, i64 %Y) {\nentry:\n %XeqC = icmp eq i64 %X, 0\n %YeqC = icmp eq i64 %Y, 999\n %XeqY = icmp eq i64 %X, %Y\n %not.YeqC = xor i1 %YeqC, true\n %and = select i1 %not.YeqC, i1 %XeqY, i1 false\n %equal = select i1 %XeqC, i1 %YeqC, i1 %and\n ret i1 %equal\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "icmp_equality_test_vector",
"test_body": "define <2 x i1> @icmp_equality_test_vector(<2 x i64> %X, <2 x i64> %Y) {\nentry:\n %XeqC = icmp eq <2 x i64> %X, <i64 123, i64 456>\n %YeqC = icmp eq <2 x i64> %Y, <i64 123, i64 456>\n %XeqY = icmp eq <2 x i64> %X, %Y\n %not.YeqC = xor <2 x i1> %YeqC, splat (i1 true)\n %and = select <2 x i1> %not.YeqC, <2 x i1> %XeqY, <2 x i1> zeroinitializer\n %equal = select <2 x i1> %XeqC, <2 x i1> %YeqC, <2 x i1> %and\n ret <2 x i1> %equal\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "icmp_equality_test_commute_select2",
"test_body": "define i1 @icmp_equality_test_commute_select2(i64 %X, i64 %Y, i64 %Z) {\nentry:\n %XeqZ = icmp eq i64 %X, %Z\n %YeqZ = icmp eq i64 %Y, %Z\n %XeqY = icmp eq i64 %X, %Y\n %not.XeqZ = xor i1 %XeqZ, true\n %and = select i1 %YeqZ, i1 false, i1 %XeqY\n %equal = select i1 %not.XeqZ, i1 %and, i1 %YeqZ\n ret i1 %equal\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "icmp_equality_test_constant",
"test_body": "define i1 @icmp_equality_test_constant(i42 %X, i42 %Y) {\nentry:\n %XeqC = icmp eq i42 %X, -42\n %YeqC = icmp eq i42 %Y, -42\n %XeqY = icmp eq i42 %X, %Y\n %not.YeqC = xor i1 %YeqC, true\n %and = select i1 %not.YeqC, i1 %XeqY, i1 false\n %equal = select i1 %XeqC, i1 %YeqC, i1 %and\n ret i1 %equal\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "icmp_equality_test_wrong_and",
"test_body": "define i1 @icmp_equality_test_wrong_and(i64 %X, i64 %Y, i64 %Z) {\nentry:\n %XeqZ = icmp eq i64 %X, %Z\n %YeqZ = icmp eq i64 %Y, %Z\n %XeqY = icmp eq i64 %X, %Y\n %not.YeqZ = xor i1 %YeqZ, true\n %and = select i1 %not.YeqZ, i1 false, i1 %XeqY\n %equal = select i1 %XeqZ, i1 %YeqZ, i1 %and\n ret i1 %equal\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "icmp_equality_test",
"test_body": "define i1 @icmp_equality_test(i64 %X, i64 %Y, i64 %Z) {\nentry:\n %XeqZ = icmp eq i64 %X, %Z\n %YeqZ = icmp eq i64 %Y, %Z\n %XeqY = icmp eq i64 %X, %Y\n %not.YeqZ = xor i1 %YeqZ, true\n %and = select i1 %not.YeqZ, i1 %XeqY, i1 false\n %equal = select i1 %XeqZ, i1 %YeqZ, i1 %and\n ret i1 %equal\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "icmp_equality_test_missing_not",
"test_body": "define i1 @icmp_equality_test_missing_not(i64 %X, i64 %Y, i64 %Z) {\n %XeqZ = icmp eq i64 %X, %Z\n %YeqZ = icmp eq i64 %Y, %Z\n %XeqY = icmp eq i64 %X, %Y\n %and = select i1 %YeqZ, i1 %XeqY, i1 false\n %equal = select i1 %XeqZ, i1 %YeqZ, i1 %and\n ret i1 %equal\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "icmp_equality_test_constant_samesign",
"test_body": "define i1 @icmp_equality_test_constant_samesign(i42 %X, i42 %Y) {\nentry:\n %XeqC = icmp eq i42 %X, -42\n %YeqC = icmp eq i42 %Y, -42\n %XeqY = icmp samesign eq i42 %X, %Y\n %not.YeqC = xor i1 %YeqC, true\n %and = select i1 %not.YeqC, i1 %XeqY, i1 false\n %equal = select i1 %XeqC, i1 %YeqC, i1 %and\n ret i1 %equal\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "icmp_equality_test_commute_icmp2",
"test_body": "define i1 @icmp_equality_test_commute_icmp2(i64 %X, i64 %Y, i64 %Z) {\n %XeqZ = icmp eq i64 %Z, %X\n %YeqZ = icmp eq i64 %Y, %Z\n %XeqY = icmp eq i64 %Y, %X\n %not.YeqZ = xor i1 %YeqZ, true\n %and = select i1 %not.YeqZ, i1 %XeqY, i1 false\n %equal = select i1 %XeqZ, i1 %YeqZ, i1 %and\n ret i1 %equal\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "icmp_equality_test_commute_select1",
"test_body": "define i1 @icmp_equality_test_commute_select1(i64 %X, i64 %Y, i64 %Z) {\nentry:\n %XeqZ = icmp eq i64 %X, %Z\n %YeqZ = icmp eq i64 %Y, %Z\n %XeqY = icmp eq i64 %X, %Y\n %and = select i1 %YeqZ, i1 false, i1 %XeqY\n %equal = select i1 %XeqZ, i1 %YeqZ, i1 %and\n ret i1 %equal\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/InstCombine/icmp.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "icmp_and_or_lshr",
"test_body": "target datalayout = \"e-p:64:64:64-p1:16:16:16-p2:32:32:32-p3:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64\"\n\ndefine i1 @icmp_and_or_lshr(i32 %x, i32 %y) {\n %shf = lshr i32 %x, %y\n %or = or i32 %shf, %x\n %and = and i32 %or, 1\n %ret = icmp ne i32 %and, 0\n ret i1 %ret\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstCombine] `samesign` flag should be dropped in `InstCombinerImpl::foldICmpAndConstConst`",
"body": "Reproducer:\r\n```\r\ndefine i1 @src(i32 %x, i32 %y) {\r\n %shf = lshr i32 %x, %y\r\n %or = or i32 %shf, %x\r\n %and = and i32 %or, 1\r\n %ret = icmp samesign ne i32 %and, 0\r\n ret i1 %ret\r\n}\r\n\r\ndefine i1 @tgt(i32 %x, i32 %y) {\r\n %shf1 = shl nuw i32 1, %y\r\n %or2 = or i32 %shf1, 1\r\n %and3 = and i32 %x, %or2\r\n %ret = icmp samesign ne i32 %and3, 0\r\n ret i1 %ret\r\n}\r\n```\r\n```\r\nTransformation doesn't verify!\r\n\r\nERROR: Target is more poisonous than source\r\n\r\nExample:\r\ni32 %x = #x80000000 (2147483648, -2147483648)\r\ni32 %y = #x0000001f (31)\r\n\r\nSource:\r\ni32 %shf = #x00000001 (1)\r\ni32 %or = #x80000001 (2147483649, -2147483647)\r\ni32 %and = #x00000001 (1)\r\ni1 %ret = #x1 (1)\r\n\r\nTarget:\r\ni32 %shf1 = #x80000000 (2147483648, -2147483648)\r\ni32 %or2 = #x80000001 (2147483649, -2147483647)\r\ni32 %and3 = #x80000000 (2147483648, -2147483648)\r\ni1 %ret = poison\r\nSource value: #x1 (1)\r\nTarget value: poison\r\n```\r\n",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": []
}
| true |
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
| null |
113869
|
https://github.com/llvm/llvm-project/issues/113869
|
miscompilation
|
c752efbdcc1ebd81f879633d6b798248064e2ae2
| 2024-10-28T06:34:27 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "e577f14b670ee2ae6bb717133310b215be4331b3",
"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": [
[
1056,
1062
]
],
"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": [
"canonicalizeSaturatedAdd"
],
"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 e577f14b670ee2ae6bb717133310b215be4331b3
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Fri Nov 1 22:18:44 2024 +0800
[InstCombine] Use `m_NotForbidPoison` when folding `(X u< Y) ? -1 : (~X + Y) --> uadd.sat(~X, Y)` (#114345)
Alive2: https://alive2.llvm.org/ce/z/mTGCo-
We cannot reuse `~X` if `m_AllOnes` matches a vector constant with some
poison elts. An alternative solution is to create a new not instead of
reusing `~X`. But it doesn't worth the effort because we need to add a
one-use check.
Fixes https://github.com/llvm/llvm-project/issues/113869.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index 162ebebf1b8f..999ad1adff20 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -1056,7 +1056,7 @@ static Value *canonicalizeSaturatedAdd(ICmpInst *Cmp, Value *TVal, Value *FVal,
// Strictness of the comparison is irrelevant.
X = Cmp0;
Y = Cmp1;
- if (match(FVal, m_c_Add(m_Not(m_Specific(X)), m_Specific(Y)))) {
+ if (match(FVal, m_c_Add(m_NotForbidPoison(m_Specific(X)), m_Specific(Y)))) {
// (X u< Y) ? -1 : (~X + Y) --> uadd.sat(~X, Y)
// (X u< Y) ? -1 : (Y + ~X) --> uadd.sat(Y, ~X)
BinaryOperator *BO = cast<BinaryOperator>(FVal);
|
[
{
"file": "llvm/test/Transforms/InstCombine/saturating-add-sub.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "uadd_sat_not_commute_select",
"test_body": "define i32 @uadd_sat_not_commute_select(i32 %x, i32 %y) {\n %notx = xor i32 %x, -1\n %a = add i32 %notx, %y\n %c = icmp ult i32 %y, %x\n %r = select i1 %c, i32 %a, i32 -1\n ret i32 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "uadd_sat_not_ugt_commute_add",
"test_body": "define <2 x i32> @uadd_sat_not_ugt_commute_add(<2 x i32> %x, <2 x i32> %yp) {\n %y = sdiv <2 x i32> %yp, <i32 2442, i32 4242>\n %notx = xor <2 x i32> %x, splat (i32 -1)\n %a = add <2 x i32> %y, %notx\n %c = icmp ugt <2 x i32> %y, %x\n %r = select <2 x i1> %c, <2 x i32> splat (i32 -1), <2 x i32> %a\n ret <2 x i32> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "uadd_sat_not_ugt_commute_add_partial_poison",
"test_body": "define <2 x i32> @uadd_sat_not_ugt_commute_add_partial_poison(<2 x i32> %x, <2 x i32> %yp) {\n %notx = xor <2 x i32> %x, <i32 -1, i32 poison>\n %a = add nuw <2 x i32> %yp, %notx\n %c = icmp ugt <2 x i32> %yp, %x\n %r = select <2 x i1> %c, <2 x i32> splat (i32 -1), <2 x i32> %a\n ret <2 x i32> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Poison value wrongly propagates through vector operations on an optimized code",
"body": "https://github.com/llvm/llvm-project/blob/5d4a0d54b5269bad1410e6db957836fe98634069/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp#L1050-L1060\r\n\r\nAlive2 report: https://alive2.llvm.org/ce/z/6tSdhb\r\n\r\n```llvm\r\n----------------------------------------\r\ndefine <2 x i32> @uadd_sat_not_ugt_commute_add.2(<2 x i32> %x, <2 x i32> %yp) {\r\n#0:\r\n %#1 = sdiv <2 x i32> { 2442, 4242 }, %yp\r\n %notx = xor <2 x i32> %x, { 4294967295, poison }\r\n %a = add nuw <2 x i32> %#1, %notx\r\n %c = icmp ugt <2 x i32> %#1, %x\r\n %r = select <2 x i1> %c, <2 x i32> { 4294967295, 4294967295 }, <2 x i32> %a\r\n ret <2 x i32> %r\r\n}\r\n=>\r\ndefine <2 x i32> @uadd_sat_not_ugt_commute_add.2(<2 x i32> %x, <2 x i32> %yp) {\r\n#0:\r\n %#1 = sdiv <2 x i32> { 2442, 4242 }, %yp\r\n %notx = xor <2 x i32> %x, { 4294967295, poison }\r\n %r = uadd_sat <2 x i32> %#1, %notx\r\n ret <2 x i32> %r\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 i32> %x = < poison, #x00000000 (0) >\r\n<2 x i32> %yp = < #x00000008 (8), #x0000000e (14) >\r\n\r\nSource:\r\n<2 x i32> %#1 = < #x00000131 (305), #x0000012f (303) >\r\n<2 x i32> %notx = < poison, poison >\r\n<2 x i32> %a = < poison, poison >\r\n<2 x i1> %c = < poison, #x1 (1) >\r\n<2 x i32> %r = < poison, #xffffffff (4294967295, -1) >\r\n\r\nTarget:\r\n<2 x i32> %#1 = < #x00000131 (305), #x0000012f (303) >\r\n<2 x i32> %notx = < poison, poison >\r\n<2 x i32> %r = < poison, poison >\r\nSource value: < poison, #xffffffff (4294967295, -1) >\r\nTarget value: < 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```",
"author": "bongjunj",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
134696
|
https://github.com/llvm/llvm-project/issues/134696
|
crash
|
b71123f1272ee081b18b8ced1925d6e9300e7310
| 2025-04-07T17:26:23 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "995fd47944f471e985e34d7da8c0667059decbac",
"components": [
"LoopAccessAnalysis"
],
"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": [
[
1781,
1787
]
],
"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": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": [
"MemoryDepChecker::couldPreventStoreLoadForward"
],
"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 995fd47944f471e985e34d7da8c0667059decbac
Author: Florian Hahn <flo@fhahn.com>
Date: Sat Apr 12 20:05:37 2025 +0100
[LAA] Make sure MaxVF for Store-Load forward safe dep distances is pow2.
MaxVF computed in couldPreventStoreLoadFowrard may not be a power of 2,
as CommonStride may not be a power-of-2.
This can cause crashes after 78777a20. Use bit_floor to make sure it is
a suitable power-of-2.
Fixes https://github.com/llvm/llvm-project/issues/134696.
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index a37ed5c706bd..0cb1332eb337 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -1781,7 +1781,8 @@ bool MemoryDepChecker::couldPreventStoreLoadForward(uint64_t Distance,
MaxStoreLoadForwardSafeDistanceInBits &&
MaxVFWithoutSLForwardIssuesPowerOf2 !=
VectorizerParams::MaxVectorWidth * TypeByteSize) {
- uint64_t MaxVF = MaxVFWithoutSLForwardIssuesPowerOf2 / CommonStride;
+ uint64_t MaxVF =
+ bit_floor(MaxVFWithoutSLForwardIssuesPowerOf2 / CommonStride);
uint64_t MaxVFInBits = MaxVF * TypeByteSize * 8;
MaxStoreLoadForwardSafeDistanceInBits =
std::min(MaxStoreLoadForwardSafeDistanceInBits, MaxVFInBits);
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/RISCV/safe-dep-distance.ll",
"commands": [
"opt < %s -passes=loop-vectorize -scalable-vectorization=on -riscv-v-vector-bits-min=-1 -mtriple riscv64-linux-gnu -mattr=+v,+f -S"
],
"tests": [
{
"test_name": "safe_load_store_distance_not_pow_of_2",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n64-S128\"\ntarget triple = \"riscv64\"\n\n@a = external global [10 x [12 x i16]]\n\ndefine void @safe_load_store_distance_not_pow_of_2(i64 %N) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep = getelementptr [10 x [12 x i16]], ptr @a, i64 0, i64 0, i64 %iv\n %0 = load i16, ptr %gep, align 2\n %gep.off = getelementptr [10 x [12 x i16]], ptr @a, i64 0, i64 8, i64 %iv\n store i16 0, ptr %gep.off, align 2\n %iv.next = add nsw i64 %iv, 3\n %cmp = icmp ult i64 %iv, %N\n br i1 %cmp, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[LoopVectorize] Assertion `isPowerOf2_32(End.getKnownMinValue()) && \"Expected End to be a power of 2\"' failed.",
"body": "Testcase:\n```llvm ir\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\n@a = external global [0 x [12 x i16]]\n\ndefine void @b(i64 %0) #0 {\nentry:\n br label %for.cond3.preheader\n\nfor.cond3.preheader: ; preds = %for.cond3.preheader, %entry\n %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.cond3.preheader ]\n %arrayidx9 = getelementptr [0 x [12 x i16]], ptr @a, i64 0, i64 0, i64 %indvars.iv\n %1 = load i16, ptr %arrayidx9, align 2\n %arrayidx9.2 = getelementptr [0 x [12 x i16]], ptr @a, i64 0, i64 8, i64 %indvars.iv\n store i16 0, ptr %arrayidx9.2, align 2\n %indvars.iv.next = add nsw i64 %indvars.iv, 3\n %cmp = icmp ult i64 %indvars.iv, %0\n br i1 %cmp, label %for.cond3.preheader, label %for.cond.cleanup.loopexit\n\nfor.cond.cleanup.loopexit: ; preds = %for.cond3.preheader\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+v\" }\n```\n\nCommands/backtrace\n```\n$ /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt reduced.ll --passes=loop-vectorize\nWARNING: You're attempting to print out a bitcode file.\nThis is inadvisable as it may cause display problems. If\nyou REALLY want to taste LLVM bitcode first-hand, you\ncan force output with the `-f' option.\n\nopt: /scratch/ewlu/daily-upstream-build/llvm/llvm/lib/Transforms/Vectorize/VPlanHelpers.h:87: llvm::VFRange::VFRange(const llvm::ElementCount&, const llvm::ElementCount&): Assertion `isPowerOf2_32(End.getKnownMinValue()) && \"Expected End to be a power of 2\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0. Program arguments: /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt reduced.ll --passes=loop-vectorize\n1. Running pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"reduced.ll\"\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"b\"\n #0 0x00005c0c5d95b1a2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x349c1a2)\n #1 0x00005c0c5d95820f llvm::sys::RunSignalHandlers() (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x349920f)\n #2 0x00005c0c5d958354 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #3 0x0000774312045330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)\n #4 0x000077431209eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #5 0x000077431209eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #6 0x000077431209eb2c pthread_kill ./nptl/pthread_kill.c:89:10\n #7 0x000077431204527e raise ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x00007743120288ff abort ./stdlib/abort.c:81:7\n #9 0x000077431202881b _nl_load_domain ./intl/loadmsgcat.c:1177:9\n#10 0x000077431203b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)\n#11 0x00005c0c5c7b1baf llvm::LoopVectorizationPlanner::buildVPlansWithVPRecipes(llvm::ElementCount, llvm::ElementCount) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x22f2baf)\n#12 0x00005c0c5c7b210d llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x22f310d)\n#13 0x00005c0c5c7b4105 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x22f5105)\n#14 0x00005c0c5c7b7511 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x22f8511)\n#15 0x00005c0c5c7b7ad7 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x22f8ad7)\n#16 0x00005c0c5b484b75 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0xfc5b75)\n#17 0x00005c0c5d74633a llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x328733a)\n#18 0x00005c0c5b4872b5 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0xfc82b5)\n#19 0x00005c0c5d744c14 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x3285c14)\n#20 0x00005c0c5b483265 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0xfc4265)\n#21 0x00005c0c5d74522d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x328622d)\n#22 0x00005c0c5ac19391 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/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x75a391)\n#23 0x00005c0c5ac0aeac optMain (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x74beac)\n#24 0x000077431202a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3\n#25 0x000077431202a28b call_init ./csu/../csu/libc-start.c:128:20\n#26 0x000077431202a28b __libc_start_main ./csu/../csu/libc-start.c:347:5\n#27 0x00005c0c5ac014f5 _start (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x7424f5)\nAborted (core dumped)\n```\n\ngodbolt: https://godbolt.org/z/rKd5sx7xW\n\nFound via fuzzer (C program before reduction)",
"author": "ewlu",
"labels": [
"vectorizers",
"crash",
"generated by fuzzer"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
102187
|
https://github.com/llvm/llvm-project/issues/102187
|
crash
|
4b6e3e38c46f8fedb92a30b29cc9654450244e2d
| 2024-08-06T17:31:46 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "2601d6f189cf1d4e4e77a7cba83e5d32c87bf079",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
14049,
14060
],
[
14080,
14090
]
],
"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 2601d6f189cf1d4e4e77a7cba83e5d32c87bf079
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Tue Aug 6 12:27:36 2024 -0700
[SLP]Fix PR102187: do not insert extractelement before landingpad instruction.
Landingpad instruction must be the very first instruction after the phi
nodes, so need to inser extractelement/shuffles after this instruction.
Fixes https://github.com/llvm/llvm-project/issues/102187
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 9589d306581e..5c8873853a73 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -14049,12 +14049,19 @@ Value *BoUpSLP::vectorizeTree(
"ExternallyUsedValues map or remain as scalar in vectorized "
"instructions");
if (auto *VecI = dyn_cast<Instruction>(Vec)) {
- if (auto *PHI = dyn_cast<PHINode>(VecI))
- Builder.SetInsertPoint(PHI->getParent(),
- PHI->getParent()->getFirstNonPHIIt());
- else
+ if (auto *PHI = dyn_cast<PHINode>(VecI)) {
+ if (PHI->getParent()->isLandingPad())
+ Builder.SetInsertPoint(
+ PHI->getParent(),
+ std::next(
+ PHI->getParent()->getLandingPadInst()->getIterator()));
+ else
+ Builder.SetInsertPoint(PHI->getParent(),
+ PHI->getParent()->getFirstNonPHIIt());
+ } else {
Builder.SetInsertPoint(VecI->getParent(),
std::next(VecI->getIterator()));
+ }
} else {
Builder.SetInsertPoint(&F->getEntryBlock(), F->getEntryBlock().begin());
}
@@ -14080,11 +14087,18 @@ Value *BoUpSLP::vectorizeTree(
auto VecIt = VectorCasts.find(Key);
if (VecIt == VectorCasts.end()) {
IRBuilderBase::InsertPointGuard Guard(Builder);
- if (auto *IVec = dyn_cast<PHINode>(Vec))
- Builder.SetInsertPoint(
- IVec->getParent()->getFirstNonPHIOrDbgOrLifetime());
- else if (auto *IVec = dyn_cast<Instruction>(Vec))
+ if (auto *IVec = dyn_cast<PHINode>(Vec)) {
+ if (IVec->getParent()->isLandingPad())
+ Builder.SetInsertPoint(IVec->getParent(),
+ std::next(IVec->getParent()
+ ->getLandingPadInst()
+ ->getIterator()));
+ else
+ Builder.SetInsertPoint(
+ IVec->getParent()->getFirstNonPHIOrDbgOrLifetime());
+ } else if (auto *IVec = dyn_cast<Instruction>(Vec)) {
Builder.SetInsertPoint(IVec->getNextNonDebugInstruction());
+ }
Vec = Builder.CreateIntCast(
Vec,
getWidenedType(
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/extractelement-phi-in-landingpad.ll",
"commands": [
"opt -S --passes=slp-vectorizer -slp-threshold=-99999 -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define void @test() personality ptr null {\nbb:\n invoke void null()\n to label %bb65 unwind label %bb4\n\nbb2: ; No predecessors!\n invoke void null()\n to label %bb65 unwind label %bb4\n\nbb4: ; preds = %bb2, %bb\n %phi5 = phi i32 [ 0, %bb ], [ 0, %bb2 ]\n %phi6 = phi i32 [ 0, %bb ], [ 0, %bb2 ]\n %landingpad = landingpad { ptr, i32 }\n cleanup\n call void null(i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5)\n ret void\n\nbb65: ; preds = %bb2, %bb\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "LLVM ERROR: Broken module found, compilation aborted!",
"body": "To reproduce run opt with \r\n[Test.ll.tgz](https://github.com/user-attachments/files/16513795/Test.ll.tgz)\r\nusing `-passes slp-vectorizer -slp-threshold=-99999` \r\n\r\nReproducer https://godbolt.org/z/f4szGsMYd\r\n\r\n```\r\nThe unwind destination does not have an exception handling instruction!\r\n %invoke = invoke i64 null(ptr addrspace(1) null, i32 0, i64 0, i32 0)\r\n to label %bb65 unwind label %bb4\r\nThe unwind destination does not have an exception handling instruction!\r\n %invoke3 = invoke i64 null(ptr addrspace(1) null, i32 0, i64 0, i32 0)\r\n to label %bb65 unwind label %bb4\r\nLandingPadInst not the first non-PHI instruction in the block.\r\n %landingpad = landingpad { ptr, i32 }\r\n cleanup\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 -slp-threshold=-99999 <source>\r\n1.\tRunning pass \"verify\" on module \"<source>\"\r\n #0 0x0000000004f1d2d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f1d2d8)\r\n #1 0x0000000004f1aa4c SignalHandler(int) Signals.cpp:0:0\r\n #2 0x0000788c1ca42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x0000788c1ca969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x0000788c1ca42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x0000788c1ca287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00000000007b40fd llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0\r\n #7 0x0000000004e571e8 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e571e8)\r\n #8 0x0000000004d53550 llvm::VerifierPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d53550)\r\n #9 0x00000000008d8a7e 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+0x8d8a7e)\r\n#10 0x0000000004d17270 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d17270)\r\n#11 0x00000000008e37f2 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+0x8e37f2)\r\n#12 0x00000000008d671c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8d671c)\r\n#13 0x0000788c1ca29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#14 0x0000788c1ca29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#15 0x00000000008cdb7e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8cdb7e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```",
"author": "TatyanaDoubts",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
117537
|
https://github.com/llvm/llvm-project/issues/117537
|
crash
|
c979ec05642f292737d250c6682d85ed49bc7b6e
| 2024-11-25T10:47:02 |
[
"llvm/test/Transforms/SimpleLoopUnswitch"
] |
{
"fix_commit": "fc5c89900f2a4b50e0f3a88ef7c89115d93684f4",
"components": [
"SimpleLoopUnswitch"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
1248,
1255
]
],
"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": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": [
"buildClonedLoopBlocks"
],
"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 fc5c89900f2a4b50e0f3a88ef7c89115d93684f4
Author: Nikita Popov <npopov@redhat.com>
Date: Wed Nov 27 11:47:22 2024 +0100
[SimpleLoopUnswitch] Fix LCSSA phi node invalidation
Fixes https://github.com/llvm/llvm-project/issues/117537.
diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
index aa3cbc5e4bdd..d8ef450eeb9a 100644
--- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
+++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
@@ -1248,8 +1248,9 @@ static BasicBlock *buildClonedLoopBlocks(
assert(VMap.lookup(&I) == &ClonedI && "Mismatch in the value map!");
// Forget SCEVs based on exit phis in case SCEV looked through the phi.
- if (SE && isa<PHINode>(I))
- SE->forgetValue(&I);
+ if (SE)
+ if (auto *PN = dyn_cast<PHINode>(&I))
+ SE->forgetLcssaPhiWithNewPredecessor(&L, PN);
BasicBlock::iterator InsertPt = MergeBB->getFirstInsertionPt();
|
[
{
"file": "llvm/test/Transforms/SimpleLoopUnswitch/pr117537.ll",
"commands": [
"opt -S -passes='print<scalar-evolution>,simple-loop-unswitch<nontrivial>,print<scalar-evolution>' -verify-scev < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "define void @test(ptr %p) {\nentry:\n %check = icmp eq ptr %p, null\n br label %bb0\n\nbb0: ; preds = %loop0, %entry\n br i1 %check, label %loop0, label %latch\n\nlatch: ; preds = %bb0\n br i1 %check, label %exit0, label %loop0\n\nexit0: ; preds = %latch\n ret void\n\nloop0: ; preds = %latch, %bb0\n %v = load atomic i32, ptr %p unordered, align 8\n %add = add i32 %v, 3\n br i1 true, label %preheader, label %bb0\n\npreheader: ; preds = %loop0\n br label %loop1\n\nloop1: ; preds = %backedge, %preheader\n %iv1 = phi i32 [ %add, %preheader ], [ %iv1.next, %backedge ]\n %iv1.next = add i32 %iv1, -33\n br label %loop2\n\nbackedge: ; preds = %loop2\n br i1 true, label %exit1, label %loop1\n\nloop2: ; preds = %loop2, %loop1\n %iv0 = phi i32 [ %iv1, %loop1 ], [ %iv0.next, %loop2 ]\n %iv0.next = add nsw i32 %iv0, 1\n %cmp = icmp sgt i32 %iv0.next, 0\n br i1 %cmp, label %backedge, label %loop2\n\nexit1: ; preds = %backedge\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SCEV] Assertion `isAvailableAtLoopEntry(Op, L) && \"SCEVAddRecExpr operand is not available at loop entry!\"' failed.",
"body": "Faulty IR:\n```\n; ModuleID = 'test.ll'\nsource_filename = \"/nfs/build-cache/zvm-dev-4598/jdk11/x86_64/fastdebug/lib/server/boilerplate.ll\"\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @test(ptr addrspace(1) %p) {\nentry:\n %check = icmp eq ptr addrspace(1) %p, null\n br label %bb0\n\nbb0: ; preds = %loop0, %entry\n br i1 %check, label %loop0, label %latch\n\nlatch: ; preds = %bb0\n br i1 %check, label %exit0, label %loop0\n\nexit0: ; preds = %latch\n ret void\n\nloop0: ; preds = %latch, %bb0\n %0 = load atomic i32, ptr addrspace(1) %p unordered, align 8\n %add = add i32 %0, 3\n br i1 true, label %preheader, label %bb0\n\npreheader: ; preds = %loop0\n br label %loop1\n\nloop1: ; preds = %backedge, %preheader\n %iv1 = phi i32 [ %add, %preheader ], [ %1, %backedge ]\n %1 = add i32 %iv1, -33\n br label %loop2\n\nbackedge: ; preds = %loop2\n br i1 true, label %exit1, label %loop1\n\nloop2: ; preds = %loop2, %loop1\n %iv0 = phi i32 [ %iv1, %loop1 ], [ %2, %loop2 ]\n %2 = add nsw i32 %iv0, 1\n %3 = icmp sgt i32 %2, 0\n br i1 %3, label %backedge, label %loop2\n\nexit1: ; preds = %backedge\n ret void\n}\n```\nfails when run with `opt -passes='print<scalar-evolution>,simple-loop-unswitch<nontrivial>,print<scalar-evolution>' `\nDemo of failure: https://godbolt.org/z/qhboK5r3j\n",
"author": "Nirhar",
"labels": [
"crash",
"llvm:transforms"
],
"comments": [
{
"author": "Nirhar",
"body": "Here is the IR after simple-loop-unswitch pass:\n\n\n\nAt the point of crash, the SCEV for Exit Value of `%iv0`(which I assume, as we crashed while printing it) is `(-4 + (-1 * %1) + %.us-phi)`, which is incorrect. The crash happens because `%1` is in a block that does not properly dominate `%iv0`. Looks like, simple-loop-unswitch is either incorrectly updating the SCEV in the pass, or is incorrectly reporting SCEV to be preserved. As of now, I'm not sure which is the case. "
},
{
"author": "Nirhar",
"body": "@nikic @dtcxzyw @EugeneZelenko any thoughts? I'm inclined to having a patch that removes SCEV from simple-loop-unswitch 's list of preserved analyses."
},
{
"author": "dtcxzyw",
"body": "> I'm inclined to having a patch that removes SCEV from simple-loop-unswitch 's list of preserved analyses.\n\nSome SCEVs should be invalidated in `unswitchNontrivialInvariants`. Removing SCEV from the list of preserved analyses doesn't fix the issue.\n"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
129057
|
https://github.com/llvm/llvm-project/issues/129057
|
miscompilation
|
6a5bb4c2f1e7a48d5c8ffd7b5ab4a7addc3e661f
| 2025-02-27T13:44:09 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "69effe054c136defda8766688ac0de4626a0eb05",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
18071,
18076
]
],
"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::collectValuesToDemote"
],
"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 69effe054c136defda8766688ac0de4626a0eb05
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Thu Feb 27 08:33:07 2025 -0800
[SLP]Check for potential safety of the truncation for vectorized scalars with multi uses
If the vectorized scalars has multiple uses, need to check if it is safe
to truncate the vectorized value, before actually trying doing it.
Otherwise, the compiler may loose some important bits, which may lead to
a miscompilation.
Fixes #129057
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index e8c91ebd508c..2d343ca31f07 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -18071,6 +18071,12 @@ bool BoUpSLP::collectValuesToDemote(
(void)for_each(E.Scalars, std::bind(IsPotentiallyTruncated, _1,
std::ref(BitWidth)));
} else {
+ // Several vectorized uses? Check if we can truncate it, otherwise -
+ // exit.
+ if (any_of(E.Scalars, [&](Value *V) {
+ return !V->hasOneUse() && !IsPotentiallyTruncated(V, BitWidth);
+ }))
+ return false;
bool NeedToExit = false;
if (Checker && !AttemptCheckBitwidth(Checker, NeedToExit))
return false;
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/ext-used-scalar-different-bitwidth.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-100 < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@f = global i32 zeroinitializer\n@.str = constant [4 x i8] c\"%d\\0A\\00\"\n\ndefine i32 @main() {\nentry:\n store i32 152, ptr @f, align 4\n %agg.tmp.sroa.0.0.copyload.i = load i32, ptr @f, align 4\n %add.i.i = shl i32 %agg.tmp.sroa.0.0.copyload.i, 24\n %sext.i = add i32 %add.i.i, 83886080\n %conv2.i = ashr i32 %sext.i, 24\n %and.i = and i32 %conv2.i, 66440127\n %cmp3.i.i = icmp ugt i32 %and.i, 33554431\n %shl.i.i = select i1 %cmp3.i.i, i32 0, i32 6\n %cond.i.i = shl i32 %and.i, %shl.i.i\n %0 = trunc i32 %cond.i.i to i8\n %sext.1.i = add i32 0, 83886080\n %conv2.1.i = ashr i32 %sext.1.i, 24\n %and.1.i = and i32 %conv2.1.i, 1\n %cmp3.i.1.i = icmp ugt i32 0, 0\n %shl.i.1.i = select i1 %cmp3.i.1.i, i32 0, i32 0\n %cond.i.1.i = shl i32 %and.1.i, %shl.i.1.i\n %1 = trunc i32 %cond.i.1.i to i8\n %conv17.1.i = and i8 %0, %1\n %sext.2.i = add i32 0, 83886080\n %conv2.2.i = ashr i32 %sext.2.i, 24\n %and.2.i = and i32 %conv2.2.i, 1\n %shl.i.2.i = select i1 false, i32 0, i32 0\n %cond.i.2.i = shl i32 %and.2.i, %shl.i.2.i\n %2 = trunc i32 %cond.i.2.i to i8\n %conv17.2.i = and i8 %conv17.1.i, %2\n %sext.3.i = add i32 0, 83886080\n %conv2.3.i = ashr i32 %sext.3.i, 24\n %and.3.i = and i32 %conv2.3.i, 1\n %shl.i.3.i = select i1 false, i32 0, i32 0\n %cond.i.3.i = shl i32 %and.3.i, %shl.i.3.i\n %3 = trunc i32 %cond.i.3.i to i8\n %conv17.3.i = and i8 %conv17.2.i, %3\n %sext.4.i = add i32 0, 83886080\n %conv2.4.i = ashr i32 %sext.4.i, 24\n %and.4.i = and i32 %conv2.4.i, 1\n %shl.i.4.i = select i1 false, i32 0, i32 0\n %cond.i.4.i = shl i32 %and.4.i, %shl.i.4.i\n %4 = trunc i32 %cond.i.4.i to i8\n %conv17.4.i = and i8 %conv17.3.i, %4\n %sext.5.i = add i32 0, 83886080\n %conv2.5.i = ashr i32 %sext.5.i, 24\n %and.5.i = and i32 %conv2.5.i, 1\n %shl.i.5.i = select i1 false, i32 0, i32 0\n %cond.i.5.i = shl i32 %and.5.i, %shl.i.5.i\n %5 = trunc i32 %cond.i.5.i to i8\n %conv17.5.i = and i8 %conv17.4.i, %5\n %sext.6.i = add i32 0, 83886080\n %conv2.6.i = ashr i32 %sext.6.i, 24\n %and.6.i = and i32 %conv2.6.i, 1\n %shl.i.6.i = select i1 false, i32 0, i32 0\n %cond.i.6.i = shl i32 %and.6.i, %shl.i.6.i\n %6 = trunc i32 %cond.i.6.i to i8\n %conv17.6.i = and i8 %conv17.5.i, %6\n %sext.7.i = add i32 0, 83886080\n %conv2.7.i = ashr i32 %sext.7.i, 24\n %and.7.i = and i32 %conv2.7.i, 1\n %shl.i.7.i = select i1 false, i32 0, i32 0\n %cond.i.7.i = shl i32 %and.7.i, %shl.i.7.i\n %7 = trunc i32 %cond.i.7.i to i8\n %conv17.7.i = and i8 %conv17.6.i, %7\n %conv = zext i8 %conv17.7.i to i32\n %call1 = call i32 (ptr, ...) @printf(ptr @.str, i32 %conv)\n ret i32 0\n}\n\ndeclare i32 @printf(ptr, ...)",
"lli_expected_out": "1\n",
"additional_args": null
}
]
}
] |
{
"title": "[SLPVectorizer] Miscompilation at O3",
"body": "Reproducer:\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\n@f = global i32 zeroinitializer\n@.str = constant [4 x i8] c\"%d\\0A\\00\"\n\ndefine i32 @main() {\nentry:\n store i32 152, ptr @f, align 4\n %agg.tmp.sroa.0.0.copyload.i = load i32, ptr @f, align 4\n %add.i.i = shl i32 %agg.tmp.sroa.0.0.copyload.i, 24\n %sext.i = add i32 %add.i.i, 83886080\n %conv2.i = ashr i32 %sext.i, 24\n %and.i = and i32 %conv2.i, 66440127\n %cmp3.i.i = icmp ugt i32 %and.i, 33554431\n %shl.i.i = select i1 %cmp3.i.i, i32 0, i32 6\n %cond.i.i = shl i32 %and.i, %shl.i.i\n %0 = trunc i32 %cond.i.i to i8\n %sext.1.i = add i32 0, 83886080\n %conv2.1.i = ashr i32 %sext.1.i, 24\n %and.1.i = and i32 %conv2.1.i, 1\n %cmp3.i.1.i = icmp ugt i32 0, 0\n %shl.i.1.i = select i1 %cmp3.i.1.i, i32 0, i32 0\n %cond.i.1.i = shl i32 %and.1.i, %shl.i.1.i\n %1 = trunc i32 %cond.i.1.i to i8\n %conv17.1.i = and i8 %0, %1\n %sext.2.i = add i32 0, 83886080\n %conv2.2.i = ashr i32 %sext.2.i, 24\n %and.2.i = and i32 %conv2.2.i, 1\n %shl.i.2.i = select i1 false, i32 0, i32 0\n %cond.i.2.i = shl i32 %and.2.i, %shl.i.2.i\n %2 = trunc i32 %cond.i.2.i to i8\n %conv17.2.i = and i8 %conv17.1.i, %2\n %sext.3.i = add i32 0, 83886080\n %conv2.3.i = ashr i32 %sext.3.i, 24\n %and.3.i = and i32 %conv2.3.i, 1\n %shl.i.3.i = select i1 false, i32 0, i32 0\n %cond.i.3.i = shl i32 %and.3.i, %shl.i.3.i\n %3 = trunc i32 %cond.i.3.i to i8\n %conv17.3.i = and i8 %conv17.2.i, %3\n %sext.4.i = add i32 0, 83886080\n %conv2.4.i = ashr i32 %sext.4.i, 24\n %and.4.i = and i32 %conv2.4.i, 1\n %shl.i.4.i = select i1 false, i32 0, i32 0\n %cond.i.4.i = shl i32 %and.4.i, %shl.i.4.i\n %4 = trunc i32 %cond.i.4.i to i8\n %conv17.4.i = and i8 %conv17.3.i, %4\n %sext.5.i = add i32 0, 83886080\n %conv2.5.i = ashr i32 %sext.5.i, 24\n %and.5.i = and i32 %conv2.5.i, 1\n %shl.i.5.i = select i1 false, i32 0, i32 0\n %cond.i.5.i = shl i32 %and.5.i, %shl.i.5.i\n %5 = trunc i32 %cond.i.5.i to i8\n %conv17.5.i = and i8 %conv17.4.i, %5\n %sext.6.i = add i32 0, 83886080\n %conv2.6.i = ashr i32 %sext.6.i, 24\n %and.6.i = and i32 %conv2.6.i, 1\n %shl.i.6.i = select i1 false, i32 0, i32 0\n %cond.i.6.i = shl i32 %and.6.i, %shl.i.6.i\n %6 = trunc i32 %cond.i.6.i to i8\n %conv17.6.i = and i8 %conv17.5.i, %6\n %sext.7.i = add i32 0, 83886080\n %conv2.7.i = ashr i32 %sext.7.i, 24\n %and.7.i = and i32 %conv2.7.i, 1\n %shl.i.7.i = select i1 false, i32 0, i32 0\n %cond.i.7.i = shl i32 %and.7.i, %shl.i.7.i\n %7 = trunc i32 %cond.i.7.i to i8\n %conv17.7.i = and i8 %conv17.6.i, %7\n %conv = zext i8 %conv17.7.i to i32\n %call1 = call i32 (ptr, ...) @printf(ptr @.str, i32 %conv)\n ret i32 0\n}\n\ndeclare i32 @printf(ptr, ...)\n```\n```\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@f = global i32 0\n@.str = constant [4 x i8] c\"%d\\0A\\00\"\n\ndefine i32 @main() {\nentry:\n store i32 152, ptr @f, align 4\n %agg.tmp.sroa.0.0.copyload.i = load i32, ptr @f, align 4\n %add.i.i = shl i32 %agg.tmp.sroa.0.0.copyload.i, 24\n %0 = insertelement <8 x i32> <i32 poison, i32 83886080, i32 83886080, i32 83886080, i32 83886080, i32 83886080, i32 83886080, i32 83886080>, i32 %add.i.i, i32 0\n %1 = add <8 x i32> <i32 83886080, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>, %0\n %2 = ashr <8 x i32> %1, splat (i32 24)\n %3 = trunc <8 x i32> %2 to <8 x i8>\n %4 = and <8 x i8> %3, <i8 -65, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>\n %5 = zext <8 x i8> %4 to <8 x i32>\n %6 = shufflevector <8 x i32> %5, <8 x i32> poison, <2 x i32> <i32 0, i32 poison>\n %7 = shufflevector <2 x i32> %6, <2 x i32> <i32 poison, i32 0>, <2 x i32> <i32 0, i32 3>\n %8 = icmp ugt <2 x i32> %7, <i32 33554431, i32 0>\n %9 = call <8 x i1> @llvm.vector.insert.v8i1.v2i1(<8 x i1> <i1 poison, i1 poison, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false>, <2 x i1> %8, i64 0)\n %10 = select <8 x i1> %9, <8 x i8> zeroinitializer, <8 x i8> <i8 6, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0>\n %11 = shl <8 x i8> %4, %10\n %12 = call i8 @llvm.vector.reduce.and.v8i8(<8 x i8> %11)\n %conv = zext i8 %12 to i32\n %call1 = call i32 (ptr, ...) @printf(ptr @.str, i32 %conv)\n ret i32 0\n}\n\ndeclare i32 @printf(ptr, ...)\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <8 x i1> @llvm.vector.insert.v8i1.v2i1(<8 x i1>, <2 x i1>, i64 immarg) #0\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i8 @llvm.vector.reduce.and.v8i8(<8 x i8>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n```\nllubi output:\nBefore SLP:\n```\nEntering function main\n store i32 152, ptr @f, align 4\n %agg.tmp.sroa.0.0.copyload.i = load i32, ptr @f, align 4 -> i32 152\n %add.i.i = shl i32 %agg.tmp.sroa.0.0.copyload.i, 24 -> i32 -1744830464\n %sext.i = add i32 %add.i.i, 83886080 -> i32 -1660944384\n %conv2.i = ashr i32 %sext.i, 24 -> i32 -99\n %and.i = and i32 %conv2.i, 66440127 -> i32 66440093\n %cmp3.i.i = icmp ugt i32 %and.i, 33554431 -> T\n %shl.i.i = select i1 %cmp3.i.i, i32 0, i32 6 -> i32 0\n %cond.i.i = shl i32 %and.i, %shl.i.i -> i32 66440093\n %0 = trunc i32 %cond.i.i to i8 -> i8 -99\n %sext.1.i = add i32 0, 83886080 -> i32 83886080\n %conv2.1.i = ashr i32 %sext.1.i, 24 -> i32 5\n %and.1.i = and i32 %conv2.1.i, 1 -> i32 1\n %cmp3.i.1.i = icmp ugt i32 0, 0 -> F\n %shl.i.1.i = select i1 %cmp3.i.1.i, i32 0, i32 0 -> i32 0\n %cond.i.1.i = shl i32 %and.1.i, %shl.i.1.i -> i32 1\n %1 = trunc i32 %cond.i.1.i to i8 -> i8 1\n %conv17.1.i = and i8 %0, %1 -> i8 1\n %sext.2.i = add i32 0, 83886080 -> i32 83886080\n %conv2.2.i = ashr i32 %sext.2.i, 24 -> i32 5\n %and.2.i = and i32 %conv2.2.i, 1 -> i32 1\n %shl.i.2.i = select i1 false, i32 0, i32 0 -> i32 0\n %cond.i.2.i = shl i32 %and.2.i, %shl.i.2.i -> i32 1\n %2 = trunc i32 %cond.i.2.i to i8 -> i8 1\n %conv17.2.i = and i8 %conv17.1.i, %2 -> i8 1\n %sext.3.i = add i32 0, 83886080 -> i32 83886080\n %conv2.3.i = ashr i32 %sext.3.i, 24 -> i32 5\n %and.3.i = and i32 %conv2.3.i, 1 -> i32 1\n %shl.i.3.i = select i1 false, i32 0, i32 0 -> i32 0\n %cond.i.3.i = shl i32 %and.3.i, %shl.i.3.i -> i32 1\n %3 = trunc i32 %cond.i.3.i to i8 -> i8 1\n %conv17.3.i = and i8 %conv17.2.i, %3 -> i8 1\n %sext.4.i = add i32 0, 83886080 -> i32 83886080\n %conv2.4.i = ashr i32 %sext.4.i, 24 -> i32 5\n %and.4.i = and i32 %conv2.4.i, 1 -> i32 1\n %shl.i.4.i = select i1 false, i32 0, i32 0 -> i32 0\n %cond.i.4.i = shl i32 %and.4.i, %shl.i.4.i -> i32 1\n %4 = trunc i32 %cond.i.4.i to i8 -> i8 1\n %conv17.4.i = and i8 %conv17.3.i, %4 -> i8 1\n %sext.5.i = add i32 0, 83886080 -> i32 83886080\n %conv2.5.i = ashr i32 %sext.5.i, 24 -> i32 5\n %and.5.i = and i32 %conv2.5.i, 1 -> i32 1\n %shl.i.5.i = select i1 false, i32 0, i32 0 -> i32 0\n %cond.i.5.i = shl i32 %and.5.i, %shl.i.5.i -> i32 1\n %5 = trunc i32 %cond.i.5.i to i8 -> i8 1\n %conv17.5.i = and i8 %conv17.4.i, %5 -> i8 1\n %sext.6.i = add i32 0, 83886080 -> i32 83886080\n %conv2.6.i = ashr i32 %sext.6.i, 24 -> i32 5\n %and.6.i = and i32 %conv2.6.i, 1 -> i32 1\n %shl.i.6.i = select i1 false, i32 0, i32 0 -> i32 0\n %cond.i.6.i = shl i32 %and.6.i, %shl.i.6.i -> i32 1\n %6 = trunc i32 %cond.i.6.i to i8 -> i8 1\n %conv17.6.i = and i8 %conv17.5.i, %6 -> i8 1\n %sext.7.i = add i32 0, 83886080 -> i32 83886080\n %conv2.7.i = ashr i32 %sext.7.i, 24 -> i32 5\n %and.7.i = and i32 %conv2.7.i, 1 -> i32 1\n %shl.i.7.i = select i1 false, i32 0, i32 0 -> i32 0\n %cond.i.7.i = shl i32 %and.7.i, %shl.i.7.i -> i32 1\n %7 = trunc i32 %cond.i.7.i to i8 -> i8 1\n %conv17.7.i = and i8 %conv17.6.i, %7 -> i8 1\n %conv = zext i8 %conv17.7.i to i32 -> i32 1\n %call1 = call i32 (ptr, ...) @printf(ptr @.str, i32 %conv)\n Printf: 1\n -> i32 2\n ret i32 0\nExiting function main\n```\nAfter SLP:\n```\nEntering function main\n store i32 152, ptr @f, align 4\n %agg.tmp.sroa.0.0.copyload.i = load i32, ptr @f, align 4 -> i32 152\n %add.i.i = shl i32 %agg.tmp.sroa.0.0.copyload.i, 24 -> i32 -1744830464\n %0 = insertelement <8 x i32> <i32 poison, i32 83886080, i32 83886080, i32 83886080, i32 83886080, i32 83886080, i32 83886080, i32 83886080>, i32 %add.i.i, i32 0 -> { i32 -1744830464, i32 83886080, i32 83886080, i32 83886080, i32 83886080, i32 83886080, i32 83886080, i32 83886080 }\n %1 = add <8 x i32> <i32 83886080, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>, %0 -> { i32 -1660944384, i32 83886080, i32 83886080, i32 83886080, i32 83886080, i32 83886080, i32 83886080, i32 83886080 }\n %2 = ashr <8 x i32> %1, splat (i32 24) -> { i32 -99, i32 5, i32 5, i32 5, i32 5, i32 5, i32 5, i32 5 }\n %3 = trunc <8 x i32> %2 to <8 x i8> -> { i8 -99, i8 5, i8 5, i8 5, i8 5, i8 5, i8 5, i8 5 }\n %4 = and <8 x i8> %3, <i8 -65, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1> -> { i8 -99, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1 }\n %5 = zext <8 x i8> %4 to <8 x i32> -> { i32 157, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1 }\n %6 = shufflevector <8 x i32> %5, <8 x i32> poison, <2 x i32> <i32 0, i32 poison> -> { i32 157, poison }\n %7 = shufflevector <2 x i32> %6, <2 x i32> <i32 poison, i32 0>, <2 x i32> <i32 0, i32 3> -> { i32 157, i32 0 }\n %8 = icmp ugt <2 x i32> %7, <i32 33554431, i32 0> -> { F, F }\n %9 = call <8 x i1> @llvm.vector.insert.v8i1.v2i1(<8 x i1> <i1 poison, i1 poison, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false>, <2 x i1> %8, i64 0) -> { F, F, F, F, F, F, F, F }\n %10 = select <8 x i1> %9, <8 x i8> zeroinitializer, <8 x i8> <i8 6, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0> -> { i8 6, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0 }\n %11 = shl <8 x i8> %4, %10 -> { i8 64, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1 }\n %12 = call i8 @llvm.vector.reduce.and.v8i8(<8 x i8> %11) -> i8 0\n %conv = zext i8 %12 to i32 -> i32 0\n %call1 = call i32 (ptr, ...) @printf(ptr @.str, i32 %conv)\n Printf: 0\n -> i32 2\n ret i32 0\nExiting function main\n```\nllvm version: a88f4f1962b47aa8db49b8687a7f8b9097a3d13b\n\nC reproducer:\n```\n#include \"csmith.h\"\nstruct d {\n uint8_t a;\n uint16_t b\n} f;\nstatic uint64_t c[] = {66440127};\nuint64_t e;\nuint8_t h = 5;\nuint32_t g(uint8_t, struct d);\nint32_t j() {\n int16_t i = 10;\n struct d k = {152};\n for (e = 0; e < 22; ++e) {\n int32_t l[0];\n struct d *m = &f;\n h &= safe_lshift_func_int32_t_s_u(\n safe_add_func_int8_t_s_s(g(0, *m = k), 5) & c[0],\n safe_add_func_int16_t_s_s(6, (k.a > k.b) < l));\n }\n return i;\n}\nuint32_t g(uint8_t, struct d n) { return n.a; }\nint main() {\n j();\n printf(\"%d\\n\", h);\n}\n```\n```\n> gcc -w -I/usr/include/csmith -fsanitize=address,undefined test.c && ./a.out\n5\n> bin/clang -w -I/usr/include/csmith -O3 test.c && ./a.out\n0\n```\n",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:SLPVectorizer"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
150338
|
https://github.com/llvm/llvm-project/issues/150338
|
crash
|
98562ffaaa74ebebfcfaf42f6604c736637e0d46
| 2025-07-23T22:50:28 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "be6bed4dc6e346d316a910ee7cb742ece791d855",
"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": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": [
[
1502,
1509
]
],
"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": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": [
"InstCombinerImpl::visitStoreInst"
],
"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 be6bed4dc6e346d316a910ee7cb742ece791d855
Author: Nikita Popov <npopov@redhat.com>
Date: Thu Jul 24 11:07:01 2025 +0200
[InstCombine] Remove instructions before+after unreachable at same time
There is no need to first remove the instructions before and then
the ones after in two different worklist iterations. We don't need
to worry about change reporting here, as the functions do that
themselves.
This avoids the issue in #150338, but not really in a principled
way. It's possible that we will have to allow poison arguments
to lifetime.start/lifetime.end again if this turns out to be a
recurring problem.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
index 365a9b3aafc9..0be1034b046b 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
@@ -1502,8 +1502,7 @@ Instruction *InstCombinerImpl::visitStoreInst(StoreInst &SI) {
// This is a non-terminator unreachable marker. Don't remove it.
if (isa<UndefValue>(Ptr)) {
// Remove guaranteed-to-transfer instructions before the marker.
- if (removeInstructionsBeforeUnreachable(SI))
- return &SI;
+ removeInstructionsBeforeUnreachable(SI);
// Remove all instructions after the marker and handle dead blocks this
// implies.
|
[
{
"file": "llvm/test/Transforms/InstCombine/pr150338.ll",
"commands": [
"opt -S -passes=instcombine < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n; Make sure this does not crash.\ndefine void @test(ptr %arg) {\n;\n %a = alloca i32\n store ptr %a, ptr %arg\n store i1 true, ptr poison\n call void @llvm.lifetime.end.p0(i64 4, ptr %a)\n ret void\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "clang crashes on valid code at -O1 and above on x86_64-linux-gnu: Assertion `hasUseList()' failed",
"body": "It appears to be a recent regression as it doesn't reproduce with the latest Compiler Explorer build. \n\n```\n[515] % clangtk -v\nclang version 22.0.0git (https://github.com/llvm/llvm-project.git 71c06d7a5f99ef7039b024d75cbdcddd71872602)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /local/home/suz/suz-local/software/local/clang-trunk/bin\nBuild config: +assertions\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12\nCandidate multilib: .;@m64\nSelected multilib: .;@m64\nFound CUDA installation: /usr/local/cuda, version 12.1\n[516] % \n[516] % clangtk -O1 small.c\nclang-22: /local/suz-local/software/clangbuild/llvm-project/llvm/include/llvm/IR/Value.h:357: llvm::Value::use_iterator llvm::Value::materialized_use_begin(): Assertion `hasUseList()' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\nStack dump:\n0.\tProgram arguments: /local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22 -cc1 -triple x86_64-unknown-linux-gnu -O1 -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/20250723-clangtk-m64-O3-build-232105/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20250723-clangtk-m64-O3-build-232105/delta -resource-dir /local/home/suz/suz-local/software/local/clang-trunk/lib/clang/22 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/home/suz/suz-local/software/local/clang-trunk/lib/clang/22/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -ferror-limit 19 -fmessage-length=100 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-7ab6d0.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<interleave-forced-only;vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O1>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"small.c\"\n4.\tRunning pass \"instcombine<max-iterations=1;no-verify-fixpoint>\" on function \"e\"\n #0 0x00005623f4e4ecd0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4215cd0)\n #1 0x00005623f4e4b97f llvm::sys::RunSignalHandlers() (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x421297f)\n #2 0x00005623f4e4bad2 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #3 0x00007fc314aa6520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #4 0x00007fc314afa9fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #5 0x00007fc314afa9fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #6 0x00007fc314afa9fc pthread_kill ./nptl/pthread_kill.c:89:10\n #7 0x00007fc314aa6476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x00007fc314a8c7f3 abort ./stdlib/abort.c:81:7\n #9 0x00007fc314a8c71b _nl_load_domain ./intl/loadmsgcat.c:1177:9\n#10 0x00007fc314a9de96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n#11 0x00005623f3d3b209 (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3102209)\n#12 0x00005623f4f40361 llvm::wouldInstructionBeTriviallyDead(llvm::Instruction const*, llvm::TargetLibraryInfo const*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4307361)\n#13 0x00005623f498607b llvm::InstCombinerImpl::run() (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3d4d07b)\n#14 0x00005623f4987e0a 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&) InstructionCombining.cpp:0:0\n#15 0x00005623f49891e0 llvm::InstCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3d501e0)\n#16 0x00005623f50eb566 llvm::detail::PassModel<llvm::Function, llvm::InstCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x44b2566)\n#17 0x00005623f47a67d7 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3b6d7d7)\n#18 0x00005623f1f212e6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x12e82e6)\n#19 0x00005623f47a6d49 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3b6dd49)\n#20 0x00005623f1f219d6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x12e89d6)\n#21 0x00005623f47a4af4 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3b6baf4)\n#22 0x00005623f50fa503 (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 0x00005623f50feaf3 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x44c5af3)\n#24 0x00005623f57f035f clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4bb735f)\n#25 0x00005623f72391fc clang::ParseAST(clang::Sema&, bool, bool) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x66001fc)\n#26 0x00005623f5b0c1f9 clang::FrontendAction::Execute() (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4ed31f9)\n#27 0x00005623f5a87ed5 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4e4eed5)\n#28 0x00005623f5bfc5b8 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4fc35b8)\n#29 0x00005623f1aa5403 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xe6c403)\n#30 0x00005623f1a9b9ba ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#31 0x00005623f1aa0470 clang_main(int, char**, llvm::ToolContext const&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xe67470)\n#32 0x00005623f196d89b main (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xd3489b)\n#33 0x00007fc314a8dd90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\n#34 0x00007fc314a8de40 call_init ./csu/../csu/libc-start.c:128:20\n#35 0x00007fc314a8de40 __libc_start_main ./csu/../csu/libc-start.c:379:5\n#36 0x00005623f1a9b0e5 _start (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xe620e5)\nclangtk: error: unable to execute command: Aborted\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\nclang version 22.0.0git (https://github.com/llvm/llvm-project.git 71c06d7a5f99ef7039b024d75cbdcddd71872602)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /local/home/suz/suz-local/software/local/clang-trunk/bin\nBuild config: +assertions\nclangtk: note: diagnostic msg: \n********************\n\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\nPreprocessed source(s) and associated run script(s) are located at:\nclangtk: note: diagnostic msg: /tmp/small-db824a.c\nclangtk: note: diagnostic msg: /tmp/small-db824a.sh\nclangtk: note: diagnostic msg: \n\n********************\n[517] % \n[517] % cat small.c\nint a, c, d;\nstatic int *b;\nint *e(int **f) {\n int g, *h = &g;\n d = *b;\n if (a)\n e(&h);\n return *f;\n}\nint main() {\n c = a - (a & 744049087);\n if (c > 1818615278) {\n int i, **j = &b;\n *j = &i;\n }\n return 0;\n}\n```",
"author": "zhendongsu",
"labels": [
"regression",
"crash",
"llvm:instcombine"
],
"comments": [
{
"author": "nikic",
"body": "Reduced:\n```llvm\ndefine void @test(ptr %arg) {\n %a = alloca i32\n store ptr %a, ptr %arg\n store i1 true, ptr poison\n call void @llvm.lifetime.end.p0(i64 4, ptr %a)\n ret void\n}\n```"
},
{
"author": "nikic",
"body": "Fixed in https://github.com/llvm/llvm-project/commit/be6bed4dc6e346d316a910ee7cb742ece791d855. But if we encounter more variants of this, we'll need to allow poison in lifetime.start/end."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
87856
|
https://github.com/llvm/llvm-project/issues/87856
|
crash
|
b17d44558ba4c30a3005089b334f68593d6a9c7c
| 2024-04-06T02:19:05 |
[
"llvm/test/Transforms/Attributor"
] |
{
"fix_commit": "2d61692d4b75b7d92b44bfafb1011c1723955151",
"components": [
"Attributor"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
5899,
5908
]
],
"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": 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": [
"AANoCaptureImpl::updateImpl"
],
"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 2d61692d4b75b7d92b44bfafb1011c1723955151
Author: Matt Arsenault <Matthew.Arsenault@amd.com>
Date: Thu May 23 19:31:33 2024 +0200
Attributor: Do not assume function context in AANoCapture (#91462)
If the calling function has the null_pointer_is_valid attribute, somehow
a null constant reaches here. I'm not sure why exactly, it doesn't
happen for other types of constants.
Fixes #87856
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 41b66aafe7d3..1b3bf3c732ed 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -5690,6 +5690,9 @@ bool AANoCapture::isImpliedByIR(Attributor &A, const IRPosition &IRP,
return V.use_empty();
// You cannot "capture" null in the default address space.
+ //
+ // FIXME: This should use NullPointerIsDefined to account for the function
+ // attribute.
if (isa<UndefValue>(V) || (isa<ConstantPointerNull>(V) &&
V.getType()->getPointerAddressSpace() == 0)) {
return true;
@@ -5899,10 +5902,13 @@ ChangeStatus AANoCaptureImpl::updateImpl(Attributor &A) {
const Function *F =
isArgumentPosition() ? IRP.getAssociatedFunction() : IRP.getAnchorScope();
- assert(F && "Expected a function!");
- const IRPosition &FnPos = IRPosition::function(*F);
+
+ // TODO: Is the checkForAllUses below useful for constants?
+ if (!F)
+ return indicatePessimisticFixpoint();
AANoCapture::StateType T;
+ const IRPosition &FnPos = IRPosition::function(*F);
// Readonly means we cannot capture through memory.
bool IsKnown;
|
[
{
"file": "llvm/test/Transforms/Attributor/issue87856.ll",
"commands": [
"opt -S -passes=attributor < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @null_ptr_is_valid_call_with_null() #0 {\n;\n call void @store_as0(ptr null)\n ret void\n}\n\ndefine void @null_ptr_is_valid_call_with_undef() #0 {\n;\n call void @store_as0(ptr undef)\n ret void\n}\n\ndefine void @store_as0(ptr %0) {\n;\n store i16 0, ptr %0, align 2\n ret void\n}\n\ndefine void @call_store_as1() {\n;\n call void @store_as1(ptr addrspace(1) null)\n ret void\n}\n\ndefine void @store_as1(ptr addrspace(1) %arg) {\n;\n store i16 0, ptr addrspace(1) %arg, align 2\n ret void\n}\n\nattributes #0 = { null_pointer_is_valid }\n;.\n;.",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[attributor] Crash on `null_pointer_is_valid` function",
"body": "With\r\n\r\n```\r\ntarget datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"aarch64-none-linux-android28\"\r\n\r\n; Function Attrs: null_pointer_is_valid\r\ndefine i64 @foo() #0 {\r\n call fastcc void @bar(ptr null)\r\n ret i64 0\r\n}\r\n\r\ndefine fastcc void @bar(ptr %0) {\r\n store i16 0, ptr %0, align 2\r\n ret void\r\n}\r\n\r\nattributes #0 = { null_pointer_is_valid }\r\n```\r\n\r\nand running\r\n\r\n```\r\nopt -passes=attributor file.ll\r\n```\r\n\r\nwe crash with\r\n\r\n```\r\nopt: llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp:5901: virtual ChangeStatus (anonymous namespace)::AANoCaptureImpl::updateImpl(Attributor &): Assertion `F && \"Expected a function!\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: opt -passes=attributor reduced.ll\r\n #0 0x000000000165bf38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (llvm-project/build/Release/bin/opt+0x165bf38)\r\n #1 0x0000000001659a40 llvm::sys::RunSignalHandlers() (llvm-project/build/Release/bin/opt+0x1659a40)\r\n #2 0x000000000165c938 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007f3ec923e6f0 __restore_rt (/lib64/libc.so.6+0x3e6f0)\r\n #4 0x00007f3ec928b94c __pthread_kill_implementation (/lib64/libc.so.6+0x8b94c)\r\n #5 0x00007f3ec923e646 gsignal (/lib64/libc.so.6+0x3e646)\r\n #6 0x00007f3ec92287f3 abort (/lib64/libc.so.6+0x287f3)\r\n #7 0x00007f3ec922871b _nl_load_domain.cold (/lib64/libc.so.6+0x2871b)\r\n #8 0x00007f3ec9237386 (/lib64/libc.so.6+0x37386)\r\n #9 0x0000000002f2a65b (anonymous namespace)::AANoCaptureImpl::updateImpl(llvm::Attributor&) AttributorAttributes.cpp:0:0\r\n#10 0x0000000002ec8492 llvm::AbstractAttribute::update(llvm::Attributor&) (llvm-project/build/Release/bin/opt+0x2ec8492)\r\n#11 0x0000000002ed3b83 llvm::Attributor::updateAA(llvm::AbstractAttribute&) (llvm-project/build/Release/bin/opt+0x2ed3b83)\r\n#12 0x0000000002eec289 llvm::AANoCapture const* llvm::Attributor::getOrCreateAAFor<llvm::AANoCapture>(llvm::IRPosition, llvm::AbstractAttribute const*, llvm::DepClassTy, bool, bool) Attributor.cpp:0:0\r\n#13 0x0000000002f1ab57 (anonymous namespace)::AANoAliasCallSiteArgument::updateImpl(llvm::Attributor&) AttributorAttributes.cpp:0:0\r\n#14 0x0000000002ec8492 llvm::AbstractAttribute::update(llvm::Attributor&) (llvm-project/build/Release/bin/opt+0x2ec8492)\r\n#15 0x0000000002ed3b83 llvm::Attributor::updateAA(llvm::AbstractAttribute&) (llvm-project/build/Release/bin/opt+0x2ed3b83)\r\n#16 0x0000000002efba19 llvm::AANoAlias const* llvm::Attributor::getOrCreateAAFor<llvm::AANoAlias>(llvm::IRPosition, llvm::AbstractAttribute const*, llvm::DepClassTy, bool, bool) Attributor.cpp:0:0\r\n#17 0x0000000002ede880 void llvm::Attributor::checkAndQueryIRAttr<(llvm::Attribute::AttrKind)20, llvm::AANoAlias>(llvm::IRPosition const&, llvm::AttributeSet) (llvm-project/build/Release/bin/opt+0x2ede880)\r\n#18 0x0000000002edd545 llvm::Attributor::identifyDefaultAbstractAttributes(llvm::Function&) (llvm-project/build/Release/bin/opt+0x2edd545)\r\n#19 0x0000000002ee0800 runAttributorOnFunctions(llvm::InformationCache&, llvm::SetVector<llvm::Function*, llvm::SmallVector<llvm::Function*, 0u>, llvm::DenseSet<llvm::Function*, llvm::DenseMapInfo<llvm::Function*, void>>, 0u>&, llvm::AnalysisGetter&, llvm::CallGraphUpdater&, bool, bool) Attributor.cpp:0:0\r\n#20 0x0000000002edfc41 llvm::AttributorPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (llvm-project/build/Release/bin/opt+0x2edfc41)\r\n#21 0x0000000002b6fcdd llvm::detail::PassModel<llvm::Module, llvm::AttributorPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) PassBuilderPipelines.cpp:0:0\r\n#22 0x0000000001853e56 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (llvm-project/build/Release/bin/opt+0x1853e56)\r\n#23 0x0000000002afaa4b llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (llvm-project/build/Release/bin/opt+0x2afaa4b)\r\n#24 0x0000000001622f36 optMain (llvm-project/build/Release/bin/opt+0x1622f36)\r\n```",
"author": "lanza",
"labels": [
"crash-on-valid",
"llvm::Attributor"
],
"comments": [
{
"author": "lanza",
"body": "https://github.com/llvm/llvm-project/blob/0f52f4ddd909eb38f2a691ffed8469263fe5f635/llvm/lib/Transforms/IPO/AttributorAttributes.cpp#L5901"
},
{
"author": "dtcxzyw",
"body": "cc @arsenm "
},
{
"author": "arsenm",
"body": "Just returning on the null function seems to work, but I don't understand exactly why it reaches here. AANoCapture::isImpliedByIR is incorrectly reimplementing NullPointerIsDefined but fixing that doesn't seem to help any "
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
95547
|
https://github.com/llvm/llvm-project/issues/95547
|
miscompilation
|
7767f0d47428db66d65b07b35aa52f0507df71f9
| 2024-06-14T13:54:00 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "534f8569a3c9fccfd5cbc5f632b63ad0cf711098",
"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": [
[
291,
300
]
],
"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": 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": [
"canEvaluateTruncated"
],
"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 534f8569a3c9fccfd5cbc5f632b63ad0cf711098
Author: Nikita Popov <npopov@redhat.com>
Date: Mon Jun 17 15:36:55 2024 +0200
[InstCombine] Don't preserve context across div
We can't preserve the context across a non-speculatable instruction,
as this might introduce a trap. Alternatively, we could also
insert all the replacement instruction at the use-site, but that
would be a more intrusive change for the sake of this edge case.
Fixes https://github.com/llvm/llvm-project/issues/95547.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index 1b4c319032ca..6a6bdba3fa70 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -291,10 +291,12 @@ static bool canEvaluateTruncated(Value *V, Type *Ty, InstCombinerImpl &IC,
uint32_t BitWidth = Ty->getScalarSizeInBits();
assert(BitWidth < OrigBitWidth && "Unexpected bitwidths!");
APInt Mask = APInt::getBitsSetFrom(OrigBitWidth, BitWidth);
- if (IC.MaskedValueIsZero(I->getOperand(0), Mask, 0, CxtI) &&
- IC.MaskedValueIsZero(I->getOperand(1), Mask, 0, CxtI)) {
- return canEvaluateTruncated(I->getOperand(0), Ty, IC, CxtI) &&
- canEvaluateTruncated(I->getOperand(1), Ty, IC, CxtI);
+ // Do not preserve the original context instruction. Simplifying div/rem
+ // based on later context may introduce a trap.
+ if (IC.MaskedValueIsZero(I->getOperand(0), Mask, 0, I) &&
+ IC.MaskedValueIsZero(I->getOperand(1), Mask, 0, I)) {
+ return canEvaluateTruncated(I->getOperand(0), Ty, IC, I) &&
+ canEvaluateTruncated(I->getOperand(1), Ty, IC, I);
}
break;
}
|
[
{
"file": "llvm/test/Transforms/InstCombine/trunc.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "trunc_nuw_xor_vector",
"test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64\"\n\ndefine <2 x i1> @trunc_nuw_xor_vector(<2 x i8> %x, <2 x i8> %y) {\n %xor = xor <2 x i8> %x, %y\n %r = trunc nuw <2 x i8> %xor to <2 x i1>\n ret <2 x i1> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "pr95547",
"test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64\"\n\ndeclare void @use.i8(i8)\n\ndefine void @pr95547(i32 %x) {\n %x.trunc = trunc i32 %x to i16\n %div = udiv i16 11, %x.trunc\n %cmp = icmp ult i32 %x, 256\n br i1 %cmp, label %loop, label %exit\n\nloop: ; preds = %loop, %0\n %trunc = trunc i16 %div to i8\n call void @use.i8(i8 %trunc)\n br label %loop\n\nexit: ; preds = %0\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstCombine] Wrong value truncation due to incorrect analysis of iv known bits",
"body": "```llvm\r\ndefine void @src(i32 %0, ptr %p, i1 %cnd) {\r\nentry:\r\n br i1 %cnd, label %header, label %exit\r\n\r\nheader: ; preds = %latch, %entry\r\n %iv = phi i32 [ %iv.next, %latch ], [ 256, %entry ]\r\n %iv.trunc = trunc i32 %iv to i16\r\n %div = udiv i16 11, %iv.trunc\r\n br i1 %cnd, label %loop1, label %loop0\r\n\r\nloop0: ; preds = %header\r\n %load = load i32, ptr %p, align 4\r\n br label %loop1\r\n\r\nloop1: ; preds = %loop0, %header\r\n %v = phi i32 [ %load, %loop0 ], [ 0, %header ]\r\n store i32 %v, ptr %p, align 4\r\n %guard = icmp ugt i32 %iv, 10\r\n br i1 %guard, label %latch, label %loop2\r\n\r\nloop2: ; preds = %loop1\r\n %div.trunc = trunc i16 %div to i8\r\n store i8 %div.trunc, ptr %p, align 1\r\n br label %latch\r\n\r\nlatch: ; preds = %loop2, %loop1\r\n %iv.next = add nuw nsw i32 %iv, 1\r\n %exitcond = icmp ugt i32 %iv, 300\r\n br i1 %exitcond, label %exit, label %header\r\n\r\nexit: ; preds = %latch\r\n ret void\r\n}\r\n```\r\nIf we run `instcombine` pass on this example, it will convert `trunc i32 %iv to i16` into `trunc i32 %iv to i8` to avoid cast:\r\nhttps://godbolt.org/z/ze4E45ThT\r\n\r\nBut this transformation is wrong, because on the first iteration `%iv` is equal to 256, and the 8 bits trunc makes it equal to `0`. This give us a division by zero on the next instruction: `%div = udiv i16 11, %iv.trunc`.\r\n\r\nIt seems that the problematic patch is https://github.com/llvm/llvm-project/pull/73662\r\n\r\n@nikic Could you please take a look?",
"author": "aleks-tmb",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": [
{
"author": "antoniofrighetto",
"body": "May be false positive in Alive2 as well?"
},
{
"author": "dtcxzyw",
"body": "> May be false positive in Alive2 as well?\r\n\r\nYou need `-src-unroll` and `-tgt-unroll` for loops :)\r\nhttps://alive2.llvm.org/ce/z/Vh4zAU"
},
{
"author": "antoniofrighetto",
"body": "Just out of curiosity, did you fine-tune the iterations in a particular way, or some trial-and-error? (I had tried a few ones before and didn’t manage to have the UB triggered)"
},
{
"author": "dtcxzyw",
"body": "> Just out of curiosity, did you fine-tune the iterations in a particular way, or some trial-and-error? (I had tried a few ones before and didn’t manage to have the UB triggered)\r\n\r\nI just full unrolled the loop :)\r\n```\r\n%iv.next = add nuw nsw i32 %iv, 1\r\n%exitcond = icmp ugt i32 %iv, 300\r\n```"
},
{
"author": "antoniofrighetto",
"body": "> I just full unrolled the loop :)\r\n\r\nDefinitely makes sense, thanks!"
},
{
"author": "nikic",
"body": "Reduced test case:\r\n```llvm\r\ndefine void @src(i32 %x) {\r\n %x.trunc = trunc i32 %x to i16\r\n %div = udiv i16 11, %x.trunc\r\n %cmp = icmp ult i32 %x, 256\r\n br i1 %cmp, label %loop, label %exit\r\n\r\nloop:\r\n %trunc = trunc i16 %div to i8\r\n call void @use(i8 %trunc)\r\n br label %loop\r\n\r\nexit:\r\n ret void\r\n}\r\n\r\ndeclare void @use(i8)\r\n```\r\n\r\nThe issue is that canEvaluateTruncated() preserves context instruction across non-speculatable operations."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
106780
|
https://github.com/llvm/llvm-project/issues/106780
|
crash
|
5aa83eb677d2f8cba0c2ad3dcc14f3f4e80a0bba
| 2024-08-30T19:02:15 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "654bb4e9f287f9ccb5142d1c62a9ab17c16e29d7",
"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": [
[
6817,
6822
]
],
"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 654bb4e9f287f9ccb5142d1c62a9ab17c16e29d7
Author: Florian Hahn <flo@fhahn.com>
Date: Sun Sep 1 20:35:28 2024 +0100
[LV] Don't consider branches leaving loop in collectValuesToIgnore.
Branches exiting the loop will remain regardless, so don't consider them
in collectValuesToIgnore.
This fixes another divergence between legacy and VPlan-based cost model.
Fixes https://github.com/llvm/llvm-project/issues/106780.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index fa05b8dd2242..a8722db654f5 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -6817,6 +6817,9 @@ void LoopVectorizationCostModel::collectValuesToIgnore() {
if (auto *Br = dyn_cast_or_null<BranchInst>(Op)) {
BasicBlock *ThenBB = Br->getSuccessor(0);
BasicBlock *ElseBB = Br->getSuccessor(1);
+ // Don't considers branches leaving the loop for simplification.
+ if (!TheLoop->contains(ThenBB) || !TheLoop->contains(ElseBB))
+ continue;
bool ThenEmpty = IsEmptyBlock(ThenBB);
bool ElseEmpty = IsEmptyBlock(ElseBB);
if ((ThenEmpty && ElseEmpty) ||
|
[
{
"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": "dead_load",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine void @dead_load(ptr %p, i16 %start) {\nentry:\n %start.ext = sext i16 %start to i64\n br label %loop\n\nloop: ; preds = %loop, %entry\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: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "cost_of_exit_branch_and_cond_insts",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i16 @llvm.umax.i16(i16, i16) #0\n\ndefine i32 @cost_of_exit_branch_and_cond_insts(ptr %a, ptr %b, i1 %c, i16 %x) {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]\n br i1 %c, label %then, label %loop.exiting\n\nthen: ; preds = %loop.header\n %gep = getelementptr inbounds i32, ptr %b, i32 %iv\n store i1 false, ptr %a, align 1\n store i32 0, ptr %gep, align 4\n br label %loop.exiting\n\nloop.exiting: ; preds = %then, %loop.header\n %iv.next = add i32 %iv, 1\n %umax = tail call i16 @llvm.umax.i16(i16 %x, i16 111)\n %umax.ext = zext i16 %umax to i32\n %sub = sub i32 770, %umax.ext\n %ec = icmp slt i32 %iv, %sub\n br i1 %ec, label %loop.latch, label %exit\n\nloop.latch: ; preds = %loop.exiting\n br label %loop.header\n\nexit: ; preds = %loop.exiting\n br label %return\n\nreturn: ; preds = %exit\n ret i32 0\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "dead_live_out_due_to_scalar_epilogue_required",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine i8 @dead_live_out_due_to_scalar_epilogue_required(ptr %src, ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %idxprom = sext i32 %iv to i64\n %gep.src = getelementptr i8, ptr %src, i64 %idxprom\n %l = load i8, ptr %gep.src, align 1\n %gep.dst = getelementptr i8, ptr %dst, i64 %idxprom\n store i8 0, ptr %gep.dst, align 1\n %iv.next = add i32 %iv, 4\n %cmp = icmp ult i32 %iv, 1001\n br i1 %cmp, label %loop, label %exit\n\nexit: ; preds = %loop\n %r = phi i8 [ %l, %loop ]\n ret i8 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[VPlan] Assertion \" VPlan cost model and legacy cost model disagreed\"' failed.",
"body": "Tested using ef7b18a53c0d186dcda1e322be6035407fdedb55\r\n\r\nTestcase:\r\n```c\r\nunsigned short a;\r\nextern int b;\r\nvoid c(_Bool d, int e, long long f[], unsigned short g[][16],\r\n unsigned short h[][16], unsigned short i[][13], short j[][13],\r\n int k[][21], unsigned char l[][21][21], signed char m[][24]) {\r\n for (short n = 0; n < 5; n += -5532)\r\n for (char o = 0; o < 3; o += d)\r\n for (int p = 0; p < -({ g[d][1] > 0115 ? g[d][1] : 0115; }) + 770; p++)\r\n for (_Bool q = 0; q < (_Bool)e; q = 5)\r\n for (_Bool r = 2048749519 ? 8 ? f[d] : 0 : 0; r < 1; r = h)\r\n b = a = 0;\r\n}\r\nvoid hash();\r\nunsigned short a = 6;\r\nlong long f[6];\r\nunsigned short g[6][16];\r\nunsigned short h[1][16];\r\nunsigned short i[1][13];\r\nshort j[1][13];\r\nint k[1][21];\r\nunsigned char l[1][21][21];\r\nsigned char m[1][24];\r\nint main() {\r\n for (long s = 0; s < 6; ++s)\r\n f[s] = 6;\r\n for (long s = 0; s < 16; ++s)\r\n for (long n = 0; n < 16; ++n)\r\n g[s][n] = 7;\r\n c(1, 407418382874, f, g, h, i, j, k, l, m);\r\n hash(a);\r\n}\r\n```\r\nc command:\r\n```\r\n/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/clang -fno-strict-aliasing -march=rv64gcv -flto -O3 -fuse-ld=lld red.c -o rv64gcv.out -w\r\n```\r\n\r\nLLVM IR testcase:\r\n```llvm ir\r\n; ModuleID = 'reduced.bc'\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\r\ndeclare i16 @llvm.umax.i16(i16, i16) #0\r\n\r\ndefine i32 @main(ptr %a) #1 {\r\nentry:\r\n br label %for.cond22.preheader.us.us76.us.us.us.us.i.1\r\n\r\nfor.cond22.preheader.us.us76.us.us.us.us.i.1: ; preds = %for.cond22.preheader.us.us76.us.us.us.usthread-pre-split.i.1, %entry\r\n %p.072.us.us77.us.us.us.us.i.1 = phi i32 [ %inc.us.us80.us.us.us.us.i.1, %for.cond22.preheader.us.us76.us.us.us.usthread-pre-split.i.1 ], [ 0, %entry ]\r\n br i1 false, label %for.body41.lr.ph.us.us.us.us.us.us.us.i.1, label %for.cond22.for.cond.cleanup28_crit_edge.us.us.us.us.us.us.i.1\r\n\r\nfor.body41.lr.ph.us.us.us.us.us.us.us.i.1: ; preds = %for.cond22.preheader.us.us76.us.us.us.us.i.1\r\n store i1 false, ptr %a, align 1\r\n store i32 0, ptr null, align 4\r\n br label %for.cond22.for.cond.cleanup28_crit_edge.us.us.us.us.us.us.i.1\r\n\r\nfor.cond22.for.cond.cleanup28_crit_edge.us.us.us.us.us.us.i.1: ; preds = %for.body41.lr.ph.us.us.us.us.us.us.us.i.1, %for.cond22.preheader.us.us76.us.us.us.us.i.1\r\n %inc.us.us80.us.us.us.us.i.1 = add i32 %p.072.us.us77.us.us.us.us.i.1, 1\r\n %narrow.us.us81.us.us.us.us.i.1 = tail call i16 @llvm.umax.i16(i16 0, i16 0)\r\n %spec.select.us.us82.us.us.us.us.i.1 = zext i16 %narrow.us.us81.us.us.us.us.i.1 to i32\r\n %add.us.us83.us.us.us.us.i.1 = sub i32 770, %spec.select.us.us82.us.us.us.us.i.1\r\n %cmp18.us.us84.us.us.us.us.i.1 = icmp slt i32 %p.072.us.us77.us.us.us.us.i.1, %add.us.us83.us.us.us.us.i.1\r\n br i1 %cmp18.us.us84.us.us.us.us.i.1, label %for.cond22.preheader.us.us76.us.us.us.usthread-pre-split.i.1, label %for.cond22.for.cond.cleanup28_crit_edge.us.us.us.us.us.us.i.1.for.cond.cleanup20.us.us.us.us.i.1_crit_edge\r\n\r\nfor.cond22.for.cond.cleanup28_crit_edge.us.us.us.us.us.us.i.1.for.cond.cleanup20.us.us.us.us.i.1_crit_edge: ; preds = %for.cond22.for.cond.cleanup28_crit_edge.us.us.us.us.us.us.i.1\r\n br label %for.cond.cleanup20.us.us.us.us.i.1\r\n\r\nfor.cond.cleanup20.us.us.us.us.i.1: ; preds = %for.cond22.for.cond.cleanup28_crit_edge.us.us.us.us.us.us.i.1.for.cond.cleanup20.us.us.us.us.i.1_crit_edge\r\n ret i32 0\r\n\r\nfor.cond22.preheader.us.us76.us.us.us.usthread-pre-split.i.1: ; preds = %for.cond22.for.cond.cleanup28_crit_edge.us.us.us.us.us.us.i.1\r\n br label %for.cond22.preheader.us.us76.us.us.us.us.i.1\r\n}\r\n\r\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\r\nattributes #1 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-b,-e,-experimental-smctr,-experimental-smmpm,-experimental-smnpm,-experimental-ssctr,-experimental-ssnpm,-experimental-sspm,-experimental-supm,-experimental-zacas,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-experimental-zvbc32e,-experimental-zvkgs,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssqosid,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\n```\r\n\r\nCommand/backtrace:\r\n```\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize reduced.ll -S\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7366: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize reduced.ll -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 \"main\"\r\n #0 0x00005e8221f7d690 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x301e690)\r\n #1 0x00005e8221f7aa9f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x301ba9f)\r\n #2 0x00005e8221f7abf5 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x0000772c88c42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x0000772c88c969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x0000772c88c969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x0000772c88c969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x0000772c88c42476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x0000772c88c287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x0000772c88c2871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x0000772c88c39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x00005e8220f4a3e0 llvm::LoopVectorizationPlanner::computeBestVF() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1feb3e0)\r\n#12 0x00005e8220f60ffb llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2001ffb)\r\n#13 0x00005e8220f64011 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2005011)\r\n#14 0x00005e8220f64687 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2005687)\r\n#15 0x00005e821fdc0fb6 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+0xe61fb6)\r\n#16 0x00005e8221d8858f 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+0x2e2958f)\r\n#17 0x00005e821fdc4146 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+0xe65146)\r\n#18 0x00005e8221d8730b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e2830b)\r\n#19 0x00005e821fdc03e6 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+0xe613e6)\r\n#20 0x00005e8221d8534d 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+0x2e2634d)\r\n#21 0x00005e821f5e6ee6 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+0x687ee6)\r\n#22 0x00005e821f5d8c71 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x679c71)\r\n#23 0x0000772c88c29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#24 0x0000772c88c29e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#25 0x0000772c88c29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#26 0x00005e821f5cf025 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x670025)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\nhttps://godbolt.org/z/ej1Gax953\r\n\r\nFound via fuzzer\r\n\r\nRelated/prior issue: https://github.com/llvm/llvm-project/issues/106641\r\n\r\ncc @fhahn",
"author": "patrick-rivos",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
87798
|
https://github.com/llvm/llvm-project/issues/87798
|
crash
|
49ef12a08c4c7d7ae4765929e72fe2320a12b08c
| 2024-04-05T16:02:46 |
[
"llvm/test/Analysis/ScalarEvolution"
] |
{
"fix_commit": "54a9f0007cb4f19d2e9df30405c5027229f5def0",
"components": [
"ScalarEvolution"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
928,
938
]
],
"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": [
"BinomialCoefficient"
],
"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 54a9f0007cb4f19d2e9df30405c5027229f5def0
Author: annamthomas <anna@azul.com>
Date: Wed Apr 10 09:02:23 2024 -0400
[SCEV] Fix BinomialCoefficient Iteration to fit in W bits (#88010)
BinomialCoefficient computes the value of W-bit IV at iteration It of a loop. When W is 1, we can call multiplicative inverse on 0 which triggers an assert since 1b76120.
Since the arithmetic is supposed to wrap if It or K does not fit in W bits, do the truncation into W bits after we do the shift.
Fixes #87798
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index e030b9fc7dac..9fcce797f559 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -928,11 +928,9 @@ static const SCEV *BinomialCoefficient(const SCEV *It, unsigned K,
APInt OddFactorial(W, 1);
unsigned T = 1;
for (unsigned i = 3; i <= K; ++i) {
- APInt Mult(W, i);
- unsigned TwoFactors = Mult.countr_zero();
+ unsigned TwoFactors = countr_zero(i);
T += TwoFactors;
- Mult.lshrInPlace(TwoFactors);
- OddFactorial *= Mult;
+ OddFactorial *= (i >> TwoFactors);
}
// We need at least W + T bits for the multiplication step
|
[
{
"file": "llvm/test/Analysis/ScalarEvolution/pr87798.ll",
"commands": [
"opt -disable-output -passes='print<scalar-evolution>' -verify-scev < %s 2>&1"
],
"tests": [
{
"test_name": "pr87798",
"test_body": "target datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i32 @pr87798() {\nbb:\n br label %bb1\n\nbb1: ; preds = %bb1, %bb\n %phi = phi i32 [ 0, %bb ], [ %add4, %bb1 ]\n %phi2 = phi i32 [ 0, %bb ], [ %add, %bb1 ]\n %phi3 = phi i32 [ 0, %bb ], [ %add5, %bb1 ]\n %add = add i32 %phi2, %phi3\n %mul = mul i32 %phi2, %phi3\n %add4 = add i32 %mul, %phi\n %and = and i32 %phi, 1\n %add5 = add i32 %phi3, 1\n br i1 true, label %preheader, label %bb1\n\npreheader: ; preds = %bb1\n %phi9 = phi i32 [ %and, %bb1 ]\n br label %loop\n\nloop: ; preds = %loop, %preheader\n br label %loop\n\nbb7: ; No predecessors!\n %zext = zext i32 %phi9 to i64\n ret i32 0\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Assertion failure: \"multiplicative inverse is only defined for odd numbers\" exposed through usage in SCEV",
"body": "With this change [1b76120](https://github.com/llvm/llvm-project/commit/1b761205f2686516cebadbcbc37f798197d9c482) landed in https://github.com/llvm/llvm-project/pull/87610, we started seeing an assertion failure on the introduced API.\r\n\r\nThis change caused an assertion failure in usage of multiplicativeInverse in SCEV's BinomialCoefficient algorithm (which was also updated by the change to use this overloaded API). The `oddFactorial` in this algorithm becomes 0 and the assertion in newly introduced API gets triggered. Note that the old API for multiplicativeInverse (which passed in the explicit modulo) returned 0 when the input was also 0, and probably hid this bug in SCEV. \r\n\r\nHere's a minimal reproducer for trunk:\r\n```\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine i32 @\"static jint Test.iMeth(jlong, jint, jint)2272037699586\"() {\r\nbci_0:\r\n br label %bci_71.preheader\r\n\r\nbci_71.preheader: ; preds = %bci_71.preheader, %bci_0\r\n %local_9_242 = phi i32 [ 0, %bci_0 ], [ %1, %bci_71.preheader ]\r\n %local_7_241 = phi i32 [ 0, %bci_0 ], [ %0, %bci_71.preheader ]\r\n %local_4_239 = phi i32 [ 0, %bci_0 ], [ %3, %bci_71.preheader ]\r\n %0 = add i32 %local_7_241, %local_4_239\r\n %.neg14 = mul i32 %local_7_241, %local_4_239\r\n %1 = add i32 %.neg14, %local_9_242\r\n %2 = and i32 %local_9_242, 1\r\n %3 = add i32 %local_4_239, 1\r\n br i1 true, label %bci_10.i38.preheader, label %bci_71.preheader\r\n\r\nbci_10.i38: ; preds = %bci_10.i38.preheader, %bci_10.i38\r\n br label %bci_10.i38\r\n\r\n\"static jlong FuzzerUtils.checkSum(jobject)2306397437964.exit\": ; No predecessors!\r\n %4 = zext i32 %.lcssa596 to i64\r\n ret i32 0\r\n\r\nbci_10.i38.preheader: ; preds = %bci_71.preheader\r\n %.lcssa596 = phi i32 [ %2, %bci_71.preheader ]\r\n br label %bci_10.i38\r\n}\r\n```\r\n\r\nopt -passes=indvars reduced.ll produces:\r\n```\r\nopt: /root/llvm-project/llvm/lib/Support/APInt.cpp:1245: llvm::APInt llvm::APInt::multiplicativeInverse() const: Assertion `(*this)[0] && \"multiplicative inverse is only defined for odd numbers!\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=indvars <source>\r\n #0 0x0000000004cfc568 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4cfc568)\r\n #1 0x0000000004cf9cbc SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007f7209e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x00007f7209e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x00007f7209e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x00007f7209e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00007f7209e2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x00007f7209e39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x0000000004bf9eff llvm::APInt::multiplicativeInverse() const (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4bf9eff)\r\n #9 0x000000000443a4b5 llvm::SCEVAddRecExpr::evaluateAtIteration(llvm::ArrayRef<llvm::SCEV const*>, llvm::SCEV const*, llvm::ScalarEvolution&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x443a4b5)\r\n#10 0x000000000443cb4f llvm::ScalarEvolution::computeSCEVAtScope(llvm::SCEV const*, llvm::Loop const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x443cb4f)\r\n#11 0x000000000443cfee llvm::ScalarEvolution::getSCEVAtScope(llvm::SCEV const*, llvm::Loop const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x443cfee)\r\n#12 0x000000000443c525 llvm::ScalarEvolution::computeSCEVAtScope(llvm::SCEV const*, llvm::Loop const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x443c525)\r\n#13 0x000000000443cfee llvm::ScalarEvolution::getSCEVAtScope(llvm::SCEV const*, llvm::Loop const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x443cfee)\r\n#14 0x000000000404eca0 llvm::rewriteLoopExitValues(llvm::Loop*, llvm::LoopInfo*, llvm::TargetLibraryInfo*, llvm::ScalarEvolution*, llvm::TargetTransformInfo const*, llvm::SCEVExpander&, llvm::DominatorTree*, llvm::ReplaceExitVal, llvm::SmallVector<llvm::WeakTrackingVH, 16u>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x404eca0)\r\n#15 0x0000000003a10fd8 (anonymous namespace)::IndVarSimplify::run(llvm::Loop*) IndVarSimplify.cpp:0:0\r\n#16 0x0000000003a11c1a llvm::IndVarSimplifyPass::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3a11c1a)\r\n#17 0x00000000029ffd4e llvm::detail::PassModel<llvm::Loop, llvm::IndVarSimplifyPass, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x29ffd4e)\r\n#18 0x0000000003aaef56 std::optional<llvm::PreservedAnalyses> llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::runSinglePass<llvm::Loop, std::unique_ptr<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, std::default_delete<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>>>>(llvm::Loop&, std::unique_ptr<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, std::default_delete<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>>>&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&, llvm::PassInstrumentation&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3aaef56)\r\n#19 0x0000000003aaf1ee llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::runWithoutLoopNestPasses(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3aaf1ee)\r\n#20 0x0000000003ab05d9 llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3ab05d9)\r\n...\r\n```",
"author": "annamthomas",
"labels": [
"llvm:SCEV",
"crash"
],
"comments": [
{
"author": "topperc",
"body": "CC @jayfoad "
},
{
"author": "annamthomas",
"body": "I think the old API (multiplicativeInverse when modulo provided) was hiding this bug since multiplicative inverse shouldn't be asked for 0.\r\nAlso, the reason the `oddFactorial` becomes 0 here is because of this:\r\n```\r\n// Calculate K! / 2^T and T; we divide out the factors of two before\r\n // multiplying for calculating K! / 2^T to avoid overflow.\r\n // Other overflow doesn't matter because we only care about the bottom\r\n // W bits of the result.\r\n APInt OddFactorial(W, 1);\r\n unsigned T = 1;\r\n for (unsigned i = 3; i <= K; ++i) {\r\n APInt Mult(W, i);\r\n unsigned TwoFactors = Mult.countr_zero();\r\n T += TwoFactors;\r\n Mult.lshrInPlace(TwoFactors);\r\n OddFactorial *= Mult; \r\n }\r\n ```\r\n\r\nHere, W is one (bit width = 1 and I believe this is the bug) and we are trying to represent Mult=4 in one bit. That makes `Mult` 0 and hence `OddFactorial` 0.\r\n\r\nOne thing we can obviously do is in the newly introduced API, explicitly check if the APInt is 0 and return 0 (this makes behaviour same as the old API).\r\nBut I think this is hiding the bug. "
},
{
"author": "jayfoad",
"body": "Suggestion:\r\n```diff\r\ndiff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp\r\nindex e030b9fc7dac..3f8c390614ff 100644\r\n--- a/llvm/lib/Analysis/ScalarEvolution.cpp\r\n+++ b/llvm/lib/Analysis/ScalarEvolution.cpp\r\n@@ -928,11 +928,9 @@ static const SCEV *BinomialCoefficient(const SCEV *It, unsigned K,\r\n APInt OddFactorial(W, 1);\r\n unsigned T = 1;\r\n for (unsigned i = 3; i <= K; ++i) {\r\n- APInt Mult(W, i);\r\n- unsigned TwoFactors = Mult.countr_zero();\r\n+ unsigned TwoFactors = countr_zero(i);\r\n T += TwoFactors;\r\n- Mult.lshrInPlace(TwoFactors);\r\n- OddFactorial *= Mult;\r\n+ OddFactorial *= i >> TwoFactors;\r\n }\r\n \r\n // We need at least W + T bits for the multiplication step\r\n```"
},
{
"author": "annamthomas",
"body": "yes, that would probably work as well (since we avoid representing Mult in W bit width), but how can the bitWidth of the SCEV result`W` be 1 in the first place? "
},
{
"author": "jayfoad",
"body": "> yes, that would probably work as well (since we avoid representing Mult in W bit width), but how can the bitWidth of the SCEV result`W` be 1 in the first place?\r\n\r\nNo idea! I have only looked at `BinomialCoefficient` itself, not at its callers. I assume it is supposed to work for any W > 0 and K > 0. At least I don't see it mentioned that K has to be representable in W bits, or anything like that."
},
{
"author": "efriedma-quic",
"body": "The function is supposed to compute `BC(It, K) mod 2^W`, i.e. the binomial coefficient truncated to fit into a W-bit integer. This is useful for computing the value of a W-bit induction variable at iteration \"It\" of a loop. There isn't any expectation that \"It\" or \"K\" fit losslessly into \"W\": the arithmetic is supposed to wrap.\r\n\r\nGiven the way the function works, truncating \"i\" after the shift looks like the right solution."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
82877
|
https://github.com/llvm/llvm-project/issues/82877
|
hang
|
f32c6b28b84130dc77e0e69d6d3b692aec933280
| 2024-02-24T13:05:43 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "abe4677d9f8ab82f722f29dbf57952052accd70b",
"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": [
[
2341,
2351
],
[
2361,
2372
],
[
2375,
2380
]
],
"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": [
"InstCombiner::getFreelyInvertedImpl"
],
"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 abe4677d9f8ab82f722f29dbf57952052accd70b
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Tue Mar 5 03:51:06 2024 +0800
[InstCombine] Fix infinite loop due to incorrect `DoesConsume` (#82973)
When a call to `getFreelyInvertedImpl` with a select/phi node fails,
`DoesConsume` should not be changed.
Fixes https://github.com/llvm/llvm-project/issues/82877.
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 87c8dca7efed..80ce0c9275b2 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -2341,11 +2341,13 @@ Value *InstCombiner::getFreelyInvertedImpl(Value *V, bool WillInvertAllUses,
!shouldAvoidAbsorbingNotIntoSelect(*cast<SelectInst>(V));
// Selects/min/max with invertible operands are freely invertible
if (IsSelect || match(V, m_MaxOrMin(m_Value(A), m_Value(B)))) {
+ bool LocalDoesConsume = DoesConsume;
if (!getFreelyInvertedImpl(B, B->hasOneUse(), /*Builder*/ nullptr,
- DoesConsume, Depth))
+ LocalDoesConsume, Depth))
return nullptr;
if (Value *NotA = getFreelyInvertedImpl(A, A->hasOneUse(), Builder,
- DoesConsume, Depth)) {
+ LocalDoesConsume, Depth)) {
+ DoesConsume = LocalDoesConsume;
if (Builder != nullptr) {
Value *NotB = getFreelyInvertedImpl(B, B->hasOneUse(), Builder,
DoesConsume, Depth);
@@ -2361,12 +2363,13 @@ Value *InstCombiner::getFreelyInvertedImpl(Value *V, bool WillInvertAllUses,
}
if (PHINode *PN = dyn_cast<PHINode>(V)) {
+ bool LocalDoesConsume = DoesConsume;
SmallVector<std::pair<Value *, BasicBlock *>, 8> IncomingValues;
for (Use &U : PN->operands()) {
BasicBlock *IncomingBlock = PN->getIncomingBlock(U);
Value *NewIncomingVal = getFreelyInvertedImpl(
U.get(), /*WillInvertAllUses=*/false,
- /*Builder=*/nullptr, DoesConsume, MaxAnalysisRecursionDepth - 1);
+ /*Builder=*/nullptr, LocalDoesConsume, MaxAnalysisRecursionDepth - 1);
if (NewIncomingVal == nullptr)
return nullptr;
// Make sure that we can safely erase the original PHI node.
@@ -2375,6 +2378,8 @@ Value *InstCombiner::getFreelyInvertedImpl(Value *V, bool WillInvertAllUses,
if (Builder != nullptr)
IncomingValues.emplace_back(NewIncomingVal, IncomingBlock);
}
+
+ DoesConsume = LocalDoesConsume;
if (Builder != nullptr) {
IRBuilderBase::InsertPointGuard Guard(*Builder);
Builder->SetInsertPoint(PN);
|
[
{
"file": "llvm/test/Transforms/InstCombine/pr82877.ll",
"commands": [
"opt -S -passes=instcombine < %s"
],
"tests": [
{
"test_name": "func",
"test_body": "define i64 @func(i32 %p, i1 %cmp1) {\nentry:\n %not = xor i32 %p, -1\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %p0 = phi i32 [ %not, %entry ], [ %conv, %for.body ]\n %cond = select i1 %cmp1, i32 0, i32 -1231558963\n %xor = xor i32 %cond, %p0\n %cmp2 = icmp ne i32 %xor, 1\n %conv = zext i1 %cmp2 to i32\n br i1 %cmp2, label %for.body, label %for.exit\n\nfor.exit: ; preds = %for.body\n ret i64 0\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstCombine] InstCombine gets stuck when simplifying icmps ",
"body": "Reduced test case: https://godbolt.org/z/dc6jnha5q\r\n```\r\ndefine i64 @func(i32 %p) {\r\nentry:\r\n %not = xor i32 %p, -1\r\n br label %for.body\r\n\r\nfor.body:\r\n %p0 = phi i32 [ %not, %entry ], [ %conv, %for.body ]\r\n %p1 = phi i32 [ 0, %entry ], [ %inc, %for.body ]\r\n %inc = add i32 %p1, 1\r\n %cmp1 = icmp ne i32 %inc, 0\r\n %cond = select i1 %cmp1, i32 0, i32 -1231558963\r\n %xor = xor i32 %cond, %p0\r\n %cmp2 = icmp ne i32 %xor, -2\r\n %conv = zext i1 %cmp2 to i32\r\n br i1 %cmp2, label %for.body, label %for.exit\r\n\r\nfor.exit:\r\n ret i64 0\r\n}\r\n```\r\n\r\n```\r\nIC: Visiting: %p0 = phi i32 [ %not, %entry ], [ %conv, %for.body ]\r\nIC: Visiting: %cmp2 = icmp ne i32 %1, -2\r\nADD DEFERRED: %2 = select i1 %cmp1.not, i32 1231558962, i32 -1\r\nADD DEFERRED: %3 = xor i32 %2, %p0\r\nIC: Old = %cmp2 = icmp ne i32 %1, -2\r\n New = <badref> = icmp ne i32 %3, 1\r\nADD: %cmp2 = icmp ne i32 %3, 1\r\nIC: ERASE %4 = icmp ne i32 %1, -2\r\nADD DEFERRED: %1 = xor i32 %0, %p0\r\nIC: ERASE %1 = xor i32 %0, %p0\r\nADD DEFERRED: %0 = select i1 %cmp1.not, i32 -1231558963, i32 0\r\nADD DEFERRED: %p0 = phi i32 [ %not, %entry ], [ %conv, %for.body ]\r\nADD: %p0 = phi i32 [ %not, %entry ], [ %conv, %for.body ]\r\nIC: ERASE %0 = select i1 %cmp1.not, i32 -1231558963, i32 0\r\nADD DEFERRED: %cmp1.not = icmp eq i32 %inc, 0\r\nADD: %cmp1.not = icmp eq i32 %inc, 0\r\nADD: %1 = xor i32 %0, %p0\r\nADD: %0 = select i1 %cmp1.not, i32 1231558962, i32 -1\r\nIC: Visiting: %0 = select i1 %cmp1.not, i32 1231558962, i32 -1\r\nIC: Visiting: %1 = xor i32 %0, %p0\r\nIC: Visiting: %cmp1.not = icmp eq i32 %inc, 0\r\nIC: Visiting: %p0 = phi i32 [ %not, %entry ], [ %conv, %for.body ]\r\nIC: Visiting: %cmp2 = icmp ne i32 %1, 1\r\nADD DEFERRED: %2 = select i1 %cmp1.not, i32 -1231558963, i32 0\r\nADD DEFERRED: %3 = xor i32 %2, %p0\r\nIC: Old = %cmp2 = icmp ne i32 %1, 1\r\n New = <badref> = icmp ne i32 %3, -2\r\nADD: %cmp2 = icmp ne i32 %3, -2\r\nIC: ERASE %4 = icmp ne i32 %1, 1\r\nADD DEFERRED: %1 = xor i32 %0, %p0\r\nIC: ERASE %1 = xor i32 %0, %p0\r\nADD DEFERRED: %0 = select i1 %cmp1.not, i32 1231558962, i32 -1\r\nADD DEFERRED: %p0 = phi i32 [ %not, %entry ], [ %conv, %for.body ]\r\nADD: %p0 = phi i32 [ %not, %entry ], [ %conv, %for.body ]\r\nIC: ERASE %0 = select i1 %cmp1.not, i32 1231558962, i32 -1\r\nADD DEFERRED: %cmp1.not = icmp eq i32 %inc, 0\r\nADD: %cmp1.not = icmp eq i32 %inc, 0\r\nADD: %1 = xor i32 %0, %p0\r\nADD: %0 = select i1 %cmp1.not, i32 -1231558963, i32 0\r\nIC: Visiting: %0 = select i1 %cmp1.not, i32 -1231558963, i32 0\r\nIC: Visiting: %1 = xor i32 %0, %p0\r\nIC: Visiting: %cmp1.not = icmp eq i32 %inc, 0\r\n\r\nRepeats multiple times...\r\n```",
"author": "dtcxzyw",
"labels": [
"llvm:instcombine",
"llvm:hang"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Another reproducer:\r\n```\r\n/*\r\n * This is a RANDOMLY GENERATED PROGRAM.\r\n *\r\n * Generator: csmith 2.4.0\r\n * Git version: 0ec6f1b\r\n * Options: --max-funcs 3 --max-block-depth 3 --quiet --no-packed-struct --no-bitfields --no-volatiles --no-volatile-pointers --output ./csmith2024-02-24@16:09/test34436.c\r\n * Seed: 3421191658\r\n */\r\n\r\n#include \"csmith.h\"\r\n\r\n\r\nstatic long __undefined;\r\n\r\n\r\n\r\nstatic int32_t g_11[2] = {(-1L),(-1L)};\r\nstatic uint16_t g_12 = 0x5EB7L;\r\nstatic uint64_t g_31 = 2UL;\r\nstatic uint64_t g_33[9][1][9] = {{{0x0273394210AB9CA2LL,0x0B9C45D188285970LL,0x0B9C45D188285970LL,0x0273394210AB9CA2LL,18446744073709551611UL,18446744073709551607UL,0x461D90BCC9DF78A4LL,0x0B9C45D188285970LL,18446744073709551607UL}},{{4UL,0x0B9C45D188285970LL,0xF205A4AAC46587A7LL,0x461D90BCC9DF78A4LL,18446744073709551614UL,18446744073709551614UL,0x461D90BCC9DF78A4LL,0xF205A4AAC46587A7LL,0x0B9C45D188285970LL}},{{0x461D90BCC9DF78A4LL,18446744073709551611UL,0xF205A4AAC46587A7LL,0xD17401D8B2D29C61LL,18446744073709551611UL,0x0B9C45D188285970LL,1UL,0xF205A4AAC46587A7LL,0xF205A4AAC46587A7LL}},{{4UL,18446744073709551614UL,0x0B9C45D188285970LL,0xD17401D8B2D29C61LL,0x0B9C45D188285970LL,18446744073709551614UL,4UL,0x0B9C45D188285970LL,0xF205A4AAC46587A7LL}},{{0x0273394210AB9CA2LL,18446744073709551611UL,18446744073709551607UL,0x461D90BCC9DF78A4LL,0x0B9C45D188285970LL,18446744073709551607UL,1UL,18446744073709551607UL,0xDAEE255298A7B986LL}},{{0xF205A4AAC46587A7LL,0xDAEE255298A7B986LL,0xDAEE255298A7B986LL,0xF205A4AAC46587A7LL,18446744073709551606UL,0x68F5B79C14114C53LL,18446744073709551607UL,0xDAEE255298A7B986LL,0x68F5B79C14114C53LL}},{{0x0B9C45D188285970LL,0xDAEE255298A7B986LL,1UL,18446744073709551607UL,18446744073709551609UL,18446744073709551609UL,18446744073709551607UL,1UL,0xDAEE255298A7B986LL}},{{18446744073709551607UL,18446744073709551606UL,1UL,18446744073709551611UL,18446744073709551606UL,0xDAEE255298A7B986LL,18446744073709551614UL,1UL,1UL}},{{0x0B9C45D188285970LL,18446744073709551609UL,0xDAEE255298A7B986LL,18446744073709551611UL,0xDAEE255298A7B986LL,18446744073709551609UL,0x0B9C45D188285970LL,0xDAEE255298A7B986LL,1UL}}};\r\nstatic const int32_t *g_35 = &g_11[1];\r\nstatic int64_t g_66[5][4] = {{(-9L),6L,6L,(-9L)},{6L,(-9L),6L,6L},{(-9L),(-9L),3L,(-9L)},{(-9L),6L,6L,(-9L)},{6L,(-9L),6L,6L}};\r\nstatic uint32_t g_94[3] = {0x3680C6D9L,0x3680C6D9L,0x3680C6D9L};\r\nstatic uint32_t g_149 = 5UL;\r\nstatic int64_t g_157[9] = {9L,9L,(-1L),9L,9L,(-1L),9L,9L,(-1L)};\r\nstatic int8_t g_165 = 8L;\r\nstatic int16_t g_168 = 0xD32BL;\r\nstatic int32_t *g_169 = &g_11[0];\r\nstatic int32_t *g_170 = (void*)0;\r\nstatic uint8_t g_185 = 246UL;\r\nstatic int32_t **g_256 = &g_169;\r\nstatic int32_t *** const g_255 = &g_256;\r\nstatic uint32_t g_306 = 0xF063AF95L;\r\nstatic int16_t g_311 = 7L;\r\nstatic int32_t g_313 = 0x472F43A5L;\r\nstatic const uint16_t g_341 = 0xB915L;\r\nstatic uint8_t g_346[6] = {0x3EL,0x3EL,0x3EL,0x3EL,0x3EL,0x3EL};\r\nstatic uint8_t g_366[6][2] = {{0x39L,0x39L},{0UL,0x39L},{0x39L,0UL},{0x39L,0x39L},{0UL,0x39L},{0x39L,0UL}};\r\nstatic const int64_t *g_373 = &g_157[0];\r\nstatic const int64_t **g_372 = &g_373;\r\nstatic uint32_t g_380 = 4294967293UL;\r\nstatic uint16_t g_407 = 0UL;\r\nstatic int8_t g_409 = (-2L);\r\nstatic int8_t *g_408 = &g_409;\r\nstatic const int8_t g_412 = 0xF0L;\r\nstatic const int8_t g_414 = 0x89L;\r\nstatic const int8_t g_416[5][10] = {{0L,0xDDL,0L,(-1L),(-1L),0L,0xDDL,0L,(-1L),(-1L)},{0L,0xDDL,0L,(-1L),(-1L),0L,0xDDL,0L,(-1L),(-1L)},{0L,0xDDL,0L,(-1L),(-1L),0L,0xDDL,0L,(-1L),(-1L)},{0L,0xDDL,0L,(-1L),(-1L),0L,0xDDL,0L,(-1L),(-1L)},{0L,0xDDL,0L,(-1L),(-1L),0L,0xDDL,0L,(-1L),(-1L)}};\r\nstatic const int8_t *g_415[9][1] = {{&g_416[2][2]},{&g_416[2][2]},{&g_416[2][2]},{&g_416[2][2]},{&g_416[2][2]},{&g_416[2][2]},{&g_416[2][2]},{&g_416[2][2]},{&g_416[2][2]}};\r\nstatic int8_t g_426 = (-6L);\r\nstatic int32_t g_457 = 0x1708815BL;\r\nstatic int16_t *g_466[10][10][2] = {{{&g_311,&g_168},{&g_311,(void*)0},{&g_311,&g_168},{&g_311,&g_311},{&g_168,&g_311},{(void*)0,&g_311},{&g_168,&g_311},{&g_311,&g_168},{&g_311,(void*)0},{&g_311,&g_168}},{{&g_311,&g_311},{&g_168,&g_311},{(void*)0,&g_311},{&g_168,&g_311},{&g_311,&g_168},{&g_311,(void*)0},{&g_311,&g_168},{&g_311,&g_311},{&g_168,&g_311},{(void*)0,&g_311}},{{&g_168,&g_311},{&g_311,&g_168},{&g_311,&g_168},{&g_168,(void*)0},{(void*)0,(void*)0},{(void*)0,&g_168},{&g_168,&g_168},{(void*)0,(void*)0},{(void*)0,(void*)0},{&g_168,&g_168}},{{&g_168,(void*)0},{(void*)0,(void*)0},{(void*)0,&g_168},{&g_168,&g_168},{(void*)0,(void*)0},{(void*)0,(void*)0},{&g_168,&g_168},{&g_168,(void*)0},{(void*)0,(void*)0},{(void*)0,&g_168}},{{&g_168,&g_168},{(void*)0,(void*)0},{(void*)0,(void*)0},{&g_168,&g_168},{&g_168,(void*)0},{(void*)0,(void*)0},{(void*)0,&g_168},{&g_168,&g_168},{(void*)0,(void*)0},{(void*)0,(void*)0}},{{&g_168,&g_168},{&g_168,(void*)0},{(void*)0,(void*)0},{(void*)0,&g_168},{&g_168,&g_168},{(void*)0,(void*)0},{(void*)0,(void*)0},{&g_168,&g_168},{&g_168,(void*)0},{(void*)0,(void*)0}},{{(void*)0,&g_168},{&g_168,&g_168},{(void*)0,(void*)0},{(void*)0,(void*)0},{&g_168,&g_168},{&g_168,(void*)0},{(void*)0,(void*)0},{(void*)0,&g_168},{&g_168,&g_168},{(void*)0,(void*)0}},{{(void*)0,(void*)0},{&g_168,&g_168},{&g_168,(void*)0},{(void*)0,(void*)0},{(void*)0,&g_168},{&g_168,&g_168},{(void*)0,(void*)0},{(void*)0,(void*)0},{&g_168,&g_168},{&g_168,(void*)0}},{{(void*)0,(void*)0},{(void*)0,&g_168},{&g_168,&g_168},{(void*)0,(void*)0},{(void*)0,(void*)0},{&g_168,&g_168},{&g_168,(void*)0},{(void*)0,(void*)0},{(void*)0,&g_168},{&g_168,&g_168}},{{(void*)0,(void*)0},{(void*)0,(void*)0},{&g_168,&g_168},{&g_168,(void*)0},{(void*)0,(void*)0},{(void*)0,&g_168},{&g_168,&g_168},{(void*)0,(void*)0},{(void*)0,(void*)0},{&g_168,&g_168}}};\r\nstatic int32_t *g_596[1] = {&g_11[0]};\r\n\r\n\r\n\r\nstatic uint8_t func_1(void);\r\nstatic int32_t func_8(int32_t p_9);\r\nstatic int16_t func_15(int8_t p_16, uint32_t p_17, int32_t p_18);\r\n\r\n\r\n\r\n\r\n\r\nstatic uint8_t func_1(void)\r\n{ \r\n int32_t l_7 = (-8L);\r\n uint16_t *l_572 = &g_407;\r\n int32_t *l_573 = &g_11[1];\r\n int32_t *l_588 = &g_313;\r\n int8_t *l_595 = (void*)0;\r\n int32_t **l_597 = &g_596[0];\r\n (*l_573) = (safe_div_func_uint16_t_u_u(((*l_572) = (0xCDF98A59L && (((0x4EBB0CB8CE3E63E3LL > (safe_lshift_func_uint32_t_u_u(1UL, (~(l_7 , func_8(l_7)))))) > (((safe_mul_func_uint32_t_u_u((l_7 || (safe_add_func_uint8_t_u_u(((g_341 && (-1L)) , 0x01L), g_416[2][6]))), l_7)) & 0xDE15L) , l_7)) >= l_7))), 65527UL));\r\n (*l_597) = (((((*l_573) ^ (**g_372)) != (safe_div_func_int8_t_s_s((safe_rshift_func_uint64_t_u_u(0x1A63987AF980F8B3LL, (safe_rshift_func_uint8_t_u_u((((g_426 ^= ((safe_add_func_int64_t_s_s(((safe_add_func_uint32_t_u_u(((safe_sub_func_uint16_t_u_u((safe_mod_func_int8_t_s_s(0x95L, (((*l_588) = (*l_573)) ^ ((*l_573) != (safe_rshift_func_int32_t_s_s((*l_573), ((((safe_sub_func_int32_t_s_s(((((safe_mod_func_int8_t_s_s((*g_408), 3UL)) && 0x38L) || g_168) == (*l_573)), (*l_573))) && 249UL) & g_31) , g_457))))))), g_94[0])) , g_341), g_94[2])) ^ g_149), (*g_373))) > 0xF735A181L)) != (*l_573)) != (-1L)), g_185)))), (*l_573)))) ^ (-1L)) , g_596[0]);\r\n for (g_185 = 0; (g_185 == 37); g_185 = safe_add_func_uint32_t_u_u(g_185, 4))\r\n { \r\n uint32_t l_600 = 0x5F5A8D5BL;\r\n (**l_597) = l_600;\r\n }\r\n return g_426;\r\n}\r\n\r\n\r\n\r\n\r\nstatic int32_t func_8(int32_t p_9)\r\n{ \r\n int32_t *l_10[7][10][3] = {{{&g_11[0],&g_11[0],&g_11[1]},{&g_11[1],&g_11[0],(void*)0},{&g_11[0],&g_11[0],&g_11[1]},{&g_11[0],&g_11[0],&g_11[1]},{&g_11[0],(void*)0,(void*)0},{&g_11[0],&g_11[1],&g_11[1]},{&g_11[1],&g_11[1],&g_11[1]},{&g_11[0],&g_11[0],&g_11[1]},{(void*)0,&g_11[1],(void*)0},{&g_11[1],(void*)0,&g_11[1]}},{{&g_11[1],&g_11[1],&g_11[1]},{&g_11[1],&g_11[1],&g_11[1]},{&g_11[0],&g_11[1],(void*)0},{&g_11[1],&g_11[1],&g_11[1]},{&g_11[0],&g_11[0],&g_11[1]},{&g_11[0],&g_11[1],&g_11[0]},{(void*)0,&g_11[1],&g_11[0]},{&g_11[0],&g_11[1],&g_11[1]},{&g_11[1],&g_11[1],&g_11[1]},{&g_11[1],&g_11[1],&g_11[1]}},{{(void*)0,(void*)0,(void*)0},{&g_11[0],&g_11[1],&g_11[1]},{(void*)0,&g_11[1],(void*)0},{&g_11[0],&g_11[0],&g_11[1]},{(void*)0,&g_11[0],&g_11[1]},{&g_11[1],&g_11[1],&g_11[0]},{&g_11[1],&g_11[1],&g_11[1]},{&g_11[0],&g_11[1],&g_11[1]},{(void*)0,(void*)0,&g_11[0]},{&g_11[0],&g_11[1],&g_11[0]}},{{&g_11[0],(void*)0,&g_11[0]},{&g_11[1],&g_11[1],&g_11[1]},{&g_11[0],&g_11[1],&g_11[1]},{&g_11[1],&g_11[0],&g_11[0]},{&g_11[1],&g_11[1],&g_11[1]},{&g_11[1],&g_11[1],&g_11[1]},{&g_11[1],&g_11[0],(void*)0},{&g_11[1],&g_11[0],&g_11[1]},{&g_11[1],&g_11[0],(void*)0},{&g_11[1],&g_11[1],&g_11[1]}},{{&g_11[0],&g_11[1],&g_11[1]},{&g_11[1],&g_11[0],&g_11[1]},{&g_11[1],&g_11[1],&g_11[0]},{&g_11[0],&g_11[1],&g_11[0]},{&g_11[1],(void*)0,&g_11[1]},{&g_11[1],&g_11[1],&g_11[1]},{&g_11[1],(void*)0,(void*)0},{&g_11[0],&g_11[1],&g_11[1]},{&g_11[1],&g_11[1],&g_11[1]},{&g_11[1],&g_11[1],&g_11[1]}},{{&g_11[0],&g_11[0],&g_11[1]},{&g_11[1],&g_11[0],&g_11[1]},{&g_11[1],&g_11[1],&g_11[0]},{&g_11[1],&g_11[1],&g_11[1]},{&g_11[1],(void*)0,&g_11[1]},{&g_11[1],&g_11[1],&g_11[1]},{&g_11[1],&g_11[1],&g_11[1]},{&g_11[1],&g_11[1],&g_11[1]},{&g_11[0],&g_11[1],(void*)0},{&g_11[1],&g_11[1],&g_11[1]}},{{&g_11[0],&g_11[0],&g_11[1]},{&g_11[0],&g_11[1],&g_11[0]},{(void*)0,&g_11[1],&g_11[0]},{&g_11[0],&g_11[1],&g_11[1]},{&g_11[1],&g_11[1],&g_11[1]},{&g_11[1],&g_11[1],&g_11[1]},{(void*)0,(void*)0,(void*)0},{&g_11[0],&g_11[1],&g_11[1]},{(void*)0,&g_11[1],(void*)0},{&g_11[0],&g_11[0],&g_11[1]}}};\r\n int32_t **l_23 = &l_10[6][7][1];\r\n int32_t l_24[1];\r\n uint64_t *l_30 = &g_31;\r\n uint64_t *l_32 = &g_33[8][0][8];\r\n int16_t *l_310 = &g_311;\r\n int32_t *l_312 = &g_313;\r\n uint16_t *l_314 = &g_12;\r\n uint8_t * const l_319 = &g_185;\r\n int32_t *l_338[7];\r\n int8_t l_381 = 0x82L;\r\n int64_t *l_425 = &g_66[1][0];\r\n int64_t **l_424[6] = {&l_425,&l_425,&l_425,&l_425,&l_425,&l_425};\r\n int64_t ***l_423 = &l_424[2];\r\n int i, j, k;\r\n for (i = 0; i < 1; i++)\r\n l_24[i] = 1L;\r\n for (i = 0; i < 7; i++)\r\n l_338[i] = &g_313;\r\n --g_12;\r\n (*l_312) |= (((*l_310) |= func_15((((((*l_32) = ((*l_30) = (((safe_mod_func_uint64_t_u_u((((p_9 , (void*)0) == ((*l_23) = l_10[5][8][0])) && (g_11[1] <= 0x8543L)), l_24[0])) , (!(safe_div_func_uint16_t_u_u((g_12 , ((((((safe_sub_func_int64_t_s_s(((-1L) && (g_12 >= p_9)), p_9)) > 0xED293E35L) | 0x12CB5DCFL) > g_11[1]) , p_9) , p_9)), g_11[1])))) && g_11[0]))) , 0UL) != 0x52L) || g_12), p_9, g_12)) <= 0xA360L);\r\n (*l_23) = (void*)0;\r\n if (((p_9 && (((((*l_312) >= ((*l_314) = 65535UL)) , (safe_div_func_int32_t_s_s((safe_mod_func_uint16_t_u_u(((((l_319 == l_319) >= (safe_rshift_func_int16_t_s_s((((safe_mod_func_uint32_t_u_u(p_9, g_149)) , (void*)0) != l_30), p_9))) , g_31) != p_9), g_31)), p_9))) != g_157[0]) && p_9)) && 0L))\r\n { \r\n int8_t * const l_324[7] = {(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0};\r\n int8_t *l_326[9] = {&g_165,&g_165,&g_165,&g_165,&g_165,&g_165,&g_165,&g_165,&g_165};\r\n int8_t **l_325 = &l_326[6];\r\n int8_t *l_328 = &g_165;\r\n int8_t **l_327 = &l_328;\r\n int32_t l_333 = 1L;\r\n int32_t l_369 = 0x5EBB0ECBL;\r\n const int8_t *l_413 = &g_414;\r\n int32_t **l_417 = (void*)0;\r\n int32_t l_458[9][2][1] = {{{(-5L)},{(-5L)}},{{(-6L)},{(-5L)}},{{(-5L)},{(-6L)}},{{(-5L)},{(-5L)}},{{(-6L)},{(-5L)}},{{(-5L)},{(-6L)}},{{(-5L)},{(-5L)}},{{(-6L)},{(-5L)}},{{(-5L)},{(-6L)}}};\r\n int32_t l_496[6][7] = {{1L,0xA4F1B851L,0x37A88DA2L,0xA4F1B851L,1L,0L,0L},{1L,0xA4F1B851L,0x37A88DA2L,0xA4F1B851L,1L,0L,0L},{1L,0xA4F1B851L,0x37A88DA2L,0xA4F1B851L,1L,0L,0L},{1L,0xA4F1B851L,0x37A88DA2L,0xA4F1B851L,1L,0L,0L},{1L,0xA4F1B851L,0x37A88DA2L,0xA4F1B851L,1L,0L,0L},{1L,0xA4F1B851L,0x37A88DA2L,0xA4F1B851L,1L,0L,0L}};\r\n uint8_t l_499 = 4UL;\r\n int i, j, k;\r\n if (((((l_324[0] == ((*l_327) = ((*l_325) = &g_165))) , 0x77C2C50F563A9C1DLL) , ((*l_319) = (safe_mul_func_int32_t_s_s(p_9, ((safe_lshift_func_uint64_t_u_u(l_333, (--(*l_32)))) & (safe_mul_func_uint64_t_u_u(((void*)0 != l_338[2]), (safe_sub_func_int64_t_s_s(0x64D8F0F17592A3D5LL, ((0x23L ^ g_313) < g_12)))))))))) , g_341))\r\n { \r\n return p_9;\r\n }\r\n else\r\n { \r\n int64_t l_367 = 1L;\r\n int32_t l_368 = 3L;\r\n int64_t *l_399 = &g_157[0];\r\n int64_t **l_398[8] = {&l_399,&l_399,&l_399,&l_399,&l_399,&l_399,&l_399,&l_399};\r\n int64_t ***l_397 = &l_398[6];\r\n int32_t **l_420 = (void*)0;\r\n int32_t l_460[9][4][7] = {{{0x3D2FE6F7L,(-1L),0L,0x6944E926L,(-1L),(-1L),0x2AF43CFEL},{0x77DC1A4FL,7L,0L,0xB5C39BA6L,0x8A6F8D2AL,0x78B5A455L,6L},{0L,3L,0x3D2FE6F7L,0x27A80343L,0x38C9E105L,(-1L),(-1L)},{0xD73C9A77L,0xCE3D98E2L,0x38C9E105L,(-1L),8L,(-1L),0x38C9E105L}},{{6L,6L,0x835FBC13L,5L,0xCCB98A17L,5L,0x651280DBL},{8L,1L,(-1L),0L,(-1L),(-1L),0x571592F3L},{0L,0x10A7A682L,0xB9488037L,6L,0xCCB98A17L,0x2F71711FL,0x27A80343L},{(-1L),0x38C9E105L,1L,4L,8L,7L,(-1L)}},{{0x7639893BL,0L,0x8D6AEC21L,1L,0x38C9E105L,0x541A2144L,0x08FC8D1FL},{0x651280DBL,(-1L),0L,0xD73C9A77L,0x8A6F8D2AL,0x74F12713L,0L},{1L,0x74F12713L,1L,0x52681015L,(-1L),0L,0x34D5741FL},{0x6944E926L,0xB5C39BA6L,0x78B5A455L,0x92017A1BL,(-1L),0L,(-1L)}},{{0x787EDD2CL,0x0AF78BCDL,0xB5C39BA6L,5L,(-1L),0x74F12713L,0L},{0x74F12713L,(-10L),0x10A7A682L,1L,0L,0x541A2144L,3L},{0L,0xCCB98A17L,0x7639893BL,6L,0xA8583C15L,7L,0xA8583C15L},{0x8A6F8D2AL,0xC899F44EL,0xC899F44EL,0x8A6F8D2AL,0x88020F57L,0x2F71711FL,(-1L)}},{{0xA8583C15L,0x835FBC13L,0x2AF43CFEL,0L,0x787EDD2CL,0x77DC1A4FL,1L},{1L,5L,5L,0x73D9572DL,0L,0L,0x77DC1A4FL},{(-1L),0x7639893BL,0x2DCD775DL,2L,0L,0xC899F44EL,(-10L)},{(-1L),0xB9488037L,0x835FBC13L,1L,0x92017A1BL,4L,0xCE3D98E2L}},{{0x7BF1CC1CL,6L,(-1L),0x92017A1BL,0x8A6F8D2AL,(-1L),(-1L)},{4L,0x571592F3L,0xC899F44EL,8L,0L,0x835FBC13L,0L},{2L,0x77DC1A4FL,8L,0x7BF1CC1CL,0xCCB98A17L,0x74F12713L,0x08FC8D1FL},{2L,0x8A6F8D2AL,3L,0x571592F3L,(-1L),0L,1L}},{{4L,3L,0x92017A1BL,0x38C9E105L,0x7BF1CC1CL,0x88020F57L,5L},{0x7BF1CC1CL,(-1L),0L,0x78B5A455L,5L,(-1L),0x835FBC13L},{(-1L),0L,0L,0L,0L,(-1L),0L},{(-1L),0x3D2FE6F7L,1L,3L,0xC14CCFD7L,0L,0x2F71711FL}},{{1L,0x787EDD2CL,1L,0x651280DBL,8L,0x92017A1BL,0x7639893BL},{(-10L),0x3D2FE6F7L,1L,(-1L),0L,(-1L),1L},{0x52681015L,0L,2L,(-1L),0x88020F57L,0x0AF78BCDL,0L},{7L,(-1L),0x0AF78BCDL,1L,0xB9488037L,1L,0L}},{{(-1L),3L,0x2DFF457AL,0x787EDD2CL,1L,0L,0x8D6AEC21L},{0x27A80343L,0x8A6F8D2AL,6L,0x2DFF457AL,1L,8L,(-1L)},{(-1L),0x77DC1A4FL,6L,1L,(-1L),1L,0x34D5741FL},{6L,0x571592F3L,0x2DFF457AL,1L,0x78B5A455L,0x52681015L,0x3D2FE6F7L}}};\r\n uint8_t l_461 = 0xE6L;\r\n int i, j, k;\r\n for (g_185 = 0; (g_185 <= 2); g_185 += 1)\r\n { \r\n int32_t l_358[8][2] = {{0xC6A9D3CAL,(-5L)},{0x33E30AB4L,0x33E30AB4L},{(-5L),0xC6A9D3CAL},{0x356F701CL,0xC6A9D3CAL},{(-5L),0x33E30AB4L},{0x33E30AB4L,(-5L)},{0xC6A9D3CAL,0x356F701CL},{0xC6A9D3CAL,(-5L)}};\r\n uint8_t *l_364 = (void*)0;\r\n uint8_t *l_365[9][4][7] = {{{&g_185,&g_366[5][1],(void*)0,&g_185,&g_366[5][1],&g_366[5][1],(void*)0},{&g_185,&g_366[4][1],&g_185,&g_366[2][0],(void*)0,&g_366[5][1],&g_185},{(void*)0,&g_366[5][1],&g_366[1][0],&g_366[5][1],&g_366[1][0],&g_366[5][1],(void*)0},{&g_185,&g_366[5][1],(void*)0,&g_366[2][0],&g_185,&g_366[4][1],&g_185}},{{(void*)0,&g_366[5][1],&g_366[5][1],&g_185,(void*)0,&g_366[5][1],&g_185},{&g_366[5][1],&g_366[5][1],(void*)0,&g_185,&g_366[5][1],&g_366[5][1],&g_366[5][1]},{&g_366[5][1],&g_366[5][1],&g_366[5][1],&g_366[5][1],&g_366[5][1],&g_366[1][1],&g_185},{&g_366[2][0],&g_185,&g_366[5][1],&g_366[4][1],&g_366[5][1],&g_185,&g_366[5][1]}},{{(void*)0,&g_366[5][1],&g_366[1][1],&g_366[5][1],&g_366[4][0],&g_366[5][1],(void*)0},{&g_366[2][0],&g_366[4][1],&g_366[5][1],&g_185,&g_366[5][1],&g_366[5][1],&g_185},{&g_366[5][1],&g_366[5][0],&g_366[5][1],&g_366[5][1],&g_366[0][1],&g_366[5][1],(void*)0},{&g_185,(void*)0,&g_366[5][1],&g_366[5][1],&g_366[2][0],&g_366[5][1],&g_366[5][1]}},{{&g_366[0][1],&g_185,&g_366[4][0],&g_366[5][1],&g_366[1][0],&g_366[5][1],&g_185},{&g_366[5][1],&g_366[5][1],&g_366[5][1],&g_185,&g_185,&g_366[5][1],&g_366[5][1]},{&g_366[1][1],&g_366[1][1],&g_366[0][1],&g_185,&g_366[1][0],&g_366[5][1],&g_366[5][1]},{&g_366[5][1],&g_185,&g_366[2][0],&g_366[5][1],&g_366[2][0],&g_185,&g_366[5][1]}},{{&g_366[5][1],&g_366[5][1],&g_366[1][0],&g_185,&g_366[0][1],&g_366[1][1],&g_366[1][1]},{&g_366[5][1],&g_366[5][1],&g_185,&g_185,&g_366[5][1],&g_366[5][1],&g_366[5][1]},{&g_185,&g_366[5][1],&g_366[1][0],&g_366[5][1],&g_366[4][0],&g_185,&g_366[0][1]},{&g_366[5][1],&g_366[5][1],&g_366[2][0],&g_366[5][1],&g_366[5][1],(void*)0,&g_185}},{{(void*)0,&g_366[5][1],&g_366[0][1],&g_366[5][1],&g_366[5][1],&g_366[5][0],&g_366[5][1]},{&g_185,&g_366[5][1],&g_366[5][1],&g_185,&g_366[5][1],&g_366[4][1],&g_366[2][0]},{(void*)0,&g_366[5][1],&g_366[4][0],&g_366[5][1],&g_366[1][1],&g_366[5][1],(void*)0},{&g_366[5][1],&g_185,&g_366[5][1],&g_366[4][1],&g_366[5][1],&g_185,&g_366[2][0]}},{{&g_185,&g_366[1][1],&g_366[5][1],&g_366[5][1],&g_366[5][1],&g_366[5][1],&g_366[5][1]},{&g_366[5][1],&g_366[5][1],&g_366[5][1],&g_366[5][1],&g_366[5][1],&g_185,&g_185},{&g_366[5][1],&g_185,&g_366[1][1],&g_366[5][1],(void*)0,&g_366[5][1],&g_366[0][1]},{&g_366[5][1],(void*)0,&g_366[5][1],&g_366[5][1],&g_366[5][1],&g_366[4][1],&g_366[5][1]}},{{&g_366[1][1],&g_366[5][0],&g_366[5][1],&g_185,&g_366[5][1],&g_366[5][0],&g_366[1][1]},{&g_366[5][1],&g_366[4][1],&g_366[5][1],&g_366[5][1],&g_366[5][1],(void*)0,&g_366[5][1]},{&g_366[0][1],&g_366[5][1],(void*)0,&g_366[5][1],&g_366[1][1],&g_185,&g_366[5][1]},{&g_185,&g_185,&g_366[5][1],&g_366[5][1],&g_366[5][1],&g_366[5][1],&g_366[5][1]}},{{&g_366[5][1],&g_366[5][1],&g_366[5][1],&g_366[5][1],&g_366[5][1],(void*)0,&g_366[5][1]},{&g_366[5][1],&g_366[5][1],&g_366[5][1],(void*)0,&g_185,&g_366[5][1],&g_185},{&g_366[0][1],&g_366[5][1],(void*)0,&g_185,&g_185,&g_366[1][1],&g_366[5][1]},{&g_366[5][1],(void*)0,&g_185,&g_366[5][1],&g_185,&g_185,&g_366[5][1]}}};\r\n const int64_t ***l_374 = &g_372;\r\n int32_t l_379 = 1L;\r\n int i, j, k;\r\n (***g_255) &= (p_9 , ((((safe_div_func_int32_t_s_s(((*l_312) = (safe_add_func_int16_t_s_s(p_9, (g_346[4] = ((*l_314) = 0x6B72L))))), ((safe_sub_func_int16_t_s_s(((g_380 = (safe_sub_func_uint64_t_u_u(((safe_rshift_func_uint64_t_u_s(((((!(safe_sub_func_int64_t_s_s((safe_mul_func_int16_t_s_s(0xB195L, l_358[2][0])), (safe_unary_minus_func_int8_t_s(g_157[5]))))) , ((safe_rshift_func_uint32_t_u_s((((safe_mod_func_uint64_t_u_u((l_358[7][1] = p_9), (((g_366[3][0]--) & (((((*l_374) = g_372) != ((safe_sub_func_int16_t_s_s((l_369 |= ((((**l_327) |= (safe_div_func_int16_t_s_s((g_157[7] , g_157[0]), 0x06ABL))) | g_31) , g_306)), p_9)) , (void*)0)) == 0UL) , p_9)) , p_9))) < g_341) >= g_33[1][0][8]), 17)) , 0x2338L)) ^ 65535UL) , g_94[1]), l_379)) & (*g_373)), 0x739DBB08F21F6146LL))) , g_31), 0L)) && l_381))) >= (-5L)) & 0L) ^ l_379));\r\n }\r\n for (g_165 = 0; (g_165 == (-6)); g_165 = safe_sub_func_int8_t_s_s(g_165, 3))\r\n { \r\n const int64_t ***l_396 = (void*)0;\r\n int64_t ****l_400 = (void*)0;\r\n int64_t ****l_401 = &l_397;\r\n int32_t l_406 = (-1L);\r\n const int8_t *l_411[4][10][5] = {{{&g_412,&g_412,&g_412,&g_412,&g_412},{(void*)0,&g_412,&g_412,&g_412,&g_412},{&g_412,&g_412,&g_412,&g_412,&g_412},{&g_412,&g_412,&g_412,&g_412,&g_412},{&g_412,(void*)0,&g_412,&g_412,&g_412},{&g_412,(void*)0,&g_412,(void*)0,&g_412},{&g_412,&g_412,&g_412,(void*)0,&g_412},{&g_412,&g_412,&g_412,&g_412,(void*)0},{&g_412,&g_412,&g_412,&g_412,&g_412},{(void*)0,&g_412,&g_412,&g_412,&g_412}},{{&g_412,&g_412,&g_412,&g_412,&g_412},{(void*)0,&g_412,&g_412,&g_412,&g_412},{&g_412,&g_412,&g_412,&g_412,&g_412},{&g_412,&g_412,&g_412,&g_412,&g_412},{&g_412,(void*)0,&g_412,&g_412,&g_412},{&g_412,(void*)0,&g_412,(void*)0,&g_412},{&g_412,&g_412,&g_412,(void*)0,&g_412},{&g_412,&g_412,&g_412,&g_412,(void*)0},{&g_412,&g_412,&g_412,&g_412,&g_412},{(void*)0,&g_412,&g_412,&g_412,&g_412}},{{&g_412,&g_412,&g_412,&g_412,&g_412},{(void*)0,&g_412,&g_412,&g_412,&g_412},{&g_412,&g_412,&g_412,&g_412,&g_412},{&g_412,&g_412,&g_412,&g_412,&g_412},{&g_412,(void*)0,&g_412,&g_412,&g_412},{&g_412,(void*)0,&g_412,(void*)0,&g_412},{&g_412,&g_412,&g_412,(void*)0,&g_412},{&g_412,&g_412,&g_412,&g_412,(void*)0},{&g_412,&g_412,&g_412,&g_412,&g_412},{(void*)0,&g_412,&g_412,&g_412,&g_412}},{{&g_412,&g_412,&g_412,&g_412,&g_412},{(void*)0,&g_412,&g_412,&g_412,&g_412},{&g_412,&g_412,&g_412,&g_412,&g_412},{&g_412,&g_412,&g_412,&g_412,(void*)0},{&g_412,&g_412,&g_412,&g_412,&g_412},{&g_412,&g_412,&g_412,&g_412,(void*)0},{(void*)0,&g_412,&g_412,&g_412,&g_412},{(void*)0,&g_412,&g_412,(void*)0,&g_412},{&g_412,&g_412,&g_412,&g_412,&g_412},{&g_412,(void*)0,&g_412,&g_412,&g_412}}};\r\n const int8_t **l_410[5][8][6] = {{{&l_411[2][7][3],&l_411[2][7][3],&l_411[2][7][3],&l_411[2][7][3],&l_411[3][7][3],&l_411[2][7][3]},{&l_411[3][5][2],&l_411[2][7][3],&l_411[3][4][4],&l_411[2][7][3],&l_411[2][7][3],(void*)0},{(void*)0,&l_411[2][7][3],(void*)0,&l_411[2][7][3],&l_411[2][7][3],&l_411[2][7][3]},{&l_411[3][5][2],&l_411[0][2][2],&l_411[2][7][3],&l_411[2][7][3],&l_411[3][3][1],&l_411[2][7][3]},{&l_411[2][7][3],&l_411[0][3][1],&l_411[0][7][3],&l_411[2][3][0],&l_411[2][7][3],&l_411[2][7][3]},{(void*)0,&l_411[2][8][1],&l_411[2][7][3],&l_411[2][7][3],(void*)0,&l_411[2][7][3]},{&l_411[2][7][3],&l_411[3][1][4],&l_411[2][7][3],&l_411[2][7][3],&l_411[2][7][3],&l_411[2][7][3]},{&l_411[0][8][2],&l_411[2][7][3],&l_411[0][7][3],&l_411[2][7][3],&l_411[0][7][3],&l_411[2][7][3]}},{{&l_411[2][7][3],&l_411[2][7][3],&l_411[2][7][3],&l_411[2][7][3],(void*)0,&l_411[2][7][3]},{&l_411[2][7][3],(void*)0,(void*)0,&l_411[0][2][2],&l_411[2][7][3],(void*)0},{&l_411[2][7][3],(void*)0,&l_411[3][4][4],&l_411[3][1][4],(void*)0,&l_411[2][7][3]},{&l_411[1][2][4],&l_411[2][7][3],&l_411[2][7][3],&l_411[0][3][1],&l_411[0][7][3],&l_411[2][3][0]},{&l_411[3][3][1],&l_411[2][7][3],&l_411[2][7][3],&l_411[2][7][3],&l_411[2][7][3],&l_411[2][7][3]},{&l_411[3][2][0],&l_411[3][1][4],&l_411[3][7][3],&l_411[2][7][3],(void*)0,&l_411[2][8][1]},{&l_411[3][2][0],&l_411[2][8][1],(void*)0,&l_411[2][7][3],&l_411[2][7][3],&l_411[3][6][3]},{&l_411[3][3][1],&l_411[0][3][1],&l_411[2][7][3],&l_411[0][3][1],&l_411[3][3][1],&l_411[2][7][3]}},{{&l_411[1][2][4],&l_411[0][2][2],&l_411[2][7][3],&l_411[3][1][4],&l_411[2][7][3],&l_411[1][1][3]},{&l_411[2][7][3],&l_411[2][7][3],&l_411[2][7][3],&l_411[0][2][2],&l_411[2][7][3],&l_411[1][1][3]},{&l_411[2][7][3],&l_411[2][7][3],&l_411[2][7][3],&l_411[2][7][3],&l_411[3][7][3],&l_411[2][7][3]},{&l_411[2][7][3],&l_411[2][7][3],&l_411[2][7][3],&l_411[2][7][3],&l_411[2][7][3],&l_411[3][6][3]},{&l_411[0][8][2],(void*)0,(void*)0,&l_411[2][7][3],&l_411[3][5][2],&l_411[2][8][1]},{&l_411[2][7][3],&l_411[2][7][3],&l_411[3][7][3],&l_411[2][7][3],&l_411[3][5][2],&l_411[2][7][3]},{(void*)0,(void*)0,&l_411[2][7][3],&l_411[2][3][0],&l_411[2][7][3],&l_411[2][3][0]},{&l_411[2][7][3],&l_411[2][7][3],&l_411[2][7][3],&l_411[2][7][3],&l_411[3][7][3],&l_411[2][7][3]}},{{&l_411[3][5][2],&l_411[2][7][3],&l_411[3][4][4],&l_411[2][7][3],&l_411[2][7][3],(void*)0},{(void*)0,&l_411[2][7][3],(void*)0,&l_411[2][7][3],&l_411[2][7][3],&l_411[2][7][3]},{&l_411[3][5][2],&l_411[0][2][2],&l_411[2][7][3],&l_411[2][7][3],(void*)0,&l_411[2][7][3]},{(void*)0,&l_411[2][7][3],&l_411[2][7][3],&l_411[0][3][1],&l_411[1][2][4],(void*)0},{&l_411[3][5][2],&l_411[3][1][4],&l_411[1][2][4],&l_411[2][4][2],&l_411[2][7][3],&l_411[2][7][3]},{&l_411[3][3][1],&l_411[2][7][3],&l_411[1][2][4],&l_411[2][7][3],(void*)0,(void*)0},{&l_411[3][4][4],&l_411[2][7][3],&l_411[2][7][3],&l_411[1][1][3],&l_411[2][7][3],&l_411[2][7][3]},{&l_411[2][7][3],&l_411[2][7][3],&l_411[2][7][3],&l_411[2][8][1],(void*)0,&l_411[2][7][3]}},{{&l_411[2][7][3],&l_411[2][3][0],&l_411[3][5][2],&l_411[2][7][3],&l_411[2][7][3],&l_411[2][7][3]},{&l_411[2][7][3],&l_411[2][3][0],(void*)0,&l_411[2][7][3],(void*)0,&l_411[0][2][2]},{&l_411[2][7][3],&l_411[2][7][3],(void*)0,&l_411[2][7][3],&l_411[2][7][3],&l_411[0][3][1]},{(void*)0,&l_411[2][7][3],&l_411[3][3][1],&l_411[0][2][2],(void*)0,&l_411[2][8][1]},{&l_411[2][7][3],&l_411[2][7][3],&l_411[0][7][3],(void*)0,&l_411[2][7][3],&l_411[3][1][4]},{&l_411[2][7][3],&l_411[3][1][4],&l_411[2][7][3],&l_411[0][2][2],&l_411[1][2][4],&l_411[2][7][3]},{(void*)0,&l_411[2][7][3],&l_411[2][7][3],&l_411[2][7][3],(void*)0,&l_411[2][7][3]},{&l_411[2][7][3],&l_411[2][7][3],&l_411[3][7][3],&l_411[2][7][3],&l_411[2][7][3],(void*)0}}};\r\n int32_t **l_418 = &l_338[6];\r\n int32_t ***l_419[4][2] = {{&l_23,&l_418},{&l_23,&l_418},{&l_23,&l_418},{&l_23,&l_418}};\r\n int i, j, k;\r\n l_333 ^= (((safe_rshift_func_int64_t_s_u((p_9 , ((((((g_407 |= (l_369 = (safe_mod_func_int64_t_s_s(((0xA2936E82L == ((safe_add_func_uint32_t_u_u((safe_mod_func_uint8_t_u_u(l_368, (((((((p_9 , (safe_mod_func_int64_t_s_s((safe_mod_func_int8_t_s_s((l_396 != ((*l_401) = l_397)), (safe_lshift_func_uint32_t_u_s((g_311 || ((safe_lshift_func_uint8_t_u_u((p_9 <= p_9), 4)) | (*g_373))), 31)))), 1L))) && p_9) , &g_373) == &l_399) & (-2L)) , g_313) , g_149))), l_406)) | (-7L))) || g_33[2][0][6]), 0xE09499CAD8E44A95LL)))) ^ p_9) > (*g_169)) || p_9) , g_94[2]) >= (-1L))), 54)) , (*l_312)) | p_9);\r\n (*g_169) = (((*l_314) = (((g_408 = &g_165) != (g_415[6][0] = (l_413 = (void*)0))) <= ((((((*g_255) = l_417) != (l_420 = (l_23 = l_418))) | (l_368 ^= ((((*l_319) = ((((((p_9 | ((safe_mul_func_uint16_t_u_u(0x7263L, (&g_373 == ((**l_401) = (*l_397))))) < ((&g_372 != l_423) & 0x5FL))) && g_414) , p_9) , (*g_372)) != (void*)0) ^ g_185)) && g_426) >= 0x0347D94C0175571CLL))) & p_9) , g_366[5][1]))) == g_414);\r\n if (p_9)\r\n break;\r\n if ((*g_169))\r\n continue;\r\n }\r\n if ((((*l_425) = (p_9 , p_9)) ^ p_9))\r\n { \r\n int32_t *l_434 = &l_24[0];\r\n l_434 = ((safe_unary_minus_func_int64_t_s((safe_rshift_func_uint32_t_u_s((safe_add_func_int32_t_s_s((safe_lshift_func_uint16_t_u_u(5UL, 10)), 4294967293UL)), 24)))) , &g_313);\r\n (*l_23) = (*l_23);\r\n (*l_23) = l_434;\r\n (*l_23) = l_434;\r\n }\r\n else\r\n { \r\n int8_t ***l_437 = (void*)0;\r\n int8_t ***l_438[3];\r\n int32_t l_443 = (-7L);\r\n int32_t l_459[8][9][1] = {{{0x6734A3A9L},{0x17C83ADDL},{0x328560B7L},{1L},{0x220AB6B7L},{1L},{0x220AB6B7L},{1L},{0x328560B7L}},{{0x17C83ADDL},{0x6734A3A9L},{0x7340F128L},{6L},{0x8A5B444AL},{0x553E4A9CL},{6L},{0x71E29F3CL},{6L}},{{0x553E4A9CL},{0x8A5B444AL},{6L},{0x7340F128L},{0x6734A3A9L},{0x17C83ADDL},{0x328560B7L},{1L},{0x220AB6B7L}},{{1L},{0x220AB6B7L},{1L},{0x328560B7L},{0x17C83ADDL},{0x6734A3A9L},{0x7340F128L},{6L},{0x8A5B444AL}},{{0x553E4A9CL},{6L},{0x71E29F3CL},{6L},{0x553E4A9CL},{0x8A5B444AL},{6L},{0x7340F128L},{0x6734A3A9L}},{{0x17C83ADDL},{0x328560B7L},{1L},{0x220AB6B7L},{1L},{0x220AB6B7L},{1L},{0x328560B7L},{0x17C83ADDL}},{{0x6734A3A9L},{0x7340F128L},{6L},{0x8A5B444AL},{0x553E4A9CL},{6L},{0x71E29F3CL},{6L},{0x553E4A9CL}},{{0x8A5B444AL},{6L},{0x7340F128L},{0x6734A3A9L},{0x17C83ADDL},{0x328560B7L},{1L},{0x220AB6B7L},{1L}}};\r\n int16_t * const l_467 = &g_168;\r\n int i, j, k;\r\n for (i = 0; i < 3; i++)\r\n l_438[i] = &l_327;\r\n l_443 = (((safe_div_func_uint32_t_u_u((&g_415[6][0] == (l_327 = &g_408)), (l_333 = 1L))) & ((safe_lshift_func_int8_t_s_s((safe_sub_func_int16_t_s_s(l_443, ((~((!(l_417 != l_420)) | (0x38L ^ ((safe_sub_func_uint64_t_u_u((safe_sub_func_uint16_t_u_u((((safe_add_func_int8_t_s_s((((*l_314) = (safe_mul_func_int64_t_s_s(((*l_425) ^= (*g_373)), (g_457 = (safe_add_func_int64_t_s_s((((~l_443) | p_9) , (*g_373)), g_11[1])))))) , 9L), 0xE4L)) , g_346[4]) , 0x1284L), p_9)), 0x1264E6488AB867F8LL)) , 0xF8L)))) , g_380))), 1)) , (*g_408))) & (-8L));\r\n l_461--;\r\n (*l_312) ^= (((g_466[8][2][1] = &g_168) == l_467) < ((safe_rshift_func_int32_t_s_u((p_9 != (safe_add_func_int64_t_s_s((safe_rshift_func_int8_t_s_s((safe_rshift_func_int16_t_s_u((safe_rshift_func_int16_t_s_s(((safe_add_func_int32_t_s_s((safe_sub_func_uint16_t_u_u(p_9, ((++(*l_314)) & (~((safe_div_func_int32_t_s_s((safe_rshift_func_int16_t_s_s((((*l_30) = l_443) & (((safe_lshift_func_uint16_t_u_u((+((safe_mul_func_uint8_t_u_u((--(*l_319)), l_496[1][1])) | ((safe_add_func_uint8_t_u_u((((*l_32) = p_9) <= (l_326[7] == &g_346[2])), 0xA6L)) , p_9))), 13)) , p_9) < l_443)), p_9)), 9UL)) | g_11[1]))))), p_9)) , 0x32F2L), g_416[3][4])), g_66[3][3])), 2)), p_9))), 31)) == (*g_373)));\r\n (*g_169) ^= p_9;\r\n }\r\n }\r\n (*g_169) = p_9;\r\n ++l_499;\r\n }\r\n else\r\n { \r\n int64_t *l_512[8] = {(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0};\r\n int32_t l_513[4];\r\n int64_t l_524[6][10][4] = {{{0x4C3D815AE43813BALL,0xF0C6CFC406DFDF2ALL,0x082E0D4638A26EFBLL,1L},{0xC881B6CB4CC4A5C9LL,0xE4DE13E2542AFC13LL,(-5L),0x2E1C39099BE1D503LL},{(-2L),(-1L),0xC881B6CB4CC4A5C9LL,(-1L)},{0xCD7E5718D9CE495DLL,0x25989EA0395394D5LL,0x25989EA0395394D5LL,0xCD7E5718D9CE495DLL},{0xF0C6CFC406DFDF2ALL,0xF884BC59129141D1LL,(-1L),(-1L)},{9L,0xE1735034541A91DALL,1L,0x082E0D4638A26EFBLL},{(-2L),3L,0xC42F5F76941C79BDLL,0x082E0D4638A26EFBLL},{0x25989EA0395394D5LL,0xE1735034541A91DALL,1L,0x19EE989D2DF288E2LL},{0xCF630E151FD4A638LL,1L,0x4C3D815AE43813BALL,(-3L)},{(-1L),(-7L),9L,0xE4DE13E2542AFC13LL}},{{1L,0x19EE989D2DF288E2LL,1L,0xCF630E151FD4A638LL},{0L,(-5L),0xA72890E95F62B265LL,0xE1735034541A91DALL},{0xCD7E5718D9CE495DLL,0xA726B99D96E26521LL,0L,0x49C30984D15A5727LL},{9L,(-1L),0L,(-1L)},{0xF884BC59129141D1LL,0xCD7E5718D9CE495DLL,0xF884BC59129141D1LL,3L},{3L,0xC881B6CB4CC4A5C9LL,0xE1735034541A91DALL,7L},{(-1L),0x082E0D4638A26EFBLL,(-10L),0xC881B6CB4CC4A5C9LL},{1L,0x2E1C39099BE1D503LL,(-10L),(-1L)},{(-1L),(-1L),0xE1735034541A91DALL,1L},{3L,(-1L),0xF884BC59129141D1LL,0x5333F827537ACEF5LL}},{{0xF884BC59129141D1LL,0x5333F827537ACEF5LL,0L,(-7L)},{9L,0x25989EA0395394D5LL,0L,1L},{0xCD7E5718D9CE495DLL,1L,0xA72890E95F62B265LL,0x4C3D815AE43813BALL},{0L,(-2L),1L,0L},{1L,0xC42F5F76941C79BDLL,9L,9L},{(-1L),(-1L),0x4C3D815AE43813BALL,(-2L)},{0xCF630E151FD4A638LL,0x49C30984D15A5727LL,1L,1L},{0x25989EA0395394D5LL,0L,0xC42F5F76941C79BDLL,1L},{(-2L),0L,1L,1L},{0L,0x49C30984D15A5727LL,0xE4DE13E2542AFC13LL,(-2L)}},{{0xA726B99D96E26521LL,(-1L),(-7L),9L},{(-3L),0xC42F5F76941C79BDLL,0xF0C6CFC406DFDF2ALL,0L},{(-1L),(-2L),0x5333F827537ACEF5LL,0x4C3D815AE43813BALL},{0xF0C6CFC406DFDF2ALL,1L,0x49C30984D15A5727LL,1L},{(-1L),0x25989EA0395394D5LL,1L,(-7L)},{0L,0x5333F827537ACEF5LL,(-1L),0x5333F827537ACEF5LL},{0x49C30984D15A5727LL,(-1L),0x2E1C39099BE1D503LL,1L},{(-7L),(-1L),0L,(-1L)},{(-2L),0x2E1C39099BE1D503LL,(-2L),0xC881B6CB4CC4A5C9LL},{(-2L),0x082E0D4638A26EFBLL,0L,7L}},{{(-7L),0xC881B6CB4CC4A5C9LL,0x2E1C39099BE1D503LL,3L},{0x49C30984D15A5727LL,0xCD7E5718D9CE495DLL,(-1L),(-1L)},{0L,(-1L),1L,0x49C30984D15A5727LL},{(-1L),0xA726B99D96E26521LL,0x49C30984D15A5727LL,0xE1735034541A91DALL},{0xF0C6CFC406DFDF2ALL,(-5L),0x5333F827537ACEF5LL,0xCF630E151FD4A638LL},{(-1L),0x19EE989D2DF288E2LL,0xF0C6CFC406DFDF2ALL,0xE4DE13E2542AFC13LL},{(-3L),(-7L),(-7L),(-3L)},{0xA726B99D96E26521LL,1L,0xE4DE13E2542AFC13LL,0x19EE989D2DF288E2LL},{0L,0xE1735034541A91DALL,1L,0x082E0D4638A26EFBLL},{(-2L),3L,0xC42F5F76941C79BDLL,0x082E0D4638A26EFBLL}},{{0x25989EA0395394D5LL,0xE1735034541A91DALL,1L,0x19EE989D2DF288E2LL},{0xCF630E151FD4A638LL,1L,0x4C3D815AE43813BALL,(-3L)},{(-1L),(-7L),9L,0xE4DE13E2542AFC13LL},{0xE1735034541A91DALL,(-1L),(-1L),0L},{(-2L),0x5333F827537ACEF5LL,0x4C3D815AE43813BALL,3L},{(-3L),0x2E1C39099BE1D503LL,7L,9L},{0L,0xF884BC59129141D1LL,0x25989EA0395394D5LL,0xE4DE13E2542AFC13LL},{1L,(-3L),1L,(-10L)},{(-10L),0xF0C6CFC406DFDF2ALL,3L,(-1L)},{1L,0x49C30984D15A5727LL,1L,0xF0C6CFC406DFDF2ALL}}};\r\n int16_t l_549 = 8L;\r\n int8_t l_567 = 0x65L;\r\n int i, j, k;\r\n for (i = 0; i < 4; i++)\r\n l_513[i] = 0x50CAB1D2L;\r\n (*g_169) |= 1L;\r\n for (g_12 = 0; (g_12 != 9); g_12++)\r\n { \r\n for (g_426 = 17; (g_426 == (-2)); g_426 = safe_sub_func_uint16_t_u_u(g_426, 3))\r\n { \r\n uint8_t l_523[10][4][6] = {{{0xF4L,0x83L,0UL,0xF4L,0xF1L,0x11L},{255UL,0xF4L,0UL,0xF4L,255UL,0xB7L},{0xF4L,255UL,0xB7L,0xC9L,255UL,0x6DL},{0x83L,0xF4L,0xF1L,255UL,0xF1L,0x6DL}},{{0xF1L,0x83L,0xB7L,0x11L,0x11L,0xB7L},{0xF1L,0xF1L,0UL,255UL,253UL,0x11L},{0x83L,0xF1L,0UL,0xC9L,0x11L,0UL},{0xF4L,0x83L,0UL,0xF4L,0xF1L,0x11L}},{{255UL,0xF4L,0UL,0xF4L,255UL,0xB7L},{0xF4L,255UL,0xB7L,0xC9L,255UL,0x6DL},{0x83L,0xF4L,0xF1L,255UL,0xF1L,0x6DL},{0xF1L,0x83L,0xB7L,0x11L,0x11L,0xB7L}},{{0xF1L,0xF1L,0UL,255UL,253UL,0x11L},{0x83L,0xF1L,0UL,0xC9L,0x11L,0UL},{0xF4L,0x83L,0UL,0xF4L,0xF1L,0x11L},{255UL,0xF4L,0UL,0xF4L,255UL,0xB7L}},{{0xF4L,255UL,0xB7L,0xC9L,255UL,0x6DL},{0x83L,0xF4L,0xF1L,255UL,0xF1L,0x6DL},{0xF1L,0x83L,0xB7L,0x11L,0x11L,0xB7L},{0xF1L,0xF1L,0UL,255UL,253UL,0x11L}},{{0x83L,0xF1L,0UL,0xC9L,0x11L,0UL},{0xF4L,0x83L,0UL,0xF4L,0xF1L,0x11L},{255UL,0xF4L,0UL,0xF4L,255UL,0xB7L},{0xF4L,255UL,0xB7L,0xC9L,255UL,0x6DL}},{{0x83L,0xF4L,0xF1L,255UL,0xF1L,0x6DL},{0xF1L,0x83L,0xB7L,0x11L,0x11L,0xB7L},{0xF1L,0xF1L,0UL,255UL,253UL,0x11L},{0x83L,0x79L,255UL,255UL,0x80L,0xF1L}},{{8UL,1UL,255UL,8UL,0x79L,0xC9L},{253UL,8UL,0xF1L,8UL,253UL,0x11L},{8UL,253UL,0x11L,255UL,253UL,0x83L},{1UL,8UL,253UL,253UL,0x79L,0x83L}},{{0x79L,1UL,0x11L,0x80L,0x80L,0x11L},{0x79L,0x79L,0xF1L,253UL,0x5FL,0xC9L},{1UL,0x79L,255UL,255UL,0x80L,0xF1L},{8UL,1UL,255UL,8UL,0x79L,0xC9L}},{{253UL,8UL,0xF1L,8UL,253UL,0x11L},{8UL,253UL,0x11L,255UL,253UL,0x83L},{1UL,8UL,253UL,253UL,0x79L,0x83L},{0x79L,1UL,0x11L,0x80L,0x80L,0x11L}}};\r\n int i, j, k;\r\n (**g_256) = ((safe_div_func_int8_t_s_s(1L, ((p_9 , ((safe_sub_func_int32_t_s_s(p_9, ((safe_add_func_int16_t_s_s((l_512[7] == (void*)0), ((*l_310) = (g_165 | l_513[1])))) | (safe_add_func_uint64_t_u_u(p_9, (safe_sub_func_uint32_t_u_u((safe_sub_func_int8_t_s_s(((!(safe_add_func_uint64_t_u_u(((p_9 <= 0L) ^ g_33[8][0][8]), (-1L)))) < l_513[0]), g_149)), l_513[1]))))))) , (-1L))) && g_426))) ^ l_523[3][2][5]);\r\n return l_524[3][2][1];\r\n }\r\n for (g_426 = 0; (g_426 < 8); g_426++)\r\n { \r\n (**g_255) = &l_513[2];\r\n }\r\n }\r\n for (g_426 = 26; (g_426 == 5); g_426 = safe_sub_func_uint8_t_u_u(g_426, 8))\r\n { \r\n int32_t l_534 = (-1L);\r\n int32_t l_536 = 0xD26B6040L;\r\n uint64_t l_537 = 18446744073709551610UL;\r\n for (g_407 = 25; (g_407 < 30); g_407 = safe_add_func_uint64_t_u_u(g_407, 8))\r\n { \r\n uint16_t l_533 = 0xD203L;\r\n int32_t l_535 = (-4L);\r\n (**g_256) = (safe_add_func_uint16_t_u_u((l_533 != (((l_533 > p_9) > p_9) ^ l_533)), l_513[1]));\r\n l_537++;\r\n return l_535;\r\n }\r\n for (l_537 = 0; (l_537 >= 29); l_537++)\r\n { \r\n uint32_t *l_564[5][7][7] = {{{&g_94[2],&g_380,&g_149,&g_380,&g_94[0],&g_380,&g_149},{&g_149,&g_149,(void*)0,&g_94[2],&g_380,&g_94[2],&g_380},{&g_94[1],&g_149,&g_149,&g_94[2],&g_94[2],&g_380,&g_380},{&g_94[2],&g_380,&g_380,&g_94[0],&g_380,&g_94[2],&g_149},{&g_94[2],&g_94[2],&g_94[2],(void*)0,&g_94[0],(void*)0,&g_149},{&g_94[1],&g_149,&g_94[2],&g_94[0],&g_149,(void*)0,&g_149},{&g_149,&g_94[2],(void*)0,&g_94[2],&g_94[2],(void*)0,&g_149}},{{&g_94[2],&g_380,&g_94[2],&g_94[2],&g_94[0],(void*)0,&g_380},{&g_94[2],&g_94[2],&g_94[2],&g_380,&g_380,(void*)0,&g_380},{&g_380,&g_380,&g_380,&g_94[2],&g_380,(void*)0,&g_149},{&g_94[2],&g_94[2],&g_149,&g_380,&g_94[0],&g_94[2],&g_149},{&g_380,&g_149,(void*)0,&g_380,&g_94[2],&g_380,(void*)0},{&g_94[2],&g_94[2],&g_149,&g_94[2],&g_149,&g_94[2],&g_149},{&g_94[2],&g_380,&g_149,&g_380,&g_94[0],&g_380,&g_149}},{{&g_149,&g_149,(void*)0,&g_94[2],&g_380,&g_94[2],&g_380},{&g_94[1],&g_149,&g_149,&g_94[2],&g_94[2],&g_380,&g_380},{&g_94[2],&g_380,&g_94[2],&g_94[0],&g_94[0],&g_94[2],&g_149},{&g_380,&g_149,&g_380,&g_149,&g_380,&g_149,&g_94[2]},{&g_94[2],(void*)0,&g_149,&g_94[0],&g_94[1],&g_380,&g_94[2]},{&g_94[0],&g_380,&g_94[2],&g_94[2],&g_149,&g_149,&g_149},{&g_149,&g_94[2],&g_149,&g_380,&g_94[2],&g_149,&g_94[2]}},{{&g_94[2],(void*)0,&g_380,&g_94[2],(void*)0,&g_380,&g_94[1]},{&g_380,&g_94[2],&g_94[2],&g_94[2],(void*)0,&g_149,&g_380},{&g_149,&g_380,&g_94[2],&g_149,&g_94[2],&g_94[2],&g_94[2]},{&g_380,(void*)0,&g_94[2],&g_149,&g_149,&g_380,&g_149},{&g_94[2],&g_149,&g_380,&g_94[2],&g_94[1],&g_94[2],&g_94[2]},{&g_149,&g_380,&g_380,&g_94[2],&g_380,&g_94[2],&g_380},{&g_94[0],&g_94[0],&g_94[2],&g_380,&g_94[0],&g_94[2],&g_94[1]}},{{&g_94[2],&g_94[0],&g_94[2],&g_94[2],&g_94[2],&g_380,&g_94[2]},{&g_380,&g_380,&g_94[2],&g_94[0],&g_94[0],&g_94[2],&g_149},{&g_380,&g_149,&g_380,&g_149,&g_380,&g_149,&g_94[2]},{&g_94[2],(void*)0,&g_149,&g_94[0],&g_94[1],&g_380,&g_94[2]},{&g_94[0],&g_380,&g_94[2],&g_94[2],&g_149,&g_149,&g_149},{&g_149,&g_94[2],&g_149,&g_380,&g_94[2],&g_149,&g_94[2]},{&g_94[2],(void*)0,&g_380,&g_94[2],(void*)0,&g_380,&g_94[1]}}};\r\n int32_t l_565 = 0x56C2B96EL;\r\n uint16_t l_566[10][7] = {{0x136DL,0UL,0x0D3AL,0UL,0x136DL,0xF559L,4UL},{0UL,0UL,0xE1E7L,0x5533L,2UL,0x5533L,0xE1E7L},{4UL,4UL,0UL,0x0D3AL,0xFD06L,0xFB9BL,0xF306L},{0UL,0x5533L,1UL,1UL,0x5533L,0UL,2UL},{0x136DL,0UL,0UL,0xDCD5L,0xFD06L,0xFD06L,0xDCD5L},{2UL,0x92D3L,2UL,65535UL,2UL,0xE80DL,0UL},{0UL,0UL,0x136DL,0xFB9BL,0x136DL,0UL,0UL},{1UL,0x5533L,0UL,2UL,0x852DL,0xE80DL,0x852DL},{0UL,4UL,4UL,4UL,0xF559L,0x136DL,0UL},{0x92D3L,0xE80DL,2UL,0x5533L,0x5533L,2UL,0xE80DL}};\r\n int i, j, k;\r\n l_567 = (safe_div_func_int32_t_s_s(((*l_312) ^= (!(**g_372))), (safe_lshift_func_int32_t_s_s((p_9 == ((((((*l_314) ^= l_549) || (((--(*l_30)) && ((*g_373) >= (safe_sub_func_uint8_t_u_u(p_9, ((*l_319) = (((safe_mod_func_int64_t_s_s(((*l_425) = (safe_mod_func_uint16_t_u_u(((l_536 = ((safe_mul_func_uint16_t_u_u(g_346[3], (((((safe_sub_func_int8_t_s_s((safe_add_func_uint32_t_u_u((&g_380 != l_564[2][0][2]), ((0xDD250ABB124CD325LL < g_409) >= (*g_373)))), g_407)) , (*g_373)) < l_565) , &g_185) != (void*)0))) , p_9)) < p_9), p_9))), 0xEEC46540531036A0LL)) == 4294967288UL) < g_412)))))) != 0x6A948BE95CCE685BLL)) != p_9) , l_566[0][3]) , g_366[3][0])), p_9))));\r\n (**g_256) |= ((void*)0 != &g_407);\r\n if (p_9)\r\n break;\r\n }\r\n }\r\n }\r\n return p_9;\r\n}\r\n\r\n\r\n\r\n\r\nstatic int16_t func_15(int8_t p_16, uint32_t p_17, int32_t p_18)\r\n{ \r\n uint16_t l_43[8][6] = {{4UL,0x864FL,65527UL,0x864FL,4UL,65527UL},{0x864FL,4UL,65527UL,0x11FBL,0x11FBL,65527UL},{0x11FBL,0x11FBL,65527UL,4UL,0x864FL,65527UL},{4UL,0x864FL,65527UL,0x864FL,4UL,65527UL},{0x864FL,4UL,65527UL,0x11FBL,0x11FBL,65527UL},{0x11FBL,0x11FBL,65527UL,4UL,0x864FL,65527UL},{4UL,0x864FL,65527UL,0x864FL,4UL,65527UL},{0x864FL,4UL,65527UL,0x11FBL,0x11FBL,65527UL}};\r\n int32_t l_54 = 1L;\r\n int32_t l_55 = 0x1814A667L;\r\n int32_t l_57 = 0xF053B50BL;\r\n int32_t l_58[8];\r\n int64_t *l_83 = &g_66[3][3];\r\n int32_t l_106[2];\r\n int32_t *l_111 = (void*)0;\r\n int32_t **l_110[9] = {(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0};\r\n int32_t ***l_109 = &l_110[8];\r\n const int32_t l_145 = (-1L);\r\n int64_t *l_156 = &g_157[0];\r\n int8_t *l_164 = &g_165;\r\n uint16_t l_166 = 4UL;\r\n int16_t *l_167 = &g_168;\r\n int64_t *l_171 = (void*)0;\r\n int64_t *l_172 = &g_157[8];\r\n uint32_t l_196 = 4294967295UL;\r\n uint16_t l_199 = 4UL;\r\n int8_t l_288 = 0L;\r\n int8_t l_291 = (-5L);\r\n uint32_t l_302 = 18446744073709551615UL;\r\n int i, j;\r\n for (i = 0; i < 8; i++)\r\n l_58[i] = 0xE0FBC7DBL;\r\n for (i = 0; i < 2; i++)\r\n l_106[i] = (-1L);\r\nlbl_244:\r\n for (g_31 = 0; (g_31 <= 0); g_31 += 1)\r\n { \r\n int32_t l_52[5] = {0x50B10B9BL,0x50B10B9BL,0x50B10B9BL,0x50B10B9BL,0x50B10B9BL};\r\n uint16_t l_108 = 1UL;\r\n int i;\r\n if (g_11[(g_31 + 1)])\r\n break;\r\n if (g_11[(g_31 + 1)])\r\n break;\r\n for (p_18 = 0; (p_18 <= 0); p_18 += 1)\r\n { \r\n int32_t *l_38 = &g_11[(g_31 + 1)];\r\n int32_t l_53 = 0x2DAC39F6L;\r\n int32_t l_56[8][5][2] = {{{0xEDC4196DL,0x55470A06L},{0xFFFF0E59L,0L},{6L,0xEDC4196DL},{(-1L),9L},{2L,0x62CF0DA5L}},{{0x2A43FB2FL,0xFFFF0E59L},{0x7A36831AL,0x7A36831AL},{(-1L),6L},{0x28A4BD3CL,0xEF314FBCL},{0xFB4D153BL,0L}},{{0x1831F773L,0xFB4D153BL},{9L,0x0066401EL},{9L,0xFB4D153BL},{0x1831F773L,0L},{0xFB4D153BL,0xEF314FBCL}},{{0x28A4BD3CL,6L},{(-1L),0x7A36831AL},{0x7A36831AL,0xFFFF0E59L},{0x2A43FB2FL,0x62CF0DA5L},{2L,9L}},{{(-1L),0xEDC4196DL},{6L,0L},{0xFFFF0E59L,0x55470A06L},{0xEDC4196DL,0x55470A06L},{0xFFFF0E59L,0L}},{{6L,0xEDC4196DL},{(-1L),9L},{2L,0x62CF0DA5L},{0x2A43FB2FL,0xFFFF0E59L},{0x7A36831AL,0x7A36831AL}},{{(-1L),6L},{0x28A4BD3CL,0xEF314FBCL},{0xFB4D153BL,0L},{0x1831F773L,0xFB4D153BL},{9L,0x0066401EL}},{{9L,0xFB4D153BL},{0x1831F773L,0L},{0xFB4D153BL,0xEF314FBCL},{0x28A4BD3CL,6L},{(-1L),0x7A36831AL}}};\r\n uint8_t l_59[3];\r\n int i, j, k;\r\n for (i = 0; i < 3; i++)\r\n l_59[i] = 0x9FL;\r\n if (p_18)\r\n { \r\n const int32_t *l_34 = &g_11[0];\r\n int32_t *l_37 = &g_11[1];\r\n int32_t **l_36[5][1][4] = {{{&l_37,&l_37,&l_37,&l_37}},{{&l_37,&l_37,&l_37,&l_37}},{{&l_37,&l_37,&l_37,&l_37}},{{&l_37,&l_37,&l_37,&l_37}},{{&l_37,&l_37,&l_37,&l_37}}};\r\n int32_t ***l_39 = &l_36[3][0][1];\r\n int i, j, k;\r\n g_35 = l_34;\r\n g_11[g_31] = 0x10944B0CL;\r\n l_38 = &g_11[1];\r\n g_11[g_31] = (((*l_39) = (void*)0) == &l_38);\r\n }\r\n else\r\n { \r\n int32_t *l_40 = &g_11[0];\r\n int32_t *l_41 = &g_11[(g_31 + 1)];\r\n int32_t *l_42[3][7] = {{&g_11[(g_31 + 1)],&g_11[(g_31 + 1)],&g_11[1],&g_11[1],&g_11[(g_31 + 1)],&g_11[(g_31 + 1)],&g_11[1]},{&g_11[1],&g_11[(g_31 + 1)],&g_11[1],&g_11[(g_31 + 1)],&g_11[1],&g_11[(g_31 + 1)],&g_11[1]},{&g_11[(g_31 + 1)],&g_11[1],&g_11[1],&g_11[(g_31 + 1)],&g_11[(g_31 + 1)],&g_11[1],&g_11[1]}};\r\n int i, j;\r\n l_43[0][0]--;\r\n }\r\n for (p_17 = 0; (p_17 <= 0); p_17 += 1)\r\n { \r\n int32_t *l_46 = &g_11[1];\r\n int32_t *l_47 = &g_11[1];\r\n int32_t *l_48 = &g_11[1];\r\n int32_t *l_49 = &g_11[1];\r\n int32_t *l_50 = &g_11[0];\r\n int32_t *l_51[3][10] = {{(void*)0,(void*)0,&g_11[1],(void*)0,(void*)0,&g_11[1],(void*)0,(void*)0,&g_11[1],(void*)0},{(void*)0,&g_11[1],&g_11[1],(void*)0,&g_11[1],&g_11[1],(void*)0,&g_11[1],&g_11[1],(void*)0},{&g_11[1],(void*)0,&g_11[1],&g_11[1],(void*)0,&g_11[1],&g_11[1],(void*)0,&g_11[1],&g_11[1]}};\r\n int32_t **l_62[7][7] = {{&l_38,&l_38,&l_47,&l_38,&l_38,&l_47,&l_38},{(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0},{&l_51[1][6],&l_38,&l_51[1][6],&l_51[1][6],&l_38,&l_51[1][6],&l_51[1][6]},{(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0},{&l_38,&l_51[1][6],&l_51[1][6],&l_38,&l_51[1][6],&l_51[1][6],&l_38},{(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0},{&l_38,&l_38,&l_47,&l_38,&l_38,&l_47,&l_38}};\r\n int i, j;\r\n --l_59[0];\r\n g_35 = l_51[1][6];\r\n }\r\n if ((*l_38))\r\n continue;\r\n for (l_53 = 0; (l_53 <= 1); l_53 += 1)\r\n { \r\n int i, j, k;\r\n return l_56[(g_31 + 6)][(l_53 + 2)][p_18];\r\n }\r\n for (l_54 = 0; (l_54 >= 0); l_54 -= 1)\r\n { \r\n int64_t *l_65 = &g_66[3][3];\r\n int64_t **l_84 = (void*)0;\r\n int64_t **l_85 = &l_65;\r\n int64_t *l_87[8] = {&g_66[2][3],&g_66[4][1],&g_66[4][1],&g_66[2][3],&g_66[4][1],&g_66[4][1],&g_66[2][3],&g_66[4][1]};\r\n int64_t **l_86 = &l_87[7];\r\n uint32_t *l_93[3];\r\n int32_t l_104 = 0L;\r\n int32_t l_105[1];\r\n uint32_t l_107 = 0UL;\r\n int32_t l_112 = 0x2EFCB156L;\r\n int i;\r\n for (i = 0; i < 3; i++)\r\n l_93[i] = &g_94[2];\r\n for (i = 0; i < 1; i++)\r\n l_105[i] = 0L;\r\n l_112 &= ((((safe_mul_func_uint8_t_u_u(((((*l_65) &= 1L) , (safe_div_func_int32_t_s_s((safe_div_func_uint32_t_u_u((((((((safe_rshift_func_uint32_t_u_s(g_11[(g_31 + 1)], ((safe_div_func_int8_t_s_s(((((safe_mul_func_int64_t_s_s(((safe_sub_func_int16_t_s_s(p_16, (p_16 <= ((!(safe_mul_func_int64_t_s_s(((*l_83) = (~(l_105[0] ^= ((((*l_85) = l_83) == ((*l_86) = (void*)0)) >= ((((((+(safe_mul_func_uint8_t_u_u(0x1FL, (safe_sub_func_uint32_t_u_u((g_94[2]--), (+(safe_mul_func_int64_t_s_s(((safe_mod_func_uint32_t_u_u(g_11[1], (safe_sub_func_uint16_t_u_u(((g_12 <= g_11[(g_31 + 1)]) >= g_12), 7L)))) != p_16), l_55)))))))) == l_104) , 0x02DFE65AL) , p_17) , g_12) ^ 0xA833846322F5C3AALL))))), g_31))) < l_106[0])))) , l_107), 0UL)) , l_104) & 0x93ACL) > p_16), g_11[1])) , l_108))) , 4L) <= l_58[7]) , l_109) != (void*)0) & p_16) < p_16), 4294967291UL)), p_17))) & p_16), g_12)) != l_52[3]) , p_17) ^ 0x0A3500CD5182C662LL);\r\n }\r\n }\r\n }\r\n for (p_17 = 1; (p_17 <= 5); p_17 += 1)\r\n { \r\n int64_t * const *l_114 = (void*)0;\r\n int32_t l_115 = 0xC0B326B5L;\r\n int32_t l_122 = (-1L);\r\n int32_t l_128 = 3L;\r\n int32_t l_129 = (-6L);\r\n int32_t ***l_144 = &l_110[3];\r\n for (g_12 = 0; (g_12 <= 5); g_12 += 1)\r\n { \r\n int i, j;\r\n if (l_43[g_12][g_12])\r\n break;\r\n for (p_18 = 0; (p_18 <= 8); p_18 += 1)\r\n { \r\n return p_17;\r\n }\r\n for (g_31 = 0; (g_31 <= 7); g_31 += 1)\r\n { \r\n int i;\r\n l_58[g_31] = (~p_18);\r\n if (p_16)\r\n continue;\r\n g_11[1] = (((0x33A8E694L & p_18) , 0xE34AC405L) & (((void*)0 == l_114) , 0x7FEED684L));\r\n }\r\n }\r\n if (p_16)\r\n { \r\n uint64_t l_116 = 0xDCA698BDAB2CB753LL;\r\n int32_t l_119 = (-7L);\r\n int32_t l_123 = 0xDAE3C54FL;\r\n int32_t l_125 = 0x5C04B26AL;\r\n int32_t l_127[4][3] = {{1L,1L,0x4C425AE9L},{1L,1L,0x4C425AE9L},{1L,1L,0x4C425AE9L},{1L,1L,0x4C425AE9L}};\r\n uint32_t *l_146 = (void*)0;\r\n uint32_t *l_147 = (void*)0;\r\n uint32_t *l_148 = &g_149;\r\n int i, j;\r\n l_115 = l_115;\r\n for (p_18 = 1; (p_18 <= 5); p_18 += 1)\r\n { \r\n int16_t l_120 = 0xDB9CL;\r\n int32_t l_121 = 0x49656563L;\r\n int32_t l_124[1][4] = {{0x080E9152L,0x080E9152L,0x080E9152L,0x080E9152L}};\r\n int32_t l_126 = (-6L);\r\n uint16_t l_130 = 0x6C88L;\r\n int i, j;\r\n --l_116;\r\n l_130++;\r\n }\r\n g_11[0] = ((l_127[1][0] = ((1L ^ (safe_mod_func_int16_t_s_s(((g_94[1] , (safe_add_func_int16_t_s_s(((l_83 != &l_116) < ((((+((*l_148) ^= (g_94[1] = ((safe_mul_func_int32_t_s_s(((((safe_mul_func_int32_t_s_s((g_11[1] , (g_33[8][0][8] > (((((safe_mod_func_uint8_t_u_u(0xB6L, ((g_31 <= (((l_115 >= 1UL) < g_94[2]) < p_16)) , p_17))) , 0xB692CA01L) , &l_110[8]) == l_144) | g_94[2]))), g_31)) , (void*)0) != (void*)0) , p_17), l_145)) | 0x7FL)))) != 1L) != l_123) && p_17)), p_18))) || p_16), g_12))) || (-1L))) == 4294967292UL);\r\n }\r\n else\r\n { \r\n int32_t **l_150 = (void*)0;\r\n l_150 = (*l_144);\r\n }\r\n return g_33[6][0][7];\r\n }\r\n if (((g_66[3][3] && 0x44L) | (((*l_172) = (&g_11[0] == (g_170 = (g_169 = ((!(safe_lshift_func_int8_t_s_u(((safe_mul_func_uint8_t_u_u((g_12 , (((l_83 == (l_156 = l_83)) || g_94[1]) == (((*l_167) = (safe_div_func_uint16_t_u_u((0x63AD2DFDL > (safe_mul_func_int8_t_s_s(((*l_164) ^= (safe_add_func_uint64_t_u_u(g_33[2][0][2], 0UL))), l_166))), g_33[8][0][8]))) <= g_11[1]))), p_17)) >= (-1L)), 6))) , &g_11[1]))))) , 0L)))\r\n { \r\n uint16_t l_173 = 1UL;\r\n uint32_t *l_186[9];\r\n int64_t *l_188[5] = {&g_66[3][3],&g_66[3][3],&g_66[3][3],&g_66[3][3],&g_66[3][3]};\r\n int32_t l_193 = 1L;\r\n int32_t ***l_257 = &g_256;\r\n uint64_t *l_276[9] = {&g_33[7][0][8],&g_33[7][0][8],&g_33[7][0][8],&g_33[7][0][8],&g_33[7][0][8],&g_33[7][0][8],&g_33[7][0][8],&g_33[7][0][8],&g_33[7][0][8]};\r\n int32_t l_283 = (-9L);\r\n int32_t l_287 = 0L;\r\n int32_t l_292 = 0x1C44CF0EL;\r\n int32_t l_293 = 0x11BC2BF2L;\r\n int32_t l_295 = 0xE1623BE8L;\r\n int32_t l_296[1][9] = {{0xD646E06EL,0xD646E06EL,0x34B75A98L,0xD646E06EL,0xD646E06EL,0x34B75A98L,0xD646E06EL,0xD646E06EL,0x34B75A98L}};\r\n uint16_t l_299 = 0x0AFDL;\r\n uint16_t l_305 = 0xFAD6L;\r\n int i, j;\r\n for (i = 0; i < 9; i++)\r\n l_186[i] = &g_149;\r\nlbl_267:\r\n ++l_173;\r\n for (l_55 = 0; (l_55 <= 5); l_55 += 1)\r\n { \r\n uint8_t *l_184 = &g_185;\r\n int64_t * const l_187 = &g_66[3][3];\r\n int64_t **l_191 = &l_172;\r\n const uint8_t l_192 = 0x7EL;\r\n int32_t l_236 = 1L;\r\n int i;\r\n if ((safe_div_func_uint8_t_u_u((safe_mod_func_int32_t_s_s((*g_170), ((safe_mod_func_uint8_t_u_u((((*l_184) = (l_164 != &p_16)) || (((((((l_186[6] = l_111) != &g_94[2]) , l_187) == l_188[3]) == (safe_rshift_func_uint32_t_u_u(g_33[2][0][5], (((*l_191) = &g_157[3]) != &g_66[3][3])))) > 0xB3L) != l_173)), 3L)) , p_17))), l_192)))\r\n { \r\n int32_t l_194 = 0xBE4B794FL;\r\n int32_t l_195[8] = {0xFA8EE88EL,0xFA8EE88EL,0x2CC03310L,0xFA8EE88EL,0xFA8EE88EL,0x2CC03310L,0xFA8EE88EL,0xFA8EE88EL};\r\n int i;\r\n ++l_196;\r\n g_170 = &g_11[1];\r\n return g_33[6][0][6];\r\n }\r\n else\r\n { \r\n --l_199;\r\n }\r\n for (g_165 = 0; (g_165 <= 8); g_165 += 1)\r\n { \r\n int i, j;\r\n (*g_170) ^= l_43[l_55][l_55];\r\n return g_157[(l_55 + 1)];\r\n }\r\n for (g_12 = 1; (g_12 <= 5); g_12 += 1)\r\n { \r\n uint64_t l_239 = 0xCCD539717E3722A4LL;\r\n int i, j;\r\n (*g_169) = (safe_mod_func_int8_t_s_s((safe_mul_func_int8_t_s_s((safe_div_func_int32_t_s_s((safe_sub_func_uint32_t_u_u((safe_mod_func_uint16_t_u_u((safe_rshift_func_uint16_t_u_u(((l_193 = (((safe_mod_func_uint64_t_u_u(p_16, (safe_sub_func_uint8_t_u_u(((*l_184)++), ((((safe_unary_minus_func_uint32_t_u((((safe_mul_func_int16_t_s_s((0L ^ l_173), ((((safe_sub_func_uint16_t_u_u((safe_add_func_int64_t_s_s(p_17, (((safe_sub_func_uint16_t_u_u(p_18, (l_43[(g_12 + 1)][g_12] |= (((safe_add_func_int16_t_s_s(((g_33[0][0][2]++) || (!l_173)), ((l_236 = 0x9C1AF257L) >= (*g_169)))) < (safe_lshift_func_int32_t_s_u((*g_169), 5))) || g_33[8][0][8])))) < l_193) ^ g_11[1]))), g_168)) , g_149) , g_66[3][3]) , 0x3A3CL))) & l_239) , p_17))) < l_239) > l_193) >= 18446744073709551607UL))))) , (-1L)) != g_12)) ^ 0x81AF9209L), 2)), g_165)), (*g_169))), g_157[2])), g_165)), g_94[2]));\r\n (*g_170) = p_18;\r\n }\r\n for (l_173 = 1; (l_173 <= 5); l_173 += 1)\r\n { \r\n l_193 = (-1L);\r\n return g_33[8][0][8];\r\n }\r\n }\r\n for (g_165 = 0; (g_165 >= (-25)); g_165--)\r\n { \r\n uint8_t *l_251[10][10][2] = {{{&g_185,(void*)0},{&g_185,&g_185},{(void*)0,&g_185},{&g_185,(void*)0},{&g_185,&g_185},{&g_185,&g_185},{&g_185,&g_185},{&g_185,&g_185},{&g_185,(void*)0},{&g_185,&g_185}},{{(void*)0,&g_185},{&g_185,(void*)0},{&g_185,&g_185},{(void*)0,&g_185},{&g_185,(void*)0},{&g_185,&g_185},{&g_185,&g_185},{&g_185,&g_185},{&g_185,&g_185},{&g_185,&g_185}},{{&g_185,&g_185},{&g_185,&g_185},{&g_185,(void*)0},{&g_185,&g_185},{&g_185,&g_185},{&g_185,&g_185},{&g_185,&g_185},{&g_185,&g_185},{&g_185,(void*)0},{&g_185,&g_185}},{{&g_185,&g_185},{(void*)0,&g_185},{&g_185,(void*)0},{(void*)0,&g_185},{&g_185,&g_185},{&g_185,&g_185},{&g_185,&g_185},{&g_185,&g_185},{&g_185,&g_185},{(void*)0,&g_185}},{{&g_185,&g_185},{&g_185,&g_185},{&g_185,&g_185},{&g_185,&g_185},{&g_185,&g_185},{(void*)0,(void*)0},{&g_185,&g_185},{(void*)0,&g_185},{&g_185,&g_185},{&g_185,(void*)0}},{{&g_185,&g_185},{&g_185,&g_185},{&g_185,&g_185},{(void*)0,&g_185},{&g_185,(void*)0},{&g_185,(void*)0},{&g_185,(void*)0},{&g_185,&g_185},{(void*)0,&g_185},{&g_185,&g_185}},{{&g_185,&g_185},{&g_185,(void*)0},{&g_185,&g_185},{&g_185,&g_185},{(void*)0,&g_185},{&g_185,(void*)0},{(void*)0,&g_185},{&g_185,&g_185},{&g_185,&g_185},{&g_185,&g_185}},{{&g_185,&g_185},{&g_185,&g_185},{(void*)0,&g_185},{&g_185,&g_185},{&g_185,&g_185},{&g_185,&g_185},{&g_185,&g_185},{&g_185,&g_185},{(void*)0,(void*)0},{&g_185,&g_185}},{{(void*)0,&g_185},{&g_185,&g_185},{&g_185,(void*)0},{&g_185,&g_185},{&g_185,&g_185},{&g_185,&g_185},{(void*)0,&g_185},{&g_185,(void*)0},{&g_185,(void*)0},{&g_185,(void*)0}},{{&g_185,&g_185},{(void*)0,&g_185},{&g_185,&g_185},{&g_185,&g_185},{&g_185,(void*)0},{&g_185,&g_185},{&g_185,&g_185},{(void*)0,&g_185},{&g_185,(void*)0},{(void*)0,&g_185}}};\r\n int32_t l_252[2];\r\n int32_t l_266 = (-9L);\r\n int64_t *l_274 = &g_157[7];\r\n int32_t l_289[7] = {0xA2D0A057L,0xA2D0A057L,0xA2D0A057L,0xA2D0A057L,0xA2D0A057L,0xA2D0A057L,0xA2D0A057L};\r\n int i, j, k;\r\n for (i = 0; i < 2; i++)\r\n l_252[i] = 0L;\r\n for (p_16 = (-8); (p_16 > (-2)); p_16++)\r\n { \r\n if (g_168)\r\n goto lbl_244;\r\n }\r\n if (((safe_sub_func_int16_t_s_s((((safe_add_func_int16_t_s_s((safe_lshift_func_uint8_t_u_s((l_252[1] ^= (g_149 , p_16)), (((p_16 > (((0xA6BC4429L & (g_255 != l_257)) ^ (((safe_mul_func_int64_t_s_s((g_33[8][0][8] || ((safe_add_func_uint64_t_u_u((safe_mul_func_uint64_t_u_u(((safe_add_func_int8_t_s_s(g_12, l_266)) , 0x221D217DB600C3A3LL), 0xF75A03B73B3FD032LL)), g_33[8][0][8])) | g_157[0])), 0x36BB0D7DC54451A0LL)) != 0xE35EL) <= g_149)) < 4294967293UL)) | p_16) | l_266))), g_33[3][0][6])) > 1UL) , g_33[1][0][6]), g_66[1][1])) | p_16))\r\n { \r\n if ((***g_255))\r\n break;\r\n }\r\n else\r\n { \r\n uint16_t l_270[10] = {0x99BCL,0x1F3FL,0x2820L,0x2820L,0x1F3FL,0x99BCL,0x1F3FL,0x2820L,0x2820L,0x1F3FL};\r\n int64_t **l_275 = &l_188[4];\r\n int32_t l_284 = (-1L);\r\n int32_t l_285 = 1L;\r\n int32_t l_286 = 0x8B011B8DL;\r\n int32_t l_290 = 1L;\r\n int32_t l_294 = 0x4EF4180CL;\r\n int32_t l_297 = (-1L);\r\n int32_t l_298[9] = {9L,9L,9L,9L,9L,9L,9L,9L,9L};\r\n int i;\r\n if (l_55)\r\n goto lbl_267;\r\n (***g_255) = (g_31 == g_66[3][3]);\r\n (***l_257) ^= ((safe_add_func_int32_t_s_s(l_270[0], (((safe_sub_func_int32_t_s_s((0x1737AA7C1C7358A4LL && g_157[3]), (((safe_unary_minus_func_int16_t_s(((((*l_275) = l_274) != (void*)0) != ((void*)0 != l_276[5])))) <= (safe_rshift_func_int32_t_s_s((safe_div_func_uint64_t_u_u((safe_add_func_uint16_t_u_u(g_33[8][0][8], g_94[2])), l_270[0])), l_252[1]))) & g_168))) , 4294967295UL) , p_16))) , p_16);\r\n --l_299;\r\n }\r\n l_302++;\r\n g_306 &= (l_305 = (***l_257));\r\n }\r\n }\r\n else\r\n { \r\n uint8_t l_307[9][7] = {{0x0DL,0x0DL,1UL,0xE6L,1UL,1UL,1UL},{0xE6L,255UL,255UL,0xE6L,0UL,246UL,0xE6L},{246UL,1UL,0UL,0UL,0UL,0x22L,1UL},{0UL,255UL,0x0DL,246UL,246UL,0x0DL,255UL},{0UL,1UL,0x22L,0UL,9UL,9UL,0UL},{0x22L,255UL,0x22L,9UL,255UL,1UL,1UL},{255UL,0UL,0x0DL,0UL,255UL,0x0DL,246UL},{246UL,1UL,9UL,246UL,9UL,1UL,246UL},{0x22L,246UL,1UL,9UL,246UL,9UL,1UL}};\r\n int i, j;\r\n --l_307[0][5];\r\n }\r\n return p_16;\r\n}\r\n\r\n\r\n\r\n\r\n\r\nint main (int argc, char* argv[])\r\n{\r\n int i, j, k;\r\n int print_hash_value = 0;\r\n if (argc == 2 && strcmp(argv[1], \"1\") == 0) print_hash_value = 1;\r\n platform_main_begin();\r\n crc32_gentab();\r\n func_1();\r\n for (i = 0; i < 2; i++)\r\n {\r\n transparent_crc(g_11[i], \"g_11[i]\", print_hash_value);\r\n if (print_hash_value) printf(\"index = [%d]\\n\", i);\r\n\r\n }\r\n transparent_crc(g_12, \"g_12\", print_hash_value);\r\n transparent_crc(g_31, \"g_31\", print_hash_value);\r\n for (i = 0; i < 9; i++)\r\n {\r\n for (j = 0; j < 1; j++)\r\n {\r\n for (k = 0; k < 9; k++)\r\n {\r\n transparent_crc(g_33[i][j][k], \"g_33[i][j][k]\", print_hash_value);\r\n if (print_hash_value) printf(\"index = [%d][%d][%d]\\n\", i, j, k);\r\n\r\n }\r\n }\r\n }\r\n for (i = 0; i < 5; i++)\r\n {\r\n for (j = 0; j < 4; j++)\r\n {\r\n transparent_crc(g_66[i][j], \"g_66[i][j]\", print_hash_value);\r\n if (print_hash_value) printf(\"index = [%d][%d]\\n\", i, j);\r\n\r\n }\r\n }\r\n for (i = 0; i < 3; i++)\r\n {\r\n transparent_crc(g_94[i], \"g_94[i]\", print_hash_value);\r\n if (print_hash_value) printf(\"index = [%d]\\n\", i);\r\n\r\n }\r\n transparent_crc(g_149, \"g_149\", print_hash_value);\r\n for (i = 0; i < 9; i++)\r\n {\r\n transparent_crc(g_157[i], \"g_157[i]\", print_hash_value);\r\n if (print_hash_value) printf(\"index = [%d]\\n\", i);\r\n\r\n }\r\n transparent_crc(g_165, \"g_165\", print_hash_value);\r\n transparent_crc(g_168, \"g_168\", print_hash_value);\r\n transparent_crc(g_185, \"g_185\", print_hash_value);\r\n transparent_crc(g_306, \"g_306\", print_hash_value);\r\n transparent_crc(g_311, \"g_311\", print_hash_value);\r\n transparent_crc(g_313, \"g_313\", print_hash_value);\r\n transparent_crc(g_341, \"g_341\", print_hash_value);\r\n for (i = 0; i < 6; i++)\r\n {\r\n transparent_crc(g_346[i], \"g_346[i]\", print_hash_value);\r\n if (print_hash_value) printf(\"index = [%d]\\n\", i);\r\n\r\n }\r\n for (i = 0; i < 6; i++)\r\n {\r\n for (j = 0; j < 2; j++)\r\n {\r\n transparent_crc(g_366[i][j], \"g_366[i][j]\", print_hash_value);\r\n if (print_hash_value) printf(\"index = [%d][%d]\\n\", i, j);\r\n\r\n }\r\n }\r\n transparent_crc(g_380, \"g_380\", print_hash_value);\r\n transparent_crc(g_407, \"g_407\", print_hash_value);\r\n transparent_crc(g_409, \"g_409\", print_hash_value);\r\n transparent_crc(g_412, \"g_412\", print_hash_value);\r\n transparent_crc(g_414, \"g_414\", print_hash_value);\r\n for (i = 0; i < 5; i++)\r\n {\r\n for (j = 0; j < 10; j++)\r\n {\r\n transparent_crc(g_416[i][j], \"g_416[i][j]\", print_hash_value);\r\n if (print_hash_value) printf(\"index = [%d][%d]\\n\", i, j);\r\n\r\n }\r\n }\r\n transparent_crc(g_426, \"g_426\", print_hash_value);\r\n transparent_crc(g_457, \"g_457\", print_hash_value);\r\n platform_main_end(crc32_context ^ 0xFFFFFFFFUL, print_hash_value);\r\n return 0;\r\n}\r\n\r\n/************************ statistics *************************\r\nXXX max struct depth: 0\r\nbreakdown:\r\n depth: 0, occurrence: 138\r\nXXX total union variables: 0\r\n\r\nXXX max expression depth: 48\r\nbreakdown:\r\n depth: 1, occurrence: 114\r\n depth: 2, occurrence: 28\r\n depth: 3, occurrence: 1\r\n depth: 4, occurrence: 1\r\n depth: 5, occurrence: 1\r\n depth: 6, occurrence: 2\r\n depth: 16, occurrence: 1\r\n depth: 17, occurrence: 2\r\n depth: 18, occurrence: 2\r\n depth: 19, occurrence: 1\r\n depth: 24, occurrence: 1\r\n depth: 25, occurrence: 1\r\n depth: 28, occurrence: 1\r\n depth: 29, occurrence: 1\r\n depth: 30, occurrence: 1\r\n depth: 31, occurrence: 1\r\n depth: 32, occurrence: 1\r\n depth: 34, occurrence: 3\r\n depth: 38, occurrence: 1\r\n depth: 43, occurrence: 1\r\n depth: 48, occurrence: 1\r\n\r\nXXX total number of pointers: 101\r\n\r\nXXX times a variable address is taken: 515\r\nXXX times a pointer is dereferenced on RHS: 36\r\nbreakdown:\r\n depth: 1, occurrence: 32\r\n depth: 2, occurrence: 2\r\n depth: 3, occurrence: 2\r\nXXX times a pointer is dereferenced on LHS: 69\r\nbreakdown:\r\n depth: 1, occurrence: 59\r\n depth: 2, occurrence: 7\r\n depth: 3, occurrence: 3\r\nXXX times a pointer is compared with null: 5\r\nXXX times a pointer is compared with address of another variable: 5\r\nXXX times a pointer is compared with another pointer: 3\r\nXXX times a pointer is qualified to be dereferenced: 1932\r\n\r\nXXX max dereference level: 3\r\nbreakdown:\r\n level: 0, occurrence: 0\r\n level: 1, occurrence: 190\r\n level: 2, occurrence: 35\r\n level: 3, occurrence: 30\r\nXXX number of pointers point to pointers: 36\r\nXXX number of pointers point to scalars: 65\r\nXXX number of pointers point to structs: 0\r\nXXX percent of pointers has null in alias set: 38.6\r\nXXX average alias set size: 1.44\r\n\r\nXXX times a non-volatile is read: 427\r\nXXX times a non-volatile is write: 241\r\nXXX times a volatile is read: 0\r\nXXX times read thru a pointer: 0\r\nXXX times a volatile is write: 0\r\nXXX times written thru a pointer: 0\r\nXXX times a volatile is available for access: 0\r\nXXX percentage of non-volatile access: 100\r\n\r\nXXX forward jumps: 0\r\nXXX backward jumps: 2\r\n\r\nXXX stmts: 111\r\nXXX max block depth: 3\r\nbreakdown:\r\n depth: 0, occurrence: 13\r\n depth: 1, occurrence: 17\r\n depth: 2, occurrence: 28\r\n depth: 3, occurrence: 53\r\n\r\nXXX percentage a fresh-made variable is used: 16.5\r\nXXX percentage an existing variable is used: 83.5\r\nXXX total OOB instances added: 0\r\n********************* end of statistics **********************/\r\n\r\n```"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
97590
|
https://github.com/llvm/llvm-project/issues/97590
|
crash
|
ed51908cec879c9dff435abdc70d8b03afc35c07
| 2024-07-03T15:09:36 |
[
"llvm/test/Transforms/Inline"
] |
{
"fix_commit": "be7239e5a60927f5b4932f995dc4b57423ea8534",
"components": [
"InlineCost"
],
"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": [
[
2644,
2651
]
],
"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": null,
"llvm/lib/Analysis/InlineCost.cpp": [
"CallAnalyzer::stripAndComputeInBoundsConstantOffsets"
],
"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 be7239e5a60927f5b4932f995dc4b57423ea8534
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Tue Jul 9 15:08:04 2024 +0800
[Inline] Remove bitcast handling in `CallAnalyzer::stripAndComputeInBoundsConstantOffsets` (#97988)
As we are now using opaque pointers, bitcast handling is no longer
needed.
Closes https://github.com/llvm/llvm-project/issues/97590.
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index 94aa8ecf6f55..345e5a019520 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -2644,8 +2644,6 @@ ConstantInt *CallAnalyzer::stripAndComputeInBoundsConstantOffsets(Value *&V) {
if (!GEP->isInBounds() || !accumulateGEPOffset(*GEP, Offset))
return nullptr;
V = GEP->getPointerOperand();
- } else if (Operator::getOpcode(V) == Instruction::BitCast) {
- V = cast<Operator>(V)->getOperand(0);
} else if (GlobalAlias *GA = dyn_cast<GlobalAlias>(V)) {
if (GA->isInterposable())
break;
|
[
{
"file": "llvm/test/Transforms/Inline/pr97590.ll",
"commands": [
"opt -S -passes=inline < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n; Check that we don't crash when computing the\n; base pointer of `bitcast <1 x ptr> to ptr`\n\ndefine void @caller(<1 x ptr> %x) {\n;\nentry:\n %p = bitcast <1 x ptr> %x to ptr\n call void @callee(ptr %p)\n ret void\n}\n\ndefine void @callee(ptr %p) {\n;\nentry:\n ret void\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[Inline] Assertion `V->getType()->isPointerTy() && \"Unexpected operand type!\"' failed.",
"body": "Reproducer: https://godbolt.org/z/qGc1Kx5YK\r\n```\r\n; bin/opt -passes=inline reduced.ll -S\r\ndefine i32 @func_120(i1 %tobool626, ptr %g_231, ptr %l_506, i1 %tobool724, ptr %p) {\r\nentry:\r\n %0 = bitcast i1 %tobool626 to <1 x i1>\r\n call void @llvm.masked.store.v1i64.p0(<1 x i64> zeroinitializer, ptr %g_231, i32 8, <1 x i1> %0)\r\n %1 = xor i1 %tobool626, true\r\n %2 = bitcast i1 %1 to <1 x i1>\r\n %3 = call <1 x ptr> @llvm.masked.load.v1p0.p0(ptr %g_231, i32 8, <1 x i1> %2, <1 x ptr> poison)\r\n %4 = bitcast <1 x ptr> %3 to ptr\r\n br i1 %tobool626, label %common.ret, label %if.else647\r\n\r\ncommon.ret: ; preds = %entry, %lor.end739\r\n ret i32 0\r\n\r\nif.else647: ; preds = %entry\r\n br i1 %tobool724, label %land.rhs725, label %lor.end739\r\n\r\nland.rhs725: ; preds = %if.else647\r\n %call726 = load i32, ptr %p, align 4\r\n br label %lor.end739\r\n\r\nlor.end739: ; preds = %land.rhs725, %if.else647\r\n %call745 = call i32 @func_136(ptr %4)\r\n br label %common.ret\r\n}\r\n\r\ndefine i32 @func_136(ptr nocapture readnone %p_137) {\r\nentry:\r\n ret i32 0\r\n}\r\n\r\n```\r\n```\r\nopt: /root/llvm-project/llvm/lib/Analysis/InlineCost.cpp:2656: llvm::ConstantInt* {anonymous}::CallAnalyzer::stripAndComputeInBoundsConstantOffsets(llvm::Value*&): Assertion `V->getType()->isPointerTy() && \"Unexpected operand type!\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=inline <source>\r\n1.\tRunning pass \"cgscc(inline)\" on module \"<source>\"\r\n #0 0x0000000004e7cf38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e7cf38)\r\n #1 0x0000000004e7a69c SignalHandler(int) Signals.cpp:0:0\r\n #2 0x000077b96f042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x000077b96f0969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x000077b96f042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x000077b96f0287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x000077b96f02871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x000077b96f039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x00000000043ea53a (anonymous namespace)::CallAnalyzer::analyze() (.part.0) InlineCost.cpp:0:0\r\n #9 0x00000000043eb650 llvm::getInlineCost(llvm::CallBase&, llvm::Function*, llvm::InlineParams const&, llvm::TargetTransformInfo&, llvm::function_ref<llvm::AssumptionCache& (llvm::Function&)>, llvm::function_ref<llvm::TargetLibraryInfo const& (llvm::Function&)>, llvm::function_ref<llvm::BlockFrequencyInfo& (llvm::Function&)>, llvm::ProfileSummaryInfo*, llvm::OptimizationRemarkEmitter*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43eb650)\r\n#10 0x00000000043ebba6 llvm::getInlineCost(llvm::CallBase&, llvm::InlineParams const&, llvm::TargetTransformInfo&, llvm::function_ref<llvm::AssumptionCache& (llvm::Function&)>, llvm::function_ref<llvm::TargetLibraryInfo const& (llvm::Function&)>, llvm::function_ref<llvm::BlockFrequencyInfo& (llvm::Function&)>, llvm::ProfileSummaryInfo*, llvm::OptimizationRemarkEmitter*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43ebba6)\r\n#11 0x00000000043ed0ab llvm::InlineCost llvm::function_ref<llvm::InlineCost (llvm::CallBase&)>::callback_fn<getDefaultInlineAdvice(llvm::CallBase&, llvm::AnalysisManager<llvm::Function>&, llvm::InlineParams const&)::'lambda2'(llvm::CallBase&)>(long, llvm::CallBase&) InlineAdvisor.cpp:0:0\r\n#12 0x00000000043f310d llvm::shouldInline(llvm::CallBase&, llvm::function_ref<llvm::InlineCost (llvm::CallBase&)>, llvm::OptimizationRemarkEmitter&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43f310d)\r\n#13 0x00000000043f4af5 getDefaultInlineAdvice(llvm::CallBase&, llvm::AnalysisManager<llvm::Function>&, llvm::InlineParams const&) InlineAdvisor.cpp:0:0\r\n#14 0x00000000043f4d3b llvm::DefaultInlineAdvisor::getAdviceImpl(llvm::CallBase&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43f4d3b)\r\n#15 0x00000000043eda71 llvm::InlineAdvisor::getAdvice(llvm::CallBase&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43eda71)\r\n#16 0x000000000371e48d llvm::InlinerPass::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x371e48d)\r\n#17 0x0000000002e127ae llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::InlinerPass, 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/opt+0x2e127ae)\r\n#18 0x000000000431385b 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/opt+0x431385b)\r\n#19 0x0000000002e1154e 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/opt+0x2e1154e)\r\n#20 0x00000000043155b9 llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43155b9)\r\n#21 0x0000000002e1152e 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/opt+0x2e1152e)\r\n#22 0x0000000004c780c0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4c780c0)\r\n#23 0x00000000008d8702 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+0x8d8702)\r\n#24 0x00000000008cb60c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8cb60c)\r\n#25 0x000077b96f029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#26 0x000077b96f029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#27 0x00000000008c2a6e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8c2a6e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```\r\nhttps://github.com/llvm/llvm-project/blob/f1a8f94bba8b090a0d667065e4b8b4fc66b6a5cc/llvm/lib/Analysis/InlineCost.cpp#L2647-L2648\r\nshould be removed as we use opaque pointers now.\r\n",
"author": "dtcxzyw",
"labels": [
"crash-on-valid",
"llvm:analysis"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Related patch: #96878 "
},
{
"author": "dtcxzyw",
"body": "Reduced reproducer: https://godbolt.org/z/rbjK6ETEW\r\n```\r\n; bin/opt -passes=inline reduced.ll -S\r\ndefine void @caller(<1 x ptr> %x) {\r\nentry:\r\n %p = bitcast <1 x ptr> %x to ptr\r\n call void @callee(ptr %p)\r\n ret void\r\n}\r\n\r\ndefine void @callee(ptr %p) {\r\nentry:\r\n ret void\r\n}\r\n```"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
89669
|
https://github.com/llvm/llvm-project/issues/89669
|
miscompilation
|
d97cdd7d088b11b45038112a5f7fe5cbf60a6461
| 2024-04-22T21:27:36 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "a1b1c4a6d1d52916c5d885170a5f54632d579cdc",
"components": [
"InstCombine",
"ValueTracking"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
8042,
8058
]
],
"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": [
[
131,
137
]
],
"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": [
[
320,
326
]
],
"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": [
"llvm::isKnownNegation",
"matchMinMax"
],
"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": [
"Negator::visitImpl"
],
"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 a1b1c4a6d1d52916c5d885170a5f54632d579cdc
Author: Nikita Popov <npopov@redhat.com>
Date: Wed Apr 24 10:56:26 2024 +0900
[InstCombine] Fix miscompile in negation of select (#89698)
Swapping the operands of a select is not valid if one hand is more
poisonous that the other, because the negation zero contains poison
elements.
Fix this by adding an extra parameter to isKnownNegation() to forbid
poison elements.
I've implemented this using manual checks to avoid needing four variants
for the NeedsNSW/AllowPoison combinations. Maybe there is a better way
to do this...
Fixes https://github.com/llvm/llvm-project/issues/89669.
diff --git a/llvm/include/llvm/Analysis/ValueTracking.h b/llvm/include/llvm/Analysis/ValueTracking.h
index a2fa8f6064e1..571e44cdac26 100644
--- a/llvm/include/llvm/Analysis/ValueTracking.h
+++ b/llvm/include/llvm/Analysis/ValueTracking.h
@@ -131,7 +131,8 @@ bool isKnownNonZero(const Value *V, const SimplifyQuery &Q, unsigned Depth = 0);
/// Currently can recoginze Value pair:
/// 1: <X, Y> if X = sub (0, Y) or Y = sub (0, X)
/// 2: <X, Y> if X = sub (A, B) and Y = sub (B, A)
-bool isKnownNegation(const Value *X, const Value *Y, bool NeedNSW = false);
+bool isKnownNegation(const Value *X, const Value *Y, bool NeedNSW = false,
+ bool AllowPoison = true);
/// Returns true if the give value is known to be non-negative.
bool isKnownNonNegative(const Value *V, const SimplifyQuery &SQ,
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 21e3f8a4cc52..7501f78ca23b 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -8042,17 +8042,27 @@ static SelectPatternResult matchMinMax(CmpInst::Predicate Pred,
return {SPF_UNKNOWN, SPNB_NA, false};
}
-bool llvm::isKnownNegation(const Value *X, const Value *Y, bool NeedNSW) {
+bool llvm::isKnownNegation(const Value *X, const Value *Y, bool NeedNSW,
+ bool AllowPoison) {
assert(X && Y && "Invalid operand");
- // X = sub (0, Y) || X = sub nsw (0, Y)
- if ((!NeedNSW && match(X, m_Sub(m_ZeroInt(), m_Specific(Y)))) ||
- (NeedNSW && match(X, m_NSWNeg(m_Specific(Y)))))
+ auto IsNegationOf = [&](const Value *X, const Value *Y) {
+ if (!match(X, m_Neg(m_Specific(Y))))
+ return false;
+
+ auto *BO = cast<BinaryOperator>(X);
+ if (NeedNSW && !BO->hasNoSignedWrap())
+ return false;
+
+ auto *Zero = cast<Constant>(BO->getOperand(0));
+ if (!AllowPoison && !Zero->isNullValue())
+ return false;
+
return true;
+ };
- // Y = sub (0, X) || Y = sub nsw (0, X)
- if ((!NeedNSW && match(Y, m_Sub(m_ZeroInt(), m_Specific(X)))) ||
- (NeedNSW && match(Y, m_NSWNeg(m_Specific(X)))))
+ // X = -Y or Y = -X
+ if (IsNegationOf(X, Y) || IsNegationOf(Y, X))
return true;
// X = sub (A, B), Y = sub (B, A) || X = sub nsw (A, B), Y = sub nsw (B, A)
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp b/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp
index d697f361dec0..ed2a98ba4ae4 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp
@@ -320,7 +320,8 @@ std::array<Value *, 2> Negator::getSortedOperandsOfBinOp(Instruction *I) {
return NegatedPHI;
}
case Instruction::Select: {
- if (isKnownNegation(I->getOperand(1), I->getOperand(2))) {
+ if (isKnownNegation(I->getOperand(1), I->getOperand(2), /*NeedNSW=*/false,
+ /*AllowPoison=*/false)) {
// Of one hand of select is known to be negation of another hand,
// just swap the hands around.
auto *NewSelect = cast<SelectInst>(I->clone());
|
[
{
"file": "llvm/test/Transforms/InstCombine/sub-of-negatible.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "negate_select_of_negation_poison",
"test_body": "define <2 x i32> @negate_select_of_negation_poison(<2 x i1> %c, <2 x i32> %x) {\n %neg = sub <2 x i32> <i32 0, i32 poison>, %x\n %sel = select <2 x i1> %c, <2 x i32> %neg, <2 x i32> %x\n %neg2 = sub <2 x i32> zeroinitializer, %sel\n ret <2 x i32> %neg2\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "dont_negate_ordinary_select",
"test_body": "define i8 @dont_negate_ordinary_select(i8 %x, i8 %y, i8 %z, i1 %c) {\n %t0 = select i1 %c, i8 %x, i8 %y\n %t1 = sub i8 %z, %t0\n ret i8 %t1\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "miscompile of vector double-negation + select by InstCombine",
"body": "https://alive2.llvm.org/ce/z/N1RVAr\r\n\r\nthis:\r\n```llvm\r\ndefine <4 x i32> @f(<4 x i32> %0) {\r\n %2 = sub <4 x i32> zeroinitializer, %0\r\n %3 = select <4 x i1> <i1 false, i1 true, i1 poison, i1 poison>, <4 x i32> %2, <4 x i32> %0\r\n %4 = sub <4 x i32> zeroinitializer, %3\r\n ret <4 x i32> %4\r\n}\r\n```\r\nis being optimized to:\r\n```llvm\r\ndefine <4 x i32> @f(<4 x i32> %0) {\r\n ret <4 x i32> %0\r\n}\r\n```\r\nhere's Alive's work explaining why this is wrong:\r\n```\r\nERROR: Value mismatch\r\n\r\nExample:\r\n<4 x i32> %#0 = < #x00000001 (1), poison, poison, poison >\r\n\r\nSource:\r\n<4 x i32> %#2 = < #xffffffff (4294967295, -1), poison, poison, poison >\r\n<4 x i32> %#3 = < #x00000001 (1), poison, poison, poison >\r\n<4 x i32> %#4 = < #xffffffff (4294967295, -1), poison, poison, poison >\r\n\r\nTarget:\r\nSource value: < #xffffffff (4294967295, -1), poison, poison, poison >\r\nTarget value: < #x00000001 (1), poison, poison, poison >\r\n```\r\n\r\ncc @nunoplopes @hatsunespica\r\n\r\n",
"author": "regehr",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": [
{
"author": "topperc",
"body": "I think the problem is this code in Negator::visitImpl.\r\n\r\n```\r\n case Instruction::Select: {\r\n if (isKnownNegation(I->getOperand(1), I->getOperand(2))) { \r\n // Of one hand of select is known to be negation of another hand, \r\n // just swap the hands around. \r\n auto *NewSelect = cast<SelectInst>(I->clone()); \r\n // Just swap the operands of the select. \r\n NewSelect->swapValues(); \r\n // Don't swap prof metadata, we didn't change the branch behavior. \r\n NewSelect->setName(I->getName() + \".neg\"); \r\n Builder.Insert(NewSelect); \r\n return NewSelect; \r\n } \r\n```\r\n\r\nThe IR at the time of that code running was\r\n```\r\n%2 = sub <4 x i32> <i32 poison, i32 0, i32 0, i32 0>, %0\r\n%3 = select <4 x i1> <i1 false, i1 true, i1 poison, i1 poison>, <4 x i32> %2, <4 x i32> %0\r\n%4 = sub <4 x i32> zeroinitializer, %3\r\n```\r\n\r\nSo operand element 0 of %2 is poison. This occurred because element 0 isn't selected so SimplifiedDemandedVectorElts replaced with poison.\r\n\r\nOnce Negator swaps the operands, now element 1 of %2 is never selected so we end up with `sub <4 x i32> poison, %0`\r\n\r\nIt doesn't look like swapping the operands of the select is poison safe.\r\n\r\nCC @nikic "
},
{
"author": "nikic",
"body": "Yeah, that analysis sounds right to me. With that in mind, a more direct test case would be:\r\n```llvm\r\ndefine <2 x i32> @f(<2 x i1> %c, <2 x i32> %x) {\r\n %neg = sub <2 x i32> <i32 0, i32 poison>, %x\r\n %sel = select <2 x i1> %c, <2 x i32> %neg, <2 x i32> %x\r\n %neg2 = sub <2 x i32> zeroinitializer, %sel\r\n ret <2 x i32> %neg2\r\n}\r\n```"
},
{
"author": "regehr",
"body": "off topic but do we want an llvm-reduce pass that shrinks vectors? and maybe also shrinks lane sizes? if so I could work on that sort of thing this summer"
},
{
"author": "XChy",
"body": "> off topic but do we want an llvm-reduce pass that shrinks vectors? and maybe also shrinks lane sizes? if so I could work on that sort of thing this summer\r\n\r\nSounds great to me. I think some SLPVectorizer testcases that involve 16 or even 32 lanes should be further reduced."
}
]
}
| true |
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
| null |
100298
|
https://github.com/llvm/llvm-project/issues/100298
|
miscompilation
|
75642a00e15b722bdfb90726be31f1c8adaeb0c5
| 2024-07-24T04:19:53 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "59eae919c938f890e9b9b4be8a3fa3cb1b11ed89",
"components": [
"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": [
[
1435,
1441
],
[
1468,
1474
],
[
1546,
1552
],
[
2329,
2335
],
[
2943,
2949
],
[
3509,
3515
],
[
4001,
4007
],
[
5909,
5918
]
],
"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": [
[
130,
135
]
],
"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": [
"ComputeNumSignBitsImpl",
"computeKnownBitsFromOperator",
"computeKnownFPClass",
"isKnownNonZeroFromOperator",
"isKnownToBeAPowerOfTwo",
"isNonEqualPHIs"
],
"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": [
"getWithCondContext"
],
"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 a87fbeb3a77a53ded341277c5b326f7696d47594
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Wed Jul 24 20:06:36 2024 +0800
[ValueTracking] Don't use CondContext in dataflow analysis of phi nodes (#100316)
See the following case:
```
define i16 @pr100298() {
entry:
br label %for.inc
for.inc:
%indvar = phi i32 [ -15, %entry ], [ %mask, %for.inc ]
%add = add nsw i32 %indvar, 9
%mask = and i32 %add, 65535
%cmp1 = icmp ugt i32 %mask, 5
br i1 %cmp1, label %for.inc, label %for.end
for.end:
%conv = trunc i32 %add to i16
%cmp2 = icmp ugt i32 %mask, 3
%shl = shl nuw i16 %conv, 14
%res = select i1 %cmp2, i16 %conv, i16 %shl
ret i16 %res
}
```
When computing knownbits of `%shl` with `%cmp2=false`, we cannot use
this condition in the analysis of `%mask (%for.inc -> %for.inc)`.
Fixes https://github.com/llvm/llvm-project/issues/100298.
(cherry picked from commit 59eae919c938f890e9b9b4be8a3fa3cb1b11ed89)
diff --git a/llvm/include/llvm/Analysis/SimplifyQuery.h b/llvm/include/llvm/Analysis/SimplifyQuery.h
index a560744f0122..e8f43c8c2e91 100644
--- a/llvm/include/llvm/Analysis/SimplifyQuery.h
+++ b/llvm/include/llvm/Analysis/SimplifyQuery.h
@@ -130,6 +130,12 @@ struct SimplifyQuery {
Copy.CC = &CC;
return Copy;
}
+
+ SimplifyQuery getWithoutCondContext() const {
+ SimplifyQuery Copy(*this);
+ Copy.CC = nullptr;
+ return Copy;
+ }
};
} // end namespace llvm
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 40fe1ffe13f1..4b77c0046cc7 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -1435,7 +1435,7 @@ static void computeKnownBitsFromOperator(const Operator *I,
// inferred hold at original context instruction. TODO: It may be
// correct to use the original context. IF warranted, explore and
// add sufficient tests to cover.
- SimplifyQuery RecQ = Q;
+ SimplifyQuery RecQ = Q.getWithoutCondContext();
RecQ.CxtI = P;
computeKnownBits(R, DemandedElts, Known2, Depth + 1, RecQ);
switch (Opcode) {
@@ -1468,7 +1468,7 @@ static void computeKnownBitsFromOperator(const Operator *I,
// phi. This is important because that is where the value is actually
// "evaluated" even though it is used later somewhere else. (see also
// D69571).
- SimplifyQuery RecQ = Q;
+ SimplifyQuery RecQ = Q.getWithoutCondContext();
unsigned OpNum = P->getOperand(0) == R ? 0 : 1;
Instruction *RInst = P->getIncomingBlock(OpNum)->getTerminator();
@@ -1546,7 +1546,7 @@ static void computeKnownBitsFromOperator(const Operator *I,
// phi. This is important because that is where the value is actually
// "evaluated" even though it is used later somewhere else. (see also
// D69571).
- SimplifyQuery RecQ = Q;
+ SimplifyQuery RecQ = Q.getWithoutCondContext();
RecQ.CxtI = P->getIncomingBlock(u)->getTerminator();
Known2 = KnownBits(BitWidth);
@@ -2329,7 +2329,7 @@ bool isKnownToBeAPowerOfTwo(const Value *V, bool OrZero, unsigned Depth,
// it is an induction variable where in each step its value is a power of
// two.
auto *PN = cast<PHINode>(I);
- SimplifyQuery RecQ = Q;
+ SimplifyQuery RecQ = Q.getWithoutCondContext();
// Check if it is an induction variable and always power of two.
if (isPowerOfTwoRecurrence(PN, OrZero, Depth, RecQ))
@@ -2943,7 +2943,7 @@ static bool isKnownNonZeroFromOperator(const Operator *I,
return true;
// Check if all incoming values are non-zero using recursion.
- SimplifyQuery RecQ = Q;
+ SimplifyQuery RecQ = Q.getWithoutCondContext();
unsigned NewDepth = std::max(Depth, MaxAnalysisRecursionDepth - 1);
return llvm::all_of(PN->operands(), [&](const Use &U) {
if (U.get() == PN)
@@ -3509,7 +3509,7 @@ static bool isNonEqualPHIs(const PHINode *PN1, const PHINode *PN2,
if (UsedFullRecursion)
return false;
- SimplifyQuery RecQ = Q;
+ SimplifyQuery RecQ = Q.getWithoutCondContext();
RecQ.CxtI = IncomBB->getTerminator();
if (!isKnownNonEqual(IV1, IV2, DemandedElts, Depth + 1, RecQ))
return false;
@@ -4001,7 +4001,7 @@ static unsigned ComputeNumSignBitsImpl(const Value *V,
// Take the minimum of all incoming values. This can't infinitely loop
// because of our depth threshold.
- SimplifyQuery RecQ = Q;
+ SimplifyQuery RecQ = Q.getWithoutCondContext();
Tmp = TyBits;
for (unsigned i = 0, e = NumIncomingValues; i != e; ++i) {
if (Tmp == 1) return Tmp;
@@ -5909,10 +5909,10 @@ void computeKnownFPClass(const Value *V, const APInt &DemandedElts,
// Recurse, but cap the recursion to two levels, because we don't want
// to waste time spinning around in loops. We need at least depth 2 to
// detect known sign bits.
- computeKnownFPClass(
- IncValue, DemandedElts, InterestedClasses, KnownSrc,
- PhiRecursionLimit,
- Q.getWithInstruction(P->getIncomingBlock(U)->getTerminator()));
+ computeKnownFPClass(IncValue, DemandedElts, InterestedClasses, KnownSrc,
+ PhiRecursionLimit,
+ Q.getWithoutCondContext().getWithInstruction(
+ P->getIncomingBlock(U)->getTerminator()));
if (First) {
Known = KnownSrc;
|
[
{
"file": "llvm/test/Transforms/InstCombine/pr100298.ll",
"commands": [
"opt -S -passes=instcombine < %s"
],
"tests": [
{
"test_name": "pr100298",
"test_body": "define i16 @pr100298() {\nentry:\n br label %for.inc\n\nfor.inc: ; preds = %for.inc, %entry\n %indvar = phi i32 [ -15, %entry ], [ %mask, %for.inc ]\n %add = add nsw i32 %indvar, 9\n %mask = and i32 %add, 65535\n %cmp1 = icmp ugt i32 %mask, 5\n br i1 %cmp1, label %for.inc, label %for.end\n\nfor.end: ; preds = %for.inc\n %conv = trunc i32 %add to i16\n %cmp2 = icmp ugt i32 %mask, 3\n %shl = shl nuw i16 %conv, 14\n %res = select i1 %cmp2, i16 %conv, i16 %shl\n ret i16 %res\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Miscompilation at O3",
"body": "```\r\n#include \"csmith.h\"\r\nuint32_t a;\r\nint16_t c;\r\nvoid d() {\r\n for (a = -15; a >= 6; a = safe_add_func_uint16_t_u_u(a, 9))\r\n ;\r\n c = safe_lshift_func_int16_t_s_u(safe_lshift_func_uint16_t_u_s(a,14), 0);\r\n}\r\nint main() {\r\n d();\r\n printf(\"%d\\n\", c);\r\n return 0;\r\n}\r\n```\r\n\r\n```\r\ndtcxzyw@dtcxzyw:~/WorkSpace/Projects/compilers/LLVM/llvm-build$ gcc -O0 test.c -fsanitize=undefined -I/usr/include/csmith -w\r\ndtcxzyw@dtcxzyw:~/WorkSpace/Projects/compilers/LLVM/llvm-build$ ./a.out \r\n-16384\r\ndtcxzyw@dtcxzyw:~/WorkSpace/Projects/compilers/LLVM/llvm-build$ bin/clang -O3 test.c -I/usr/include/csmith -w\r\ndtcxzyw@dtcxzyw:~/WorkSpace/Projects/compilers/LLVM/llvm-build$ ./a.out \r\n0\r\n```\r\n\r\nllvm version: 2d6ff0c533aa1b0fe6d91764846f636c4a4e911c",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:analysis"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Reduced testcase: https://alive2.llvm.org/ce/z/9fExrA\r\n```\r\n; bin/opt -passes=instcombine test.ll -S\r\ndefine i16 @src() {\r\nentry:\r\n br label %for.inc\r\n\r\nfor.inc:\r\n %storemerge6 = phi i32 [ -15, %entry ], [ %conv1, %for.inc ]\r\n %add.i = add nsw i32 %storemerge6, 9\r\n %conv1 = and i32 %add.i, 65535\r\n %cmp = icmp ugt i32 %conv1, 5\r\n br i1 %cmp, label %for.inc, label %for.end\r\n\r\nfor.end:\r\n %conv2 = trunc nuw nsw i32 %conv1 to i16\r\n %cmp3.i = icmp ugt i32 %conv1, 3\r\n %0 = shl nuw i16 %conv2, 14\r\n %cond.in.i = select i1 %cmp3.i, i16 %conv2, i16 %0\r\n ret i16 %cond.in.i\r\n}\r\n```"
}
]
}
| true |
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
| null |
148260
|
https://github.com/llvm/llvm-project/issues/148260
|
crash
|
69ea174bf07533b7f63139f78b0ec3d3766aedc4
| 2025-07-11T16:27:05 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "c363a3f9c858b38afa34f3a8ebcc3fa7a4062315",
"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": [
[
8112,
8118
],
[
8120,
8125
]
],
"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": [
"VPRecipeBuilder::getScaledReductions"
],
"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 c363a3f9c858b38afa34f3a8ebcc3fa7a4062315
Author: David Sherwood <david.sherwood@arm.com>
Date: Tue Jul 15 09:54:58 2025 +0100
[LV] Ensure getScaledReductions only matches extends inside the loop (#148264)
In getScaledReductions for the case where we try to match a partial
reduction of the form:
%phi = phi i32 ...
...
%add = add i32 %phi, %zext
where
%zext = i8 %some_val to i32
we should ensure that %zext is actually inside the loop.
Fixes https://github.com/llvm/llvm-project/issues/148260
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 5380a0fc6498..06db89a89bc3 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -8112,7 +8112,7 @@ bool VPRecipeBuilder::getScaledReductions(
std::optional<unsigned> BinOpc;
Type *ExtOpTypes[2] = {nullptr};
- auto CollectExtInfo = [&Exts,
+ auto CollectExtInfo = [this, &Exts,
&ExtOpTypes](SmallVectorImpl<Value *> &Ops) -> bool {
unsigned I = 0;
for (Value *OpI : Ops) {
@@ -8120,6 +8120,11 @@ bool VPRecipeBuilder::getScaledReductions(
if (!match(OpI, m_ZExtOrSExt(m_Value(ExtOp))))
return false;
Exts[I] = cast<Instruction>(OpI);
+
+ // TODO: We should be able to support live-ins.
+ if (!CM.TheLoop->contains(Exts[I]))
+ return false;
+
ExtOpTypes[I] = ExtOp->getType();
I++;
}
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-interleave=1 -enable-epilogue-vectorization=false -S < %s",
"opt -passes=loop-vectorize -enable-epilogue-vectorization=false -S < %s",
"opt -passes=loop-vectorize -force-vector-interleave=1 -vectorizer-maximize-bandwidth -enable-epilogue-vectorization=false -S < %s"
],
"tests": [
{
"test_name": "add_of_zext_outside_loop",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i32 @add_of_zext_outside_loop(i32 %a, ptr noalias %b, i8 %c, i32 %d) #0 {\nentry:\n %conv1 = zext i8 %c to i32\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i32 [ %d, %entry ], [ %iv.next, %for.body ]\n %rdx = phi i32 [ %a, %entry ], [ %rdx.next, %for.body ]\n %arrayidx = getelementptr inbounds i8, ptr %b, i32 %iv\n store i8 0, ptr %arrayidx, align 1\n %rdx.next = add nsw i32 %rdx, %conv1\n %iv.next = add nuw nsw i32 %iv, 1\n %cmp = icmp eq i32 %iv.next, 1024\n br i1 %cmp, label %exit, label %for.body\n\nexit: ; preds = %for.body\n %add.lcssa = phi i32 [ %rdx.next, %for.body ]\n ret i32 %add.lcssa\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "add_of_loop_invariant_zext",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i32 @add_of_loop_invariant_zext(i32 %a, ptr %b, i8 %c, i32 %d) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i32 [ %d, %entry ], [ %iv.next, %for.body ]\n %rdx = phi i32 [ %a, %entry ], [ %rdx.next, %for.body ]\n %arrayidx = getelementptr inbounds i8, ptr %b, i32 %iv\n store i8 0, ptr %arrayidx, align 1\n %conv1 = zext i8 %c to i32\n %rdx.next = add nsw i32 %rdx, %conv1\n %iv.next = add nuw nsw i32 %iv, 1\n %cmp = icmp eq i32 %iv.next, 1024\n br i1 %cmp, label %exit, label %for.body\n\nexit: ; preds = %for.body\n %add.lcssa = phi i32 [ %rdx.next, %for.body ]\n ret i32 %add.lcssa\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[LV] Assertion `Val && \"isa<> used on a null pointer\"' failed",
"body": "Compile this:\n\n```\nint a;\nextern bool b[];\nchar d, c;\nvoid f() {\n for (int e(d); e; e += 4LL) {\n b[e] = 0;\n a += c;\n }\n}\n```\n\nwith:\n\n clang++ -Ofast -mcpu=grace -c func.cpp\n\nto trigger this assert:\n\n```\nllvm/include/llvm/Support/Casting.h:109: static bool llvm::isa_impl_cl<llvm::VPWidenCastRecipe, const llvm::VPRecipeBase *>::doit(const From *) [To = llvm::VPWidenCastRecipe, From = const llvm::VPRecipeBase *]: Assertion `Val && \"isa<> used on a null pointer\"' failed.\n```\n\nSee also: https://godbolt.org/z/G9nM71bbr",
"author": "sjoerdmeijer",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "david-arm",
"body": "OK I'll take a look."
},
{
"author": "david-arm",
"body": "I think I have a fix. We're attempting to match a partial reduction where the extended value lives outside the loop."
},
{
"author": "david-arm",
"body": "@sjoerdmeijer FYI https://github.com/llvm/llvm-project/pull/148264"
},
{
"author": "sjoerdmeijer",
"body": "Thanks for the quick fix @david-arm !"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
105785
|
https://github.com/llvm/llvm-project/issues/105785
|
miscompilation
|
1241c762c165972690c4edfb82ec7421c1e64658
| 2024-08-23T05:45:52 |
[
"llvm/test/Transforms/ConstraintElimination"
] |
{
"fix_commit": "85b6aac7c25f9d2a976a76045ace1e7afebb5965",
"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": [
[
1464,
1470
]
],
"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": [
"checkAndReplaceCmp"
],
"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 3ff9d92aae0945daa85ec6f85f05a3aeaaa9f962
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Fri Aug 23 16:06:00 2024 +0800
[ConstraintElim] Fix miscompilation caused by PR97974 (#105790)
Fixes https://github.com/llvm/llvm-project/issues/105785.
(cherry picked from commit 85b6aac7c25f9d2a976a76045ace1e7afebb5965)
diff --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
index c31173879af1..37022104d0a9 100644
--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -1464,7 +1464,7 @@ static bool checkAndReplaceCmp(CmpIntrinsic *I, ConstraintInfo &Info,
ToRemove.push_back(I);
return true;
}
- if (checkCondition(ICmpInst::ICMP_EQ, LHS, RHS, I, Info)) {
+ if (checkCondition(ICmpInst::ICMP_EQ, LHS, RHS, I, Info).value_or(false)) {
I->replaceAllUsesWith(ConstantInt::get(I->getType(), 0));
ToRemove.push_back(I);
return true;
|
[
{
"file": "llvm/test/Transforms/ConstraintElimination/pr105785.ll",
"commands": [
"opt -passes=constraint-elimination -S %s"
],
"tests": [
{
"test_name": "pr105785",
"test_body": "define void @pr105785(ptr %p) {\nentry:\n br label %for.cond\n\nfor.cond: ; preds = %for.cond1, %entry\n %for.ind = phi i32 [ 0, %entry ], [ 1, %for.cond1 ]\n %cmp = icmp eq i32 %for.ind, 0\n br i1 %cmp, label %for.cond1, label %for.end6\n\nfor.cond1: ; preds = %for.body3, %for.cond\n %for.ind2 = phi i32 [ %inc, %for.body3 ], [ 0, %for.cond ]\n %cmp2 = icmp ult i32 %for.ind2, 3\n br i1 %cmp2, label %for.body3, label %for.cond\n\nfor.body3: ; preds = %for.cond1\n %scmp = call i32 @llvm.scmp.i32.i32(i32 %for.ind, i32 1)\n store i32 %scmp, ptr %p, align 4\n %inc = add nuw nsw i32 %for.ind2, 1\n br label %for.cond1\n\nfor.end6: ; preds = %for.cond\n ret void\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.scmp.i32.i32(i32, i32) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": "-src-unroll=4 -tgt-unroll=4"
}
]
}
] |
{
"title": "[ConstraintElim] Miscompilation with cmp intrinsic",
"body": "Reproducer: https://alive2.llvm.org/ce/z/Tvz2NA\r\n```\r\n; bin/opt -passes=constraint-elimination test.ll -S\r\ndefine void @h(ptr %p) {\r\nentry:\r\n br label %for.cond\r\n\r\nfor.cond: ; preds = %for.cond1, %entry\r\n %storemerge = phi i32 [ 0, %entry ], [ 1, %for.cond1 ]\r\n %cmp = icmp eq i32 %storemerge, 0\r\n br i1 %cmp, label %for.cond1, label %for.end6\r\n\r\nfor.cond1: ; preds = %for.cond, %for.body3\r\n %i.0 = phi i32 [ %inc, %for.body3 ], [ 0, %for.cond ]\r\n %cmp2 = icmp ult i32 %i.0, 3\r\n br i1 %cmp2, label %for.body3, label %for.cond\r\n\r\nfor.body3: ; preds = %for.cond1\r\n %sub.i = tail call range(i32 -1, 2) i32 @llvm.scmp.i32.i32(i32 1, i32 %storemerge)\r\n store i32 %sub.i, ptr %p, align 4\r\n %inc = add nuw nsw i32 %i.0, 1\r\n br label %for.cond1\r\n\r\nfor.end6:\r\n ret void\r\n}\r\n```\r\n\r\n```\r\ndefine void @h(ptr %p) {\r\nentry:\r\n br label %for.cond\r\n\r\nfor.cond: ; preds = %for.cond1, %entry\r\n %storemerge = phi i32 [ 0, %entry ], [ 1, %for.cond1 ]\r\n %cmp = icmp eq i32 %storemerge, 0\r\n br i1 %cmp, label %for.cond1, label %for.end6\r\n\r\nfor.cond1: ; preds = %for.body3, %for.cond\r\n %i.0 = phi i32 [ %inc, %for.body3 ], [ 0, %for.cond ]\r\n %cmp2 = icmp ult i32 %i.0, 3\r\n br i1 %cmp2, label %for.body3, label %for.cond\r\n\r\nfor.body3: ; preds = %for.cond1\r\n store i32 0, ptr %p, align 4\r\n %inc = add nuw nsw i32 %i.0, 1\r\n br label %for.cond1\r\n\r\nfor.end6: ; preds = %for.cond\r\n ret void\r\n}\r\n```\r\n\r\nThe result of scmp should be 1 instead of 0.\r\n\r\nReduced C reproducer:\r\n```\r\n#include <stdio.h>\r\n#include <stdint.h>\r\n\r\nint builtin_scmp(int d, int e) { return (d > e) - (d < e); }\r\nint32_t f = 0;\r\nint64_t g = 0;\r\nvoid h() {\r\n for (f = 0; f <= 0; f++) {\r\n int i;\r\n for (i = 0; i < 3; i++)\r\n g = builtin_scmp(1, f);\r\n }\r\n}\r\nint main() {\r\n h();\r\n printf(\"%d\\n\", (int)g);\r\n return 0;\r\n}\r\n```\r\n\r\nI will post a fix later.\r\n",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:transforms"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
95520
|
https://github.com/llvm/llvm-project/issues/95520
|
crash
|
e7acb3792b8ba971bda2c9564ed26c2a60a2ddbc
| 2024-06-14T09:26:34 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "40a72f8cc414726a8be234a260650fd62354da21",
"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": [
[
577,
583
]
],
"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": [
[
231,
236
]
],
"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": [
"VPInstruction::generatePerPart"
],
"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 40a72f8cc414726a8be234a260650fd62354da21
Author: Florian Hahn <flo@fhahn.com>
Date: Fri Jun 14 22:16:51 2024 +0100
[VPlan] Support extracting any lane of uniform value.
If the value we are extracting a lane from is uniform, only the first
lane will be set. Return lane 0 for any requested lane.
This fixes a crash when trying to extract the last lane for a
first-order recurrence resume value.
Fixes https://github.com/llvm/llvm-project/issues/95520.
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index f17be451e684..348a2be5072b 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -231,6 +231,11 @@ Value *VPTransformState::get(VPValue *Def, const VPIteration &Instance) {
return Data
.PerPartScalars[Def][Instance.Part][Instance.Lane.mapToCacheIndex(VF)];
}
+ if (!Instance.Lane.isFirstLane() &&
+ vputils::isUniformAfterVectorization(Def) &&
+ hasScalarValue(Def, {Instance.Part, VPLane::getFirstLane()})) {
+ return Data.PerPartScalars[Def][Instance.Part][0];
+ }
assert(hasVectorValue(Def, Instance.Part));
auto *VecPart = Data.PerPartOutput[Def][Instance.Part];
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index 7a482455473e..a3ff6395bb39 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -577,7 +577,8 @@ Value *VPInstruction::generatePerPart(VPTransformState &State, unsigned Part) {
// When loop is unrolled without vectorizing, retrieve UF - Offset.
Res = State.get(getOperand(0), State.UF - Offset);
}
- Res->setName(Name);
+ if (isa<ExtractElementInst>(Res))
+ Res->setName(Name);
return Res;
}
case VPInstruction::LogicalAnd: {
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/reduction-recurrence-costs-sve.ll",
"commands": [
"opt -p loop-vectorize -S %s",
"opt -p loop-vectorize -prefer-predicate-over-epilogue=predicate-else-scalar-epilogue -S %s"
],
"tests": [
{
"test_name": "chained_recurrences",
"test_body": "target datalayout = \"e-m:o-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"arm64-apple-macosx14.0.0\"\n\ndefine i32 @chained_recurrences(i32 %x, i64 %y, ptr %src.1, i32 %z, ptr %src.2) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %0 = phi i32 [ 0, %entry ], [ %3, %loop ]\n %1 = phi i32 [ 0, %entry ], [ %0, %loop ]\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %sum.red = phi i32 [ 0, %entry ], [ %red.2, %loop ]\n %2 = add i64 %y, 1\n %gep.1 = getelementptr i32, ptr %src.1, i64 %2\n %3 = load i32, ptr %gep.1, align 4\n %or3 = or i32 %1, %x\n %iv.next = add i64 %iv, 1\n %shr = lshr i32 %x, 1\n %4 = shl i32 %or3, 1\n %5 = or i32 %4, 2\n %shl19 = shl i32 %x, 1\n %6 = or i32 %shr, %shl19\n %7 = or i32 %6, %5\n %8 = or i32 %7, %x\n %or20 = or i32 %z, %x\n %not = and i32 %or20, 1\n %and = xor i32 %not, 1\n %idx.ext.1 = zext i32 %and to i64\n %gep.2 = getelementptr i32, ptr %src.2, i64 %idx.ext.1\n %9 = load i32, ptr %gep.2, align 4\n %shr24 = lshr i32 %8, 1\n %idx.ext.2 = zext i32 %shr24 to i64\n %gep.3 = getelementptr i32, ptr %src.2, i64 %idx.ext.2\n %10 = load i32, ptr %gep.3, align 4\n %red.1 = or i32 %9, %sum.red\n %red.2 = or i32 %red.1, %10\n %ec = icmp eq i64 %iv, %y\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i32 %red.2\n}\n\nattributes #0 = { \"target-features\"=\"+sve\" }\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/first-order-recurrence-chains.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -S %s"
],
"tests": [
{
"test_name": "test_resinking_required",
"test_body": "define double @test_resinking_required(ptr %p, ptr noalias %a, ptr noalias %b) {\nEntry:\n br label %Loop\n\nLoop: ; preds = %Loop, %Entry\n %for.1 = phi double [ %l1, %Loop ], [ 0.000000e+00, %Entry ]\n %for.2 = phi double [ %l2, %Loop ], [ 0.000000e+00, %Entry ]\n %for.3 = phi double [ %for.2, %Loop ], [ 0.000000e+00, %Entry ]\n %iv = phi i64 [ %iv.next, %Loop ], [ 0, %Entry ]\n %USE_2_FORS = fdiv double %for.3, %for.1\n %div = fdiv double 0.000000e+00, %for.1\n %l1 = load double, ptr %a, align 8\n %iv.next = add nuw nsw i64 %iv, 1\n %l2 = load double, ptr %b, align 8\n store double %div, ptr %p, align 8\n %cond = icmp eq i64 %iv.next, 0\n br i1 %cond, label %End, label %Loop\n\nEnd: ; preds = %Loop\n %res.1 = fadd double %for.1, %for.2\n %res.2 = fadd double %res.1, %for.3\n ret double %res.2\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/first-order-recurrence-complex.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -S %s"
],
"tests": [
{
"test_name": "instruction_with_2_FOR_operands_and_multiple_other_uses_chain",
"test_body": "define void @instruction_with_2_FOR_operands_and_multiple_other_uses_chain(ptr noalias %dst.1, ptr noalias %dst.2, ptr noalias %dst.3, ptr noalias %for.ptr.1, ptr noalias %for.ptr.2) {\nbb:\n br label %loop\n\nloop: ; preds = %loop, %bb\n %for.1 = phi float [ 0.000000e+00, %bb ], [ %for.1.next, %loop ]\n %for.2 = phi float [ 0.000000e+00, %bb ], [ %for.2.next, %loop ]\n %iv = phi i64 [ 0, %bb ], [ %iv.next, %loop ]\n %for.1.use.1 = fmul fast float %for.1, 2.000000e+00\n %for.1.use.c = fmul fast float %for.1.use.1, 2.000000e+00\n %used.by.both = fmul fast float %for.1.use.c, %for.2\n %for.2.next = load float, ptr %for.ptr.2, align 4\n %for.1.use.3 = fadd fast float %for.1, 1.000000e+00\n %iv.next = add nuw nsw i64 %iv, 1\n %for.1.next = load float, ptr %for.ptr.1, align 4\n %gep.dst.1 = getelementptr inbounds float, ptr %dst.1, i64 %iv\n store float %used.by.both, ptr %gep.dst.1, align 4\n %gep.dst.2 = getelementptr inbounds float, ptr %dst.2, i64 %iv\n store float %for.1.use.1, ptr %gep.dst.2, align 4\n %gep.dst.3 = getelementptr inbounds float, ptr %dst.3, i64 %iv\n store float %for.1.use.3, ptr %gep.dst.3, align 4\n %ec = icmp slt i64 %iv, 1000\n br i1 %ec, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "instruction_with_2_FOR_operands_and_multiple_other_uses",
"test_body": "define void @instruction_with_2_FOR_operands_and_multiple_other_uses(ptr noalias %dst.1, ptr noalias %dst.2, ptr noalias %dst.3, ptr noalias %for.ptr.1, ptr noalias %for.ptr.2) {\nbb:\n br label %loop\n\nloop: ; preds = %loop, %bb\n %for.1 = phi float [ 0.000000e+00, %bb ], [ %for.1.next, %loop ]\n %for.2 = phi float [ 0.000000e+00, %bb ], [ %for.2.next, %loop ]\n %iv = phi i64 [ 0, %bb ], [ %iv.next, %loop ]\n %for.1.use.1 = fmul fast float %for.1, 2.000000e+00\n %used.by.both = fmul fast float %for.1, %for.2\n %for.2.next = load float, ptr %for.ptr.2, align 4\n %for.1.use.3 = fadd fast float %for.1, 1.000000e+00\n %iv.next = add nuw nsw i64 %iv, 1\n %for.1.next = load float, ptr %for.ptr.1, align 4\n %gep.dst.1 = getelementptr inbounds float, ptr %dst.1, i64 %iv\n store float %used.by.both, ptr %gep.dst.1, align 4\n %gep.dst.2 = getelementptr inbounds float, ptr %dst.2, i64 %iv\n store float %for.1.use.1, ptr %gep.dst.2, align 4\n %gep.dst.3 = getelementptr inbounds float, ptr %dst.3, i64 %iv\n store float %for.1.use.3, ptr %gep.dst.3, align 4\n %ec = icmp slt i64 %iv, 1000\n br i1 %ec, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "instruction_with_2_FOR_operands",
"test_body": "define void @instruction_with_2_FOR_operands(ptr noalias %A, ptr noalias %B, ptr noalias %C) {\nbb:\n br label %bb13\n\nbb13: ; preds = %bb13, %bb\n %tmp37 = phi float [ %tmp60, %bb13 ], [ 0.000000e+00, %bb ]\n %tmp27 = phi float [ %tmp49, %bb13 ], [ 1.000000e+00, %bb ]\n %iv = phi i64 [ %iv.next, %bb13 ], [ 0, %bb ]\n %tmp38 = fmul fast float %tmp37, %tmp27\n %iv.next = add nuw nsw i64 %iv, 1\n %gep = getelementptr inbounds float, ptr %C, i64 %iv\n %tmp49 = load float, ptr %A, align 4\n %tmp60 = load float, ptr %B, align 4\n store float %tmp38, ptr %gep, align 4\n %tmp12 = icmp slt i64 %iv, 1000\n br i1 %tmp12, label %bb13, label %bb74\n\nbb74: ; preds = %bb13\n ret void\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_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
},
{
"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
}
]
},
{
"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
}
]
}
] |
{
"title": "Assertion `hasVectorValue(Def, Instance.Part)' failed.",
"body": "To reproduce run the following test opt 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 i32 @wombat() gc \"statepoint-example\" {\r\nbb:\r\n br label %bb2\r\n\r\nbb1: ; preds = %bb2\r\n ret i32 0\r\n\r\nbb2: ; preds = %bb2, %bb\r\n %phi = phi i64 [ 0, %bb ], [ %add, %bb2 ]\r\n %phi3 = phi i32 [ 0, %bb ], [ %load, %bb2 ]\r\n %add = add i64 %phi, 1\r\n %load = load i32, ptr addrspace(1) null, align 4\r\n %icmp = icmp ult i64 %phi, 1\r\n br i1 %icmp, label %bb2, label %bb1\r\n}\r\n```\r\nReproducer: https://godbolt.org/z/cv7Tf3vba\r\n\r\nStack dump:\r\n```\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes loop-vectorize <source>\r\n #0 0x0000000004e41688 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e41688)\r\n #1 0x0000000004e3eddc SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007ec2abe42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x00007ec2abe969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x00007ec2abe42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x00007ec2abe287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00007ec2abe2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x00007ec2abe39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x0000000003fecdce (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3fecdce)\r\n #9 0x0000000004008abe llvm::VPInstruction::generatePerPart(llvm::VPTransformState&, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4008abe)\r\n#10 0x000000000400ae5e llvm::VPInstruction::execute(llvm::VPTransformState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x400ae5e)\r\n#11 0x0000000003fe5fbf llvm::VPBasicBlock::executeRecipes(llvm::VPTransformState*, llvm::BasicBlock*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3fe5fbf)\r\n#12 0x0000000003fe9cb0 llvm::VPBasicBlock::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3fe9cb0)\r\n#13 0x0000000003feda3e llvm::VPlan::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3feda3e)\r\n#14 0x0000000003eda4e5 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+0x3eda4e5)\r\n#15 0x0000000003eef18b llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3eef18b)\r\n#16 0x0000000003ef1a4d llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3ef1a4d)\r\n#17 0x0000000003ef2c5b llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3ef2c5b)\r\n#18 0x0000000002e0679e 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+0x2e0679e)\r\n#19 0x0000000004c49a6c llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4c49a6c)\r\n#20 0x0000000000dbabee 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+0xdbabee)\r\n#21 0x0000000004c483ae llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4c483ae)\r\n#22 0x0000000000dbc65e 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+0xdbc65e)\r\n#23 0x0000000004c462bc llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4c462bc)\r\n#24 0x00000000008db912 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+0x8db912)\r\n#25 0x00000000008ceabc optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8ceabc)\r\n#26 0x00007ec2abe29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#27 0x00007ec2abe29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#28 0x00000000008c5f0e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8c5f0e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```\r\n\r\n",
"author": "TatyanaDoubts",
"labels": [
"vectorizers",
"crash-on-valid"
],
"comments": [
{
"author": "dtcxzyw",
"body": "cc @fhahn "
}
]
}
| true |
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
| null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.