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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|
94897
|
https://github.com/llvm/llvm-project/issues/94897
|
miscompilation
|
add89088fb8de84fdbeb97c0386a831e51d090a1
| 2024-06-09T10:15:35 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "e4b0655b297e4f4b0eb26548c8be48d527ebc178",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": [
[
2441,
2449
]
],
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": [
"InstCombinerImpl::foldICmpShlConstant"
],
"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 e4b0655b297e4f4b0eb26548c8be48d527ebc178
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Mon Jun 10 03:17:01 2024 +0800
[InstCombine] Fix missing argument typo in `InstCombinerImpl::foldICmpShlConstant` (#94899)
Closes #94897.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 4203147bc6a5..3fce4a3c20b3 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -2441,9 +2441,10 @@ Instruction *InstCombinerImpl::foldICmpShlConstant(ICmpInst &Cmp,
Type *TruncTy = ShType->getWithNewBitWidth(TypeBits - Amt);
Constant *NewC =
ConstantInt::get(TruncTy, RHSC.ashr(*ShiftAmt).trunc(TypeBits - Amt));
- return new ICmpInst(
- CmpPred, Builder.CreateTrunc(X, TruncTy, "", Shl->hasNoSignedWrap()),
- NewC);
+ return new ICmpInst(CmpPred,
+ Builder.CreateTrunc(X, TruncTy, "", /*IsNUW=*/false,
+ Shl->hasNoSignedWrap()),
+ NewC);
}
}
|
[
{
"file": "llvm/test/Transforms/InstCombine/icmp.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "test_icmp_shl_sgt",
"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 @test_icmp_shl_sgt(i64 %x) {\n %shl = shl i64 %x, 32\n %cmp = icmp sgt i64 %shl, 8589934591\n ret i1 %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_icmp_shl_nuw_i31",
"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 @test_icmp_shl_nuw_i31(i31 %x) {\n %shl = shl nuw i31 %x, 23\n %cmp = icmp ugt i31 %shl, -50331648\n ret i1 %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_icmp_shl_vec",
"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 <2 x i1> @test_icmp_shl_vec(<2 x i64> %x) {\n %shl = shl <2 x i64> %x, splat (i64 32)\n %cmp = icmp ult <2 x i64> %shl, splat (i64 8589934593)\n ret <2 x i1> %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_icmp_shl_nsw_i31",
"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 @test_icmp_shl_nsw_i31(i31 %x) {\n %shl = shl nsw i31 %x, 23\n %cmp = icmp ugt i31 %shl, -50331648\n ret i1 %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_icmp_shl_nsw",
"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 @test_icmp_shl_nsw(i64 %x) {\n %shl = shl nsw i64 %x, 32\n %cmp = icmp ult i64 %shl, 8589934593\n ret i1 %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "pr94897",
"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 @pr94897(i32 range(i32 -2147483648, 0) %x) {\n %shl = shl nsw i32 %x, 24\n %cmp = icmp ugt i32 %shl, -50331648\n ret i1 %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_icmp_shl_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 @test_icmp_shl_nuw(i64 %x) {\n %shl = shl nuw i64 %x, 32\n %cmp = icmp ult i64 %shl, 8589934593\n ret i1 %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "wrong code at -O1 and above on x86_64-linux-gnu",
"body": "This appears to be a recent regression as it doesn't reproduce with 18.1.0 and earlier.\r\n\r\nCompiler Explorer: https://godbolt.org/z/T9b4a7z3v\r\n\r\n```console\r\n% clangtk -v\r\nclang version 19.0.0git (https://github.com/llvm/llvm-project.git 338cbfef03e0ab58d7b52f3301928c58b194a1b4)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\r\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nCandidate multilib: .;@m64\r\nSelected multilib: .;@m64\r\n% \r\n% clangtk -O0 small.c; ./a.out\r\n% clangtk -O1 small.c\r\n% ./a.out\r\nAborted\r\n% cat small.c\r\nint a;\r\nchar b(char c, char d) { return c - d; }\r\nint main() {\r\n int e;\r\n for (a = -10; a > -11; a--)\r\n e = b(a, -1);\r\n if (e > -2)\r\n __builtin_abort();\r\n return 0;\r\n}\r\n```",
"author": "zhendongsu",
"labels": [
"miscompilation",
"confirmed",
"llvm:instcombine"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Reproducer: https://alive2.llvm.org/ce/z/_3cyuT\r\n```ll\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\r\n\r\ndefine i1 @src() {\r\nentry:\r\n br label %for.body\r\n\r\nfor.body:\r\n %storemerge4 = phi i32 [ -10, %entry ], [ %dec, %for.body ]\r\n %dec = add nsw i32 %storemerge4, -1\r\n %cmp = icmp ugt i32 %dec, -11\r\n br i1 %cmp, label %for.body, label %for.end\r\n\r\nfor.end:\r\n %sub.i.le = shl nsw i32 %storemerge4, 24\r\n %cmp2 = icmp ugt i32 %sub.i.le, -50331648\r\n ret i1 %cmp2\r\n}\r\n\r\ndefine i1 @tgt() {\r\nentry:\r\n br label %for.body\r\n\r\nfor.body:\r\n %storemerge4 = phi i32 [ -10, %entry ], [ %dec, %for.body ]\r\n %dec = add nsw i32 %storemerge4, -1\r\n %cmp = icmp ugt i32 %dec, -11\r\n br i1 %cmp, label %for.body, label %for.end\r\n\r\nfor.end:\r\n %0 = trunc nuw i32 %storemerge4 to i8\r\n %cmp2 = icmp ugt i8 %0, -3\r\n ret i1 %cmp2\r\n}\r\n```\r\n\r\n`nuw` flag is incorrectly added."
},
{
"author": "dtcxzyw",
"body": "Caused by https://github.com/llvm/llvm-project/commit/5c7c1f6aba467b1c5a51d58fc591314ecd7147ce."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
133751
|
https://github.com/llvm/llvm-project/issues/133751
|
crash
|
2d7add6e2e56baf46504a8a22dec42b61f63360f
| 2025-03-31T16:55:56 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "bfd8cc0a3e82c5e6345a66dd5db5242accb6874b",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
8854,
8860
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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 bfd8cc0a3e82c5e6345a66dd5db5242accb6874b
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Mon Mar 31 10:31:18 2025 -0700
[SLP]Fix a check for the whole register use
Need to check the value type, not the return type, of the instructions,
when doing the analysis for the whole register use to prevent a compiler
crash.
Fixes #133751
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index a4b0378abc07..0679eac17658 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -8854,7 +8854,8 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
// FIXME: Reshuffing scalars is not supported yet for non-power-of-2 ops.
if ((UserTreeIdx.UserTE &&
UserTreeIdx.UserTE->hasNonWholeRegisterOrNonPowerOf2Vec(*TTI)) ||
- !hasFullVectorsOrPowerOf2(*TTI, VL.front()->getType(), VL.size())) {
+ !hasFullVectorsOrPowerOf2(*TTI, getValueType(VL.front()),
+ VL.size())) {
LLVM_DEBUG(dbgs() << "SLP: Reshuffling scalars not yet supported "
"for nodes with padding.\n");
auto Invalid = ScheduleBundle::invalid();
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/cmp-values-non-full-registers.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-grtev4-linux-gnu < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @test() {\n;\nentry:\n br i1 false, label %bb1, label %bb2\n\nbb2:\n %cmp14.us = fcmp ogt x86_fp80 0xK00000000000000000000, 0xK00000000000000000000\n %imax.2.us = select i1 %cmp14.us, i64 0, i64 0\n %jmax.2.us = select i1 %cmp14.us, i64 0, i64 0\n %cmp13.us = fcmp olt x86_fp80 0xK00000000000000000000, 0xK00000000000000000000\n %imin.2.us = select i1 %cmp13.us, i64 0, i64 0\n %jmin.2.us = select i1 %cmp13.us, i64 0, i64 0\n br label %bb1\n\nbb1:\n %storemerge64 = phi i64 [ 0, %entry ], [ %imin.2.us, %bb2 ]\n %storemerge63 = phi i64 [ 0, %entry ], [ %jmin.2.us, %bb2 ]\n %storemerge62 = phi i64 [ 0, %entry ], [ %imax.2.us, %bb2 ]\n %storemerge = phi i64 [ 0, %entry ], [ %jmax.2.us, %bb2 ]\n ret void\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "SLPVectorizer: \"Reshuffling scalars not yet supported for nodes with padding\" assert",
"body": "```\n$ cat /tmp/a.ll\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-grtev4-linux-gnu\"\n\ndefine void @gsl_matrix_long_double_minmax_index() {\nentry:\n br i1 false, label %cleanup22, label %for.cond6.preheader.us.preheader\n\nfor.cond6.preheader.us.preheader: ; preds = %entry\n %cmp14.us = fcmp ogt x86_fp80 0xK00000000000000000000, 0xK00000000000000000000\n %imax.2.us = select i1 %cmp14.us, i64 0, i64 0\n %jmax.2.us = select i1 %cmp14.us, i64 0, i64 0\n %cmp13.us = fcmp olt x86_fp80 0xK00000000000000000000, 0xK00000000000000000000\n %imin.2.us = select i1 %cmp13.us, i64 0, i64 0\n %jmin.2.us = select i1 %cmp13.us, i64 0, i64 0\n br label %cleanup22\n\ncleanup22: ; preds = %for.cond6.preheader.us.preheader, %entry\n %storemerge64 = phi i64 [ 0, %entry ], [ %imin.2.us, %for.cond6.preheader.us.preheader ]\n %storemerge63 = phi i64 [ 0, %entry ], [ %jmin.2.us, %for.cond6.preheader.us.preheader ]\n %storemerge62 = phi i64 [ 0, %entry ], [ %imax.2.us, %for.cond6.preheader.us.preheader ]\n %storemerge = phi i64 [ 0, %entry ], [ %jmax.2.us, %for.cond6.preheader.us.preheader ]\n ret void\n}\n$ opt -p slp-vectorizer /tmp/a.ll -disable-output\nopt: ../../llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:3714: TreeEntry *llvm::slpvectorizer::BoUpSLP::newTreeEntry(ArrayRef<Value *>, TreeEntry::EntryState, ScheduleBundle &, const InstructionsState &, const EdgeInfo &, ArrayRef<int>, ArrayRef<unsigned int>): Assertion `(hasFullVectorsOrPowerOf2(*TTI, \ngetValueType(VL.front()), VL.size()) || ReuseShuffleIndices.empty()) && \"Reshuffling scalars not yet supported for nodes with padding\"' failed. \n\n```\n\n@alexey-bataev ",
"author": "aeubanks",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
139103
|
https://github.com/llvm/llvm-project/issues/139103
|
crash
|
77d1db6df757ff86c69661e02dd5b402e120e5f5
| 2025-05-08T16:09:31 |
[
"llvm/test/Analysis/MemorySSA"
] |
{
"fix_commit": "05f1e313948768fdd8527969cd79809cbd0654ff",
"components": [
"MemorySSAUpdater"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": [
[
1119,
1124
],
[
1135,
1144
]
],
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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::applyInsertUpdates"
],
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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 05f1e313948768fdd8527969cd79809cbd0654ff
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Sat May 10 21:48:26 2025 +0800
[MemorySSAUpdater] Fix iterator invalidation bug in `applyInsertUpdates` (#139370)
This patch defers resetting optimized accesses until all uses are
replaced, to avoid invalidating the iterator.
Closes https://github.com/llvm/llvm-project/issues/139103.
Closes https://github.com/llvm/llvm-project/issues/139289.
Closes https://github.com/llvm/llvm-project/issues/139308.
diff --git a/llvm/lib/Analysis/MemorySSAUpdater.cpp b/llvm/lib/Analysis/MemorySSAUpdater.cpp
index aa9f0b6e100c..ecfecb03c375 100644
--- a/llvm/lib/Analysis/MemorySSAUpdater.cpp
+++ b/llvm/lib/Analysis/MemorySSAUpdater.cpp
@@ -1119,6 +1119,9 @@ void MemorySSAUpdater::applyInsertUpdates(ArrayRef<CFGUpdate> Updates,
if (auto DefsList = MSSA->getWritableBlockDefs(BlockWithDefsToReplace)) {
for (auto &DefToReplaceUses : *DefsList) {
BasicBlock *DominatingBlock = DefToReplaceUses.getBlock();
+ // We defer resetting optimized accesses until all uses are replaced, to
+ // avoid invalidating the iterator.
+ SmallVector<MemoryUseOrDef *, 4> ResetOptimized;
for (Use &U : llvm::make_early_inc_range(DefToReplaceUses.uses())) {
MemoryAccess *Usr = cast<MemoryAccess>(U.getUser());
if (MemoryPhi *UsrPhi = dyn_cast<MemoryPhi>(Usr)) {
@@ -1135,10 +1138,13 @@ void MemorySSAUpdater::applyInsertUpdates(ArrayRef<CFGUpdate> Updates,
assert(IDom && "Block must have a valid IDom.");
U.set(GetLastDef(IDom->getBlock()));
}
- cast<MemoryUseOrDef>(Usr)->resetOptimized();
+ ResetOptimized.push_back(cast<MemoryUseOrDef>(Usr));
}
}
}
+
+ for (auto *Usr : ResetOptimized)
+ Usr->resetOptimized();
}
}
}
|
[
{
"file": "llvm/test/Analysis/MemorySSA/pr139103.ll",
"commands": [
"opt -disable-output -passes=\"loop-mssa(licm,loop-rotate,licm,simple-loop-unswitch<nontrivial>),print<memoryssa>\" -verify-memoryssa < %s 2>&1"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n; Make sure that we update MSSA correctly in this case.\n\n\ndefine void @test(ptr %p, i1 %cond) {\nentry:\n br label %for.header\n\nfor.header:\n br i1 false, label %exit.loopexit1, label %for.header2.preheader\n\nfor.header2.preheader:\n br label %for.body\n\nfor.header2:\n br i1 false, label %for.latch, label %for.body\n\nfor.body:\n store i32 0, ptr %p, align 4\n store i8 0, ptr %p, align 1\n br i1 %cond, label %for.header2, label %exit.loopexit\n\nfor.latch:\n br i1 false, label %for.inc, label %exit.loopexit1\n\nfor.inc:\n br label %for.header\n\nexit.loopexit:\n br label %exit\n\nexit.loopexit1:\n br label %exit\n\nexit:\n ret void\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[MemorySSA][LoopRotate] Assertion `!Paths.empty() && \"Need a path to move\"' failed.",
"body": "This is a recent regression (llvm version 37fecfaa63eef7bd9dff9c16d74e61c99e3ce70a).\nReproducer: https://godbolt.org/z/9MGhvsKPb\n```\n> bin/opt -passes=\"loop-mssa(loop-instsimplify,loop-simplifycfg,licm<no-allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-unswitch<nontrivial;trivial>)\" test.ll -S\nopt: /data/zyw/llvm-project/llvm/lib/Analysis/MemorySSA.cpp:783: {anonymous}::ClobberWalker::tryOptimizePhi(llvm::MemoryPhi*, llvm::MemoryAccess*, const llvm::MemoryLocation&)::<lambda(llvm::SmallVectorImpl<{anonymous}::ClobberWalker::TerminatedPath>&)>: Assertion `!Paths.empty() && \"Need a path to move\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0. Program arguments: ../llvm-build/bin/opt -passes=loop-mssa(loop-instsimplify,loop-simplifycfg,licm<no-allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-unswitch<nontrivial;trivial>) test.ll -S\n1. Running pass \"function(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 module \"test.ll\"\n2. Running 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 \"func_137\"\n #0 0x00007ffff7dfebb2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/zyw/llvm-build/bin/../lib/libLLVMSupport.so.21.0git+0x1febb2)\n #1 0x00007ffff7dfbd1f llvm::sys::RunSignalHandlers() (/data/zyw/llvm-build/bin/../lib/libLLVMSupport.so.21.0git+0x1fbd1f)\n #2 0x00007ffff7dfbe64 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #3 0x00007ffff7842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #4 0x00007ffff78969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #5 0x00007ffff7842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #6 0x00007ffff78287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #7 0x00007ffff782871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #8 0x00007ffff7839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #9 0x00007ffff3f85027 (/data/zyw/llvm-build/bin/../lib/../lib/libLLVMAnalysis.so.21.0git+0x385027)\n#10 0x00007ffff3f88c30 (anonymous namespace)::ClobberWalker::findClobber(llvm::BatchAAResults&, llvm::MemoryAccess*, (anonymous namespace)::UpwardsMemoryQuery&, unsigned int&) MemorySSA.cpp:0:0\n#11 0x00007ffff3f898cc llvm::MemorySSA::ClobberWalkerBase::getClobberingMemoryAccessBase(llvm::MemoryAccess*, llvm::BatchAAResults&, unsigned int&, bool, bool) (/data/zyw/llvm-build/bin/../lib/../lib/libLLVMAnalysis.so.21.0git+0x3898cc)\n#12 0x00007ffff3f8b01a llvm::MemorySSA::SkipSelfWalker::getClobberingMemoryAccess(llvm::MemoryAccess*, llvm::BatchAAResults&) (/data/zyw/llvm-build/bin/../lib/../lib/libLLVMAnalysis.so.21.0git+0x38b01a)\n#13 0x00007ffff4f91e6a getClobberingMemoryAccess(llvm::MemorySSA&, llvm::BatchAAResults&, llvm::SinkAndHoistLICMFlags&, llvm::MemoryUseOrDef*) LICM.cpp:0:0\n#14 0x00007ffff4f99055 llvm::canSinkOrHoistInst(llvm::Instruction&, llvm::AAResults*, llvm::DominatorTree*, llvm::Loop*, llvm::MemorySSAUpdater&, bool, llvm::SinkAndHoistLICMFlags&, llvm::OptimizationRemarkEmitter*) (.part.0) LICM.cpp:0:0\n#15 0x00007ffff4fa223a llvm::hoistRegion(llvm::DomTreeNodeBase<llvm::BasicBlock>*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::TargetLibraryInfo*, llvm::Loop*, llvm::MemorySSAUpdater&, llvm::ScalarEvolution*, llvm::ICFLoopSafetyInfo*, llvm::SinkAndHoistLICMFlags&, llvm::OptimizationRemarkEmitter*, bool, bool) (/data/zyw/llvm-build/bin/../lib/../lib/libLLVMScalarOpts.so.21.0git+0x1a223a)\n#16 0x00007ffff4fa72e0 (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 0x00007ffff4faa26c llvm::LICMPass::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/data/zyw/llvm-build/bin/../lib/../lib/libLLVMScalarOpts.so.21.0git+0x1aa26c)\n#18 0x00007ffff66887f5 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&) (/data/zyw/llvm-build/bin/../lib/../lib/libLLVMPasses.so.21.0git+0x887f5)\n#19 0x00007ffff5018914 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 0x00007ffff5019c80 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&) (/data/zyw/llvm-build/bin/../lib/../lib/libLLVMScalarOpts.so.21.0git+0x219c80)\n#21 0x00007ffff5019e3b 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&) (/data/zyw/llvm-build/bin/../lib/../lib/libLLVMScalarOpts.so.21.0git+0x219e3b)\n#22 0x00007ffff66886d5 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&) (/data/zyw/llvm-build/bin/../lib/../lib/libLLVMPasses.so.21.0git+0x886d5)\n#23 0x00007ffff501b958 llvm::FunctionToLoopPassAdaptor::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/data/zyw/llvm-build/bin/../lib/../lib/libLLVMScalarOpts.so.21.0git+0x21b958)\n#24 0x00007ffff70ad865 llvm::detail::PassModel<llvm::Function, llvm::FunctionToLoopPassAdaptor, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/data/zyw/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.21.0git+0xad865)\n#25 0x00007ffff3909a1d llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/data/zyw/llvm-build/bin/../lib/../lib/libLLVMCore.so.21.0git+0x309a1d)\n#26 0x00007ffff70ad135 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/data/zyw/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.21.0git+0xad135)\n#27 0x00007ffff39078d0 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/data/zyw/llvm-build/bin/../lib/../lib/libLLVMCore.so.21.0git+0x3078d0)\n#28 0x00007ffff70adaf5 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/data/zyw/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.21.0git+0xadaf5)\n#29 0x00007ffff390857d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/data/zyw/llvm-build/bin/../lib/../lib/libLLVMCore.so.21.0git+0x30857d)\n#30 0x00007ffff7f9ba9b 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) (/data/zyw/llvm-build/bin/../lib/libLLVMOptDriver.so.21.0git+0x23a9b)\n#31 0x00007ffff7fa58ed optMain (/data/zyw/llvm-build/bin/../lib/libLLVMOptDriver.so.21.0git+0x2d8ed)\n#32 0x00007ffff7829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#33 0x00007ffff7829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#34 0x0000555555555095 _start (../llvm-build/bin/opt+0x1095)\nAborted (core dumped)\n```",
"author": "dtcxzyw",
"labels": [
"crash-on-valid",
"llvm:analysis",
"generated by fuzzer"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Reduced:\n```\n; bin/opt -passes=\"loop-mssa(licm,loop-rotate,licm,simple-loop-unswitch<nontrivial>)\" -verify-memoryssa 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 @func_137(i1 %0) {\nentry:\n br label %for.cond9\n\nfor.cond9: ; preds = %for.inc519, %entry\n br i1 false, label %for.end521, label %for.cond23\n\nfor.cond23: ; preds = %if.else229, %for.cond9\n %l_1344.1 = phi i32 [ %conv50, %if.else229 ], [ 0, %for.cond9 ]\n br i1 true, label %for.end494, label %for.cond29\n\nfor.cond29: ; preds = %for.cond23\n store i32 0, ptr null, align 4\n %1 = load i32, ptr null, align 4\n %conv50 = xor i32 %1, %l_1344.1\n br i1 %0, label %if.else229, label %if.then204\n\nif.then204: ; preds = %for.cond29\n ret void\n\nif.else229: ; preds = %for.cond29\n br label %for.cond23\n\nfor.end494: ; preds = %for.cond23\n br i1 false, label %for.inc519, label %for.end521\n\nfor.inc519: ; preds = %for.end494\n br label %for.cond9\n\nfor.end521: ; preds = %for.end494, %for.cond9\n ret void\n}\n```\n```\nopt: /home/dtcxzyw/WorkSpace/Projects/compilers/llvm-project/llvm/lib/Analysis/MemorySSA.cpp:2067: void llvm::MemorySSA::verifyOrderingDominationAndDefUses(IterT, VerificationLevel) const [with IterT = llvm::iterator_range<llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::BasicBlock, false, false, void, false, void>, false, false> >]: Assertion `dominates(MD, U) && \"Memory Def does not dominate it's uses\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0. Program arguments: bin/opt -passes=loop-mssa(licm,loop-rotate,licm,simple-loop-unswitch<nontrivial>) -verify-memoryssa test.ll -S\n1. Running pass \"function(loop-mssa(licm<allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-unswitch<nontrivial;trivial>))\" on module \"test.ll\"\n2. Running pass \"loop-mssa(licm<allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-unswitch<nontrivial;trivial>)\" on function \"func_137\"\n #0 0x00007dd7dd025f52 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.21.0git+0x225f52)\n #1 0x00007dd7dd022e2f llvm::sys::RunSignalHandlers() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.21.0git+0x222e2f)\n #2 0x00007dd7dd022f74 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #3 0x00007dd7dca45330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)\n #4 0x00007dd7dca9eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #5 0x00007dd7dca9eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #6 0x00007dd7dca9eb2c pthread_kill ./nptl/pthread_kill.c:89:10\n #7 0x00007dd7dca4527e raise ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x00007dd7dca288ff abort ./stdlib/abort.c:81:7\n #9 0x00007dd7dca2881b _nl_load_domain ./intl/loadmsgcat.c:1177:9\n#10 0x00007dd7dca3b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)\n#11 0x00007dd7d43b84ef void llvm::MemorySSA::verifyOrderingDominationAndDefUses<llvm::iterator_range<llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::BasicBlock, false, false, void, false, void>, false, false>>>(llvm::iterator_range<llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::BasicBlock, false, false, void, false, void>, false, false>>, llvm::MemorySSA::VerificationLevel) const (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMAnalysis.so.21.0git+0x3b84ef)\n#12 0x00007dd7d43b8c11 llvm::MemorySSA::verifyMemorySSA(llvm::MemorySSA::VerificationLevel) const (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMAnalysis.so.21.0git+0x3b8c11)\n#13 0x00007dd7d49c96ce (anonymous namespace)::LoopRotate::rotateLoop(llvm::Loop*, bool) LoopRotationUtils.cpp:0:0\n#14 0x00007dd7d49c9fbf llvm::LoopRotation(llvm::Loop*, llvm::LoopInfo*, llvm::TargetTransformInfo const*, llvm::AssumptionCache*, llvm::DominatorTree*, llvm::ScalarEvolution*, llvm::MemorySSAUpdater*, llvm::SimplifyQuery const&, bool, unsigned int, bool, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMTransformUtils.so.21.0git+0x1c9fbf)\n#15 0x00007dd7d583ff34 llvm::LoopRotatePass::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMScalarOpts.so.21.0git+0x23ff34)\n#16 0x00007dd7d73ac765 llvm::detail::PassModel<llvm::Loop, llvm::LoopRotatePass, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libPolly.so.21.0git+0x1ac765)\n#17 0x00007dd7d5834aed 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&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMScalarOpts.so.21.0git+0x234aed)\n#18 0x00007dd7d583459c 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&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMScalarOpts.so.21.0git+0x23459c)\n#19 0x00007dd7d73ac815 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&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libPolly.so.21.0git+0x1ac815)\n#20 0x00007dd7d5836395 llvm::FunctionToLoopPassAdaptor::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMScalarOpts.so.21.0git+0x236395)\n#21 0x00007dd7dbcdaa45 llvm::detail::PassModel<llvm::Function, llvm::FunctionToLoopPassAdaptor, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.21.0git+0xdaa45)\n#22 0x00007dd7d3d2a494 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.21.0git+0x32a494)\n#23 0x00007dd7dbcda315 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.21.0git+0xda315)\n#24 0x00007dd7d3d28d70 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.21.0git+0x328d70)\n#25 0x00007dd7dbcdacd5 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.21.0git+0xdacd5)\n#26 0x00007dd7d3d29365 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.21.0git+0x329365)\n#27 0x00007dd7dd2712e9 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.21.0git+0x2c2e9)\n#28 0x00007dd7dd27c306 optMain (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.21.0git+0x37306)\n#29 0x00007dd7dca2a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3\n#30 0x00007dd7dca2a28b call_init ./csu/../csu/libc-start.c:128:20\n#31 0x00007dd7dca2a28b __libc_start_main ./csu/../csu/libc-start.c:347:5\n#32 0x000063062f7cd095 _start (bin/opt+0x1095)\n\nAborted (core dumped)\n```"
},
{
"author": "dtcxzyw",
"body": "Bisected to 4d60c6d9b2c863d773aac9b59af8780e5ba23fcd\ncc @arsenm @nikic "
},
{
"author": "dtcxzyw",
"body": "Another reproducer:\n```\n; bin/opt -passes=\"loop-mssa(licm,loop-rotate,licm,simple-loop-unswitch<nontrivial>)\" -verify-memoryssa 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 @test(ptr %p, i1 %cond) {\nentry:\n br label %for.header\n\nfor.header:\n br i1 false, label %exit.loopexit1, label %for.header2.preheader\n\nfor.header2.preheader:\n br label %for.body\n\nfor.header2:\n br i1 false, label %for.latch, label %for.body\n\nfor.body:\n store i32 0, ptr %p, align 4\n store i8 0, ptr %p, align 1\n br i1 %cond, label %for.header2, label %exit.loopexit\n\nfor.latch:\n br i1 false, label %for.inc, label %exit.loopexit1\n\nfor.inc:\n br label %for.header\n\nexit.loopexit:\n br label %exit\n\nexit.loopexit1:\n br label %exit\n\nexit:\n ret void\n}\n```"
},
{
"author": "dtcxzyw",
"body": "I will post a patch later.\n"
},
{
"author": "dtcxzyw",
"body": "https://github.com/llvm/llvm-project/commit/4d60c6d9b2c863d773aac9b59af8780e5ba23fcd is correct. This is an iterator-invalidation bug in MemorySSA.\n"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
102351
|
https://github.com/llvm/llvm-project/issues/102351
|
miscompilation
|
203a2ca8cd6af505e11a38aebceeaf864271042c
| 2024-08-07T18:49:59 |
[
"llvm/test/Transforms/SimplifyCFG"
] |
{
"fix_commit": "3c9022c965b85951f30af140da591f819acef8a0",
"components": [
"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": [
[
1028,
1034
],
[
1133,
1139
]
],
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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": null,
"llvm/lib/Transforms/Utils/Local.cpp": [
"CanRedirectPredsOfEmptyBBToSucc",
"llvm::TryToSimplifyUncondBranchFromEmptyBlock"
],
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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 3c9022c965b85951f30af140da591f819acef8a0
Author: AdityaK <hiraditya@msn.com>
Date: Tue Sep 10 22:39:02 2024 -0700
Bail out jump threading on indirect branches (#103688)
The bug was introduced by
https://github.com/llvm/llvm-project/pull/68473
Fixes: #102351
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index d0669e44f821..c85c819263e2 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -1028,7 +1028,14 @@ CanRedirectPredsOfEmptyBBToSucc(BasicBlock *BB, BasicBlock *Succ,
if (!BB->hasNPredecessorsOrMore(2))
return false;
- // Get single common predecessors of both BB and Succ
+ if (any_of(BBPreds, [](const BasicBlock *Pred) {
+ return isa<PHINode>(Pred->begin()) &&
+ isa<IndirectBrInst>(Pred->getTerminator());
+ }))
+ return false;
+
+ // Get the single common predecessor of both BB and Succ. Return false
+ // when there are more than one common predecessors.
for (BasicBlock *SuccPred : SuccPreds) {
if (BBPreds.count(SuccPred)) {
if (CommonPred)
@@ -1133,7 +1140,7 @@ bool llvm::TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB,
bool BBKillable = CanPropagatePredecessorsForPHIs(BB, Succ, BBPreds);
- // Even if we can not fold bB into Succ, we may be able to redirect the
+ // Even if we can not fold BB into Succ, we may be able to redirect the
// predecessors of BB to Succ.
bool BBPhisMergeable =
BBKillable ||
|
[
{
"file": "llvm/test/Transforms/SimplifyCFG/switch-branch-fold-indirectbr-102351.ll",
"commands": [
"opt < %s -passes=simplifycfg -S"
],
"tests": [
{
"test_name": "main",
"test_body": "@.str = private unnamed_addr constant [23 x i8] c\"OP_1:(instruction=%d)\\0A\\00\", align 1\n@.str.1 = private unnamed_addr constant [28 x i8] c\"TERMINATE:(instruction=%d)\\0A\\00\", align 1\n\n; Function Attrs: mustprogress norecurse uwtable\ndefine dso_local noundef i32 @main() #0 {\nentry:\n %bytecode = alloca [2 x ptr], align 16\n store ptr blockaddress(@main, %VM__OP_1), ptr %bytecode, align 16, !tbaa !5\n %arrayidx1 = getelementptr inbounds [2 x ptr], ptr %bytecode, i64 0, i64 1\n store ptr blockaddress(@main, %VM__TERMINATE), ptr %arrayidx1, align 8, !tbaa !5\n br label %while.body\n\nwhile.body: ; preds = %entry, %sw.epilog\n %state.0 = phi i32 [ 0, %entry ], [ %state.1, %sw.epilog ]\n %index.0 = phi i32 [ 0, %entry ], [ %index.2, %sw.epilog ]\n switch i32 %state.0, label %sw.epilog [\n i32 0, label %sw.bb\n i32 1, label %VM__OP_1\n i32 2, label %sw.bb4\n ]\n\nsw.bb: ; preds = %while.body\n br label %indirectgoto\n\nVM__OP_1: ; preds = %while.body, %indirectgoto\n %index.1 = phi i32 [ %index.3, %indirectgoto ], [ %index.0, %while.body ]\n br label %sw.epilog\n\nsw.bb4: ; preds = %while.body\n %call = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %index.0)\n %inc = add nsw i32 %index.0, 1\n br label %indirectgoto\n\nsw.epilog: ; preds = %while.body, %VM__OP_1\n %state.1 = phi i32 [ %state.0, %while.body ], [ 2, %VM__OP_1 ]\n %index.2 = phi i32 [ %index.0, %while.body ], [ %index.1, %VM__OP_1 ]\n br label %while.body, !llvm.loop !9\n\nVM__TERMINATE: ; preds = %indirectgoto\n %call7 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %index.3)\n ret i32 0\n\nindirectgoto: ; preds = %sw.bb4, %sw.bb\n %index.3 = phi i32 [ %inc, %sw.bb4 ], [ %index.0, %sw.bb ]\n %idxprom.pn = sext i32 %index.3 to i64\n %indirect.goto.dest.in = getelementptr inbounds [2 x ptr], ptr %bytecode, i64 0, i64 %idxprom.pn\n %indirect.goto.dest = load ptr, ptr %indirect.goto.dest.in, align 8, !tbaa !5\n indirectbr ptr %indirect.goto.dest, [label %VM__OP_1, label %VM__TERMINATE]\n}\ndeclare i32 @printf(ptr noundef, ...) #1\n\nattributes #0 = { mustprogress norecurse 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 = { \"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 18.0.0git (https://github.com/llvm/llvm-project.git 67782d2de5ea9c8653b8f0110237a3c355291c0e)\"}\n!5 = !{!6, !6, i64 0}\n!6 = !{!\"any pointer\", !7, i64 0}\n!7 = !{!\"omnipotent char\", !8, i64 0}\n!8 = !{!\"Simple C++ TBAA\"}\n!9 = !{!10, !10, i64 0}\n!10 = !{!\"int\", !7, i64 0}\n!11 = distinct !{!11, !12, !13}\n!12 = !{!\"llvm.loop.mustprogress\"}\n!13 = !{!\"llvm.loop.unroll.disable\"}",
"lli_expected_out": "OP_1:(instruction=0)\nTERMINATE:(instruction=1)\n",
"additional_args": null
}
]
}
] |
{
"title": "Miscompile in code with indirect gotos",
"body": "The simplifycfg pass (incorrectly?) optimizes one of the case statements.\r\n\r\n```llvm\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\n@.str = private unnamed_addr constant [23 x i8] c\"OP_1:(instruction=%d)\\0A\\00\", align 1\r\n@.str.1 = private unnamed_addr constant [28 x i8] c\"TERMINATE:(instruction=%d)\\0A\\00\", align 1\r\n\r\n; Function Attrs: mustprogress norecurse uwtable\r\ndefine dso_local noundef i32 @main() #0 {\r\nentry:\r\n %bytecode = alloca [2 x ptr], align 16\r\n store ptr blockaddress(@main, %VM__OP_1), ptr %bytecode, align 16, !tbaa !5\r\n %arrayidx1 = getelementptr inbounds [2 x ptr], ptr %bytecode, i64 0, i64 1\r\n store ptr blockaddress(@main, %VM__TERMINATE), ptr %arrayidx1, align 8, !tbaa !5\r\n br label %while.body\r\n\r\nwhile.body: ; preds = %entry, %sw.epilog\r\n %state.0 = phi i32 [ 0, %entry ], [ %state.1, %sw.epilog ]\r\n %index.0 = phi i32 [ 0, %entry ], [ %index.2, %sw.epilog ]\r\n switch i32 %state.0, label %sw.epilog [\r\n i32 0, label %sw.bb\r\n i32 1, label %VM__OP_1\r\n i32 2, label %sw.bb4\r\n ]\r\n\r\nsw.bb: ; preds = %while.body\r\n br label %indirectgoto\r\n\r\nVM__OP_1: ; preds = %while.body, %indirectgoto\r\n %index.1 = phi i32 [ %index.3, %indirectgoto ], [ %index.0, %while.body ]\r\n br label %sw.epilog\r\n\r\nsw.bb4: ; preds = %while.body\r\n %call = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %index.0)\r\n %inc = add nsw i32 %index.0, 1\r\n br label %indirectgoto\r\n\r\nsw.epilog: ; preds = %while.body, %VM__OP_1\r\n %state.1 = phi i32 [ %state.0, %while.body ], [ 2, %VM__OP_1 ]\r\n %index.2 = phi i32 [ %index.0, %while.body ], [ %index.1, %VM__OP_1 ]\r\n br label %while.body, !llvm.loop !9\r\n\r\nVM__TERMINATE: ; preds = %indirectgoto\r\n %call7 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %index.3)\r\n ret i32 0\r\n\r\nindirectgoto: ; preds = %sw.bb4, %sw.bb\r\n %index.3 = phi i32 [ %inc, %sw.bb4 ], [ %index.0, %sw.bb ]\r\n %idxprom.pn = sext i32 %index.3 to i64\r\n %indirect.goto.dest.in = getelementptr inbounds [2 x ptr], ptr %bytecode, i64 0, i64 %idxprom.pn\r\n %indirect.goto.dest = load ptr, ptr %indirect.goto.dest.in, align 8, !tbaa !5\r\n indirectbr ptr %indirect.goto.dest, [label %VM__OP_1, label %VM__TERMINATE]\r\n}\r\ndeclare i32 @printf(ptr noundef, ...) #1\r\n\r\nattributes #0 = { mustprogress norecurse uwtable \"min-legal-vector-width\"=\"0\" \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"x86-64\" \"target-features\"=\"+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87\" \"tune-cpu\"=\"generic\" }\r\nattributes #1 = { \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"x86-64\" \"target-features\"=\"+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87\" \"tune-cpu\"=\"generic\" }\r\n\r\n!llvm.module.flags = !{!0, !1, !2, !3}\r\n!llvm.ident = !{!4}\r\n\r\n!0 = !{i32 1, !\"wchar_size\", i32 4}\r\n!1 = !{i32 8, !\"PIC Level\", i32 2}\r\n!2 = !{i32 7, !\"PIE Level\", i32 2}\r\n!3 = !{i32 7, !\"uwtable\", i32 2}\r\n!4 = !{!\"clang version 18.0.0git (https://github.com/llvm/llvm-project.git 67782d2de5ea9c8653b8f0110237a3c355291c0e)\"}\r\n!5 = !{!6, !6, i64 0}\r\n!6 = !{!\"any pointer\", !7, i64 0}\r\n!7 = !{!\"omnipotent char\", !8, i64 0}\r\n!8 = !{!\"Simple C++ TBAA\"}\r\n!9 = !{!10, !10, i64 0}\r\n!10 = !{!\"int\", !7, i64 0}\r\n!11 = distinct !{!11, !12, !13}\r\n!12 = !{!\"llvm.loop.mustprogress\"}\r\n!13 = !{!\"llvm.loop.unroll.disable\"}\r\n```\r\n\r\n$ opt -passes=simplifycfg orig.ll -S -o out.ll\r\n```llvm\r\n; ModuleID = 'orig.ll'\r\nsource_filename = \"orig.ll\"\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\n@.str = private unnamed_addr constant [23 x i8] c\"OP_1:(instruction=%d)\\0A\\00\", align 1\r\n@.str.1 = private unnamed_addr constant [28 x i8] c\"TERMINATE:(instruction=%d)\\0A\\00\", align 1\r\n\r\n; Function Attrs: mustprogress norecurse uwtable\r\ndefine dso_local noundef i32 @main() #0 {\r\nentry:\r\n %bytecode = alloca [2 x ptr], align 16\r\n store ptr blockaddress(@main, %VM__OP_1), ptr %bytecode, align 16, !tbaa !5\r\n %arrayidx1 = getelementptr inbounds [2 x ptr], ptr %bytecode, i64 0, i64 1\r\n store ptr blockaddress(@main, %VM__TERMINATE), ptr %arrayidx1, align 8, !tbaa !5\r\n br label %while.body\r\n\r\nwhile.body: ; preds = %sw.epilog, %entry\r\n %state.0 = phi i32 [ 0, %entry ], [ %state.1, %sw.epilog ]\r\n %index.0 = phi i32 [ 0, %entry ], [ %index.0, %sw.epilog ]\r\n switch i32 %state.0, label %sw.epilog [\r\n i32 0, label %VM__TERMINATE\r\n i32 1, label %VM__OP_1\r\n i32 2, label %sw.bb4\r\n ]\r\n\r\nVM__OP_1: ; preds = %while.body\r\n br label %sw.epilog\r\n\r\nsw.bb4: ; preds = %while.body\r\n %call = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %index.0)\r\n %inc = add nsw i32 %index.0, 1\r\n br label %VM__TERMINATE\r\n\r\nsw.epilog: ; preds = %VM__OP_1, %while.body\r\n %state.1 = phi i32 [ %state.0, %while.body ], [ 2, %VM__OP_1 ]\r\n br label %while.body, !llvm.loop !9\r\n\r\nVM__TERMINATE: ; preds = %sw.bb4, %while.body\r\n %index.3 = phi i32 [ %inc, %sw.bb4 ], [ %index.0, %while.body ]\r\n %call7 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %index.3)\r\n ret i32 0\r\n}\r\n\r\ndeclare i32 @printf(ptr noundef, ...) #1\r\n\r\nattributes #0 = { mustprogress norecurse uwtable \"min-legal-vector-width\"=\"0\" \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"x86-64\" \"target-features\"=\"+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87\" \"tune-cpu\"=\"generic\" }\r\nattributes #1 = { \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"x86-64\" \"target-features\"=\"+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87\" \"tune-cpu\"=\"generic\" }\r\n\r\n!llvm.module.flags = !{!0, !1, !2, !3}\r\n!llvm.ident = !{!4}\r\n\r\n!0 = !{i32 1, !\"wchar_size\", i32 4}\r\n!1 = !{i32 8, !\"PIC Level\", i32 2}\r\n!2 = !{i32 7, !\"PIE Level\", i32 2}\r\n!3 = !{i32 7, !\"uwtable\", i32 2}\r\n!4 = !{!\"clang version 18.0.0git (https://github.com/llvm/llvm-project.git 67782d2de5ea9c8653b8f0110237a3c355291c0e)\"}\r\n!5 = !{!6, !6, i64 0}\r\n!6 = !{!\"any pointer\", !7, i64 0}\r\n!7 = !{!\"omnipotent char\", !8, i64 0}\r\n!8 = !{!\"Simple C++ TBAA\"}\r\n!9 = !{!10, !10, i64 0}\r\n!10 = !{!\"int\", !7, i64 0}\r\n```",
"author": "hiraditya",
"labels": [
"miscompilation",
"llvm:transforms"
],
"comments": [
{
"author": "hiraditya",
"body": "Original C code\r\n\r\n```c\r\nextern int printf(const char *fmt, ...);\r\n\r\nint main() {\r\n void* bytecode[2];\r\n bytecode[0] = &&VM__OP_1;\r\n bytecode[1] = &&VM__TERMINATE;\r\n\r\n int state = 0;\r\n int index = 0;\r\n\r\n while (1) {\r\n switch (state) {\r\n case 0:\r\n goto *bytecode[index];\r\n case 1:\r\n // NOTE: THIS IS ONLY REACHABLE VIA INDIRECT GOTOS\r\n VM__OP_1:\r\n state = 2;\r\n break;\r\n case 2:\r\n printf(\"OP_1:(instruction=%d)\\n\", index);\r\n index++;\r\n goto *bytecode[index];\r\n }\r\n }\r\n\r\nVM__TERMINATE:\r\n printf(\"TERMINATE:(instruction=%d)\\n\", index);\r\n return 0;\r\n}\r\n```\r\n\r\nhttps://github.com/llvm/llvm-project/pull/76295 makes the miscompile go away(https://godbolt.org/z/d9bGnhhv6) but I think simplifycfg still has the bug.\r\n"
},
{
"author": "efriedma-quic",
"body": "Looks like TryToSimplifyUncondBranchFromEmptyBlock is not handling indirectbr predecessors correctly: the indirectbr's successor list is rewritten so it has a successor that isn't address-taken. That edge is then proven impossible, so the indirectbr is completely eliminated."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
76852
|
https://github.com/llvm/llvm-project/issues/76852
|
crash
|
4d11f04b20f0bd7488e19e8f178ba028412fa519
| 2024-01-03T19:32:37 |
[
"llvm/test/Transforms/LoopDeletion"
] |
{
"fix_commit": "a0b911745494e3c2f53a27f23c536314818ce0b1",
"components": [
"LoopDeletion"
],
"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": [
[
452,
457
],
[
487,
499
]
],
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": [
"deleteLoopIfDead"
],
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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 a0b911745494e3c2f53a27f23c536314818ce0b1
Author: Manish Kausik H <46352931+Nirhar@users.noreply.github.com>
Date: Fri Jan 19 20:00:20 2024 +0530
LoopDeletion: Move EH pad check before the isLoopNeverExecuted Check (#78189)
This commit modifies `LoopDeletion::deleteLoopIfDead` to check if the
exit block of a loop is an EH pad before checking if the loop gets
executed. This handles the case where an unreachable loop has a
landingpad as an Exit block, and the loop gets deleted, leaving leaving
the landingpad without an edge from an unwind clause.
Fixes #76852.
diff --git a/llvm/lib/Transforms/Scalar/LoopDeletion.cpp b/llvm/lib/Transforms/Scalar/LoopDeletion.cpp
index c041e3621a16..bfe9374cf2f8 100644
--- a/llvm/lib/Transforms/Scalar/LoopDeletion.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopDeletion.cpp
@@ -452,6 +452,13 @@ static LoopDeletionResult deleteLoopIfDead(Loop *L, DominatorTree &DT,
BasicBlock *ExitBlock = L->getUniqueExitBlock();
+ // We can't directly branch to an EH pad. Don't bother handling this edge
+ // case.
+ if (ExitBlock && ExitBlock->isEHPad()) {
+ LLVM_DEBUG(dbgs() << "Cannot delete loop exiting to EH pad.\n");
+ return LoopDeletionResult::Unmodified;
+ }
+
if (ExitBlock && isLoopNeverExecuted(L)) {
LLVM_DEBUG(dbgs() << "Loop is proven to never execute, delete it!\n");
// We need to forget the loop before setting the incoming values of the exit
@@ -487,13 +494,6 @@ static LoopDeletionResult deleteLoopIfDead(Loop *L, DominatorTree &DT,
return LoopDeletionResult::Unmodified;
}
- // We can't directly branch to an EH pad. Don't bother handling this edge
- // case.
- if (ExitBlock && ExitBlock->isEHPad()) {
- LLVM_DEBUG(dbgs() << "Cannot delete loop exiting to EH pad.\n");
- return LoopDeletionResult::Unmodified;
- }
-
// Finally, we have to check that the loop really is dead.
bool Changed = false;
if (!isLoopDead(L, SE, ExitingBlocks, ExitBlock, Changed, Preheader, LI)) {
|
[
{
"file": "llvm/test/Transforms/LoopDeletion/loop-with-ehpad-not-executed.ll",
"commands": [
"opt %s -passes=loop-deletion -S"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @wombat() personality ptr null {\n;\nbb:\n br i1 false, label %bb1, label %bb4\n\nbb1: ; preds = %bb\n br label %bb2\n\nbb2: ; preds = %bb1, %bb2\n %invoke = invoke double null()\n to label %bb2 unwind label %bb3\n\nbb3: ; preds = %bb2\n %landingpad = landingpad { ptr, i32 }\n cleanup\n ret void\n\nbb4: ; preds = %bb\n ret void\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": " LLVM ERROR: Broken module found, compilation aborted!",
"body": "The bug was found by FuzzGen IR test generator\r\n\r\nRun opt with -passes=loop-deletion \r\nhttps://godbolt.org/z/16zoTYEqx\r\n\r\nTest.ll\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\" personality ptr null {\r\nbb:\r\n br i1 false, label %bb1, label %bb4\r\n\r\nbb1: ; preds = %bb\r\n br label %bb2\r\n\r\nbb2: ; preds = %bb1, %bb2\r\n %invoke = invoke double null(i64 0)\r\n to label %bb2 unwind label %bb3\r\n\r\nbb3: ; preds = %bb2\r\n %landingpad = landingpad { ptr, i32 }\r\n cleanup\r\n ret void\r\n\r\nbb4: ; preds = %bb\r\n ret void\r\n}\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-deletion <source>\r\n #0 0x0000000003597b18 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3597b18)\r\n #1 0x000000000359526c SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007fee38042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x00007fee380969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x00007fee38042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x00007fee380287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00000000007905f3 llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0\r\n #7 0x00000000034dea68 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x34dea68)\r\n #8 0x0000000002f6f993 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2f6f993)\r\n #9 0x000000000088bbae llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x88bbae)\r\n#10 0x0000000002f34d6c llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2f34d6c)\r\n#11 0x0000000000895cca 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) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x895cca)\r\n#12 0x000000000079c483 main (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x79c483)\r\n#13 0x00007fee38029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#14 0x00007fee38029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#15 0x000000000088af1e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x88af1e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```",
"author": "TatyanaDoubts",
"labels": [
"loopoptim",
"crash"
],
"comments": [
{
"author": "Nirhar",
"body": "Just looked at the IR after loop deletion and before the verify pass, and looks like loop-deletion incorrectly considered the block with the landingpad as the exit block of the loop:\r\n```\r\ndefine void @wombat() gc \"statepoint-example\" personality ptr null {\r\nbb:\r\n br i1 false, label %bb1, label %bb4\r\n\r\nbb1: ; preds = %bb\r\n br label %bb3\r\n\r\nbb3: ; preds = %bb1\r\n %landingpad = landingpad { ptr, i32 }\r\n cleanup\r\n ret void\r\n\r\nbb4: ; preds = %bb\r\n ret void\r\n}\r\n\r\n$28 = void\r\n```\r\nThe problem seems to be with `Loop::getUniqueExitBlock` from https://github.com/llvm/llvm-project/blob/b6fc463d4c0b00e0741776f9d41b47f532a80b9e/llvm/lib/Transforms/Scalar/LoopDeletion.cpp#L453\r\n\r\nwhich returns the landingpad as the exit block of the loop. Perhaps this must be altered to consider that unwind edges are not real edges in the DAG. \r\n\r\n\r\n"
},
{
"author": "Nirhar",
"body": "I'm not sure who are the right persons to consult on this. @EugeneZelenko I leave it to you for you to add them."
},
{
"author": "nikic",
"body": "@Nirhar Isn't this already guarded by https://github.com/llvm/llvm-project/blob/b6fc463d4c0b00e0741776f9d41b47f532a80b9e/llvm/lib/Transforms/Scalar/LoopDeletion.cpp#L492?"
},
{
"author": "nikic",
"body": "Ah, this case hits the isLoopNeverExecuted() branch. So that check should just get moved higher, so it covers that case as well."
},
{
"author": "Nirhar",
"body": "@nikic Ah yes that makes sense. I'll land a patch for this soon!\r\n"
},
{
"author": "Nirhar",
"body": "@nikic On second thought, moving the landing pad check higher will not delete the loop, given that this loop never gets executed as well. Isn't it a better solution to delete the loop as well as delete the landing pad instruction?\r\n\r\nEssentially I propose to first check if the loop never gets executed. If yes, delete the loop. Next check if the exit block is a landing pad used exclusively by the loop. If yes, delete the landing pad as well. Is this solution acceptable to you?\r\n\r\nAlso is it correct to call the landing pad as an `ExitBlock`? In my opinion, semantically the landingpad should not be the block that `L->getUniqueExitBlock` returns given that the landingpad is not a part of the loop's logic. Thus in this case according to me `L->getUniqueExitBlock` should have returned a nullptr, and we should have hit the branch https://github.com/llvm/llvm-project/blob/b6fc463d4c0b00e0741776f9d41b47f532a80b9e/llvm/lib/Transforms/Scalar/LoopDeletion.cpp#L485 "
},
{
"author": "nikic",
"body": "> On second thought, moving the landing pad check higher will not delete the loop, given that this loop never gets executed as well. Isn't it a better solution to delete the loop as well as delete the landing pad instruction?\r\n\r\nThis is a degenerate case, it is not worthwhile to try and optimize it. It's possible to handle this case, but it's much harder than you think. The current code will always replace a loop with a branch to the exit, even if the loop is known to never execute, because this preserves the outer loop structure. If we replaced the entire loop with unreachable (which is what would really be necessary to handle the landingpad case) we may also break an outer loop and would have to perform corresponding loop info updates.\r\n\r\n> Also is it correct to call the landing pad as an ExitBlock? \r\n\r\nNote that ExitBlock and ExitingBlock are different things. And ExitingBlock is part of the loop and branches to an ExitBlock not part of the loop. So yes, landingpad is a valid ExitBlock here."
},
{
"author": "Nirhar",
"body": "Understood, thanks for the clarification @nikic !"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
118467
|
https://github.com/llvm/llvm-project/issues/118467
|
miscompilation
|
73731d6873b6fb0757c3065aaf2452eaccd0eebc
| 2024-12-03T10:44:21 |
[
"llvm/test/Transforms/AggressiveInstCombine"
] |
{
"fix_commit": "f68b0e36997322eeda8fd199ea80deb1b49c5410",
"components": [
"AggressiveInstCombine"
],
"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": [
[
803,
810
]
],
"llvm/lib/Transforms/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": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": [
"foldConsecutiveLoads"
],
"llvm/lib/Transforms/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 f68b0e36997322eeda8fd199ea80deb1b49c5410
Author: Antonio Frighetto <me@antoniofrighetto.com>
Date: Wed Dec 4 10:15:11 2024 +0100
[AggressiveInstCombine] Use APInt and avoid truncation when folding loads
A miscompilation issue has been addressed with improved handling.
Fixes: https://github.com/llvm/llvm-project/issues/118467.
diff --git a/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp b/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
index b5b561797f75..45ee2d472a11 100644
--- a/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
+++ b/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
@@ -803,8 +803,7 @@ static bool foldConsecutiveLoads(Instruction &I, const DataLayout &DL,
APInt Offset1(DL.getIndexTypeSizeInBits(Load1Ptr->getType()), 0);
Load1Ptr = Load1Ptr->stripAndAccumulateConstantOffsets(
DL, Offset1, /* AllowNonInbounds */ true);
- Load1Ptr = Builder.CreatePtrAdd(Load1Ptr,
- Builder.getInt32(Offset1.getZExtValue()));
+ Load1Ptr = Builder.CreatePtrAdd(Load1Ptr, Builder.getInt(Offset1));
}
// Generate wider load.
NewLoad = Builder.CreateAlignedLoad(WiderType, Load1Ptr, LI1->getAlign(),
|
[
{
"file": "llvm/test/Transforms/AggressiveInstCombine/X86/or-load.ll",
"commands": [
"opt < %s -passes=aggressive-instcombine -mtriple x86_64-none-eabi -mattr=avx2 -data-layout=\"e-n64\" -S",
"opt < %s -passes=aggressive-instcombine -mtriple x86_64-none-eabi -mattr=avx2 -data-layout=\"E-n64\" -S"
],
"tests": [
{
"test_name": "loadcombine_consecutive_idx_64",
"test_body": "define i32 @loadcombine_consecutive_idx_64(ptr %data) {\nentry:\n %arrayidx = getelementptr inbounds nuw i8, ptr %data, i64 2149675577\n %val = load i8, ptr %arrayidx, align 1\n %conv = zext i8 %val to i32\n %arrayidx.2 = getelementptr inbounds nuw i8, ptr %data, i64 2149675576\n %val.2 = load i8, ptr %arrayidx.2, align 1\n %conv.2 = zext i8 %val.2 to i32\n %shl = shl nuw nsw i32 %conv, 8\n %or = or disjoint i32 %shl, %conv.2\n ret i32 %or\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Invalid LLVM IR code generated on x86-64 with a very simple sample (crash the generated executable code)",
"body": "Below is a very simple program that's loading 16 bits table value into a 32 bits variable from a 8 bits table.\nOn **x86-64** with **-O2** or **-O3** flags, this program works fine with LLVM 16.0.0 and below, but since LLVM 17.0.0, the LLVM IR and the generated assembly code are using a wrong calculated offset on the table (doesn't occurs on LLVM armv8 whatever the version).\nAs you can see below, the offset in the table which is supposed to be **2149675576** (**0x80217238**) has its 32 upper bits inverted for **-2145291720** (**0xFFFFFFFF80217238**).\n\n```c\n\n#include <stdint.h>\n\n// Load 16 bits into 32 bits value from data offset 0x80217238\n\nuint32_t Test(const uint8_t* data)\n{ \n uint32_t a, b, c; \n\tb = 0xFFFF8022 << 16;\n b += 0xFFFFE808; \n a = data[b + 0xFFFF8A31];\n c = data[b + 0xFFFF8A30];\n c &= ~0x0000FF00;\n c |= ((a << 8) | (a >> 24)) & 0x0000FF00;\n\treturn c;\n}\n\n```\n\nLLVM IR with LLVM 16.0.0 (from Compiler Explorer)\n```ll\ndefine dso_local noundef i32 @Test(unsigned char const*)(ptr nocapture noundef readonly %data) local_unnamed_addr {\nentry:\n %arrayidx4 = getelementptr inbounds i8, ptr %data, i64 2149675576\n %0 = load i16, ptr %arrayidx4, align 1\n %1 = zext i16 %0 to i32\n ret i32 %1\n}\n\ndeclare void @llvm.dbg.value(metadata, metadata, metadata) #1\n```\nLLVM IR with LLVM 19.1.0 and trunk (from Compiler Explorer)\n```ll\ndefine dso_local noundef range(i32 0, 65536) i32 @Test(unsigned char const*)(ptr nocapture noundef readonly %data) local_unnamed_addr {\nentry:\n %0 = getelementptr i8, ptr %data, i64 -2145291720\n %1 = load i16, ptr %0, align 1\n %2 = zext i16 %1 to i32\n ret i32 %2\n}\n```\n\n\n\n\n\n",
"author": "dje64240",
"labels": [
"miscompilation",
"llvm:transforms"
],
"comments": [
{
"author": "topperc",
"body": "opt-bisect suggests AggressiveInstCominer. There were two separate loads that got merged. The resulting GEP had an index of `i32 -2145291720` with trunk and `i64 2149675576` with clang 16. Those would be the same number if GEP zero extended indices instead of sign extending."
},
{
"author": "antoniofrighetto",
"body": "Alive2: https://alive2.llvm.org/ce/z/G5CgkD."
},
{
"author": "AZero13",
"body": "> opt-bisect suggests AggressiveInstCominer. There were two separate loads that got merged. The resulting GEP had an index of `i32 -2145291720` with trunk and `i64 2149675576` with clang 16. Those would be the same number if GEP zero extended indices instead of sign extending.\n\nSee my PR for 19.x "
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
112467
|
https://github.com/llvm/llvm-project/issues/112467
|
miscompilation
|
9df8d8d05c2650b51bd4233e1759206d163f3133
| 2024-10-16T03:31:20 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "3bf2295ee0ebd1eafe66ca15dff44bdb31e6198a",
"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": [
[
3369,
3376
]
],
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": [
"InstCombinerImpl::foldAndOrOfICmps"
],
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 3bf2295ee0ebd1eafe66ca15dff44bdb31e6198a
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Wed Oct 16 16:24:44 2024 +0800
[InstCombine] Drop `samesign` flag in `foldAndOrOfICmpsWithConstEq` (#112489)
In
https://github.com/llvm/llvm-project/commit/5dbfca30c1a672cd0c5089df2b4fdd171436643a
we assume that RHS is poison implies LHS is also poison. It doesn't hold
after introducing samesign flag.
This patch drops the `samesign` flag on RHS if the original expression
is a logical and/or.
Closes #112467.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index 64bee4ab974e..c8407e8ba5ab 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -3369,8 +3369,14 @@ Value *InstCombinerImpl::foldAndOrOfICmps(ICmpInst *LHS, ICmpInst *RHS,
// We can convert this case to bitwise and, because both operands are used
// on the LHS, and as such poison from both will propagate.
if (Value *V = foldAndOrOfICmpsWithConstEq(RHS, LHS, IsAnd,
- /*IsLogical*/ false, Builder, Q))
+ /*IsLogical=*/false, Builder, Q)) {
+ // If RHS is still used, we should drop samesign flag.
+ if (IsLogical && RHS->hasSameSign() && !RHS->use_empty()) {
+ RHS->setSameSign(false);
+ addToWorklist(RHS);
+ }
return V;
+ }
if (Value *V = foldIsPowerOf2OrZero(LHS, RHS, IsAnd, Builder, *this))
return V;
|
[
{
"file": "llvm/test/Transforms/InstCombine/and-or-icmp-min-max.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "sge_and_max_commute",
"test_body": "define i1 @sge_and_max_commute(i8 %x, i8 %y) {\n %cmp = icmp sge i8 %x, %y\n %cmpeq = icmp eq i8 %x, 127\n %r = and i1 %cmpeq, %cmp\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "sge_and_max_logical",
"test_body": "define i1 @sge_and_max_logical(i8 %x, i8 %y) {\n %cmp = icmp sge i8 %x, %y\n %cmpeq = icmp eq i8 %x, 127\n %r = select i1 %cmp, i1 %cmpeq, i1 false\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "sge_and_max_logical_samesign",
"test_body": "define i1 @sge_and_max_logical_samesign(i8 %x, i8 %y) {\n %cmp = icmp sge i8 %x, %y\n %cmpeq = icmp samesign eq i8 %x, 127\n %r = select i1 %cmp, i1 %cmpeq, i1 false\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/InstCombine/and-or-icmp-nullptr.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "sgt_and_min_logical_samesign",
"test_body": "define i1 @sgt_and_min_logical_samesign(ptr %x, ptr %y) {\n %cmp = icmp sgt ptr %x, %y\n %cmpeq = icmp samesign eq ptr %x, null\n %r = select i1 %cmp, i1 %cmpeq, i1 false\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "sgt_and_min_logical",
"test_body": "define i1 @sgt_and_min_logical(ptr %x, ptr %y) {\n %cmp = icmp sgt ptr %x, %y\n %cmpeq = icmp eq ptr %x, null\n %r = select i1 %cmp, i1 %cmpeq, i1 false\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "sle_or_not_min",
"test_body": "define i1 @sle_or_not_min(ptr %x, ptr %y) {\n %cmp = icmp sle ptr %x, %y\n %cmpeq = icmp ne ptr %x, null\n %r = or i1 %cmp, %cmpeq\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstCombine] `samesign` flag should be dropped in `foldAndOrOfICmpsWithConstEq`",
"body": "Reproducer:\r\n```\r\n; bin/opt -passes=instcombine test.ll -S\r\ndefine i1 @src(i8 %x, i8 %y) {\r\n %cmp = icmp sgt i8 %x, %y\r\n %cmpeq = icmp samesign ne i8 %x, 0\r\n %r = select i1 %cmp, i1 true, i1 %cmpeq\r\n ret i1 %r\r\n}\r\n```\r\n```\r\ndefine i1 @tgt(i8 %x, i8 %y) {\r\n %cmpeq = icmp samesign ne i8 %x, 0\r\n %1 = icmp slt i8 %y, 0\r\n %r = or i1 %cmpeq, %1\r\n ret i1 %r\r\n}\r\n```\r\n```\r\n----------------------------------------\r\ndefine i1 @src(i8 %x, i8 %y) {\r\n#0:\r\n %cmp = icmp sgt i8 %x, %y\r\n %cmpeq = icmp samesign ne i8 %x, 0\r\n %r = select i1 %cmp, i1 1, i1 %cmpeq\r\n ret i1 %r\r\n}\r\n=>\r\ndefine i1 @tgt(i8 %x, i8 %y) {\r\n#0:\r\n %cmpeq = icmp samesign ne i8 %x, 0\r\n %#1 = icmp slt i8 %y, 0\r\n %r = or i1 %cmpeq, %#1\r\n ret i1 %r\r\n}\r\nTransformation doesn't verify!\r\n\r\nERROR: Target is more poisonous than source\r\n\r\nExample:\r\ni8 %x = #x81 (129, -127)\r\ni8 %y = #x80 (128, -128)\r\n\r\nSource:\r\ni1 %cmp = #x1 (1)\r\ni1 %cmpeq = poison\r\ni1 %r = #x1 (1)\r\n\r\nTarget:\r\ni1 %cmpeq = poison\r\ni1 %#1 = #x1 (1)\r\ni1 %r = 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": true,
"is_single_func_fix": true
}
| null |
137152
|
https://github.com/llvm/llvm-project/issues/137152
|
crash
|
224cd50e005a9215e8c528d5ce68d4fcdfcdb98f
| 2025-04-24T10:47:46 |
[
"llvm/test/Transforms/GlobalOpt"
] |
{
"fix_commit": "57530c23a53b5e003d389437637f61c5b9814e22",
"components": [
"GlobalOpt"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": [
[
719,
728
]
],
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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": [
"allUsesOfLoadedValueWillTrapIfNull"
],
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 57530c23a53b5e003d389437637f61c5b9814e22
Author: Nikita Popov <npopov@redhat.com>
Date: Thu Apr 24 15:15:47 2025 +0200
[GlobalOpt] Do not promote malloc if there are atomic loads/stores (#137158)
When converting a malloc stored to a global into a global, we will
introduce an i1 flag to track whether the global has been initialized.
In case of atomic loads/stores, this will result in verifier failures,
because atomic ops on i1 are illegal. Even if we changed this to i8, I
don't think it is a good idea to change atomic types in that way.
Instead, bail out of the transform is we encounter any atomic
loads/stores of the global.
Fixes https://github.com/llvm/llvm-project/issues/137152.
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index cfba8dcc05b2..3771cccbde17 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -719,10 +719,14 @@ static bool allUsesOfLoadedValueWillTrapIfNull(const GlobalVariable *GV) {
const Value *P = Worklist.pop_back_val();
for (const auto *U : P->users()) {
if (auto *LI = dyn_cast<LoadInst>(U)) {
+ if (!LI->isSimple())
+ return false;
SmallPtrSet<const PHINode *, 8> PHIs;
if (!AllUsesOfValueWillTrapIfNull(LI, PHIs))
return false;
} else if (auto *SI = dyn_cast<StoreInst>(U)) {
+ if (!SI->isSimple())
+ return false;
// Ignore stores to the global.
if (SI->getPointerOperand() != P)
return false;
|
[
{
"file": "llvm/test/Transforms/GlobalOpt/malloc-promote-atomic.ll",
"commands": [
"opt -passes=globalopt -S < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n@g = internal global ptr null, align 8\n\ndefine void @init() {\n;\n %alloc = call ptr @malloc(i64 48)\n store atomic ptr %alloc, ptr @g seq_cst, align 8\n ret void\n}\n\ndefine i1 @check() {\n;\n %val = load atomic ptr, ptr @g seq_cst, align 8\n %cmp = icmp eq ptr %val, null\n ret i1 %cmp\n}\n\ndeclare ptr @malloc(i64) allockind(\"alloc,uninitialized\") allocsize(0)",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[GlobalOpt] Incorrect change of atomic type",
"body": "```llvm\n; RUN: opt -S -passes=globalopt\n@g = internal global ptr null, align 8\n\ndefine void @init() {\n %alloc = call ptr @malloc(i64 48)\n store atomic ptr %alloc, ptr @g seq_cst, align 8\n ret void\n} \n\ndefine i1 @check() {\n %val = load atomic ptr, ptr @g seq_cst, align 8\n %cmp = icmp eq ptr %val, null\n ret i1 %cmp\n}\n\ndeclare ptr @malloc(i64) allockind(\"alloc,uninitialized\") allocsize(0)\n```\nResults in:\n```\natomic memory access' size must be byte-sized\n i1 store atomic i1 true, ptr @g.init seq_cst, align 1\natomic memory access' size must be byte-sized\n i1 %g.init.val = load atomic i1, ptr @g.init seq_cst, align 1\nLLVM ERROR: Broken module found, compilation aborted!\n```\n",
"author": "nikic",
"labels": [
"ipo",
"release:backport",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
119173
|
https://github.com/llvm/llvm-project/issues/119173
|
miscompilation
|
ab77db03ce28e86a61010e51ea13796ea09efc46
| 2024-12-09T07:19:06 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "30f3752e54fa7cd595a434a985efbe9a7abe9b65",
"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": [
[
6637,
6644
],
[
8588,
8593
]
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"LoopVectorizationCostModel::getInstructionCost",
"VPRecipeBuilder::tryToWiden"
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": 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 30f3752e54fa7cd595a434a985efbe9a7abe9b65
Author: Florian Hahn <flo@fhahn.com>
Date: Mon Feb 3 17:01:02 2025 +0000
[VPlan] Only use SCEV for live-ins in tryToWiden. (#125436)
Replacing a recipe with a live-in may not be correct in all cases,
e.g. when replacing recipes involving header-phi recipes, like
reductions.
For now, only use SCEV to simplify live-ins.
More powerful input simplification can be built in top of
https://github.com/llvm/llvm-project/pull/124432 in the future.
Fixes https://github.com/llvm/llvm-project/issues/119173.
Fixes https://github.com/llvm/llvm-project/issues/125374.
PR: https://github.com/llvm/llvm-project/pull/125436
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index cbb9960959f2..ce66350669d5 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -6637,8 +6637,10 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I,
// fold away. We can generalize this for all operations using the notion
// of neutral elements. (TODO)
if (I->getOpcode() == Instruction::Mul &&
- (PSE.getSCEV(I->getOperand(0))->isOne() ||
- PSE.getSCEV(I->getOperand(1))->isOne()))
+ ((TheLoop->isLoopInvariant(I->getOperand(0)) &&
+ PSE.getSCEV(I->getOperand(0))->isOne()) ||
+ (TheLoop->isLoopInvariant(I->getOperand(1)) &&
+ PSE.getSCEV(I->getOperand(1))->isOne())))
return 0;
// Detect reduction patterns
@@ -8588,6 +8590,8 @@ VPWidenRecipe *VPRecipeBuilder::tryToWiden(Instruction *I,
// to replace operands with constants.
ScalarEvolution &SE = *PSE.getSE();
auto GetConstantViaSCEV = [this, &SE](VPValue *Op) {
+ if (!Op->isLiveIn())
+ return Op;
Value *V = Op->getUnderlyingValue();
if (isa<Constant>(V) || !SE.isSCEVable(V->getType()))
return Op;
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/mul-simplification.ll",
"commands": [
"opt -p loop-vectorize -S %s"
],
"tests": [
{
"test_name": "mul_select_operand_known_1_via_scev",
"test_body": "target triple = \"arm64-apple-macosx\"\n\ndefine i64 @mul_select_operand_known_1_via_scev() {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %red = phi i64 [ 12, %entry ], [ %red.next, %loop ]\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %0 = and i32 %iv, 1\n %cmp1.i = icmp eq i32 %0, 0\n %narrow.i = select i1 %cmp1.i, i32 1, i32 %iv\n %mul = zext nneg i32 %narrow.i to i64\n %red.next = mul nsw i64 %red, %mul\n %iv.next = add nuw nsw i32 %iv, 1\n %ec = icmp eq i32 %iv, 1\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n %res = phi i64 [ %red.next, %loop ]\n ret i64 %res\n}\n",
"lli_expected_out": null,
"additional_args": "-src-unroll=4 -tgt-unroll=4"
},
{
"test_name": "pr125374",
"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() {\nentry:\n br label %for.body.i.i\n\nfor.body.i.i: ; preds = %for.body.i.i, %entry\n %indvars.iv.i.i = phi i64 [ 0, %entry ], [ %indvars.iv.next.i.i, %for.body.i.i ]\n %conv678.i.i = phi i8 [ 1, %entry ], [ %add.i.i.i, %for.body.i.i ]\n %add.i.i.i = add i8 0, %conv678.i.i\n %indvars.iv.next.i.i = add i64 %indvars.iv.i.i, 1\n %exitcond.not.i.i = icmp eq i64 %indvars.iv.i.i, 1\n br i1 %exitcond.not.i.i, label %o.exit, label %for.body.i.i\n\no.exit: ; preds = %for.body.i.i\n %conv6.i.i = zext i8 %add.i.i.i to i32\n ret i32 %conv6.i.i\n}\n",
"lli_expected_out": null,
"additional_args": "-src-unroll=2 -tgt-unroll=2"
}
]
}
] |
{
"title": "[clang] Miscompilation at -O3",
"body": "This code prints 15 at -O3, but prints 5 at -O0/1/2:\n```c\nint printf(const char *, ...);\nstatic int a[] = {4294967295, 5};\nint b, c;\nint main() {\n a[1] = b = 5;\n unsigned d = -13;\n for (; d >= 8; d = a[0] + d + 6) {\n int *e = &b;\n *e = a[0] - -1 + b;\n }\n a[c];\n printf(\"%d\\n\", b);\n}\n```\n\nCompiler Explorer: https://godbolt.org/z/4xdPqcjPb\n\nBisected to https://github.com/llvm/llvm-project/commit/6d6eea92e36c301e34a7ec11b2a40e3080f79f53, which was committed by @fhahn ",
"author": "cardigan1008",
"labels": [
"miscompilation",
"vectorizers"
],
"comments": [
{
"author": "hstk30-hw",
"body": "Don't ignore the warning.\n\n```\n<source>:2:19: warning: implicit conversion from 'long' to 'int' changes value from 4294967294 to -2 [-Wconstant-conversion]\n 2 | static int a[] = {4294967294, 5};\n | ~^~~~~~~~~~\n```"
},
{
"author": "antoniofrighetto",
"body": "Please leave the issue opened, as it's implementation-defined behaviour, not undefined behaviour."
},
{
"author": "antoniofrighetto",
"body": "Reduced to:\n```llvm\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine noundef i32 @src() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %entry, %for.body\n %d.06 = phi i32 [ -13, %entry ], [ %add2.reass, %for.body ]\n %add45 = phi i32 [ 5, %entry ], [ %add, %for.body ]\n %add = add i32 0, %add45\n %add2.reass = add i32 %d.06, 5\n %cmp = icmp ugt i32 %add2.reass, 7\n br i1 %cmp, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret i32 %add\n}\n```\n\n@fhahn I think the issue fundamentally here lies in the fact that we are incorrectly widening the constant 5 (retrieved from SCEV) to `<5, 5, 5, 5>`, when in fact it should be `<5, 0, 0, 0>` (VPlan value: `WIDEN-REDUCTION-PHI ir<%add45> = phi ir<5>`). The VPBasicBlock for the miscompiled basic block is the following one:\n```\nvector.body:\n EMIT vp<%4> = CANONICAL-INDUCTION ir<0>, vp<%7>\n WIDEN-INDUCTION %d.06 = phi -13, %add2.reass, ir<5>, vp<%0>\n WIDEN-REDUCTION-PHI ir<%add45> = phi ir<5>\n EMIT vp<%5> = WIDEN-CANONICAL-INDUCTION vp<%4>\n EMIT vp<%6> = icmp ule vp<%5>, vp<%3>\n```\nI'm not that familiar with VPlan, though I feel like that either we are not taking into account the active lane, or we should have not emitted a widen instruction in the first place.\n\n(Godbolt: https://llvm.godbolt.org/z/4Wz46ceh1)"
},
{
"author": "antoniofrighetto",
"body": "@fhahn Would you be willing to have a look at it? Happy to help with any additional triage, if needed."
},
{
"author": "fhahn",
"body": "Yep let me take a look!"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
157335
|
https://github.com/llvm/llvm-project/issues/157335
|
crash
|
61a8d2deec7341527a35299d1b1ed2cf2327706f
| 2025-09-07T09:21:41 |
[
"llvm/test/Transforms/VectorCombine"
] |
{
"fix_commit": "ad3a0ae9e15f102e2cdc37e34d47b5b9d6e09497",
"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": [
[
3903,
3908
]
],
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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::foldSelectShuffle"
],
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 ad3a0ae9e15f102e2cdc37e34d47b5b9d6e09497
Author: Simon Pilgrim <llvm-dev@redking.me.uk>
Date: Mon Sep 8 13:04:23 2025 +0100
[VectorCombine] foldSelectShuffle - early-out cases where the max vector register width isn't large enough (#157430)
Technically this could happen with vector units that can't handle all legal scalar widths - but its good enough to use a generic crash test without a suitable target
Fixes #157335
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index 7a0b7ad57a49..9dd1532d1b23 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -3903,6 +3903,8 @@ bool VectorCombine::foldSelectShuffle(Instruction &I, bool FromReduction) {
unsigned MaxVectorSize =
TTI.getRegisterBitWidth(TargetTransformInfo::RGK_FixedWidthVector);
unsigned MaxElementsInVector = MaxVectorSize / ElementSize;
+ if (MaxElementsInVector == 0)
+ return false;
// When there are multiple shufflevector operations on the same input,
// especially when the vector length is larger than the register size,
// identical shuffle patterns may occur across different groups of elements.
|
[
{
"file": "llvm/test/Transforms/VectorCombine/pr157335.ll",
"commands": [
"opt -passes=vector-combine -S %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine <2 x double> @PR157335() {\n;\n %v0 = fmul <2 x double> zeroinitializer, zeroinitializer\n %v1 = fmul <2 x double> zeroinitializer, zeroinitializer\n %v2 = fsub <2 x double> %v0, %v1\n %v3 = fadd <2 x double> %v0, %v1\n %v4 = shufflevector <2 x double> %v2, <2 x double> %v3, <2 x i32> <i32 0, i32 3>\n ret <2 x double> %v4\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[VectorCombine] llvm/test/CodeGen/PowerPC/swaps-le-7.ll crashes with -passes=vector-combine",
"body": "The following reproducer comes from https://github.com/llvm/llvm-project/blob/main/llvm/test/CodeGen/PowerPC/swaps-le-7.ll\n\nReproducer:\nhttps://godbolt.org/z/5c69hEYGf\n\nBacktrace:\n```console\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-trunk/bin/opt -o /app/output.s -S -passes=vector-combine <source>\n1.\tRunning pass \"function(vector-combine)\" on module \"<source>\"\n2.\tRunning pass \"vector-combine\" on function \"zg\"\n #0 0x00000000051c5948 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/opt+0x51c5948)\n #1 0x00000000051c2b14 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x000074409f442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x000000000333c02a (anonymous namespace)::VectorCombine::foldSelectShuffle(llvm::Instruction&, bool) VectorCombine.cpp:0:0\n #4 0x000000000333e071 (anonymous namespace)::VectorCombine::run()::'lambda'(llvm::Instruction&)::operator()(llvm::Instruction&) const (.isra.0) VectorCombine.cpp:0:0\n #5 0x000000000333f12c llvm::VectorCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-trunk/bin/opt+0x333f12c)\n #6 0x0000000002b961ae llvm::detail::PassModel<llvm::Function, llvm::VectorCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-trunk/bin/opt+0x2b961ae)\n #7 0x0000000004fb33b7 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-trunk/bin/opt+0x4fb33b7)\n #8 0x0000000000e50cbe llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-trunk/bin/opt+0xe50cbe)\n #9 0x0000000004fb7018 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-trunk/bin/opt+0x4fb7018)\n#10 0x00000000009802ae llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-trunk/bin/opt+0x9802ae)\n#11 0x0000000004fadbd7 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-trunk/bin/opt+0x4fadbd7)\n#12 0x0000000000989dfa 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-trunk/bin/opt+0x989dfa)\n#13 0x000000000097e4b3 optMain (/opt/compiler-explorer/clang-trunk/bin/opt+0x97e4b3)\n#14 0x000074409f429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#15 0x000074409f429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#16 0x00000000009764c5 _start (/opt/compiler-explorer/clang-trunk/bin/opt+0x9764c5)\nProgram terminated with signal: SIGFPE\nCompiler returned: 136\n```\n",
"author": "k-arrows",
"labels": [
"crash",
"llvm::vectorcombine"
],
"comments": [
{
"author": "k-arrows",
"body": "This crash happens with opt(trunk) and opt(assertions trunk), and does not with opt 21.1.0\nhttps://godbolt.org/z/8bhzhKMvY"
},
{
"author": "dtcxzyw",
"body": "This crash disappears after specifying `target triple = \"powerpc64le-unknown-linux-gnu\"`. I think VectorCombine/SLPVectorizer are not expected to work without TTI.\n"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
121584
|
https://github.com/llvm/llvm-project/issues/121584
|
miscompilation
|
4a7c0b8afe6bf616cd6bb4f13b5b706a43c10e74
| 2025-01-03T17:05:45 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "24c2ba07ce65a5bf7d1113e05c517169d950b663",
"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": [
[
2066,
2079
],
[
2095,
2101
],
[
2108,
2114
],
[
2131,
2137
]
],
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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": [
"simplifyIRemMulShl"
],
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 24c2ba07ce65a5bf7d1113e05c517169d950b663
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Sun Jan 5 01:20:54 2025 +0800
[InstCombine] Drop NSW when converting `shl X, BW - 1` back into mul (#121633)
`X <<s BW - 1` and `X *s INT_MIN` are not equivalent.
Alive2: https://alive2.llvm.org/ce/z/MKKFrj
Closes https://github.com/llvm/llvm-project/issues/121584
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
index f85a3c936513..97a765ecfb6b 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
@@ -2066,14 +2066,18 @@ static Instruction *simplifyIRemMulShl(BinaryOperator &I,
bool ShiftByX = false;
// If V is not nullptr, it will be matched using m_Specific.
- auto MatchShiftOrMulXC = [](Value *Op, Value *&V, APInt &C) -> bool {
+ auto MatchShiftOrMulXC = [](Value *Op, Value *&V, APInt &C,
+ bool &PreserveNSW) -> bool {
const APInt *Tmp = nullptr;
if ((!V && match(Op, m_Mul(m_Value(V), m_APInt(Tmp)))) ||
(V && match(Op, m_Mul(m_Specific(V), m_APInt(Tmp)))))
C = *Tmp;
else if ((!V && match(Op, m_Shl(m_Value(V), m_APInt(Tmp)))) ||
- (V && match(Op, m_Shl(m_Specific(V), m_APInt(Tmp)))))
+ (V && match(Op, m_Shl(m_Specific(V), m_APInt(Tmp))))) {
C = APInt(Tmp->getBitWidth(), 1) << *Tmp;
+ // We cannot preserve NSW when shifting by BW - 1.
+ PreserveNSW = Tmp->ult(Tmp->getBitWidth() - 1);
+ }
if (Tmp != nullptr)
return true;
@@ -2095,7 +2099,9 @@ static Instruction *simplifyIRemMulShl(BinaryOperator &I,
return false;
};
- if (MatchShiftOrMulXC(Op0, X, Y) && MatchShiftOrMulXC(Op1, X, Z)) {
+ bool Op0PreserveNSW = true, Op1PreserveNSW = true;
+ if (MatchShiftOrMulXC(Op0, X, Y, Op0PreserveNSW) &&
+ MatchShiftOrMulXC(Op1, X, Z, Op1PreserveNSW)) {
// pass
} else if (MatchShiftCX(Op0, Y, X) && MatchShiftCX(Op1, Z, X)) {
ShiftByX = true;
@@ -2108,7 +2114,7 @@ static Instruction *simplifyIRemMulShl(BinaryOperator &I,
OverflowingBinaryOperator *BO0 = cast<OverflowingBinaryOperator>(Op0);
// TODO: We may be able to deduce more about nsw/nuw of BO0/BO1 based on Y >=
// Z or Z >= Y.
- bool BO0HasNSW = BO0->hasNoSignedWrap();
+ bool BO0HasNSW = Op0PreserveNSW && BO0->hasNoSignedWrap();
bool BO0HasNUW = BO0->hasNoUnsignedWrap();
bool BO0NoWrap = IsSRem ? BO0HasNSW : BO0HasNUW;
@@ -2131,7 +2137,7 @@ static Instruction *simplifyIRemMulShl(BinaryOperator &I,
};
OverflowingBinaryOperator *BO1 = cast<OverflowingBinaryOperator>(Op1);
- bool BO1HasNSW = BO1->hasNoSignedWrap();
+ bool BO1HasNSW = Op1PreserveNSW && BO1->hasNoSignedWrap();
bool BO1HasNUW = BO1->hasNoUnsignedWrap();
bool BO1NoWrap = IsSRem ? BO1HasNSW : BO1HasNUW;
// (rem (mul X, Y), (mul nuw/nsw X, Z))
|
[
{
"file": "llvm/test/Transforms/InstCombine/rem-mul-shl.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "srem_XY_XZ_with_CY_gt_CZ_no_nuw_out",
"test_body": "define <2 x i8> @srem_XY_XZ_with_CY_gt_CZ_no_nuw_out(<2 x i8> %X) {\n %BO0 = mul nsw <2 x i8> %X, splat (i8 10)\n %BO1 = shl nuw nsw <2 x i8> %X, splat (i8 3)\n %r = srem <2 x i8> %BO0, %BO1\n ret <2 x i8> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "srem_XY_XZ_with_CY_gt_CZ_drop_nsw_commuted",
"test_body": "define i8 @srem_XY_XZ_with_CY_gt_CZ_drop_nsw_commuted(i8 noundef %X) {\n %BO0 = mul nsw i8 %X, 127\n %BO1 = shl nsw i8 %X, 7\n %r = srem i8 %BO0, %BO1\n ret i8 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "srem_XY_XZ_with_CY_gt_CZ_drop_nsw",
"test_body": "define i8 @srem_XY_XZ_with_CY_gt_CZ_drop_nsw(i8 noundef %X) {\n %BO0 = mul nsw i8 %X, 127\n %BO1 = shl nsw i8 %X, 7\n %r = srem i8 %BO1, %BO0\n ret i8 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "srem_XY_XZ_with_CY_gt_CZ_fail_missing_flag1",
"test_body": "define i8 @srem_XY_XZ_with_CY_gt_CZ_fail_missing_flag1(i8 %X) {\n %BO0 = mul nuw nsw i8 %X, 10\n %BO1 = mul nuw i8 %X, 6\n %r = srem i8 %BO0, %BO1\n ret i8 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstCombine] Miscompilation in `simplifyIRemMulShl`",
"body": "Alive2: https://alive2.llvm.org/ce/z/rdeehL\n```\n\n----------------------------------------\ndefine i8 @srem_XY_XZ_with_CY_gt_CZ_no_nuw_out1(i8 noundef %X) {\n#0:\n %BO0 = mul nsw i8 noundef %X, 127\n %BO1 = shl nsw i8 noundef %X, 7\n %r = srem i8 %BO1, %BO0\n ret i8 %r\n}\n=>\ndefine i8 @srem_XY_XZ_with_CY_gt_CZ_no_nuw_out1(i8 noundef %X) {\n#0:\n %r = sub nsw i8 0, noundef %X\n ret i8 %r\n}\nTransformation doesn't verify!\n\nERROR: Value mismatch\n\nExample:\ni8 noundef %X = #xff (255, -1)\n\nSource:\ni8 %BO0 = #x81 (129, -127)\ni8 %BO1 = #x80 (128, -128)\ni8 %r = #xff (255, -1)\n\nTarget:\ni8 %r = #x01 (1)\nSource value: #xff (255, -1)\nTarget value: #x01 (1)\n\nSummary:\n 0 correct transformations\n 1 incorrect transformations\n 0 failed-to-prove transformations\n 0 Alive2 errors\n```",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
125357
|
https://github.com/llvm/llvm-project/issues/125357
|
crash
|
cdeeb390a9ea21540fc44ba10dede66fbc0b2fc8
| 2025-02-01T20:11:30 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "0c70a26f46e4efd5a29eb281ff99d2cf7f04c6f6",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
20147,
20153
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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 0c70a26f46e4efd5a29eb281ff99d2cf7f04c6f6
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Mon Feb 3 04:37:49 2025 -0800
[SLP]Clear root node reordering only if the root node is not re-used in graph
The reordering of the root node can be safely cleared only if the root
node is not reused, otherwise the graph might be broken
Fixes #125357
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 4f83b9cfa18d..539c9227af7e 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -20147,7 +20147,7 @@ public:
}
V.reorderTopToBottom();
// No need to reorder the root node at all.
- V.reorderBottomToTop(/*IgnoreReorder=*/true);
+ V.reorderBottomToTop(!V.doesRootHaveInTreeUses());
// Keep extracted other reduction values, if they are used in the
// vectorization trees.
BoUpSLP::ExtraValueToDebugLocsMap LocalExternallyUsedValues(
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/root-node-reordered-reused.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "; ModuleID = 'test.ll'\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\ndefine i32 @main(i32 %0) {\nentry:\n %tobool.not = icmp eq i32 %0, 0\n br i1 %tobool.not, label %if.end6, label %if.then\n\nif.then: ; preds = %entry\n br i1 %tobool.not, label %if.end, label %i\n\nif.end: ; preds = %if.then\n br i1 %tobool.not, label %if.end6, label %i\n\nif.end6: ; preds = %if.end, %entry\n %h.0 = phi i32 [ %0, %if.end ], [ 0, %entry ]\n br i1 %tobool.not, label %i, label %if.end13\n\ni: ; preds = %if.end13, %if.end6, %if.end, %if.then\n %h.1 = phi i32 [ %0, %if.then ], [ %h.2, %if.end13 ], [ %0, %if.end ], [ %h.0, %if.end6 ]\n %j.0 = phi i32 [ undef, %if.then ], [ %j.1, %if.end13 ], [ undef, %if.end ], [ %0, %if.end6 ]\n %k.0 = phi i32 [ undef, %if.then ], [ %k.1, %if.end13 ], [ undef, %if.end ], [ %0, %if.end6 ]\n %l.0 = phi i32 [ undef, %if.then ], [ %l.1, %if.end13 ], [ undef, %if.end ], [ %0, %if.end6 ]\n %or = or i32 %j.0, %h.1\n %or9 = or i32 %or, %k.0\n %or10 = or i32 %or9, %l.0\n %tobool11.not = icmp eq i32 %or10, 0\n br i1 %tobool11.not, label %if.end13, label %land.rhs\n\nland.rhs: ; preds = %i\n br label %if.end13\n\nif.end13: ; preds = %i, %land.rhs, %if.end6\n %h.2 = phi i32 [ %h.0, %if.end6 ], [ %h.1, %land.rhs ], [ %h.1, %i ]\n %j.1 = phi i32 [ %0, %if.end6 ], [ %j.0, %land.rhs ], [ %j.0, %i ]\n %k.1 = phi i32 [ %0, %if.end6 ], [ %k.0, %land.rhs ], [ %k.0, %i ]\n %l.1 = phi i32 [ %0, %if.end6 ], [ %l.0, %land.rhs ], [ %l.0, %i ]\n br i1 true, label %if.end15, label %i\n\nif.end15: ; preds = %if.end13\n ret i32 0\n\n; uselistorder directives\n uselistorder i32 %k.0, { 1, 2, 0 }\n uselistorder i32 %l.0, { 1, 2, 0 }\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 `TE->isSame(VL) && \"Expected same scalars.\"' 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/6ca9841xE\n\n```\n[512] % clangtk -v\nclang version 21.0.0git (https://github.com/llvm/llvm-project.git 7612dcc6e8d8e7f19b364084effbb01946294720)\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[513] % \n[513] % clangtk -O3 small.c\nclang-21: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:3011: llvm::slpvectorizer::BoUpSLP::TreeEntry* llvm::slpvectorizer::BoUpSLP::getVectorizedOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int): Assertion `TE->isSame(VL) && \"Expected same scalars.\"' 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/20250201-clangtk-m64-O3-build-174536/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20250201-clangtk-m64-O3-build-174536/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-b035e7.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 0x00005596296c84af llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x479d4af)\n #1 0x00005596296c5c84 SignalHandler(int) Signals.cpp:0:0\n #2 0x00007fe817057420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\n #3 0x00007fe816a8e00b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\n #4 0x00007fe816a6d859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\n #5 0x00007fe816a6d729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\n #6 0x00007fe816a6d729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\n #7 0x00007fe816a7efd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\n #8 0x000055962b1df5c7 llvm::slpvectorizer::BoUpSLP::getSpillCost() (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x62b45c7)\n #9 0x000055962b243030 llvm::slpvectorizer::BoUpSLP::getTreeCost(llvm::ArrayRef<llvm::Value*>) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x6318030)\n#10 0x000055962b247f34 (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&, llvm::AssumptionCache*) SLPVectorizer.cpp:0:0\n#11 0x000055962b24a205 llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x631f205)\n#12 0x000055962b24ee25 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+0x6323e25)\n#13 0x000055962b24fedb llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&)::'lambda3'(bool)::operator()(bool) const SLPVectorizer.cpp:0:0\n#14 0x000055962b253720 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x6328720)\n#15 0x000055962b259f46 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#16 0x000055962b25aaa3 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x632faa3)\n#17 0x000055962ac7c7e6 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+0x5d517e6)\n#18 0x000055962903ed49 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+0x4113d49)\n#19 0x000055962693a376 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+0x1a0f376)\n#20 0x000055962903d5b2 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x41125b2)\n#21 0x0000559626938aa6 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+0x1a0daa6)\n#22 0x000055962903cfd1 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+0x4111fd1)\n#23 0x0000559629991596 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\n#24 0x0000559629995253 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+0x4a6a253)\n#25 0x000055962a09f2ce clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x51742ce)\n#26 0x000055962ba0f29c clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x6ae429c)\n#27 0x000055962a09f708 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x5174708)\n#28 0x000055962a3719d9 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x54469d9)\n#29 0x000055962a2f25be clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x53c75be)\n#30 0x000055962a466746 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x553b746)\n#31 0x00005596264d4a87 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x15a9a87)\n#32 0x00005596264cc33a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#33 0x00005596264d0471 clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x15a5471)\n#34 0x00005596263bb29b main (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x149029b)\n#35 0x00007fe816a6f083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\n#36 0x00005596264cbdce _start (/local/suz-local/software/local/clang-trunk/bin/clang-21+0x15a0dce)\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 7612dcc6e8d8e7f19b364084effbb01946294720)\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-401f68.c\nclangtk: note: diagnostic msg: /tmp/small-401f68.sh\nclangtk: note: diagnostic msg: \n\n********************\n[514] % \n[514] % cat small.c\nint a, b, c, d, e;\nvolatile int f;\nint main() {\n int h = 0, j, k, l;\n if (d) {\n h = c;\n if (f)\n goto i;\n if (f)\n goto i;\n }\n l = j = k = d;\n if (!b)\n i:\n (l | (h | j) | k) && f;\n if (a != e)\n goto i;\n return 0;\n}\n```\n\n\n",
"author": "zhendongsu",
"labels": [
"llvm:SLPVectorizer",
"crash",
"generated by fuzzer"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Reduced reproducer: https://godbolt.org/z/TWadzP8Gc\n"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
141265
|
https://github.com/llvm/llvm-project/issues/141265
|
crash
|
69f2ff3e9be5e786529a409e6f06f942096e8dbb
| 2025-05-23T17:57:35 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "aa452b65fc7ebfee6f7e5b9d08aa418d532c7b88",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
18535,
18540
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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 aa452b65fc7ebfee6f7e5b9d08aa418d532c7b88
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Sat May 24 07:20:41 2025 -0700
[SLP]Restore insertion points after gathers vectorization
Restore insertion points after gathers vectorization to avoid a crash in
a root node vectorization.
Fixes #141265
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 0f86c572639c..831703b375d9 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -18535,6 +18535,7 @@ Value *BoUpSLP::vectorizeTree(
}
}
for (auto &Entry : GatherEntries) {
+ IRBuilderBase::InsertPointGuard Guard(Builder);
Builder.SetInsertPoint(Entry.second);
Builder.SetCurrentDebugLocation(Entry.second->getDebugLoc());
(void)vectorizeTree(Entry.first);
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/RISCV/gather-insert-point-restore.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=riscv64-unknown-linux-gnu -mattr=+v < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine i16 @test(ptr %i) {\n;\nentry:\n %gep.us154 = getelementptr i8, ptr %i, i64 132860\n %gep.us154.1 = getelementptr i8, ptr %i, i64 137774\n %gep.us154.2 = getelementptr i8, ptr %i, i64 142688\n %gep.us154.3 = getelementptr i8, ptr %i, i64 147602\n %gep.us154.4 = getelementptr i8, ptr %i, i64 152516\n %gep.us154.5 = getelementptr i8, ptr %i, i64 157430\n br label %for.cond5.us\n\nfor.cond5.us:\n %0 = load i16, ptr %gep.us154, align 2\n %1 = load i16, ptr %gep.us154.1, align 2\n %2 = load i16, ptr %gep.us154.2, align 2\n %3 = load i16, ptr %gep.us154.3, align 2\n %4 = load i16, ptr %gep.us154.4, align 2\n %5 = load i16, ptr %gep.us154.5, align 2\n %6 = call i16 @llvm.umax.i16(i16 %5, i16 0)\n %7 = call i16 @llvm.umax.i16(i16 %0, i16 %6)\n %8 = call i16 @llvm.umax.i16(i16 %1, i16 %7)\n %9 = call i16 @llvm.umax.i16(i16 %2, i16 %8)\n %10 = call i16 @llvm.umax.i16(i16 %3, i16 %9)\n %11 = call i16 @llvm.umax.i16(i16 %2, i16 %10)\n %12 = call i16 @llvm.umax.i16(i16 %3, i16 %11)\n %13 = call i16 @llvm.umax.i16(i16 %4, i16 %12)\n %14 = load i16, ptr %gep.us154, align 2\n %15 = call i16 @llvm.umax.i16(i16 %14, i16 %13)\n %16 = load i16, ptr %gep.us154.1, align 2\n %17 = call i16 @llvm.umax.i16(i16 %16, i16 %15)\n %18 = call i16 @llvm.umax.i16(i16 %4, i16 %17)\n ret i16 %18\n}\n\ndeclare i16 @llvm.umax.i16(i16, i16) #1",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SLPVectorizer] Instruction does not dominate all uses!",
"body": "Testcase:\n```llvm ir\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine i16 @c(ptr %i) #0 {\nentry:\n %gep.us154 = getelementptr i8, ptr %i, i64 132860\n %gep.us154.1 = getelementptr i8, ptr %i, i64 137774\n %gep.us154.2 = getelementptr i8, ptr %i, i64 142688\n %gep.us154.3 = getelementptr i8, ptr %i, i64 147602\n %gep.us154.4 = getelementptr i8, ptr %i, i64 152516\n %gep.us154.5 = getelementptr i8, ptr %i, i64 157430\n br label %for.cond5.us\n\nfor.cond5.us: ; preds = %entry\n %0 = load i16, ptr %gep.us154, align 2\n %1 = load i16, ptr %gep.us154.1, align 2\n %2 = load i16, ptr %gep.us154.2, align 2\n %3 = load i16, ptr %gep.us154.3, align 2\n %4 = load i16, ptr %gep.us154.4, align 2\n %5 = load i16, ptr %gep.us154.5, align 2\n %6 = call i16 @llvm.umax.i16(i16 %5, i16 0)\n %7 = call i16 @llvm.umax.i16(i16 %0, i16 %6)\n %8 = call i16 @llvm.umax.i16(i16 %1, i16 %7)\n %9 = call i16 @llvm.umax.i16(i16 %2, i16 %8)\n %10 = call i16 @llvm.umax.i16(i16 %3, i16 %9)\n %11 = call i16 @llvm.umax.i16(i16 %2, i16 %10)\n %12 = call i16 @llvm.umax.i16(i16 %3, i16 %11)\n %13 = call i16 @llvm.umax.i16(i16 %4, i16 %12)\n %14 = load i16, ptr %gep.us154, align 2\n %15 = call i16 @llvm.umax.i16(i16 %14, i16 %13)\n %16 = load i16, ptr %gep.us154.1, align 2\n %17 = call i16 @llvm.umax.i16(i16 %16, i16 %15)\n %18 = call i16 @llvm.umax.i16(i16 %4, i16 %17)\n ret i16 %18\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i16 @llvm.umax.i16(i16, i16) #1\n\n; uselistorder directives\nuselistorder ptr @llvm.umax.i16, { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }\n\nattributes #0 = { \"target-features\"=\"+v\" }\nattributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n```\n\nCommand/backtrace:\n```\n$ /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt reduced.ll --passes=slp-vectorizer\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\nInstruction does not dominate all uses!\n %6 = call <4 x i16> @llvm.experimental.vp.strided.load.v4i16.p0.i64(ptr align 2 %gep.us154.2, i64 4914, <4 x i1> splat (i1 true), i32 4)\n %4 = call <8 x i16> @llvm.vector.insert.v8i16.v4i16(<8 x i16> poison, <4 x i16> %6, i64 0)\nInstruction does not dominate all uses!\n %7 = call <4 x i16> @llvm.masked.gather.v4i16.v4p0(<4 x ptr> %3, i32 2, <4 x i1> splat (i1 true), <4 x i16> poison)\n %5 = call <8 x i16> @llvm.vector.insert.v8i16.v4i16(<8 x i16> %4, <4 x i16> %7, i64 4)\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. Program arguments: /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt reduced.ll --passes=slp-vectorizer\n1. Running pass \"verify\" on module \"reduced.ll\"\n #0 0x00005de624576b42 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x3588b42)\n #1 0x00005de624573baf llvm::sys::RunSignalHandlers() (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x3585baf)\n #2 0x00005de624573cf4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #3 0x0000723bce445330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)\n #4 0x0000723bce49eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #5 0x0000723bce49eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #6 0x0000723bce49eb2c pthread_kill ./nptl/pthread_kill.c:89:10\n #7 0x0000723bce44527e raise ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x0000723bce4288ff abort ./stdlib/abort.c:81:7\n #9 0x00005de6216a55f8 llvm::GlobPattern::create(llvm::StringRef, std::optional<unsigned long>) (.cold) GlobPattern.cpp:0:0\n#10 0x00005de6244a24f5 (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x34b44f5)\n#11 0x00005de6243a4a90 llvm::VerifierPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x33b6a90)\n#12 0x00005de621795e15 llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x7a7e15)\n#13 0x00005de62435f33d 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+0x337133d)\n#14 0x00005de6217a2051 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+0x7b4051)\n#15 0x00005de621793b8c optMain (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x7a5b8c)\n#16 0x0000723bce42a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3\n#17 0x0000723bce42a28b call_init ./csu/../csu/libc-start.c:128:20\n#18 0x0000723bce42a28b __libc_start_main ./csu/../csu/libc-start.c:347:5\n#19 0x00005de62178a1e5 _start (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x79c1e5)\nAborted\n```\n\nGodbolt: https://godbolt.org/z/hq5nGcnrd\n\nFound via fuzzer: Reduced from C testcase in https://github.com/llvm/llvm-project/issues/141262",
"author": "ewlu",
"labels": [
"llvm:SLPVectorizer",
"crash",
"generated by fuzzer"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
118850
|
https://github.com/llvm/llvm-project/issues/118850
|
crash
|
9ad22cf0ee9eb686ea9fd76fd9cc41f4c006ccbc
| 2024-12-05T18:11:28 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "4f7f71b7bccdc38f37b82981e8fa9ceb536a7016",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
168,
174
]
],
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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": [
"UnrollState::unrollWidenInductionByUF"
],
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 4f7f71b7bccdc38f37b82981e8fa9ceb536a7016
Author: Florian Hahn <flo@fhahn.com>
Date: Fri Dec 6 16:28:47 2024 +0000
[VPlan] Compare APInt instead of getSExtValue to fix crash in unroll.
getSExtValue assumes the result fits in 64 bits, but this may not be the
case for indcutions with wider types. Instead, directly perform the
compare on the APInt for the ConstantInt.
Fixes https://github.com/llvm/llvm-project/issues/118850.
diff --git a/llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp b/llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp
index f653269713b3..ff6c9295ee20 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp
@@ -168,7 +168,7 @@ void UnrollState::unrollWidenInductionByUF(
auto *ConstStep = ScalarStep->isLiveIn()
? dyn_cast<ConstantInt>(ScalarStep->getLiveInIRValue())
: nullptr;
- if (!ConstStep || ConstStep->getZExtValue() != 1) {
+ if (!ConstStep || ConstStep->getValue() != 1) {
if (TypeInfo.inferScalarType(ScalarStep) != IVTy) {
ScalarStep =
Builder.createWidenCast(Instruction::Trunc, ScalarStep, IVTy);
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/interleave-with-i65-induction.ll",
"commands": [
"opt -p loop-vectorize -force-vector-width=4 -force-vector-interleave=2 -S %s"
],
"tests": [
{
"test_name": "i65_induction_with_negative_step",
"test_body": "define void @i65_induction_with_negative_step(ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.i65 = phi i65 [ 0, %entry ], [ %iv.i65.next, %loop ]\n %for = phi i64 [ 0, %entry ], [ %trunc, %loop ]\n %trunc = trunc i65 %iv.i65 to i64\n %gep = getelementptr inbounds i64, ptr %dst, i64 %trunc\n store i64 %for, ptr %gep, align 8\n %iv.next = add i64 %iv, 1\n %icmp = icmp eq i64 %iv.next, 1000\n %iv.i65.next = add i65 %iv.i65, -1\n br i1 %icmp, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Assertion `getActiveBits() <= 64 && \"Too many bits for uint64_t\"' failed.",
"body": "To reproduce run the test below with -passes=loop-vectorize\n```\n; ModuleID = './reduced.ll'\nsource_filename = \"./reduced.ll\"\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32-ni:1-p2:32:8:8:32-ni:2\"\ntarget triple = \"aarch64-none-linux-gnu\"\n\ndefine double @wombat() gc \"statepoint-example\" {\nbb:\n br label %bb2\n\nbb1: ; preds = %bb2\n ret double 0.000000e+00\n\nbb2: ; preds = %bb2, %bb\n %phi = phi i64 [ 0, %bb ], [ %add, %bb2 ]\n %phi3 = phi i65 [ 0, %bb ], [ %add5, %bb2 ]\n %phi4 = phi i64 [ 0, %bb ], [ %trunc, %bb2 ]\n %trunc = trunc i65 %phi3 to i64\n store i64 0, ptr addrspace(1) null, align 8\n %add = add i64 %phi, 1\n %icmp = icmp ugt i64 %add, 0\n %add5 = add i65 %phi3, -1\n br i1 %icmp, label %bb2, label %bb1\n}\n```\nReproducer: https://godbolt.org/z/cjEcv8b4Y\n\nStack dump:\n```\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=loop-vectorize <source>\n1.\tRunning pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"<source>\"\n2.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"wombat\"\n #0 0x00000000051b3748 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x51b3748)\n #1 0x00000000051b113c SignalHandler(int) Signals.cpp:0:0\n #2 0x000071a06ec42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x000071a06ec969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x000071a06ec42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x000071a06ec287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x000071a06ec2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x000071a06ec39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x0000000000b2d8a9 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xb2d8a9)\n #9 0x0000000004308ae6 (anonymous namespace)::UnrollState::unrollBlock(llvm::VPBlockBase*) VPlanUnroll.cpp:0:0\n#10 0x000000000430788c (anonymous namespace)::UnrollState::unrollBlock(llvm::VPBlockBase*) VPlanUnroll.cpp:0:0\n#11 0x0000000004309060 llvm::VPlanTransforms::unrollByUF(llvm::VPlan&, unsigned int, llvm::LLVMContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4309060)\n#12 0x0000000004176b76 llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool, llvm::DenseMap<llvm::SCEV const*, llvm::Value*, llvm::DenseMapInfo<llvm::SCEV const*, void>, llvm::detail::DenseMapPair<llvm::SCEV const*, llvm::Value*>> const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4176b76)\n#13 0x000000000418cb6f llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x418cb6f)\n#14 0x000000000418ebd9 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x418ebd9)\n#15 0x000000000418f213 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x418f213)\n#16 0x0000000002fcba8e llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2fcba8e)\n#17 0x0000000004fb2700 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4fb2700)\n#18 0x0000000000e33a9e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe33a9e)\n#19 0x0000000004fb101b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4fb101b)\n#20 0x0000000000e3312e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe3312e)\n#21 0x0000000004fb0a20 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4fb0a20)\n#22 0x0000000000910a1a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x910a1a)\n#23 0x0000000000903099 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x903099)\n#24 0x000071a06ec29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#25 0x000071a06ec29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#26 0x00000000008fa97e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8fa97e)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```\n",
"author": "TatyanaDoubts",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "huang-me",
"body": "Hi @TatyanaDoubts, \nHow did you get the IR snippet? \nThe IR you provided is weird. I'll have to check where i65 constant 0 in `%phi3 = phi i65 [ 0, %bb ], [ %add5, %bb2 ]` come from since it seems it's the origin of the problem."
},
{
"author": "fhahn",
"body": "I suspect this was found via a fuzzer, thanks for sharing the test case!"
},
{
"author": "TatyanaDoubts",
"body": "Hi @huang-me, @fhahn, yes this crash was found by the fuzzer generated test. "
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
91369
|
https://github.com/llvm/llvm-project/issues/91369
|
miscompilation
|
9a28814f59e8f52cc63ae3d17023cee8348d9b53
| 2024-05-07T18:12:26 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "082c81ae4ab9db6bb0acd52098288223dd58501a",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
8841,
8848
]
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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::tryToBuildVPlanWithVPRecipes"
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 082c81ae4ab9db6bb0acd52098288223dd58501a
Author: Florian Hahn <flo@fhahn.com>
Date: Tue May 7 21:31:40 2024 +0100
[LV] Properly extend versioned constant strides.
We only version unknown strides to 1. If the original type is i1, then
the sign of the extension matters. Properly extend the stride value
before replacing it.
Fixes https://github.com/llvm/llvm-project/issues/91369.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 3be0102bea3e..261933966b74 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -8841,8 +8841,10 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
VPValue *StrideVPV = Plan->getLiveIn(U);
if (!StrideVPV)
continue;
- VPValue *CI = Plan->getOrAddLiveIn(ConstantInt::get(
- U->getType(), ScevStride->getAPInt().getSExtValue()));
+ unsigned BW = U->getType()->getScalarSizeInBits();
+ APInt C = isa<SExtInst>(U) ? ScevStride->getAPInt().sext(BW)
+ : ScevStride->getAPInt().zext(BW);
+ VPValue *CI = Plan->getOrAddLiveIn(ConstantInt::get(U->getType(), C));
StrideVPV->replaceAllUsesWith(CI);
}
}
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/version-stride-with-integer-casts.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-width=4 -S %s"
],
"tests": [
{
"test_name": "zext_of_i1_stride",
"test_body": "target datalayout = \"p:8:8:8\"\n\n; Function Attrs: mustprogress\ndefine void @zext_of_i1_stride(i1 %g, ptr %dst) #0 {\nentry:\n %g.16 = zext i1 %g to i16\n %g.64 = zext i1 %g to i64\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep = getelementptr inbounds i16, ptr %dst, i64 %iv\n store i16 %g.16, ptr %gep, align 2\n %iv.next = add nuw nsw i64 %iv, %g.64\n %cmp = icmp ult i64 %iv.next, 16\n br i1 %cmp, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { mustprogress }\n",
"lli_expected_out": null,
"additional_args": "-src-unroll=32 -tgt-unroll=32"
}
]
}
] |
{
"title": "[LoopVectorize] Sign-extension miscompile",
"body": "C Testcase:\r\n```c\r\nlong a, d;\r\nshort b[20];\r\nshort c[20];\r\n_Bool e[20];\r\nint f(_Bool g) {\r\n for (long h = 0; h < 16; h += g)\r\n b[h] = (short) g;\r\n for (int i = 0; i < 12; i++)\r\n for (int j = d; j; j++)\r\n c[i] = (short) a < e[i];\r\n return (int) b[0];\r\n}\r\nint main() {\r\n __builtin_printf(\"%X\\n\", f(1));\r\n}\r\n```\r\nGodbolt: https://godbolt.org/z/3E8frs1Me\r\n\r\nWith loop-vectorize: `FFFFFFFF`\r\nWithout loop-vectorize: `1`\r\n\r\nReduced LLVM IR:\r\n```llvm ir\r\n; ModuleID = 'red.ll'\r\nsource_filename = \"red.c\"\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\n@b = global [20 x i16] zeroinitializer, align 2\r\n@.str = constant [4 x i8] c\"%X\\0A\\00\"\r\n\r\n; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) uwtable vscale_range(2,1024)\r\ndefine i32 @f(i1 %g) #0 {\r\nentry:\r\n %conv = zext i1 %g to i16\r\n %zext.g.i64 = zext i1 %g to i64\r\n br label %for.body\r\n\r\nfor.cond3.preheader: ; preds = %for.body\r\n %0 = load i64, ptr @b, align 2\r\n %zero = and i64 %0, 0\r\n %true = icmp eq i64 %zero, 0\r\n %2 = load i16, ptr @b, align 2\r\n %conv26 = sext i16 %2 to i32\r\n ret i32 %conv26\r\n\r\nfor.body: ; preds = %for.body, %entry\r\n %phi.0 = phi i64 [ 0, %entry ], [ %add, %for.body ]\r\n %idx.0 = getelementptr inbounds [20 x i16], ptr @b, i64 0, i64 %phi.0\r\n store i16 %conv, ptr %idx.0, align 2\r\n %add = add nuw nsw i64 %phi.0, %zext.g.i64\r\n %cmp = icmp ult i64 %add, 16\r\n br i1 %cmp, label %for.body, label %for.cond3.preheader, !llvm.loop !0\r\n}\r\n\r\n; Function Attrs: nofree nounwind uwtable vscale_range(2,1024)\r\ndefine noundef signext i32 @main() #1 {\r\nentry:\r\n %call = tail call signext i32 @f(i1 noundef zeroext true)\r\n %call1 = tail call signext i32 (ptr, ...) @printf(ptr noundef nonnull @.str, i32 noundef signext %call) #3\r\n ret i32 0\r\n}\r\n\r\n; Function Attrs: nofree nounwind\r\ndeclare noundef signext i32 @printf(ptr nocapture noundef readonly, ...) #2\r\n\r\nattributes #0 = { nofree norecurse nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) uwtable vscale_range(2,1024) \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"generic-rv64\" \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-e,-experimental-smmpm,-experimental-smnpm,-experimental-ssnpm,-experimental-sspm,-experimental-ssqosid,-experimental-supm,-experimental-zaamo,-experimental-zabha,-experimental-zalasr,-experimental-zalrsc,-experimental-zfbfmin,-experimental-zicfilp,-experimental-zicfiss,-experimental-ztso,-experimental-zvfbfmin,-experimental-zvfbfwma,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smepmp,-smstateen,-ssaia,-ssccptr,-sscofpmf,-sscounterenw,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-za128rs,-za64rs,-zacas,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-zmmul,-zvbb,-zvbc,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\nattributes #1 = { nofree nounwind uwtable vscale_range(2,1024) \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"generic-rv64\" \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-e,-experimental-smmpm,-experimental-smnpm,-experimental-ssnpm,-experimental-sspm,-experimental-ssqosid,-experimental-supm,-experimental-zaamo,-experimental-zabha,-experimental-zalasr,-experimental-zalrsc,-experimental-zfbfmin,-experimental-zicfilp,-experimental-zicfiss,-experimental-ztso,-experimental-zvfbfmin,-experimental-zvfbfwma,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smepmp,-smstateen,-ssaia,-ssccptr,-sscofpmf,-sscounterenw,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-za128rs,-za64rs,-zacas,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-zmmul,-zvbb,-zvbc,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\nattributes #2 = { nofree nounwind \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"generic-rv64\" \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-e,-experimental-smmpm,-experimental-smnpm,-experimental-ssnpm,-experimental-sspm,-experimental-ssqosid,-experimental-supm,-experimental-zaamo,-experimental-zabha,-experimental-zalasr,-experimental-zalrsc,-experimental-zfbfmin,-experimental-zicfilp,-experimental-zicfiss,-experimental-ztso,-experimental-zvfbfmin,-experimental-zvfbfwma,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smepmp,-smstateen,-ssaia,-ssccptr,-sscofpmf,-sscounterenw,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-za128rs,-za64rs,-zacas,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-zmmul,-zvbb,-zvbc,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\nattributes #3 = { nounwind }\r\n\r\n!0 = distinct !{!0, !1}\r\n!1 = !{!\"llvm.loop.mustprogress\"}\r\n```\r\nLoopVectorize pass.\r\n\r\nLooks like a sext/zext related issue.",
"author": "patrick-rivos",
"labels": [
"miscompilation",
"vectorizers"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
144279
|
https://github.com/llvm/llvm-project/issues/144279
|
crash
|
7e6c1bd3edf4fc19be70587a4ac33a76bab78c02
| 2025-06-15T21:04:55 |
[
"llvm/test/Transforms/InstSimplify/ConstProp"
] |
{
"fix_commit": "80b79ce432bbe12701fd9fe495ff9feeb5e4b9ca",
"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": [
[
432,
437
]
],
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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": [
"ReadDataFromGlobal"
],
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 80b79ce432bbe12701fd9fe495ff9feeb5e4b9ca
Author: Nikita Popov <npopov@redhat.com>
Date: Tue Jun 17 09:30:28 2025 +0200
[ConstantFolding] Handle reading from type padding (#144330)
ReadDataFromGlobal() did not handle reads from the padding of types (in
the sense of type store size != type alloc size, rather than struct
padding).
Return zero in that case.
Fixes https://github.com/llvm/llvm-project/issues/144279.
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 2b7a438a9ef0..b58f9b26a865 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -432,6 +432,10 @@ bool ReadDataFromGlobal(Constant *C, uint64_t ByteOffset, unsigned char *CurPtr,
assert(ByteOffset <= DL.getTypeAllocSize(C->getType()) &&
"Out of range access");
+ // Reading type padding, return zero.
+ if (ByteOffset >= DL.getTypeStoreSize(C->getType()))
+ return true;
+
// If this element is zero or undefined, we can just return since *CurPtr is
// zero initialized.
if (isa<ConstantAggregateZero>(C) || isa<UndefValue>(C))
|
[
{
"file": "llvm/test/Transforms/InstSimplify/ConstProp/loads.ll",
"commands": [
"opt < %s -passes=instsimplify -S"
],
"tests": [
{
"test_name": "<module>",
"test_body": "@i40_struct = constant { i40, i8 } { i40 0, i8 1 }\n@i40_array = constant [2 x i40] [i40 0, i40 1]\n\ndefine i8 @load_i40_struct_padding() {\n %v = load i8, ptr getelementptr (i8, ptr @i40_struct, i64 6)\n ret i8 %v\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[AggressiveInstCombine] assertion failure loading from non-power-of-two byte-sized zero field of global struct",
"body": "```llvm\n@0 = constant { i40, i1 } { i40 0, i1 1 }\ndefine void @f() {\n %1 = load i1, ptr @0\n ret void\n}\n```\n```\n$ opt --version\nLLVM (http://llvm.org/):\n LLVM version 20.1.7\n DEBUG build with assertions.\n Default target: x86_64-unknown-linux-gnu\n Host CPU: znver5\n$ opt -S -passes aggressive-instcombine reduced.ll\nopt: llvm/lib/Support/APInt.cpp:457: APInt llvm::APInt::extractBits(unsigned int, unsigned int) const: Assertion `bitPosition < BitWidth && (numBits + bitPosition) <= BitWidth && \"Illegal bit extraction\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0.\tProgram arguments: 20.x-Debug/bin/opt -passes aggressive-instcombine reduced.ll -S\n1.\tRunning pass \"function(aggressive-instcombine)\" on module \"reduced.ll\"\n2.\tRunning pass \"aggressive-instcombine\" on function \"f\"\n #0 0x00007f6af9311bc6 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) llvm/lib/Support/Unix/Signals.inc:799:11\n #1 0x00007f6af931212f PrintStackTraceSignalHandler(void*) llvm/lib/Support/Unix/Signals.inc:875:1\n #2 0x00007f6af93101a0 llvm::sys::RunSignalHandlers() llvm/lib/Support/Signals.cpp:105:5\n #3 0x00007f6af931275e SignalHandler(int) llvm/lib/Support/Unix/Signals.inc:415:1\n #4 0x00007f6af8b56750 (/usr/lib64/libc.so.6+0x3d750)\n #5 0x00007f6af8bafa9c (/usr/lib64/libc.so.6+0x96a9c)\n #6 0x00007f6af8b56616 raise (/usr/lib64/libc.so.6+0x3d616)\n #7 0x00007f6af8b3e28d abort (/usr/lib64/libc.so.6+0x2528d)\n #8 0x00007f6af8b3e1f5 __assert_perror_fail (/usr/lib64/libc.so.6+0x251f5)\n #9 0x00007f6af91021db llvm::APInt::extractBits(unsigned int, unsigned int) const llvm/lib/Support/APInt.cpp:0:3\n#10 0x00007f6afaa4c319 (anonymous namespace)::ReadDataFromGlobal(llvm::Constant*, unsigned long, unsigned char*, unsigned int, llvm::DataLayout const&) llvm/lib/Analysis/ConstantFolding.cpp:445:45\n#11 0x00007f6afaa4c68b (anonymous namespace)::ReadDataFromGlobal(llvm::Constant*, unsigned long, unsigned char*, unsigned int, llvm::DataLayout const&) llvm/lib/Analysis/ConstantFolding.cpp:478:32\n#12 0x00007f6afaa4d3ee (anonymous namespace)::FoldReinterpretLoadFromConst(llvm::Constant*, llvm::Type*, long, llvm::DataLayout const&) llvm/lib/Analysis/ConstantFolding.cpp:622:7\n#13 0x00007f6afaa4cf72 llvm::ConstantFoldLoadFromConst(llvm::Constant*, llvm::Type*, llvm::APInt const&, llvm::DataLayout const&) llvm/lib/Analysis/ConstantFolding.cpp:723:19\n#14 0x00007f6afc550eb3 foldPatternedLoads(llvm::Instruction&, llvm::DataLayout const&) llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp:910:15\n#15 0x00007f6afc54dca8 foldUnusualPatterns(llvm::Function&, llvm::DominatorTree&, llvm::TargetTransformInfo&, llvm::TargetLibraryInfo&, llvm::AAResults&, llvm::AssumptionCache&, bool&) llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp:1253:21\n#16 0x00007f6afc54d9bd runImpl(llvm::Function&, llvm::AssumptionCache&, llvm::TargetTransformInfo&, llvm::TargetLibraryInfo&, llvm::DominatorTree&, llvm::AAResults&, bool&) llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp:1278:17\n#17 0x00007f6afc54d855 llvm::AggressiveInstCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp:1290:7\n#18 0x00007f6aff99a1d8 llvm::detail::PassModel<llvm::Function, llvm::AggressiveInstCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) llvm/include/llvm/IR/PassManagerInternal.h:91:17\n#19 0x00007f6af9de0ed2 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) llvm/include/llvm/IR/PassManagerImpl.h:85:5\n#20 0x00007f6b06c0be58 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) llvm/include/llvm/IR/PassManagerInternal.h:91:17\n#21 0x00007f6af9ddf7f5 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) llvm/lib/IR/PassManager.cpp:124:38\n#22 0x00007f6b06c2d648 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) llvm/include/llvm/IR/PassManagerInternal.h:91:17\n#23 0x00007f6af9ddfdf2 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) llvm/include/llvm/IR/PassManagerImpl.h:85:5\n#24 0x00007f6b088241ce 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) llvm/tools/opt/NewPMDriver.cpp:541:3\n#25 0x00007f6b08861f85 optMain llvm/tools/opt/optdriver.cpp:739:12\n#26 0x00005575215c34a9 main llvm/tools/opt/opt.cpp:25:42\n#27 0x00007f6af8b403fb (/usr/lib64/libc.so.6+0x273fb)\n#28 0x00007f6af8b404ab __libc_start_main (/usr/lib64/libc.so.6+0x274ab)\n#29 0x00005575215c33b5 _start (20.x-Debug/bin/opt+0x23b5)\n```\nAlso repros at 087a6ac420ad99c523b9dd517351e0c6d1f1a980.",
"author": "jacobly0",
"labels": [
"crash",
"llvm:analysis"
],
"comments": [
{
"author": "nikic",
"body": "To make it clearer what the core problem is:\n```\n; RUN: opt -S -passes=instsimplify\n@g = constant { i40, i8 } { i40 0, i8 1 }\ndefine i8 @f() {\n %v = load i8, ptr getelementptr (i8, ptr @g, i64 6)\n ret i8 %v\n}\n```\nThis is accessing the padding between the store size and the alloc size of `i40`, which ReadDataFromGlobal does not correctly handle."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
102597
|
https://github.com/llvm/llvm-project/issues/102597
|
miscompilation
|
513c3726ebc0a324f7e5a11d25617bb9557324d6
| 2024-08-09T11:02:59 |
[
"llvm/test/Transforms/IndVarSimplify"
] |
{
"fix_commit": "3512bcc2e9ab06b0ae2cab78744550b515e54184",
"components": [
"ScalarEvolution"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
11961,
11969
]
],
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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::computeConstantDifference"
],
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 3512bcc2e9ab06b0ae2cab78744550b515e54184
Author: Nikita Popov <npopov@redhat.com>
Date: Mon Aug 12 15:18:32 2024 +0200
[SCEV] Fix incorrect extension in computeConstantDifference()
The Mul factor was zero-extended here, resulting in incorrect
results for integers larger than 64-bit.
As we currently only multiply by 1 or -1, just split this into
two cases -- there's no need for a full multiplication here.
Fixes https://github.com/llvm/llvm-project/issues/102597.
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 9ecdcbe2c5de..318a9d773dc2 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -11961,9 +11961,14 @@ ScalarEvolution::computeConstantDifference(const SCEV *More, const SCEV *Less) {
SmallDenseMap<const SCEV *, int, 8> Multiplicity;
APInt Diff(BW, 0);
auto Add = [&](const SCEV *S, int Mul) {
- if (auto *C = dyn_cast<SCEVConstant>(S))
- Diff += C->getAPInt() * Mul;
- else
+ if (auto *C = dyn_cast<SCEVConstant>(S)) {
+ if (Mul == 1) {
+ Diff += C->getAPInt();
+ } else {
+ assert(Mul == -1);
+ Diff -= C->getAPInt();
+ }
+ } else
Multiplicity[S] += Mul;
};
auto Decompose = [&](const SCEV *S, int Mul) {
|
[
{
"file": "llvm/test/Transforms/IndVarSimplify/pr102597.ll",
"commands": [
"opt -S -passes=indvars < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define void @test() {\nentry:\n br label %loop\n\nloop: ; preds = %loop.latch, %entry\n %iv = phi i128 [ 3, %entry ], [ %iv.dec, %loop.latch ]\n %tobool = icmp ne i128 %iv, 0\n br i1 %tobool, label %loop.latch, label %if\n\nif: ; preds = %loop\n call void @foo()\n br label %loop.latch\n\nloop.latch: ; preds = %if, %loop\n %iv.dec = add nsw i128 %iv, -1\n %cmp = icmp sgt i128 %iv, 0\n br i1 %cmp, label %loop, label %exit\n\nexit: ; preds = %loop.latch\n ret void\n}\n\ndeclare void @foo()\n",
"lli_expected_out": null,
"additional_args": "-src-unroll=4 -tgt-unroll=4"
}
]
}
] |
{
"title": "[SCEV] WRONG code ",
"body": "```\r\nint printf(const char *, ...);\r\n__int128 a = 3, c;\r\nchar b;\r\nint main() {\r\n c = 3;\r\n for (; c >= 0; c--) {\r\n b = 0;\r\n for (; b <= 3; b++) {\r\n if (c)\r\n break;\r\n a = 0;\r\n }\r\n }\r\n printf(\"%d\\n\", (int)a);\r\n}\r\n\r\n```\r\n\r\nclang -march=z15 -O1 wrong0.i -o a.out\r\n\r\nThis program should print '0' as 'a' is set to zero inside the loop. It now prints '3' instead. A bisect leads to a recent commit: 79af689 \" [SCEV] Handle more adds in computeConstantDifference() (#101339)\".\r\n\r\nSeems like IndVarSimplify has gone wrong with an i128:\r\nGOOD <> BROKEN\r\n```\r\n; *** IR Dump After IndVarSimplifyPass on loo ; *** IR Dump After IndVarSimplifyPass on loo\r\n\r\n; Preheader: ; Preheader:\r\nentry: entry:\r\n br label %for.cond1.preheader br label %for.cond1.preheader\r\n\r\n; Loop: ; Loop:\r\nfor.cond1.preheader: for.cond1.preheader: \r\n %storemerge11 = phi i128 [ 3, %entry ], [ % %storemerge11 = phi i128 [ 3, %entry ], [ %\r\n %tobool = icmp ne i128 %storemerge11, 0 | br i1 true, label %for.inc5, label %if.end.\r\n br i1 %tobool, label %for.inc5, label %if.e <\r\n\r\nif.end.lr.ph: if.end.lr.ph: \r\n store i128 0, ptr @a, align 8, !tbaa !4 store i128 0, ptr @a, align 8, !tbaa !4\r\n br label %if.end br label %if.end\r\n\r\nif.end: if.end: \r\n %storemerge89 = phi i8 [ 0, %if.end.lr.ph ] %storemerge89 = phi i8 [ 0, %if.end.lr.ph ]\r\n %inc = add nuw nsw i8 %storemerge89, 1 %inc = add nuw nsw i8 %storemerge89, 1\r\n %cmp2 = icmp ugt i8 %storemerge89, 2 %cmp2 = icmp ugt i8 %storemerge89, 2\r\n %or.cond = or i1 %tobool, %cmp2 | %or.cond = or i1 true, %cmp2\r\n br i1 %or.cond, label %for.inc5.loopexit, l br i1 %or.cond, label %for.inc5.loopexit, l\r\n\r\nfor.inc5: for.inc5: \r\n %storemerge8.lcssa = phi i8 [ 0, %for.cond1 %storemerge8.lcssa = phi i8 [ 0, %for.cond1\r\n %dec = add nsw i128 %storemerge11, -1 %dec = add nsw i128 %storemerge11, -1\r\n %cmp = icmp ugt i128 %storemerge11, 0 %cmp = icmp ugt i128 %storemerge11, 0\r\n br i1 %cmp, label %for.cond1.preheader, lab br i1 %cmp, label %for.cond1.preheader, lab\r\n\r\nfor.inc5.loopexit: for.inc5.loopexit: \r\n %inc.lcssa = phi i8 [ %inc, %if.end ] %inc.lcssa = phi i8 [ %inc, %if.end ]\r\n br label %for.inc5 br label %for.inc5\r\n\r\n; Exit blocks ; Exit blocks\r\nfor.end6: for.end6: \r\n %storemerge8.lcssa.lcssa = phi i8 [ %storem %storemerge8.lcssa.lcssa = phi i8 [ %storem\r\n store i128 -1, ptr @c, align 8, !tbaa !4 store i128 -1, ptr @c, align 8, !tbaa !4\r\n store i8 %storemerge8.lcssa.lcssa, ptr @b, store i8 %storemerge8.lcssa.lcssa, ptr @b, \r\n %0 = load i128, ptr @a, align 8, !tbaa !4 %0 = load i128, ptr @a, align 8, !tbaa !4\r\n %conv7 = trunc i128 %0 to i32 %conv7 = trunc i128 %0 to i32\r\n %call = call signext i32 (ptr, ...) @printf %call = call signext i32 (ptr, ...) @printf\r\n ret i32 0 ret i32 0\r\n\r\n```",
"author": "JonPsson1",
"labels": [
"miscompilation",
"llvm:SCEV"
],
"comments": [
{
"author": "nikic",
"body": "Classic mistake: https://github.com/llvm/llvm-project/blob/2f8f58dd17a11934e8c8ec212b6474f76fb18e61/llvm/lib/Analysis/ScalarEvolution.cpp#L11967 This `* Mul` doesn't do what I wanted it to do :)\r\n\r\nI should really pick up https://github.com/llvm/llvm-project/pull/80309 again to prevent this kind of mistake in the first place."
},
{
"author": "JonPsson1",
"body": "Is this commit self-contained in the sense that I could revert it on my testing machines? Or will you revert / fix soon?"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
91078
|
https://github.com/llvm/llvm-project/issues/91078
|
crash
|
d5ca2e46ca97758de6edb9f071f2114205380d87
| 2024-05-04T18:39:13 |
[
"llvm/test/Transforms/VectorCombine"
] |
{
"fix_commit": "d145f40963f15e94c4aefcc406a365fbe779e934",
"components": [
"VectorCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
1755,
1764
]
],
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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::foldShuffleToIdentity"
],
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 d145f40963f15e94c4aefcc406a365fbe779e934
Author: David Green <david.green@arm.com>
Date: Sun May 5 10:47:11 2024 +0100
[VectorCombine] shuffleToIdentity - guard against call instructions.
The shuffleToIdentity fold needs to be a bit more careful about the difference
between call instructions and intrinsics. The second can be handled, but the
first should result in bailing out. This patch also adds some extra intrinsic
tests from #91000.
Fixes #91078
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index 04d2ff594bf5..bbb70134870a 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -1755,10 +1755,13 @@ bool VectorCombine::foldShuffleToIdentity(Instruction &I) {
return false;
if (IL.first->getValueID() != Item[0].first->getValueID())
return false;
+ if (isa<CallInst>(IL.first) && !isa<IntrinsicInst>(IL.first))
+ return false;
auto *II = dyn_cast<IntrinsicInst>(IL.first);
return !II ||
- II->getIntrinsicID() ==
- cast<IntrinsicInst>(Item[0].first)->getIntrinsicID();
+ (isa<IntrinsicInst>(Item[0].first) &&
+ II->getIntrinsicID() ==
+ cast<IntrinsicInst>(Item[0].first)->getIntrinsicID());
}))
return false;
|
[
{
"file": "llvm/test/Transforms/VectorCombine/AArch64/shuffletoidentity.ll",
"commands": [
"opt -passes=vector-combine -S %s"
],
"tests": [
{
"test_name": "callinst",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x half> @callinst(<8 x half> %a) {\n %ab = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = call <4 x half> @othercall(<4 x half> %at)\n %abb = call <4 x half> @llvm.fabs.v4f16(<4 x half> %ab)\n %r = shufflevector <4 x half> %abt, <4 x half> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x half> %r\n}\n\ndeclare <4 x half> @othercall(<4 x half>)\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x half> @llvm.fabs.v4f16(<4 x half>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "callinst2",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x half> @callinst2(<8 x half> %a) {\n %ab = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = call <4 x half> @llvm.fabs.v4f16(<4 x half> %at)\n %abb = call <4 x half> @othercall(<4 x half> %ab)\n %r = shufflevector <4 x half> %abt, <4 x half> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x half> %r\n}\n\ndeclare <4 x half> @othercall(<4 x half>)\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x half> @llvm.fabs.v4f16(<4 x half>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "lrint",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i32> @lrint(<8 x half> %a) {\n %ab = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = call <4 x i32> @llvm.lrint.v4i32.v4f16(<4 x half> %at)\n %abb = call <4 x i32> @llvm.lrint.v4i32.v4f16(<4 x half> %ab)\n %r = shufflevector <4 x i32> %abt, <4 x i32> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i32> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x i32> @llvm.lrint.v4i32.v4f16(<4 x half>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "abs_different",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i8> @abs_different(<8 x i8> %a) {\n %ab = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = call <4 x i8> @llvm.abs.v4i8(<4 x i8> %at, i1 true)\n %abb = call <4 x i8> @llvm.abs.v4i8(<4 x i8> %ab, i1 false)\n %r = shufflevector <4 x i8> %abt, <4 x i8> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i8> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x i8> @llvm.abs.v4i8(<4 x i8>, i1 immarg) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "powi",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x half> @powi(<8 x half> %a) {\n %ab = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = call <4 x half> @llvm.powi.v4f16.i32(<4 x half> %at, i32 10)\n %abb = call <4 x half> @llvm.powi.v4f16.i32(<4 x half> %ab, i32 10)\n %r = shufflevector <4 x half> %abt, <4 x half> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x half> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x half> @llvm.powi.v4f16.i32(<4 x half>, i32) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "abs",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i8> @abs(<8 x i8> %a) {\n %ab = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = call <4 x i8> @llvm.abs.v4i8(<4 x i8> %at, i1 false)\n %abb = call <4 x i8> @llvm.abs.v4i8(<4 x i8> %ab, i1 false)\n %r = shufflevector <4 x i8> %abt, <4 x i8> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i8> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x i8> @llvm.abs.v4i8(<4 x i8>, i1 immarg) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "A/F: isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\" after commit a4d1026",
"body": "A few of our internal tests started hitting an assertion failure which I bisected back to commit a4d10266d20bfe5930dfed77e17832af341ed66e. \r\n\r\nConsider the following code:\r\n```c++\r\ntemplate <typename a> a b(a);\r\ntypedef float c __attribute__((__vector_size__(32)));\r\ntypedef float __attribute__((ext_vector_type(8))) d;\r\ntypedef float __attribute__((ext_vector_type(4))) e;\r\nc f;\r\n#define g(h) (b(h))\r\nd i;\r\nvoid j() {\r\n c k = __builtin_ia32_rsqrtps256(f);\r\n d l(k);\r\n d m g(i);\r\n volatile e n = __builtin_shufflevector(l, m, 15, 2, 0, 1);\r\n}\r\n```\r\nWhen compiled with optimizations and `-mavx` it hits an assertion failure:\r\n```\r\n$ ~/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang -c -O2 -mavx repro2.cpp \r\nclang: /home/dyung/src/upstream/llvm_clean_git/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From*) [with To = llvm::IntrinsicInst; From = llvm::Value]: Assertion `isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"' failed. \r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0. Program arguments: /home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang -c -O2 -mavx repro2.cpp\r\n1. <eof> parser at end of file\r\n2. Optimizer\r\n #0 0x0000557d533cfe2f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x4055e2f)\r\n #1 0x0000557d533cd96c llvm::sys::CleanupOnSignal(unsigned long) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x405396c)\r\n #2 0x0000557d5331a4e8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0\r\n #3 0x00007f0ccbb8b420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #4 0x00007f0ccb65800b raise /build/glibc-e2p3jK/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #5 0x00007f0ccb637859 abort /build/glibc-e2p3jK/glibc-2.31/stdlib/abort.c:81:7\r\n #6 0x00007f0ccb637729 get_sysdep_segment_value /build/glibc-e2p3jK/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #7 0x00007f0ccb637729 _nl_load_domain /build/glibc-e2p3jK/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #8 0x00007f0ccb648fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #9 0x0000557d54cd0f88 (anonymous namespace)::VectorCombine::foldShuffleToIdentity(llvm::Instruction&)::'lambda3'(std::pair<llvm::Value*, int>)::operator()(std::pair<llvm::Value*, int>) const (.isra.0) VectorCombine.cpp:0:0\r\n#10 0x0000557d54cdac11 (anonymous namespace)::VectorCombine::foldShuffleToIdentity(llvm::Instruction&) VectorCombine.cpp:0:0\r\n#11 0x0000557d54ce56f1 (anonymous namespace)::VectorCombine::run()::'lambda'(llvm::Instruction&)::operator()(llvm::Instruction&) const (.isra.0) VectorCombine.cpp:0:0\r\n#12 0x0000557d54ce695d llvm::VectorCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x596c95d)\r\n#13 0x0000557d547ca386 llvm::detail::PassModel<llvm::Function, llvm::VectorCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x5450386)\r\n#14 0x0000557d50a03b4c llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x1689b4c)\r\n#15 0x0000557d52d96d0d llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x3a1cd0d)\r\n#16 0x0000557d509e66d6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x166c6d6)\r\n#17 0x0000557d52d94b9d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x3a1ab9d)\r\n#18 0x0000557d5366aa28 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#19 0x0000557d5366dd85 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#20 0x0000557d5366e449 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x42f4449)\r\n#21 0x0000557d53cc97ca clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x494f7ca)\r\n#22 0x0000557d55a3f65c clang::ParseAST(clang::Sema&, bool, bool) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x66c565c)\r\n#23 0x0000557d53cc8278 clang::CodeGenAction::ExecuteAction() (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x494e278)\r\n#24 0x0000557d53f56729 clang::FrontendAction::Execute() (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x4bdc729)\r\n#25 0x0000557d53edc48e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x4b6248e)\r\n#26 0x0000557d54040e86 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x4cc6e86)\r\n#27 0x0000557d505e1bbc cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x1267bbc)\r\n#28 0x0000557d505dacca ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#29 0x0000557d53d0d8ed void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0\r\n#30 0x0000557d5331a9f0 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x3fa09f0)\r\n#31 0x0000557d53d0df0f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0\r\n#32 0x0000557d53cd2a4c clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x4958a4c)\r\n#33 0x0000557d53cd34dd clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x49594dd)\r\n#34 0x0000557d53cdb8f5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x49618f5)\r\n#35 0x0000557d505defab clang_main(int, char**, llvm::ToolContext const&) (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x1264fab)\r\n#36 0x0000557d504db96b main (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x116196b)\r\n#37 0x00007f0ccb639083 __libc_start_main /build/glibc-e2p3jK/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#38 0x0000557d505da79e _start (/home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin/clang+0x126079e)\r\nclang: error: clang frontend command failed with exit code 134 (use -v to see invocation)\r\nclang version 19.0.0 (https://github.com/llvm/llvm-project.git a4d10266d20bfe5930dfed77e17832af341ed66e)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /home/dyung/src/upstream/a4d10266d20bfe5930dfed77e17832af341ed66e-linux/bin\r\nBuild config: +assertions\r\n```",
"author": "dyung",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
114082
|
https://github.com/llvm/llvm-project/issues/114082
|
crash
|
0f040433d325aa68ec6840aa179f3f314c26153a
| 2024-10-29T16:26:31 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "77bec78878762e34150fe23734fa43df796c873c",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
13398,
13404
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
"BoUpSLP::getLastInstructionInBundle"
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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 77bec78878762e34150fe23734fa43df796c873c
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Fri Nov 8 04:16:01 2024 -0800
[SLP]Do not look for last instruction in schedule block for buildvectors
If looking for the insertion point for the node and the node is
a buildvector node, the compiler should not use scheduling info for such
nodes, they may contain only partial info, which is not fully correct
and may cause compiler crash.
Fixes #114082
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index b2f677fb84f9..c5b3537bc57b 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -13398,7 +13398,7 @@ Instruction &BoUpSLP::getLastInstructionInBundle(const TreeEntry *E) {
// scheduled, and the last instruction is VL.back(). So we start with
// VL.back() and iterate over schedule data until we reach the end of the
// bundle. The end of the bundle is marked by null ScheduleData.
- if (BlocksSchedules.count(BB)) {
+ if (BlocksSchedules.count(BB) && !E->isGather()) {
Value *V = E->isOneOf(E->Scalars.back());
if (doesNotNeedToBeScheduled(V))
V = *find_if_not(E->Scalars, doesNotNeedToBeScheduled);
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/buildvector-schedule-for-subvector.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-99999 < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define void @test() {\nbb:\n %icmp = icmp samesign ult i32 0, 0\n %select = select i1 %icmp, i32 0, i32 0\n %zext = zext i32 %select to i64\n %getelementptr = getelementptr ptr addrspace(1), ptr addrspace(1) null, i64 %zext\n store ptr addrspace(1) null, ptr addrspace(1) %getelementptr, align 8\n %icmp1 = icmp eq i32 0, 0\n %icmp2 = icmp eq i32 0, 0\n %icmp3 = icmp samesign ult i32 0, 0\n %icmp4 = icmp eq i32 0, 0\n %add = add i32 1, 0\n %icmp5 = icmp samesign ult i32 %add, 0\n store volatile i32 0, ptr addrspace(1) null, align 4\n %call = call i32 null(<2 x double> zeroinitializer)\n %icmp6 = icmp eq i32 %call, 0\n %icmp7 = icmp samesign ult i32 0, 0\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 opt with the test below with -passes=slp-vectorizer -slp-threshold=-99999\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 %icmp = icmp samesign ult i32 0, 0\r\n %select = select i1 %icmp, i32 0, i32 0\r\n %zext = zext i32 %select to i64\r\n %getelementptr = getelementptr ptr addrspace(1), ptr addrspace(1) null, i64 %zext\r\n store ptr addrspace(1) null, ptr addrspace(1) %getelementptr, align 8\r\n %icmp1 = icmp eq i32 0, 0\r\n %icmp2 = icmp eq i32 0, 0\r\n %icmp3 = icmp samesign ult i32 0, 0\r\n %icmp4 = icmp eq i32 0, 0\r\n %add = add i32 1, 0\r\n %icmp5 = icmp samesign ult i32 %add, 0\r\n store volatile i32 0, ptr addrspace(1) null, align 4\r\n %call = call i32 @llvm.x86.sse2.cvttsd2si(<2 x double> zeroinitializer)\r\n %icmp6 = icmp eq i32 %call, 0\r\n %icmp7 = icmp samesign ult i32 0, 0\r\n ret void\r\n}\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)\r\ndeclare i32 @llvm.x86.sse2.cvttsd2si(<2 x double>) #1\r\n\r\nattributes #0 = { \"target-features\"=\"+prfchw,-cldemote,+avx,+aes,+sahf,+pclmul,-xop,+crc32,+xsaves,-avx512fp16,-usermsr,-sm4,-egpr,+sse4.1,-avx512ifma,+xsave,+sse4.2,-tsxldtrk,-sm3,-ptwrite,-widekl,+invpcid,+64bit,+xsavec,-avx10.1-512,-avx512vpopcntdq,+cmov,-avx512vp2intersect,+avx512cd,+movbe,-avxvnniint8,-ccmp,-amx-int8,-kl,-avx10.1-256,+evex512,-avxvnni,+rtm,+adx,+avx2,-hreset,-movdiri,-serialize,-sha512,-vpclmulqdq,+avx512vl,-uintr,-cf,+clflushopt,-raoint,-cmpccxadd,+bmi,-amx-tile,+sse,-avx10.2-256,-gfni,-avxvnniint16,-amx-fp16,-zu,-ndd,+xsaveopt,+rdrnd,+avx512f,-amx-bf16,-avx512bf16,-avx512vnni,-push2pop2,+cx8,+avx512bw,+sse3,+pku,-nf,+fsgsbase,-clzero,-mwaitx,-lwp,+lzcnt,-sha,-movdir64b,-ppx,-wbnoinvd,-enqcmd,-avx10.2-512,-avxneconvert,-tbm,-pconfig,-amx-complex,+ssse3,+cx16,+bmi2,+fma,+popcnt,-avxifma,+f16c,-avx512bitalg,-rdpru,+clwb,+mmx,+sse2,+rdseed,-avx512vbmi2,-prefetchi,-rdpid,-fma4,-avx512vbmi,-shstk,-vaes,-waitpkg,-sgx,+fxsr,+avx512dq,-sse4a,-avx512f\" }\r\nattributes #1 = { nocallback nofree nosync nounwind willreturn memory(none) \"target-features\"=\"+prfchw,-cldemote,+avx,+aes,+sahf,+pclmul,-xop,+crc32,+xsaves,-avx512fp16,-usermsr,-sm4,-egpr,+sse4.1,-avx512ifma,+xsave,+sse4.2,-tsxldtrk,-sm3,-ptwrite,-widekl,+invpcid,+64bit,+xsavec,-avx10.1-512,-avx512vpopcntdq,+cmov,-avx512vp2intersect,+avx512cd,+movbe,-avxvnniint8,-ccmp,-amx-int8,-kl,-avx10.1-256,+evex512,-avxvnni,+rtm,+adx,+avx2,-hreset,-movdiri,-serialize,-sha512,-vpclmulqdq,+avx512vl,-uintr,-cf,+clflushopt,-raoint,-cmpccxadd,+bmi,-amx-tile,+sse,-avx10.2-256,-gfni,-avxvnniint16,-amx-fp16,-zu,-ndd,+xsaveopt,+rdrnd,+avx512f,-amx-bf16,-avx512bf16,-avx512vnni,-push2pop2,+cx8,+avx512bw,+sse3,+pku,-nf,+fsgsbase,-clzero,-mwaitx,-lwp,+lzcnt,-sha,-movdir64b,-ppx,-wbnoinvd,-enqcmd,-avx10.2-512,-avxneconvert,-tbm,-pconfig,-amx-complex,+ssse3,+cx16,+bmi2,+fma,+popcnt,-avxifma,+f16c,-avx512bitalg,-rdpru,+clwb,+mmx,+sse2,+rdseed,-avx512vbmi2,-prefetchi,-rdpid,-fma4,-avx512vbmi,-shstk,-vaes,-waitpkg,-sgx,+fxsr,+avx512dq,-sse4a,-avx512f\" }\r\n```\r\nReproducer: https://godbolt.org/z/nTE84xq7n\r\n\r\nStack dump\r\n```\r\nInstruction does not dominate all uses!\r\n %5 = icmp eq <4 x i32> %4, zeroinitializer\r\n %2 = call <8 x i1> @llvm.vector.insert.v8i1.v4i1(<8 x i1> poison, <4 x i1> %5, i64 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 0x00000000050e7a98 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x50e7a98)\r\n #1 0x00000000050e548c SignalHandler(int) Signals.cpp:0:0\r\n #2 0x000078c8a0042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x000078c8a00969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x000078c8a0042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x000078c8a00287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00000000007d7d7b llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0\r\n #7 0x00000000050265b8 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x50265b8)\r\n #8 0x0000000004f24790 llvm::VerifierPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f24790)\r\n #9 0x00000000009015ce 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+0x9015ce)\r\n#10 0x0000000004ee5440 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4ee5440)\r\n#11 0x000000000090c1ea 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+0x90c1ea)\r\n#12 0x00000000008ff258 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8ff258)\r\n#13 0x000078c8a0029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#14 0x000078c8a0029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#15 0x00000000008f6d2e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8f6d2e)\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 |
112356
|
https://github.com/llvm/llvm-project/issues/112356
|
miscompilation
|
a3a9ba80337ec1b276a7571049eda6ea03276ea3
| 2024-10-15T13:21:27 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "9b7491e8669126180253480821d5addde34874d0",
"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": [
[
50,
55
]
],
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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": [
"Operator::hasPoisonGeneratingFlags"
],
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 9b7491e8669126180253480821d5addde34874d0
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Tue Oct 15 23:07:16 2024 +0800
[IR] Add support for `samesign` in `Operator::hasPoisonGeneratingFlags` (#112358)
Fix https://github.com/llvm/llvm-project/issues/112356.
diff --git a/llvm/lib/IR/Operator.cpp b/llvm/lib/IR/Operator.cpp
index f93ff8f6fc8a..199eb4d90f55 100644
--- a/llvm/lib/IR/Operator.cpp
+++ b/llvm/lib/IR/Operator.cpp
@@ -50,6 +50,8 @@ bool Operator::hasPoisonGeneratingFlags() const {
if (auto *NNI = dyn_cast<PossiblyNonNegInst>(this))
return NNI->hasNonNeg();
return false;
+ case Instruction::ICmp:
+ return cast<ICmpInst>(this)->hasSameSign();
default:
if (const auto *FP = dyn_cast<FPMathOperator>(this))
return FP->hasNoNaNs() || FP->hasNoInfs();
|
[
{
"file": "llvm/test/Transforms/InstCombine/icmp.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "icmp_samesign_logical_or",
"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_samesign_logical_or(i32 %In) {\n %c1 = icmp samesign slt i32 %In, 0\n %c2 = icmp samesign ne i32 %In, 1\n %V = select i1 %c1, i1 true, i1 %c2\n ret i1 %V\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "icmp_and_inv_pow2_or_zero_ne_0",
"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\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #0\n\ndefine i1 @icmp_and_inv_pow2_or_zero_ne_0(i32 %A, i32 %B) {\n %popcnt = tail call i32 @llvm.ctpop.i32(i32 %A)\n %cond = icmp ult i32 %popcnt, 2\n call void @llvm.assume(i1 %cond)\n %inv = xor i32 %B, -1\n %and = and i32 %A, %inv\n %cmp = icmp ne i32 %and, 0\n ret i1 %cmp\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #1\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\nattributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "icmp_samesign_logical_and",
"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_samesign_logical_and(i32 %In) {\n %c1 = icmp samesign sgt i32 %In, -1\n %c2 = icmp samesign eq i32 %In, 1\n %V = select i1 %c1, i1 %c2, i1 false\n ret i1 %V\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstCombine] `samesign` flag should be dropped",
"body": "Reproducer:\r\n```\r\ndefine i1 @src(i32 %In) {\r\n %c1 = icmp samesign sgt i32 %In, -1\r\n %c2 = icmp samesign eq i32 %In, 1\r\n %V = select i1 %c1, i1 %c2, i1 false\r\n ret i1 %V\r\n}\r\n\r\ndefine i1 @tgt(i32 %In) {\r\n %c2 = icmp samesign eq i32 %In, 1\r\n ret i1 %c2\r\n}\r\n```\r\n\r\nWe should check this flag in `Operator::hasPoisonGeneratingFlags`.\r\n",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:ir"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
116852
|
https://github.com/llvm/llvm-project/issues/116852
|
crash
|
d8a1c6d72739c99f4b52a84e907b96b685b44c5e
| 2024-11-19T18:03:10 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "79682c4d57620e623fb30271cc8003d0c9e14a01",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
13614,
13620
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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::gather"
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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 79682c4d57620e623fb30271cc8003d0c9e14a01
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Tue Nov 19 11:03:11 2024 -0800
[SLP]Check if the buildvector root is not a part of the graph before deletion
If the buildvector root has no uses, it might be still needed as a part
of the graph, so need to check that it is not a part of the graph before
deletion.
Fixes #116852
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index dc0dffd9fcbf..e70627b6afc1 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -13614,7 +13614,10 @@ Value *BoUpSLP::gather(
} else {
Vec = CreateShuffle(Root, Vec, Mask);
if (auto *OI = dyn_cast<Instruction>(OriginalRoot);
- OI && OI->hasNUses(0))
+ OI && OI->hasNUses(0) &&
+ none_of(VectorizableTree, [&](const std::unique_ptr<TreeEntry> &TE) {
+ return TE->VectorizedValue == OI;
+ }))
eraseInstruction(OI);
}
}
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/bv-root-part-of-graph.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @test() {\n;\nbb:\n br label %bb1\n\nbb1:\n %phi = phi i32 [ 0, %bb ], [ %or21, %bb1 ]\n %sitofp = sitofp i32 0 to float\n %fadd = fadd float %sitofp, %sitofp\n %fadd2 = fadd float %fadd, 0.000000e+00\n %fcmp = fcmp ogt float %fadd2, 0.000000e+00\n %select = select i1 %fcmp, i32 0, i32 0\n %select3 = select i1 false, i32 %select, i32 0\n %fadd4 = fadd float %sitofp, 0.000000e+00\n %fadd5 = fadd float %fadd4, 0.000000e+00\n %fcmp6 = fcmp ogt float %fadd5, 0.000000e+00\n %select7 = select i1 %fcmp6, i32 0, i32 0\n %select8 = select i1 false, i32 %select7, i32 0\n %or = or i32 %select3, %select8\n %sitofp9 = sitofp i32 0 to float\n %fmul = fmul float 0.000000e+00, 0.000000e+00\n %fadd10 = fadd float %sitofp9, %fmul\n %fadd11 = fadd float %fadd10, 0.000000e+00\n %fcmp12 = fcmp ogt float %fadd11, 0.000000e+00\n %select13 = select i1 %fcmp12, i32 0, i32 0\n %select14 = select i1 false, i32 %select13, i32 0\n %or15 = or i32 %select14, %or\n %fadd16 = fadd float %fmul, 0.000000e+00\n %fadd17 = fadd float %fadd16, 0.000000e+00\n %fcmp18 = fcmp ogt float %fadd17, 0.000000e+00\n %select19 = select i1 %fcmp18, i32 0, i32 0\n %select20 = select i1 false, i32 %select19, i32 0\n %or21 = or i32 %or15, %select20\n br label %bb1\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Assertion `I->use_empty() && \"trying to erase instruction with users.\"' failed.",
"body": "To reproduce run the test below with -passes=slp-vectorizer\r\n```\r\n; ModuleID = './reduced.ll'\r\nsource_filename = \"./reduced.ll\"\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine void @wombat() gc \"statepoint-example\" {\r\nbb:\r\n br label %bb1\r\n\r\nbb1: ; preds = %bb1, %bb\r\n %phi = phi i32 [ 0, %bb ], [ %or21, %bb1 ]\r\n %sitofp = sitofp i32 0 to float\r\n %fadd = fadd float %sitofp, %sitofp\r\n %fadd2 = fadd float %fadd, 0.000000e+00\r\n %fcmp = fcmp ogt float %fadd2, 0.000000e+00\r\n %select = select i1 %fcmp, i32 0, i32 0\r\n %select3 = select i1 false, i32 %select, i32 0\r\n %fadd4 = fadd float %sitofp, 0.000000e+00\r\n %fadd5 = fadd float %fadd4, 0.000000e+00\r\n %fcmp6 = fcmp ogt float %fadd5, 0.000000e+00\r\n %select7 = select i1 %fcmp6, i32 0, i32 0\r\n %select8 = select i1 false, i32 %select7, i32 0\r\n %or = or i32 %select3, %select8\r\n %sitofp9 = sitofp i32 0 to float\r\n %fmul = fmul float 0.000000e+00, 0.000000e+00\r\n %fadd10 = fadd float %sitofp9, %fmul\r\n %fadd11 = fadd float %fadd10, 0.000000e+00\r\n %fcmp12 = fcmp ogt float %fadd11, 0.000000e+00\r\n %select13 = select i1 %fcmp12, i32 0, i32 0\r\n %select14 = select i1 false, i32 %select13, i32 0\r\n %or15 = or i32 %select14, %or\r\n %fadd16 = fadd float %fmul, 0.000000e+00\r\n %fadd17 = fadd float %fadd16, 0.000000e+00\r\n %fcmp18 = fcmp ogt float %fadd17, 0.000000e+00\r\n %select19 = select i1 %fcmp18, i32 0, i32 0\r\n %select20 = select i1 false, i32 %select19, i32 0\r\n %or21 = or i32 %or15, %select20\r\n br label %bb1\r\n}\r\n```\r\nReproducer: https://godbolt.org/z/T8j1xEoKM\r\nStack dump:\r\n```\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer <source>\r\n1.\tRunning pass \"function(slp-vectorizer)\" on module \"<source>\"\r\n2.\tRunning pass \"slp-vectorizer\" on function \"wombat\"\r\n #0 0x0000000005194b38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5194b38)\r\n #1 0x000000000519252c SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007eacdf842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x00007eacdf8969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x00007eacdf842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x00007eacdf8287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00007eacdf82871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x00007eacdf839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x000000000419bb4f (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x419bb4f)\r\n #9 0x000000000425f0bf llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\r\n#10 0x000000000425fa7b llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x425fa7b)\r\n#11 0x0000000002fbe41e llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2fbe41e)\r\n#12 0x0000000004f949e8 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f949e8)\r\n#13 0x0000000000e4027e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe4027e)\r\n#14 0x0000000004f9340e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f9340e)\r\n#15 0x0000000000e3f92e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe3f92e)\r\n#16 0x0000000004f92e40 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f92e40)\r\n#17 0x0000000000909fda llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x909fda)\r\n#18 0x00000000008fc70a optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8fc70a)\r\n#19 0x00007eacdf829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#20 0x00007eacdf829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#21 0x00000000008f3e9e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8f3e9e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```\r\n",
"author": "TatyanaDoubts",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
155512
|
https://github.com/llvm/llvm-project/issues/155512
|
crash
|
d63dd5eed0ea2f34bcf8b178211f8771ea75dec7
| 2025-08-26T22:37:59 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "e5a4ea20c5b6b37f7fd944b5ef7395d0623d4bdb",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
20529,
20535
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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 e5a4ea20c5b6b37f7fd944b5ef7395d0623d4bdb
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Sun Aug 31 08:48:34 2025 -0700
[SLP]Do not remove reduced value, if it is a copyable
If the value is checked for the reduction and it is a copyable element
in a root node, it should not be deleted, since it may still be used
after vectorization.
Fixes #155512
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 33418d86d51d..ebdd1c81da69 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -20529,7 +20529,9 @@ Value *BoUpSLP::vectorizeTree(
!(GatheredLoadsEntriesFirst.has_value() &&
IE->Idx >= *GatheredLoadsEntriesFirst &&
VectorizableTree.front()->isGather() &&
- is_contained(VectorizableTree.front()->Scalars, I)))
+ is_contained(VectorizableTree.front()->Scalars, I)) &&
+ !(!VectorizableTree.front()->isGather() &&
+ VectorizableTree.front()->isCopyableElement(I)))
continue;
SmallVector<SelectInst *> LogicalOpSelects;
I->replaceUsesWithIf(PoisonValue::get(I->getType()), [&](Use &U) {
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/RISCV/reduced-copyable-element.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=riscv64-unknown-linux-gnu -mattr=+v < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n@n = external global [0 x i64]\n\ndefine i32 @main() {\n;\nentry:\n %0 = load i64, ptr getelementptr (i8, ptr @n, i64 32), align 8\n %conv13.i.1 = trunc i64 %0 to i32\n %cond.i.1 = tail call i32 @llvm.smin.i32(i32 %conv13.i.1, i32 0)\n %conv40.i.1 = sext i32 %cond.i.1 to i64\n %cond47.i.1 = tail call i64 @llvm.umin.i64(i64 %conv40.i.1, i64 17179869184)\n %1 = trunc i64 %cond47.i.1 to i32\n %2 = add i32 %1, 1\n %3 = load i64, ptr @n, align 8\n %conv13.i.2 = trunc i64 %3 to i32\n %cond.i.2 = tail call i32 @llvm.smin.i32(i32 %conv13.i.2, i32 0)\n %conv40.i.2 = sext i32 %cond.i.2 to i64\n %cond47.i.2 = tail call i64 @llvm.umin.i64(i64 %conv40.i.2, i64 17179869184)\n %4 = trunc i64 %cond47.i.2 to i32\n %5 = or i32 %2, %4\n ret i32 %5\n}\n\ndeclare i32 @llvm.smin.i32(i32, i32)\ndeclare i64 @llvm.umin.i64(i64, i64)",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SLPVectorizer] Assertion `(I->use_empty() || all_of(I->uses(), [&](Use &U) { return isDeleted( cast<Instruction>(U.getUser())); })) && \"trying to erase instruction with users.\"' 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@i = internal global i32 47741\n@n = external global [0 x i64]\n\ndefine void @init() {\nentry:\n store <4 x i64> splat (i64 1), ptr @n, align 32\n ret void\n}\n\ndefine i32 @main(ptr %a) #0 {\nentry:\n tail call void @init()\n %0 = load i32, ptr @i, align 4\n %conv3.i = zext i32 %0 to i64\n %sub.i = add i64 %conv3.i, -47731\n br label %for.body.i\n\nfor.cond.for.cond.cleanup_crit_edge.i: ; preds = %for.body.i\n store i32 %conv507173.i, ptr %a, align 4\n ret i32 0\n\nfor.body.i: ; preds = %for.body.i, %entry\n %conv74.i = phi i64 [ %conv.i, %for.body.i ], [ 0, %entry ]\n %conv507173.i = phi i32 [ %conv50.i, %for.body.i ], [ 1, %entry ]\n %arrayidx12.i = getelementptr i64, ptr @n, i64 %conv74.i\n %1 = load i64, ptr %arrayidx12.i, align 8\n %conv13.i = trunc i64 %1 to i32\n %cond.i = tail call i32 @llvm.smin.i32(i32 %conv13.i, i32 1)\n %conv40.i = sext i32 %cond.i to i64\n %cond47.i = tail call i64 @llvm.umin.i64(i64 %conv40.i, i64 17179869184)\n %2 = trunc i64 %cond47.i to i32\n %conv50.i = sub i32 %conv507173.i, %2\n %add.i = shl i64 %conv74.i, 32\n %sext.i = add i64 %add.i, 17179869184\n %conv.i = ashr i64 %sext.i, 32\n %cmp.i = icmp slt i64 %conv74.i, %sub.i\n br i1 %cmp.i, label %for.body.i, label %for.cond.for.cond.cleanup_crit_edge.i\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.smin.i32(i32, i32) #1\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i64 @llvm.umin.i64(i64, i64) #1\n\nattributes #0 = { \"target-features\"=\"+v\" }\nattributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n```\n\nCommands/backtrace:\n```\n$ /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt \"--passes=lto<O2>\" reduced.ll\nWARNING: You're attempting to print out a bitcode file.\nThis is inadvisable as it may cause display problems. If\nyou REALLY want to taste LLVM bitcode first-hand, you\ncan force output with the `-f' option.\n\nopt: /scratch/ewlu/daily-upstream-build/llvm/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:3475: void llvm::slpvectorizer::BoUpSLP::removeInstructionsAndOperands(llvm::ArrayRef<BlockT*>, llvm::ArrayRef<std::tuple<llvm::Value*, unsigned int, bool> >) [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.\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<O2> 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<O2>,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 \"main\"\n #0 0x000063d0f06b35a2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x33c25a2)\n #1 0x000063d0f06b029f llvm::sys::RunSignalHandlers() (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x33bf29f)\n #2 0x000063d0f06b03ec SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #3 0x00007700fb245330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)\n #4 0x00007700fb29eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #5 0x00007700fb29eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #6 0x00007700fb29eb2c pthread_kill ./nptl/pthread_kill.c:89:10\n #7 0x00007700fb24527e raise ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x00007700fb2288ff abort ./stdlib/abort.c:81:7\n #9 0x00007700fb22881b _nl_load_domain ./intl/loadmsgcat.c:1177:9\n#10 0x00007700fb23b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)\n#11 0x000063d0ee3b4201 void llvm::slpvectorizer::BoUpSLP::removeInstructionsAndOperands<llvm::Instruction>(llvm::ArrayRef<llvm::Instruction*>, llvm::ArrayRef<std::tuple<llvm::Value*, unsigned int, bool>>) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x10c3201)\n#12 0x000063d0ee410617 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>>) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x111f617)\n#13 0x000063d0ee41dcc4 (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&, llvm::AssumptionCache*) SLPVectorizer.cpp:0:0\n#14 0x000063d0ee42222d llvm::SLPVectorizerPass::tryToVectorize(llvm::Instruction*, llvm::slpvectorizer::BoUpSLP&)::'lambda'(llvm::Instruction*, llvm::ArrayRef<llvm::Value*>)::operator()(llvm::Instruction*, llvm::ArrayRef<llvm::Value*>) const (.constprop.0) SLPVectorizer.cpp:0:0\n#15 0x000063d0ee426296 llvm::SLPVectorizerPass::tryToVectorize(llvm::Instruction*, llvm::slpvectorizer::BoUpSLP&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x1135296)\n#16 0x000063d0ee4264e8 llvm::SLPVectorizerPass::tryToVectorize(llvm::ArrayRef<llvm::WeakTrackingVH>, llvm::slpvectorizer::BoUpSLP&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x11354e8)\n#17 0x000063d0ee426bb6 llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x1135bb6)\n#18 0x000063d0ee42b040 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x113a040)\n#19 0x000063d0ee433648 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+0x1142648)\n#20 0x000063d0ee434326 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-buil\nd/build-gcv/build-llvm-linux/bin/opt+0x1143326)\n#21 0x000063d0edb8f905 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+0x89e905)\n#22 0x000063d0f0495b75 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+0x31a4b75)\n#23 0x000063d0edb91705 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+0x8a0705)\n#24 0x000063d0f0494881 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x31a3881)\n#25 0x000063d0ed823205 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+0x532205)\n#26 0x000063d0f04928dd 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+0x31a18dd)\n#27 0x000063d0ed82f2f1 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x53e2f1)\n#28 0x000063d0ed8213dd optMain (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x5303dd)\n#29 0x00007700fb22a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3\n#30 0x00007700fb22a28b call_init ./csu/../csu/libc-start.c:128:20\n#31 0x00007700fb22a28b __libc_start_main ./csu/../csu/libc-start.c:347:5\n#32 0x000063d0ed817325 _start (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x526325)\nAborted (core dumped)\n```\n\nGodbolt: https://godbolt.org/z/EnWsq6vsK\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 |
128736
|
https://github.com/llvm/llvm-project/issues/128736
|
crash
|
02128342d2818e5a65846fec4179ed5344045102
| 2025-02-25T16:27:23 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "39bab1de33333ee3c62b586c4e8d26f8c443bc60",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
1389,
1397
],
[
2849,
2859
],
[
2915,
2926
],
[
16466,
16474
],
[
17075,
17081
],
[
20449,
20456
],
[
20678,
20684
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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",
"removeInstructionsAndOperands",
"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 39bab1de33333ee3c62b586c4e8d26f8c443bc60
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Wed Feb 26 14:12:05 2025 -0800
[SLP]Check if the operand for removal is the reduction operand, awaiting for the reduction
If the operand of the instruction-to-be-removed is a reduction value,
which is not reduced yet, and, thus, it has no users, it may be removed
during operands analysis.
Fixes #128736
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index b25b09306aca..e8c91ebd508c 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -1389,9 +1389,10 @@ 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.
- Value *
- vectorizeTree(const ExtraValueToDebugLocsMap &ExternallyUsedValues,
- Instruction *ReductionRoot = nullptr);
+ Value *vectorizeTree(
+ const ExtraValueToDebugLocsMap &ExternallyUsedValues,
+ Instruction *ReductionRoot = nullptr,
+ ArrayRef<std::tuple<Value *, unsigned, bool>> VectorValuesAndScales = {});
/// \returns the cost incurred by unwanted spills and fills, caused by
/// holding live values over call sites.
@@ -2849,11 +2850,13 @@ public:
/// Remove instructions from the parent function and clear the operands of \p
/// DeadVals instructions, marking for deletion trivially dead operands.
template <typename T>
- void removeInstructionsAndOperands(ArrayRef<T *> DeadVals) {
+ void removeInstructionsAndOperands(
+ ArrayRef<T *> DeadVals,
+ ArrayRef<std::tuple<Value *, unsigned, bool>> VectorValuesAndScales) {
SmallVector<WeakTrackingVH> DeadInsts;
for (T *V : DeadVals) {
auto *I = cast<Instruction>(V);
- DeletedInstructions.insert(I);
+ eraseInstruction(I);
}
DenseSet<Value *> Processed;
for (T *V : DeadVals) {
@@ -2915,12 +2918,17 @@ public:
// loop iteration.
if (auto *OpI = dyn_cast<Instruction>(OpV))
if (!DeletedInstructions.contains(OpI) &&
+ (!OpI->getType()->isVectorTy() ||
+ none_of(VectorValuesAndScales,
+ [&](const std::tuple<Value *, unsigned, bool> &V) {
+ return std::get<0>(V) == OpI;
+ })) &&
isInstructionTriviallyDead(OpI, TLI))
DeadInsts.push_back(OpI);
}
VI->removeFromParent();
- DeletedInstructions.insert(VI);
+ eraseInstruction(VI);
SE->forgetValue(VI);
}
}
@@ -16466,9 +16474,10 @@ Value *BoUpSLP::vectorizeTree() {
return vectorizeTree(ExternallyUsedValues);
}
-Value *
-BoUpSLP::vectorizeTree(const ExtraValueToDebugLocsMap &ExternallyUsedValues,
- Instruction *ReductionRoot) {
+Value *BoUpSLP::vectorizeTree(
+ const ExtraValueToDebugLocsMap &ExternallyUsedValues,
+ Instruction *ReductionRoot,
+ ArrayRef<std::tuple<Value *, unsigned, bool>> VectorValuesAndScales) {
// All blocks must be scheduled before any instructions are inserted.
for (auto &BSIter : BlocksSchedules) {
scheduleBlock(BSIter.second.get());
@@ -17075,7 +17084,7 @@ BoUpSLP::vectorizeTree(const ExtraValueToDebugLocsMap &ExternallyUsedValues,
// cache correctness.
// NOTE: removeInstructionAndOperands only marks the instruction for deletion
// - instructions are not deleted until later.
- removeInstructionsAndOperands(ArrayRef(RemovedInsts));
+ removeInstructionsAndOperands(ArrayRef(RemovedInsts), VectorValuesAndScales);
Builder.ClearInsertionPoint();
InstrElementSize.clear();
@@ -20449,8 +20458,8 @@ public:
InsertPt = GetCmpForMinMaxReduction(RdxRootInst);
// Vectorize a tree.
- Value *VectorizedRoot =
- V.vectorizeTree(LocalExternallyUsedValues, InsertPt);
+ Value *VectorizedRoot = V.vectorizeTree(
+ LocalExternallyUsedValues, InsertPt, VectorValuesAndScales);
// Update TrackedToOrig mapping, since the tracked values might be
// updated.
for (Value *RdxVal : Candidates) {
@@ -20678,7 +20687,7 @@ public:
Ignore->replaceAllUsesWith(P);
}
}
- V.removeInstructionsAndOperands(RdxOps);
+ V.removeInstructionsAndOperands(RdxOps, VectorValuesAndScales);
}
} else if (!CheckForReusedReductionOps) {
for (ReductionOpsType &RdxOps : ReductionOps)
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/reduction-with-removed-extracts.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -mcpu=znver2 < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine i32 @test(i32 %arg) {\n;\nbb:\n br label %bb1\n\nbb1:\n %phi = phi i32 [ 0, %bb ], [ %mul37, %bb1 ]\n %mul = mul i64 0, 0\n %trunc = trunc i64 %mul to i32\n %or = or i32 0, %trunc\n %or2 = or i32 0, %or\n %or3 = or i32 %or2, 0\n %mul4 = mul i32 0, %or3\n %mul5 = mul i32 %or3, 0\n %mul6 = mul i32 %mul5, %mul4\n %mul7 = mul i32 %mul6, %mul4\n %mul8 = mul i32 %mul7, %or3\n %mul9 = mul i64 0, 0\n %trunc10 = trunc i64 %mul9 to i32\n %or11 = or i32 0, %trunc10\n %or12 = or i32 %arg, %or11\n %or13 = or i32 %or12, 0\n %mul14 = mul i32 %or13, %mul8\n %mul15 = mul i32 %mul14, 0\n %mul16 = mul i32 %mul15, 0\n %mul17 = mul i32 %mul16, %or13\n %shl = shl i64 0, 0\n %mul18 = mul i64 %shl, 0\n %trunc19 = trunc i64 %mul18 to i32\n %or20 = or i32 0, %trunc19\n %or21 = or i32 0, %or20\n %or22 = or i32 %or21, 0\n %mul23 = mul i32 %or22, %mul17\n %mul24 = mul i32 %mul23, 0\n %mul25 = mul i32 %mul24, 0\n %mul26 = mul i32 %mul25, %or22\n %shl27 = shl i64 0, 0\n %mul28 = mul i64 %shl27, 0\n %trunc29 = trunc i64 %mul28 to i32\n %or30 = or i32 0, %trunc29\n %or31 = or i32 0, %or30\n %or32 = or i32 %or31, 0\n %mul33 = mul i32 0, %or32\n %mul34 = mul i32 %or32, %mul26\n %mul35 = mul i32 %mul34, %mul33\n %mul36 = mul i32 %mul35, %mul33\n %mul37 = mul i32 %mul36, %or32\n br label %bb1\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Assertion `I->use_empty() && \"trying to erase instruction with users.\"' failed.",
"body": "To reproduce run opt with the test below using -passes=slp-vectorizer.\n```\n; ModuleID = './reduced.ll'\nsource_filename = \"./reduced.ll\"\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i32 @wombat(i32 %arg) #0 gc \"statepoint-example\" {\nbb:\n br label %bb1\n \nbb1: ; preds = %bb1, %bb\n %phi = phi i32 [ 0, %bb ], [ %mul37, %bb1 ]\n %mul = mul i64 0, 0\n %trunc = trunc i64 %mul to i32\n %or = or i32 0, %trunc\n %or2 = or i32 0, %or\n %or3 = or i32 %or2, 0\n %mul4 = mul i32 0, %or3\n %mul5 = mul i32 %or3, 0\n %mul6 = mul i32 %mul5, %mul4\n %mul7 = mul i32 %mul6, %mul4\n %mul8 = mul i32 %mul7, %or3\n %mul9 = mul i64 0, 0\n %trunc10 = trunc i64 %mul9 to i32\n %or11 = or i32 0, %trunc10\n %or12 = or i32 %arg, %or11\n %or13 = or i32 %or12, 0\n %mul14 = mul i32 %or13, %mul8\n %mul15 = mul i32 %mul14, 0\n %mul16 = mul i32 %mul15, 0\n %mul17 = mul i32 %mul16, %or13\n %shl = shl i64 0, 0\n %mul18 = mul i64 %shl, 0\n %trunc19 = trunc i64 %mul18 to i32\n %or20 = or i32 0, %trunc19\n %or21 = or i32 0, %or20\n %or22 = or i32 %or21, 0\n %mul23 = mul i32 %or22, %mul17\n %mul24 = mul i32 %mul23, 0\n %mul25 = mul i32 %mul24, 0\n %mul26 = mul i32 %mul25, %or22\n %shl27 = shl i64 0, 0\n %mul28 = mul i64 %shl27, 0\n %trunc29 = trunc i64 %mul28 to i32\n %or30 = or i32 0, %trunc29\n %or31 = or i32 0, %or30\n %or32 = or i32 %or31, 0\n %mul33 = mul i32 0, %or32\n %mul34 = mul i32 %or32, %mul26\n %mul35 = mul i32 %mul34, %mul33\n %mul36 = mul i32 %mul35, %mul33\n %mul37 = mul i32 %mul36, %or32\n br label %bb1\n}\n\nattributes #0 = { \"target-cpu\"=\"znver2\" }\n```\n\nReproducer: https://godbolt.org/z/4PPzsMbP3\n\nStack dump:\n```\nopt: /root/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:4570: llvm::slpvectorizer::BoUpSLP::~BoUpSLP(): Assertion `I->use_empty() && \"trying to erase instruction with users.\"' 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 \"wombat\"\n #0 0x00000000054546a8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x54546a8)\n #1 0x0000000005452064 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007b5c5f242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007b5c5f2969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007b5c5f242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007b5c5f2287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x00007b5c5f22871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x00007b5c5f239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x000000000440d177 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x440d177)\n #9 0x00000000044d46ae llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\n#10 0x00000000044d50cb llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x44d50cb)\n#11 0x000000000318a35e 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+0x318a35e)\n#12 0x000000000524e9e0 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x524e9e0)\n#13 0x0000000000e6f88e 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+0xe6f88e)\n#14 0x000000000524d2fb llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x524d2fb)\n#15 0x0000000000e6eb7e 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+0xe6eb7e)\n#16 0x000000000524cd00 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x524cd00)\n#17 0x0000000000935e7a 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+0x935e7a)\n#18 0x00000000009294ec optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9294ec)\n#19 0x00007b5c5f229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#20 0x00007b5c5f229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#21 0x0000000000920dc5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x920dc5)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```",
"author": "TatyanaDoubts",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
114879
|
https://github.com/llvm/llvm-project/issues/114879
|
miscompilation
|
3850801ca57575640a6ad3a5a421a416dc5c6f12
| 2024-11-04T22:12:00 |
[
"llvm/test/Transforms/IndVarSimplify",
"llvm/test/Transforms/LoopStrengthReduce",
"llvm/test/Transforms/LoopUnroll",
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "0b9f1cc024ca6c7e8d60524be07c0ddfcd08b23c",
"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": [
[
6023,
6029
]
],
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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::createNodeForPHI"
],
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 0b9f1cc024ca6c7e8d60524be07c0ddfcd08b23c
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Thu Nov 7 15:53:51 2024 +0800
[SCEV] Disallow simplifying phi(undef, X) to X (#115109)
See the following case:
```
@GlobIntONE = global i32 0, align 4
define ptr @src() {
entry:
br label %for.body.peel.begin
for.body.peel.begin: ; preds = %entry
br label %for.body.peel
for.body.peel: ; preds = %for.body.peel.begin
br i1 true, label %cleanup.peel, label %cleanup.loopexit.peel
cleanup.loopexit.peel: ; preds = %for.body.peel
br label %cleanup.peel
cleanup.peel: ; preds = %cleanup.loopexit.peel, %for.body.peel
%retval.2.peel = phi ptr [ undef, %for.body.peel ], [ @GlobIntONE, %cleanup.loopexit.peel ]
br i1 true, label %for.body.peel.next, label %cleanup7
for.body.peel.next: ; preds = %cleanup.peel
br label %for.body.peel.next1
for.body.peel.next1: ; preds = %for.body.peel.next
br label %entry.peel.newph
entry.peel.newph: ; preds = %for.body.peel.next1
br label %for.body
for.body: ; preds = %cleanup, %entry.peel.newph
%retval.0 = phi ptr [ %retval.2.peel, %entry.peel.newph ], [ %retval.2, %cleanup ]
br i1 false, label %cleanup, label %cleanup.loopexit
cleanup.loopexit: ; preds = %for.body
br label %cleanup
cleanup: ; preds = %cleanup.loopexit, %for.body
%retval.2 = phi ptr [ %retval.0, %for.body ], [ @GlobIntONE, %cleanup.loopexit ]
br i1 false, label %for.body, label %cleanup7.loopexit
cleanup7.loopexit: ; preds = %cleanup
%retval.2.lcssa.ph = phi ptr [ %retval.2, %cleanup ]
br label %cleanup7
cleanup7: ; preds = %cleanup7.loopexit, %cleanup.peel
%retval.2.lcssa = phi ptr [ %retval.2.peel, %cleanup.peel ], [ %retval.2.lcssa.ph, %cleanup7.loopexit ]
ret ptr %retval.2.lcssa
}
define ptr @tgt() {
entry:
br label %for.body.peel.begin
for.body.peel.begin: ; preds = %entry
br label %for.body.peel
for.body.peel: ; preds = %for.body.peel.begin
br i1 true, label %cleanup.peel, label %cleanup.loopexit.peel
cleanup.loopexit.peel: ; preds = %for.body.peel
br label %cleanup.peel
cleanup.peel: ; preds = %cleanup.loopexit.peel, %for.body.peel
%retval.2.peel = phi ptr [ undef, %for.body.peel ], [ @GlobIntONE, %cleanup.loopexit.peel ]
br i1 true, label %for.body.peel.next, label %cleanup7
for.body.peel.next: ; preds = %cleanup.peel
br label %for.body.peel.next1
for.body.peel.next1: ; preds = %for.body.peel.next
br label %entry.peel.newph
entry.peel.newph: ; preds = %for.body.peel.next1
br label %for.body
for.body: ; preds = %cleanup, %entry.peel.newph
br i1 false, label %cleanup, label %cleanup.loopexit
cleanup.loopexit: ; preds = %for.body
br label %cleanup
cleanup: ; preds = %cleanup.loopexit, %for.body
br i1 false, label %for.body, label %cleanup7.loopexit
cleanup7.loopexit: ; preds = %cleanup
%retval.2.lcssa.ph = phi ptr [ %retval.2.peel, %cleanup ]
br label %cleanup7
cleanup7: ; preds = %cleanup7.loopexit, %cleanup.peel
%retval.2.lcssa = phi ptr [ %retval.2.peel, %cleanup.peel ], [ %retval.2.lcssa.ph, %cleanup7.loopexit ]
ret ptr %retval.2.lcssa
}
```
1. `simplifyInstruction(%retval.2.peel)` returns `@GlobIntONE`. Thus,
`ScalarEvolution::createNodeForPHI` returns SCEV expr `@GlobIntONE` for
`%retval.2.peel`.
2. `SimplifyIndvar::replaceIVUserWithLoopInvariant` tries to replace the
use of `%retval.2.peel` in `%retval.2.lcssa.ph` with `@GlobIntONE`.
3. `simplifyLoopAfterUnroll -> simplifyLoopIVs -> SCEVExpander::expand`
reuses `%retval.2.peel = phi ptr [ undef, %for.body.peel ], [
@GlobIntONE, %cleanup.loopexit.peel ]` to generate code for
`@GlobIntONE`. It is incorrect.
This patch disallows simplifying `phi(undef, X)` to `X` by setting
`CanUseUndef` to false.
Closes https://github.com/llvm/llvm-project/issues/114879.
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 58e23e9556f1..b10811133770 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -6023,7 +6023,11 @@ const SCEV *ScalarEvolution::createNodeForPHI(PHINode *PN) {
if (const SCEV *S = createAddRecFromPHI(PN))
return S;
- if (Value *V = simplifyInstruction(PN, {getDataLayout(), &TLI, &DT, &AC}))
+ // We do not allow simplifying phi (undef, X) to X here, to avoid reusing the
+ // phi node for X.
+ if (Value *V = simplifyInstruction(
+ PN, {getDataLayout(), &TLI, &DT, &AC, /*CtxI=*/nullptr,
+ /*UseInstrInfo=*/true, /*CanUseUndef=*/false}))
return getSCEV(V);
if (const SCEV *S = createNodeFromSelectLikePHI(PN))
|
[
{
"file": "llvm/test/Transforms/IndVarSimplify/invalidate-modified-lcssa-phi.ll",
"commands": [
"opt -passes='loop(indvars,loop-deletion)' -verify-scev -S %s"
],
"tests": [
{
"test_name": "test_pr52023",
"test_body": "define i8 @test_pr52023(i1 %c.1, i1 %c.2) {\nentry:\n br label %loop.1\n\nloop.1: ; preds = %loop.1.latch, %entry\n %inc79 = phi i8 [ %inc.lcssa, %loop.1.latch ], [ 0, %entry ]\n br label %loop.2\n\nloop.2: ; preds = %loop.2.latch, %loop.1\n %inc6 = phi i8 [ %inc79, %loop.1 ], [ %inc, %loop.2.latch ]\n %inc = add i8 %inc6, 1\n br i1 %c.1, label %loop.2.latch, label %loop.1.latch\n\nloop.2.latch: ; preds = %loop.2\n br i1 false, label %loop.2, label %loop.1.latch\n\nloop.1.latch: ; preds = %loop.2.latch, %loop.2\n %inc.lcssa = phi i8 [ %inc, %loop.2.latch ], [ undef, %loop.2 ]\n br i1 %c.2, label %exit, label %loop.1\n\nexit: ; preds = %loop.1.latch\n %inc.lcssa.lcssa = phi i8 [ %inc.lcssa, %loop.1.latch ]\n ret i8 %inc.lcssa.lcssa\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/IndVarSimplify/no-iv-rewrite.ll",
"commands": [
"opt < %s -passes=indvars -S -indvars-predicate-loops=0"
],
"tests": [
{
"test_name": "identityphi",
"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\n; Function Attrs: nounwind\ndefine void @identityphi(i32 %limit) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %control, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %control ]\n br i1 undef, label %if.then, label %control\n\nif.then: ; preds = %loop\n br label %control\n\ncontrol: ; preds = %if.then, %loop\n %iv.next = phi i32 [ %iv, %loop ], [ undef, %if.then ]\n %cmp = icmp slt i32 %iv.next, %limit\n br i1 %cmp, label %loop, label %exit\n\nexit: ; preds = %control\n ret void\n}\n\nattributes #0 = { nounwind }\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopStrengthReduce/X86/2012-01-13-phielim.ll",
"commands": [
"opt < %s -S -loop-reduce -mtriple=x86_64-- -mcpu=core2"
],
"tests": [
{
"test_name": "test3",
"test_body": "; Function Attrs: nounwind ssp uwtable\ndefine fastcc void @test3(ptr nocapture %u) #0 {\nentry:\n br i1 undef, label %meshBB1, label %meshBB5\n\nfor.inc8.us.i: ; preds = %for.body3.us.i\n br i1 undef, label %meshBB1, label %meshBB\n\nfor.body3.us.i: ; preds = %meshBB, %for.body3.lr.ph.us.i\n %indvars.iv.i.SV.phi = phi i64 [ %indvars.iv.next.i, %meshBB ], [ 0, %for.body3.lr.ph.us.i ]\n %storemerge13.us.i.SV.phi = phi i32 [ 0, %meshBB ], [ 0, %for.body3.lr.ph.us.i ]\n %Opq.sa.calc12 = sub i32 undef, 227\n %0 = add nsw i64 %indvars.iv.i.SV.phi, %indvars.iv8.i.SV.phi26\n %1 = trunc i64 %0 to i32\n %mul.i.us.i = mul nsw i32 0, %1\n %arrayidx5.us.i = getelementptr inbounds double, ptr %u, i64 %indvars.iv.i.SV.phi\n %2 = load double, ptr %arrayidx5.us.i, align 8\n %indvars.iv.next.i = add i64 %indvars.iv.i.SV.phi, 1\n br i1 undef, label %for.inc8.us.i, label %meshBB\n\nfor.body3.lr.ph.us.i: ; preds = %meshBB1, %meshBB\n %indvars.iv8.i.SV.phi26 = phi i64 [ undef, %meshBB1 ], [ %indvars.iv8.i.SV.phi24, %meshBB ]\n %arrayidx.us.i = getelementptr inbounds double, ptr undef, i64 %indvars.iv8.i.SV.phi26\n %3 = add i64 %indvars.iv8.i.SV.phi26, 1\n br label %for.body3.us.i\n\nfor.inc8.us.i2: ; preds = %meshBB5\n unreachable\n\neval_At_times_u.exit: ; preds = %meshBB5\n ret void\n\nmeshBB: ; preds = %for.body3.us.i, %for.inc8.us.i\n %indvars.iv8.i.SV.phi24 = phi i64 [ undef, %for.body3.us.i ], [ %3, %for.inc8.us.i ]\n %meshStackVariable.phi = phi i32 [ %Opq.sa.calc12, %for.body3.us.i ], [ undef, %for.inc8.us.i ]\n br i1 undef, label %for.body3.lr.ph.us.i, label %for.body3.us.i\n\nmeshBB1: ; preds = %for.inc8.us.i, %entry\n br label %for.body3.lr.ph.us.i\n\nmeshBB5: ; preds = %entry\n br i1 undef, label %eval_At_times_u.exit, label %for.inc8.us.i2\n}\n\nattributes #0 = { nounwind ssp uwtable }\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopUnroll/pr114879.ll",
"commands": [
"opt -S -passes=loop-unroll-full -unroll-full-max-count=1 %s"
],
"tests": [
{
"test_name": "test",
"test_body": "@GlobIntONE = external global i32, align 4\n\ndefine ptr @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %cleanup, %entry\n %retval.0 = phi ptr [ undef, %entry ], [ %retval.2, %cleanup ]\n %cmp1.not = phi i1 [ true, %entry ], [ false, %cleanup ]\n br i1 %cmp1.not, label %cleanup, label %cleanup.loopexit\n\ncleanup.loopexit: ; preds = %for.body\n br label %cleanup\n\ncleanup: ; preds = %cleanup.loopexit, %for.body\n %retval.2 = phi ptr [ %retval.0, %for.body ], [ @GlobIntONE, %cleanup.loopexit ]\n br i1 %cmp1.not, label %for.body, label %cleanup2\n\ncleanup2: ; preds = %cleanup\n %retval.2.lcssa = phi ptr [ %retval.2, %cleanup ]\n ret ptr %retval.2.lcssa\n}\n",
"lli_expected_out": null,
"additional_args": "--src-unroll=10 -tgt-unroll=10"
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/uniform-blend.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-width=4 -S %s"
],
"tests": [
{
"test_name": "blend_uniform_iv",
"test_body": "@dst = external global [32 x i16], align 1\n\ndefine void @blend_uniform_iv(i1 %c) {\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 %c, label %loop.next, label %loop.latch\n\nloop.next: ; preds = %loop.header\n br label %loop.latch\n\nloop.latch: ; preds = %loop.next, %loop.header\n %blend = phi i64 [ poison, %loop.header ], [ %iv, %loop.next ]\n %dst.ptr = getelementptr inbounds [32 x i16], ptr @dst, i16 0, i64 %blend\n store i16 0, ptr %dst.ptr, align 2\n %iv.next = add nuw nsw i64 %iv, 1\n %cmp439 = icmp ult i64 %iv, 31\n br i1 %cmp439, label %loop.header, label %exit\n\nexit: ; preds = %loop.latch\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "blend_uniform_iv_trunc",
"test_body": "@dst = external global [32 x i16], align 1\n\ndefine void @blend_uniform_iv_trunc(i1 %c) {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %iv.trunc.2 = trunc i64 %iv to i16\n br i1 %c, label %loop.next, label %loop.latch\n\nloop.next: ; preds = %loop.header\n br label %loop.latch\n\nloop.latch: ; preds = %loop.next, %loop.header\n %blend = phi i16 [ poison, %loop.header ], [ %iv.trunc.2, %loop.next ]\n %dst.ptr = getelementptr inbounds [32 x i16], ptr @dst, i16 0, i16 %blend\n store i16 0, ptr %dst.ptr, align 2\n %iv.next = add nuw nsw i64 %iv, 1\n %cmp439 = icmp ult i64 %iv, 31\n br i1 %cmp439, label %loop.header, label %exit\n\nexit: ; preds = %loop.latch\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "WRONG code: GVN? Loop opts?",
"body": "cat wrong0.i\r\n```\r\nint printf(const char *, ...);\r\nunsigned int IntArr[6];\r\nunsigned int GlobIntONE = 1, GlobIntZERO = 0;\r\nconst unsigned int *GlobIntPtr = 0;\r\nunsigned long Res;\r\nunsigned long *ResPtr = &Res;\r\nconst unsigned int **GlobIntPtrPTr = &GlobIntPtr;\r\nunsigned int *func() {\r\n int *GlobIntONEPtr = &GlobIntONE;\r\n for (int Idx = 0; Idx <= 7; Idx += 1) {\r\n int Idx2 = 1;\r\n if (Idx > 0) {\r\n for (; Idx2 <= 7; Idx2 += 1)\r\n ;\r\n return GlobIntONEPtr;\r\n }\r\n }\r\n 0 != &GlobIntONEPtr;\r\n return &GlobIntZERO;\r\n}\r\n\r\nint main() {\r\n IntArr[GlobIntZERO] = GlobIntZERO;\r\n *GlobIntPtrPTr = func();\r\n unsigned char Byte = *GlobIntPtr;\r\n *ResPtr = Byte;\r\n printf(\"checksum = %X\\n\", Res);\r\n}\r\n```\r\n\r\n\r\nIn the above file, func() should obviously should return GlobIntONEPtr, but it does not if compiled with '-fno-inline -mllvm -unroll-full-max-count=1'.\r\n\r\n```\r\nclang -O0 -march=z16 wrong0.i -o a.out -w -fno-inline ; ./a.out\r\nchecksum = 1\r\n\r\nclang -O3 -march=z16 wrong0.i -o a.out -w -fno-inline ; ./a.out\r\nchecksum = 1\r\n\r\nclang -O3 -march=z16 wrong0.i -o a.out -w -fno-inline -mllvm -unroll-full-max-count=1 ; ./a.out\r\nchecksum = 0\r\n\r\n```\r\nIt may be that GVN does something wrong, as after it @func() is always returning ptr undef. Or it could very well be some of the loop optimizations that is run just before it.\r\n\r\nA bisect shows that\r\n\r\n```\r\nd77067d08a3f56dc2d0e6c95bd2852c943df743a is the first bad commit\r\ncommit d77067d08a3f56dc2d0e6c95bd2852c943df743a\r\nAuthor: Nikita Popov <npopov@redhat.com>\r\nDate: Wed Dec 6 14:17:18 2023 +0100\r\n\r\n [ValueTracking] Add dominating condition support in computeKnownBits() (#73662)\r\n\r\n```\r\n@nikic ",
"author": "JonPsson1",
"labels": [
"miscompilation",
"llvm:SCEV"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Bisected to LoopUnrollFullPass:\r\n```\r\n; bin/opt -passes=loop-unroll-full -unroll-full-max-count=1 test.ll -S\r\n\r\n@GlobIntONE = dso_local global i32 1, align 4\r\n@GlobIntZERO = dso_local local_unnamed_addr global i32 0, align 4\r\n\r\ndefine i32 @main() local_unnamed_addr {\r\nentry:\r\n br label %for.body\r\n\r\nfor.body: ; preds = %entry, %cleanup\r\n %retval.0 = phi ptr [ undef, %entry ], [ %retval.2, %cleanup ]\r\n %cmp1.not = phi i1 [ true, %entry ], [ false, %cleanup ]\r\n br i1 %cmp1.not, label %cleanup, label %for.cond2.preheader\r\n\r\nfor.cond2.preheader: ; preds = %for.body\r\n br label %cleanup.loopexit\r\n\r\ncleanup.loopexit: ; preds = %for.cond2.preheader\r\n br label %cleanup\r\n\r\ncleanup: ; preds = %cleanup.loopexit, %for.body\r\n %retval.2 = phi ptr [ %retval.0, %for.body ], [ @GlobIntONE, %cleanup.loopexit ]\r\n br i1 %cmp1.not, label %for.body, label %cleanup7\r\n\r\ncleanup7: ; preds = %cleanup\r\n %retval.2.lcssa = phi ptr [ %retval.2, %cleanup ]\r\n %res = load i32, ptr %retval.2.lcssa, align 4\r\n ret i32 %res\r\n}\r\n```\r\n```\r\nsource_filename = \"test.ll\"\r\n\r\n@GlobIntONE = dso_local global i32 1, align 4\r\n@GlobIntZERO = dso_local local_unnamed_addr global i32 0, align 4\r\n\r\ndefine i32 @main() local_unnamed_addr {\r\nentry:\r\n br label %for.body.peel.begin\r\n\r\nfor.body.peel.begin: ; preds = %entry\r\n br label %for.body.peel\r\n\r\nfor.body.peel: ; preds = %for.body.peel.begin\r\n br i1 true, label %cleanup.peel, label %for.cond2.preheader.peel\r\n\r\nfor.cond2.preheader.peel: ; preds = %for.body.peel\r\n br label %cleanup.loopexit.peel\r\n\r\ncleanup.loopexit.peel: ; preds = %for.cond2.preheader.peel\r\n br label %cleanup.peel\r\n\r\ncleanup.peel: ; preds = %cleanup.loopexit.peel, %for.body.peel\r\n %retval.2.peel = phi ptr [ undef, %for.body.peel ], [ @GlobIntONE, %cleanup.loopexit.peel ]\r\n br i1 true, label %for.body.peel.next, label %cleanup7\r\n\r\nfor.body.peel.next: ; preds = %cleanup.peel\r\n br label %for.body.peel.next1\r\n\r\nfor.body.peel.next1: ; preds = %for.body.peel.next\r\n br label %entry.peel.newph\r\n\r\nentry.peel.newph: ; preds = %for.body.peel.next1\r\n br label %for.body\r\n\r\nfor.body: ; preds = %cleanup, %entry.peel.newph\r\n br i1 false, label %cleanup, label %for.cond2.preheader\r\n\r\nfor.cond2.preheader: ; preds = %for.body\r\n br label %cleanup.loopexit\r\n\r\ncleanup.loopexit: ; preds = %for.cond2.preheader\r\n br label %cleanup\r\n\r\ncleanup: ; preds = %cleanup.loopexit, %for.body\r\n br i1 false, label %for.body, label %cleanup7.loopexit, !llvm.loop !0\r\n\r\ncleanup7.loopexit: ; preds = %cleanup\r\n %retval.2.lcssa.ph = phi ptr [ %retval.2.peel, %cleanup ]\r\n br label %cleanup7\r\n\r\ncleanup7: ; preds = %cleanup7.loopexit, %cleanup.peel\r\n %retval.2.lcssa = phi ptr [ %retval.2.peel, %cleanup.peel ], [ %retval.2.lcssa.ph, %cleanup7.loopexit ]\r\n %res = load i32, ptr %retval.2.lcssa, align 4\r\n ret i32 %res\r\n}\r\n\r\n!0 = distinct !{!0, !1}\r\n!1 = !{!\"llvm.loop.peeled.count\", i32 1}\r\n```"
},
{
"author": "dtcxzyw",
"body": "`simplifyLoopAfterUnroll -> simplifyLoopIVs` causes the miscompilation: https://alive2.llvm.org/ce/z/yiBsZt\r\nI will post a fix later.\r\n"
},
{
"author": "dtcxzyw",
"body": "The root cause is:\r\n1. `simplifyInstruction(%retval.2.peel)` returns `@GlobIntONE`. Thus, `ScalarEvolution::createNodeForPHI` returns SCEV expr `@GlobIntONE` for `%retval.2.peel`.\r\n2. `SimplifyIndvar::replaceIVUserWithLoopInvariant` tries to replace the use of `%retval.2.peel` in `%retval.2.lcssa.ph` with `@GlobIntONE`.\r\n3. `SCEVExpander::expand` reuses `%retval.2.peel = phi ptr [ undef, %for.body.peel ], [ @GlobIntONE, %cleanup.loopexit.peel ]` to generate code for `@GlobIntONE`. It is incorrect.\r\n\r\nTwo possible solutions:\r\n1. Set `CanUseUndef` to false in `simplifyInstruction`.\r\n2. Block this case in `ScalarEvolution::canReuseInstruction`.\r\n\r\n@nikic @preames Any thoughts?\r\n"
},
{
"author": "nikic",
"body": "I think setting `CanUseUndef=false` would be the correct thing to do. The reverse replacement here is particularly fishy, but more generally, if we make an assumption about the value of undef at a particular use, we have to be consistent about that assumption, and SCEV cannot really guarantee that this is the case."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
109510
|
https://github.com/llvm/llvm-project/issues/109510
|
crash
|
eb6e7e8f89a3d5c1cbc9856774ca00208753fb12
| 2024-09-21T04:01:16 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "bd8fe9972e3f17776e4e05e69e13ab8271d34132",
"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": [
[
1158,
1164
],
[
1166,
1171
]
],
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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::optimize"
],
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 bd8fe9972e3f17776e4e05e69e13ab8271d34132
Author: Florian Hahn <flo@fhahn.com>
Date: Sat Sep 21 12:45:36 2024 +0100
[VPlan] Mov licm to end of VPlan optimizations.
This moves licm after expanding replicate regions. This fixes a crash
when trying to hoist a predicated VPReplicateRecipes which later get
expanded to replicate regions.
Hoisting replicate regions out was not intended (see the discussion and
at the review and comment on shallow traversal in licm()).
Fixes https://github.com/llvm/llvm-project/issues/109510.
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 06ac15f52fe1..fd6090affbbf 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -1158,7 +1158,6 @@ void VPlanTransforms::optimize(VPlan &Plan) {
removeRedundantInductionCasts(Plan);
simplifyRecipes(Plan);
- licm(Plan);
legalizeAndOptimizeInductions(Plan);
removeDeadRecipes(Plan);
@@ -1166,6 +1165,7 @@ void VPlanTransforms::optimize(VPlan &Plan) {
removeRedundantExpandSCEVRecipes(Plan);
mergeBlocksIntoPredecessors(Plan);
+ licm(Plan);
}
// Add a VPActiveLaneMaskPHIRecipe and related recipes to \p Plan and replace
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/invariant-replicate-region.ll",
"commands": [
"opt -p loop-vectorize -force-vector-width=4 -S %s"
],
"tests": [
{
"test_name": "test_invariant_replicate_region",
"test_body": "target datalayout = \"e-m:o-i64:64-i128:128-n32:64-S128-Fn32\"\ntarget triple = \"arm64-apple-macosx14.0.0\"\n\ndefine i32 @test_invariant_replicate_region(i32 %x, i1 %c) {\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.latch\n\nthen: ; preds = %loop.header\n %rem.1 = urem i32 10, %x\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n %res = phi i32 [ 0, %loop.header ], [ %rem.1, %then ]\n %iv.next = add i32 %iv, 1\n %ec = icmp eq i32 %iv, 99\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret i32 %res\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "A/F: verifyVPlanIsValid(*Plan) && \"VPlan is invalid\" after a861ed411a",
"body": "We have an internal test that recently started to hit an assertion failure which I bisected back to commit a861ed411a359b7cb2b58d642e4a7f2fdcf92057. \r\n\r\nConsider the following code:\r\n```c\r\nint g_78, g_659, func_32_l_1852;\r\nlong g_128;\r\nunsigned func_32_p_33;\r\nvoid func_32() {\r\n int *l_1145 = &g_659;\r\n *l_1145 = 0;\r\n short __trans_tmp_11;\r\n for (; g_78; g_78 += 1) {\r\n func_32_l_1852 = 0;\r\n for (; func_32_l_1852 <= 3; func_32_l_1852 += 1) {\r\n int *l_1863 = &g_659;\r\n __trans_tmp_11 = *l_1863;\r\n if (10 % ((__trans_tmp_11 >= 0) - func_32_p_33))\r\n break;\r\n ++g_128;\r\n *l_1863 = func_32_p_33 <= --g_128;\r\n }\r\n }\r\n}\r\n```\r\n\r\nIf compiled with optimizations and a compiler built from a861ed411a359b7cb2b58d642e4a7f2fdcf92057 you can see it hits an assertion failure:\r\n```\r\n$ ~/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang -c -O2 repro.c\r\nVPIRBasicBlock can only be used as pre-header or a successor of middle-block at the moment!\r\nclang: /home/dyung/src/upstream/llvm_clean_git/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:8594: 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, preprocessed source, and associated run script.\r\nStack dump:\r\n0. Program arguments: /home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang -c -O2 repro.c\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-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.c\"\r\n4. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"func_32\"\r\n #0 0x00005572973a049f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0x233549f)\r\n #1 0x000055729739dfec llvm::sys::CleanupOnSignal(unsigned long) (/home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0x2332fec)\r\n #2 0x00005572972f0418 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0\r\n #3 0x00007f5d2a347420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #4 0x00007f5d29e1400b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #5 0x00007f5d29df3859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\r\n #6 0x00007f5d29df3729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #7 0x00007f5d29df3729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #8 0x00007f5d29e04fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #9 0x0000557298e08438 llvm::LoopVectorizationPlanner::buildVPlansWithVPRecipes(llvm::ElementCount, llvm::ElementCount) (/home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0x3d9d438)\r\n#10 0x0000557298e0878f llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (/home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0x3d9d78f)\r\n#11 0x0000557298e0a62e llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0x3d9f62e)\r\n#12 0x0000557298e0d501 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0x3da2501)\r\n#13 0x0000557298e0db73 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0x3da2b73)\r\n#14 0x0000557298836146 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0x37cb146)\r\n#15 0x0000557296e5bd41 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0x1df0d41)\r\n#16 0x0000557295f84cc6 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/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0xf19cc6)\r\n#17 0x0000557296e5a6ad llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0x1def6ad)\r\n#18 0x0000557295f85686 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0xf1a686)\r\n#19 0x0000557296e5a0e1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0x1def0e1)\r\n#20 0x0000557297636863 (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#21 0x0000557297639dbd 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/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0x25cedbd)\r\n#22 0x0000557297d17c5c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0x2cacc5c)\r\n#23 0x0000557299c7aa8c clang::ParseAST(clang::Sema&, bool, bool) (/home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0x4c0fa8c)\r\n#24 0x0000557297d18078 clang::CodeGenAction::ExecuteAction() (/home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0x2cad078)\r\n#25 0x0000557297fdf129 clang::FrontendAction::Execute() (/home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0x2f74129)\r\n#26 0x0000557297f5b6fe clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0x2ef06fe)\r\n#27 0x00005572980cba26 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0x3060a26)\r\n#28 0x0000557295f09185 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0xe9e185)\r\n#29 0x0000557295f00f0a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#30 0x0000557297d5e0cd 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#31 0x00005572972f0920 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0x2285920)\r\n#32 0x0000557297d5e6ef 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#33 0x0000557297d22274 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0x2cb7274)\r\n#34 0x0000557297d2338d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0x2cb838d)\r\n#35 0x0000557297d2b4a5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0x2cc04a5)\r\n#36 0x0000557295f0611b clang_main(int, char**, llvm::ToolContext const&) (/home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0xe9b11b)\r\n#37 0x0000557295e3609b main (/home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0xdcb09b)\r\n#38 0x00007f5d29df5083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#39 0x0000557295f0099e _start (/home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin/clang+0xe9599e)\r\nclang: error: clang frontend command failed with exit code 134 (use -v to see invocation)\r\nclang version 20.0.0 (https://github.com/llvm/llvm-project.git a861ed411a359b7cb2b58d642e4a7f2fdcf92057)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /home/dyung/src/upstream/a861ed411a359b7cb2b58d642e4a7f2fdcf92057-linux/bin\r\nBuild config: +assertions\r\n```\r\n\r\nBuilding with a compiler built from the commit that immediately preceded this one (37e5319a12ba47c18049728804d3d1e1b10c4eb4), you can see that the compilation succeeds.\r\n```\r\n$ ~/src/upstream/37e5319a12ba47c18049728804d3d1e1b10c4eb4-linux/bin/clang -c -O2 repro.c\r\n$\r\n```",
"author": "dyung",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
|
58e05779b483bb3d9f734bd09f5cb2241431a0b7
|
154330
|
https://github.com/llvm/llvm-project/issues/154330
|
crash
|
b20c291baec94ba3707e92b86836ff1c4bceda8c
| 2025-08-19T13:11:46 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "d67dba5e8880bdd856b0d3812dcdccf8c7902aba",
"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": [
[
473,
480
],
[
482,
492
]
],
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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": [
"cloneForLane"
],
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 d67dba5e8880bdd856b0d3812dcdccf8c7902aba
Author: Florian Hahn <flo@fhahn.com>
Date: Thu Aug 21 11:34:49 2025 +0100
[VPlan] Check Def2LaneDefs first in cloneForLane. (NFC)
If we have entries in Def2LaneDefs, we always have to use it. Move the
check before.
Otherwise we may not pick the correct operand, e.g. if Op was a
replicate recipe that got single-scalar after replicating it.
Fixes https://github.com/llvm/llvm-project/issues/154330.
diff --git a/llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp b/llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp
index 62fd83a5e092..d47d76d20373 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp
@@ -473,8 +473,11 @@ cloneForLane(VPlan &Plan, VPBuilder &Builder, Type *IdxTy,
// Collect the operands at Lane, creating extracts as needed.
SmallVector<VPValue *> NewOps;
for (VPValue *Op : RepR->operands()) {
- if (vputils::isSingleScalar(Op)) {
- NewOps.push_back(Op);
+ // If Op is a definition that has been unrolled, directly use the clone for
+ // the corresponding lane.
+ auto LaneDefs = Def2LaneDefs.find(Op);
+ if (LaneDefs != Def2LaneDefs.end()) {
+ NewOps.push_back(LaneDefs->second[Lane.getKnownLane()]);
continue;
}
if (Lane.getKind() == VPLane::Kind::ScalableLast) {
@@ -482,11 +485,8 @@ cloneForLane(VPlan &Plan, VPBuilder &Builder, Type *IdxTy,
Builder.createNaryOp(VPInstruction::ExtractLastElement, {Op}));
continue;
}
- // If Op is a definition that has been unrolled, directly use the clone for
- // the corresponding lane.
- auto LaneDefs = Def2LaneDefs.find(Op);
- if (LaneDefs != Def2LaneDefs.end()) {
- NewOps.push_back(LaneDefs->second[Lane.getKnownLane()]);
+ if (vputils::isSingleScalar(Op)) {
+ NewOps.push_back(Op);
continue;
}
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/X86/replicate-recipe-with-only-first-lane-used.ll",
"commands": [
"opt -p loop-vectorize -force-vector-width=4 -force-vector-interleave=2 -S %s"
],
"tests": [
{
"test_name": "uniform_load_replicating_select",
"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 float @uniform_load_replicating_select(ptr %A, ptr %B, i64 %0) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]\n %l = load float, ptr %A, align 4\n %c = fcmp ogt float %l, 0.000000e+00\n %gep.B = getelementptr inbounds float, ptr %B, i64 %iv\n %sel.ptr = select i1 %c, ptr %A, ptr %gep.B\n %base = select i1 %c, float 1.000000e+01, float 1.000000e+00\n %l.2 = load float, ptr %sel.ptr, align 4\n %div = fdiv float 4.000000e+00, %l.2\n %pow = tail call float @llvm.pow.f32(float %base, float %div)\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv, %0\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret float %pow\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.pow.f32(float, float) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Assertion in Vectorize/VPlan.cpp \"trying to delete a VPValue with remaining users\"",
"body": "```\n$ clang -c -O2 repro.ll\nclang: .../Linux_x86_64/llvm/lib/Transforms/Vectorize/VPlan.cpp:95: virtual llvm::VPValue::~VPValue(): Assertion `Us\ners.empty() && \"trying to delete a VPValue with remaining users\"' failed. PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, \nand associated run script. \nStack dump: 0. Program arguments: ...//bin/clang -c -O2 repro.ll 1. Optimizer \n2. 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\n-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-inst\ns;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-fi\nxpoint>,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-l\noads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"repro.ll\" \n3. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"_Qtest\" \n #0 0x00000000046945a8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/.../bin/clang+0x4694\n5a8) \n #1 0x00000000046919cc llvm::sys::CleanupOnSignal(unsigned long) (.../bin/clang+0x46919cc)\n #2 0x00000000045de438 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0 \n #3 0x00007fe4b29d7420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420) \n #4 0x00007fe4b25ee00b raise /build/glibc-FcRMwW/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\n #5 0x00007fe4b25cd859 abort /build/glibc-FcRMwW/glibc-2.31/stdlib/abort.c:81:7\n #6 0x00007fe4b25cd729 get_sysdep_segment_value /build/glibc-FcRMwW/glibc-2.31/intl/loadmsgcat.c:509:8\n #7 0x00007fe4b25cd729 _nl_load_domain /build/glibc-FcRMwW/glibc-2.31/intl/loadmsgcat.c:970:34\n #8 0x00007fe4b25defd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6) \n #9 0x0000000005f1d824 llvm::VPValue::~VPValue() (.../bin/clang+0x5f1d824)\n#10 0x0000000005f42356 llvm::VPReplicateRecipe::~VPReplicateRecipe() VPlanRecipes.cpp:0:0\n#11 0x0000000005f476ce llvm::VPRecipeBase::eraseFromParent() (.../bin/clang+0x5f476ce)\n#12 0x0000000005fc3514 llvm::VPlanTransforms::replicateByVF(llvm::VPlan&, llvm::ElementCount) (.../bin/clang+0x5fc3514) \n#13 0x0000000005f02594 llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoo\npVectorizer&, llvm::DominatorTree*, bool) (.../bin/clang+0x5f02594)\n#14 0x0000000005f1691f llvm::LoopVectorizePass::processLoop(llvm::Loop*) (.../bin/clang+0x5f1691\nf)\n#15 0x0000000005f187c0 llvm::LoopVectorizePass::runImpl(llvm::Function&) (.../bin/clang+0x5f187c\n0)\n#16 0x0000000005f18e27 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (.../bin/clang+0x5f18e27)\n#17 0x0000000005b0379e llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::r\nun(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) PassBuilder.cpp:0:0\n...\n```\nReduced reproducer:\n```\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @_Qtest(ptr %0, ptr %1, ptr %2, i64 %3, float %4) {\n br label %6\n\n6: ; preds = %37, %5\n %7 = phi float [ %.0, %37 ], [ 0.000000e+00, %5 ]\n %8 = phi i64 [ %38, %37 ], [ %3, %5 ]\n %9 = icmp sgt i64 %8, 0\n br i1 %9, label %.critedge, label %39\n\n.critedge: ; preds = %6\n %10 = call ptr @llvm.stacksave.p0()\n %11 = load float, ptr %2, align 4\n %12 = fcmp ogt float %11, 0.000000e+00\n br i1 %12, label %13, label %25\n\n13: ; preds = %.critedge\n %14 = load float, ptr %0, align 4\n %15 = fdiv float 0.000000e+00, %14\n %16 = load float, ptr %1, align 4\n %17 = fmul float %14, 0.000000e+00\n %18 = fdiv float %16, %17\n %19 = fadd float %4, %18\n %20 = call float @llvm.pow.f32(float 0.000000e+00, float %15)\n %21 = fmul float %20, 0.000000e+00\n %22 = fmul float %19, %4\n %23 = call float @llvm.exp.f32(float %22)\n %24 = fmul float %21, %23\n br label %37\n\n25: ; preds = %.critedge\n %26 = load float, ptr %1, align 4\n %27 = fdiv float 0.000000e+00, %26\n %28 = load float, ptr %0, align 4\n %29 = fmul float %26, 0.000000e+00\n %30 = fdiv float %28, %29\n %31 = fadd float %4, %30\n %32 = call float @llvm.pow.f32(float %4, float %27)\n %33 = fmul float %32, 0.000000e+00\n %34 = fmul float %31, %4\n %35 = call float @llvm.exp.f32(float %34)\n %36 = fmul float %33, %35\n br label %37\n\n37: ; preds = %25, %13\n %.0 = phi float [ %24, %13 ], [ %36, %25 ]\n call void @llvm.stackrestore.p0(ptr %10)\n %38 = add i64 %8, -1\n br label %6\n\n39: ; preds = %39, %6\n store float %7, ptr %0, align 4\n br label %39\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.pow.f32(float, float) #0\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.exp.f32(float) #0\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn\ndeclare ptr @llvm.stacksave.p0() #1\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn\ndeclare void @llvm.stackrestore.p0(ptr) #1\n\n; uselistorder directives\nuselistorder ptr @llvm.pow.f32, { 1, 0 }\nuselistorder ptr @llvm.exp.f32, { 1, 0 }\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\nattributes #1 = { nocallback nofree nosync nounwind willreturn }\n```\nclang version:\n```\nclang version 22.0.0git (https://github.com/llvm/llvm-project 2f011ea37ad480fdf16e2364e0487409cb4d1c75)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\n```",
"author": "eugeneepshteyn",
"labels": [
"regression",
"vectorizers",
"crash"
],
"comments": [
{
"author": "eugeneepshteyn",
"body": "LLVM build at commit ID 9ddc043538329a0a1386d12e191de7b4c43051e9 is known to work. The issue was introduced sometime after that."
},
{
"author": "fhahn",
"body": "Suspect this is caused by #151487 (7e9989390d95cbb382cb2dc9eb44b37717e23738). Taking a look"
},
{
"author": "eugeneepshteyn",
"body": "Thank you @fhahn , I can confirm that the larger use case that was the source of the reproducer also works now."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
111042
|
https://github.com/llvm/llvm-project/issues/111042
|
crash
|
67c0846357bcd6faca713315380f9981a805a6e5
| 2024-10-03T18:44:33 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "68210c7c269b7b7325dedaea7cea9fe9d979fab5",
"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": [
[
2185,
2190
]
],
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": [
"VPPredInstPHIRecipe::execute"
],
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 68210c7c269b7b7325dedaea7cea9fe9d979fab5
Author: Florian Hahn <flo@fhahn.com>
Date: Sat Oct 5 19:15:05 2024 +0100
[VPlan] Only generate first lane for VPPredInstPHI if no others used.
IF only the first lane of the result is used, only generate the first
lane.
Fixes https://github.com/llvm/llvm-project/issues/111042.
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index 0d092b9c10ac..376b3d33be76 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -2185,6 +2185,9 @@ void VPPredInstPHIRecipe::execute(VPTransformState &State) {
// predicated iteration inserts its generated value in the correct vector.
State.reset(getOperand(0), VPhi);
} else {
+ if (vputils::onlyFirstLaneUsed(this) && !State.Lane->isFirstLane())
+ return;
+
Type *PredInstType = getOperand(0)->getUnderlyingValue()->getType();
PHINode *Phi = State.Builder.CreatePHI(PredInstType, 2);
Phi->addIncoming(PoisonValue::get(ScalarPredInst->getType()),
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/X86/divs-with-tail-folding.ll",
"commands": [
"opt -p loop-vectorize -mtriple x86_64 -prefer-predicate-over-epilogue=predicate-dont-vectorize -mcpu=skylake-avx512 -S %s"
],
"tests": [
{
"test_name": "sdiv_feeding_gep_predicated",
"test_body": "define void @sdiv_feeding_gep_predicated(ptr %dst, i32 %x, i64 %M, i64 %conv6, i64 %N) {\nentry:\n %conv61 = zext i32 %x to i64\n br label %loop\n\nloop: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %c = icmp ule i64 %iv, %M\n br i1 %c, label %then, label %loop.latch\n\nthen: ; preds = %loop\n %div18 = sdiv i64 %M, %conv6\n %conv20 = trunc i64 %div18 to i32\n %mul30 = mul i64 %div18, %conv61\n %sub31 = sub i64 %iv, %mul30\n %conv34 = trunc i64 %sub31 to i32\n %mul35 = mul i32 %x, %conv20\n %add36 = add i32 %mul35, %conv34\n %idxprom = sext i32 %add36 to i64\n %gep = getelementptr double, ptr %dst, i64 %idxprom\n store double 0.000000e+00, ptr %gep, align 8\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop\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.latch\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/X86/drop-poison-generating-flags.ll",
"commands": [
"opt %s -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -S"
],
"tests": [
{
"test_name": "pr70590_recipe_without_underlying_instr",
"test_body": "target datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-pc-linux-gnu\"\n\n@c = external global [5 x i8]\n\ndefine void @pr70590_recipe_without_underlying_instr(i64 %n, ptr noalias %dst) {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %inc, %loop.latch ]\n %cmp = icmp eq i64 %iv, %n\n br i1 %cmp, label %loop.latch, label %then\n\nthen: ; preds = %loop.header\n %rem = srem i64 3, 0\n %add3 = add i64 %rem, -3\n %add5 = add i64 %iv, %add3\n %gep = getelementptr [5 x i8], ptr @c, i64 0, i64 %add5\n %l = load i8, ptr %gep, align 1\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n %sr = phi i8 [ 0, %loop.header ], [ %l, %then ]\n %gep.dst = getelementptr i8, ptr %dst, i64 %iv\n store i8 %sr, ptr %gep.dst, align 4\n %inc = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %inc, 4\n br i1 %exitcond.not, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/X86/replicate-recipe-with-only-first-lane-used.ll",
"commands": [
"opt -p loop-vectorize -force-vector-width=4 -force-vector-interleave=2 -S %s"
],
"tests": [
{
"test_name": "replicate_udiv_with_only_first_lane_used",
"test_body": "target datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @replicate_udiv_with_only_first_lane_used(i32 %x, ptr %dst, i64 %d) {\nentry:\n %c = icmp eq i32 %x, 10\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 true, label %loop.latch, label %else\n\nelse: ; preds = %loop.header\n %div.i = udiv i64 99, %d\n br label %loop.latch\n\nloop.latch: ; preds = %else, %loop.header\n %retval.0.i = phi i64 [ %div.i, %else ], [ 0, %loop.header ]\n %gep = getelementptr i16, ptr %dst, i64 %retval.0.i\n store i16 0, ptr %gep, align 2\n %iv.next = add i64 %iv, 1\n %cmp = icmp ult i64 %iv.next, 101\n br i1 %cmp, label %loop.header, label %exit\n\nexit: ; preds = %loop.latch\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[clang] Assertion failed in VPlan.cpp:258",
"body": "When I compiled the code with -O2 flag, it crashed:\r\n\r\n```c\r\n#include <stdint.h>\r\nstatic uint8_t c[] = {1};\r\nvoid a();\r\nlong b(int h) {\r\n long d = 0;\r\n if (h < 0)\r\n return -1;\r\n int e = 0;\r\n for (int f = 0; f <= h; f++) {\r\n e++;\r\n d += f;\r\n }\r\n long a = d / e;\r\n return a;\r\n}\r\nvoid g();\r\nuint8_t i() {\r\n uint16_t k[4];\r\n int f;\r\n for (; g + f < 4; f++)\r\n k[b(c[0] - 1)] = 5;\r\n for (; f; a(k))\r\n ;\r\n uint8_t *l[3][3], j;\r\n l[0][j] = c;\r\n}\r\n```\r\n\r\nThe crash is:\r\n```\r\nclang: /root/llvm-project/llvm/lib/Transforms/Vectorize/VPlan.cpp:258: llvm::Value* llvm::VPTransformState::get(llvm::VPValue*, bool): Assertion `(VF.isScalar() || Def->isLiveIn() || hasVectorValue(Def) || !vputils::onlyFirstLaneUsed(Def) || (hasScalarValue(Def, VPLane(0)) && Data.VPV2Scalars[Def].size() == 1)) && \"Trying to access a single scalar per part but has multiple scalars \" \"per part.\"' failed.\r\n```\r\n\r\nDetails can be found here: https://godbolt.org/z/fTrKKha5E",
"author": "cardigan1008",
"labels": [
"vectorizers",
"crash",
"regression:19"
],
"comments": [
{
"author": "shafik",
"body": "Looks like a clang-19 regression: https://godbolt.org/z/6d3edKn86"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
106248
|
https://github.com/llvm/llvm-project/issues/106248
|
crash
|
616f7d3d4f6d9bea6f776e357c938847e522a681
| 2024-08-27T17:02:16 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "0a272d3a1703415abca42dc2e2cc2b57cb30734e",
"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": [
[
6529,
6534
]
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"LoopVectorizationCostModel::getInstructionCost"
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 0a272d3a1703415abca42dc2e2cc2b57cb30734e
Author: Florian Hahn <flo@fhahn.com>
Date: Thu Aug 29 12:08:27 2024 +0100
[LV] Use SCEV to analyze second operand for cost query.
Improve operand analysis using SCEV for cost purposes. This fixes a
divergence between legacy and VPlan-based cost-modeling after
533e6bbd0d34.
Fixes https://github.com/llvm/llvm-project/issues/106248.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 56f51e14a6eb..4cc75e2e7546 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -6529,6 +6529,10 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I,
// Certain instructions can be cheaper to vectorize if they have a constant
// second vector operand. One example of this are shifts on x86.
Value *Op2 = I->getOperand(1);
+ if (!isa<Constant>(Op2) && PSE.getSE()->isSCEVable(Op2->getType()) &&
+ isa<SCEVConstant>(PSE.getSCEV(Op2))) {
+ Op2 = cast<SCEVConstant>(PSE.getSCEV(Op2))->getValue();
+ }
auto Op2Info = TTI.getOperandInfo(Op2);
if (Op2Info.Kind == TargetTransformInfo::OK_AnyValue &&
Legal->isInvariant(Op2))
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/X86/cost-constant-known-via-scev.ll",
"commands": [
"opt -p loop-vectorize -S %s"
],
"tests": [
{
"test_name": "test_foldable_live_in_via_scev",
"test_body": "target datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i64 @test_foldable_live_in_via_scev() {\nentry:\n %conv = zext i16 -6 to i64\n %add = add nsw i64 %conv, -65528\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 1, %entry ], [ %iv.next, %loop ]\n %red = phi i64 [ 1, %entry ], [ %mul, %loop ]\n %mul = mul nsw i64 %red, %add\n %iv.next = add nsw i32 %iv, 1\n %ec = icmp eq i32 %iv.next, 100\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n %ret = phi i64 [ %mul, %loop ]\n ret i64 %ret\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[clang] Assertion failed in Vectorize",
"body": "In #105722 , we resolved the assertion failure in vectorization. However, I met this crash again with the following case:\r\n\r\n```c\r\n#include <stdint.h>\r\nint a;\r\nlong b;\r\nstruct e {\r\n uint16_t f;\r\n uint64_t g;\r\n int32_t h\r\n} static i = {65530};\r\nvoid c(int d) {\r\n for (; a; a++)\r\n b *= d;\r\n}\r\nuint32_t j(struct e, uint16_t);\r\nuint64_t k() { j(i, 0); }\r\nuint32_t j(struct e, uint16_t) { c(i.f - 65528); }\r\n```\r\nI compiled it with -O2 flag and it crashed. But when I compiled with -O1/-O0, it worked.\r\n\r\nThe crash is: clang++: /root/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7359: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), BestFactor.Width, CostCtx, OrigLoop, CM)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\n\r\nThe details can be found here: https://godbolt.org/z/8x48xsKs6",
"author": "cardigan1008",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "fhahn",
"body": "Thanks for the report @cardigan1008, should be fixed now"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
88796
|
https://github.com/llvm/llvm-project/issues/88796
|
crash
|
9ef28cf88ca6e45c3ecb75c649463f8797db68d2
| 2024-04-15T21:04:00 |
[
"llvm/test/Transforms/VectorCombine"
] |
{
"fix_commit": "57b9c15227ec15a5e2abf4587d7d0ad536cff9e6",
"components": [
"VectorCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/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": [
[
1961,
1977
]
],
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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::foldTruncFromReductions"
],
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 57b9c15227ec15a5e2abf4587d7d0ad536cff9e6
Author: Ramkumar Ramachandra <r@artagnon.com>
Date: Wed May 8 09:47:55 2024 +0100
VectorCombine: fix logical error after m_Trunc match (#91201)
The matcher m_Trunc() matches an Operator with a given Opcode, which
could either be an Instruction or ConstExpr.
VectorCombine::foldTruncFromReductions() incorrectly assumes that the
pattern matched is always an Instruction, and attempts a cast. Fix this.
Fixes #88796.
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index bbb70134870a..8573a8adf53b 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -1961,17 +1961,17 @@ bool VectorCombine::foldTruncFromReductions(Instruction &I) {
if (!match(ReductionSrc, m_OneUse(m_Trunc(m_Value(TruncSrc)))))
return false;
- auto *Trunc = cast<CastInst>(ReductionSrc);
auto *TruncSrcTy = cast<VectorType>(TruncSrc->getType());
auto *ReductionSrcTy = cast<VectorType>(ReductionSrc->getType());
Type *ResultTy = I.getType();
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
- InstructionCost OldCost =
- TTI.getCastInstrCost(Instruction::Trunc, ReductionSrcTy, TruncSrcTy,
- TTI::CastContextHint::None, CostKind, Trunc) +
- TTI.getArithmeticReductionCost(ReductionOpc, ReductionSrcTy, std::nullopt,
- CostKind);
+ InstructionCost OldCost = TTI.getArithmeticReductionCost(
+ ReductionOpc, ReductionSrcTy, std::nullopt, CostKind);
+ if (auto *Trunc = dyn_cast<CastInst>(ReductionSrc))
+ OldCost +=
+ TTI.getCastInstrCost(Instruction::Trunc, ReductionSrcTy, TruncSrcTy,
+ TTI::CastContextHint::None, CostKind, Trunc);
InstructionCost NewCost =
TTI.getArithmeticReductionCost(ReductionOpc, TruncSrcTy, std::nullopt,
CostKind) +
|
[
{
"file": "llvm/test/Transforms/VectorCombine/pr88796.ll",
"commands": [
"opt -passes=vector-combine -S %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define i32 @test() {\nentry:\n %0 = tail call i16 @llvm.vector.reduce.and.nxv8i16(<vscale x 8 x i16> trunc (<vscale x 8 x i32> splat (i32 268435456) to <vscale x 8 x i16>))\n ret i32 0\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i16 @llvm.vector.reduce.and.nxv8i16(<vscale x 8 x i16>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[VectorCombine] Assertion 'isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"' failed.",
"body": "Reduced LLVM IR:\r\n```llvm ir\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine i32 @main() #0 {\r\nentry:\r\n %0 = tail call i16 @llvm.vector.reduce.and.nxv8i16(<vscale x 8 x i16> trunc (<vscale x 8 x i32> shufflevector (<vscale x 8 x i32> insertelement (<vscale x 8 x i32> poison, i32 268435456, i64 0), <vscale x 8 x i32> poison, <vscale x 8 x i32> zeroinitializer) to <vscale x 8 x i16>))\r\n ret i32 0\r\n}\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\r\ndeclare i16 @llvm.vector.reduce.and.nxv8i16(<vscale x 8 x i16>) #1\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl256b,+zvl32b,+zvl64b,-e,-experimental-smmpm,-experimental-smnpm,-experimental-ssnpm,-experimental-sspm,-experimental-ssqosid,-experimental-supm,-experimental-zaamo,-experimental-zabha,-experimental-zalasr,-experimental-zalrsc,-experimental-zfbfmin,-experimental-zicfilp,-experimental-zicfiss,-experimental-ztso,-experimental-zvfbfmin,-experimental-zvfbfwma,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smepmp,-ssaia,-ssccptr,-sscofpmf,-sscounterenw,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-za128rs,-za64rs,-zacas,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-zmmul,-zvbb,-zvbc,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\nattributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\r\n```\r\nGodbolt: https://godbolt.org/z/jrEv178Ev\r\n\r\nBacktrace:\r\n```\r\nopt: /scratch/tc-testing/tc-apr-15/llvm/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From*) [with To = llvm::CastInst; From = llvm::Value]: Assertion `isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/opt --passes=vector-combine reduced.ll\r\n #0 0x00005eb857c5a1b0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/opt+0x2da91b0)\r\n #1 0x00005eb857c575bf llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/opt+0x2da65bf)\r\n #2 0x00005eb857c57715 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x000071f7d0e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x000071f7d0e969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x000071f7d0e969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x000071f7d0e969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x000071f7d0e42476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x000071f7d0e287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x000071f7d0e2871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x000071f7d0e39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x00005eb856da36eb (anonymous namespace)::VectorCombine::run()::'lambda'(llvm::Instruction&)::operator()(llvm::Instruction&) const VectorCombine.cpp:0:0\r\n#12 0x00005eb856da4290 llvm::VectorCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/opt+0x1ef3290)\r\n#13 0x00005eb855bc7936 llvm::detail::PassModel<llvm::Function, llvm::VectorCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/opt+0xd16936)\r\n#14 0x00005eb857a7f451 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/opt+0x2bce451)\r\n#15 0x00005eb855bbec26 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/opt+0xd0dc26)\r\n#16 0x00005eb857a7e12b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/opt+0x2bcd12b)\r\n#17 0x00005eb855bc6ee6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/opt+0xd15ee6)\r\n#18 0x00005eb857a7bf61 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/opt+0x2bcaf61)\r\n#19 0x00005eb855440205 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/opt+0x58f205)\r\n#20 0x00005eb855432836 optMain (/scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/opt+0x581836)\r\n#21 0x000071f7d0e29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#22 0x000071f7d0e29e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#23 0x000071f7d0e29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#24 0x00005eb8554284b5 _start (/scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/opt+0x5774b5)\r\nzsh: IOT instruction /scratch/tc-testing/tc-apr-15/build-rv64gcv/build-llvm-linux/bin/op\r\n```\r\n\r\nFound via fuzzer.",
"author": "patrick-rivos",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
98838
|
https://github.com/llvm/llvm-project/issues/98838
|
miscompilation
|
9ba9e480fa4ef1f37a2b6b51603ac8e446cca5ff
| 2024-07-14T21:26:59 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "beccecaacde405a3b50891c67594eccbcd1c8b08",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
14201,
14209
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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 beccecaacde405a3b50891c67594eccbcd1c8b08
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Mon Jul 15 07:03:22 2024 -0700
[SLP]Fix PR98838: do no replace condition of select-based logical op by poison.
If the reduction operation is a select-based logical op, the condition
should be replaced by the poison, better to replace by the non-poisoning
constant to prevent poison propagation in the vector code.
Fixes https://github.com/llvm/llvm-project/issues/98838
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 5c2fc0b9320e..74a16d3fbcad 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -14201,9 +14201,23 @@ Value *BoUpSLP::vectorizeTree(
for (Instruction *I : RemovedInsts) {
if (getTreeEntry(I)->Idx != 0)
continue;
+ SmallVector<SelectInst *> LogicalOpSelects;
I->replaceUsesWithIf(PoisonValue::get(I->getType()), [&](Use &U) {
+ // Do not replace condition of the logical op in form select <cond>.
+ bool IsPoisoningLogicalOp = isa<SelectInst>(U.getUser()) &&
+ (match(U.getUser(), m_LogicalAnd()) ||
+ match(U.getUser(), m_LogicalOr())) &&
+ U.getOperandNo() == 0;
+ if (IsPoisoningLogicalOp) {
+ LogicalOpSelects.push_back(cast<SelectInst>(U.getUser()));
+ return false;
+ }
return UserIgnoreList->contains(U.getUser());
});
+ // Replace conditions of the poisoning logical ops with the non-poison
+ // constant value.
+ for (SelectInst *SI : LogicalOpSelects)
+ SI->setCondition(Constant::getNullValue(SI->getCondition()->getType()));
}
}
// Retain to-be-deleted instructions for some debug-info bookkeeping and alias
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/select-reduction-op.ll",
"commands": [
"opt -S --passes=slp-vectorizer < %s"
],
"tests": [
{
"test_name": "src",
"test_body": "define i1 @src(i1 %cmp4.118.i) {\n %cmp4.118.i.not = xor i1 %cmp4.118.i, true\n %brmerge = select i1 %cmp4.118.i.not, i1 true, i1 poison\n %.not = xor i1 poison, true\n %brmerge2 = select i1 %brmerge, i1 true, i1 %.not\n %.not3 = xor i1 poison, true\n %brmerge4 = select i1 %brmerge2, i1 true, i1 %.not3\n %.not5 = xor i1 poison, true\n %brmerge6 = select i1 %brmerge4, i1 true, i1 %.not5\n %.not7 = xor i1 poison, true\n %brmerge8 = select i1 %brmerge6, i1 true, i1 %.not7\n ret i1 %brmerge8\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "wrong code at -O3 on x86_64-linux-gnu",
"body": "It appears to be a recent regression as it doesn't reproduce with 18.1.0 and earlier. \r\n\r\nCompiler Explorer: https://godbolt.org/z/fzsqjEPWW\r\n\r\n```\r\n[562] % clangtk -v\r\nclang version 19.0.0git (https://github.com/llvm/llvm-project.git 52139d8f9a4e3f595ca552393d62ba06b0bc082c)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\r\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nCandidate multilib: .;@m64\r\nSelected multilib: .;@m64\r\n[563] % \r\n[563] % clangtk -O2 -w small.c\r\n[564] % ./a.out\r\n0\r\n[565] % clangtk -O3 -w small.c\r\n[566] % ./a.out\r\n[567] % \r\n[567] % cat small.c\r\nint printf(const char *, ...);\r\nint a, b, e, g;\r\nvolatile int c;\r\nstatic int d[1] = {1}, f;\r\nint h() {\r\n for (b = 0; b < 4; b++) {\r\n for (e = 0; e < 4; e++)\r\n while (b) {\r\n if (c > 0 && d[1])\r\n break;\r\n return f;\r\n }\r\n }\r\n return 0;\r\n}\r\nvoid i() {\r\n int *j[1];\r\n j[g] = &d[0];\r\n}\r\nint main() {\r\n h();\r\n printf(\"%d\\n\", a);\r\n return 0;\r\n}\r\n```\r\n\r\n",
"author": "zhendongsu",
"labels": [
"miscompilation",
"llvm:SLPVectorizer",
"confirmed"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Reproducer: https://alive2.llvm.org/ce/z/Whfr_a\r\n```\r\n; bin/opt -passes=slp-vectorizer -S test.ll\r\ndefine i1 @src(i1 %cmp4.118.i) {\r\n %cmp4.118.i.not = xor i1 %cmp4.118.i, true\r\n %brmerge = select i1 %cmp4.118.i.not, i1 true, i1 poison\r\n %.not = xor i1 poison, true\r\n %brmerge2 = select i1 %brmerge, i1 true, i1 %.not\r\n %.not3 = xor i1 poison, true\r\n %brmerge4 = select i1 %brmerge2, i1 true, i1 %.not3\r\n %.not5 = xor i1 poison, true\r\n %brmerge6 = select i1 %brmerge4, i1 true, i1 %.not5\r\n %.not7 = xor i1 poison, true\r\n %brmerge8 = select i1 %brmerge6, i1 true, i1 %.not7\r\n ret i1 %brmerge8\r\n}\r\n```\r\n```\r\ndefine i1 @tgt(i1 %cmp4.118.i) {\r\n %1 = insertelement <4 x i1> <i1 poison, i1 true, i1 true, i1 true>, i1 %cmp4.118.i, i32 0\r\n %2 = xor <4 x i1> %1, <i1 true, i1 poison, i1 poison, i1 poison>\r\n %.not7 = xor i1 poison, true\r\n %3 = freeze <4 x i1> %2\r\n %4 = call i1 @llvm.vector.reduce.or.v4i1(<4 x i1> %3)\r\n %op.rdx = select i1 %4, i1 true, i1 %.not7\r\n %op.rdx1 = select i1 poison, i1 true, i1 %op.rdx\r\n ret i1 %op.rdx1\r\n}\r\n```\r\ncc @alexey-bataev "
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
108697
|
https://github.com/llvm/llvm-project/issues/108697
|
crash
|
848cb21ddca5dc4d8c52e487264936be8f1bfe8d
| 2024-09-14T13:01:28 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "9de327c94d0c995803b6485fb28ac4cad1e53bbe",
"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": [
[
6551,
6564
]
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
"LoopVectorizationCostModel::getInstructionCost"
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 9de327c94d0c995803b6485fb28ac4cad1e53bbe
Author: Florian Hahn <flo@fhahn.com>
Date: Wed Oct 2 20:16:41 2024 +0100
[LV] Generalize predication checks from 2c8836c899 for operands.
This fixes another case where the VPlan-based and legacy cost models
disagree. If any of the operands is predicated, it can't be trivially
hoisted and we should consider the cost for evaluating it each loop
iteration.
Fixes https://github.com/llvm/llvm-project/issues/108697.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index de3b981a4fe3..6e082b1c134d 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -6551,14 +6551,17 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I,
Op2 = cast<SCEVConstant>(PSE.getSCEV(Op2))->getValue();
}
auto Op2Info = TTI.getOperandInfo(Op2);
- auto IsInvariant = [this](Value *Op) {
+ std::function<bool(Value *)> IsInvariant =
+ [this, &IsInvariant](Value *Op) -> bool {
if (!Legal->isInvariant(Op))
return false;
- // Consider Op2 invariant, if it is not a predicated instruction in the
- // loop. In that case, it is not trivially hoistable.
+ // Consider Op2invariant, if it or its operands aren't predicated
+ // instruction in the loop. In that case, it is not trivially hoistable.
return !isa<Instruction>(Op) ||
!TheLoop->contains(cast<Instruction>(Op)) ||
- !isPredicatedInst(cast<Instruction>(Op));
+ (!isPredicatedInst(cast<Instruction>(Op)) &&
+ all_of(cast<Instruction>(Op)->operands(),
+ [&IsInvariant](Value *Op) { return IsInvariant(Op); }));
};
if (Op2Info.Kind == TargetTransformInfo::OK_AnyValue && IsInvariant(Op2))
Op2Info.Kind = TargetTransformInfo::OK_UniformValue;
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/X86/predicated-instruction-cost.ll",
"commands": [
"opt -p loop-vectorize -S %s"
],
"tests": [
{
"test_name": "predicated_urem_shl_cost",
"test_body": "target datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @predicated_urem_shl_cost(ptr %A, i32 %x, i1 %c) {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i32 [ 1, %entry ], [ %iv.next, %loop.latch ]\n %gep = getelementptr inbounds i32, ptr %A, i32 %iv\n %l = load i32, ptr %gep, align 4\n br i1 %c, label %then, label %loop.latch\n\nthen: ; preds = %loop.header\n %rem = urem i32 2, %x\n %shl = shl i32 %l, %rem\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n %p = phi i32 [ 0, %loop.header ], [ %shl, %then ]\n store i32 %p, ptr %gep, align 4\n %iv.next = add i32 %iv, 1\n %ec = icmp eq i32 %iv, 0\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
},
{
"test_name": "test_wide_shift_uses_predicated_invariant_instruction",
"test_body": "target datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @test_wide_shift_uses_predicated_invariant_instruction(i32 %d, i1 %c, ptr %dst) {\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 %loop.latch, label %else\n\nelse: ; preds = %loop.header\n %rem = urem i32 100, %d\n %sext = shl i32 %rem, 12\n %shl.i = shl i32 999, %sext\n br label %loop.latch\n\nloop.latch: ; preds = %else, %loop.header\n %p = phi i32 [ %shl.i, %else ], [ 0, %loop.header ]\n %gep = getelementptr inbounds i32, ptr %dst, i32 %iv\n store i32 %p, ptr %gep, align 4\n %iv.next = add i32 %iv, 1\n %ec = icmp eq i32 %iv.next, 100\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "clang crashes on valid code at -O{2,3} on x86_64-linux-gnu: Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop)) && \" VPlan cost model and legacy cost model disagreed\"' failed ",
"body": "Compiler Explorer: https://godbolt.org/z/9K4a3Pr7j\r\n\r\n```\r\n[508] % clangtk -v\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git 223e2efa5e886502a9467b7ef700ebce9b7886e8)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\r\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nCandidate multilib: .;@m64\r\nSelected multilib: .;@m64\r\n[509] % \r\n[509] % clangtk -O2 small.c\r\nclang-20: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7390: 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.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/20240914-clangtk-m64-O3-build-061621/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20240914-clangtk-m64-O3-build-061621/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/20 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-34578e.o -x c small.c\r\n1.\t<eof> parser at end of file\r\n2.\tOptimizer\r\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"small.c\"\r\n4.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\r\n #0 0x000055ba1845c4ff llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x43484ff)\r\n #1 0x000055ba18459a34 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007fbbfabd4420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #3 0x00007fbbfa60b00b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #4 0x00007fbbfa5ea859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\r\n #5 0x00007fbbfa5ea729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #6 0x00007fbbfa5ea729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #7 0x00007fbbfa5fbfd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #8 0x000055ba19db5fcb llvm::LoopVectorizationPlanner::computeBestVF() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5ca1fcb)\r\n #9 0x000055ba19dd169a llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5cbd69a)\r\n#10 0x000055ba19dd42d1 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5cc02d1)\r\n#11 0x000055ba19dd4943 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5cc0943)\r\n#12 0x000055ba19946a06 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5832a06)\r\n#13 0x000055ba17dec0d1 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3cd80d1)\r\n#14 0x000055ba15926546 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x1812546)\r\n#15 0x000055ba17deaa3d llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3cd6a3d)\r\n#16 0x000055ba15925216 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x1811216)\r\n#17 0x000055ba17dea471 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3cd6471)\r\n#18 0x000055ba18713673 (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 0x000055ba187167f8 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x46027f8)\r\n#20 0x000055ba18decf5c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4cd8f5c)\r\n#21 0x000055ba1ac8966c clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x6b7566c)\r\n#22 0x000055ba18ded378 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4cd9378)\r\n#23 0x000055ba1908a659 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4f76659)\r\n#24 0x000055ba1900c07e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4ef807e)\r\n#25 0x000055ba191772b6 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x50632b6)\r\n#26 0x000055ba154f2b15 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13deb15)\r\n#27 0x000055ba154ebbba ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#28 0x000055ba154ef58e clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13db58e)\r\n#29 0x000055ba153dd43b main (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x12c943b)\r\n#30 0x00007fbbfa5ec083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#31 0x000055ba154eb64e _start (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13d764e)\r\nclangtk: error: unable to execute command: Aborted\r\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git 223e2efa5e886502a9467b7ef700ebce9b7886e8)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nclangtk: note: diagnostic msg: \r\n********************\r\n\r\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\r\nPreprocessed source(s) and associated run script(s) are located at:\r\nclangtk: note: diagnostic msg: /tmp/small-682958.c\r\nclangtk: note: diagnostic msg: /tmp/small-682958.sh\r\nclangtk: note: diagnostic msg: \r\n\r\n********************\r\n[510] % \r\n[510] % cat small.c\r\nshort a, b, c, d;\r\nunsigned short e;\r\nint main() {\r\n for (; d; d++) {\r\n e = a + b;\r\n c = b > 3 || e > b ? e : e << b;\r\n c = c ? 2 / c : 0;\r\n b = 1;\r\n }\r\n return 0;\r\n}\r\n```",
"author": "zhendongsu",
"labels": [
"vectorizers",
"crash-on-valid"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
128838
|
https://github.com/llvm/llvm-project/issues/128838
|
crash
|
9c65e6ac115a7d8566c874537791125c3ace7c1a
| 2025-02-26T07:25:33 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "62994c3291239f3d11f958d002319b2bd6eddbc9",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
7691,
7701
]
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
[
2180,
2186
],
[
2189,
2206
],
[
2210,
2219
]
],
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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": [
[
189,
196
]
],
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.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::executePlan"
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"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::handleUncountableEarlyExit",
"VPlanTransforms::materializeLiveInBroadcasts"
],
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 62994c3291239f3d11f958d002319b2bd6eddbc9
Author: Florian Hahn <flo@fhahn.com>
Date: Wed Mar 12 22:03:18 2025 +0000
[VPlan] Also introduce explicit broadcasts for values from entry VPBB.
Update and generalize materializeBroadcasts to also introduce explicit
broadcasts for VPValues defined in the Plans Entry block.
This fixes a crash when trying to insert the broadcasts generated by
VPTransformState::get after the generating instruction, which isn't
possible after invoke instructions.
Fixes https://github.com/llvm/llvm-project/issues/128838.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index bab2c6efd403..02bacde3f60a 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7691,11 +7691,11 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
((VectorizingEpilogue && ExpandedSCEVs) ||
(!VectorizingEpilogue && !ExpandedSCEVs)) &&
"expanded SCEVs to reuse can only be used during epilogue vectorization");
- VPlanTransforms::materializeLiveInBroadcasts(BestVPlan);
// TODO: Move to VPlan transform stage once the transition to the VPlan-based
// cost model is complete for better cost estimates.
VPlanTransforms::runPass(VPlanTransforms::unrollByUF, BestVPlan, BestUF,
OrigLoop->getHeader()->getContext());
+ VPlanTransforms::materializeBroadcasts(BestVPlan);
VPlanTransforms::optimizeForVFAndUF(BestVPlan, BestVF, BestUF, PSE);
VPlanTransforms::simplifyRecipes(BestVPlan, *Legal->getWidestInductionType());
VPlanTransforms::removeDeadRecipes(BestVPlan);
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index ecf52673480e..f23795f87d46 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -2180,7 +2180,7 @@ void VPlanTransforms::handleUncountableEarlyExit(
LatchExitingBranch->eraseFromParent();
}
-void VPlanTransforms::materializeLiveInBroadcasts(VPlan &Plan) {
+void VPlanTransforms::materializeBroadcasts(VPlan &Plan) {
if (Plan.hasScalarVFOnly())
return;
@@ -2189,18 +2189,25 @@ void VPlanTransforms::materializeLiveInBroadcasts(VPlan &Plan) {
VPDT.recalculate(Plan);
#endif
+ SmallVector<VPValue *> VPValues;
+ append_range(VPValues, Plan.getLiveIns());
+ for (VPRecipeBase &R : *Plan.getEntry())
+ append_range(VPValues, R.definedValues());
+
auto *VectorPreheader = Plan.getVectorPreheader();
- for (VPValue *LiveIn : Plan.getLiveIns()) {
- if (all_of(LiveIn->users(),
- [LiveIn](VPUser *U) { return U->usesScalars(LiveIn); }) ||
- !LiveIn->getLiveInIRValue() ||
- isa<Constant>(LiveIn->getLiveInIRValue()))
+ for (VPValue *VPV : VPValues) {
+ if (all_of(VPV->users(),
+ [VPV](VPUser *U) { return U->usesScalars(VPV); }) ||
+ (VPV->isLiveIn() &&
+ (!VPV->getLiveInIRValue() || isa<Constant>(VPV->getLiveInIRValue()))))
continue;
// Add explicit broadcast at the insert point that dominates all users.
VPBasicBlock *HoistBlock = VectorPreheader;
VPBasicBlock::iterator HoistPoint = VectorPreheader->end();
- for (VPUser *User : LiveIn->users()) {
+ for (VPUser *User : VPV->users()) {
+ if (User->usesScalars(VPV))
+ continue;
if (cast<VPRecipeBase>(User)->getParent() == VectorPreheader)
HoistPoint = HoistBlock->begin();
else
@@ -2210,10 +2217,10 @@ void VPlanTransforms::materializeLiveInBroadcasts(VPlan &Plan) {
}
VPBuilder Builder(cast<VPBasicBlock>(HoistBlock), HoistPoint);
- auto *Broadcast = Builder.createNaryOp(VPInstruction::Broadcast, {LiveIn});
- LiveIn->replaceUsesWithIf(
- Broadcast, [LiveIn, Broadcast](VPUser &U, unsigned Idx) {
- return Broadcast != &U && !U.usesScalars(LiveIn);
- });
+ auto *Broadcast = Builder.createNaryOp(VPInstruction::Broadcast, {VPV});
+ VPV->replaceUsesWithIf(Broadcast,
+ [VPV, Broadcast](VPUser &U, unsigned Idx) {
+ return Broadcast != &U && !U.usesScalars(VPV);
+ });
}
}
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.h b/llvm/lib/Transforms/Vectorize/VPlanTransforms.h
index 8a9a81e00fe2..2ec07eea1ecc 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.h
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.h
@@ -189,8 +189,8 @@ struct VPlanTransforms {
optimizeInductionExitUsers(VPlan &Plan,
DenseMap<VPValue *, VPValue *> &EndValues);
- /// Add explicit broadcasts for live-ins used as vectors.
- static void materializeLiveInBroadcasts(VPlan &Plan);
+ /// Add explicit broadcasts for live-ins and VPValues defined in \p Plan's entry block if they are used as vectors.
+ static void materializeBroadcasts(VPlan &Plan);
};
} // namespace llvm
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/RISCV/illegal-type.ll",
"commands": [
"opt < %s -passes=loop-vectorize -mattr=+v -force-vector-width=4 -scalable-vectorization=on -S 2>&1"
],
"tests": [
{
"test_name": "uniform_store_i1",
"test_body": "target triple = \"riscv64-linux-gnu\"\n\ndefine void @uniform_store_i1(ptr noalias %dst, ptr noalias %start, i64 %N) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %first.sroa = phi ptr [ %incdec.ptr, %for.body ], [ %start, %entry ]\n %iv = phi i64 [ %iv.next, %for.body ], [ 0, %entry ]\n %iv.next = add i64 %iv, 1\n %incdec.ptr = getelementptr inbounds i64, ptr %first.sroa, i64 1\n %cmp.not = icmp eq ptr %incdec.ptr, %start\n store i1 %cmp.not, ptr %dst, align 1\n %cmp = icmp ult i64 %iv, %N\n br i1 %cmp, label %for.body, label %end, !llvm.loop !0\n\nend: ; preds = %for.body\n ret void\n}\n\n!0 = distinct !{!0, !1}\n!1 = !{!\"llvm.loop.vectorize.scalable.enable\", i1 true}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/X86/epilog-vectorization-inductions.ll",
"commands": [
"opt -passes=loop-vectorize -mcpu=znver2 -S %s"
],
"tests": [
{
"test_name": "test_induction_step_needs_expansion",
"test_body": "target triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @test_induction_step_needs_expansion(ptr noalias %j, ptr %k, i64 %l, i16 %off) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %p.09 = phi i16 [ 0, %entry ], [ %add, %loop ]\n %add = sub i16 %p.09, %off\n %arrayidx3 = getelementptr inbounds i16, ptr %k, i64 %iv\n store i16 %add, ptr %arrayidx3, align 2\n %iv.next = add nuw nsw i64 %iv, 1\n %ec = icmp eq i64 %iv.next, %l\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/X86/induction-step.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-width=4 -S %s"
],
"tests": [
{
"test_name": "wide_add_induction_step_live_in",
"test_body": "target triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i16 @wide_add_induction_step_live_in(ptr %dst, i64 %N, i16 %off) {\nentry:\n %o.1 = add i16 %off, 2\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.2 = phi i16 [ 0, %entry ], [ %add, %loop ]\n %add = add i16 %iv.2, %o.1\n %gep.dst = getelementptr inbounds i16, ptr %dst, i64 %iv\n store i16 %add, ptr %gep.dst, align 2\n %iv.next = add nuw nsw i64 %iv, 1\n %ec = icmp eq i64 %iv.next, %N\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i16 %add\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "wide_sub_induction_step_live_in",
"test_body": "target triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i16 @wide_sub_induction_step_live_in(ptr %dst, i64 %N, i16 %off) {\nentry:\n %o.1 = add i16 %off, 2\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.2 = phi i16 [ 0, %entry ], [ %sub, %loop ]\n %sub = sub i16 %iv.2, %o.1\n %gep.dst = getelementptr inbounds i16, ptr %dst, i64 %iv\n store i16 %sub, ptr %gep.dst, align 2\n %iv.next = add nuw nsw i64 %iv, 1\n %ec = icmp eq i64 %iv.next, %N\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i16 %sub\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/expand-scev-after-invoke.ll",
"commands": [
"opt -p loop-vectorize -force-vector-width=4 -force-vector-interleave=2 -S %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndeclare i32 @foo()\n\n; Test case for https://github.com/llvm/llvm-project/issues/128838. Make sure\n; we do not crash when expanding %step.\ndefine void @test(ptr %dst) personality ptr null {\n;\nentry:\n %step = invoke i32 @foo()\n to label %loop unwind label %lpad\n\nloop:\n %iv.1 = phi i64 [ 0, %entry ], [ %add, %loop ]\n %iv.2 = phi i32 [ 0, %entry ], [ %iv.2.next, %loop ]\n %add = add i64 %iv.1, 1\n %gep = getelementptr inbounds i32, ptr %dst, i64 %iv.1\n store i32 %iv.2, ptr %gep, align 8\n %iv.2.next = add i32 %iv.2, %step\n %ec = icmp ult i64 %iv.1, 161\n br i1 %ec, label %loop, label %exit\n\nexit:\n ret void\n\nlpad:\n %landingpad = landingpad { ptr, i32 }\n cleanup\n ret void\n}",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/float-induction.ll",
"commands": [
"opt < %s -passes=loop-vectorize,dce,instcombine -force-vector-interleave=1 -force-vector-width=4 -S",
"opt < %s -passes=loop-vectorize,dce,instcombine -force-vector-interleave=2 -force-vector-width=4 -S",
"opt < %s -passes=loop-vectorize,dce,instcombine -force-vector-interleave=2 -force-vector-width=1 -S",
"opt < %s -passes=loop-vectorize,dce,simplifycfg,instcombine,simplifycfg -force-vector-interleave=1 -force-vector-width=2 -simplifycfg-require-and-preserve-domtree=1 -keep-loops=false -S"
],
"tests": [
{
"test_name": "fp_iv_loop1_fast_FMF",
"test_body": "@fp_inc = external global float, align 4\n\ndefine void @fp_iv_loop1_fast_FMF(float %init, ptr noalias captures(none) %A, i32 %N) {\nentry:\n %cmp4 = icmp sgt i32 %N, 0\n br i1 %cmp4, label %for.body.lr.ph, label %for.end\n\nfor.body.lr.ph: ; preds = %entry\n %fpinc = load float, ptr @fp_inc, align 4\n br label %for.body\n\nfor.body: ; preds = %for.body, %for.body.lr.ph\n %indvars.iv = phi i64 [ 0, %for.body.lr.ph ], [ %indvars.iv.next, %for.body ]\n %x.05 = phi float [ %init, %for.body.lr.ph ], [ %add, %for.body ]\n %arrayidx = getelementptr inbounds float, ptr %A, i64 %indvars.iv\n store float %x.05, ptr %arrayidx, align 4\n %add = fsub fast float %x.05, %fpinc\n %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1\n %lftr.wideiv = trunc i64 %indvars.iv.next to i32\n %exitcond = icmp eq i32 %lftr.wideiv, %N\n br i1 %exitcond, label %for.end.loopexit, label %for.body\n\nfor.end.loopexit: ; preds = %for.body\n br label %for.end\n\nfor.end: ; preds = %for.end.loopexit, %entry\n ret void\n}\n\n!llvm.module.flags = !{!0}\n\n!0 = !{i32 2, !\"Debug Info Version\", i32 3}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "fp_iv_loop3",
"test_body": "@fp_inc = external global float, align 4\n\ndefine void @fp_iv_loop3(float %init, ptr noalias captures(none) %A, ptr noalias captures(none) %B, ptr noalias captures(none) %C, i32 %N) {\nentry:\n %cmp9 = icmp sgt i32 %N, 0\n br i1 %cmp9, label %for.body.lr.ph, label %for.end\n\nfor.body.lr.ph: ; preds = %entry\n %0 = load float, ptr @fp_inc, align 4\n br label %for.body\n\nfor.body: ; preds = %for.body, %for.body.lr.ph\n %indvars.iv = phi i64 [ 0, %for.body.lr.ph ], [ %indvars.iv.next, %for.body ]\n %y.012 = phi float [ 0x3FB99999A0000000, %for.body.lr.ph ], [ %conv1, %for.body ]\n %x.011 = phi float [ %init, %for.body.lr.ph ], [ %add, %for.body ]\n %arrayidx = getelementptr inbounds float, ptr %A, i64 %indvars.iv\n store float %x.011, ptr %arrayidx, align 4\n %add = fadd fast float %x.011, %0\n %conv1 = fadd fast float %y.012, -5.000000e-01\n %add2 = fadd fast float %conv1, %add\n %arrayidx4 = getelementptr inbounds float, ptr %B, i64 %indvars.iv\n store float %add2, ptr %arrayidx4, align 4\n %arrayidx6 = getelementptr inbounds float, ptr %C, i64 %indvars.iv\n store float %conv1, ptr %arrayidx6, align 4\n %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1\n %lftr.wideiv = trunc i64 %indvars.iv.next to i32\n %exitcond = icmp eq i32 %lftr.wideiv, %N\n br i1 %exitcond, label %for.end.loopexit, label %for.body\n\nfor.end.loopexit: ; preds = %for.body\n br label %for.end\n\nfor.end: ; preds = %for.end.loopexit, %entry\n ret void\n}\n\n!llvm.module.flags = !{!0}\n\n!0 = !{i32 2, !\"Debug Info Version\", i32 3}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "fp_iv_loop1_reassoc_FMF",
"test_body": "@fp_inc = external global float, align 4\n\ndefine void @fp_iv_loop1_reassoc_FMF(float %init, ptr noalias captures(none) %A, i32 %N) {\nentry:\n %cmp4 = icmp sgt i32 %N, 0\n br i1 %cmp4, label %for.body.lr.ph, label %for.end\n\nfor.body.lr.ph: ; preds = %entry\n %fpinc = load float, ptr @fp_inc, align 4\n br label %for.body\n\nfor.body: ; preds = %for.body, %for.body.lr.ph\n %indvars.iv = phi i64 [ 0, %for.body.lr.ph ], [ %indvars.iv.next, %for.body ]\n %x.05 = phi float [ %init, %for.body.lr.ph ], [ %add, %for.body ]\n %arrayidx = getelementptr inbounds float, ptr %A, i64 %indvars.iv\n store float %x.05, ptr %arrayidx, align 4\n %add = fsub reassoc float %x.05, %fpinc\n %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1\n %lftr.wideiv = trunc i64 %indvars.iv.next to i32\n %exitcond = icmp eq i32 %lftr.wideiv, %N\n br i1 %exitcond, label %for.end.loopexit, label %for.body\n\nfor.end.loopexit: ; preds = %for.body\n br label %for.end\n\nfor.end: ; preds = %for.end.loopexit, %entry\n ret void\n}\n\n!llvm.module.flags = !{!0}\n\n!0 = !{i32 2, !\"Debug Info Version\", i32 3}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/induction-step.ll",
"commands": [
"opt < %s -passes=loop-vectorize -force-vector-interleave=1 -force-vector-width=8 -S"
],
"tests": [
{
"test_name": "wide_add_induction_step_live_in",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine void @wide_add_induction_step_live_in(ptr %dst, i64 %N, i16 %off) {\nentry:\n %o.1 = add i16 %off, 2\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.2 = phi i16 [ 0, %entry ], [ %add, %loop ]\n %add = add i16 %iv.2, %o.1\n %gep.dst = getelementptr inbounds i16, ptr %dst, i64 %iv\n store i16 %add, ptr %gep.dst, align 2\n %iv.next = add nuw nsw i64 %iv, 1\n %ec = icmp eq i64 %iv.next, %N\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/induction.ll",
"commands": [
"opt < %s -passes=loop-vectorize -force-vector-interleave=1 -force-vector-width=2 -force-widen-divrem-via-safe-divisor=0 -S",
"opt < %s -passes=loop-vectorize,instcombine -force-vector-interleave=1 -force-vector-width=2 -force-widen-divrem-via-safe-divisor=0 -S",
"opt < %s -passes=loop-vectorize,instcombine -force-vector-interleave=2 -force-vector-width=2 -force-widen-divrem-via-safe-divisor=0 -S",
"opt < %s -passes=loop-vectorize -force-vector-interleave=2 -force-vector-width=2 -force-widen-divrem-via-safe-divisor=0 -S",
"opt < %s -passes=loop-vectorize,instcombine -force-vector-interleave=2 -force-vector-width=4 -force-widen-divrem-via-safe-divisor=0 -enable-interleaved-mem-accesses -S"
],
"tests": [
{
"test_name": "test_optimized_cast_induction_feeding_first_order_recurrence",
"test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine void @test_optimized_cast_induction_feeding_first_order_recurrence(i64 %n, i32 %step, ptr %ptr) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %for = phi i32 [ 0, %entry ], [ %iv.2.conv, %loop ]\n %iv.1 = phi i64 [ 0, %entry ], [ %iv.1.next, %loop ]\n %iv.2 = phi i32 [ 0, %entry ], [ %iv.2.next, %loop ]\n %iv.2.ext = shl i32 %iv.2, 24\n %iv.2.conv = ashr exact i32 %iv.2.ext, 24\n %gep = getelementptr inbounds i32, ptr %ptr, i64 %iv.1\n store i32 %for, ptr %gep, align 4\n %iv.2.next = add nsw i32 %iv.2.conv, %step\n %iv.1.next = add nuw nsw i64 %iv.1, 1\n %exitcond = icmp eq i64 %iv.1.next, %n\n br i1 %exitcond, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Assertion `!NodePtr->isKnownSentinel()' failed.",
"body": "To reproduce run opt with the test below, -passes=loop-vectorize\n```\n; ModuleID = './reduced.ll'\nsource_filename = \"./reduced.ll\"\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @wombat() gc \"statepoint-example\" personality ptr null {\nbb:\n %invoke = invoke i32 null(ptr addrspace(1) null, i32 0, i32 0, i32 0)\n to label %bb1 unwind label %bb5\n\nbb1: ; preds = %bb1, %bb\n %phi = phi i64 [ %add, %bb1 ], [ 0, %bb ]\n %phi2 = phi i32 [ %add3, %bb1 ], [ 0, %bb ]\n %add = add i64 %phi, 1\n %sitofp = sitofp i32 %phi2 to double\n store double %sitofp, ptr addrspace(1) null, align 8\n %add3 = add i32 %phi2, %invoke\n %icmp = icmp ult i64 %phi, 161\n br i1 %icmp, label %bb1, label %bb4\n\nbb4: ; preds = %bb1\n ret void\n\nbb5: ; preds = %bb\n %landingpad = landingpad { ptr, i32 }\n cleanup\n ret void\n}\n```\nReproducer: https://godbolt.org/z/3do96adnn\n\nStack dump:\n```\nopt: /root/llvm-project/llvm/include/llvm/ADT/ilist_iterator.h:322: llvm::ilist_iterator_w_bits<OptionsT, IsReverse, IsConst>::reference llvm::ilist_iterator_w_bits<OptionsT, IsReverse, IsConst>::operator*() const [with OptionsT = llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>; bool IsReverse = false; bool IsConst = false; llvm::ilist_iterator_w_bits<OptionsT, IsReverse, IsConst>::reference = llvm::Instruction&]: Assertion `!NodePtr->isKnownSentinel()' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=loop-vectorize <source>\n1.\tRunning pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"<source>\"\n2.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"wombat\"\n #0 0x0000000005452b98 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5452b98)\n #1 0x0000000005450554 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007b16e6242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007b16e62969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007b16e6242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007b16e62287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x00007b16e622871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x00007b16e6239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x00000000044f6c23 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x44f6c23)\n #9 0x000000000450ebb3 llvm::VPTransformState::get(llvm::VPValue*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x450ebb3)\n#10 0x0000000004543138 llvm::VPInstruction::generate(llvm::VPTransformState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4543138)\n#11 0x0000000004544ba4 llvm::VPInstruction::execute(llvm::VPTransformState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4544ba4)\n#12 0x00000000044f82e7 llvm::VPBasicBlock::executeRecipes(llvm::VPTransformState*, llvm::BasicBlock*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x44f82e7)\n#13 0x00000000045038f9 llvm::VPIRBasicBlock::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x45038f9)\n#14 0x0000000004510249 llvm::VPlan::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4510249)\n#15 0x00000000043cccce llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool, llvm::DenseMap<llvm::SCEV const*, llvm::Value*, llvm::DenseMapInfo<llvm::SCEV const*, void>, llvm::detail::DenseMapPair<llvm::SCEV const*, llvm::Value*>> const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43cccce)\n#16 0x00000000043e15d8 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43e15d8)\n#17 0x00000000043e2f49 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43e2f49)\n#18 0x00000000043e35c3 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43e35c3)\n#19 0x000000000318aaae llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x318aaae)\n#20 0x000000000524cd90 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x524cd90)\n#21 0x0000000000e6f54e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe6f54e)\n#22 0x000000000524b6ab llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x524b6ab)\n#23 0x0000000000e6e83e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe6e83e)\n#24 0x000000000524b0b0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x524b0b0)\n#25 0x0000000000935a3a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x935a3a)\n#26 0x00000000009290ac optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9290ac)\n#27 0x00007b16e6229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#28 0x00007b16e6229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#29 0x0000000000920985 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x920985)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```",
"author": "TatyanaDoubts",
"labels": [
"vectorizers",
"crash-on-valid"
],
"comments": [
{
"author": "fhahn",
"body": "looking "
}
]
}
| true |
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
| null |
128600
|
https://github.com/llvm/llvm-project/issues/128600
|
crash
|
495774d6d59379edad3c8c35be8c4672d4a513fa
| 2025-02-24T23:53:48 |
[
"llvm/test/Transforms/LoopFusion"
] |
{
"fix_commit": "90de4a4ac96ef314e3af9c43c516d5aaf105777a",
"components": [
"LoopFuse"
],
"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": [
[
1176,
1181
],
[
1481,
1486
]
],
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.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": [
"canSinkInst",
"collectMovablePreheaderInsts",
"movePreheaderInsts"
],
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.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 90de4a4ac96ef314e3af9c43c516d5aaf105777a
Author: Madhur Amilkanthwar <madhura@nvidia.com>
Date: Mon Jul 28 12:08:43 2025 +0530
[LoopFusion] Fix sink instructions (#147501)
If we have instructions in second loop's preheader which can be sunk, we
should also be adjusting PHI nodes to receive values from the fused loop's latch block.
Fixes #128600
diff --git a/llvm/lib/Transforms/Scalar/LoopFuse.cpp b/llvm/lib/Transforms/Scalar/LoopFuse.cpp
index d6bd92d520e2..b5eb647a042b 100644
--- a/llvm/lib/Transforms/Scalar/LoopFuse.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopFuse.cpp
@@ -1176,6 +1176,28 @@ private:
return true;
}
+ /// This function fixes PHI nodes after fusion in \p SafeToSink.
+ /// \p SafeToSink instructions are the instructions that are to be moved past
+ /// the fused loop. Thus, the PHI nodes in \p SafeToSink should be updated to
+ /// receive values from the fused loop if they are currently taking values
+ /// from the first loop (i.e. FC0)'s latch.
+ void fixPHINodes(ArrayRef<Instruction *> SafeToSink,
+ const FusionCandidate &FC0,
+ const FusionCandidate &FC1) const {
+ for (Instruction *Inst : SafeToSink) {
+ // No update needed for non-PHI nodes.
+ PHINode *Phi = dyn_cast<PHINode>(Inst);
+ if (!Phi)
+ continue;
+ for (unsigned I = 0; I < Phi->getNumIncomingValues(); I++) {
+ if (Phi->getIncomingBlock(I) != FC0.Latch)
+ continue;
+ assert(FC1.Latch && "FC1 latch is not set");
+ Phi->setIncomingBlock(I, FC1.Latch);
+ }
+ }
+ }
+
/// Collect instructions in the \p FC1 Preheader that can be hoisted
/// to the \p FC0 Preheader or sunk into the \p FC1 Body
bool collectMovablePreheaderInsts(
@@ -1481,6 +1503,9 @@ private:
assert(I->getParent() == FC1.Preheader);
I->moveBefore(*FC1.ExitBlock, FC1.ExitBlock->getFirstInsertionPt());
}
+ // PHI nodes in SinkInsts need to be updated to receive values from the
+ // fused loop.
+ fixPHINodes(SinkInsts, FC0, FC1);
}
/// Determine if two fusion candidates have identical guards
|
[
{
"file": "llvm/test/Transforms/LoopFusion/sunk-phi-nodes.ll",
"commands": [
"opt -passes=loop-fusion -S < %s 2>&1"
],
"tests": [
{
"test_name": "<module>",
"test_body": "define dso_local i32 @check_sunk_phi_nodes() {\n;\nentry:\n br label %for.body\n\nfor.body: ; preds = %entry, %for.inc\n %sum1.02 = phi i32 [ 0, %entry ], [ %add, %for.inc ]\n %i.01 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]\n %add = add nsw i32 %sum1.02, %i.01\n br label %for.inc\n\nfor.inc: ; preds = %for.body\n %inc = add nsw i32 %i.01, 1\n %cmp = icmp slt i32 %inc, 10\n br i1 %cmp, label %for.body, label %for.end\n\nfor.end: ; preds = %for.inc\n %sum1.0.lcssa = phi i32 [ %add, %for.inc ]\n br label %for.body4\n\nfor.body4: ; preds = %for.end, %for.inc6\n %i1.04 = phi i32 [ 0, %for.end ], [ %inc7, %for.inc6 ]\n %sum2.03 = phi i32 [ 0, %for.end ], [ %add5, %for.inc6 ]\n %mul = mul nsw i32 %i1.04, %i1.04\n %add5 = add nsw i32 %sum2.03, %mul\n br label %for.inc6\n\nfor.inc6: ; preds = %for.body4\n %inc7 = add nsw i32 %i1.04, 1\n %cmp3 = icmp slt i32 %inc7, 10\n br i1 %cmp3, label %for.body4, label %for.end8\n\nfor.end8: ; preds = %for.inc6\n %sum2.0.lcssa = phi i32 [ %add5, %for.inc6 ]\n %0 = add i32 %sum1.0.lcssa, %sum2.0.lcssa\n ret i32 %0\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[Clang] Optimization LoopFuse.cpp crashes on valid LLVM IR. Assertion `!verifyFunction(*FC0.Header->getParent(), &errs())' failed.",
"body": "To reproduce: https://godbolt.org/z/zMEsM448G\n`opt -passes=mem2reg,loop-rotate,loop-fusion {test}` crashes on the LLVMIR generated from `clang -O0` because of an assertion failure.\nStack Dump:\n```\nPHI node entries do not match predecessors!\n %sum1.0.lcssa = phi i32 [ %add, %for.inc ]\nlabel %for.inc\nlabel %for.inc6\nopt: /root/llvm-project/llvm/lib/Transforms/Scalar/LoopFuse.cpp:1759: llvm::Loop* {anonymous}::LoopFuser::performFusion(const {anonymous}::FusionCandidate&, const {anonymous}::FusionCandidate&): Assertion `!verifyFunction(*FC0.Header->getParent(), &errs())' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=mem2reg,loop-rotate,loop-fusion <source>\n1.\tRunning pass \"function(mem2reg,loop(loop-rotate<header-duplication;no-prepare-for-lto>),loop-fusion)\" on module \"<source>\"\n2.\tRunning pass \"loop-fusion\" on function \"main\"\n #0 0x00000000054498e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x54498e8)\n #1 0x00000000054472a4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x0000704d50642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x0000704d506969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x0000704d50642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x0000704d506287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x0000704d5062871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x0000704d50639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x000000000402a593 (anonymous namespace)::LoopFuser::performFusion((anonymous namespace)::FusionCandidate const&, (anonymous namespace)::FusionCandidate const&) LoopFuse.cpp:0:0\n #9 0x000000000402cab5 (anonymous namespace)::LoopFuser::fuseCandidates() LoopFuse.cpp:0:0\n#10 0x000000000402e5c1 llvm::LoopFusePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x402e5c1)\n#11 0x00000000031828ae llvm::detail::PassModel<llvm::Function, llvm::LoopFusePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x31828ae)\n#12 0x0000000005243e40 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5243e40)\n#13 0x0000000000e6e23e 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+0xe6e23e)\n#14 0x000000000524275b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x524275b)\n#15 0x0000000000e6d54e 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+0xe6d54e)\n#16 0x0000000005242160 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5242160)\n#17 0x0000000000935dda 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+0x935dda)\n#18 0x000000000092944c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x92944c)\n#19 0x0000704d50629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#20 0x0000704d50629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#21 0x0000000000920d25 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x920d25)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```\n\nThe Test IR causing the failure:\n```\n@.str = private unnamed_addr constant [7 x i8] c\"%d %d\\0A\\00\", align 1\n\ndefine dso_local i32 @main() #0 {\nentry:\n %retval = alloca i32, align 4\n %sum1 = alloca i32, align 4\n %sum2 = alloca i32, align 4\n %i = alloca i32, align 4\n %i1 = alloca i32, align 4\n store i32 0, ptr %retval, align 4\n store i32 0, ptr %sum1, align 4\n store i32 0, ptr %sum2, align 4\n store i32 0, ptr %i, align 4\n br label %for.cond\n\nfor.cond:\n %0 = load i32, ptr %i, align 4\n %cmp = icmp slt i32 %0, 10\n br i1 %cmp, label %for.body, label %for.end\n\nfor.body:\n %1 = load i32, ptr %i, align 4\n %2 = load i32, ptr %sum1, align 4\n %add = add nsw i32 %2, %1\n store i32 %add, ptr %sum1, align 4\n br label %for.inc\n\nfor.inc:\n %3 = load i32, ptr %i, align 4\n %inc = add nsw i32 %3, 1\n store i32 %inc, ptr %i, align 4\n br label %for.cond\n\nfor.end:\n store i32 0, ptr %i1, align 4\n br label %for.cond2\n\nfor.cond2:\n %4 = load i32, ptr %i1, align 4\n %cmp3 = icmp slt i32 %4, 10\n br i1 %cmp3, label %for.body4, label %for.end8\n\nfor.body4:\n %5 = load i32, ptr %i1, align 4\n %6 = load i32, ptr %i1, align 4\n %mul = mul nsw i32 %5, %6\n %7 = load i32, ptr %sum2, align 4\n %add5 = add nsw i32 %7, %mul\n store i32 %add5, ptr %sum2, align 4\n br label %for.inc6\n\nfor.inc6:\n %8 = load i32, ptr %i1, align 4\n %inc7 = add nsw i32 %8, 1\n store i32 %inc7, ptr %i1, align 4\n br label %for.cond2\n\nfor.end8:\n %9 = load i32, ptr %sum1, align 4\n %10 = load i32, ptr %sum2, align 4\n %call = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %9, i32 noundef %10)\n ret i32 0\n}\n\ndeclare i32 @printf(ptr noundef, ...) #1\n\nattributes #0 = { noinline nounwind uwtable \"frame-pointer\"=\"all\" \"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 = { \"frame-pointer\"=\"all\" \"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\nIt is generated from\n```c\n#include <stdio.h>\nint main() {\n int sum1 = 0, sum2 = 0;\n for (int i = 0; i < 10; i++) {\n sum1 += i;\n }\n for (int i = 0; i < 10; i++) {\n sum2 += i * i;\n }\n printf(\"%d %d\\n\", sum1, sum2);\n return 0;\n}\n```\n",
"author": "zitongzhoueric",
"labels": [
"loopoptim",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
155287
|
https://github.com/llvm/llvm-project/issues/155287
|
crash
|
cdb18705fc81018303e1089bbae0a2ae2fd201af
| 2025-08-25T20:29:01 |
[
"llvm/test/Transforms/LoopIdiom"
] |
{
"fix_commit": "b29084f0d80dd4fd66f1421350c87f79c537d071",
"components": [
"ScalarEvolution"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
1239,
1248
]
],
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.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": [
"SCEVExpander::tryToReuseLCSSAPhi"
],
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.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 b29084f0d80dd4fd66f1421350c87f79c537d071
Author: Florian Hahn <flo@fhahn.com>
Date: Tue Aug 26 11:38:39 2025 +0100
[SCEVExp] Check if getPtrToIntExpr resulted in CouldNotCompute.
This fixes a crash trying to use SCEVCouldNotCompute, if getPtrToIntExpr
failed.
Fixes https://github.com/llvm/llvm-project/issues/155287
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index 060ca92e559a..3e3d51bffff3 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -1239,10 +1239,13 @@ Value *SCEVExpander::tryToReuseLCSSAPhi(const SCEVAddRecExpr *S) {
if (!isa<SCEVAddRecExpr>(ExitSCEV))
continue;
Type *PhiTy = PN.getType();
- if (STy->isIntegerTy() && PhiTy->isPointerTy())
+ if (STy->isIntegerTy() && PhiTy->isPointerTy()) {
ExitSCEV = SE.getPtrToIntExpr(ExitSCEV, STy);
- else if (S->getType() != PN.getType())
+ if (isa<SCEVCouldNotCompute>(ExitSCEV))
+ continue;
+ } else if (S->getType() != PN.getType()) {
continue;
+ }
// Check if we can re-use the existing PN, by adjusting it with an expanded
// offset, if the offset is simpler.
|
[
{
"file": "llvm/test/Transforms/LoopIdiom/reuse-lcssa-phi-scev-expansion.ll",
"commands": [
"opt -p loop-idiom -S %s"
],
"tests": [
{
"test_name": "phi_ptr_addressspace_ptrtoint_fail",
"test_body": "target datalayout = \"e-m:e-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\n\ndefine void @phi_ptr_addressspace_ptrtoint_fail(ptr addrspace(1) %arg) {\nbb:\n br label %loop.1\n\nloop.1: ; preds = %loop.1, %bb\n %iv.1 = phi i64 [ 0, %bb ], [ %add5, %loop.1 ]\n %add5 = add i64 %iv.1, 1\n %getelementptr = getelementptr i16, ptr addrspace(1) %arg, i64 %add5\n br i1 false, label %loop.1, label %loop.2.ph\n\nloop.2.ph: ; preds = %loop.1\n %phi = phi ptr addrspace(1) [ %getelementptr, %loop.1 ]\n br label %loop.2.header\n\nloop.2.header: ; preds = %loop.2.latch, %loop.2.ph\n %iv.2 = phi i64 [ %iv.1, %loop.2.ph ], [ %iv.2.next, %loop.2.latch ]\n %grep.arg = getelementptr i32, ptr addrspace(1) %arg, i64 %iv.2\n store i32 0, ptr addrspace(1) %grep.arg, align 4\n %ec = icmp ult i64 %iv.2, 1\n br i1 %ec, label %loop.2.latch, label %exit\n\nloop.2.latch: ; preds = %loop.2.header\n %iv.2.next = add i64 %iv.2, 1\n br label %loop.2.header\n\nexit: ; preds = %loop.2.header\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Attempt to use a SCEVCouldNotCompute object! UNREACHABLE executed at /root/llvm-project/llvm/lib/Analysis/ScalarEvolution.cpp:412!",
"body": "To reproduce run opt with the test below, -passes=loop-idiom.\n```\n; ModuleID = './reduced.ll'\nsource_filename = \"./reduced.ll\"\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i32 @wombat(ptr addrspace(1) %arg) gc \"statepoint-example\" {\nbb:\n br label %bb2\n\nbb1: ; preds = %bb2\n %phi = phi ptr addrspace(1) [ %getelementptr, %bb2 ]\n br label %bb7\n\nbb2: ; preds = %bb2, %bb\n %phi3 = phi i64 [ 0, %bb ], [ %add5, %bb2 ]\n %phi4 = phi i64 [ 0, %bb ], [ %add, %bb2 ]\n %add = add i64 %phi4, 1\n %getelementptr = getelementptr i16, ptr addrspace(1) null, i64 %add\n %add5 = add i64 %phi3, 1\n br i1 false, label %bb2, label %bb1\n\nbb6: ; preds = %bb7\n ret i32 0\n\nbb7: ; preds = %bb10, %bb1\n %phi8 = phi i64 [ %phi3, %bb1 ], [ %add11, %bb10 ]\n %getelementptr9 = getelementptr i32, ptr addrspace(1) %arg, i64 %phi8\n store i32 0, ptr addrspace(1) %getelementptr9, align 4\n %icmp = icmp ult i64 %phi8, 1\n br i1 %icmp, label %bb10, label %bb6\n\nbb10: ; preds = %bb7\n %add11 = add i64 %phi8, 1\n br label %bb7\n}\n```\nReproducer: https://godbolt.org/z/qrWxb665W\nStack dump:\n```\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=loop-idiom <source>\n1.\tRunning pass \"function(loop(loop-idiom))\" on module \"<source>\"\n2.\tRunning pass \"loop(loop-idiom)\" on function \"wombat\"\n #0 0x00000000056fda38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x56fda38)\n #1 0x00000000056fa8e4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x000072a056242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x000072a0562969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x000072a056242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x000072a0562287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x0000000005634fda (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5634fda)\n #7 0x0000000004d415be llvm::SCEV::getType() const (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d415be)\n #8 0x0000000004d8c80e llvm::ScalarEvolution::getMinusSCEV(llvm::SCEV const*, llvm::SCEV const*, llvm::SCEV::NoWrapFlags, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d8c80e)\n #9 0x00000000049c63d8 llvm::SCEVExpander::tryToReuseLCSSAPhi(llvm::SCEVAddRecExpr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x49c63d8)\n#10 0x00000000049cb858 llvm::SCEVExpander::visitAddRecExpr(llvm::SCEVAddRecExpr const*) (.part.0) ScalarEvolutionExpander.cpp:0:0\n#11 0x00000000049c5455 llvm::SCEVVisitor<llvm::SCEVExpander, llvm::Value*>::visit(llvm::SCEV const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x49c5455)\n#12 0x00000000049c60fd llvm::SCEVExpander::expand(llvm::SCEV const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x49c60fd)\n#13 0x00000000049cb0f3 llvm::SCEVExpander::expandAddToGEP(llvm::SCEV const*, llvm::Value*, llvm::SCEV::NoWrapFlags) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x49cb0f3)\n#14 0x00000000049cc095 llvm::SCEVExpander::visitAddRecExpr(llvm::SCEVAddRecExpr const*) (.part.0) ScalarEvolutionExpander.cpp:0:0\n#15 0x00000000049c5455 llvm::SCEVVisitor<llvm::SCEVExpander, llvm::Value*>::visit(llvm::SCEV const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x49c5455)\n#16 0x00000000049c60fd llvm::SCEVExpander::expand(llvm::SCEV const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x49c60fd)\n#17 0x00000000049cc928 llvm::SCEVExpander::expandCodeFor(llvm::SCEV const*, llvm::Type*, llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>, false, false>) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x49cc928)\n#18 0x0000000004494e77 (anonymous namespace)::LoopIdiomRecognize::processLoopStridedStore(llvm::Value*, llvm::SCEV const*, llvm::MaybeAlign, llvm::Value*, llvm::Instruction*, llvm::SmallPtrSetImpl<llvm::Instruction*>&, llvm::SCEVAddRecExpr const*, llvm::SCEV const*, bool, bool) LoopIdiomRecognize.cpp:0:0\n#19 0x0000000004498c11 (anonymous namespace)::LoopIdiomRecognize::processLoopStores(llvm::SmallVectorImpl<llvm::StoreInst*>&, llvm::SCEV const*, (anonymous namespace)::LoopIdiomRecognize::ForMemset) LoopIdiomRecognize.cpp:0:0\n#20 0x00000000044997b4 (anonymous namespace)::LoopIdiomRecognize::runOnCountableLoop() LoopIdiomRecognize.cpp:0:0\n#21 0x000000000449b0fd llvm::LoopIdiomRecognizePass::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x449b0fd)\n#22 0x0000000002e085be llvm::detail::PassModel<llvm::Loop, llvm::LoopIdiomRecognizePass, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2e085be)\n#23 0x00000000044c0406 std::optional<llvm::PreservedAnalyses> llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::runSinglePass<llvm::Loop, std::unique_ptr<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, std::default_delete<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>>>>(llvm::Loop&, std::unique_ptr<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, std::default_delete<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>>>&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&, llvm::PassInstrumentation&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x44c0406)\n#24 0x00000000044c05ef llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::runWithoutLoopNestPasses(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x44c05ef)\n#25 0x00000000044c1d54 llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x44c1d54)\n#26 0x00000000044c2860 llvm::FunctionToLoopPassAdaptor::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x44c2860)\n#27 0x0000000000ed957e llvm::detail::PassModel<llvm::Function, llvm::FunctionToLoopPassAdaptor, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xed957e)\n#28 0x00000000054eb6c1 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x54eb6c1)\n#29 0x0000000000ed969e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xed969e)\n#30 0x00000000054ebd0a llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x54ebd0a)\n#31 0x000000000096d56e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x96d56e)\n#32 0x00000000054e9771 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x54e9771)\n#33 0x000000000097780a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x97780a)\n#34 0x000000000096b8d7 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x96b8d7)\n#35 0x000072a056229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#36 0x000072a056229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#37 0x00000000009629f5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9629f5)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```",
"author": "TatyanaDoubts",
"labels": [
"llvm:SCEV",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
92887
|
https://github.com/llvm/llvm-project/issues/92887
|
miscompilation
|
f78b1a40864470f7eb30dfda44a6ea8e845346a5
| 2024-05-21T09:38:14 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "263224e4481b0850539a93a272184aac4abe86d4",
"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": [
[
2901,
2907
]
],
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": [
"InstCombinerImpl::visitShuffleVectorInst"
],
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 263224e4481b0850539a93a272184aac4abe86d4
Author: Nikita Popov <npopov@redhat.com>
Date: Tue May 21 14:57:19 2024 +0200
[InstCombine] Require poison operand in canEvaluateShuffled transform
This transform works on single-source shuffles, which require that
the second operand is poison, not undef. Otherwise we may convert
undef to poison.
Fixes https://github.com/llvm/llvm-project/issues/92887.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
index 99f1f8eb34bb..745ccbfe9dc7 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -2901,7 +2901,7 @@ Instruction *InstCombinerImpl::visitShuffleVectorInst(ShuffleVectorInst &SVI) {
if (Instruction *I = foldIdentityPaddedShuffles(SVI))
return I;
- if (match(RHS, m_Undef()) && canEvaluateShuffled(LHS, Mask)) {
+ if (match(RHS, m_Poison()) && canEvaluateShuffled(LHS, Mask)) {
Value *V = evaluateInDifferentElementOrder(LHS, Mask, Builder);
return replaceInstUsesWith(SVI, V);
}
|
[
{
"file": "llvm/test/Transforms/InstCombine/vec_shuffle.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "pr92887",
"test_body": "define i16 @pr92887(<2 x i16> %v) {\n %v0 = extractelement <2 x i16> %v, i64 0\n %v0lo = and i16 %v0, 1\n %v1 = extractelement <2 x i16> %v, i64 1\n %v1lo = and i16 %v1, 1\n %ins1 = insertelement <4 x i16> poison, i16 %v0lo, i64 0\n %ins2 = insertelement <4 x i16> %ins1, i16 %v1lo, i64 1\n %shuf = shufflevector <4 x i16> %ins2, <4 x i16> <i16 poison, i16 poison, i16 undef, i16 undef>, <4 x i32> <i32 0, i32 1, i32 6, i32 7>\n %extract = extractelement <4 x i16> %shuf, i32 2\n ret i16 %extract\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "blend_elements_from_load",
"test_body": "define <4 x i16> @blend_elements_from_load(ptr align 8 %_0) {\n %load = load <3 x i16>, ptr %_0, align 8\n %rv = shufflevector <3 x i16> <i16 0, i16 undef, i16 undef>, <3 x i16> %load, <4 x i32> <i32 0, i32 1, i32 3, i32 5>\n ret <4 x i16> %rv\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Miscompile with opt -passes=\"instcombine\"",
"body": "llvm commit: 502bea25bdc07d1\r\n\r\nReproduce with:\r\n```opt -passes=\"instcombine\" bbi-95633_2.ll -S -o -```\r\n\r\nResult:\r\n```\r\ndefine i16 @foo() {\r\nentry:\r\n store i16 0, ptr @bit, align 2\r\n store i16 0, ptr getelementptr inbounds (i8, ptr @bit, i64 2), align 2\r\n store i16 0, ptr getelementptr inbounds (i8, ptr @bit, i64 4), align 2\r\n store i16 0, ptr getelementptr inbounds (i8, ptr @bit, i64 6), align 2\r\n store i16 2, ptr getelementptr inbounds (i8, ptr @bit, i64 8), align 2\r\n store i16 0, ptr getelementptr inbounds (i8, ptr @bit, i64 10), align 2\r\n ret i16 poison\r\n}\r\n```\r\nNote the poison return value which I think is wrong.\r\n\r\nBefore commit e93d324adb4ff8\r\n```\r\n[InstCombine] Preserve poison in evaluateInDifferentElementOrder()\r\n\r\nDon't unnecessarily replace poison with undef.\r\n```\r\nwe instead got\r\n```\r\ndefine i16 @foo() {\r\nentry:\r\n store i16 0, ptr @bit, align 2\r\n store i16 0, ptr getelementptr inbounds (%struct.bit, ptr @bit, i64 0, i32 1), align 2\r\n store i16 0, ptr getelementptr inbounds (%struct.bit, ptr @bit, i64 0, i32 2), align 2\r\n store i16 0, ptr getelementptr inbounds (%struct.bit, ptr @bit, i64 0, i32 3), align 2\r\n store i16 2, ptr getelementptr inbounds (%struct.bit, ptr @bit, i64 0, i32 4), align 2\r\n store i16 0, ptr getelementptr inbounds (%struct.bit, ptr @bit, i64 0, i32 5), align 2\r\n ret i16 1\r\n}\r\n```\r\nwhere we return 1 instead of poison.\r\n\r\nI tried to use Alive2 on the input/output in\r\n https://alive2.llvm.org/ce/z/1GVkRh\r\nand it says\r\n```\r\nTransformation doesn't verify!\r\n\r\nERROR: Target is more poisonous than source\r\n```\r\n\r\n[bbi-95633_2.ll.gz](https://github.com/llvm/llvm-project/files/15387836/bbi-95633_2.ll.gz)\r\n",
"author": "mikaelholmen",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": [
{
"author": "mikaelholmen",
"body": "@nikic : Any idea about this?"
},
{
"author": "artagnon",
"body": "Here's a reduced test case:\r\n\r\n```llvm\r\n; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5\r\n; RUN: opt -passes=instcombine -S %s | FileCheck %s\r\n\r\n%struct.widget = type { i16, i16, i16, i16, i16, i16 }\r\n\r\n; Miscompile. Correct output: 1, incorrect output: poison.\r\ndefine i16 @pr92887(ptr %p, i16 %x, i16 %y) {\r\n; CHECK-LABEL: define i16 @pr92887(\r\n; CHECK-SAME: ptr [[P:%.*]], i16 [[X:%.*]], i16 [[Y:%.*]]) {\r\n; CHECK-NEXT: store i16 0, ptr [[P]], align 2\r\n; CHECK-NEXT: [[P_REPACK1:%.*]] = getelementptr inbounds i8, ptr [[P]], i64 2\r\n; CHECK-NEXT: store i16 0, ptr [[P_REPACK1]], align 2\r\n; CHECK-NEXT: [[P_REPACK2:%.*]] = getelementptr inbounds i8, ptr [[P]], i64 4\r\n; CHECK-NEXT: store i16 0, ptr [[P_REPACK2]], align 2\r\n; CHECK-NEXT: [[P_REPACK3:%.*]] = getelementptr inbounds i8, ptr [[P]], i64 6\r\n; CHECK-NEXT: store i16 0, ptr [[P_REPACK3]], align 2\r\n; CHECK-NEXT: [[P_REPACK4:%.*]] = getelementptr inbounds i8, ptr [[P]], i64 8\r\n; CHECK-NEXT: store i16 2, ptr [[P_REPACK4]], align 2\r\n; CHECK-NEXT: [[P_REPACK5:%.*]] = getelementptr inbounds i8, ptr [[P]], i64 10\r\n; CHECK-NEXT: store i16 0, ptr [[P_REPACK5]], align 2\r\n; CHECK-NEXT: ret i16 poison\r\n;\r\n store %struct.widget { i16 0, i16 0, i16 0, i16 0, i16 2, i16 0 }, ptr %p\r\n %insert.y = insertelement <2 x i16> zeroinitializer, i16 %y, i64 0\r\n %insert.x = insertelement <2 x i16> %insert.y, i16 %x, i64 1\r\n %shufflevector = shufflevector <2 x i16> %insert.x, <2 x i16> zeroinitializer, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>\r\n %extract = extractelement <4 x i16> %shufflevector, i32 2 ; undef\r\n %and = and i16 %extract, 0 ; 0\r\n %gep = getelementptr %struct.widget, ptr %p, i32 0, i32 4\r\n %load = load i16, ptr %gep ; 2\r\n %or = or i16 %and, %load ; 2\r\n %ashr = ashr i16 %or, 1 ; 1\r\n ret i16 %ashr ; 1\r\n}\r\n```\r\n\r\nEDIT: Sorry, Alive2 verifies the transformation as correct."
},
{
"author": "nikic",
"body": "The problematic transform is:\r\n```llvm\r\ndefine i16 @src(<2 x i16> %v) {\r\n %v0 = extractelement <2 x i16> %v, i64 0\r\n %v0lo = and i16 %v0, 1\r\n %v1 = extractelement <2 x i16> %v, i64 1\r\n %v1lo = and i16 %v1, 1\r\n %ins1 = insertelement <4 x i16> poison, i16 %v0lo, i64 0\r\n %ins2 = insertelement <4 x i16> %ins1, i16 %v1lo, i64 1\r\n %shuf = shufflevector <4 x i16> %ins2, <4 x i16> <i16 poison, i16 poison, i16 undef, i16 undef>, <4 x i32> <i32 0, i32 1, i32 6, i32 7>\r\n %extract = extractelement <4 x i16> %shuf, i32 2\r\n ret i16 %extract\r\n}\r\n```\r\nTo:\r\n```\r\ndefine i16 @src(<2 x i16> %v) {\r\n %v0 = extractelement <2 x i16> %v, i64 0\r\n %v0lo = and i16 %v0, 1\r\n %v1 = extractelement <2 x i16> %v, i64 1\r\n %v1lo = and i16 %v1, 1\r\n %1 = insertelement <4 x i16> poison, i16 %v0lo, i64 0\r\n %shuf = insertelement <4 x i16> %1, i16 %v1lo, i64 1\r\n %extract = extractelement <4 x i16> %shuf, i32 2\r\n ret i16 %extract\r\n}\r\n```\r\n\r\nAt a glance, the problem is likely that https://github.com/llvm/llvm-project/blob/e93d324adb4ff80dcbf0e5b678ed3342350eb2de/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp#L2881 should be matching m_Poison, not m_Undef, otherwise it's not a real single-source shuffle."
},
{
"author": "mikaelholmen",
"body": "Thanks for the quick fix!\r\nI've verified that it solves the problem we saw."
},
{
"author": "nikic",
"body": "As a bonus, fixed a similar miscompile in https://github.com/llvm/llvm-project/commit/ecd269e8305330c185bbedbd5a59e887122333ba."
},
{
"author": "nikic",
"body": "Another one in https://github.com/llvm/llvm-project/commit/8f1c984325bd679b2634a6173db69548da87ac71."
},
{
"author": "nikic",
"body": "And... one more in https://github.com/llvm/llvm-project/commit/d0e0205bfc5a147f8744a176a10f185af7520c26."
},
{
"author": "mikaelholmen",
"body": "Nice, four fixes from just one issue! :)"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
121745
|
https://github.com/llvm/llvm-project/issues/121745
|
miscompilation
|
3874c64418d2a7e36eab9af9253d905b48b36078
| 2025-01-06T10:26:21 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "f9369cc602272796c15de1065a782f812e791df3",
"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": [
[
562,
582
],
[
1086,
1103
]
],
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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::adjustFixedOrderRecurrences",
"VPlanTransforms::clearReductionWrapFlags",
"collectUsersRecursively",
"createScalarIVSteps",
"legalizeAndOptimizeInductions"
],
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 f9369cc602272796c15de1065a782f812e791df3
Author: Florian Hahn <flo@fhahn.com>
Date: Mon Jan 6 22:40:41 2025 +0000
[VPlan] Make sure last IV increment value is available if needed.
Legalize extract-from-ends using uniform VPReplicateRecipe of wide
inductions to use regular VPReplicateRecipe, so the correct end value
is available.
Fixes https://github.com/llvm/llvm-project/issues/121745.
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 395287bde76f..3e3f5adf73a0 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -562,21 +562,63 @@ createScalarIVSteps(VPlan &Plan, InductionDescriptor::InductionKind Kind,
return Builder.createScalarIVSteps(InductionOpcode, FPBinOp, BaseIV, Step);
}
+static SmallVector<VPUser *> collectUsersRecursively(VPValue *V) {
+ SetVector<VPUser *> Users(V->user_begin(), V->user_end());
+ for (unsigned I = 0; I != Users.size(); ++I) {
+ VPRecipeBase *Cur = cast<VPRecipeBase>(Users[I]);
+ if (isa<VPHeaderPHIRecipe>(Cur))
+ continue;
+ for (VPValue *V : Cur->definedValues())
+ Users.insert(V->user_begin(), V->user_end());
+ }
+ return Users.takeVector();
+}
+
/// Legalize VPWidenPointerInductionRecipe, by replacing it with a PtrAdd
/// (IndStart, ScalarIVSteps (0, Step)) if only its scalar values are used, as
/// VPWidenPointerInductionRecipe will generate vectors only. If some users
/// require vectors while other require scalars, the scalar uses need to extract
/// the scalars from the generated vectors (Note that this is different to how
-/// int/fp inductions are handled). Also optimize VPWidenIntOrFpInductionRecipe,
-/// if any of its users needs scalar values, by providing them scalar steps
-/// built on the canonical scalar IV and update the original IV's users. This is
-/// an optional optimization to reduce the needs of vector extracts.
+/// int/fp inductions are handled). Legalize extract-from-ends using uniform
+/// VPReplicateRecipe of wide inductions to use regular VPReplicateRecipe, so
+/// the correct end value is available. Also optimize
+/// VPWidenIntOrFpInductionRecipe, if any of its users needs scalar values, by
+/// providing them scalar steps built on the canonical scalar IV and update the
+/// original IV's users. This is an optional optimization to reduce the needs of
+/// vector extracts.
static void legalizeAndOptimizeInductions(VPlan &Plan) {
+ using namespace llvm::VPlanPatternMatch;
SmallVector<VPRecipeBase *> ToRemove;
VPBasicBlock *HeaderVPBB = Plan.getVectorLoopRegion()->getEntryBasicBlock();
bool HasOnlyVectorVFs = !Plan.hasVF(ElementCount::getFixed(1));
VPBuilder Builder(HeaderVPBB, HeaderVPBB->getFirstNonPhi());
for (VPRecipeBase &Phi : HeaderVPBB->phis()) {
+ auto *PhiR = dyn_cast<VPHeaderPHIRecipe>(&Phi);
+ if (!PhiR)
+ break;
+
+ // Check if any uniform VPReplicateRecipes using the phi recipe are used by
+ // ExtractFromEnd. Those must be replaced by a regular VPReplicateRecipe to
+ // ensure the final value is available.
+ // TODO: Remove once uniformity analysis is done on VPlan.
+ for (VPUser *U : collectUsersRecursively(PhiR)) {
+ auto *ExitIRI = dyn_cast<VPIRInstruction>(U);
+ VPValue *Op;
+ if (!ExitIRI || !match(ExitIRI->getOperand(0),
+ m_VPInstruction<VPInstruction::ExtractFromEnd>(
+ m_VPValue(Op), m_VPValue())))
+ continue;
+ auto *RepR = dyn_cast<VPReplicateRecipe>(Op);
+ if (!RepR || !RepR->isUniform())
+ continue;
+ assert(!RepR->isPredicated() && "RepR must not be predicated");
+ Instruction *I = RepR->getUnderlyingInstr();
+ auto *Clone =
+ new VPReplicateRecipe(I, RepR->operands(), /*IsUniform*/ false);
+ Clone->insertAfter(RepR);
+ RepR->replaceAllUsesWith(Clone);
+ }
+
// Replace wide pointer inductions which have only their scalars used by
// PtrAdd(IndStart, ScalarIVSteps (0, Step)).
if (auto *PtrIV = dyn_cast<VPWidenPointerInductionRecipe>(&Phi)) {
@@ -1086,18 +1128,6 @@ bool VPlanTransforms::adjustFixedOrderRecurrences(VPlan &Plan,
return true;
}
-static SmallVector<VPUser *> collectUsersRecursively(VPValue *V) {
- SetVector<VPUser *> Users(V->user_begin(), V->user_end());
- for (unsigned I = 0; I != Users.size(); ++I) {
- VPRecipeBase *Cur = cast<VPRecipeBase>(Users[I]);
- if (isa<VPHeaderPHIRecipe>(Cur))
- continue;
- for (VPValue *V : Cur->definedValues())
- Users.insert(V->user_begin(), V->user_end());
- }
- return Users.takeVector();
-}
-
void VPlanTransforms::clearReductionWrapFlags(VPlan &Plan) {
for (VPRecipeBase &R :
Plan.getVectorLoopRegion()->getEntryBasicBlock()->phis()) {
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/iv_outside_user.ll",
"commands": [
"opt -S -passes=loop-vectorize -force-vector-interleave=1 -force-vector-width=2 < %s",
"opt -S -passes=loop-vectorize -force-vector-interleave=2 -force-vector-width=1 < %s"
],
"tests": [
{
"test_name": "test_iv_uniform_with_outside_use_scev_simplification",
"test_body": "define i32 @test_iv_uniform_with_outside_use_scev_simplification(ptr %dst) {\nentry:\n %step.1 = sext i8 0 to i32\n %step.2 = add nsw i32 %step.1, 1\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %gep.dst = getelementptr inbounds i16, ptr %dst, i32 %iv\n store i16 0, ptr %gep.dst, align 2\n %iv.next = add i32 %step.2, %iv\n %cmp.i = icmp slt i32 %iv.next, 8\n br i1 %cmp.i, label %loop, label %e.exit\n\ne.exit: ; preds = %loop\n %res = phi i32 [ %iv.next, %loop ]\n ret i32 %res\n}\n",
"lli_expected_out": null,
"additional_args": "-src-unroll=8 -tgt-unroll=8"
}
]
}
] |
{
"title": "[clang] Miscompilation at -O2/3",
"body": "This code prints 8 at `-O0/1` and prints 1 at `-O2/3`:\n\n```c\nint printf(const char *, ...);\nstatic char a;\nstatic char *b = &a;\nstatic int c;\nshort d;\nvoid e() {\n short f[8];\n char **g[] = {&b, &b};\n c = 0;\n for (; c < 8; c = 81 + 462704684 + *b - 462704765 + c + 1)\n f[c] = 0;\n d = f[5];\n}\nint main() {\n e();\n printf(\"%d\\n\", c);\n}\n```\n\nCompiler Explorer: https://godbolt.org/z/MEKz8oncP\n\nBisected to https://github.com/llvm/llvm-project/commit/df4a615c988f3ae56f7e68a7df86acb60f16493a, which was committed by @fhahn ",
"author": "cardigan1008",
"labels": [
"miscompilation",
"vectorizers"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Reduced testcase: https://alive2.llvm.org/ce/z/6Bg63G\n```\n; bin/opt -passes=loop-vectorize test.ll -S\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i32 @src() {\nentry:\n %f.i = alloca [8 x i16], align 16\n %conv.i = sext i8 0 to i32\n %invariant.op.i = add nsw i32 %conv.i, 1\n br label %for.body.i\n\nfor.body.i: ; preds = %for.body.i, %entry\n %0 = phi i32 [ 0, %entry ], [ %add2.reass.i, %for.body.i ]\n %idxprom.i = sext i32 %0 to i64\n %arrayidx.i = getelementptr [8 x i16], ptr %f.i, i64 0, i64 %idxprom.i\n store i16 0, ptr %arrayidx.i, align 2\n %add2.reass.i = add i32 %invariant.op.i, %0\n %cmp.i = icmp slt i32 %add2.reass.i, 8\n br i1 %cmp.i, label %for.body.i, label %e.exit\n\ne.exit: ; preds = %for.body.i\n %add2.reass.i.lcssa = phi i32 [ %add2.reass.i, %for.body.i ]\n ret i32 %add2.reass.i.lcssa\n}\n```"
},
{
"author": "fhahn",
"body": "Looking into it now, thanks"
},
{
"author": "yaoxinliu",
"body": "Thank God! clang19 works as expected."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
151392
|
https://github.com/llvm/llvm-project/issues/151392
|
crash
|
c7500a2ec3baae1f0d7de0de94407d4bdb2e5d4d
| 2025-07-30T20:45:12 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "39c30665e99145e07b0170b552f18371a67b2e03",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
2836,
2847
]
],
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": [
"scalarizeInstruction"
],
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 39c30665e99145e07b0170b552f18371a67b2e03
Author: Florian Hahn <flo@fhahn.com>
Date: Sat Aug 2 19:49:59 2025 +0100
[VPlan] Update type of cloned instruction in scalarizeInstruction.
The operands of the replicate recipe may have been narrowed, resulting
in a narrower result type. Update the type of the cloned instruction to
the correct type.
Fixes https://github.com/llvm/llvm-project/issues/151392.
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index 11b4677ec102..98d11f0bc789 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -2836,12 +2836,12 @@ static void scalarizeInstruction(const Instruction *Instr,
Instruction *Cloned = Instr->clone();
if (!IsVoidRetTy) {
Cloned->setName(Instr->getName() + ".cloned");
-#if !defined(NDEBUG)
- // Verify that VPlan type inference results agree with the type of the
- // generated values.
- assert(State.TypeAnalysis.inferScalarType(RepRecipe) == Cloned->getType() &&
- "inferred type and type from generated instructions do not match");
-#endif
+ Type *ResultTy = State.TypeAnalysis.inferScalarType(RepRecipe);
+ // The operands of the replicate recipe may have been narrowed, resulting in
+ // a narrower result type. Update the type of the cloned instruction to the
+ // correct type.
+ if (ResultTy != Cloned->getType())
+ Cloned->mutateType(ResultTy);
}
RepRecipe->applyFlags(*Cloned);
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/single-scalar-cast-minbw.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-width=4 -S %s"
],
"tests": [
{
"test_name": "single_scalar_cast_stored",
"test_body": "define void @single_scalar_cast_stored(ptr %src, ptr %dst, i32 %n) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %l = load i16, ptr %src, align 2\n %cmp = icmp eq i16 %l, 0\n %l.ext = zext i16 %l to i32\n %and = and i32 %l.ext, 15\n %sel = select i1 %cmp, i32 0, i32 %and\n %sel.trunc = trunc i32 %sel to i16\n store i16 %sel.trunc, ptr %dst, align 2\n %iv.next = add nuw i32 %iv, 1\n %ec = icmp ne i32 %iv.next, %n\n br i1 %ec, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[LoopVectorize] Assertion `State.TypeAnalysis.inferScalarType(RepRecipe) == Cloned->getType() && \"inferred type and type from generated instructions do not match\"' failed.",
"body": "Testcase:\n```llvm ir\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\n@b = external global [0 x i16]\n@n = internal global i16 9\n@u = external global [9 x i64]\n@p = external global [9 x i16]\n\ndefine i64 @c(i8 %k, i16 %n, ptr %p, ptr %u, ptr %w, i64 %indvars.iv133, i8 %sub, i8 %add98.us.us.us) {\nentry:\n %arrayidx36 = getelementptr i8, ptr %u, i64 64\n br label %for.cond18.preheader.us.us.us\n\nfor.cond18.preheader.us.us.us: ; preds = %cond.false.us.us.us, %entry\n br label %cond.false.us.us.us\n\ncond.false.us.us.us: ; preds = %for.body27.us.us.us, %for.cond18.preheader.us.us.us\n %ah.0.us.us.us = phi i32 [ %add67.us.us.us, %for.body27.us.us.us ], [ 0, %for.cond18.preheader.us.us.us ]\n %0 = load i16, ptr %p, align 2\n %conv22.us.us.us = sext i16 %0 to i32\n %cmp24.us.us.us = icmp slt i32 %ah.0.us.us.us, %conv22.us.us.us\n br i1 %cmp24.us.us.us, label %for.body27.us.us.us, label %for.cond18.preheader.us.us.us\n\nfor.body27.us.us.us: ; preds = %cond.false.us.us.us\n %1 = load i16, ptr %w, align 2\n %tobool.not.us.us.us = icmp eq i16 %1, 0\n %narrow.us.us.us = select i1 %tobool.not.us.us.us, i16 0, i16 %n\n %cond35.us.us.us = sext i16 %narrow.us.us.us to i32\n %2 = load i64, ptr %arrayidx36, align 8\n %conv37.us.us.us = trunc i64 %2 to i32\n %cond43.us.us.us = tail call i32 @llvm.smin.i32(i32 %cond35.us.us.us, i32 %conv37.us.us.us)\n %conv46.us.us.us = trunc i32 %cond43.us.us.us to i16\n store i16 %conv46.us.us.us, ptr @b, align 2\n %3 = load i8, ptr %w, align 1\n %conv54.us.us.us = sext i8 %3 to i16\n store i16 %conv54.us.us.us, ptr %u, align 2\n %add67.us.us.us = add i32 %ah.0.us.us.us, 1\n br label %cond.false.us.us.us\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.smin.i32(i32, i32) #0\n\ndefine i64 @main(ptr %k) #1 {\nentry:\n store i64 57, ptr getelementptr inbounds nuw (i8, ptr @u, i64 64), align 32\n %0 = load i16, ptr @n, align 2\n %1 = call i64 @c(i8 0, i16 %0, ptr @p, ptr @u, ptr %k, i64 0, i8 0, i8 0)\n ret i64 %1\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\nattributes #1 = { \"target-features\"=\"+v\" }\n```\n\nCommands/backtrace\n```\n$ /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt \"-passes=lto<O3>\" reduced.ll\nWARNING: You're attempting to print out a bitcode file.\nThis is inadvisable as it may cause display problems. If\nyou REALLY want to taste LLVM bitcode first-hand, you\ncan force output with the `-f' option.\n\nopt: /scratch/ewlu/daily-upstream-build/llvm/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp:2842: void scalarizeInstruction(const llvm::Instruction*, llvm::VPReplicateRecipe*, const llvm::VPLane&, llvm::VPTransformState&): Assertion `State.TypeAnalysis.inferScalarType(RepRecipe) == Cloned->getType() && \"inferred type and type from generated instructions do not match\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0. Program arguments: /scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt -passes=lto<O3> reduced.ll\n1. Running pass \"function<eager-inv>(loop-mssa(licm<allowspeculation>),gvn<>,memcpyopt,dse,move-auto-init,mldst-motion<no-split-footer-bb>,loop(indvars,loop-deletion,loop-unroll-full),loop-distribute,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,sccp,instcombine<max-iterations=1;no-verify-fixpoint>,bdce,slp-vectorizer,vector-combine,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop(evl-iv-simplify),jump-threading)\" on module \"reduced.ll\"\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\n #0 0x0000645af6577e72 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x338ee72)\n #1 0x0000645af6574b6f llvm::sys::RunSignalHandlers() (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x338bb6f)\n #2 0x0000645af6574cbc SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #3 0x000079da8fc45330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)\n #4 0x000079da8fc9eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #5 0x000079da8fc9eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #6 0x000079da8fc9eb2c pthread_kill ./nptl/pthread_kill.c:89:10\n #7 0x000079da8fc4527e raise ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x000079da8fc288ff abort ./stdlib/abort.c:81:7\n #9 0x000079da8fc2881b _nl_load_domain ./intl/loadmsgcat.c:1177:9\n#10 0x000079da8fc3b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)\n#11 0x0000645af4394a5d (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x11aba5d)\n#12 0x0000645af43986a3 llvm::VPReplicateRecipe::execute(llvm::VPTransformState&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x11af6a3)\n#13 0x0000645af433bee1 llvm::VPBasicBlock::executeRecipes(llvm::VPTransformState*, llvm::BasicBlock*) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x1152ee1)\n#14 0x0000645af43510d7 llvm::VPBasicBlock::execute(llvm::VPTransformState*) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x11680d7)\n#15 0x0000645af43582c1 llvm::VPlan::execute(llvm::VPTransformState*) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x116f2c1)\n#16 0x0000645af41d802f llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0xfef02f)\n#17 0x0000645af41e69f7 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0xffd9f7)\n#18 0x0000645af41e96a1 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x10006a1)\n#19 0x0000645af41e9c67 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x1000c67)\n#20 0x0000645af3a81535 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x898535)\n#21 0x0000645af635bb7d llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x3172b7d)\n#22 0x0000645af3a83d15 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x89ad15)\n#23 0x0000645af635bf67 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x3172f67)\n#24 0x0000645af3719fe5 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x530fe5)\n#25 0x0000645af635d10d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x317410d)\n#26 0x0000645af3726099 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x53d099)\n#27 0x0000645af37181a8 optMain (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x52f1a8)\n#28 0x000079da8fc2a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3\n#29 0x000079da8fc2a28b call_init ./csu/../csu/libc-start.c:128:20\n#30 0x000079da8fc2a28b __libc_start_main ./csu/../csu/libc-start.c:347:5\n#31 0x0000645af370e0b5 _start (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x5250b5)\nAborted (core dumped)\n```\n\nGodbolt: https://godbolt.org/z/T3cbfY9zG\n\nFound via fuzzer (C program before reduction)",
"author": "ewlu",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
89338
|
https://github.com/llvm/llvm-project/issues/89338
|
miscompilation
|
ab1d988e1483895a71dcd257bdcaf6fdb0a83d62
| 2024-04-19T01:55:15 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "46957a138dea339799059ea5bf032e40042ff185",
"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": [
[
1988,
1994
]
],
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": [
"InstCombinerImpl::visitCallInst"
],
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 46957a138dea339799059ea5bf032e40042ff185
Author: Nikita Popov <npopov@redhat.com>
Date: Fri Apr 19 14:00:49 2024 +0900
[InstCombine] Fix incorrect fshr to fshl transform
This transform is only valid if the (modular) shift amount is not
zero.
Proof: https://alive2.llvm.org/ce/z/WBxn-x
Fixes https://github.com/llvm/llvm-project/issues/89338.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index aa547565bd08..e7a2f54f8680 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1988,7 +1988,10 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
// is not entirely arbitrary. For historical reasons, the backend may
// recognize rotate left patterns but miss rotate right patterns.
if (IID == Intrinsic::fshr) {
- // fshr X, Y, C --> fshl X, Y, (BitWidth - C)
+ // fshr X, Y, C --> fshl X, Y, (BitWidth - C) if C is not zero.
+ if (!isKnownNonZero(ShAmtC, SQ.getWithInstruction(II)))
+ return nullptr;
+
Constant *LeftShiftC = ConstantExpr::getSub(WidthC, ShAmtC);
Module *Mod = II->getModule();
Function *Fshl = Intrinsic::getDeclaration(Mod, Intrinsic::fshl, Ty);
|
[
{
"file": "llvm/test/Transforms/InstCombine/fsh.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "fsh_unary_shuffle_ops_partial_widening",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <2 x i32> @llvm.fshr.v2i32(<2 x i32>, <2 x i32>, <2 x i32>) #0\n\ndefine <2 x i32> @fsh_unary_shuffle_ops_partial_widening(<3 x i32> %x, <2 x i32> %y, <2 x i32> %z) {\n %a = shufflevector <3 x i32> %x, <3 x i32> poison, <2 x i32> <i32 1, i32 0>\n %b = shufflevector <2 x i32> %y, <2 x i32> poison, <2 x i32> <i32 1, i32 0>\n %c = shufflevector <2 x i32> %z, <2 x i32> poison, <2 x i32> <i32 1, i32 0>\n %r = call <2 x i32> @llvm.fshr.v2i32(<2 x i32> %a, <2 x i32> %b, <2 x i32> %c)\n ret <2 x i32> %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "fshr_vec_zero_elem",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <2 x i32> @llvm.fshr.v2i32(<2 x i32>, <2 x i32>, <2 x i32>) #0\n\ndefine <2 x i32> @fshr_vec_zero_elem(<2 x i32> %x, <2 x i32> %y) {\n %fsh = call <2 x i32> @llvm.fshr.v2i32(<2 x i32> %x, <2 x i32> %y, <2 x i32> <i32 2, i32 0>)\n ret <2 x i32> %fsh\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "instcombine is wrong about a vector fshr->shl transformation",
"body": "Instcombine seems to be mis-optimizing this function:\r\n```llvm\r\ndefine i32 @f(<4 x i8> %0) {\r\n %2 = call <4 x i8> @llvm.fshr.v4i8(<4 x i8> %0, <4 x i8> zeroinitializer, <4 x i8> <i8 -12, i8 -80, i8 35, i8 1>)\r\n %3 = bitcast <4 x i8> %2 to i32\r\n ret i32 %3\r\n}\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\r\ndeclare <4 x i8> @llvm.fshr.v4i8(<4 x i8>, <4 x i8>, <4 x i8>) #0\r\n\r\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\r\n```\r\nthe result is:\r\n```llvm\r\ndefine i32 @f(<4 x i8> %0) {\r\n %2 = shl <4 x i8> %0, <i8 4, i8 0, i8 5, i8 7>\r\n %3 = bitcast <4 x i8> %2 to i32\r\n ret i32 %3\r\n}\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\r\ndeclare <4 x i8> @llvm.fshr.v4i8(<4 x i8>, <4 x i8>, <4 x i8>) #0\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\r\ndeclare <4 x i8> @llvm.fshl.v4i8(<4 x i8>, <4 x i8>, <4 x i8>) #0\r\n\r\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\r\n```\r\n\r\nAlive says:\r\n```\r\nERROR: Value mismatch\r\n\r\nExample:\r\n<4 x i8> %#0 = < #x00 (0), #x01 (1), #x00 (0), #x00 (0) >\r\n\r\nSource:\r\n<4 x i8> %#2 = < #x00 (0), #x00 (0), #x00 (0), #x00 (0) >\r\ni32 %#3 = #x00000000 (0)\r\n\r\nTarget:\r\n<4 x i8> %#2 = < #x00 (0), #x01 (1), #x00 (0), #x00 (0) >\r\ni32 %#3 = #x00000100 (256)\r\nSource value: #x00000000 (0)\r\nTarget value: #x00000100 (256)\r\n```\r\n\r\nhttps://alive2.llvm.org/ce/z/s4UpPe\r\n\r\ncc @hatsunespica\r\n\r\n",
"author": "regehr",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": [
{
"author": "nikic",
"body": "Smaller test case: https://alive2.llvm.org/ce/z/hScyGk"
},
{
"author": "nikic",
"body": "I believe the root cause is the fshr to fshl canonicalization: https://alive2.llvm.org/ce/z/NQM3tR\r\n\r\nWe're performing this transform: https://alive2.llvm.org/ce/z/6UUEsS But we don't verify the pre-condition that the (modular) shift amount is not zero!\r\n\r\nFor non-vectors this is a non-issue because we'd fold a zero shift earlier, but for vectors it is an issue."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
121459
|
https://github.com/llvm/llvm-project/issues/121459
|
miscompilation
|
68d265666e708bad1c63b419b6275aaba1a7dcd2
| 2025-01-02T09:03:32 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "a4d92400a6db9566d84cb4b900149e36e117f452",
"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": [
[
2782,
2787
],
[
2838,
2843
],
[
2847,
2852
]
],
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.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": [
"foldGEPOfPhi"
],
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.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 a4d92400a6db9566d84cb4b900149e36e117f452
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Fri Jan 3 23:19:57 2025 +0800
[InstCombine] Fix GEPNoWrapFlags propagation in `foldGEPOfPhi` (#121572)
Closes https://github.com/llvm/llvm-project/issues/121459.
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 934156f04f7f..f63de1f0d410 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -2782,6 +2782,7 @@ static Instruction *foldGEPOfPhi(GetElementPtrInst &GEP, PHINode *PN,
// loop iteration).
if (Op1 == &GEP)
return nullptr;
+ GEPNoWrapFlags NW = Op1->getNoWrapFlags();
int DI = -1;
@@ -2838,6 +2839,8 @@ static Instruction *foldGEPOfPhi(GetElementPtrInst &GEP, PHINode *PN,
}
}
}
+
+ NW &= Op2->getNoWrapFlags();
}
// If not all GEPs are identical we'll have to create a new PHI node.
@@ -2847,6 +2850,8 @@ static Instruction *foldGEPOfPhi(GetElementPtrInst &GEP, PHINode *PN,
return nullptr;
auto *NewGEP = cast<GetElementPtrInst>(Op1->clone());
+ NewGEP->setNoWrapFlags(NW);
+
if (DI == -1) {
// All the GEPs feeding the PHI are identical. Clone one down into our
// BB so that it can be merged with the current GEP.
|
[
{
"file": "llvm/test/Transforms/InstCombine/opaque-ptr.ll",
"commands": [
"opt -S -passes='instcombine<no-verify-fixpoint>' < %s"
],
"tests": [
{
"test_name": "gep_of_phi_of_gep_different_type",
"test_body": "define ptr @gep_of_phi_of_gep_different_type(i1 %c, ptr %p) {\n br i1 %c, label %if, label %else\n\nif: ; preds = %0\n %gep1 = getelementptr i32, ptr %p, i64 1\n br label %join\n\nelse: ; preds = %0\n %gep2 = getelementptr i64, ptr %p, i64 2\n br label %join\n\njoin: ; preds = %else, %if\n %phi = phi ptr [ %gep1, %if ], [ %gep2, %else ]\n %gep = getelementptr i32, ptr %phi, i64 1\n ret ptr %gep\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "gep_of_phi_of_gep_flags2",
"test_body": "define ptr @gep_of_phi_of_gep_flags2(i1 %c, ptr %p) {\n br i1 %c, label %if, label %else\n\nif: ; preds = %0\n %gep1 = getelementptr nuw i32, ptr %p, i64 1\n br label %join\n\nelse: ; preds = %0\n %gep2 = getelementptr nuw i32, ptr %p, i64 2\n br label %join\n\njoin: ; preds = %else, %if\n %phi = phi ptr [ %gep1, %if ], [ %gep2, %else ]\n %gep = getelementptr i32, ptr %phi, i64 1\n ret ptr %gep\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "gep_of_phi_of_gep_flags1",
"test_body": "define ptr @gep_of_phi_of_gep_flags1(i1 %c, ptr %p) {\n br i1 %c, label %if, label %else\n\nif: ; preds = %0\n %gep1 = getelementptr inbounds i32, ptr %p, i64 1\n br label %join\n\nelse: ; preds = %0\n %gep2 = getelementptr i32, ptr %p, i64 2\n br label %join\n\njoin: ; preds = %else, %if\n %phi = phi ptr [ %gep1, %if ], [ %gep2, %else ]\n %gep = getelementptr i32, ptr %phi, i64 1\n ret ptr %gep\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstCombine] GEPNoWrapFlags is propagated incorrectly",
"body": "Alive2: https://alive2.llvm.org/ce/z/3ME7S7\n```\ndefine ptr @src(i1 %c, ptr %p) {\n br i1 %c, label %if, label %else\n\nif:\n %gep1 = getelementptr inbounds i32, ptr %p, i64 1\n br label %join\n\nelse:\n %gep2 = getelementptr i64, ptr %p, i64 2\n br label %join\n\njoin:\n %phi = phi ptr [ %gep1, %if ], [ %gep2, %else ]\n %gep = getelementptr i32, ptr %phi, i64 1\n ret ptr %gep\n}\n```\n```\n\n----------------------------------------\ndefine ptr @src(i1 %c, ptr %p) {\n#0:\n br i1 %c, label %if, label %else\n\nelse:\n %gep2 = gep ptr %p, 8 x i64 2\n br label %join\n\nif:\n %gep1 = gep inbounds ptr %p, 4 x i64 1\n br label %join\n\njoin:\n %phi = phi ptr [ %gep1, %if ], [ %gep2, %else ]\n %gep = gep ptr %phi, 4 x i64 1\n ret ptr %gep\n}\n=>\ndefine ptr @src(i1 %c, ptr %p) {\n#0:\n br i1 %c, label %if, label %else\n\nelse:\n br label %join\n\nif:\n br label %join\n\njoin:\n %#1 = phi i64 [ 4, %if ], [ 16, %else ]\n %#2 = gep inbounds nuw ptr %p, 1 x i64 %#1\n %gep = gep ptr %#2, 1 x i64 4\n ret ptr %gep\n}\nTransformation doesn't verify!\n\nERROR: Target is more poisonous than source\n\nExample:\ni1 %c = #x0 (0)\nptr %p = null\n\nSource:\n >> Jump to %else\nptr %gep2 = pointer(non-local, block_id=0, offset=16) / Address=#x0000000000000010\n >> Jump to %join\nptr %phi = pointer(non-local, block_id=0, offset=16) / Address=#x0000000000000010\nptr %gep = pointer(non-local, block_id=0, offset=20) / Address=#x0000000000000014\n\nSOURCE MEMORY STATE\n===================\nNON-LOCAL BLOCKS:\nBlock 0 >\tsize: 0\talign: 1\talloc type: 0\talive: false\taddress: 0\nBlock 1 >\tsize: 0\talign: 1\talloc type: 0\talive: true\taddress: 1\n\nTarget:\n >> Jump to %else\n >> Jump to %join\ni64 %#1 = #x0000000000000010 (16)\nptr %#2 = poison\nptr %gep = poison\nSource value: pointer(non-local, block_id=0, offset=20) / Address=#x0000000000000014\nTarget value: poison\n\nSummary:\n 0 correct transformations\n 1 incorrect transformations\n 0 failed-to-prove transformations\n 0 Alive2 errors\n```\n",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
110494
|
https://github.com/llvm/llvm-project/issues/110494
|
crash
|
1ba19d6c49663a35baf5d6cdc4a149e2aca9ae6c
| 2024-09-30T11:42:07 |
[
"llvm/test/Transforms/LoopStrengthReduce"
] |
{
"fix_commit": "7506872afc6c1cc7556eed5128a2030b6eb8ca29",
"components": [
"LoopStrengthReduce"
],
"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": [
[
6870,
6875
]
],
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.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": [
"SalvageDVI"
],
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.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 7506872afc6c1cc7556eed5128a2030b6eb8ca29
Author: Orlando Cazalet-Hyams <orlando.hyams@sony.com>
Date: Thu Oct 3 11:47:08 2024 +0100
[DebugInfo][LSR] Fix assertion failure salvaging IV with offset > 64 bits wide (#110979)
Fixes #110494
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index f69db57c25ed..575395eda1c5 100644
--- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -6870,6 +6870,8 @@ static bool SalvageDVI(llvm::Loop *L, ScalarEvolution &SE,
SE.computeConstantDifference(DVIRec.SCEVs[i], SCEVInductionVar)) {
if (Offset->getSignificantBits() <= 64)
SalvageExpr->createOffsetExpr(Offset->getSExtValue(), LSRInductionVar);
+ else
+ return false;
} else if (!SalvageExpr->createIterCountExpr(DVIRec.SCEVs[i], IterCountExpr,
SE))
return false;
|
[
{
"file": "llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-large-width.ll",
"commands": [
"opt -S -loop-reduce %s"
],
"tests": [
{
"test_name": "main",
"test_body": "define i16 @main() {\nentry:\n br label %for.cond29\n\nfor.cond29: ; preds = %for.body32, %entry\n %il_1000.0 = phi i128 [ 0, %entry ], [ %inc72, %for.body32 ]\n %l_995.0 = phi i128 [ 4704496199548239085565, %entry ], [ %inc70, %for.body32 ]\n #dbg_value(i128 %l_995.0, !4, !DIExpression(), !9)\n %cmp30 = icmp slt i128 %il_1000.0, 0\n br i1 %cmp30, label %for.body32, label %for.cond.cleanup31\n\nfor.cond.cleanup31: ; preds = %for.cond29\n ret i16 0\n\nfor.body32: ; preds = %for.cond29\n %inc70 = add i128 %l_995.0, 1\n %inc72 = add i128 %il_1000.0, 1\n br label %for.cond29\n}\n\n!llvm.dbg.cu = !{!0}\n!llvm.module.flags = !{!3}\n\n!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: \"clang\", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, retainedTypes: !2, globals: !2, splitDebugInlining: false, nameTableKind: None)\n!1 = !DIFile(filename: \"foo.c\", directory: \"/tmp\")\n!2 = !{}\n!3 = !{i32 2, !\"Debug Info Version\", i32 3}\n!4 = !DILocalVariable(name: \"l_995\", scope: !5, file: !1, line: 414, type: !7)\n!5 = distinct !DISubprogram(name: \"main\", scope: !1, file: !1, line: 397, type: !6, scopeLine: 398, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)\n!6 = !DISubroutineType(types: !2)\n!7 = !DIDerivedType(tag: DW_TAG_typedef, name: \"__uint128_t\", file: !1, baseType: !8)\n!8 = !DIBasicType(name: \"unsigned __int128\", size: 128, encoding: DW_ATE_unsigned)\n!9 = !DILocation(line: 0, scope: !5)\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "llc: ../lib/Transforms/Scalar/LoopStrengthReduce.cpp:6630: [...] Assertion `!LocationOps.empty() && \"Expected the location ops to contain the IV.\"' failed.",
"body": "llvm commit: 82e594a022d\r\nReproduce with: ```llc bbi-99605.ll -o /dev/null```\r\nResult:\r\n```\r\nllc: ../lib/Transforms/Scalar/LoopStrengthReduce.cpp:6630: void (anonymous namespace)::SCEVDbgValueBuilder::appendToVectors(SmallVectorImpl<uint64_t> &, SmallVectorImpl<llvm::Value *> &): Assertion `!LocationOps.empty() && \"Expected the location ops to contain the IV.\"' 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: build-all/bin/llc bbi-99605.ll -o /dev/null\r\n1.\tRunning pass 'Function Pass Manager' on module 'bbi-99605.ll'.\r\n2.\tRunning pass 'Loop Pass Manager' on function '@main'\r\n3.\tRunning pass 'Loop Strength Reduction' on basic block '%for.cond29'\r\n #0 0x000055e150599557 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (build-all/bin/llc+0x6dee557)\r\n #1 0x000055e1505970be llvm::sys::RunSignalHandlers() (build-all/bin/llc+0x6dec0be)\r\n #2 0x000055e150599bff SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007f66b410bcf0 __restore_rt (/lib64/libpthread.so.0+0x12cf0)\r\n #4 0x00007f66b1cc4acf raise (/lib64/libc.so.6+0x4eacf)\r\n #5 0x00007f66b1c97ea5 abort (/lib64/libc.so.6+0x21ea5)\r\n #6 0x00007f66b1c97d79 _nl_load_domain.cold.0 (/lib64/libc.so.6+0x21d79)\r\n #7 0x00007f66b1cbd426 (/lib64/libc.so.6+0x47426)\r\n #8 0x000055e15005db21 (build-all/bin/llc+0x68b2b21)\r\n #9 0x000055e15005c0c3 SalvageDVI(llvm::Loop*, llvm::ScalarEvolution&, llvm::PHINode*, (anonymous namespace)::DVIRecoveryRec&, llvm::SCEV const*, (anonymous namespace)::SCEVDbgValueBuilder) LoopStrengthReduce.cpp:0:0\r\n#10 0x000055e15002dca8 ReduceLoopStrength(llvm::Loop*, llvm::IVUsers&, llvm::ScalarEvolution&, llvm::DominatorTree&, llvm::LoopInfo&, llvm::TargetTransformInfo const&, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::MemorySSA*) LoopStrengthReduce.cpp:0:0\r\n#11 0x000055e15005e7e8 (anonymous namespace)::LoopStrengthReduce::runOnLoop(llvm::Loop*, llvm::LPPassManager&) LoopStrengthReduce.cpp:0:0\r\n#12 0x000055e14f26f0f9 llvm::LPPassManager::runOnFunction(llvm::Function&) (build-all/bin/llc+0x5ac40f9)\r\n#13 0x000055e14fba9e38 llvm::FPPassManager::runOnFunction(llvm::Function&) (build-all/bin/llc+0x63fee38)\r\n#14 0x000055e14fbb2171 llvm::FPPassManager::runOnModule(llvm::Module&) (build-all/bin/llc+0x6407171)\r\n#15 0x000055e14fbaa8b5 llvm::legacy::PassManagerImpl::run(llvm::Module&) (build-all/bin/llc+0x63ff8b5)\r\n#16 0x000055e14d988be8 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0\r\n#17 0x000055e14d98626d main (build-all/bin/llc+0x41db26d)\r\n#18 0x00007f66b1cb0d85 __libc_start_main (/lib64/libc.so.6+0x3ad85)\r\n#19 0x000055e14d9822ee _start (build-all/bin/llc+0x41d72ee)\r\nAbort (core dumped)\r\n```\r\nThe input contains the new debug info:\r\n```#dbg_value(i128 %l_995.0, !4, !DIExpression(), !9)```\r\n\r\n[bbi-99605.ll.gz](https://github.com/user-attachments/files/17189125/bbi-99605.ll.gz)\r\n",
"author": "mikaelholmen",
"labels": [
"debuginfo",
"crash",
"llvm:transforms"
],
"comments": [
{
"author": "OCHyams",
"body": "Thanks for the small reproducer. That is fixed in #110979 - this PR just avoids us crash/asserting when a salvage attempt is made with an offset over 64 bits wide and poisons the dbg record instead. I didn't look into whether we could theoretically or practically salvage it.\r\n\r\nn.b., this case was broken with debug intrinsics too, not just the new debug record format."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
89390
|
https://github.com/llvm/llvm-project/issues/89390
|
miscompilation
|
d674f45d51bffbba474b12e07f7d57a2390d2f31
| 2024-04-19T14:44:07 |
[
"llvm/test/Transforms/VectorCombine"
] |
{
"fix_commit": "4cc9c6d98dfef90d1ffa69977d13ffa2894a10f7",
"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": [
[
1405,
1410
]
],
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 4cc9c6d98dfef90d1ffa69977d13ffa2894a10f7
Author: Simon Pilgrim <llvm-dev@redking.me.uk>
Date: Mon Apr 22 09:00:20 2024 +0100
[VectorCombine] foldShuffleOfBinops - don't fold shuffle(divrem(x,y),divrem(z,w)) if mask contains poison
Fixes #89390
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index 4918cee1fa82..f23b10540338 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -1405,6 +1405,11 @@ bool VectorCombine::foldShuffleOfBinops(Instruction &I) {
B0->getOpcode() != B1->getOpcode() || B0->getType() != VecTy)
return false;
+ // Don't introduce poison into div/rem.
+ if (any_of(Mask, [](int M) { return M == PoisonMaskElem; }) &&
+ B0->isIntDivRem())
+ return false;
+
// Try to replace a binop with a shuffle if the shuffle is not costly.
// The new shuffle will choose from a single, common operand, so it may be
// cheaper than the existing two-operand shuffle.
|
[
{
"file": "llvm/test/Transforms/VectorCombine/X86/shuffle-of-binops.ll",
"commands": [
"opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=SSE2",
"opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=AVX2"
],
"tests": [
{
"test_name": "shuf_and_v16i16_yy_expensive_shuf",
"test_body": "define <16 x i16> @shuf_and_v16i16_yy_expensive_shuf(<16 x i16> %x, <16 x i16> %y, <16 x i16> %z) {\n %b0 = and <16 x i16> %x, %y\n %b1 = and <16 x i16> %y, %z\n %r = shufflevector <16 x i16> %b0, <16 x i16> %b1, <16 x i32> <i32 15, i32 22, i32 25, i32 13, i32 28, i32 0, i32 poison, i32 3, i32 0, i32 30, i32 3, i32 7, i32 9, i32 19, i32 2, i32 22>\n ret <16 x i16> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "shuf_srem_v4i32_poison",
"test_body": "define <4 x i32> @shuf_srem_v4i32_poison(<4 x i32> %a0, <4 x i32> %a1) {\n %srem0 = srem <4 x i32> %a1, %a0\n %srem1 = srem <4 x i32> splat (i32 1), %a0\n %r = shufflevector <4 x i32> %srem0, <4 x i32> %srem1, <4 x i32> <i32 0, i32 poison, i32 6, i32 3>\n ret <4 x i32> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "VectorCombine transform leading to srem by poison",
"body": "https://alive2.llvm.org/ce/z/HRAkAK\r\n\r\nthis:\r\n```llvm\r\ndefine <4 x i32> @f(<4 x i32> %0, <4 x i32> %1) {\r\n %3 = srem <4 x i32> %1, %0\r\n %4 = srem <4 x i32> <i32 1, i32 1, i32 1, i32 1>, %0\r\n %5 = shufflevector <4 x i32> %3, <4 x i32> %4, <4 x i32> <i32 0, i32 poison, i32 6, i32 3>\r\n ret <4 x i32> %5\r\n}\r\n```\r\nis getting vector-combined to this:\r\n```llvm\r\ndefine <4 x i32> @f(<4 x i32> %0, <4 x i32> %1) {\r\n %3 = shufflevector <4 x i32> %1, <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32> <i32 0, i32 poison, i32 6, i32 3>\r\n %4 = shufflevector <4 x i32> %0, <4 x i32> poison, <4 x i32> <i32 0, i32 poison, i32 2, i32 3>\r\n %5 = srem <4 x i32> %3, %4\r\n ret <4 x i32> %5\r\n}\r\n```\r\n\r\nbut that poison in lane 1 is now problematic, this gives us full UB when it hits the srem\r\n\r\ncc @nunoplopes @hatsunespica\r\n",
"author": "regehr",
"labels": [
"miscompilation",
"vectorizers"
],
"comments": [
{
"author": "RKSimon",
"body": "I'll take a look at this"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
140444
|
https://github.com/llvm/llvm-project/issues/140444
|
miscompilation
|
0b553e055ad01ca6a2c88f7da92157df29e42fd0
| 2025-05-18T09:13:07 |
[
"llvm/test/Transforms/LoopUnroll"
] |
{
"fix_commit": "a0a2a1e095ddd092e668b0b3f9a7dfa9655255e1",
"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": [
[
343,
354
]
],
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": [
"llvm::canPeelLastIteration"
],
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.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 a0a2a1e095ddd092e668b0b3f9a7dfa9655255e1
Author: Florian Hahn <flo@fhahn.com>
Date: Sun May 18 11:47:03 2025 +0100
[LoopPeel] Make sure exit condition has a single use when peeling last.
Update the check in canPeelLastIteration to make sure the exiting
condition has a single use. When peeling the last iteration, we adjust
the condition in the loop body to be true one iteration early, which
would be incorrect for other users.
Fixes https://github.com/llvm/llvm-project/issues/140444.
diff --git a/llvm/lib/Transforms/Utils/LoopPeel.cpp b/llvm/lib/Transforms/Utils/LoopPeel.cpp
index 646354bba9df..4eaa3c971437 100644
--- a/llvm/lib/Transforms/Utils/LoopPeel.cpp
+++ b/llvm/lib/Transforms/Utils/LoopPeel.cpp
@@ -343,12 +343,12 @@ bool llvm::canPeelLastIteration(const Loop &L, ScalarEvolution &SE) {
// codegen. For now, it must
// * exit via the latch,
// * the exit condition must be a NE/EQ compare of an induction with step
- // of 1.
+ // of 1 and must only be used by the exiting branch.
BasicBlock *Latch = L.getLoopLatch();
return Latch && Latch == L.getExitingBlock() &&
match(Latch->getTerminator(),
- m_Br(m_ICmp(Pred, m_Value(Inc), m_Value()), m_BasicBlock(Succ1),
- m_BasicBlock(Succ2))) &&
+ m_Br(m_OneUse(m_ICmp(Pred, m_Value(Inc), m_Value())),
+ m_BasicBlock(Succ1), m_BasicBlock(Succ2))) &&
((Pred == CmpInst::ICMP_EQ && Succ2 == L.getHeader()) ||
(Pred == CmpInst::ICMP_NE && Succ1 == L.getHeader())) &&
isa<SCEVAddRecExpr>(SE.getSCEV(Inc)) &&
|
[
{
"file": "llvm/test/Transforms/LoopUnroll/peel-last-iteration.ll",
"commands": [
"opt -p loop-unroll -unroll-full-max-count=0 -S %s"
],
"tests": [
{
"test_name": "exit_condition_has_other_loop_users",
"test_body": "define void @exit_condition_has_other_loop_users() {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i16 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %iv.next = add i16 %iv, 1\n %ec = icmp eq i16 %iv, 100\n br i1 %ec, label %loop.latch, label %then\n\nthen: ; preds = %loop.header\n call void @foo(i32 10)\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n call void @foo(i32 20)\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\ndeclare void @foo(i32)\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[LoopFullUnroll] Miscompilation at O3",
"body": "Reproducer:\n```\n; bin/opt -passes=loop-unroll-full 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_479 = global i8 -1\n@crc32_tab = global [256 x i32] zeroinitializer\n@.str.8 = constant [15 x i8] c\"checksum = %X\\0A\\00\"\n\ndefine i32 @main() {\nentry:\n br label %for.cond1.preheader.i\n\nfor.cond1.preheader.i: ; preds = %for.cond1.preheader.i, %entry\n %indvars.iv.i = phi i64 [ 0, %entry ], [ %indvars.iv.next.i, %for.cond1.preheader.i ]\n %0 = and i64 %indvars.iv.i, 20\n %tobool.not.4.not.i = icmp eq i64 %0, 16\n %xor.5.i = select i1 %tobool.not.4.not.i, i32 0, i32 1\n %arrayidx.i = getelementptr [256 x i32], ptr @crc32_tab, i64 0, i64 %indvars.iv.i\n store i32 %xor.5.i, ptr %arrayidx.i, align 4\n %indvars.iv.next.i = add i64 %indvars.iv.i, 1\n %exitcond.not.i = icmp eq i64 %indvars.iv.next.i, 256\n br i1 %exitcond.not.i, label %lbl_1516.us.us.i.i, label %for.cond1.preheader.i\n\nlbl_1516.us.us.i.i: ; preds = %lbl_1587.us.us.i.i, %for.cond1.preheader.i\n %conv134690.us.us.i.i = phi i8 [ %spec.select.i.i, %lbl_1587.us.us.i.i ], [ 0, %for.cond1.preheader.i ]\n %l_1485.0.us.us.i.i = phi i16 [ %inc130.us.us.i.i, %lbl_1587.us.us.i.i ], [ -14340, %for.cond1.preheader.i ]\n %inc130.us.us.i.i = add i16 %l_1485.0.us.us.i.i, 1\n %tobool132.not.us.us.i.i = icmp eq i8 %conv134690.us.us.i.i, 0\n br i1 %tobool132.not.us.us.i.i, label %lbl_1587.us.us.i.i, label %land.rhs133.us.us.i.i\n\nland.rhs133.us.us.i.i: ; preds = %lbl_1516.us.us.i.i\n store i8 25, ptr @g_479, align 1\n br label %lbl_1587.us.us.i.i\n\nlbl_1587.us.us.i.i: ; preds = %land.rhs133.us.us.i.i, %lbl_1516.us.us.i.i\n %tobool293.not.not.us.us.i.i = icmp eq i16 %l_1485.0.us.us.i.i, 0\n %spec.select.i.i = select i1 %tobool293.not.not.us.us.i.i, i8 1, i8 0\n br i1 %tobool293.not.not.us.us.i.i, label %func_134.exit, label %lbl_1516.us.us.i.i\n\nfunc_134.exit: ; preds = %lbl_1587.us.us.i.i\n %1 = load i8, ptr @g_479, align 1\n %idxprom.i.i.i = zext i8 %1 to i64\n %arrayidx.i.i.i = getelementptr [256 x i32], ptr @crc32_tab, i64 0, i64 %idxprom.i.i.i\n %2 = load i32, ptr %arrayidx.i.i.i, align 4\n %call.i = call i32 (ptr, ...) @printf(ptr @.str.8, i32 %2)\n ret i32 0\n}\n\ndeclare i32 @printf(ptr, ...)\n```\n```\n; ModuleID = 'reduced.ll'\nsource_filename = \"reduced.ll\"\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@g_479 = global i8 -1\n@crc32_tab = global [256 x i32] zeroinitializer\n@.str.8 = constant [15 x i8] c\"checksum = %X\\0A\\00\"\n\ndefine i32 @main() {\nentry:\n br label %for.cond1.preheader.i\n\nfor.cond1.preheader.i: ; preds = %for.cond1.preheader.i, %entry\n %indvars.iv.i = phi i64 [ 0, %entry ], [ %indvars.iv.next.i, %for.cond1.preheader.i ]\n %0 = and i64 %indvars.iv.i, 20\n %tobool.not.4.not.i = icmp eq i64 %0, 16\n %xor.5.i = select i1 %tobool.not.4.not.i, i32 0, i32 1\n %arrayidx.i = getelementptr [256 x i32], ptr @crc32_tab, i64 0, i64 %indvars.iv.i\n store i32 %xor.5.i, ptr %arrayidx.i, align 4\n %indvars.iv.next.i = add i64 %indvars.iv.i, 1\n %exitcond.not.i = icmp eq i64 %indvars.iv.next.i, 256\n br i1 %exitcond.not.i, label %lbl_1516.us.us.i.i.preheader, label %for.cond1.preheader.i\n\nlbl_1516.us.us.i.i.preheader: ; preds = %for.cond1.preheader.i\n br label %lbl_1516.us.us.i.i\n\nlbl_1516.us.us.i.i: ; preds = %lbl_1516.us.us.i.i.preheader, %lbl_1587.us.us.i.i\n %conv134690.us.us.i.i = phi i8 [ %spec.select.i.i, %lbl_1587.us.us.i.i ], [ 0, %lbl_1516.us.us.i.i.preheader ]\n %l_1485.0.us.us.i.i = phi i16 [ %inc130.us.us.i.i, %lbl_1587.us.us.i.i ], [ -14340, %lbl_1516.us.us.i.i.preheader ]\n %inc130.us.us.i.i = add nsw i16 %l_1485.0.us.us.i.i, 1\n %tobool132.not.us.us.i.i = icmp eq i8 %conv134690.us.us.i.i, 0\n br i1 %tobool132.not.us.us.i.i, label %lbl_1587.us.us.i.i, label %land.rhs133.us.us.i.i\n\nland.rhs133.us.us.i.i: ; preds = %lbl_1516.us.us.i.i\n store i8 25, ptr @g_479, align 1\n br label %lbl_1587.us.us.i.i\n\nlbl_1587.us.us.i.i: ; preds = %land.rhs133.us.us.i.i, %lbl_1516.us.us.i.i\n %tobool293.not.not.us.us.i.i = icmp eq i16 %l_1485.0.us.us.i.i, -1\n %spec.select.i.i = select i1 %tobool293.not.not.us.us.i.i, i8 1, i8 0\n br i1 %tobool293.not.not.us.us.i.i, label %func_134.exit.peel.begin, label %lbl_1516.us.us.i.i, !llvm.loop !0\n\nfunc_134.exit.peel.begin: ; preds = %lbl_1587.us.us.i.i\n %spec.select.i.i.lcssa = phi i8 [ %spec.select.i.i, %lbl_1587.us.us.i.i ]\n %inc130.us.us.i.i.lcssa = phi i16 [ %inc130.us.us.i.i, %lbl_1587.us.us.i.i ]\n br label %lbl_1516.us.us.i.i.peel\n\nlbl_1516.us.us.i.i.peel: ; preds = %func_134.exit.peel.begin\n %inc130.us.us.i.i.peel = add i16 %inc130.us.us.i.i.lcssa, 1\n %tobool132.not.us.us.i.i.peel = icmp eq i8 %spec.select.i.i.lcssa, 0\n br i1 %tobool132.not.us.us.i.i.peel, label %lbl_1587.us.us.i.i.peel, label %land.rhs133.us.us.i.i.peel\n\nland.rhs133.us.us.i.i.peel: ; preds = %lbl_1516.us.us.i.i.peel\n store i8 25, ptr @g_479, align 1\n br label %lbl_1587.us.us.i.i.peel\n\nlbl_1587.us.us.i.i.peel: ; preds = %land.rhs133.us.us.i.i.peel, %lbl_1516.us.us.i.i.peel\n %tobool293.not.not.us.us.i.i.peel = icmp eq i16 %inc130.us.us.i.i.lcssa, 0\n %spec.select.i.i.peel = select i1 %tobool293.not.not.us.us.i.i.peel, i8 1, i8 0\n br i1 %tobool293.not.not.us.us.i.i.peel, label %func_134.exit.peel.next, label %func_134.exit.peel.next\n\nfunc_134.exit.peel.next: ; preds = %lbl_1587.us.us.i.i.peel, %lbl_1587.us.us.i.i.peel\n br label %lbl_1516.us.us.i.i.peel.next\n\nlbl_1516.us.us.i.i.peel.next: ; preds = %func_134.exit.peel.next\n br label %func_134.exit\n\nfunc_134.exit: ; preds = %lbl_1516.us.us.i.i.peel.next\n %1 = load i8, ptr @g_479, align 1\n %idxprom.i.i.i = zext i8 %1 to i64\n %arrayidx.i.i.i = getelementptr [256 x i32], ptr @crc32_tab, i64 0, i64 %idxprom.i.i.i\n %2 = load i32, ptr %arrayidx.i.i.i, align 4\n %call.i = call i32 (ptr, ...) @printf(ptr @.str.8, i32 %2)\n ret i32 0\n}\n\ndeclare i32 @printf(ptr, ...)\n\n!0 = distinct !{!0, !1}\n!1 = !{!\"llvm.loop.peeled.count\", i32 1}\n```\nBefore:\n```\nchecksum = 1\n```\nAfter:\n```\nchecksum = 0\n```\nllvm version: 3ccb15d6caf57f2a866d496ada2fb52d14b179d2\n",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:transforms",
"generated by fuzzer"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Reverting https://github.com/llvm/llvm-project/commit/3fcfce4c5e5fd1c3072e8db1d692c93459e8cd74 fixes this miscompilation. And https://github.com/llvm/llvm-project/commit/7e14161f49b32387988cf9d937bbfaa27d0fbdd5 doesn't fix this problem. cc @fhahn \n\n"
},
{
"author": "fhahn",
"body": "Issue is that we modify the exit condition w/o checking for other users."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
115574
|
https://github.com/llvm/llvm-project/issues/115574
|
miscompilation
|
00bdce1c373a1c5b756f4cf694a952ef702d0294
| 2024-11-09T01:49:48 |
[
"llvm/test/Transforms/InstSimplify"
] |
{
"fix_commit": "1af627b592dd15bbe58136f902ced46251fc344d",
"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": [
[
27,
32
],
[
4731,
4742
]
],
"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": [
"simplifySelectWithICmpCond"
],
"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 1af627b592dd15bbe58136f902ced46251fc344d
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Sun Feb 2 19:04:23 2025 +0800
[InstSimplify] Add additional checks when substituting pointers (#125385)
Compile-time impact:
https://llvm-compile-time-tracker.com/compare.php?from=d09b521624f263b5f1296f8d4771836b97e600cb&to=e437ba2cb83bb965e13ef00727671896f03ff84f&stat=instructions:u
IR diff looks acceptable.
Closes https://github.com/llvm/llvm-project/issues/115574
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 21c937530cd8..3cbc4107433e 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -27,6 +27,7 @@
#include "llvm/Analysis/CmpInstAnalysis.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Analysis/InstSimplifyFolder.h"
+#include "llvm/Analysis/Loads.h"
#include "llvm/Analysis/LoopAnalysisManager.h"
#include "llvm/Analysis/MemoryBuiltins.h"
#include "llvm/Analysis/OverflowInstAnalysis.h"
@@ -4731,12 +4732,16 @@ static Value *simplifySelectWithICmpCond(Value *CondVal, Value *TrueVal,
// the arms of the select. See if substituting this value into the arm and
// simplifying the result yields the same value as the other arm.
if (Pred == ICmpInst::ICMP_EQ) {
- if (Value *V = simplifySelectWithEquivalence({{CmpLHS, CmpRHS}}, TrueVal,
- FalseVal, Q, MaxRecurse))
- return V;
- if (Value *V = simplifySelectWithEquivalence({{CmpRHS, CmpLHS}}, TrueVal,
- FalseVal, Q, MaxRecurse))
- return V;
+ if (CmpLHS->getType()->isIntOrIntVectorTy() ||
+ canReplacePointersIfEqual(CmpLHS, CmpRHS, Q.DL))
+ if (Value *V = simplifySelectWithEquivalence({{CmpLHS, CmpRHS}}, TrueVal,
+ FalseVal, Q, MaxRecurse))
+ return V;
+ if (CmpLHS->getType()->isIntOrIntVectorTy() ||
+ canReplacePointersIfEqual(CmpRHS, CmpLHS, Q.DL))
+ if (Value *V = simplifySelectWithEquivalence({{CmpRHS, CmpLHS}}, TrueVal,
+ FalseVal, Q, MaxRecurse))
+ return V;
Value *X;
Value *Y;
|
[
{
"file": "llvm/test/Transforms/InstSimplify/select-icmp.ll",
"commands": [
"opt < %s -passes=instsimplify -S"
],
"tests": [
{
"test_name": "icmp_ptr_eq_replace_null",
"test_body": "target datalayout = \"p:8:8:8\"\n\ndefine ptr @icmp_ptr_eq_replace_null(ptr %a) {\n %cmp = icmp eq ptr %a, null\n %sel = select i1 %cmp, ptr null, ptr %a\n ret ptr %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "ptr_eq_replace_same_underlying_object",
"test_body": "target datalayout = \"p:8:8:8\"\n\ndefine ptr @ptr_eq_replace_same_underlying_object(ptr %st, i64 %i, i64 %j) {\n %a = getelementptr inbounds i8, ptr %st, i64 %i\n %b = getelementptr inbounds i8, ptr %st, i64 %j\n %cmp = icmp eq ptr %a, %b\n %sel = select i1 %cmp, ptr %a, ptr %b\n ret ptr %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "icmp_ptr_eq_replace",
"test_body": "target datalayout = \"p:8:8:8\"\n\ndefine ptr @icmp_ptr_eq_replace(ptr %a, ptr %b) {\n %cmp = icmp eq ptr %a, %b\n %sel = select i1 %cmp, ptr %a, ptr %b\n ret ptr %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstSimplify] wrong folding of pointer comparison `select (icmp eq ptr ...)`",
"body": "https://github.com/llvm/llvm-project/blob/c93e001ca695e905cb965b36d63f7a348d1dd809/llvm/lib/Analysis/InstructionSimplify.cpp#L148-L167\r\n\r\nAlive2 report: https://alive2.llvm.org/ce/z/aux2zY\r\n\r\n```llvm\r\n----------------------------------------\r\ndefine ptr @smin_test8.2(ptr %a, ptr %b, ptr %c) {\r\n#0:\r\n %cmp1 = icmp eq ptr %a, %b\r\n %umin1 = select i1 %cmp1, ptr %a, ptr %b\r\n %cmp2 = icmp slt ptr %b, %c\r\n %umin2 = select i1 %cmp2, ptr %b, ptr %c\r\n %cmp3 = icmp ult ptr %umin2, %a\r\n %umin3 = select i1 %cmp3, ptr %umin2, ptr %a\r\n %cmp4 = icmp slt ptr %c, %umin3\r\n %res = select i1 %cmp4, ptr %umin1, ptr %umin3\r\n ret ptr %res\r\n}\r\n=>\r\ndefine ptr @smin_test8.2(ptr %a, ptr %b, ptr %c) {\r\n#0:\r\n %cmp2 = icmp slt ptr %b, %c\r\n %umin2 = select i1 %cmp2, ptr %b, ptr %c\r\n %cmp3 = icmp ult ptr %umin2, %a\r\n %umin3 = select i1 %cmp3, ptr %umin2, ptr %a\r\n %cmp4 = icmp slt ptr %c, %umin3\r\n %res = select i1 %cmp4, ptr %b, ptr %umin3\r\n ret ptr %res\r\n}\r\nTransformation doesn't verify!\r\n\r\nERROR: Value mismatch\r\n\r\nExample:\r\nptr %a = pointer(non-local, block_id=0, offset=1) / Address=#x1\r\nptr %b = pointer(non-local, block_id=1, offset=0) / Address=#x1\r\nptr %c = pointer(non-local, block_id=0, offset=-8) / Address=#x8\r\n\r\nSource:\r\ni1 %cmp1 = #x1 (1)\r\nptr %umin1 = pointer(non-local, block_id=0, offset=1) / Address=#x1\r\ni1 %cmp2 = #x0 (0)\r\nptr %umin2 = pointer(non-local, block_id=0, offset=-8) / Address=#x8\r\ni1 %cmp3 = #x0 (0)\r\nptr %umin3 = pointer(non-local, block_id=0, offset=1) / Address=#x1\r\ni1 %cmp4 = #x1 (1)\r\nptr %res = pointer(non-local, block_id=0, offset=1) / Address=#x1\r\n\r\nSOURCE MEMORY STATE\r\n===================\r\nNON-LOCAL BLOCKS:\r\nBlock 0 >\tsize: 0\talign: 1\talloc type: 0\talive: false\taddress: 0\r\nBlock 1 >\tsize: 1\talign: 1\talloc type: 0\talive: true\taddress: 1\r\nBlock 2 >\tsize: 1\talign: 1\talloc type: 0\talive: true\taddress: 2\r\nBlock 3 >\tsize: 3\talign: 1\talloc type: 0\talive: true\taddress: 8\r\n\r\nTarget:\r\ni1 %cmp2 = #x0 (0)\r\nptr %umin2 = pointer(non-local, block_id=0, offset=-8) / Address=#x8\r\ni1 %cmp3 = #x0 (0)\r\nptr %umin3 = pointer(non-local, block_id=0, offset=1) / Address=#x1\r\ni1 %cmp4 = #x1 (1)\r\nptr %res = pointer(non-local, block_id=1, offset=0) / Address=#x1\r\nSource value: pointer(non-local, block_id=0, offset=1) / Address=#x1\r\nTarget value: pointer(non-local, block_id=1, offset=0) / Address=#x1\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:analysis"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
111040
|
https://github.com/llvm/llvm-project/issues/111040
|
crash
|
b3e0bd3d284dec705386b1efcae40dd51b763010
| 2024-10-03T18:42:52 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "45b526afa26e76e0c351e947ac8f0e4b55aa760b",
"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": [
[
6196,
6206
]
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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::setVectorizedCallDecision"
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 45b526afa26e76e0c351e947ac8f0e4b55aa760b
Author: Florian Hahn <flo@fhahn.com>
Date: Sun Oct 6 10:34:37 2024 +0100
[LV] Honor uniform-after-vectorization in setVectorizedCallDecision.
The legacy cost model always computes the cost for uniforms as cost of
VF = 1, but VPWidenCallRecipes would be created, as
setVectorizedCallDecisions would not consider uniform calls.
Fix setVectorizedCallDecision to set to Scalarize, if the call is
uniform-after-vectorization.
This fixes a bug in VPlan construction uncovered by the VPlan-based
cost model.
Fixes https://github.com/llvm/llvm-project/issues/111040.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 6e082b1c134d..35c042b3ab7f 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -6196,11 +6196,12 @@ void LoopVectorizationCostModel::setVectorizedCallDecision(ElementCount VF) {
getScalarizationOverhead(CI, VF, CostKind);
ScalarCost = ScalarCallCost * VF.getKnownMinValue() + ScalarizationCost;
- // Honor ForcedScalars decision.
+ // Honor ForcedScalars and UniformAfterVectorization decisions.
// TODO: For calls, it might still be more profitable to widen. Use
// VPlan-based cost model to compare different options.
- if (VF.isVector() && ForcedScalar != ForcedScalars.end() &&
- ForcedScalar->second.contains(CI)) {
+ if (VF.isVector() && ((ForcedScalar != ForcedScalars.end() &&
+ ForcedScalar->second.contains(CI)) ||
+ isUniformAfterVectorization(CI, VF))) {
setCallWideningDecision(CI, VF, CM_Scalarize, nullptr,
Intrinsic::not_intrinsic, std::nullopt,
ScalarCost);
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/X86/replicate-uniform-call.ll",
"commands": [
"opt -p loop-vectorize -S %s"
],
"tests": [
{
"test_name": "smax_call_uniform",
"test_body": "target datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @smax_call_uniform(ptr %dst, i64 %x) {\nentry:\n %c = icmp ult i8 -68, -69\n %mul = mul nuw nsw i64 %x, 0\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n br i1 %c, label %loop.latch, label %else\n\nelse: ; preds = %loop.header\n %rem = urem i64 %mul, %x\n %smax = tail call i64 @llvm.smax.i64(i64 %rem, i64 0)\n br label %loop.latch\n\nloop.latch: ; preds = %else, %loop.header\n %p = phi i64 [ 1, %loop.header ], [ %smax, %else ]\n %add = add i64 %p, 1\n %gep = getelementptr i64, ptr %dst, i64 %add\n store i64 0, ptr %gep, align 8\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv.next, 0\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i64 @llvm.smax.i64(i64, i64) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[clang] Assertion failed in LoopVectorize.cpp:7401",
"body": "When I compiled the code with -O2 flag, it crashed:\r\n\r\n```c\r\n#include <stdint.h>\r\nstatic uint8_t b = 188;\r\nvoid c();\r\nlong d(int e, int p2, short j) {\r\n long f = 0, a = 1;\r\n unsigned long g;\r\n int h;\r\n if (e < 0 || j < 0)\r\n return 1;\r\n h = 0;\r\n for (; h < p2; h++) {\r\n a *= j + 1;\r\n g = e * a;\r\n f += g % (j + 1);\r\n }\r\n if (f < 0)\r\n return 0;\r\n return f;\r\n}\r\nvoid i();\r\nint64_t k() {\r\n uint32_t l[][8][10] = {0, 4, 7, 1, 4, 3446557846};\r\n int64_t m[10];\r\n int h;\r\n for (h = 0; c + h < 10; h++)\r\n m[(int)d(5, l[0][0][5] - 3446557842, b - 187) + h] = 1;\r\n i(m);\r\n uint8_t *n = &b;\r\n uint8_t **o;\r\n o[0] = &n;\r\n}\r\n```\r\n\r\nThe crash is:\r\n```\r\nclang: /root/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7401: 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\n```\r\n\r\nDetails can be found here: https://godbolt.org/z/hqP8vMG7b\r\n",
"author": "cardigan1008",
"labels": [
"regression",
"vectorizers",
"crash"
],
"comments": [
{
"author": "shafik",
"body": "This is a regression in trunk: https://godbolt.org/z/a53x7oxhq"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
98610
|
https://github.com/llvm/llvm-project/issues/98610
|
hang
|
9ad72df55cb74b29193270c28f6974d2af8e0b71
| 2024-07-12T10:31:22 |
[
"llvm/test/Transforms/MemCpyOpt"
] |
{
"fix_commit": "71051deff27928cff908ea794e09806eee662801",
"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": [
[
1296,
1301
],
[
1312,
1318
],
[
1726,
1733
]
],
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.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::processMemCpy",
"MemCpyOptPass::processMemSetMemCpyDependence"
],
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.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 71051deff27928cff908ea794e09806eee662801
Author: Nikita Popov <npopov@redhat.com>
Date: Mon Jul 15 09:41:11 2024 +0200
[MemCpyOpt] Fix infinite loop in memset+memcpy fold (#98638)
For the case where the memcpy size is zero, this transform is a complex
no-op. This can lead to an infinite loop when the size is zero in a way
that BasicAA understands, because it can still understand that dst and
dst + src_size are MustAlias.
I've tried to mitigate this before using the isZeroSize() check, but we
can hit cases where InstSimplify doesn't understand that the size is
zero, but BasicAA does.
As such, this bites the bullet and adds an explicit isKnownNonZero()
check to guard against no-op transforms.
Fixes https://github.com/llvm/llvm-project/issues/98610.
diff --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
index 4063762c88a2..cee34f0a6da1 100644
--- a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -1296,6 +1296,15 @@ bool MemCpyOptPass::processMemSetMemCpyDependence(MemCpyInst *MemCpy,
if (!BAA.isMustAlias(MemSet->getDest(), MemCpy->getDest()))
return false;
+ // Don't perform the transform if src_size may be zero. In that case, the
+ // transform is essentially a complex no-op and may lead to an infinite
+ // loop if BasicAA is smart enough to understand that dst and dst + src_size
+ // are still MustAlias after the transform.
+ Value *SrcSize = MemCpy->getLength();
+ if (!isKnownNonZero(SrcSize,
+ SimplifyQuery(MemCpy->getDataLayout(), DT, AC, MemCpy)))
+ return false;
+
// Check that src and dst of the memcpy aren't the same. While memcpy
// operands cannot partially overlap, exact equality is allowed.
if (isModSet(BAA.getModRefInfo(MemCpy, MemoryLocation::getForSource(MemCpy))))
@@ -1312,7 +1321,6 @@ bool MemCpyOptPass::processMemSetMemCpyDependence(MemCpyInst *MemCpy,
// Use the same i8* dest as the memcpy, killing the memset dest if different.
Value *Dest = MemCpy->getRawDest();
Value *DestSize = MemSet->getLength();
- Value *SrcSize = MemCpy->getLength();
if (mayBeVisibleThroughUnwinding(Dest, MemSet, MemCpy))
return false;
@@ -1726,8 +1734,7 @@ bool MemCpyOptPass::processMemCpy(MemCpyInst *M, BasicBlock::iterator &BBI) {
return true;
}
- // If the size is zero, remove the memcpy. This also prevents infinite loops
- // in processMemSetMemCpyDependence, which is a no-op for zero-length memcpys.
+ // If the size is zero, remove the memcpy.
if (isZeroSize(M->getLength())) {
++BBI;
eraseInstruction(M);
|
[
{
"file": "llvm/test/Transforms/MemCpyOpt/memcpy-zero-size.ll",
"commands": [
"opt -S -passes=memcpyopt < %s"
],
"tests": [
{
"test_name": "pr64886",
"test_body": "; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)\ndeclare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0\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) #1\n\ndefine void @pr64886(i64 %len, ptr noalias %p) {\n call void @llvm.memset.p0.i64(ptr inttoptr (i64 -1 to ptr), i8 0, i64 %len, i1 false)\n call void @llvm.memcpy.p0.p0.i64(ptr inttoptr (i64 -1 to ptr), ptr %p, i64 poison, i1 false)\n ret void\n}\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\nattributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "pr98610",
"test_body": "; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)\ndeclare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0\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) #1\n\ndefine void @pr98610(ptr %p, ptr noalias %p2) {\n call void @llvm.memset.p0.i64(ptr %p, i8 0, i64 1, i1 false)\n %zero.ext = zext i32 0 to i64\n %mul = mul i64 %zero.ext, 1\n call void @llvm.memcpy.p0.p0.i64(ptr %p, ptr %p2, i64 %mul, i1 false)\n ret void\n}\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\nattributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/MemCpyOpt/memset-memcpy-dbgloc.ll",
"commands": [
"opt -passes=memcpyopt -S %s -verify-memoryssa"
],
"tests": [
{
"test_name": "test_constant",
"test_body": "target datalayout = \"e-m:o-i64:64-f80:128-n8:16:32:64-S128\"\n\n@C = external constant [0 x i8]\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\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) #1\n\ndefine void @test_constant(i64 %src_size, ptr %dst, i64 %dst_size, i8 %c) !dbg !5 {\n %non.zero = icmp ne i64 %src_size, 0\n call void @llvm.assume(i1 %non.zero)\n call void @llvm.memset.p0.i64(ptr %dst, i8 %c, i64 %dst_size, i1 false), !dbg !11\n call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr @C, i64 %src_size, i1 false), !dbg !12\n ret void, !dbg !13\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #2\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\nattributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\nattributes #2 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n\n!llvm.dbg.cu = !{!0}\n!llvm.debugify = !{!2, !3}\n!llvm.module.flags = !{!4}\n\n!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: \"debugify\", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)\n!1 = !DIFile(filename: \"memset-memcpy-dbgloc.ll\", directory: \"/\")\n!2 = !{i32 3}\n!3 = !{i32 1}\n!4 = !{i32 2, !\"Debug Info Version\", i32 3}\n!5 = distinct !DISubprogram(name: \"test_constant\", linkageName: \"test_constant\", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8)\n!6 = !DISubroutineType(types: !7)\n!7 = !{}\n!8 = !{!9}\n!9 = !DILocalVariable(name: \"1\", scope: !5, file: !1, line: 3, type: !10)\n!10 = !DIBasicType(name: \"ty32\", size: 32, encoding: DW_ATE_unsigned)\n!11 = !DILocation(line: 1, column: 1, scope: !5)\n!12 = !DILocation(line: 2, column: 1, scope: !5)\n!13 = !DILocation(line: 3, column: 1, scope: !5)\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/MemCpyOpt/memset-memcpy-redundant-memset.ll",
"commands": [
"opt -passes=memcpyopt -S %s -verify-memoryssa"
],
"tests": [
{
"test_name": "test_different_types_i32_i128",
"test_body": "target datalayout = \"e-m:o-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine void @test_different_types_i32_i128(ptr noalias %dst, ptr %src, i32 %dst_size, i128 %src_size, i8 %c) {\n %non.zero = icmp ne i128 %src_size, 0\n call void @llvm.assume(i1 %non.zero)\n call void @llvm.memset.p0.i32(ptr %dst, i8 %c, i32 %dst_size, i1 false)\n call void @llvm.memcpy.p0.p0.i128(ptr %dst, ptr %src, i128 %src_size, i1 false)\n ret void\n}\n\n; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)\ndeclare void @llvm.memset.p0.i32(ptr nocapture writeonly, i8, i32, i1 immarg) #0\n\n; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)\ndeclare void @llvm.memcpy.p0.p0.i128(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i128, i1 immarg) #1\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #2\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\nattributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\nattributes #2 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_missing_noalias",
"test_body": "target datalayout = \"e-m:o-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine void @test_missing_noalias(ptr %src, i64 %src_size, ptr %dst, i64 %dst_size, i8 %c) {\n %non.zero = icmp ne i64 %src_size, 0\n call void @llvm.assume(i1 %non.zero)\n call void @llvm.memset.p0.i64(ptr %dst, i8 %c, i64 %dst_size, i1 false)\n call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 %src_size, i1 false)\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\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) #1\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #2\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\nattributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\nattributes #2 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_different_types_i128_i32",
"test_body": "target datalayout = \"e-m:o-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine void @test_different_types_i128_i32(ptr noalias %dst, ptr %src, i128 %dst_size, i32 %src_size, i8 %c) {\n %non.zero = icmp ne i32 %src_size, 0\n call void @llvm.assume(i1 %non.zero)\n call void @llvm.memset.p0.i128(ptr %dst, i8 %c, i128 %dst_size, i1 false)\n call void @llvm.memcpy.p0.p0.i32(ptr %dst, ptr %src, i32 %src_size, i1 false)\n ret void\n}\n\n; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)\ndeclare void @llvm.memcpy.p0.p0.i32(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i32, i1 immarg) #0\n\n; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)\ndeclare void @llvm.memset.p0.i128(ptr nocapture writeonly, i8, i128, i1 immarg) #1\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #2\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\nattributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }\nattributes #2 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_align_memcpy",
"test_body": "target datalayout = \"e-m:o-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine void @test_align_memcpy(ptr %src, ptr noalias %dst, i64 %dst_size) {\n call void @llvm.memset.p0.i64(ptr %dst, i8 0, i64 %dst_size, i1 false)\n call void @llvm.memcpy.p0.p0.i64(ptr align 8 %dst, ptr align 8 %src, i64 80, i1 false)\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\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) #1\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\nattributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_different_dst",
"test_body": "target datalayout = \"e-m:o-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine void @test_different_dst(ptr noalias %dst2, ptr %src, i64 %src_size, ptr noalias %dst, i64 %dst_size) {\n %non.zero = icmp ne i64 %src_size, 0\n call void @llvm.assume(i1 %non.zero)\n call void @llvm.memset.p0.i64(ptr %dst, i8 0, i64 %dst_size, i1 false)\n call void @llvm.memcpy.p0.p0.i64(ptr %dst2, ptr %src, i64 %src_size, i1 false)\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\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) #1\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #2\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\nattributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\nattributes #2 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_non_i8_dst_type",
"test_body": "target datalayout = \"e-m:o-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine void @test_non_i8_dst_type(ptr %src, i64 %src_size, ptr noalias %dst_pi64, i64 %dst_size, i8 %c) {\n %non.zero = icmp ne i64 %src_size, 0\n call void @llvm.assume(i1 %non.zero)\n call void @llvm.memset.p0.i64(ptr %dst_pi64, i8 %c, i64 %dst_size, i1 false)\n call void @llvm.memcpy.p0.p0.i64(ptr %dst_pi64, ptr %src, i64 %src_size, i1 false)\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\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) #1\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #2\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\nattributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\nattributes #2 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_different_types_i64_i32",
"test_body": "target datalayout = \"e-m:o-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine void @test_different_types_i64_i32(ptr noalias %dst, ptr %src, i64 %dst_size, i32 %src_size, i8 %c) {\n %non.zero = icmp ne i32 %src_size, 0\n call void @llvm.assume(i1 %non.zero)\n call void @llvm.memset.p0.i64(ptr %dst, i8 %c, i64 %dst_size, i1 false)\n call void @llvm.memcpy.p0.p0.i32(ptr %dst, ptr %src, i32 %src_size, i1 false)\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\n; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)\ndeclare void @llvm.memcpy.p0.p0.i32(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i32, i1 immarg) #1\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #2\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\nattributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\nattributes #2 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_intermediate_write",
"test_body": "target datalayout = \"e-m:o-i64:64-f80:128-n8:16:32:64-S128\"\n\n%struct = type { [8 x i8], [8 x i8] }\n\ndefine void @test_intermediate_write(ptr %b) {\n %a = alloca %struct, align 8\n %a1 = getelementptr %struct, ptr %a, i32 0, i32 1, i32 0\n call void @llvm.memset.p0.i64(ptr %a, i8 0, i64 16, i1 false)\n store i8 1, ptr %a1, align 1\n call void @llvm.memcpy.p0.p0.i64(ptr %a, ptr %b, i64 8, i1 false)\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\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) #1\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\nattributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:o-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine void @test(ptr %src, i64 %src_size, ptr noalias %dst, i64 %dst_size, i8 %c) {\n %non.zero = icmp ne i64 %src_size, 0\n call void @llvm.assume(i1 %non.zero)\n call void @llvm.memset.p0.i64(ptr %dst, i8 %c, i64 %dst_size, i1 false)\n call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 %src_size, i1 false)\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\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) #1\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #2\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\nattributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\nattributes #2 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_same_dynamic_size",
"test_body": "target datalayout = \"e-m:o-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine void @test_same_dynamic_size(ptr noalias %src, ptr noalias %dst, i64 %size, i8 %c) {\n %non.zero = icmp ne i64 %size, 0\n call void @llvm.assume(i1 %non.zero)\n call void @llvm.memset.p0.i64(ptr %dst, i8 %c, i64 %size, i1 false)\n call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 %size, i1 false)\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\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) #1\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #2\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\nattributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\nattributes #2 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_weird_element_type",
"test_body": "target datalayout = \"e-m:o-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine void @test_weird_element_type(ptr %src, i64 %src_size, ptr noalias %dst, i64 %dst_size, i8 %c) {\n %non.zero = icmp ne i64 %src_size, 0\n call void @llvm.assume(i1 %non.zero)\n call void @llvm.memset.p0.i64(ptr %dst, i8 %c, i64 %dst_size, i1 false)\n call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 %src_size, i1 false)\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\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) #1\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #2\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\nattributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\nattributes #2 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_throwing_call",
"test_body": "target datalayout = \"e-m:o-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine void @test_throwing_call(ptr %src, i64 %src_size, ptr noalias %dst, i64 %dst_size, i8 %c) {\n %non.zero = icmp ne i64 %src_size, 0\n call void @llvm.assume(i1 %non.zero)\n call void @llvm.memset.p0.i64(ptr %dst, i8 %c, i64 %dst_size, i1 false)\n call void @call() #3\n call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 %src_size, i1 false)\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\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) #1\n\ndeclare void @call()\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #2\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\nattributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\nattributes #2 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\nattributes #3 = { memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_same_const_size",
"test_body": "target datalayout = \"e-m:o-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine void @test_same_const_size(ptr noalias %src, ptr noalias %dst, i8 %c) {\n call void @llvm.memset.p0.i64(ptr %dst, i8 %c, i64 16, i1 false)\n call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 16, i1 false)\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\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) #1\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\nattributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_must_alias_different_size",
"test_body": "target datalayout = \"e-m:o-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine void @test_must_alias_different_size(ptr noalias %src, i64 %src_size, ptr noalias %dst, i64 %dst_size, i8 %c) {\n %non.zero = icmp ne i64 %src_size, 0\n call void @llvm.assume(i1 %non.zero)\n %gep1 = getelementptr i8, ptr %dst, i64 16\n call void @llvm.memset.p0.i64(ptr %gep1, i8 %c, i64 %dst_size, i1 false)\n %gep2 = getelementptr i8, ptr %dst, i64 16\n call void @llvm.memcpy.p0.p0.i64(ptr %gep2, ptr %src, i64 %src_size, i1 false)\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\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) #1\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #2\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\nattributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\nattributes #2 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_throwing_call_alloca",
"test_body": "target datalayout = \"e-m:o-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine void @test_throwing_call_alloca(ptr %src, i64 %src_size, i64 %dst_size, i8 %c) {\n %dst = alloca i8, align 1\n %non.zero = icmp ne i64 %src_size, 0\n call void @llvm.assume(i1 %non.zero)\n call void @llvm.memset.p0.i64(ptr %dst, i8 %c, i64 %dst_size, i1 false)\n call void @call() #3\n call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 %src_size, i1 false)\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\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) #1\n\ndeclare void @call()\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #2\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\nattributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\nattributes #2 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\nattributes #3 = { memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_addrspace",
"test_body": "target datalayout = \"e-m:o-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine void @test_addrspace(ptr addrspace(1) %src, i64 %src_size, ptr addrspace(1) noalias %dst, i64 %dst_size, i8 %c) {\n %non.zero = icmp ne i64 %src_size, 0\n call void @llvm.assume(i1 %non.zero)\n call void @llvm.memset.p1.i64(ptr addrspace(1) %dst, i8 %c, i64 %dst_size, i1 false)\n call void @llvm.memcpy.p1.p1.i64(ptr addrspace(1) %dst, ptr addrspace(1) %src, i64 %src_size, i1 false)\n ret void\n}\n\n; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)\ndeclare void @llvm.memset.p1.i64(ptr addrspace(1) nocapture writeonly, i8, i64, i1 immarg) #0\n\n; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)\ndeclare void @llvm.memcpy.p1.p1.i64(ptr addrspace(1) noalias nocapture writeonly, ptr addrspace(1) noalias nocapture readonly, i64, i1 immarg) #1\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #2\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\nattributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\nattributes #2 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_constant",
"test_body": "target datalayout = \"e-m:o-i64:64-f80:128-n8:16:32:64-S128\"\n\n@C = external constant [0 x i8]\n\ndefine void @test_constant(i64 %src_size, ptr %dst, i64 %dst_size, i8 %c) {\n %non.zero = icmp ne i64 %src_size, 0\n call void @llvm.assume(i1 %non.zero)\n call void @llvm.memset.p0.i64(ptr %dst, i8 %c, i64 %dst_size, i1 false)\n call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr @C, i64 %src_size, i1 false)\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\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) #1\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #2\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\nattributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\nattributes #2 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_different_types_i32_i64",
"test_body": "target datalayout = \"e-m:o-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine void @test_different_types_i32_i64(ptr noalias %dst, ptr %src, i32 %dst_size, i64 %src_size, i8 %c) {\n %non.zero = icmp ne i64 %src_size, 0\n call void @llvm.assume(i1 %non.zero)\n call void @llvm.memset.p0.i32(ptr %dst, i8 %c, i32 %dst_size, i1 false)\n call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 %src_size, 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: write)\ndeclare void @llvm.memset.p0.i32(ptr nocapture writeonly, i8, i32, i1 immarg) #1\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #2\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\nattributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }\nattributes #2 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_must_alias_same_size",
"test_body": "target datalayout = \"e-m:o-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine void @test_must_alias_same_size(ptr noalias %src, ptr noalias %dst, i8 %c) {\n %gep1 = getelementptr i8, ptr %dst, i64 16\n call void @llvm.memset.p0.i64(ptr %gep1, i8 %c, i64 16, i1 false)\n %gep2 = getelementptr i8, ptr %dst, i64 16\n call void @llvm.memcpy.p0.p0.i64(ptr %gep2, ptr %src, i64 16, i1 false)\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\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) #1\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\nattributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/MemCpyOpt/opaque-ptr.ll",
"commands": [
"opt -passes=memcpyopt -S %s -verify-memoryssa"
],
"tests": [
{
"test_name": "test_memset_memcpy",
"test_body": "define void @test_memset_memcpy(ptr %src, i64 range(i64 1, 42) %src_size, ptr noalias %dst, i64 %dst_size, i8 %c) {\n call void @llvm.memset.p0.i64(ptr %dst, i8 %c, i64 %dst_size, i1 false)\n call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 %src_size, i1 false)\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\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) #1\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\nattributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Clang hangs forever building under -O1",
"body": "ToT Clang hangs when building under -O1.\r\n\r\n```\r\nclang++ test.i -fno-exceptions -O1 -c -emit-llvm\r\n```\r\n\r\nThe reproducer, `test.i`:\r\n\r\n```c++\r\nclass MockDevice;\r\nstruct sp {\r\n MockDevice operator*();\r\n};\r\nvoid memset(void *__dest, int __ch, unsigned __len) {\r\n long __trans_tmp_1 = __builtin_object_size(__dest, 0);\r\n __builtin___memset_chk(__dest, __ch, __len, __trans_tmp_1);\r\n}\r\ntemplate <class>\r\nclass function;\r\ntemplate <class _Rp, class... _ArgTypes>\r\nclass function<_Rp(_ArgTypes...)> {\r\n public:\r\n template <class _Fp>\r\n function operator=(_Fp);\r\n};\r\ntemplate <typename T>\r\nstruct hidl_vec {\r\n hidl_vec() : mSize() { memset(mPad, 0, 0); }\r\n hidl_vec(hidl_vec &other) { *this = other; }\r\n hidl_vec &operator=(hidl_vec &other) {\r\n copyFrom(other, other.mSize);\r\n return *this;\r\n }\r\n T &operator[](unsigned index) { return mBuffer[index]; }\r\n T* mBuffer;\r\n unsigned mSize;\r\n unsigned mPad[];\r\n template <typename Array>\r\n void copyFrom(Array &data, unsigned size) {\r\n mSize = size;\r\n if (mSize) mBuffer = new T();\r\n for (int i = 0; i < size; ++i) mBuffer[i] = data[i];\r\n }\r\n};\r\nstruct Capabilities {\r\n struct OperandPerformance {\r\n int a, b, c;\r\n };\r\n hidl_vec<OperandPerformance> operandPerformance;\r\n};\r\ntemplate <typename>\r\nclass Action;\r\ntemplate <typename R, typename... Args>\r\nclass Action<R(Args...)> {\r\n using F = R();\r\n public:\r\n template <typename G>\r\n Action(G fun) {\r\n fun_ = fun;\r\n }\r\n function<F> fun_;\r\n};\r\nstruct OnCallSpec {\r\n OnCallSpec WillByDefault(Action<void()>);\r\n};\r\nstruct MockSpec {\r\n OnCallSpec InternalDefaultActionSetAt();\r\n};\r\nstruct MockDevice {\r\n MockSpec gmock_getCapabilities();\r\n};\r\nsp createMockDevice_mockDevice;\r\nMockDevice createMockDevice() {\r\n Capabilities getCapabilities_ret;\r\n (*createMockDevice_mockDevice)\r\n .gmock_getCapabilities()\r\n .InternalDefaultActionSetAt()\r\n .WillByDefault(getCapabilities_ret);\r\n return *createMockDevice_mockDevice;\r\n}\r\n```",
"author": "kongy",
"labels": [
"confirmed",
"llvm:hang",
"llvm:transforms"
],
"comments": [
{
"author": "AaronBallman",
"body": "This seems to be hanging somewhere in this vicinity:\r\n```\r\n>\tclang.exe!llvm::detail::CheckedInt::from<int,0>(int FromValue) Line 136\tC++\r\n \tclang.exe!llvm::detail::CheckedInt::from<enum llvm::IRMemLocation,0>(llvm::IRMemLocation FromValue) Line 143\tC++\r\n \tclang.exe!llvm::detail::SafeIntIterator<enum llvm::IRMemLocation,0>::SafeIntIterator<enum llvm::IRMemLocation,0>(llvm::IRMemLocation Value) Line 196\tC++\r\n \tclang.exe!llvm::iota_range<enum llvm::IRMemLocation>::iota_range<enum llvm::IRMemLocation>(llvm::IRMemLocation Begin, llvm::IRMemLocation End, bool Inclusive) Line 275\tC++\r\n \tclang.exe!llvm::enum_seq_inclusive<enum llvm::IRMemLocation,void>(llvm::IRMemLocation Begin, llvm::IRMemLocation End, llvm::force_iteration_on_noniterable_enum_t __formal) Line 381\tC++\r\n \tclang.exe!llvm::MemoryEffectsBase<enum llvm::IRMemLocation>::locations() Line 96\tC++\r\n \tclang.exe!llvm::MemoryEffectsBase<enum llvm::IRMemLocation>::MemoryEffectsBase<enum llvm::IRMemLocation>(llvm::ModRefInfo MR) Line 107\tC++\r\n \tclang.exe!llvm::MemoryEffectsBase<enum llvm::IRMemLocation>::unknown() Line 113\tC++\r\n \tclang.exe!llvm::GlobalsAAResult::getMemoryEffects(const llvm::Function * F) Line 244\tC++\r\n \tclang.exe!llvm::AAResults::Model<llvm::GlobalsAAResult>::getMemoryEffects(const llvm::Function * F) Line 784\tC++\r\n \tclang.exe!llvm::AAResults::getMemoryEffects(const llvm::Function * F) Line 396\tC++\r\n \tclang.exe!llvm::BasicAAResult::getMemoryEffects(const llvm::CallBase * Call, llvm::AAQueryInfo & AAQI) Line 830\tC++\r\n \tclang.exe!llvm::AAResults::Model<llvm::BasicAAResult>::getMemoryEffects(const llvm::CallBase * Call, llvm::AAQueryInfo & AAQI) Line 780\tC++\r\n \tclang.exe!llvm::AAResults::getMemoryEffects(const llvm::CallBase * Call, llvm::AAQueryInfo & AAQI) Line 377\tC++\r\n \tclang.exe!llvm::AAResults::getModRefInfo(const llvm::CallBase * Call, const llvm::MemoryLocation & Loc, llvm::AAQueryInfo & AAQI) Line 230\tC++\r\n \tclang.exe!llvm::AAResults::getModRefInfo(const llvm::Instruction * I, const std::optional<llvm::MemoryLocation> & OptLoc, llvm::AAQueryInfo & AAQIP) Line 628\tC++\r\n \tclang.exe!llvm::BatchAAResults::getModRefInfo(const llvm::Instruction * I, const std::optional<llvm::MemoryLocation> & OptLoc) Line 646\tC++\r\n \tclang.exe!llvm::MemCpyOptPass::processMemSetMemCpyDependence(llvm::MemCpyInst * MemCpy, llvm::MemSetInst * MemSet, llvm::BatchAAResults & BAA) Line 1252\tC++\r\n \tclang.exe!llvm::MemCpyOptPass::processMemCpy(llvm::MemCpyInst * M, llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction,1,0,void,1,llvm::BasicBlock>,0,0> & BBI) Line 1725\tC++\r\n \tclang.exe!llvm::MemCpyOptPass::iterateOnFunction(llvm::Function & F) Line 2013\tC++\r\n \tclang.exe!llvm::MemCpyOptPass::runImpl(llvm::Function & F, llvm::TargetLibraryInfo * TLI_, llvm::AAResults * AA_, llvm::AssumptionCache * AC_, llvm::DominatorTree * DT_, llvm::PostDominatorTree * PDT_, llvm::MemorySSA * MSSA_) Line 2070\tC++\r\n \tclang.exe!llvm::MemCpyOptPass::run(llvm::Function & F, llvm::AnalysisManager<llvm::Function> & AM) Line 2045\tC++\r\n \tclang.exe!llvm::detail::PassModel<llvm::Function,llvm::MemCpyOptPass,llvm::AnalysisManager<llvm::Function>>::run(llvm::Function & IR, llvm::AnalysisManager<llvm::Function> & AM) Line 90\tC++\r\n \tclang.exe!llvm::PassManager<llvm::Function,llvm::AnalysisManager<llvm::Function>>::run(llvm::Function & IR, llvm::AnalysisManager<llvm::Function> & AM) Line 85\tC++\r\n \tclang.exe!llvm::detail::PassModel<llvm::Function,llvm::PassManager<llvm::Function,llvm::AnalysisManager<llvm::Function>>,llvm::AnalysisManager<llvm::Function>>::run(llvm::Function & IR, llvm::AnalysisManager<llvm::Function> & AM) Line 90\tC++\r\n \tclang.exe!llvm::CGSCCToFunctionPassAdaptor::run(llvm::LazyCallGraph::SCC & C, llvm::AnalysisManager<llvm::LazyCallGraph::SCC,llvm::LazyCallGraph &> & AM, llvm::LazyCallGraph & CG, llvm::CGSCCUpdateResult & UR) Line 543\tC++\r\n \tclang.exe!llvm::detail::PassModel<llvm::LazyCallGraph::SCC,llvm::CGSCCToFunctionPassAdaptor,llvm::AnalysisManager<llvm::LazyCallGraph::SCC,llvm::LazyCallGraph &>,llvm::LazyCallGraph &,llvm::CGSCCUpdateResult &>::run(llvm::LazyCallGraph::SCC & IR, llvm::AnalysisManager<llvm::LazyCallGraph::SCC,llvm::LazyCallGraph &> & AM, llvm::LazyCallGraph & <ExtraArgs_0>, llvm::CGSCCUpdateResult & <ExtraArgs_1>) Line 90\tC++\r\n \tclang.exe!llvm::PassManager<llvm::LazyCallGraph::SCC,llvm::AnalysisManager<llvm::LazyCallGraph::SCC,llvm::LazyCallGraph &>,llvm::LazyCallGraph &,llvm::CGSCCUpdateResult &>::run(llvm::LazyCallGraph::SCC & InitialC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC,llvm::LazyCallGraph &> & AM, llvm::LazyCallGraph & G, llvm::CGSCCUpdateResult & UR) Line 90\tC++\r\n \tclang.exe!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 & IR, llvm::AnalysisManager<llvm::LazyCallGraph::SCC,llvm::LazyCallGraph &> & AM, llvm::LazyCallGraph & <ExtraArgs_0>, llvm::CGSCCUpdateResult & <ExtraArgs_1>) Line 90\tC++\r\n \tclang.exe!llvm::DevirtSCCRepeatedPass::run(llvm::LazyCallGraph::SCC & InitialC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC,llvm::LazyCallGraph &> & AM, llvm::LazyCallGraph & CG, llvm::CGSCCUpdateResult & UR) Line 415\tC++\r\n \tclang.exe!llvm::detail::PassModel<llvm::LazyCallGraph::SCC,llvm::DevirtSCCRepeatedPass,llvm::AnalysisManager<llvm::LazyCallGraph::SCC,llvm::LazyCallGraph &>,llvm::LazyCallGraph &,llvm::CGSCCUpdateResult &>::run(llvm::LazyCallGraph::SCC & IR, llvm::AnalysisManager<llvm::LazyCallGraph::SCC,llvm::LazyCallGraph &> & AM, llvm::LazyCallGraph & <ExtraArgs_0>, llvm::CGSCCUpdateResult & <ExtraArgs_1>) Line 90\tC++\r\n \tclang.exe!llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module & M, llvm::AnalysisManager<llvm::Module> & AM) Line 277\tC++\r\n \tclang.exe!llvm::detail::PassModel<llvm::Module,llvm::ModuleToPostOrderCGSCCPassAdaptor,llvm::AnalysisManager<llvm::Module>>::run(llvm::Module & IR, llvm::AnalysisManager<llvm::Module> & AM) Line 90\tC++\r\n \tclang.exe!llvm::PassManager<llvm::Module,llvm::AnalysisManager<llvm::Module>>::run(llvm::Module & IR, llvm::AnalysisManager<llvm::Module> & AM) Line 85\tC++\r\n \tclang.exe!llvm::ModuleInlinerWrapperPass::run(llvm::Module & M, llvm::AnalysisManager<llvm::Module> & MAM) Line 631\tC++\r\n \tclang.exe!llvm::detail::PassModel<llvm::Module,llvm::ModuleInlinerWrapperPass,llvm::AnalysisManager<llvm::Module>>::run(llvm::Module & IR, llvm::AnalysisManager<llvm::Module> & AM) Line 90\tC++\r\n \tclang.exe!llvm::PassManager<llvm::Module,llvm::AnalysisManager<llvm::Module>>::run(llvm::Module & IR, llvm::AnalysisManager<llvm::Module> & AM) Line 85\tC++\r\n \tclang.exe!`anonymous namespace'::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction Action, std::unique_ptr<llvm::raw_pwrite_stream,std::default_delete<llvm::raw_pwrite_stream>> & OS, std::unique_ptr<llvm::ToolOutputFile,std::default_delete<llvm::ToolOutputFile>> & ThinLinkOS, clang::BackendConsumer * BC) Line 1114\tC++\r\n \tclang.exe!`anonymous namespace'::EmitAssemblyHelper::EmitAssembly(clang::BackendAction Action, std::unique_ptr<llvm::raw_pwrite_stream,std::default_delete<llvm::raw_pwrite_stream>> OS, clang::BackendConsumer * BC) Line 1180\tC++\r\n \tclang.exe!clang::EmitBackendOutput(clang::DiagnosticsEngine & Diags, const clang::HeaderSearchOptions & HeaderOpts, const clang::CodeGenOptions & CGOpts, const clang::TargetOptions & TOpts, const clang::LangOptions & LOpts, llvm::StringRef TDesc, llvm::Module * M, clang::BackendAction Action, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS, std::unique_ptr<llvm::raw_pwrite_stream,std::default_delete<llvm::raw_pwrite_stream>> OS, clang::BackendConsumer * BC) Line 1341\tC++\r\n \tclang.exe!clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext & C) Line 354\tC++\r\n \tclang.exe!clang::ParseAST(clang::Sema & S, bool PrintStats, bool SkipFunctionBodies) Line 183\tC++\r\n \tclang.exe!clang::ASTFrontendAction::ExecuteAction() Line 1192\tC++\r\n \tclang.exe!clang::CodeGenAction::ExecuteAction() Line 1144\tC++\r\n \tclang.exe!clang::FrontendAction::Execute() Line 1078\tC++\r\n \tclang.exe!clang::CompilerInstance::ExecuteAction(clang::FrontendAction & Act) Line 1061\tC++\r\n \tclang.exe!clang::ExecuteCompilerInvocation(clang::CompilerInstance * Clang) Line 280\tC++\r\n \tclang.exe!cc1_main(llvm::ArrayRef<char const *> Argv, const char * Argv0, void * MainAddr) Line 283\tC++\r\n \tclang.exe!ExecuteCC1Tool(llvm::SmallVectorImpl<char const *> & ArgV, const llvm::ToolContext & ToolContext) Line 215\tC++\r\n \tclang.exe!clang_main(int Argc, char * * Argv, const llvm::ToolContext & ToolContext) Line 256\tC++\r\n \tclang.exe!main(int argc, char * * argv) Line 17\tC++\r\n \tclang.exe!invoke_main() Line 79\tC++\r\n \tclang.exe!__scrt_common_main_seh() Line 288\tC++\r\n \tclang.exe!__scrt_common_main() Line 331\tC++\r\n \tclang.exe!mainCRTStartup(void * __formal) Line 17\tC++\r\n \tkernel32.dll!00007ff830e07344()\tUnknown\r\n \tntdll.dll!00007ff83149cc91()\tUnknown\r\n```"
},
{
"author": "nikic",
"body": "Reduced:\r\n```llvm\r\n; RUN: opt -S -passes=memcpyopt < %s\r\ndefine void @test(ptr %p, ptr noalias %p2) {\r\n call void @llvm.memset.p0.i64(ptr %p, i8 0, i64 1, i1 false)\r\n %zero.ext = zext i32 0 to i64\r\n %mul = mul i64 %zero.ext, 1\r\n call void @llvm.memcpy.p0.p0.i64(ptr %p, ptr %p2, i64 %mul, i1 false)\r\n ret void\r\n}\r\n```"
},
{
"author": "nikic",
"body": "This is an infinite loop in the processMemSetMemCpyDependence() transform. I've tried to mitigate this in the past, but it looks like the mitigation doesn't work for this case. I guess we'll have to add an isKnownNonZero() check to prevent it."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
154116
|
https://github.com/llvm/llvm-project/issues/154116
|
miscompilation
|
4ff7ac23301bee8cab04993b6047e360571adde3
| 2025-08-18T13:25:53 |
[
"llvm/test/Transforms/SeparateConstOffsetFromGEP"
] |
{
"fix_commit": "2d3167f8d86ca9bdaff44cf839488c5a513f5583",
"components": [
"SeparateConstOffsetFromGEP"
],
"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": [
[
642,
647
]
],
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.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": [
"ConstantOffsetExtractor::applyExts"
],
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.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 2d3167f8d86ca9bdaff44cf839488c5a513f5583
Author: Bjorn Pettersson <bjorn.a.pettersson@ericsson.com>
Date: Wed Aug 20 19:26:11 2025 +0200
[SeparateConstOffsetFromGEP] Avoid miscompiles related to trunc nuw/nsw (#154582)
Drop poison generating flags on trunc when distributing trunc over
add/sub/or. We need to do this since for example
(add (trunc nuw A), (trunc nuw B)) is more poisonous than
(trunc nuw (add A, B))).
In some situations it is pessimistic to drop the flags. Such as
if the add in the example above also has the nuw flag. For now we
keep it simple and always drop the flags.
Worth mentioning is that we drop the flags when cloning
instructions and rebuilding the chain. This is done after the
"allowsPreservingNUW" checks in ConstantOffsetExtractor::Extract.
So we still take the "trunc nuw" into consideration when determining
if nuw can be preserved in the gep (which should be ok since that
check also require that all the involved binary operations has nuw).
Fixes #154116
diff --git a/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp b/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
index a88f8f19f852..8b9d06d7e443 100644
--- a/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
+++ b/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
@@ -642,6 +642,13 @@ Value *ConstantOffsetExtractor::applyExts(Value *V) {
Instruction *Ext = I->clone();
Ext->setOperand(0, Current);
+ // In ConstantOffsetExtractor::find we do not analyze nuw/nsw for trunc, so
+ // we assume that it is ok to redistribute trunc over add/sub/or. But for
+ // example (add (trunc nuw A), (trunc nuw B)) is more poisonous than (trunc
+ // nuw (add A, B))). To make such redistributions legal we drop all the
+ // poison generating flags from cloned trunc instructions here.
+ if (isa<TruncInst>(Ext))
+ Ext->dropPoisonGeneratingFlags();
Ext->insertBefore(*IP->getParent(), IP);
Current = Ext;
}
|
[
{
"file": "llvm/test/Transforms/SeparateConstOffsetFromGEP/AMDGPU/preserve-inbounds.ll",
"commands": [
"opt < %s -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1200 -passes=separate-const-offset-from-gep -S"
],
"tests": [
{
"test_name": "nuw_inbounds_implies_nuw_inbounds_trunc_nuw",
"test_body": "define ptr @nuw_inbounds_implies_nuw_inbounds_trunc_nuw(ptr %p, i128 %i) {\nentry:\n %idx = add nuw i128 %i, 1\n %idx.conv = trunc nuw i128 %idx to i64\n %arrayidx = getelementptr inbounds nuw i32, ptr %p, i64 %idx.conv\n ret ptr %arrayidx\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/SeparateConstOffsetFromGEP/AMDGPU/rebuild-trunc.ll",
"commands": [
"opt < %s -mtriple=x86_64-- -passes=separate-const-offset-from-gep -S"
],
"tests": [
{
"test_name": "pr154116_nsw",
"test_body": "define ptr @pr154116_nsw(ptr %p, i128 %i) {\n %idx = add i128 %i, 1\n %idx.conv = trunc nsw i128 %idx to i64\n %arrayidx = getelementptr i32, ptr %p, i64 %idx.conv\n ret ptr %arrayidx\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "pr154116_nuw",
"test_body": "define ptr @pr154116_nuw(ptr %p, i128 %i) {\n %idx = add i128 %i, 20\n %idx.conv = trunc nuw i128 %idx to i64\n %arrayidx = getelementptr i32, ptr %p, i64 %idx.conv\n ret ptr %arrayidx\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "separate-const-offset-from-gep miscompile related to \"trunc nuw\"",
"body": "llvm commit: 673750feea\n\nReproduce with:\n```\nopt -passes=separate-const-offset-from-gep bbi-109669_sep.ll -S -o - -mtriple=hexagon\n```\nThe input program does\n```\n%0 = phi i32 [ -20, %entry ]\n%1 = add i32 %0, 20\n%2 = trunc nuw i32 %1 to i16\n```\nwhere the \"trunc nuw\" is ok since %1 is 0. No truncated bits are set.\n\nHowever, in the result we get:\n```\n%0 = phi i32 [ -20, %entry ]\n[...]\n%1 = trunc nuw i32 %0 to i16\n```\nso here the input to \"trunc nuw\" is negative and the result is poison.\nLangref https://llvm.org/docs/LangRef.html#trunc-to-instruction says\n\"If the nuw keyword is present, and any of the truncated bits are non-zero, the result is a [poison value](https://llvm.org/docs/LangRef.html#poisonvalues).\"\n\nThen %1 is further used to compute the return value from the function so the whole thing results in poison which it did not in the input.\n\n(I stumbled upon this as a miscompile after\n https://github.com/llvm/llvm-project/pull/152990\nwhich I first incorrectly blamed.)\n\n[bbi-109669_sep.ll.gz](https://github.com/user-attachments/files/21836248/bbi-109669_sep.ll.gz)",
"author": "mikaelholmen",
"labels": [
"miscompilation",
"llvm:transforms"
],
"comments": [
{
"author": "bjope",
"body": "I don't think I'm an expert at SeparateConstOffsetFromGEP, but some ideas after looking at the source code:\n* One idea is to let `ConstantOffsetExtractor::applyExts `drop poison generating flags from any TruncInst when cloning the chain. Afaict distributing trunc over add/sub (and disjoint or) should be fine if we drop the flags.\n* Another idea is to track if we have truncate with nuw/nsw in `ConstantOffsetExtractor::find` and `ConstantOffsetExtractor::CanTraceInto` to skip rewrites in scenarios when we can't keep `trunc nuw`.\n\nBut maybe there are other solutions?"
},
{
"author": "nikic",
"body": "cc @ritter-x2a @jrbyrnes @krzysz00 \n\n> One idea is to let `ConstantOffsetExtractor::applyExts `drop poison generating flags from any TruncInst when cloning the chain. Afaict distributing trunc over add/sub (and disjoint or) should be fine if we drop the flags.\n\nThat sounds reasonable to me."
},
{
"author": "krzysz00",
"body": "Yeah, dropping the `nsw` or `nuw` is probablyt he safe thing\n\n(That or doing some analysis on the operands to the add to see if they're also small enough)"
},
{
"author": "ritter-x2a",
"body": "I think there is more broken around distributing truncs in separate-const-offset-from-gep. For example, I got this miscompilation while checking if the fix makes sense: https://alive2.llvm.org/ce/z/hLPfcw\n\nIt seems odd that `NonNegative` in `ConstantOffsetExtractor::find` [isn't cleared for trunc](https://github.com/llvm/llvm-project/blob/f306e0aeb2c72e040c59e160e88af3bf76457693/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp#L606-L609) but [it is for zext](https://github.com/llvm/llvm-project/blob/f306e0aeb2c72e040c59e160e88af3bf76457693/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp#L617-L620) \"because zext(a) >= 0 does not imply a >= 0\" -- that doesn't hold for trunc either.\nThe meaning of `NonNegative` also seems odd: [the doxygen comment](https://github.com/llvm/llvm-project/blob/f306e0aeb2c72e040c59e160e88af3bf76457693/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp#L235-L239) says\n> NonNegative -- Whether V is guaranteed to be non-negative. For example, an index of an inbounds GEP is guaranteed to be non-negative. Levaraging this, we can better split inbounds GEPs.\"\n\nI don't think that's right, inbounds GEP indices can be negative."
},
{
"author": "bjope",
"body": "> It seems odd that `NonNegative` in `ConstantOffsetExtractor::find` [isn't cleared for trunc](https://github.com/llvm/llvm-project/blob/f306e0aeb2c72e040c59e160e88af3bf76457693/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp#L606-L609) but [it is for zext](https://github.com/llvm/llvm-project/blob/f306e0aeb2c72e040c59e160e88af3bf76457693/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp#L617-L620) \"because zext(a) >= 0 does not imply a >= 0\" -- that doesn't hold for trunc either. \n \nI've been suspecting that there could be more problems in that area. Wondering if perhaps `NonNegative` should be cleared for trunc. And I'm not quite sure it is correct to just pass on `SignExtended` and `ZeroExtended` either for trunc.\n\nI'm not sure if there is any comprehensive tests involving scenarios with combinarions of sext/zext/trunc/add/sub/or/xor. The support for xor is for example not using CanTraceInto, so unclear to me how that works together with `NonNegative`, `SignExtended` and `ZeroExtended`.\n\nStill think dropping the nuw/nsw flags (https://github.com/llvm/llvm-project/pull/154582) would solve the problem given the IR reproducer in this issue. But agree that more problems might be lurking."
},
{
"author": "mikaelholmen",
"body": "> I think there is more broken around distributing truncs in separate-const-offset-from-gep. For example, I got this miscompilation while checking if the fix makes sense: https://alive2.llvm.org/ce/z/hLPfcw\n> \n> It seems odd that `NonNegative` in `ConstantOffsetExtractor::find` [isn't cleared for trunc](https://github.com/llvm/llvm-project/blob/f306e0aeb2c72e040c59e160e88af3bf76457693/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp#L606-L609) but [it is for zext](https://github.com/llvm/llvm-project/blob/f306e0aeb2c72e040c59e160e88af3bf76457693/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp#L617-L620) \"because zext(a) >= 0 does not imply a >= 0\" -- that doesn't hold for trunc either. The meaning of `NonNegative` also seems odd: [the doxygen comment](https://github.com/llvm/llvm-project/blob/f306e0aeb2c72e040c59e160e88af3bf76457693/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp#L235-L239) says\n> \n> > NonNegative -- Whether V is guaranteed to be non-negative. For example, an index of an inbounds GEP is guaranteed to be non-negative. Levaraging this, we can better split inbounds GEPs.\"\n> \n> I don't think that's right, inbounds GEP indices can be negative.\n\n@ritter-x2a : \nWill you write a new issue about the miscompile you found or how do we make sure that is not just forgotten?"
},
{
"author": "ritter-x2a",
"body": "> > I think there is more broken around distributing truncs in separate-const-offset-from-gep. For example, I got this miscompilation while checking if the fix makes sense: https://alive2.llvm.org/ce/z/hLPfcw\n> > It seems odd that `NonNegative` in `ConstantOffsetExtractor::find` [isn't cleared for trunc](https://github.com/llvm/llvm-project/blob/f306e0aeb2c72e040c59e160e88af3bf76457693/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp#L606-L609) but [it is for zext](https://github.com/llvm/llvm-project/blob/f306e0aeb2c72e040c59e160e88af3bf76457693/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp#L617-L620) \"because zext(a) >= 0 does not imply a >= 0\" -- that doesn't hold for trunc either. The meaning of `NonNegative` also seems odd: [the doxygen comment](https://github.com/llvm/llvm-project/blob/f306e0aeb2c72e040c59e160e88af3bf76457693/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp#L235-L239) says\n> > > NonNegative -- Whether V is guaranteed to be non-negative. For example, an index of an inbounds GEP is guaranteed to be non-negative. Levaraging this, we can better split inbounds GEPs.\"\n> > \n> > \n> > I don't think that's right, inbounds GEP indices can be negative.\n> \n> [@ritter-x2a](https://github.com/ritter-x2a) : Will you write a new issue about the miscompile you found or how do we make sure that is not just forgotten?\n\nHere it is: #154936\nI might be able to look into this myself in a few weeks, but right now I don't have the capacity."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
153676
|
https://github.com/llvm/llvm-project/issues/153676
|
crash
|
f24d91eb2c97b8b2808404caf1ddd94e5f7a14c0
| 2025-08-14T20:44:19 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "13b54f7dc14f2c40a06cad34fba4df7ad7b5b1fd",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
20975,
20985
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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::BlockScheduling::tryScheduleBundle"
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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 13b54f7dc14f2c40a06cad34fba4df7ad7b5b1fd
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Fri Aug 15 07:33:01 2025 -0700
[SLP] Recalculate dependencies for potential control dependencies if cleared
If the control dependecies are cleared after calcellation of the
copyables, need to reclculate them unconditionally.
Fixes #153754 #153676
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index a1123063d878..45c24bee6516 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -20975,11 +20975,11 @@ BoUpSLP::BlockScheduling::tryScheduleBundle(ArrayRef<Value *> VL, BoUpSLP *SLP,
continue;
}
ScheduledBundles.find(I)->getSecond().pop_back();
- if (!ControlDependentMembers.empty()) {
- ScheduleBundle Invalid = ScheduleBundle::invalid();
- calculateDependencies(Invalid, /*InsertInReadyList=*/false, SLP,
- ControlDependentMembers);
- }
+ }
+ if (!ControlDependentMembers.empty()) {
+ ScheduleBundle Invalid = ScheduleBundle::invalid();
+ calculateDependencies(Invalid, /*InsertInReadyList=*/false, SLP,
+ ControlDependentMembers);
}
return std::nullopt;
}
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/schedule-control-deps-after-copyable.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @test(i32 %e, i32 %0) {\n;\nentry:\n %h = alloca [4 x i32], align 16\n %add = add i32 %0, %e\n %add2 = add i32 %add, 1\n %add4 = add i32 %add, %add2\n store i32 %add4, ptr %h, align 16\n %arrayinit.element = getelementptr i8, ptr %h, i64 4\n %add5 = add i32 %e, 1\n %add6 = add i32 %add5, %add2\n store i32 %add6, ptr %arrayinit.element, align 4\n %arrayinit.element7 = getelementptr i8, ptr %h, i64 8\n store i32 %add6, ptr %arrayinit.element7, align 8\n %arrayinit.element10 = getelementptr i8, ptr %h, i64 12\n %call12 = tail call i32 @fn1(i32 %add)\n store i32 %call12, ptr %arrayinit.element10, align 4\n store volatile i32 0, ptr %h, align 4\n ret void\n}\n\ndeclare i32 @fn1(i32)",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "clang crashes at -O{s,2,3} on x86_64-linux-gnu: Assertion `hasValidDependencies() && \"increment of unscheduled deps would be meaningless\"' failed",
"body": "Compiler Explorer: https://godbolt.org/z/3e5csbK5T\n\nNote: another related instance of two fixed issues:\n- https://github.com/llvm/llvm-project/issues/153289\n- https://github.com/llvm/llvm-project/issues/153571\n\n```\n[536] % clangtk -v\nclang version 22.0.0git (https://github.com/llvm/llvm-project.git 016c301d30fc9e5d8a3e42fb9a5cd990bf2b164f)\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[537] % \n[537] % clangtk -O3 -c small.c\nclangtk: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:4773: int llvm::slpvectorizer::BoUpSLP::ScheduleData::incrementUnscheduledDeps(int): Assertion `hasValidDependencies() && \"increment of unscheduled deps would be meaningless\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\nStack dump:\n0.\tProgram arguments: clangtk -I/usr/local/include -I/local/suz-local/software/local/include -O3 -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 \"d\"\n #0 0x000055ca2b7759b0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x42649b0)\n #1 0x000055ca2b77265f llvm::sys::RunSignalHandlers() (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x426165f)\n #2 0x000055ca2b6b2b18 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0\n #3 0x00007fa9c9055520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #4 0x00007fa9c90a99fc __pthread_kill_implementation ./nptl/./nptl/pthread_kill.c:44:76\n #5 0x00007fa9c90a99fc __pthread_kill_internal ./nptl/./nptl/pthread_kill.c:78:10\n #6 0x00007fa9c90a99fc pthread_kill ./nptl/./nptl/pthread_kill.c:89:10\n #7 0x00007fa9c9055476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x00007fa9c903b7f3 abort ./stdlib/./stdlib/abort.c:81:7\n #9 0x00007fa9c903b71b _nl_load_domain ./intl/./intl/loadmsgcat.c:1177:9\n#10 0x00007fa9c904ce96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n#11 0x000055ca2d302004 auto void llvm::slpvectorizer::BoUpSLP::BlockScheduling::schedule<llvm::SetVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, 0u>, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, void> >, 0u> >(llvm::slpvectorizer::BoUpSLP const&, (anonymous namespace)::InstructionsState const&, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SetVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, 0u>, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, void> >, 0u>&)::'lambda'(llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::ArrayRef<llvm::slpvectorizer::BoUpSLP::ScheduleBundle*>)::operator()(llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::ArrayRef<llvm::slpvectorizer::BoUpSLP::ScheduleBundle*>) const::'lambda'(llvm::SetVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, 0u>, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, void> >, 0u>*, bool)::operator()<llvm::slpvectorizer::BoUpSLP::ScheduleData>(llvm::SetVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, 0u>, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, void> >, 0u>*, bool) const SLPVectorizer.cpp:0:0\n#12 0x000055ca2d3032c2 void llvm::slpvectorizer::BoUpSLP::BlockScheduling::schedule<llvm::SetVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, 0u>, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, void> >, 0u> >(llvm::slpvectorizer::BoUpSLP const&, (anonymous namespace)::InstructionsState const&, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SetVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, 0u>, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, void> >, 0u>&)::'lambda'(llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::ArrayRef<llvm::slpvectorizer::BoUpSLP::ScheduleBundle*>)::operator()(llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::ArrayRef<llvm::slpvectorizer::BoUpSLP::ScheduleBundle*>) const SLPVectorizer.cpp:0:0\n#13 0x000055ca2d304c6f llvm::slpvectorizer::BoUpSLP::BlockScheduling::tryScheduleBundle(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP*, (anonymous namespace)::InstructionsState const&, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&)::'lambda0'(bool, llvm::slpvectorizer::BoUpSLP::ScheduleBundle&)::operator()(bool, llvm::slpvectorizer::BoUpSLP::ScheduleBundle&) const SLPVectorizer.cpp:0:0\n#14 0x000055ca2d306699 llvm::slpvectorizer::BoUpSLP::BlockScheduling::tryScheduleBundle(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP*, (anonymous namespace)::InstructionsState const&, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&) SLPVectorizer.cpp:0:0\n#15 0x000055ca2d30825e llvm::slpvectorizer::BoUpSLP::buildTreeRec(llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, unsigned int) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5df725e)\n#16 0x000055ca2d30a479 llvm::slpvectorizer::BoUpSLP::buildTreeRec(llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, unsigned int) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5df9479)\n#17 0x000055ca2d3097d7 llvm::slpvectorizer::BoUpSLP::buildTreeRec(llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, unsigned int) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5df87d7)\n#18 0x000055ca2d30c900 llvm::slpvectorizer::BoUpSLP::buildTree(llvm::ArrayRef<llvm::Value*>) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5dfb900)\n#19 0x000055ca2d3506fa llvm::SLPVectorizerPass::vectorizeStoreChain(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, unsigned int, unsigned int, unsigned int&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5e3f6fa)\n#20 0x000055ca2d352554 llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void> >&)::'lambda'(std::map<long, unsigned int, std::less<long>, std::allocator<std::pair<long const, unsigned int> > > const&)::operator()(std::map<long, unsigned int, std::less<long>, std::allocator<std::pair<long const, unsigned int> > > const&) const SLPVectorizer.cpp:0:0\n#21 0x000055ca2d354440 llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void> >&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5e43440)\n#22 0x000055ca2d354d5b llvm::SLPVectorizerPass::vectorizeStoreChains(llvm::slpvectorizer::BoUpSLP&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5e43d5b)\n#23 0x000055ca2d356295 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#24 0x000055ca2d356e81 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5e45e81)\n#25 0x000055ca2c85d066 llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x534c066)\n#26 0x000055ca2b0b58c7 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+0x3ba48c7)\n#27 0x000055ca2880b556 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+0x12fa556)\n#28 0x000055ca2b0b5de9 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3ba4de9)\n#29 0x000055ca2880bc46 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+0x12fac46)\n#30 0x000055ca2b0b3c04 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+0x3ba2c04)\n#31 0x000055ca2ba1bf63 (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#32 0x000055ca2ba20503 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+0x450f503)\n#33 0x000055ca2c11a38f clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4c0938f)\n#34 0x000055ca2db8330c clang::ParseAST(clang::Sema&, bool, bool) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x667230c)\n#35 0x000055ca2c437ea9 clang::FrontendAction::Execute() (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4f26ea9)\n#36 0x000055ca2c3b37f5 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4ea27f5)\n#37 0x000055ca2c528c08 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5017c08)\n#38 0x000055ca2838bd78 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xe7ad78)\n#39 0x000055ca2838237a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#40 0x000055ca2c18954d 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#41 0x000055ca2b6b2fc0 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x41a1fc0)\n#42 0x000055ca2c189dee 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#43 0x000055ca2c147301 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4c36301)\n#44 0x000055ca2c148421 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&, bool) const (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4c37421)\n#45 0x000055ca2c154e04 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4c43e04)\n#46 0x000055ca28387c1b clang_main(int, char**, llvm::ToolContext const&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xe76c1b)\n#47 0x000055ca28252fab main (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xd41fab)\n#48 0x00007fa9c903cd90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\n#49 0x00007fa9c903ce40 call_init ./csu/../csu/libc-start.c:128:20\n#50 0x00007fa9c903ce40 __libc_start_main ./csu/../csu/libc-start.c:379:5\n#51 0x000055ca28381aa5 _start (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xe70aa5)\nclangtk: error: clang frontend command failed with exit code 134 (use -v to see invocation)\nclang version 22.0.0git (https://github.com/llvm/llvm-project.git 016c301d30fc9e5d8a3e42fb9a5cd990bf2b164f)\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-81e193.c\nclangtk: note: diagnostic msg: /tmp/small-81e193.sh\nclangtk: note: diagnostic msg: \n\n********************\n[538] % \n[538] % cat small.c\nextern int fn1(int);\nextern void fn2(int *);\nextern int fn3 (void);\nint a, b;\nvoid d(int e) {\n int f = a, g = 1 + (fn3() + a + b);\n int h[] = {b + g + a, e + f + g, f + g + e, fn1(g + 1)};\n fn2(h);\n}\n```",
"author": "zhendongsu",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": [
{
"author": "alexey-bataev",
"body": "Fixed in 13b54f7dc14f2c40a06cad34fba4df7ad7b5b1fd"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
153289
|
https://github.com/llvm/llvm-project/issues/153289
|
crash
|
0f6d3ad0feb42fbe36e1878fe9ffff67195c50d2
| 2025-08-12T20:46:33 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "dd5ba694bde6c92259c518b9eb2888163a812433",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
5689,
5695
],
[
20727,
20741
],
[
20748,
20755
],
[
20783,
20789
],
[
21048,
21056
],
[
21293,
21298
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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::BlockScheduling::calculateDependencies",
"BoUpSLP::BlockScheduling::initScheduleData",
"BoUpSLP::BlockScheduling::tryScheduleBundle"
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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 dd5ba694bde6c92259c518b9eb2888163a812433
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Wed Aug 13 05:57:07 2025 -0700
[SLP]Recalculate deps for potential control-dependent schedule data
After clearing the dependencies in copyable data, need to recalculate
dependencies for the original ScheduleData, if it can be marked as
control dependent.
Fixes #153289
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 98011174bd70..a3cb4d138789 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -5689,7 +5689,8 @@ private:
/// Updates the dependency information of a bundle and of all instructions/
/// bundles which depend on the original bundle.
void calculateDependencies(ScheduleBundle &Bundle, bool InsertInReadyList,
- BoUpSLP *SLP);
+ BoUpSLP *SLP,
+ ArrayRef<ScheduleData *> ControlDeps = {});
/// Sets all instruction in the scheduling region to un-scheduled.
void resetSchedule();
@@ -20727,15 +20728,21 @@ BoUpSLP::BlockScheduling::tryScheduleBundle(ArrayRef<Value *> VL, BoUpSLP *SLP,
LLVM_DEBUG(dbgs() << "SLP: bundle: " << *S.getMainOp() << "\n");
auto TryScheduleBundleImpl = [=](bool ReSchedule, ScheduleBundle &Bundle) {
- // Clear deps or reculate the region, if the memory instruction is a
- // copyable. It may have memory deps, which must be reaculated.
+ // Clear deps or recalculate the region, if the memory instruction is a
+ // copyable. It may have memory deps, which must be recalculated.
+ SmallVector<ScheduleData *> ControlDependentMembers;
auto CheckIfNeedToClearDeps = [&](ScheduleBundle &Bundle) {
SmallDenseMap<std::pair<Instruction *, Value *>, unsigned> UserOpToNumOps;
for (ScheduleEntity *SE : Bundle.getBundle()) {
if (ScheduleCopyableData *SD = dyn_cast<ScheduleCopyableData>(SE)) {
if (ScheduleData *BundleMember = getScheduleData(SD->getInst());
- BundleMember && BundleMember->hasValidDependencies())
+ BundleMember && BundleMember->hasValidDependencies()) {
BundleMember->clearDirectDependencies();
+ if (RegionHasStackSave ||
+ !isGuaranteedToTransferExecutionToSuccessor(
+ BundleMember->getInst()))
+ ControlDependentMembers.push_back(BundleMember);
+ }
continue;
}
auto *SD = cast<ScheduleData>(SE);
@@ -20748,8 +20755,12 @@ BoUpSLP::BlockScheduling::tryScheduleBundle(ArrayRef<Value *> VL, BoUpSLP *SLP,
if (auto *Op = dyn_cast<Instruction>(U.get());
Op && areAllOperandsReplacedByCopyableData(SD->getInst(), Op,
*SLP, NumOps)) {
- if (ScheduleData *OpSD = getScheduleData(Op))
+ if (ScheduleData *OpSD = getScheduleData(Op)) {
OpSD->clearDirectDependencies();
+ if (RegionHasStackSave ||
+ !isGuaranteedToTransferExecutionToSuccessor(OpSD->getInst()))
+ ControlDependentMembers.push_back(OpSD);
+ }
}
}
}
@@ -20783,7 +20794,8 @@ BoUpSLP::BlockScheduling::tryScheduleBundle(ArrayRef<Value *> VL, BoUpSLP *SLP,
CheckIfNeedToClearDeps(Bundle);
LLVM_DEBUG(dbgs() << "SLP: try schedule bundle " << Bundle << " in block "
<< BB->getName() << "\n");
- calculateDependencies(Bundle, /*InsertInReadyList=*/!ReSchedule, SLP);
+ calculateDependencies(Bundle, /*InsertInReadyList=*/!ReSchedule, SLP,
+ ControlDependentMembers);
}
if (ReSchedule) {
@@ -21048,9 +21060,9 @@ void BoUpSLP::BlockScheduling::initScheduleData(Instruction *FromI,
}
}
-void BoUpSLP::BlockScheduling::calculateDependencies(ScheduleBundle &Bundle,
- bool InsertInReadyList,
- BoUpSLP *SLP) {
+void BoUpSLP::BlockScheduling::calculateDependencies(
+ ScheduleBundle &Bundle, bool InsertInReadyList, BoUpSLP *SLP,
+ ArrayRef<ScheduleData *> ControlDeps) {
SmallVector<ScheduleEntity *> WorkList;
auto ProcessNode = [&](ScheduleEntity *SE) {
if (auto *CD = dyn_cast<ScheduleCopyableData>(SE)) {
@@ -21293,6 +21305,7 @@ void BoUpSLP::BlockScheduling::calculateDependencies(ScheduleBundle &Bundle,
};
WorkList.push_back(Bundle.getBundle().front());
+ WorkList.append(ControlDeps.begin(), ControlDeps.end());
SmallPtrSet<ScheduleBundle *, 16> Visited;
while (!WorkList.empty()) {
ScheduleEntity *SD = WorkList.pop_back_val();
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/control-dependent-schedule.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine i32 @test(i32 %0, i32 %1) {\n;\nentry:\n %k = alloca [4 x i32], align 16\n %add1 = add i32 %0, %1\n %sub2 = add i32 %add1, -1\n %call = tail call i32 (ptr, ...) @printf(ptr null, i32 %add1)\n %add2 = add i32 %1, -1\n %sub3 = add i32 %add2, %call\n %add4 = add i32 %sub3, %0\n store i32 %add4, ptr %k, align 16\n %arrayinit.element = getelementptr i8, ptr %k, i64 4\n store i32 0, ptr %arrayinit.element, align 4\n %arrayinit.element5 = getelementptr i8, ptr %k, i64 8\n %add7 = add i32 %add2, %sub2\n %sub8 = add i32 %add7, %0\n store i32 %sub8, ptr %arrayinit.element5, align 8\n %arrayinit.element9 = getelementptr i8, ptr %k, i64 12\n %add13 = add i32 %1, 1\n %add10 = add i32 %add13, %0\n %add11 = add i32 %add10, %add1\n %add12 = add i32 %add11, %0\n store i32 %add12, ptr %arrayinit.element9, align 4\n %call15 = call i32 (ptr, ...) @printf(ptr null, ptr %k)\n ret i32 %call15\n}\n\ndeclare i32 @printf(ptr, ...)",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "clang crashes at -O{s,2,3} on x86_64-linux-gnu: Assertion `hasValidDependencies() && \"increment of unscheduled deps would be meaningless\"' failed",
"body": "Compiler Explorer: https://godbolt.org/z/xWvWKe3fj\n\nNote:\n- fails: trunk\n- works: 20.1.0 and earlier (so a recent regression)\n\n```\n[569] % clangtk -v\nclang version 22.0.0git (https://github.com/llvm/llvm-project.git 44f41f55b4df5ec490df0d69e046b2d1a58acaeb)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /local/home/suz/suz-local/software/local/clang-trunk/bin\nBuild config: +assertions\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12\nCandidate multilib: .;@m64\nSelected multilib: .;@m64\nFound CUDA installation: /usr/local/cuda, version 12.1\n[570] % \n[570] % clangtk -O3 small.c\nclang-22: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:4773: int llvm::slpvectorizer::BoUpSLP::ScheduleData::incrementUnscheduledDeps(int): Assertion `hasValidDependencies() && \"increment of unscheduled deps would be meaningless\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\nStack dump:\n0.\tProgram arguments: /local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22 -cc1 -triple x86_64-unknown-linux-gnu -O3 -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/bug138/red1 -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/bug138/red1 -resource-dir /local/home/suz/suz-local/software/local/clang-trunk/lib/clang/22 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/home/suz/suz-local/software/local/clang-trunk/lib/clang/22/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -ferror-limit 19 -fmessage-length=130 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-6dbb88.o -x c small.c\n1.\t<eof> parser at end of file\n2.\tOptimizer\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,chr,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"small.c\"\n4.\tRunning pass \"slp-vectorizer\" on function \"main\"\n #0 0x0000563336e85430 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4263430)\n #1 0x0000563336e820df llvm::sys::RunSignalHandlers() (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x42600df)\n #2 0x0000563336e82232 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #3 0x00007f2abf190520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #4 0x00007f2abf1e49fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #5 0x00007f2abf1e49fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #6 0x00007f2abf1e49fc pthread_kill ./nptl/pthread_kill.c:89:10\n #7 0x00007f2abf190476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x00007f2abf1767f3 abort ./stdlib/abort.c:81:7\n #9 0x00007f2abf17671b _nl_load_domain ./intl/loadmsgcat.c:1177:9\n#10 0x00007f2abf187e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n#11 0x0000563338a0edf4 auto void llvm::slpvectorizer::BoUpSLP::BlockScheduling::schedule<llvm::SetVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, 0u>, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, void>>, 0u>>(llvm::slpvectorizer::BoUpSLP const&, (anonymous namespace)::InstructionsState const&, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SetVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, 0u>, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, void>>, 0u>&)::'lambda'(llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::ArrayRef<llvm::slpvectorizer::BoUpSLP::ScheduleBundle*>)::operator()(llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::ArrayRef<llvm::slpvectorizer::BoUpSLP::ScheduleBundle*>) const::'lambda'(llvm::SetVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, 0u>, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, void>>, 0u>*, bool)::operator()<llvm::slpvectorizer::BoUpSLP::ScheduleData>(llvm::SetVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, 0u>, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, void>>, 0u>*, bool) const SLPVectorizer.cpp:0:0\n#12 0x0000563338a11f92 void llvm::slpvectorizer::BoUpSLP::BlockScheduling::schedule<llvm::SetVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, 0u>, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, void>>, 0u>>(llvm::slpvectorizer::BoUpSLP const&, (anonymous namespace)::InstructionsState const&, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SetVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, 0u>, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, void>>, 0u>&)::'lambda'(llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::ArrayRef<llvm::slpvectorizer::BoUpSLP::ScheduleBundle*>)::operator()(llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::ArrayRef<llvm::slpvectorizer::BoUpSLP::ScheduleBundle*>) const SLPVectorizer.cpp:0:0\n#13 0x0000563338a12def llvm::slpvectorizer::BoUpSLP::BlockScheduling::tryScheduleBundle(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP*, (anonymous namespace)::InstructionsState const&, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&)::'lambda0'(bool, llvm::slpvectorizer::BoUpSLP::ScheduleBundle&)::operator()(bool, llvm::slpvectorizer::BoUpSLP::ScheduleBundle&) const SLPVectorizer.cpp:0:0\n#14 0x0000563338a14217 llvm::slpvectorizer::BoUpSLP::BlockScheduling::tryScheduleBundle(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP*, (anonymous namespace)::InstructionsState const&, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&) SLPVectorizer.cpp:0:0\n#15 0x0000563338a15cbe llvm::slpvectorizer::BoUpSLP::buildTreeRec(llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, unsigned int) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5df3cbe)\n#16 0x0000563338a17ed9 llvm::slpvectorizer::BoUpSLP::buildTreeRec(llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, unsigned int) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5df5ed9)\n#17 0x0000563338a17ed9 llvm::slpvectorizer::BoUpSLP::buildTreeRec(llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, unsigned int) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5df5ed9)\n#18 0x0000563338a17237 llvm::slpvectorizer::BoUpSLP::buildTreeRec(llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, unsigned int) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5df5237)\n#19 0x0000563338a1a360 llvm::slpvectorizer::BoUpSLP::buildTree(llvm::ArrayRef<llvm::Value*>) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5df8360)\n#20 0x0000563338a5c1ba llvm::SLPVectorizerPass::vectorizeStoreChain(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, unsigned int, unsigned int, unsigned int&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5e3a1ba)\n#21 0x0000563338a5e014 llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&)::'lambda'(std::map<long, unsigned int, std::less<long>, std::allocator<std::pair<long const, unsigned int>>> const&)::operator()(std::map<long, unsigned int, std::less<long>, std::allocator<std::pair<long const, unsigned int>>> const&) const SLPVectorizer.cpp:0:0\n#22 0x0000563338a5ff00 llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5e3df00)\n#23 0x0000563338a6081b llvm::SLPVectorizerPass::vectorizeStoreChains(llvm::slpvectorizer::BoUpSLP&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5e3e81b)\n#24 0x0000563338a61d95 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\n#25 0x0000563338a62981 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5e40981)\n#26 0x0000563337f6caf6 llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x534aaf6)\n#27 0x00005633367c6e57 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3ba4e57)\n#28 0x0000563333f1b836 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x12f9836)\n#29 0x00005633367c7379 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3ba5379)\n#30 0x0000563333f1bf26 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x12f9f26)\n#31 0x00005633367c5194 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3ba3194)\n#32 0x000056333712bd13 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\n#33 0x00005633371302b3 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x450e2b3)\n#34 0x000056333782a05f clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4c0805f)\n#35 0x000056333928da0c clang::ParseAST(clang::Sema&, bool, bool) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x666ba0c)\n#36 0x0000563337b47b59 clang::FrontendAction::Execute() (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4f25b59)\n#37 0x0000563337ac34c5 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4ea14c5)\n#38 0x0000563337c38628 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5016628)\n#39 0x0000563333a9bd58 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xe79d58)\n#40 0x0000563333a9235a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#41 0x0000563333a96e14 clang_main(int, char**, llvm::ToolContext const&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xe74e14)\n#42 0x000056333396306b main (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xd4106b)\n#43 0x00007f2abf177d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\n#44 0x00007f2abf177e40 call_init ./csu/../csu/libc-start.c:128:20\n#45 0x00007f2abf177e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\n#46 0x0000563333a91a85 _start (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xe6fa85)\nclangtk: error: unable to execute command: Aborted\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\nclang version 22.0.0git (https://github.com/llvm/llvm-project.git 44f41f55b4df5ec490df0d69e046b2d1a58acaeb)\nTarget: x86_64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /local/home/suz/suz-local/software/local/clang-trunk/bin\nBuild config: +assertions\nclangtk: note: diagnostic msg: \n********************\n\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\nPreprocessed source(s) and associated run script(s) are located at:\nclangtk: note: diagnostic msg: /tmp/small-859782.c\nclangtk: note: diagnostic msg: /tmp/small-859782.sh\nclangtk: note: diagnostic msg: \n\n********************\n[571] % \n[571] % cat small.c\nint printf(const char *, ...);\nint a, b, d, g, c, f;\nint main() {\n int h, i, j;\n i = c;\n for (int e = 0; e < 1; e++)\n if (a)\n b = e;\n j = d + i - 1;\n g = printf(\"%d\", j);\n h = j + 3;\n int k[] = {g + i - 1 + j, 0, f + j + i - 1, h + j + i + c};\n if (a)\n printf(\"%p\", (void *)k);\n return 0;\n}\n```",
"author": "zhendongsu",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
143123
|
https://github.com/llvm/llvm-project/issues/143123
|
miscompilation
|
5d3899d293e902124c3602b466031b6b799fb123
| 2025-06-06T12:10:51 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "2f15637e04f51e3ef435c0c0d39aab0e8b933023",
"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": [
[
8660,
8665
]
],
"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": [
"matchSelectPattern"
],
"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 2f15637e04f51e3ef435c0c0d39aab0e8b933023
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Mon Jun 9 15:46:09 2025 +0800
[ValueTracking] Update `Ordered` when both operands are non-NaN. (#143349)
When the original predicate is ordered and both operands are non-NaN,
`Ordered` should be set to true. This variable still matters even if
both operands are non-NaN because FMF only applies to select, not fcmp.
Closes https://github.com/llvm/llvm-project/issues/143123.
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index d6bb852e208f..d8c1096049dc 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -8660,6 +8660,7 @@ static SelectPatternResult matchSelectPattern(CmpInst::Predicate Pred,
if (LHSSafe && RHSSafe) {
// Both operands are known non-NaN.
NaNBehavior = SPNB_RETURNS_ANY;
+ Ordered = CmpInst::isOrdered(Pred);
} else if (CmpInst::isOrdered(Pred)) {
// An ordered comparison will return false when given a NaN, so it
// returns the RHS.
|
[
{
"file": "llvm/test/Transforms/InstCombine/fcmp-select.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "test_fcmp_ord_select_fcmp_oeq_var_const",
"test_body": "define i1 @test_fcmp_ord_select_fcmp_oeq_var_const(double %x) {\n %cmp1 = fcmp ord double %x, 0.000000e+00\n %sel = select i1 %cmp1, double %x, double 0.000000e+00\n %cmp2 = fcmp oeq double %sel, 1.000000e+00\n ret i1 %cmp2\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_select_nnan_nsz_fcmp_olt",
"test_body": "define float @test_select_nnan_nsz_fcmp_olt(float %x) {\n %cmp = fcmp olt float %x, 0.000000e+00\n %sel = select nnan nsz i1 %cmp, float %x, float -0.000000e+00\n ret float %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_select_nnan_nsz_fcmp_ult",
"test_body": "define float @test_select_nnan_nsz_fcmp_ult(float %x) {\n %cmp = fcmp ult float %x, 0.000000e+00\n %sel = select nnan nsz i1 %cmp, float %x, float -0.000000e+00\n ret float %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_fcmp_select_var_const_unordered",
"test_body": "define i1 @test_fcmp_select_var_const_unordered(double %x, double %y) {\n %cmp1 = fcmp ult double %x, 0x3E80000000000000\n %sel = select i1 %cmp1, double %y, double 0.000000e+00\n %cmp2 = fcmp ugt double %sel, 0x3E80000000000000\n ret i1 %cmp2\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstCombine] fcmp is incorrectly inverted",
"body": "Reproducer: https://alive2.llvm.org/ce/z/yVw9wM\n```\ndefine float @src(float %x) {\n %cmp = fcmp olt float %x, 0.000000e+00\n %sel = select nnan nsz i1 %cmp, float %x, float -0.000000e+00\n ret float %sel\n}\n\ndefine float @tgt(float %x) {\n %.inv = fcmp oge float %x, 0.000000e+00\n %sel1 = select i1 %.inv, float -0.000000e+00, float %x\n ret float %sel1\n}\n```\n```\n----------------------------------------\ndefine float @src(float %x) {\n#0:\n %cmp = fcmp olt float %x, 0.000000\n %sel = select nnan nsz i1 %cmp, float %x, float -0.000000\n ret float %sel\n}\n=>\ndefine float @tgt(float %x) {\n#0:\n %.inv = fcmp oge float %x, 0.000000\n %sel1 = select i1 %.inv, float -0.000000, float %x\n ret float %sel1\n}\nTransformation doesn't verify!\n\nERROR: Value mismatch\n\nExample:\nfloat %x = #x7f800002 (SNaN)\n\nSource:\ni1 %cmp = #x0 (0)\nfloat %sel = #x80000000 (-0.0)\n\nTarget:\ni1 %.inv = #x0 (0)\nfloat %sel1 = #x7f800002 (SNaN)\nSource value: #x80000000 (-0.0)\nTarget value: #x7f800002 (SNaN)\n```\n",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"floating-point",
"llvm:analysis",
"generated by fuzzer"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
127534
|
https://github.com/llvm/llvm-project/issues/127534
|
crash
|
6de5d1e46d1812de2bbbbe8d8d2c811e4d16acbe
| 2025-02-17T18:29:15 |
[
"llvm/test/Transforms/LoopSimplifyCFG"
] |
{
"fix_commit": "41437a6067b2f9dc8e7c458ff6417397796be31c",
"components": [
"LoopSimplifyCFG"
],
"bug_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": [
[
369,
375
]
],
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.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": [
"handleDeadExits"
],
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.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 41437a6067b2f9dc8e7c458ff6417397796be31c
Author: Aleksandr Popov <42888396+aleks-tmb@users.noreply.github.com>
Date: Fri Feb 21 12:26:39 2025 +0100
[LoopSimplifyCFG] Fix SCEV invalidation after removing dead exit (#127536)
Fixes #127534
diff --git a/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp b/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
index 765b76e54068..4524446e5947 100644
--- a/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
@@ -369,7 +369,7 @@ private:
DeadInstructions.emplace_back(LandingPad);
for (Instruction *I : DeadInstructions) {
- SE.forgetBlockAndLoopDispositions(I);
+ SE.forgetValue(I);
I->replaceAllUsesWith(PoisonValue::get(I->getType()));
I->eraseFromParent();
}
|
[
{
"file": "llvm/test/Transforms/LoopSimplifyCFG/pr117537.ll",
"commands": [
"opt -S -passes='print<scalar-evolution>,loop-mssa(licm,loop-simplifycfg,loop-predication)' -verify-scev < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n; Make sure we don't assert due to insufficient SCEV invalidation.\n\ndefine i64 @\"main\"(ptr addrspace(1) %p, i1 %check) {\n;\nentry:\n br label %loop0.pre\n\nloop0.pre:\n br i1 %check, label %exit, label %loop0\n\nloop0:\n %length = load atomic i32, ptr addrspace(1) %p unordered, align 4\n %28 = icmp ugt i32 %length, 1\n br i1 %28, label %loop0.out, label %loop1.preheader\n\nloop0.out:\n %t = add i32 0, 1\n br i1 false, label %loop1.preheader, label %mid\n\nloop1.preheader:\n %length.lcssa = phi i32 [ %length, %loop0.out ], [ %length, %loop0 ]\n %local = phi i32 [ 0, %loop0 ], [ %t, %loop0.out ]\n br label %loop1\n\nloop1:\n %iv1 = phi i32 [ 4, %loop1.preheader ], [ %iv1.next, %loop1.guarded ]\n %82 = icmp ult i32 %iv1, %length.lcssa\n %wc = call i1 @llvm.experimental.widenable.condition()\n %guard.chk = and i1 %82, %wc\n br i1 %guard.chk, label %loop1.guarded, label %deopt-exit\n\nloop1.guarded:\n %iv1.next = add nuw nsw i32 %iv1, 1\n %chk = icmp ugt i32 %iv1, 310\n br i1 %chk, label %loop1.exit, label %loop1\n\ndeopt-exit:\n %100 = call i64 (...) @llvm.experimental.deoptimize.i64(i32 13) [ \"deopt\"() ]\n ret i64 %100\n\nloop1.exit:\n ret i64 0\n\nmid:\n br label %loop0.pre\n\nexit:\n ret i64 0\n}\n\ndeclare i64 @foo()\n\ndeclare i64 @llvm.experimental.deoptimize.i64(...)\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(inaccessiblemem: readwrite)\ndeclare noundef i1 @llvm.experimental.widenable.condition()",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SCEV] Assertion `isAvailableAtLoopEntry(RHS, L) && \"RHS is not available at Loop Entry\"' failed",
"body": "During our local testing, we encountered the assertion failure `isAvailableAtLoopEntry(RHS, L) && \"RHS is not available at Loop Entry\".\n\nReduced reproducer:\n\n```llvm\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i64 @\"main\"(ptr addrspace(1) %p, i1 %check) {\nentry:\n br label %loop0.pre\n\nloop0.pre:\n br i1 %check, label %exit, label %loop0\n\nloop0:\n %length = load atomic i32, ptr addrspace(1) %p unordered, align 4\n %28 = icmp ugt i32 %length, 1\n br i1 %28, label %loop0.out, label %loop1.preheader\n\nloop0.out:\n %t = add i32 0, 1\n br i1 false, label %loop1.preheader, label %mid\n\nloop1.preheader:\n %length.lcssa = phi i32 [ %length, %loop0.out ], [ %length, %loop0 ]\n %local = phi i32 [ 0, %loop0 ], [ %t, %loop0.out ]\n br label %loop1\n\nloop1:\n %iv1 = phi i32 [ 4, %loop1.preheader ], [ %iv1.next, %loop1.guarded ]\n %82 = icmp ult i32 %iv1, %length.lcssa\n %wc = call i1 @llvm.experimental.widenable.condition()\n %guard.chk = and i1 %82, %wc\n br i1 %guard.chk, label %loop1.guarded, label %deopt-exit\n\nloop1.guarded:\n %iv1.next = add nuw nsw i32 %iv1, 1\n %chk = icmp ugt i32 %iv1, 310\n br i1 %chk, label %loop1.exit, label %loop1\n\ndeopt-exit:\n %100 = call i64 (...) @llvm.experimental.deoptimize.i64(i32 13) [ \"deopt\"() ]\n ret i64 %100\n\nloop1.exit:\n ret i64 0\n\nmid:\n br label %loop0.pre\n\nexit:\n ret i64 0\n}\n\ndeclare i64 @foo()\n\ndeclare i64 @llvm.experimental.deoptimize.i64(...)\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(inaccessiblemem: readwrite)\ndeclare noundef i1 @llvm.experimental.widenable.condition()\n```\n\n\nSteps to reproduce:\n`$opt -passes='print<scalar-evolution>,loop-mssa(licm,loop-simplifycfg,loop-predication)'`\n\nProof: https://godbolt.org/z/8hsbahTjq\n\nLooks like `LoopSimplifyCFGPass` is guilty - it doesn’t invalidate SCEV when removing a dead exit:\n\n```c++\n void handleDeadExits() {\n...\n for (Instruction *I : DeadInstructions) {\n SE.forgetBlockAndLoopDispositions(I);\n I->replaceAllUsesWith(PoisonValue::get(I->getType()));\n I->eraseFromParent();\n }\n```\n\n",
"author": "aleks-tmb",
"labels": [
"crash",
"llvm:transforms"
],
"comments": [
{
"author": "aleks-tmb",
"body": "The `LoopSimplifyCFG` pass removes `%length.lcssa.ph`, but later, in the `LoopPredication` pass, we encounter an assertion failure for the `%length.lcssa` SCEV, which remains equal to `%length`\n\n<img width=\"935\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/4d630238-569e-4d2b-b760-b09d54b4450f\" />\n\n"
},
{
"author": "aleks-tmb",
"body": "It seems the reason why forgetBlockAndLoopDispositions doesn't cover this case is that `%length.lcssa.ph` doesn't have an existing SCEV, since the instruction was just added by the previous LICM pass."
},
{
"author": "nikic",
"body": "There is some pretty tricky interaction between LCSSA formation and SCEV invalidation, see:\nhttps://github.com/llvm/llvm-project/blob/7f69a399df384c86428d0c97e3afbc8146324226/llvm/lib/Transforms/Utils/LCSSA.cpp#L206-L211\n\nBasically, when forming LCSSA form, we take care not to break the invalidation chain, so that invalidation of the LCSSA phi node is sufficient.\n\nI think the LICM predecessor splitting effectively does manual LCSSA formation and doesn't maintain this special logic.\n\nI think the extra forgetValue() call works around this issue and variants of this might appear elsewhere. But TBH I'm not totally sure."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
125278
|
https://github.com/llvm/llvm-project/issues/125278
|
crash
|
1484f82cbc62eab9c4c8f393b84c2f521bf882f6
| 2025-01-31T20:00:27 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "c4f723a7c3bb12ce4e247bcaed755c8d927f73a4",
"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": [
[
1632,
1642
],
[
1659,
1696
],
[
1749,
1767
]
],
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 c4f723a7c3bb12ce4e247bcaed755c8d927f73a4
Author: Ramkumar Ramachandra <ramkumar.ramachandra@codasip.com>
Date: Thu May 8 11:49:54 2025 +0100
[LV] Strip unmaintainable MinBWs assert (#136858)
tryToWiden attempts to replace an Instruction with a Constant from SCEV,
but forgets to erase the Instruction from the MinBWs map, leading to an
assert in VPlanTransforms::truncateToMinimalBitwidths. Going forward,
the assertion in truncateToMinimalBitwidths is unmaintainable, as LV
could simplify the expression at any point: fix the bug by stripping the
unmaintable assertion.
Fixes #125278.
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 7943f58f0739..79ddb8bf0b09 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -1632,11 +1632,6 @@ static void licm(VPlan &Plan) {
void VPlanTransforms::truncateToMinimalBitwidths(
VPlan &Plan, const MapVector<Instruction *, uint64_t> &MinBWs) {
-#ifndef NDEBUG
- // Count the processed recipes and cross check the count later with MinBWs
- // size, to make sure all entries in MinBWs have been handled.
- unsigned NumProcessedRecipes = 0;
-#endif
// Keep track of created truncates, so they can be re-used. Note that we
// cannot use RAUW after creating a new truncate, as this would could make
// other uses have different types for their operands, making them invalidly
@@ -1659,38 +1654,12 @@ void VPlanTransforms::truncateToMinimalBitwidths(
if (!NewResSizeInBits)
continue;
-#ifndef NDEBUG
- NumProcessedRecipes++;
-#endif
// If the value wasn't vectorized, we must maintain the original scalar
// type. Skip those here, after incrementing NumProcessedRecipes. Also
// skip casts which do not need to be handled explicitly here, as
// redundant casts will be removed during recipe simplification.
- if (isa<VPReplicateRecipe, VPWidenCastRecipe>(&R)) {
-#ifndef NDEBUG
- // If any of the operands is a live-in and not used by VPWidenRecipe or
- // VPWidenSelectRecipe, but in MinBWs, make sure it is counted as
- // processed as well. When MinBWs is currently constructed, there is no
- // information about whether recipes are widened or replicated and in
- // case they are reciplicated the operands are not truncated. Counting
- // them them here ensures we do not miss any recipes in MinBWs.
- // TODO: Remove once the analysis is done on VPlan.
- for (VPValue *Op : R.operands()) {
- if (!Op->isLiveIn())
- continue;
- auto *UV = dyn_cast_or_null<Instruction>(Op->getUnderlyingValue());
- if (UV && MinBWs.contains(UV) && !ProcessedTruncs.contains(Op) &&
- none_of(Op->users(),
- IsaPred<VPWidenRecipe, VPWidenSelectRecipe>)) {
- // Add an entry to ProcessedTruncs to avoid counting the same
- // operand multiple times.
- ProcessedTruncs[Op] = nullptr;
- NumProcessedRecipes += 1;
- }
- }
-#endif
+ if (isa<VPReplicateRecipe, VPWidenCastRecipe>(&R))
continue;
- }
Type *OldResTy = TypeInfo.inferScalarType(ResultVPV);
unsigned OldResSizeInBits = OldResTy->getScalarSizeInBits();
@@ -1749,19 +1718,11 @@ void VPlanTransforms::truncateToMinimalBitwidths(
NewOp->insertBefore(&R);
} else {
PH->appendRecipe(NewOp);
-#ifndef NDEBUG
- auto *OpInst = dyn_cast<Instruction>(Op->getLiveInIRValue());
- bool IsContained = MinBWs.contains(OpInst);
- NumProcessedRecipes += IsContained;
-#endif
}
}
}
}
-
- assert(MinBWs.size() == NumProcessedRecipes &&
- "some entries in MinBWs haven't been processed");
}
/// Remove BranchOnCond recipes with true conditions together with removing
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/pr125278.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-width=4 -S %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @pr125278(ptr %dst, i64 %n) {\n;\nentry:\n %true.ext = zext i1 true to i32\n br label %cond\n\ncond:\n br label %loop\n\nloop:\n %iv = phi i64 [ 0, %cond ], [ %iv.next, %loop ]\n %false.ext = zext i1 false to i32\n %xor = xor i32 %false.ext, %true.ext\n %xor.trunc = trunc i32 %xor to i8\n store i8 %xor.trunc, ptr %dst, align 1\n %iv.next = add i64 %iv, 1\n %cmp = icmp ult i64 %iv.next, %n\n br i1 %cmp, label %loop, label %cond\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[LoopVectorize] Assertion `MinBWs.size() == NumProcessedRecipes && \"some entries in MinBWs haven't been processed\"' failed.",
"body": "Testcase:\n```llvm ir\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @c() #0 {\nentry:\n %conv12 = zext i1 false to i32\n br label %for.cond1\n\nfor.cond1: ; preds = %for.body, %entry\n br label %for.body\n\nfor.body: ; preds = %for.body, %for.cond1\n %indvars.iv1 = phi i64 [ 0, %for.cond1 ], [ %indvars.iv.next, %for.body ]\n %land.ext = zext i1 false to i32\n %xor = xor i32 0, %conv12\n %conv20 = trunc i32 %xor to i8\n store i8 %conv20, ptr null, align 1\n %indvars.iv.next = add i64 %indvars.iv1, 1\n %cmp = icmp ult i64 %indvars.iv1, 1\n br i1 %cmp, label %for.body, label %for.cond1\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,+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,-zvl256b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\n```\nCommand/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/VPlanTransforms.cpp:1438: static void llvm::VPlanTransforms::truncateToMinimalBitwidths(llvm::VPlan&, const llvm::MapVector<llvm::Instruction*, long unsigned int>&): Assertion `MinBWs.size() == NumProcessedRecipes && \"some entries in MinBWs haven't been processed\"' 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 \"c\"\n #0 0x00005ac7451347e2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x33f67e2)\n #1 0x00005ac74513182f llvm::sys::RunSignalHandlers() (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x33f382f)\n #2 0x00005ac74513196c SignalHandler(int) Signals.cpp:0:0\n #3 0x00007f6297445320 (/lib/x86_64-linux-gnu/libc.so.6+0x45320)\n #4 0x00007f629749eb1c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #5 0x00007f629749eb1c __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #6 0x00007f629749eb1c pthread_kill ./nptl/pthread_kill.c:89:10\n #7 0x00007f629744526e raise ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x00007f62974288ff abort ./stdlib/abort.c:81:7\n #9 0x00007f629742881b _nl_load_domain ./intl/loadmsgcat.c:1177:9\n#10 0x00007f629743b507 (/lib/x86_64-linux-gnu/libc.so.6+0x3b507)\n#11 0x00005ac74415e85e 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&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x242085e)\n#12 0x00005ac743fd3d90 llvm::LoopVectorizationPlanner::buildVPlansWithVPRecipes(llvm::ElementCount, llvm::ElementCount) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x2295d90)\n#13 0x00005ac743fd42ee llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x22962ee)\n#14 0x00005ac743fd6055 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x2298055)\n#15 0x00005ac743fd8fe1 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x229afe1)\n#16 0x00005ac743fd95c7 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x229b5c7)\n#17 0x00005ac742ce28c5 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+0xfa48c5)\n#18 0x00005ac744f21f0a 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+0x31e3f0a)\n#19 0x00005ac742ce5055 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+0xfa7055)\n#20 0x00005ac744f2081c llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x31e281c)\n#21 0x00005ac742ce1785 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+0xfa3785)\n#22 0x00005ac744f20dfd 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+0x31e2dfd)\n#23 0x00005ac74248e195 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+0x750195)\n#24 0x00005ac74247e41e optMain (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x74041e)\n#25 0x00007f629742a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3\n#26 0x00007f629742a28b call_init ./csu/../csu/libc-start.c:128:20\n#27 0x00007f629742a28b __libc_start_main ./csu/../csu/libc-start.c:347:5\n#28 0x00005ac742474c75 _start (/scratch/ewlu/daily-upstream-build/build-gcv/build-llvm-linux/bin/opt+0x736c75)\nAborted (core dumped)\n```\n\nGodbolt: https://godbolt.org/z/YqE8f1PPz\n\nFound via fuzzer (C program before reduction)",
"author": "ewlu",
"labels": [
"vectorizers",
"crash",
"generated by fuzzer"
],
"comments": [
{
"author": "patrick-rivos",
"body": "Some triaging for the same assert here: https://github.com/llvm/llvm-project/issues/87407"
},
{
"author": "cardigan1008",
"body": "There's a case that triggers the same crash at `-O2`:\n\n```c\nint a, h;\nstruct {\n char b;\n long c;\n char d\n} static e = {2, 2, 5};\nchar f, j, l;\nshort g;\nint *i;\nstatic short k;\nvoid m() {}\nvoid n() {\n m(e);\n for (; f; f++) {\n j ^= (a > (short)*i + k | e.d) <= 0;\n h = l;\n }\n}\nvoid o() {\n g = 1;\n for (; g;)\n k = 9;\n}\nvoid main() {}\n```\n\nCompiler Explorer: https://godbolt.org/z/EK3zbjPax\n\nBisected to https://github.com/llvm/llvm-project/commit/6d6eea92e36c301e34a7ec11b2a40e3080f79f53, which was committed by @fhahn \n\nHope it helps :)"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
122583
|
https://github.com/llvm/llvm-project/issues/122583
|
miscompilation
|
16e45b8fac797c6d4ba161228b54665492204a9d
| 2025-01-11T07:48:51 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "066b88879ab5c195e7e14609e546cc238c2f3bf3",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
2441,
2446
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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": [
"appendOperandsOfVL"
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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 066b88879ab5c195e7e14609e546cc238c2f3bf3
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Mon Jan 13 10:51:26 2025 -0800
[SLP]Correctly set vector operand for extracts with poisons
When extracts are vectorized and it has some poison values instead of
instructions, need to correctly set the vectorized operand not as
poison, but as a main vector operand of the main extract instruction.
Fixes #122583
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 4b0ed5b30179..2742c3777c1e 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -2441,6 +2441,17 @@ public:
// operations or alternating sequences (e.g., +, -), we can safely
// tell the inverse operations by checking commutativity.
if (isa<PoisonValue>(VL[Lane])) {
+ if (auto *EI = dyn_cast<ExtractElementInst>(VL0)) {
+ if (OpIdx == 0) {
+ OpsVec[OpIdx][Lane] = {EI->getVectorOperand(), true, false};
+ continue;
+ }
+ } else if (auto *EV = dyn_cast<ExtractValueInst>(VL0)) {
+ if (OpIdx == 0) {
+ OpsVec[OpIdx][Lane] = {EV->getAggregateOperand(), true, false};
+ continue;
+ }
+ }
OpsVec[OpIdx][Lane] = {
PoisonValue::get(VL0->getOperand(OpIdx)->getType()), true,
false};
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/extractelemets-extended-by-poison.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %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@j = global [4 x i64] zeroinitializer\n\ndefine i32 @main() {\nentry:\n %.pre.i = load i64, ptr getelementptr inbounds nuw (i8, ptr @j, i64 24), align 8\n %.pre50.i = load i64, ptr getelementptr inbounds nuw (i8, ptr @j, i64 16), align 16\n %.pre51.i = load i64, ptr getelementptr inbounds nuw (i8, ptr @j, i64 8), align 8\n %.pre52.i = load i64, ptr @j, align 16\n %0 = or i64 %.pre51.i, 0\n %1 = trunc i64 %.pre.i to i32\n %2 = add i32 %1, 0\n %3 = trunc i64 %.pre50.i to i32\n %4 = add i32 %3, 0\n %5 = trunc i64 %.pre51.i to i32\n %6 = add i32 %5, 0\n %7 = trunc i64 0 to i32\n %8 = add i32 %5, 0\n %9 = add i32 %7, 0\n %10 = add i32 %1, 0\n %11 = add i32 %3, 0\n %12 = add i32 %5, 0\n %13 = add i32 %7, 0\n %14 = trunc i64 %.pre.i to i32\n %15 = add i32 %14, 0\n %16 = trunc i64 %.pre50.i to i32\n %17 = add i32 %16, 0\n %18 = trunc i64 %.pre51.i to i32\n %19 = add i32 %18, 0\n %20 = trunc i64 %.pre52.i to i32\n %conv14.1.i = or i32 %9, %13\n %21 = or i32 %conv14.1.i, %6\n %22 = or i32 %21, %8\n %23 = or i32 %22, %12\n %24 = or i32 %23, %4\n %25 = or i32 %24, %11\n %26 = or i32 %25, %2\n %27 = or i32 %26, %10\n %28 = or i32 %27, %15\n %29 = or i32 %28, %17\n %30 = or i32 %29, %19\n %31 = add i32 %14, 0\n %32 = add i32 %16, 0\n %33 = add i32 %18, 0\n %34 = add i32 %20, 0\n %35 = add i32 %14, 0\n %36 = add i32 %16, 0\n %37 = add i32 %18, 0\n %38 = add i32 %20, 0\n %39 = add i32 %14, 0\n %40 = add i32 %16, 0\n %41 = add i32 %18, 0\n %42 = add i32 %20, 0\n %inc.3.3.i.1 = or i64 %.pre52.i, 0\n %conv14.i.1 = or i32 %38, %34\n %conv14.1.i.1 = or i32 %conv14.i.1, %42\n %conv14.3.i.1 = or i32 %conv14.1.i.1, %33\n %conv14.145.i.1 = or i32 %conv14.3.i.1, %37\n %conv14.1.1.i.1 = or i32 %conv14.145.i.1, %41\n %conv14.3.1.i.1 = or i32 %conv14.1.1.i.1, %32\n %conv14.247.i.1 = or i32 %conv14.3.1.i.1, %36\n %conv14.1.2.i.1 = or i32 %conv14.247.i.1, %40\n %conv14.3.2.i.1 = or i32 %conv14.1.2.i.1, %31\n %conv14.349.i.1 = or i32 %conv14.3.2.i.1, %35\n %conv14.1.3.i.1 = or i32 %conv14.349.i.1, %39\n %conv14.3.3.i.1 = or i32 %conv14.1.3.i.1, %30\n ret i32 %conv14.3.3.i.1\n}\n",
"lli_expected_out": "",
"additional_args": null
}
]
}
] |
{
"title": "[SLPVectorizer] Miscompilation",
"body": "Reproducer: https://godbolt.org/z/7eEEeeKoo\nSorry, I cannot provide alive2 link since `llvm.vector.insert.v8i64.v4i64` is not supported.\n```\n; bin/opt -passes=slp-vectorizer reduced.ll -S -o opt.ll\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@j = global [4 x i64] zeroinitializer\n\ndefine i32 @main() {\nentry:\n %.pre.i = load i64, ptr getelementptr inbounds nuw (i8, ptr @j, i64 24), align 8\n %.pre50.i = load i64, ptr getelementptr inbounds nuw (i8, ptr @j, i64 16), align 16\n %.pre51.i = load i64, ptr getelementptr inbounds nuw (i8, ptr @j, i64 8), align 8\n %.pre52.i = load i64, ptr @j, align 16\n %0 = or i64 %.pre51.i, 0\n %1 = trunc i64 %.pre.i to i32\n %2 = add i32 %1, 0\n %3 = trunc i64 %.pre50.i to i32\n %4 = add i32 %3, 0\n %5 = trunc i64 %.pre51.i to i32\n %6 = add i32 %5, 0\n %7 = trunc i64 0 to i32\n %8 = add i32 %5, 0\n %9 = add i32 %7, 0\n %10 = add i32 %1, 0\n %11 = add i32 %3, 0\n %12 = add i32 %5, 0\n %13 = add i32 %7, 0\n %14 = trunc i64 %.pre.i to i32\n %15 = add i32 %14, 0\n %16 = trunc i64 %.pre50.i to i32\n %17 = add i32 %16, 0\n %18 = trunc i64 %.pre51.i to i32\n %19 = add i32 %18, 0\n %20 = trunc i64 %.pre52.i to i32\n %conv14.1.i = or i32 %9, %13\n %21 = or i32 %conv14.1.i, %6\n %22 = or i32 %21, %8\n %23 = or i32 %22, %12\n %24 = or i32 %23, %4\n %25 = or i32 %24, %11\n %26 = or i32 %25, %2\n %27 = or i32 %26, %10\n %28 = or i32 %27, %15\n %29 = or i32 %28, %17\n %30 = or i32 %29, %19\n %31 = add i32 %14, 0\n %32 = add i32 %16, 0\n %33 = add i32 %18, 0\n %34 = add i32 %20, 0\n %35 = add i32 %14, 0\n %36 = add i32 %16, 0\n %37 = add i32 %18, 0\n %38 = add i32 %20, 0\n %39 = add i32 %14, 0\n %40 = add i32 %16, 0\n %41 = add i32 %18, 0\n %42 = add i32 %20, 0\n %inc.3.3.i.1 = or i64 %.pre52.i, 0\n %conv14.i.1 = or i32 %38, %34\n %conv14.1.i.1 = or i32 %conv14.i.1, %42\n %conv14.3.i.1 = or i32 %conv14.1.i.1, %33\n %conv14.145.i.1 = or i32 %conv14.3.i.1, %37\n %conv14.1.1.i.1 = or i32 %conv14.145.i.1, %41\n %conv14.3.1.i.1 = or i32 %conv14.1.1.i.1, %32\n %conv14.247.i.1 = or i32 %conv14.3.1.i.1, %36\n %conv14.1.2.i.1 = or i32 %conv14.247.i.1, %40\n %conv14.3.2.i.1 = or i32 %conv14.1.2.i.1, %31\n %conv14.349.i.1 = or i32 %conv14.3.2.i.1, %35\n %conv14.1.3.i.1 = or i32 %conv14.349.i.1, %39\n %conv14.3.3.i.1 = or i32 %conv14.1.3.i.1, %30\n ret i32 %conv14.3.3.i.1\n}\n```\nOutput:\n```\nsource_filename = \"/app/example.ll\"\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i32 @main() {\n %0 = load <4 x i64>, ptr @j, align 16\n %1 = or i64 poison, 0\n %2 = shufflevector <4 x i64> %0, <4 x i64> poison, <8 x i32> <i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 1, i32 poison, i32 poison>\n %3 = shufflevector <4 x i64> %0, <4 x i64> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison>\n %4 = shufflevector <8 x i64> %3, <8 x i64> <i64 poison, i64 poison, i64 poison, i64 poison, i64 0, i64 poison, i64 poison, i64 poison>, <8 x i32> <i32 poison, i32 poison, i32 poison, i32 poison, i32 12, i32 1, i32 poison, i32 poison>\n %5 = call <8 x i64> @llvm.vector.insert.v8i64.v4i64(<8 x i64> %4, <4 x i64> %0, i64 0)\n %6 = trunc <8 x i64> %5 to <8 x i32>\n %7 = shufflevector <8 x i32> %6, <8 x i32> poison, <16 x i32> <i32 0, i32 0, i32 0, i32 1, i32 1, i32 1, i32 2, i32 2, i32 2, i32 3, i32 3, i32 3, i32 4, i32 4, i32 5, i32 5>\n %8 = add <16 x i32> %7, zeroinitializer\n %9 = extractelement <4 x i64> %0, i32 0\n %inc.3.3.i.1 = or i64 %9, 0\n %10 = call i32 @llvm.vector.reduce.or.v16i32(<16 x i32> %8)\n %11 = call i32 @llvm.vector.reduce.or.v8i32(<8 x i32> poison)\n %op.rdx = or i32 %10, %11\n ret i32 %op.rdx\n}\n\ndeclare <8 x i64> @llvm.vector.insert.v8i64.v4i64(<8 x i64>, <4 x i64>, i64 immarg) #0\n\ndeclare i32 @llvm.vector.reduce.or.v16i32(<16 x i32>) #0\n\ndeclare i32 @llvm.vector.reduce.or.v8i32(<8 x i32>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n```\nlli output:\n```\n> bin/lli reduced.ll\n> echo $?\n0\n> bin/lli opt.ll\n> echo $?\n255\n```\n[llubi](https://github.com/dtcxzyw/llvm-ub-aware-interpreter) output:\nBefore:\n```\n> ./llubi reduced.ll --verbose\nEntering function main\n %0 = getelementptr inbounds nuw i8, ptr @j, i64 24 -> Ptr 40[@j + 24]\n %.pre.i = load i64, ptr %0, align 8 -> i64 0\n %1 = getelementptr inbounds nuw i8, ptr @j, i64 16 -> Ptr 32[@j + 16]\n %.pre50.i = load i64, ptr %1, align 16 -> i64 0\n %2 = getelementptr inbounds nuw i8, ptr @j, i64 8 -> Ptr 24[@j + 8]\n %.pre51.i = load i64, ptr %2, align 8 -> i64 0\n %.pre52.i = load i64, ptr @j, align 16 -> i64 0\n %3 = or i64 %.pre51.i, 0 -> i64 0\n %4 = trunc i64 %.pre.i to i32 -> i32 0\n %5 = add i32 %4, 0 -> i32 0\n %6 = trunc i64 %.pre50.i to i32 -> i32 0\n %7 = add i32 %6, 0 -> i32 0\n %8 = trunc i64 %.pre51.i to i32 -> i32 0\n %9 = add i32 %8, 0 -> i32 0\n %10 = trunc i64 0 to i32 -> i32 0\n %11 = add i32 %8, 0 -> i32 0\n %12 = add i32 %10, 0 -> i32 0\n %13 = add i32 %4, 0 -> i32 0\n %14 = add i32 %6, 0 -> i32 0\n %15 = add i32 %8, 0 -> i32 0\n %16 = add i32 %10, 0 -> i32 0\n %17 = trunc i64 %.pre.i to i32 -> i32 0\n %18 = add i32 %17, 0 -> i32 0\n %19 = trunc i64 %.pre50.i to i32 -> i32 0\n %20 = add i32 %19, 0 -> i32 0\n %21 = trunc i64 %.pre51.i to i32 -> i32 0\n %22 = add i32 %21, 0 -> i32 0\n %23 = trunc i64 %.pre52.i to i32 -> i32 0\n %conv14.1.i = or i32 %12, %16 -> i32 0\n %24 = or i32 %conv14.1.i, %9 -> i32 0\n %25 = or i32 %24, %11 -> i32 0\n %26 = or i32 %25, %15 -> i32 0\n %27 = or i32 %26, %7 -> i32 0\n %28 = or i32 %27, %14 -> i32 0\n %29 = or i32 %28, %5 -> i32 0\n %30 = or i32 %29, %13 -> i32 0\n %31 = or i32 %30, %18 -> i32 0\n %32 = or i32 %31, %20 -> i32 0\n %33 = or i32 %32, %22 -> i32 0\n %34 = add i32 %17, 0 -> i32 0\n %35 = add i32 %19, 0 -> i32 0\n %36 = add i32 %21, 0 -> i32 0\n %37 = add i32 %23, 0 -> i32 0\n %38 = add i32 %17, 0 -> i32 0\n %39 = add i32 %19, 0 -> i32 0\n %40 = add i32 %21, 0 -> i32 0\n %41 = add i32 %23, 0 -> i32 0\n %42 = add i32 %17, 0 -> i32 0\n %43 = add i32 %19, 0 -> i32 0\n %44 = add i32 %21, 0 -> i32 0\n %45 = add i32 %23, 0 -> i32 0\n %inc.3.3.i.1 = or i64 %.pre52.i, 0 -> i64 0\n %conv14.i.1 = or i32 %41, %37 -> i32 0\n %conv14.1.i.1 = or i32 %conv14.i.1, %45 -> i32 0\n %conv14.3.i.1 = or i32 %conv14.1.i.1, %36 -> i32 0\n %conv14.145.i.1 = or i32 %conv14.3.i.1, %40 -> i32 0\n %conv14.1.1.i.1 = or i32 %conv14.145.i.1, %44 -> i32 0\n %conv14.3.1.i.1 = or i32 %conv14.1.1.i.1, %35 -> i32 0\n %conv14.247.i.1 = or i32 %conv14.3.1.i.1, %39 -> i32 0\n %conv14.1.2.i.1 = or i32 %conv14.247.i.1, %43 -> i32 0\n %conv14.3.2.i.1 = or i32 %conv14.1.2.i.1, %34 -> i32 0\n %conv14.349.i.1 = or i32 %conv14.3.2.i.1, %38 -> i32 0\n %conv14.1.3.i.1 = or i32 %conv14.349.i.1, %42 -> i32 0\n %conv14.3.3.i.1 = or i32 %conv14.1.3.i.1, %33 -> i32 0\n ret i32 %conv14.3.3.i.1\nExiting function main\n```\nAfter:\n```\n> ./llubi opt.ll --verbose\nEntering function main\n %0 = load <4 x i64>, ptr @j, align 16 -> { i64 0, i64 0, i64 0, i64 0 }\n %1 = or i64 poison, 1 -> poison\n %2 = or i64 poison, 0 -> poison\n %3 = shufflevector <4 x i64> %0, <4 x i64> poison, <8 x i32> <i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 1, i32 poison, i32 poison> -> { poison, poison, poison, poison, poison, i64 0, poison, poison }\n %4 = shufflevector <4 x i64> %0, <4 x i64> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison> -> { i64 0, i64 0, i64 0, i64 0, poison, poison, poison, poison }\n %5 = shufflevector <8 x i64> %4, <8 x i64> <i64 poison, i64 poison, i64 poison, i64 poison, i64 0, i64 poison, i64 poison, i64 poison>, <8 x i32> <i32 poison, i32 poison, i32 poison, i32 poison, i32 12, i32 1, i32 poison, i32 poison> -> { poison, poison, poison, poison, i64 0, i64 0, poison, poison }\n %6 = call <8 x i64> @llvm.vector.insert.v8i64.v4i64(<8 x i64> %5, <4 x i64> %0, i64 0) -> { i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, poison, poison }\n %7 = trunc <8 x i64> %6 to <8 x i32> -> { i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, poison, poison }\n %8 = shufflevector <8 x i32> %7, <8 x i32> poison, <16 x i32> <i32 0, i32 0, i32 0, i32 1, i32 1, i32 1, i32 2, i32 2, i32 2, i32 3, i32 3, i32 3, i32 4, i32 4, i32 5, i32 5> -> { i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0 }\n %9 = add <16 x i32> %8, zeroinitializer -> { i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0 }\n %10 = extractelement <4 x i64> %0, i32 0 -> i64 0\n %inc.3.3.i.1 = or i64 %10, 0 -> i64 0\n %11 = call i32 @llvm.vector.reduce.or.v16i32(<16 x i32> %9) -> i32 0\n %12 = call i32 @llvm.vector.reduce.or.v8i32(<8 x i32> poison) -> poison\n %op.rdx = or i32 %11, %12 -> poison\n ret i32 %op.rdx\nExiting function main\n\nUB triggered: Return a poison value\nExited with immediate UB.\nStacktrace:\n```\n",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:SLPVectorizer",
"generated by fuzzer"
],
"comments": [
{
"author": "dtcxzyw",
"body": "llvm version: 6329355860e9b66bc7ed68b46c166763e408d4cc"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
137797
|
https://github.com/llvm/llvm-project/issues/137797
|
crash
|
368fbc21631a16b66a2a5609271c467a025a08b9
| 2025-04-29T12:24:21 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "3aecbbcbf675bc4472dafff18d29f21457323f28",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
15245,
15250
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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 3aecbbcbf675bc4472dafff18d29f21457323f28
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Tue May 6 06:40:54 2025 -0700
[SLP]Do not match nodes if schedulability of parent nodes is different
If one user node is non-schedulable and another one is schedulable, such
nodes should be considered matched. The selection of the actual insert
point in this case differs and the insert points may match, which may
cause a compiler crash because of the broken def-use chain.
Fixes #137797
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 4d183bb42f0e..a6ae26f2f0e1 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -15245,6 +15245,11 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
continue;
}
+ if (!TEUseEI.UserTE->isGather() && !UserPHI &&
+ doesNotNeedToSchedule(TEUseEI.UserTE->Scalars) !=
+ doesNotNeedToSchedule(UseEI.UserTE->Scalars) &&
+ is_contained(UseEI.UserTE->Scalars, TEInsertPt))
+ continue;
// Check if the user node of the TE comes after user node of TEPtr,
// otherwise TEPtr depends on TE.
if ((TEInsertBlock != InsertPt->getParent() ||
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/matched-bv-schedulable.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s -slp-threshold=-99999"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @test() {\n;\nbb:\n br i1 false, label %bb1, label %bb5\n\nbb1:\n %phi = phi i32 [ %or4, %bb1 ], [ 0, %bb ]\n %phi2 = phi i32 [ %add, %bb1 ], [ 0, %bb ]\n %add = add i32 1, 0\n %or = or i32 0, %phi2\n %or3 = or i32 %or, 0\n %mul = mul i32 0, 0\n %or4 = or i32 %phi, %mul\n br i1 false, label %bb1, label %bb5\n\nbb5:\n %phi6 = phi i32 [ 0, %bb ], [ %or4, %bb1 ]\n %phi7 = phi i32 [ 0, %bb ], [ %or, %bb1 ]\n ret void\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Instruction does not dominate all uses! LLVM ERROR: Broken module found, compilation aborted!",
"body": "To reproduce run opt with the test below using -passes=slp-vectorizer -slp-threshold=-99999:\n```\n; ModuleID = './reduced.ll'\nsource_filename = \"./reduced.ll\"\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @wombat() #0 gc \"statepoint-example\" {\nbb:\n br i1 false, label %bb1, label %bb5\n\nbb1: ; preds = %bb1, %bb\n %phi = phi i32 [ %or4, %bb1 ], [ 0, %bb ]\n %phi2 = phi i32 [ %add, %bb1 ], [ 0, %bb ]\n %add = add i32 1, 0\n %or = or i32 0, %phi2\n %or3 = or i32 %or, 0\n %mul = mul i32 0, 0\n %or4 = or i32 %phi, %mul\n br i1 false, label %bb1, label %bb5\n\nbb5: ; preds = %bb1, %bb\n %phi6 = phi i32 [ 0, %bb ], [ %or4, %bb1 ]\n %phi7 = phi i32 [ 0, %bb ], [ %or, %bb1 ]\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+prfchw,-cldemote,+avx,+aes,+sahf,+pclmul,-xop,+crc32,-amx-fp8,+xsaves,-avx512fp16,-usermsr,-sm4,-egpr,+sse4.1,-avx512ifma,+xsave,+sse4.2,-tsxldtrk,-sm3,-ptwrite,-widekl,-movrs,+invpcid,+64bit,+xsavec,-avx10.1-512,-avx512vpopcntdq,+cmov,-avx512vp2intersect,+avx512cd,+movbe,-avxvnniint8,-ccmp,-amx-int8,-kl,-avx10.1-256,+evex512,-avxvnni,+rtm,+adx,+avx2,-hreset,-movdiri,-serialize,-sha512,-vpclmulqdq,+avx512vl,-uintr,-cf,+clflushopt,-raoint,-cmpccxadd,+bmi,-amx-tile,+sse,-avx10.2-256,-gfni,-avxvnniint16,-amx-fp16,-zu,-ndd,+xsaveopt,+rdrnd,+avx512f,-amx-bf16,-avx512bf16,-avx512vnni,-push2pop2,+cx8,+avx512bw,+sse3,+pku,-nf,-amx-tf32,-amx-avx512,+fsgsbase,-clzero,-mwaitx,-lwp,+lzcnt,-sha,-movdir64b,-ppx,-wbnoinvd,-enqcmd,-amx-transpose,-avx10.2-512,-avxneconvert,-tbm,-pconfig,-amx-complex,+ssse3,+cx16,+bmi2,+fma,+popcnt,-avxifma,+f16c,-avx512bitalg,-rdpru,+clwb,+mmx,+sse2,+rdseed,-avx512vbmi2,-prefetchi,-amx-movrs,-rdpid,-fma4,-avx512vbmi,-shstk,-vaes,-waitpkg,-sgx,+fxsr,+avx512dq,-sse4a,-avx512f\" }\n```\nReproducer: https://godbolt.org/z/YbPKn761h\nStack dump:\n```\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer -slp-threshold=-99999 <source>\n1.\tRunning pass \"verify\" on module \"<source>\"\n #0 0x00000000055242e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x55242e8)\n #1 0x0000000005521c74 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x000073e542242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x000073e5422969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x000073e542242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x000073e5422287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x000000000080a091 llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0\n #7 0x00000000054600e8 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x54600e8)\n #8 0x000000000535c8d8 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x535c8d8)\n #9 0x000000000093ee6e llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x93ee6e)\n#10 0x000000000531b5a0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x531b5a0)\n#11 0x00000000009492ba llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9492ba)\n#12 0x000000000093ca8c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x93ca8c)\n#13 0x000073e542229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#14 0x000073e542229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#15 0x00000000009346c5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9346c5)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```\n",
"author": "TatyanaDoubts",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
124387
|
https://github.com/llvm/llvm-project/issues/124387
|
miscompilation
|
77c325b646301e394bcd89c2980b4c2da8af49cd
| 2025-01-25T03:24:37 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "2131115be5b9d8b39af80973d9b64c0adc41d38d",
"components": [
"InstCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
1039,
1049
]
],
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": [
"InstCombinerImpl::SimplifyDemandedUseBits"
],
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 2131115be5b9d8b39af80973d9b64c0adc41d38d
Author: Fangrui Song <i@maskray.me>
Date: Sat Jan 25 13:35:11 2025 -0800
[InstCombine] Drop Range attribute when simplifying 'fshl' based on demanded bits (#124429)
When simplifying operands based on demanded bits, the return value range
of llvm.fshl might change. Keeping the Range attribute might cause
llvm.fshl to generate a poison and lead to miscompile. Drop the Range
attribute similar to `dropPosonGeneratingFlags` elsewhere.
Fix #124387
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index 943598a30f04..2c8939b5a051 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -1039,11 +1039,14 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Instruction *I,
APInt DemandedMaskLHS(DemandedMask.lshr(ShiftAmt));
APInt DemandedMaskRHS(DemandedMask.shl(BitWidth - ShiftAmt));
if (I->getOperand(0) != I->getOperand(1)) {
- if (SimplifyDemandedBits(I, 0, DemandedMaskLHS, LHSKnown,
- Depth + 1, Q) ||
+ if (SimplifyDemandedBits(I, 0, DemandedMaskLHS, LHSKnown, Depth + 1,
+ Q) ||
SimplifyDemandedBits(I, 1, DemandedMaskRHS, RHSKnown, Depth + 1,
- Q))
+ Q)) {
+ // Range attribute may no longer hold.
+ I->dropPoisonGeneratingReturnAttributes();
return I;
+ }
} else { // fshl is a rotate
// Avoid converting rotate into funnel shift.
// Only simplify if one operand is constant.
|
[
{
"file": "llvm/test/Transforms/InstCombine/fsh.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "fshl_range_trunc",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.fshl.i32(i32, i32, i32) #0\n\ndefine i8 @fshl_range_trunc(i1 %x) {\n %zext = zext i1 %x to i32\n %or = or disjoint i32 %zext, -2\n %fshl = call range(i32 -4, 2) i32 @llvm.fshl.i32(i32 %or, i32 %or, i32 1)\n %tr = trunc nsw i32 %fshl to i8\n ret i8 %tr\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[clang] Miscompile with -O2/3/s",
"body": "This code prints random value at `-O2/3/s` and -1 at `-O0/1`:\n\n```c\nint printf(const char *, ...);\nint a, b;\nvoid c(char d) { a = d; }\nint e(int d) {\n if (d < 0)\n return 1;\n return 0;\n}\nint f() {\n if (b)\n return 0;\n return 1;\n}\nint g(int d) {\n int h = 0;\n if (3 + d)\n h = f() - 1 - 1;\n return e(h) + h + h;\n}\nint main() {\n int i = g(0);\n c(i);\n printf(\"%d\\n\", a);\n}\n```\n\nCompiler Explorer: https://godbolt.org/z/KfWsKxcvE\n\nIt starts from x86_64 clang 19.1.0. ",
"author": "cardigan1008",
"labels": [
"miscompilation",
"llvm:instcombine",
"regression:19"
],
"comments": [
{
"author": "MaskRay",
"body": "InstCombine miscompiles \n\n```llvm\ndefine i32 @src(i32 %x) local_unnamed_addr {\nentry:\n %cmp = icmp eq i32 %x, 0\n %zext = zext i1 %cmp to i32\n %or = or disjoint i32 %zext, -2\n %fshl = call range(i32 -4, 2) i32 @llvm.fshl.i32(i32 %or, i32 %or, i32 1)\n %tr = trunc nsw i32 %fshl to i8\n %res = sext i8 %tr to i32\n ret i32 %res\n}\n```\n\nedit: `g` has a Range return attribute, which is propagated to the call site in `main` after inlining.\nInstCombine `InstCombinerImpl::SimplifyDemandedUseBits` simplifies the operand, but keeps the no-longer-valid Range return attribute.\n\nThen, CorrelatedValuePropagationPass added nsw, and the value eventually becomes poison."
},
{
"author": "nikic",
"body": "Slightly reduced: https://alive2.llvm.org/ce/z/3Kf7-2\n\nI assume the problem is that we don't clear the return range attribute in SimplifyDemanded."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
114901
|
https://github.com/llvm/llvm-project/issues/114901
|
miscompilation
|
a88be11eef59b1722030e1219109ea0b76eebbe5
| 2024-11-05T00:44:52 |
[
"llvm/test/Transforms/VectorCombine"
] |
{
"fix_commit": "05e838f428555bcc4507bd37912da60ea9110ef6",
"components": [
"VectorCombine"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
1032,
1040
],
[
1113,
1120
]
],
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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::foldExtractedCmps"
],
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 05e838f428555bcc4507bd37912da60ea9110ef6
Author: Simon Pilgrim <llvm-dev@redking.me.uk>
Date: Tue Nov 5 11:42:20 2024 +0000
[VectorCombine] foldExtractedCmps - disable fold on non-commutative binops
The fold needs to be adjusted to correctly track the LHS/RHS operands, which will take some refactoring, for now just disable the fold in this case.
Fixes #114901
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index 025234c54956..332c52040e21 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -1032,9 +1032,15 @@ bool VectorCombine::scalarizeBinopOrCmp(Instruction &I) {
/// a vector into vector operations followed by extract. Note: The SLP pass
/// may miss this pattern because of implementation problems.
bool VectorCombine::foldExtractedCmps(Instruction &I) {
+ auto *BI = dyn_cast<BinaryOperator>(&I);
+
// We are looking for a scalar binop of booleans.
// binop i1 (cmp Pred I0, C0), (cmp Pred I1, C1)
- if (!I.isBinaryOp() || !I.getType()->isIntegerTy(1))
+ if (!BI || !I.getType()->isIntegerTy(1))
+ return false;
+
+ // TODO: Support non-commutative binary ops.
+ if (!BI->isCommutative())
return false;
// The compare predicates should match, and each compare should have a
@@ -1113,8 +1119,7 @@ bool VectorCombine::foldExtractedCmps(Instruction &I) {
Value *VCmp = Builder.CreateCmp(Pred, X, ConstantVector::get(CmpC));
Value *Shuf = createShiftShuffle(VCmp, ExpensiveIndex, CheapIndex, Builder);
- Value *VecLogic = Builder.CreateBinOp(cast<BinaryOperator>(I).getOpcode(),
- VCmp, Shuf);
+ Value *VecLogic = Builder.CreateBinOp(BI->getOpcode(), VCmp, Shuf);
Value *NewExt = Builder.CreateExtractElement(VecLogic, CheapIndex);
replaceValue(I, *NewExt);
++NumVecCmpBO;
|
[
{
"file": "llvm/test/Transforms/VectorCombine/X86/pr114901.ll",
"commands": [
"opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=sse2",
"opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=avx2"
],
"tests": [
{
"test_name": "PR114901",
"test_body": "define i1 @PR114901(<4 x i32> %a) {\n %e1 = extractelement <4 x i32> %a, i32 1\n %e3 = extractelement <4 x i32> %a, i32 3\n %cmp1 = icmp sgt i32 %e1, -8\n %cmp3 = icmp sgt i32 %e3, 42\n %r = ashr i1 %cmp3, %cmp1\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[VectorCombine] miscompilation",
"body": "Alive2 report: https://alive2.llvm.org/ce/z/YwSTI4\r\n\r\n```llvm\r\n----------------------------------------\r\ndefine i1 @icmp_xor_v4i32.2(<4 x i32> %a) {\r\n#0:\r\n %e1 = extractelement <4 x i32> %a, i32 3\r\n %e2 = extractelement <4 x i32> %a, i32 1\r\n %cmp1 = icmp sgt i32 %e1, 42\r\n %cmp2 = icmp sgt i32 %e2, 4294967288\r\n %#1 = ashr i1 %cmp1, %cmp2\r\n ret i1 %#1\r\n}\r\n=>\r\ndefine i1 @icmp_xor_v4i32.2(<4 x i32> %a) {\r\n#0:\r\n %#1 = icmp sgt <4 x i32> %a, { poison, 4294967288, poison, 42 }\r\n %shift = shufflevector <4 x i1> %#1, <4 x i1> poison, 4294967295, 3, 4294967295, 4294967295\r\n %#2 = ashr <4 x i1> %#1, %shift\r\n %#3 = extractelement <4 x i1> %#2, i64 1\r\n ret i1 %#3\r\n}\r\nTransformation doesn't verify!\r\n\r\nERROR: Target is more poisonous than source\r\n\r\nExample:\r\n<4 x i32> %a = < #x00000000 (0), #xfffffff8 (4294967288, -8), #x00000000 (0), #x0000002b (43) >\r\n\r\nSource:\r\ni32 %e1 = #x0000002b (43)\r\ni32 %e2 = #xfffffff8 (4294967288, -8)\r\ni1 %cmp1 = #x1 (1)\r\ni1 %cmp2 = #x0 (0)\r\ni1 %#1 = #x1 (1)\r\n\r\nTarget:\r\n<4 x i1> %#1 = < poison, #x0 (0), poison, #x1 (1) >\r\n<4 x i1> %shift = < poison, #x1 (1), poison, poison >\r\n<4 x i1> %#2 = < poison, poison, poison, poison >\r\ni1 %#3 = poison\r\nSource value: #x1 (1)\r\nTarget value: poison\r\n\r\nSummary:\r\n 0 correct transformations\r\n 1 incorrect transformations\r\n 0 failed-to-prove transformations\r\n 0 Alive2 errors\r\n```",
"author": "bongjunj",
"labels": [
"miscompilation"
],
"comments": [
{
"author": "RKSimon",
"body": "It looks like the ashr operands have been commuted in the fold - will take a look later today"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
106083
|
https://github.com/llvm/llvm-project/issues/106083
|
crash
|
d075debc508898d5f365f8e909c54d6f4edada85
| 2024-08-26T14:36:57 |
[
"llvm/test/Transforms/DFAJumpThreading"
] |
{
"fix_commit": "d4a38c8ff5c993e14c42895b51a47272fb03a857",
"components": [
"DFAJumpThreading"
],
"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": [
[
194,
200
],
[
202,
207
],
[
223,
254
]
],
"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": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": [
"unfold"
],
"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 d4a38c8ff5c993e14c42895b51a47272fb03a857
Author: Usman Nadeem <mnadeem@quicinc.com>
Date: Tue Sep 24 08:54:36 2024 -0700
[DFAJumpThreading] Handle select unfolding when user phi is not a dir… (#109511)
…ect successor
Previously the code assumed that the select instruction is defined in a
block that is a direct predecessor of the block where the PHINode uses
it. So, we were hitting an assertion when we tried to access the def
block as an incoming block for the user phi node.
This patch handles that case by using the correct end block and creating
a new phi node that aggregates both the values of the select in that end
block, and then using that new unfolded phi to overwrite the original
user phi node.
Fixes #106083
Change-Id: Ie471994cca232318f74a6e6438efa21e561c2dc0
diff --git a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
index ef9c264482a6..0e2b5c925a6a 100644
--- a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
@@ -194,7 +194,6 @@ void unfold(DomTreeUpdater *DTU, LoopInfo *LI, SelectInstToUnfold SIToUnfold,
SelectInst *SI = SIToUnfold.getInst();
PHINode *SIUse = SIToUnfold.getUse();
BasicBlock *StartBlock = SI->getParent();
- BasicBlock *EndBlock = SIUse->getParent();
BranchInst *StartBlockTerm =
dyn_cast<BranchInst>(StartBlock->getTerminator());
@@ -202,6 +201,7 @@ void unfold(DomTreeUpdater *DTU, LoopInfo *LI, SelectInstToUnfold SIToUnfold,
assert(SI->hasOneUse());
if (StartBlockTerm->isUnconditional()) {
+ BasicBlock *EndBlock = StartBlock->getUniqueSuccessor();
// Arbitrarily choose the 'false' side for a new input value to the PHI.
BasicBlock *NewBlock = BasicBlock::Create(
SI->getContext(), Twine(SI->getName(), ".si.unfold.false"),
@@ -223,32 +223,44 @@ void unfold(DomTreeUpdater *DTU, LoopInfo *LI, SelectInstToUnfold SIToUnfold,
NewBlock->getFirstInsertionPt());
NewPhi->addIncoming(SIOp2, StartBlock);
- if (auto *OpSi = dyn_cast<SelectInst>(SIOp1))
- NewSIsToUnfold->push_back(SelectInstToUnfold(OpSi, SIUse));
- if (auto *OpSi = dyn_cast<SelectInst>(SIOp2))
- NewSIsToUnfold->push_back(SelectInstToUnfold(OpSi, NewPhi));
-
- // Update the phi node of SI.
- for (unsigned Idx = 0; Idx < SIUse->getNumIncomingValues(); ++Idx) {
- if (SIUse->getIncomingBlock(Idx) == StartBlock)
- SIUse->setIncomingValue(Idx, SIOp1);
+ // Update any other PHI nodes in EndBlock.
+ for (PHINode &Phi : EndBlock->phis()) {
+ if (SIUse == &Phi)
+ continue;
+ Phi.addIncoming(Phi.getIncomingValueForBlock(StartBlock), NewBlock);
}
- SIUse->addIncoming(NewPhi, NewBlock);
- // Update any other PHI nodes in EndBlock.
- for (auto II = EndBlock->begin(); PHINode *Phi = dyn_cast<PHINode>(II);
- ++II) {
- if (Phi != SIUse)
- Phi->addIncoming(Phi->getIncomingValueForBlock(StartBlock), NewBlock);
+ // Update the phi node of SI, which is its only use.
+ if (EndBlock == SIUse->getParent()) {
+ SIUse->addIncoming(NewPhi, NewBlock);
+ SIUse->replaceUsesOfWith(SI, SIOp1);
+ } else {
+ PHINode *EndPhi = PHINode::Create(SIUse->getType(), pred_size(EndBlock),
+ Twine(SI->getName(), ".si.unfold.phi"),
+ EndBlock->getFirstInsertionPt());
+ for (BasicBlock *Pred : predecessors(EndBlock)) {
+ if (Pred != StartBlock && Pred != NewBlock)
+ EndPhi->addIncoming(EndPhi, Pred);
+ }
+
+ EndPhi->addIncoming(SIOp1, StartBlock);
+ EndPhi->addIncoming(NewPhi, NewBlock);
+ SIUse->replaceUsesOfWith(SI, EndPhi);
+ SIUse = EndPhi;
}
- StartBlockTerm->eraseFromParent();
+ if (auto *OpSi = dyn_cast<SelectInst>(SIOp1))
+ NewSIsToUnfold->push_back(SelectInstToUnfold(OpSi, SIUse));
+ if (auto *OpSi = dyn_cast<SelectInst>(SIOp2))
+ NewSIsToUnfold->push_back(SelectInstToUnfold(OpSi, NewPhi));
// Insert the real conditional branch based on the original condition.
+ StartBlockTerm->eraseFromParent();
BranchInst::Create(EndBlock, NewBlock, SI->getCondition(), StartBlock);
DTU->applyUpdates({{DominatorTree::Insert, StartBlock, EndBlock},
{DominatorTree::Insert, StartBlock, NewBlock}});
} else {
+ BasicBlock *EndBlock = SIUse->getParent();
BasicBlock *NewBlockT = BasicBlock::Create(
SI->getContext(), Twine(SI->getName(), ".si.unfold.true"),
EndBlock->getParent(), EndBlock);
|
[
{
"file": "llvm/test/Transforms/DFAJumpThreading/dfa-jump-threading-transform.ll",
"commands": [
"opt -S -passes=dfa-jump-threading %s"
],
"tests": [
{
"test_name": "test2",
"test_body": "define i32 @test2(i32 %init) {\nentry:\n %cmp = icmp eq i32 %init, 0\n %sel = select i1 %cmp, i32 0, i32 2\n br label %loop.1\n\nloop.1: ; preds = %loop.1.backedge, %entry\n %state.1 = phi i32 [ %sel, %entry ], [ %state.1.be2, %loop.1.backedge ]\n br label %loop.2\n\nloop.2: ; preds = %loop.2.backedge, %loop.1\n %state.2 = phi i32 [ %state.1, %loop.1 ], [ %state.2.be, %loop.2.backedge ]\n br label %loop.3\n\nloop.3: ; preds = %case2, %loop.2\n %state = phi i32 [ %state.2, %loop.2 ], [ 3, %case2 ]\n switch i32 %state, label %infloop.i [\n i32 2, label %case2\n i32 3, label %case3\n i32 4, label %case4\n i32 0, label %case0\n i32 1, label %case1\n ]\n\ncase2: ; preds = %loop.3\n br i1 %cmp, label %loop.3, label %loop.1.backedge\n\ncase3: ; preds = %loop.3\n br i1 %cmp, label %loop.2.backedge, label %case4\n\ncase4: ; preds = %case3, %loop.3\n br i1 %cmp, label %loop.2.backedge, label %loop.1.backedge\n\nloop.1.backedge: ; preds = %case4, %case2\n %state.1.be = phi i32 [ 2, %case4 ], [ 4, %case2 ]\n %state.1.be2 = select i1 %cmp, i32 1, i32 %state.1.be\n br label %loop.1\n\nloop.2.backedge: ; preds = %case4, %case3\n %state.2.be = phi i32 [ 3, %case4 ], [ 0, %case3 ]\n br label %loop.2\n\ncase0: ; preds = %loop.3\n br label %exit\n\ncase1: ; preds = %loop.3\n br label %exit\n\ninfloop.i: ; preds = %infloop.i, %loop.3\n br label %infloop.i\n\nexit: ; preds = %case1, %case0\n ret i32 0\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "pr106083_select_dead_uses",
"test_body": "define void @pr106083_select_dead_uses(i1 %cmp1, i1 %not, ptr %p) {\nbb:\n %spec.select = select i1 %cmp1, i32 0, i32 1\n br label %.loopexit6\n\n.loopexit6: ; preds = %select.unfold, %bb\n br i1 %not, label %select.unfold, label %bb1\n\nbb1: ; preds = %.loopexit6\n %i = load i32, ptr %p, align 4\n %not2 = icmp eq i32 0, 0\n %spec.select7 = select i1 %not2, i32 %spec.select, i32 0\n br label %select.unfold\n\nselect.unfold: ; preds = %bb1, %.loopexit6\n %_2 = phi i32 [ 0, %.loopexit6 ], [ %spec.select7, %bb1 ]\n switch i32 %_2, label %bb2 [\n i32 0, label %.preheader.preheader\n i32 1, label %.loopexit6\n ]\n\n.preheader.preheader: ; preds = %select.unfold\n ret void\n\nbb2: ; preds = %select.unfold\n unreachable\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test1",
"test_body": "define i32 @test1(i32 %num) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.inc, %entry\n %count = phi i32 [ 0, %entry ], [ %inc, %for.inc ]\n %state = phi i32 [ 1, %entry ], [ %state.next, %for.inc ]\n switch i32 %state, label %for.inc [\n i32 1, label %case1\n i32 2, label %case2\n ]\n\ncase1: ; preds = %for.body\n br label %for.inc\n\ncase2: ; preds = %for.body\n %cmp = icmp eq i32 %count, 50\n %sel = select i1 %cmp, i32 1, i32 2\n br label %for.inc\n\nfor.inc: ; preds = %case2, %case1, %for.body\n %state.next = phi i32 [ %sel, %case2 ], [ 1, %for.body ], [ 2, %case1 ]\n %inc = add nsw i32 %count, 1\n %cmp.exit = icmp slt i32 %inc, %num\n br i1 %cmp.exit, label %for.body, label %for.end\n\nfor.end: ; preds = %for.inc\n ret i32 0\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "pr106083_invalidBBarg_fold",
"test_body": "define void @pr106083_invalidBBarg_fold(i1 %cmp1, i1 %cmp2, i1 %not, ptr %d) {\nbb:\n %sel = select i1 %cmp1, i32 0, i32 1\n br label %BB1\n\nBB1: ; preds = %BB1.backedge, %BB7, %bb\n %i = phi i16 [ 0, %BB1.backedge ], [ 0, %bb ], [ 1, %BB7 ]\n br i1 %not, label %BB7, label %BB2\n\nBB2: ; preds = %BB1\n store i16 0, ptr %d, align 2\n %spec.select = select i1 %cmp2, i32 %sel, i32 0\n br label %BB7\n\nBB7: ; preds = %BB2, %BB1\n %d.promoted4 = phi i16 [ 0, %BB1 ], [ 1, %BB2 ]\n %_3 = phi i32 [ 0, %BB1 ], [ %spec.select, %BB2 ]\n switch i32 %_3, label %BB1.backedge [\n i32 0, label %BB1\n i32 1, label %BB8\n ]\n\nBB1.backedge: ; preds = %BB7\n br label %BB1\n\nBB8: ; preds = %BB7\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "pr78059_bitwidth",
"test_body": "define void @pr78059_bitwidth() {\n.split.preheader:\n br label %.split\n\n.split: ; preds = %.split, %.split.preheader\n %0 = phi i128 [ 0, %.split.preheader ], [ -1, %.split ]\n switch i128 %0, label %end [\n i128 -1, label %end\n i128 0, label %.split\n ]\n\nend: ; preds = %.split, %.split\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[DFAJumpThreading] crash since b167ada",
"body": "Seeing many assertions that go away if I revert b167ada \"[DFAJumpThreading] Rewrite the way paths are enumerated (#96127)\".\r\n\r\n```\r\nclang-20 -cc1 -triple s390x-unknown-linux-gnu -target-cpu z15 -O3 -w -mllvm -enable-dfa-jump-thread -o /dev/null -emit-llvm -x ir tc_dfa-jt_invalidbbarg.ll\r\n...\r\n10 0x000002aa0a73e544 (anonymous namespace)::DFAJumpThreading::run\r\n...\r\n```\r\n\r\n```\r\nclang-20 -cc1 -triple s390x-unknown-linux-gnu -target-cpu z16 -O3 -w -mllvm -enable-dfa-jump-thread -o /dev/null -emit-llvm -x ir tc_select_mustbedeadnow.ll\r\n...\r\n#10 0x000002aa1b0c0968 llvm::DFAJumpThreadingPass::run\r\n...\r\n\r\n```\r\n[tcs_dfa-jt.tar.gz](https://github.com/user-attachments/files/16750050/tcs_dfa-jt.tar.gz)\r\n",
"author": "JonPsson1",
"labels": [
"crash",
"llvm:transforms"
],
"comments": [
{
"author": "mikaelholmen",
"body": "Perhaps the same assertion I reported here:\r\n https://github.com/llvm/llvm-project/pull/96127#issuecomment-2303862037\r\n?"
},
{
"author": "JonPsson1",
"body": "> Perhaps the same assertion I reported here: [#96127 (comment)](https://github.com/llvm/llvm-project/pull/96127#issuecomment-2303862037) ?\r\n\r\nYes, same assertion, and in addition my second test case above triggered another assertion."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
108098
|
https://github.com/llvm/llvm-project/issues/108098
|
crash
|
b8239e1201f5871bed5b633b76fa9536672f287f
| 2024-09-10T21:48:37 |
[
"llvm/test/Analysis/CostModel",
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "ea83e1c05a5adee5d8f9e680356ee57556ba64a1",
"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": [
[
1182,
1194
]
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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": [
"setWideningDecision"
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 ea83e1c05a5adee5d8f9e680356ee57556ba64a1
Author: Florian Hahn <flo@fhahn.com>
Date: Wed Sep 11 21:04:33 2024 +0100
[LV] Assign cost to all interleave members when not interleaving.
At the moment, the full cost of all interleave group members is assigned
to the instruction at the group's insert position, even if the decision
was to not form an interleave group.
This can lead to inaccurate cost estimates, e.g. if the instruction at
the insert position is dead. If the decision is to not vectorize but
scalarize or scather/gather, then the cost will be to total cost for all
members. In those cases, assign individual the cost per member, to more
closely reflect to choice per instruction.
This fixes a divergence between legacy and VPlan-based cost model.
Fixes https://github.com/llvm/llvm-project/issues/108098.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 640a7bf3d672..3b6b154b9660 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1182,13 +1182,23 @@ public:
InstructionCost Cost) {
assert(VF.isVector() && "Expected VF >=2");
/// Broadcast this decicion to all instructions inside the group.
- /// But the cost will be assigned to one instruction only.
+ /// When interleaving, the cost will only be assigned one instruction, the
+ /// insert position. For other cases, add the appropriate fraction of the
+ /// total cost to each instruction. This ensures accurate costs are used,
+ /// even if the insert position instruction is not used.
+ InstructionCost InsertPosCost = Cost;
+ InstructionCost OtherMemberCost = 0;
+ if (W != CM_Interleave)
+ OtherMemberCost = InsertPosCost = Cost / Grp->getNumMembers();
+ ;
for (unsigned Idx = 0; Idx < Grp->getFactor(); ++Idx) {
if (auto *I = Grp->getMember(Idx)) {
if (Grp->getInsertPos() == I)
- WideningDecisions[std::make_pair(I, VF)] = std::make_pair(W, Cost);
+ WideningDecisions[std::make_pair(I, VF)] =
+ std::make_pair(W, InsertPosCost);
else
- WideningDecisions[std::make_pair(I, VF)] = std::make_pair(W, 0);
+ WideningDecisions[std::make_pair(I, VF)] =
+ std::make_pair(W, OtherMemberCost);
}
}
}
|
[
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-f32-stride-5.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x float], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %in0 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.4\n %v0 = load float, ptr %in0, align 4\n %v1 = load float, ptr %in1, align 4\n %v2 = load float, ptr %in2, align 4\n %v3 = load float, ptr %in3, align 4\n %v4 = load float, ptr %in4, align 4\n %reduce.add.0 = fadd float %v0, %v1\n %reduce.add.1 = fadd float %reduce.add.0, %v2\n %reduce.add.2 = fadd float %reduce.add.1, %v3\n %reduce.add.3 = fadd float %reduce.add.2, %v4\n %reduce.add.3.narrow = fptoui float %reduce.add.3 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.3.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 5\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-f32-stride-7.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x float], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %in0 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.5\n %in6 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.6\n %v0 = load float, ptr %in0, align 4\n %v1 = load float, ptr %in1, align 4\n %v2 = load float, ptr %in2, align 4\n %v3 = load float, ptr %in3, align 4\n %v4 = load float, ptr %in4, align 4\n %v5 = load float, ptr %in5, align 4\n %v6 = load float, ptr %in6, align 4\n %reduce.add.0 = fadd float %v0, %v1\n %reduce.add.1 = fadd float %reduce.add.0, %v2\n %reduce.add.2 = fadd float %reduce.add.1, %v3\n %reduce.add.3 = fadd float %reduce.add.2, %v4\n %reduce.add.4 = fadd float %reduce.add.3, %v5\n %reduce.add.5 = fadd float %reduce.add.4, %v6\n %reduce.add.5.narrow = fptoui float %reduce.add.5 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.5.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 7\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-f32-stride-8.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x float], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %iv.7 = add nuw nsw i64 %iv, 7\n %in0 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.5\n %in6 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.6\n %in7 = getelementptr inbounds [1024 x float], ptr @A, i64 0, i64 %iv.7\n %v0 = load float, ptr %in0, align 4\n %v1 = load float, ptr %in1, align 4\n %v2 = load float, ptr %in2, align 4\n %v3 = load float, ptr %in3, align 4\n %v4 = load float, ptr %in4, align 4\n %v5 = load float, ptr %in5, align 4\n %v6 = load float, ptr %in6, align 4\n %v7 = load float, ptr %in7, align 4\n %reduce.add.0 = fadd float %v0, %v1\n %reduce.add.1 = fadd float %reduce.add.0, %v2\n %reduce.add.2 = fadd float %reduce.add.1, %v3\n %reduce.add.3 = fadd float %reduce.add.2, %v4\n %reduce.add.4 = fadd float %reduce.add.3, %v5\n %reduce.add.5 = fadd float %reduce.add.4, %v6\n %reduce.add.6 = fadd float %reduce.add.5, %v7\n %reduce.add.6.narrow = fptoui float %reduce.add.6 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.6.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 8\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-f64-stride-2.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x double], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %in0 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.1\n %v0 = load double, ptr %in0, align 8\n %v1 = load double, ptr %in1, align 8\n %reduce.add.0 = fadd double %v0, %v1\n %reduce.add.0.narrow = fptoui double %reduce.add.0 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.0.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 2\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-f64-stride-3.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x double], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %in0 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.2\n %v0 = load double, ptr %in0, align 8\n %v1 = load double, ptr %in1, align 8\n %v2 = load double, ptr %in2, align 8\n %reduce.add.0 = fadd double %v0, %v1\n %reduce.add.1 = fadd double %reduce.add.0, %v2\n %reduce.add.1.narrow = fptoui double %reduce.add.1 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.1.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 3\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-f64-stride-4.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x double], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %in0 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.3\n %v0 = load double, ptr %in0, align 8\n %v1 = load double, ptr %in1, align 8\n %v2 = load double, ptr %in2, align 8\n %v3 = load double, ptr %in3, align 8\n %reduce.add.0 = fadd double %v0, %v1\n %reduce.add.1 = fadd double %reduce.add.0, %v2\n %reduce.add.2 = fadd double %reduce.add.1, %v3\n %reduce.add.2.narrow = fptoui double %reduce.add.2 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.2.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 4\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-f64-stride-5.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x double], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %in0 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.4\n %v0 = load double, ptr %in0, align 8\n %v1 = load double, ptr %in1, align 8\n %v2 = load double, ptr %in2, align 8\n %v3 = load double, ptr %in3, align 8\n %v4 = load double, ptr %in4, align 8\n %reduce.add.0 = fadd double %v0, %v1\n %reduce.add.1 = fadd double %reduce.add.0, %v2\n %reduce.add.2 = fadd double %reduce.add.1, %v3\n %reduce.add.3 = fadd double %reduce.add.2, %v4\n %reduce.add.3.narrow = fptoui double %reduce.add.3 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.3.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 5\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-f64-stride-6.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x double], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %in0 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.5\n %v0 = load double, ptr %in0, align 8\n %v1 = load double, ptr %in1, align 8\n %v2 = load double, ptr %in2, align 8\n %v3 = load double, ptr %in3, align 8\n %v4 = load double, ptr %in4, align 8\n %v5 = load double, ptr %in5, align 8\n %reduce.add.0 = fadd double %v0, %v1\n %reduce.add.1 = fadd double %reduce.add.0, %v2\n %reduce.add.2 = fadd double %reduce.add.1, %v3\n %reduce.add.3 = fadd double %reduce.add.2, %v4\n %reduce.add.4 = fadd double %reduce.add.3, %v5\n %reduce.add.4.narrow = fptoui double %reduce.add.4 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.4.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 6\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-f64-stride-7.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x double], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %in0 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.5\n %in6 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.6\n %v0 = load double, ptr %in0, align 8\n %v1 = load double, ptr %in1, align 8\n %v2 = load double, ptr %in2, align 8\n %v3 = load double, ptr %in3, align 8\n %v4 = load double, ptr %in4, align 8\n %v5 = load double, ptr %in5, align 8\n %v6 = load double, ptr %in6, align 8\n %reduce.add.0 = fadd double %v0, %v1\n %reduce.add.1 = fadd double %reduce.add.0, %v2\n %reduce.add.2 = fadd double %reduce.add.1, %v3\n %reduce.add.3 = fadd double %reduce.add.2, %v4\n %reduce.add.4 = fadd double %reduce.add.3, %v5\n %reduce.add.5 = fadd double %reduce.add.4, %v6\n %reduce.add.5.narrow = fptoui double %reduce.add.5 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.5.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 7\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-f64-stride-8.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x double], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %iv.7 = add nuw nsw i64 %iv, 7\n %in0 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.5\n %in6 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.6\n %in7 = getelementptr inbounds [1024 x double], ptr @A, i64 0, i64 %iv.7\n %v0 = load double, ptr %in0, align 8\n %v1 = load double, ptr %in1, align 8\n %v2 = load double, ptr %in2, align 8\n %v3 = load double, ptr %in3, align 8\n %v4 = load double, ptr %in4, align 8\n %v5 = load double, ptr %in5, align 8\n %v6 = load double, ptr %in6, align 8\n %v7 = load double, ptr %in7, align 8\n %reduce.add.0 = fadd double %v0, %v1\n %reduce.add.1 = fadd double %reduce.add.0, %v2\n %reduce.add.2 = fadd double %reduce.add.1, %v3\n %reduce.add.3 = fadd double %reduce.add.2, %v4\n %reduce.add.4 = fadd double %reduce.add.3, %v5\n %reduce.add.5 = fadd double %reduce.add.4, %v6\n %reduce.add.6 = fadd double %reduce.add.5, %v7\n %reduce.add.6.narrow = fptoui double %reduce.add.6 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.6.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 8\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i16-stride-5.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl,+avx512bw --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i16], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %in0 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.4\n %v0 = load i16, ptr %in0, align 2\n %v1 = load i16, ptr %in1, align 2\n %v2 = load i16, ptr %in2, align 2\n %v3 = load i16, ptr %in3, align 2\n %v4 = load i16, ptr %in4, align 2\n %reduce.add.0 = add i16 %v0, %v1\n %reduce.add.1 = add i16 %reduce.add.0, %v2\n %reduce.add.2 = add i16 %reduce.add.1, %v3\n %reduce.add.3 = add i16 %reduce.add.2, %v4\n %reduce.add.3.narrow = trunc i16 %reduce.add.3 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.3.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 5\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i16-stride-7.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl,+avx512bw --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i16], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %in0 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.5\n %in6 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.6\n %v0 = load i16, ptr %in0, align 2\n %v1 = load i16, ptr %in1, align 2\n %v2 = load i16, ptr %in2, align 2\n %v3 = load i16, ptr %in3, align 2\n %v4 = load i16, ptr %in4, align 2\n %v5 = load i16, ptr %in5, align 2\n %v6 = load i16, ptr %in6, align 2\n %reduce.add.0 = add i16 %v0, %v1\n %reduce.add.1 = add i16 %reduce.add.0, %v2\n %reduce.add.2 = add i16 %reduce.add.1, %v3\n %reduce.add.3 = add i16 %reduce.add.2, %v4\n %reduce.add.4 = add i16 %reduce.add.3, %v5\n %reduce.add.5 = add i16 %reduce.add.4, %v6\n %reduce.add.5.narrow = trunc i16 %reduce.add.5 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.5.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 7\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i16-stride-8.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl,+avx512bw --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i16], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %iv.7 = add nuw nsw i64 %iv, 7\n %in0 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.5\n %in6 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.6\n %in7 = getelementptr inbounds [1024 x i16], ptr @A, i64 0, i64 %iv.7\n %v0 = load i16, ptr %in0, align 2\n %v1 = load i16, ptr %in1, align 2\n %v2 = load i16, ptr %in2, align 2\n %v3 = load i16, ptr %in3, align 2\n %v4 = load i16, ptr %in4, align 2\n %v5 = load i16, ptr %in5, align 2\n %v6 = load i16, ptr %in6, align 2\n %v7 = load i16, ptr %in7, align 2\n %reduce.add.0 = add i16 %v0, %v1\n %reduce.add.1 = add i16 %reduce.add.0, %v2\n %reduce.add.2 = add i16 %reduce.add.1, %v3\n %reduce.add.3 = add i16 %reduce.add.2, %v4\n %reduce.add.4 = add i16 %reduce.add.3, %v5\n %reduce.add.5 = add i16 %reduce.add.4, %v6\n %reduce.add.6 = add i16 %reduce.add.5, %v7\n %reduce.add.6.narrow = trunc i16 %reduce.add.6 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.6.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 8\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i32-stride-4-indices-01uu.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i32], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %in0 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.1\n %v0 = load i32, ptr %in0, align 4\n %v1 = load i32, ptr %in1, align 4\n %reduce.add.0 = add i32 %v0, %v1\n %reduce.add.1 = add i32 %reduce.add.0, 0\n %reduce.add.2 = add i32 %reduce.add.1, 0\n %reduce.add.2.narrow = trunc i32 %reduce.add.2 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.2.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv, 4\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i32-stride-5.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i32], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %in0 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.4\n %v0 = load i32, ptr %in0, align 4\n %v1 = load i32, ptr %in1, align 4\n %v2 = load i32, ptr %in2, align 4\n %v3 = load i32, ptr %in3, align 4\n %v4 = load i32, ptr %in4, align 4\n %reduce.add.0 = add i32 %v0, %v1\n %reduce.add.1 = add i32 %reduce.add.0, %v2\n %reduce.add.2 = add i32 %reduce.add.1, %v3\n %reduce.add.3 = add i32 %reduce.add.2, %v4\n %reduce.add.3.narrow = trunc i32 %reduce.add.3 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.3.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 5\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i32-stride-7.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i32], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %in0 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.5\n %in6 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.6\n %v0 = load i32, ptr %in0, align 4\n %v1 = load i32, ptr %in1, align 4\n %v2 = load i32, ptr %in2, align 4\n %v3 = load i32, ptr %in3, align 4\n %v4 = load i32, ptr %in4, align 4\n %v5 = load i32, ptr %in5, align 4\n %v6 = load i32, ptr %in6, align 4\n %reduce.add.0 = add i32 %v0, %v1\n %reduce.add.1 = add i32 %reduce.add.0, %v2\n %reduce.add.2 = add i32 %reduce.add.1, %v3\n %reduce.add.3 = add i32 %reduce.add.2, %v4\n %reduce.add.4 = add i32 %reduce.add.3, %v5\n %reduce.add.5 = add i32 %reduce.add.4, %v6\n %reduce.add.5.narrow = trunc i32 %reduce.add.5 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.5.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 7\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i32-stride-8.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i32], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %iv.7 = add nuw nsw i64 %iv, 7\n %in0 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.5\n %in6 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.6\n %in7 = getelementptr inbounds [1024 x i32], ptr @A, i64 0, i64 %iv.7\n %v0 = load i32, ptr %in0, align 4\n %v1 = load i32, ptr %in1, align 4\n %v2 = load i32, ptr %in2, align 4\n %v3 = load i32, ptr %in3, align 4\n %v4 = load i32, ptr %in4, align 4\n %v5 = load i32, ptr %in5, align 4\n %v6 = load i32, ptr %in6, align 4\n %v7 = load i32, ptr %in7, align 4\n %reduce.add.0 = add i32 %v0, %v1\n %reduce.add.1 = add i32 %reduce.add.0, %v2\n %reduce.add.2 = add i32 %reduce.add.1, %v3\n %reduce.add.3 = add i32 %reduce.add.2, %v4\n %reduce.add.4 = add i32 %reduce.add.3, %v5\n %reduce.add.5 = add i32 %reduce.add.4, %v6\n %reduce.add.6 = add i32 %reduce.add.5, %v7\n %reduce.add.6.narrow = trunc i32 %reduce.add.6 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.6.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 8\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i64-stride-2.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i64], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %in0 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.1\n %v0 = load i64, ptr %in0, align 8\n %v1 = load i64, ptr %in1, align 8\n %reduce.add.0 = add i64 %v0, %v1\n %reduce.add.0.narrow = trunc i64 %reduce.add.0 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.0.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 2\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i64-stride-3.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i64], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %in0 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.2\n %v0 = load i64, ptr %in0, align 8\n %v1 = load i64, ptr %in1, align 8\n %v2 = load i64, ptr %in2, align 8\n %reduce.add.0 = add i64 %v0, %v1\n %reduce.add.1 = add i64 %reduce.add.0, %v2\n %reduce.add.1.narrow = trunc i64 %reduce.add.1 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.1.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 3\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i64-stride-4.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i64], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %in0 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.3\n %v0 = load i64, ptr %in0, align 8\n %v1 = load i64, ptr %in1, align 8\n %v2 = load i64, ptr %in2, align 8\n %v3 = load i64, ptr %in3, align 8\n %reduce.add.0 = add i64 %v0, %v1\n %reduce.add.1 = add i64 %reduce.add.0, %v2\n %reduce.add.2 = add i64 %reduce.add.1, %v3\n %reduce.add.2.narrow = trunc i64 %reduce.add.2 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.2.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 4\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i64-stride-5.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i64], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %in0 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.4\n %v0 = load i64, ptr %in0, align 8\n %v1 = load i64, ptr %in1, align 8\n %v2 = load i64, ptr %in2, align 8\n %v3 = load i64, ptr %in3, align 8\n %v4 = load i64, ptr %in4, align 8\n %reduce.add.0 = add i64 %v0, %v1\n %reduce.add.1 = add i64 %reduce.add.0, %v2\n %reduce.add.2 = add i64 %reduce.add.1, %v3\n %reduce.add.3 = add i64 %reduce.add.2, %v4\n %reduce.add.3.narrow = trunc i64 %reduce.add.3 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.3.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 5\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i64-stride-6.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i64], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %in0 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.5\n %v0 = load i64, ptr %in0, align 8\n %v1 = load i64, ptr %in1, align 8\n %v2 = load i64, ptr %in2, align 8\n %v3 = load i64, ptr %in3, align 8\n %v4 = load i64, ptr %in4, align 8\n %v5 = load i64, ptr %in5, align 8\n %reduce.add.0 = add i64 %v0, %v1\n %reduce.add.1 = add i64 %reduce.add.0, %v2\n %reduce.add.2 = add i64 %reduce.add.1, %v3\n %reduce.add.3 = add i64 %reduce.add.2, %v4\n %reduce.add.4 = add i64 %reduce.add.3, %v5\n %reduce.add.4.narrow = trunc i64 %reduce.add.4 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.4.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 6\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i64-stride-7.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i64], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %in0 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.5\n %in6 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.6\n %v0 = load i64, ptr %in0, align 8\n %v1 = load i64, ptr %in1, align 8\n %v2 = load i64, ptr %in2, align 8\n %v3 = load i64, ptr %in3, align 8\n %v4 = load i64, ptr %in4, align 8\n %v5 = load i64, ptr %in5, align 8\n %v6 = load i64, ptr %in6, align 8\n %reduce.add.0 = add i64 %v0, %v1\n %reduce.add.1 = add i64 %reduce.add.0, %v2\n %reduce.add.2 = add i64 %reduce.add.1, %v3\n %reduce.add.3 = add i64 %reduce.add.2, %v4\n %reduce.add.4 = add i64 %reduce.add.3, %v5\n %reduce.add.5 = add i64 %reduce.add.4, %v6\n %reduce.add.5.narrow = trunc i64 %reduce.add.5 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.5.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 7\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i64-stride-8.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i64], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %iv.7 = add nuw nsw i64 %iv, 7\n %in0 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.5\n %in6 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.6\n %in7 = getelementptr inbounds [1024 x i64], ptr @A, i64 0, i64 %iv.7\n %v0 = load i64, ptr %in0, align 8\n %v1 = load i64, ptr %in1, align 8\n %v2 = load i64, ptr %in2, align 8\n %v3 = load i64, ptr %in3, align 8\n %v4 = load i64, ptr %in4, align 8\n %v5 = load i64, ptr %in5, align 8\n %v6 = load i64, ptr %in6, align 8\n %v7 = load i64, ptr %in7, align 8\n %reduce.add.0 = add i64 %v0, %v1\n %reduce.add.1 = add i64 %reduce.add.0, %v2\n %reduce.add.2 = add i64 %reduce.add.1, %v3\n %reduce.add.3 = add i64 %reduce.add.2, %v4\n %reduce.add.4 = add i64 %reduce.add.3, %v5\n %reduce.add.5 = add i64 %reduce.add.4, %v6\n %reduce.add.6 = add i64 %reduce.add.5, %v7\n %reduce.add.6.narrow = trunc i64 %reduce.add.6 to i8\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.6.narrow, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 8\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i8-stride-5.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl,+avx512bw --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i8], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %in0 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.4\n %v0 = load i8, ptr %in0, align 1\n %v1 = load i8, ptr %in1, align 1\n %v2 = load i8, ptr %in2, align 1\n %v3 = load i8, ptr %in3, align 1\n %v4 = load i8, ptr %in4, align 1\n %reduce.add.0 = add i8 %v0, %v1\n %reduce.add.1 = add i8 %reduce.add.0, %v2\n %reduce.add.2 = add i8 %reduce.add.1, %v3\n %reduce.add.3 = add i8 %reduce.add.2, %v4\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.3, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 5\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i8-stride-7.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl,+avx512bw --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i8], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %in0 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.5\n %in6 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.6\n %v0 = load i8, ptr %in0, align 1\n %v1 = load i8, ptr %in1, align 1\n %v2 = load i8, ptr %in2, align 1\n %v3 = load i8, ptr %in3, align 1\n %v4 = load i8, ptr %in4, align 1\n %v5 = load i8, ptr %in5, align 1\n %v6 = load i8, ptr %in6, align 1\n %reduce.add.0 = add i8 %v0, %v1\n %reduce.add.1 = add i8 %reduce.add.0, %v2\n %reduce.add.2 = add i8 %reduce.add.1, %v3\n %reduce.add.3 = add i8 %reduce.add.2, %v4\n %reduce.add.4 = add i8 %reduce.add.3, %v5\n %reduce.add.5 = add i8 %reduce.add.4, %v6\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.5, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 7\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-load-i8-stride-8.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl,+avx512bw --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i8], align 128\n@B = external global [1024 x i8], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %iv.7 = add nuw nsw i64 %iv, 7\n %in0 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.0\n %in1 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.1\n %in2 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.2\n %in3 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.3\n %in4 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.4\n %in5 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.5\n %in6 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.6\n %in7 = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.7\n %v0 = load i8, ptr %in0, align 1\n %v1 = load i8, ptr %in1, align 1\n %v2 = load i8, ptr %in2, align 1\n %v3 = load i8, ptr %in3, align 1\n %v4 = load i8, ptr %in4, align 1\n %v5 = load i8, ptr %in5, align 1\n %v6 = load i8, ptr %in6, align 1\n %v7 = load i8, ptr %in7, align 1\n %reduce.add.0 = add i8 %v0, %v1\n %reduce.add.1 = add i8 %reduce.add.0, %v2\n %reduce.add.2 = add i8 %reduce.add.1, %v3\n %reduce.add.3 = add i8 %reduce.add.2, %v4\n %reduce.add.4 = add i8 %reduce.add.3, %v5\n %reduce.add.5 = add i8 %reduce.add.4, %v6\n %reduce.add.6 = add i8 %reduce.add.5, %v7\n %out = getelementptr inbounds [1024 x i8], ptr @B, i64 0, i64 %iv.0\n store i8 %reduce.add.6, ptr %out, align 1\n %iv.next = add nuw nsw i64 %iv.0, 8\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-store-f64-stride-8.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i8], align 128\n@B = external global [1024 x double], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %iv.7 = add nuw nsw i64 %iv, 7\n %in = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.0\n %v.narrow = load i8, ptr %in, align 1\n %v = uitofp i8 %v.narrow to double\n %v0 = fadd double %v, 0.000000e+00\n %v1 = fadd double %v, 1.000000e+00\n %v2 = fadd double %v, 2.000000e+00\n %v3 = fadd double %v, 3.000000e+00\n %v4 = fadd double %v, 4.000000e+00\n %v5 = fadd double %v, 5.000000e+00\n %v6 = fadd double %v, 6.000000e+00\n %v7 = fadd double %v, 7.000000e+00\n %out0 = getelementptr inbounds [1024 x double], ptr @B, i64 0, i64 %iv.0\n %out1 = getelementptr inbounds [1024 x double], ptr @B, i64 0, i64 %iv.1\n %out2 = getelementptr inbounds [1024 x double], ptr @B, i64 0, i64 %iv.2\n %out3 = getelementptr inbounds [1024 x double], ptr @B, i64 0, i64 %iv.3\n %out4 = getelementptr inbounds [1024 x double], ptr @B, i64 0, i64 %iv.4\n %out5 = getelementptr inbounds [1024 x double], ptr @B, i64 0, i64 %iv.5\n %out6 = getelementptr inbounds [1024 x double], ptr @B, i64 0, i64 %iv.6\n %out7 = getelementptr inbounds [1024 x double], ptr @B, i64 0, i64 %iv.7\n store double %v0, ptr %out0, align 8\n store double %v1, ptr %out1, align 8\n store double %v2, ptr %out2, align 8\n store double %v3, ptr %out3, align 8\n store double %v4, ptr %out4, align 8\n store double %v5, ptr %out5, align 8\n store double %v6, ptr %out6, align 8\n store double %v7, ptr %out7, align 8\n %iv.next = add nuw nsw i64 %iv.0, 8\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/interleaved-store-i64-stride-8.ll",
"commands": [
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512vl --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\n@A = external global [1024 x i8], align 128\n@B = external global [1024 x i64], align 128\n\ndefine void @test() {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %iv.0 = add nuw nsw i64 %iv, 0\n %iv.1 = add nuw nsw i64 %iv, 1\n %iv.2 = add nuw nsw i64 %iv, 2\n %iv.3 = add nuw nsw i64 %iv, 3\n %iv.4 = add nuw nsw i64 %iv, 4\n %iv.5 = add nuw nsw i64 %iv, 5\n %iv.6 = add nuw nsw i64 %iv, 6\n %iv.7 = add nuw nsw i64 %iv, 7\n %in = getelementptr inbounds [1024 x i8], ptr @A, i64 0, i64 %iv.0\n %v.narrow = load i8, ptr %in, align 1\n %v = zext i8 %v.narrow to i64\n %v0 = add i64 %v, 0\n %v1 = add i64 %v, 1\n %v2 = add i64 %v, 2\n %v3 = add i64 %v, 3\n %v4 = add i64 %v, 4\n %v5 = add i64 %v, 5\n %v6 = add i64 %v, 6\n %v7 = add i64 %v, 7\n %out0 = getelementptr inbounds [1024 x i64], ptr @B, i64 0, i64 %iv.0\n %out1 = getelementptr inbounds [1024 x i64], ptr @B, i64 0, i64 %iv.1\n %out2 = getelementptr inbounds [1024 x i64], ptr @B, i64 0, i64 %iv.2\n %out3 = getelementptr inbounds [1024 x i64], ptr @B, i64 0, i64 %iv.3\n %out4 = getelementptr inbounds [1024 x i64], ptr @B, i64 0, i64 %iv.4\n %out5 = getelementptr inbounds [1024 x i64], ptr @B, i64 0, i64 %iv.5\n %out6 = getelementptr inbounds [1024 x i64], ptr @B, i64 0, i64 %iv.6\n %out7 = getelementptr inbounds [1024 x i64], ptr @B, i64 0, i64 %iv.7\n store i64 %v0, ptr %out0, align 8\n store i64 %v1, ptr %out1, align 8\n store i64 %v2, ptr %out2, align 8\n store i64 %v3, ptr %out3, align 8\n store i64 %v4, ptr %out4, align 8\n store i64 %v5, ptr %out5, align 8\n store i64 %v6, ptr %out6, align 8\n store i64 %v7, ptr %out7, align 8\n %iv.next = add nuw nsw i64 %iv.0, 8\n %cmp = icmp ult i64 %iv.next, 1024\n br i1 %cmp, label %for.body, label %for.cond.cleanup\n\nfor.cond.cleanup: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Analysis/CostModel/X86/masked-interleaved-store-i16.ll",
"commands": [
"opt -passes=loop-vectorize -enable-interleaved-mem-accesses -prefer-predicate-over-epilogue=predicate-dont-vectorize -S -mcpu=skx --debug-only=loop-vectorize < %s 2>&1",
"opt -passes=loop-vectorize -enable-interleaved-mem-accesses -enable-masked-interleaved-mem-accesses -prefer-predicate-over-epilogue=predicate-dont-vectorize -S -mcpu=skx --debug-only=loop-vectorize < %s 2>&1"
],
"tests": [
{
"test_name": "test2",
"test_body": "target datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @test2(ptr noalias nocapture %points, i32 %numPoints, ptr noalias nocapture readonly %x, ptr noalias nocapture readonly %y) {\nentry:\n %cmp15 = icmp sgt i32 %numPoints, 0\n br i1 %cmp15, label %for.body.preheader, label %for.end\n\nfor.body.preheader: ; preds = %entry\n %wide.trip.count = zext i32 %numPoints to i64\n br label %for.body\n\nfor.body: ; preds = %for.body, %for.body.preheader\n %indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]\n %arrayidx = getelementptr inbounds i16, ptr %x, i64 %indvars.iv\n %0 = load i16, ptr %arrayidx, align 2\n %1 = shl nsw i64 %indvars.iv, 2\n %arrayidx2 = getelementptr inbounds i16, ptr %points, i64 %1\n store i16 %0, ptr %arrayidx2, align 2\n %arrayidx4 = getelementptr inbounds i16, ptr %y, i64 %indvars.iv\n %2 = load i16, ptr %arrayidx4, align 2\n %3 = or disjoint i64 %1, 1\n %arrayidx7 = getelementptr inbounds i16, ptr %points, i64 %3\n store i16 %2, ptr %arrayidx7, align 2\n %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1\n %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count\n br i1 %exitcond.not, label %for.end.loopexit, label %for.body\n\nfor.end.loopexit: ; preds = %for.body\n br label %for.end\n\nfor.end: ; preds = %for.end.loopexit, %entry\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test1",
"test_body": "target datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @test1(ptr noalias nocapture %points, ptr noalias nocapture readonly %x, ptr noalias nocapture readonly %y) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]\n %arrayidx = getelementptr inbounds i16, ptr %x, i64 %indvars.iv\n %0 = load i16, ptr %arrayidx, align 2\n %1 = shl nuw nsw i64 %indvars.iv, 2\n %arrayidx2 = getelementptr inbounds i16, ptr %points, i64 %1\n store i16 %0, ptr %arrayidx2, align 2\n %arrayidx4 = getelementptr inbounds i16, ptr %y, i64 %indvars.iv\n %2 = load i16, ptr %arrayidx4, align 2\n %3 = or disjoint i64 %1, 1\n %arrayidx7 = getelementptr inbounds i16, ptr %points, i64 %3\n store i16 %2, ptr %arrayidx7, align 2\n %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1\n %exitcond.not = icmp eq i64 %indvars.iv.next, 1024\n br i1 %exitcond.not, label %for.end, label %for.body\n\nfor.end: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/interleaved-vs-scalar.ll",
"commands": [
"opt < %s -force-vector-width=2 -force-vector-interleave=1 -passes=loop-vectorize -S --debug-only=loop-vectorize 2>&1"
],
"tests": [
{
"test_name": "test",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64--linux-gnu\"\n\n%pair = type { i8, i8 }\n\ndefine void @test(ptr %p, ptr %q, i64 %n) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr %pair, ptr %p, i64 %i, i32 0\n %tmp1 = load i8, ptr %tmp0, align 1\n %tmp2 = getelementptr %pair, ptr %p, i64 %i, i32 1\n %tmp3 = load i8, ptr %tmp2, align 1\n %add = add i8 %tmp1, %tmp3\n %qi = getelementptr i8, ptr %q, i64 %i\n store i8 %add, ptr %qi, align 1\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp eq i64 %i.next, %n\n br i1 %cond, label %for.end, label %for.body\n\nfor.end: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/interleaved_cost.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-width=2 -debug-only=loop-vectorize -disable-output < %s 2>&1",
"opt -passes=loop-vectorize -force-vector-width=4 -debug-only=loop-vectorize -disable-output < %s 2>&1",
"opt -passes=loop-vectorize -force-vector-width=8 -debug-only=loop-vectorize -disable-output < %s 2>&1",
"opt -passes=loop-vectorize -force-vector-width=16 -debug-only=loop-vectorize -disable-output < %s 2>&1"
],
"tests": [
{
"test_name": "i8_factor_2",
"test_body": "target datalayout = \"e-m:e-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64\"\n\n%i8.2 = type { i8, i8 }\n\ndefine void @i8_factor_2(ptr %data, i64 %n) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i8.2, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i8.2, ptr %data, i64 %i, i32 1\n %tmp2 = load i8, ptr %tmp0, align 1\n %tmp3 = load i8, ptr %tmp1, align 1\n store i8 %tmp2, ptr %tmp0, align 1\n store i8 %tmp3, ptr %tmp1, align 1\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "i16_factor_2",
"test_body": "target datalayout = \"e-m:e-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64\"\n\n%i16.2 = type { i16, i16 }\n\ndefine void @i16_factor_2(ptr %data, i64 %n) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i16.2, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i16.2, ptr %data, i64 %i, i32 1\n %tmp2 = load i16, ptr %tmp0, align 2\n %tmp3 = load i16, ptr %tmp1, align 2\n store i16 %tmp2, ptr %tmp0, align 2\n store i16 %tmp3, ptr %tmp1, align 2\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "i32_factor_2",
"test_body": "target datalayout = \"e-m:e-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64\"\n\n%i32.2 = type { i32, i32 }\n\ndefine void @i32_factor_2(ptr %data, i64 %n) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i32.2, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i32.2, ptr %data, i64 %i, i32 1\n %tmp2 = load i32, ptr %tmp0, align 4\n %tmp3 = load i32, ptr %tmp1, align 4\n store i32 %tmp2, ptr %tmp0, align 4\n store i32 %tmp3, ptr %tmp1, align 4\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "i64_factor_2",
"test_body": "target datalayout = \"e-m:e-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64\"\n\n%i64.2 = type { i64, i64 }\n\ndefine void @i64_factor_2(ptr %data, i64 %n) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i64.2, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i64.2, ptr %data, i64 %i, i32 1\n %tmp2 = load i64, ptr %tmp0, align 8\n %tmp3 = load i64, ptr %tmp1, align 8\n store i64 %tmp2, ptr %tmp0, align 8\n store i64 %tmp3, ptr %tmp1, align 8\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "i64_factor_8",
"test_body": "target datalayout = \"e-m:e-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64\"\n\n%i64.8 = type { i64, i64, i64, i64, i64, i64, i64, i64 }\n\ndefine void @i64_factor_8(ptr %data, i64 %n) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i64.8, ptr %data, i64 %i, i32 2\n %tmp1 = getelementptr inbounds %i64.8, ptr %data, i64 %i, i32 6\n %tmp2 = load i64, ptr %tmp0, align 8\n %tmp3 = load i64, ptr %tmp1, align 8\n store i64 %tmp2, ptr %tmp0, align 8\n store i64 %tmp3, ptr %tmp1, align 8\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/ARM/mve-interleaved-cost.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-width=2 -debug-only=loop-vectorize -disable-output < %s 2>&1",
"opt -passes=loop-vectorize -force-vector-width=4 -debug-only=loop-vectorize -disable-output < %s 2>&1",
"opt -passes=loop-vectorize -force-vector-width=8 -debug-only=loop-vectorize -disable-output < %s 2>&1",
"opt -passes=loop-vectorize -force-vector-width=16 -debug-only=loop-vectorize -disable-output < %s 2>&1"
],
"tests": [
{
"test_name": "i16_factor_3",
"test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%i16.3 = type { i16, i16, i16 }\n\ndefine void @i16_factor_3(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i16.3, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i16.3, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %i16.3, ptr %data, i64 %i, i32 2\n %tmp3 = load i16, ptr %tmp0, align 2\n %tmp4 = load i16, ptr %tmp1, align 2\n %tmp5 = load i16, ptr %tmp2, align 2\n store i16 %tmp3, ptr %tmp0, align 2\n store i16 %tmp4, ptr %tmp1, align 2\n store i16 %tmp5, ptr %tmp2, align 2\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "f16_factor_2",
"test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%f16.2 = type { half, half }\n\ndefine void @f16_factor_2(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %f16.2, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %f16.2, ptr %data, i64 %i, i32 1\n %tmp2 = load half, ptr %tmp0, align 2\n %tmp3 = load half, ptr %tmp1, align 2\n store half %tmp2, ptr %tmp0, align 2\n store half %tmp3, ptr %tmp1, align 2\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "i32_factor_2",
"test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%i32.2 = type { i32, i32 }\n\ndefine void @i32_factor_2(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i32.2, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i32.2, ptr %data, i64 %i, i32 1\n %tmp2 = load i32, ptr %tmp0, align 4\n %tmp3 = load i32, ptr %tmp1, align 4\n store i32 %tmp2, ptr %tmp0, align 4\n store i32 %tmp3, ptr %tmp1, align 4\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "i64_factor_4",
"test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%i64.4 = type { i64, i64, i64, i64 }\n\ndefine void @i64_factor_4(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i64.4, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i64.4, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %i64.4, ptr %data, i64 %i, i32 2\n %tmp3 = getelementptr inbounds %i64.4, ptr %data, i64 %i, i32 3\n %tmp4 = load i64, ptr %tmp0, align 8\n %tmp5 = load i64, ptr %tmp1, align 8\n %tmp6 = load i64, ptr %tmp2, align 8\n %tmp7 = load i64, ptr %tmp3, align 8\n store i64 %tmp4, ptr %tmp0, align 8\n store i64 %tmp5, ptr %tmp1, align 8\n store i64 %tmp6, ptr %tmp2, align 8\n store i64 %tmp7, ptr %tmp3, align 8\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "f32_factor_3",
"test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%f32.3 = type { float, float, float }\n\ndefine void @f32_factor_3(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %f32.3, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %f32.3, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %f32.3, ptr %data, i64 %i, i32 2\n %tmp3 = load float, ptr %tmp0, align 4\n %tmp4 = load float, ptr %tmp1, align 4\n %tmp5 = load float, ptr %tmp2, align 4\n store float %tmp3, ptr %tmp0, align 4\n store float %tmp4, ptr %tmp1, align 4\n store float %tmp5, ptr %tmp2, align 4\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "i64_factor_3",
"test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%i64.3 = type { i64, i64, i64 }\n\ndefine void @i64_factor_3(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i64.3, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i64.3, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %i64.3, ptr %data, i64 %i, i32 2\n %tmp3 = load i64, ptr %tmp0, align 8\n %tmp4 = load i64, ptr %tmp1, align 8\n %tmp5 = load i64, ptr %tmp2, align 8\n store i64 %tmp3, ptr %tmp0, align 8\n store i64 %tmp4, ptr %tmp1, align 8\n store i64 %tmp5, ptr %tmp2, align 8\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "f16_factor_3",
"test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%f16.3 = type { half, half, half }\n\ndefine void @f16_factor_3(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %f16.3, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %f16.3, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %f16.3, ptr %data, i64 %i, i32 2\n %tmp3 = load half, ptr %tmp0, align 2\n %tmp4 = load half, ptr %tmp1, align 2\n %tmp5 = load half, ptr %tmp2, align 2\n store half %tmp3, ptr %tmp0, align 2\n store half %tmp4, ptr %tmp1, align 2\n store half %tmp5, ptr %tmp2, align 2\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "i8_factor_3",
"test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%i8.3 = type { i8, i8, i8 }\n\ndefine void @i8_factor_3(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i8.3, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i8.3, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %i8.3, ptr %data, i64 %i, i32 2\n %tmp3 = load i8, ptr %tmp0, align 1\n %tmp4 = load i8, ptr %tmp1, align 1\n %tmp5 = load i8, ptr %tmp2, align 1\n store i8 %tmp3, ptr %tmp0, align 1\n store i8 %tmp4, ptr %tmp1, align 1\n store i8 %tmp5, ptr %tmp2, align 1\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "f32_factor_2",
"test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%f32.2 = type { float, float }\n\ndefine void @f32_factor_2(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %f32.2, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %f32.2, ptr %data, i64 %i, i32 1\n %tmp2 = load float, ptr %tmp0, align 4\n %tmp3 = load float, ptr %tmp1, align 4\n store float %tmp2, ptr %tmp0, align 4\n store float %tmp3, ptr %tmp1, align 4\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "i8_factor_4",
"test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%i8.4 = type { i8, i8, i8, i8 }\n\ndefine void @i8_factor_4(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i8.4, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i8.4, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %i8.4, ptr %data, i64 %i, i32 2\n %tmp3 = getelementptr inbounds %i8.4, ptr %data, i64 %i, i32 3\n %tmp4 = load i8, ptr %tmp0, align 1\n %tmp5 = load i8, ptr %tmp1, align 1\n %tmp6 = load i8, ptr %tmp2, align 1\n %tmp7 = load i8, ptr %tmp3, align 1\n store i8 %tmp4, ptr %tmp0, align 1\n store i8 %tmp5, ptr %tmp1, align 1\n store i8 %tmp6, ptr %tmp2, align 1\n store i8 %tmp7, ptr %tmp3, align 1\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "i16_factor_2",
"test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%i16.2 = type { i16, i16 }\n\ndefine void @i16_factor_2(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i16.2, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i16.2, ptr %data, i64 %i, i32 1\n %tmp2 = load i16, ptr %tmp0, align 2\n %tmp3 = load i16, ptr %tmp1, align 2\n store i16 %tmp2, ptr %tmp0, align 2\n store i16 %tmp3, ptr %tmp1, align 2\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "i16_factor_4",
"test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%i16.4 = type { i16, i16, i16, i16 }\n\ndefine void @i16_factor_4(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i16.4, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i16.4, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %i16.4, ptr %data, i64 %i, i32 2\n %tmp3 = getelementptr inbounds %i16.4, ptr %data, i64 %i, i32 3\n %tmp4 = load i16, ptr %tmp0, align 2\n %tmp5 = load i16, ptr %tmp1, align 2\n %tmp6 = load i16, ptr %tmp2, align 2\n %tmp7 = load i16, ptr %tmp3, align 2\n store i16 %tmp4, ptr %tmp0, align 2\n store i16 %tmp5, ptr %tmp1, align 2\n store i16 %tmp6, ptr %tmp2, align 2\n store i16 %tmp7, ptr %tmp3, align 2\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "f64_factor_3",
"test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%f64.3 = type { double, double, double }\n\ndefine void @f64_factor_3(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %f64.3, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %f64.3, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %f64.3, ptr %data, i64 %i, i32 2\n %tmp3 = load double, ptr %tmp0, align 8\n %tmp4 = load double, ptr %tmp1, align 8\n %tmp5 = load double, ptr %tmp2, align 8\n store double %tmp3, ptr %tmp0, align 8\n store double %tmp4, ptr %tmp1, align 8\n store double %tmp5, ptr %tmp2, align 8\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "i8_factor_2",
"test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%i8.2 = type { i8, i8 }\n\ndefine void @i8_factor_2(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i8.2, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i8.2, ptr %data, i64 %i, i32 1\n %tmp2 = load i8, ptr %tmp0, align 1\n %tmp3 = load i8, ptr %tmp1, align 1\n store i8 %tmp2, ptr %tmp0, align 1\n store i8 %tmp3, ptr %tmp1, align 1\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "i32_factor_4",
"test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%i32.4 = type { i32, i32, i32, i32 }\n\ndefine void @i32_factor_4(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i32.4, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i32.4, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %i32.4, ptr %data, i64 %i, i32 2\n %tmp3 = getelementptr inbounds %i32.4, ptr %data, i64 %i, i32 3\n %tmp4 = load i32, ptr %tmp0, align 4\n %tmp5 = load i32, ptr %tmp1, align 4\n %tmp6 = load i32, ptr %tmp2, align 4\n %tmp7 = load i32, ptr %tmp3, align 4\n store i32 %tmp4, ptr %tmp0, align 4\n store i32 %tmp5, ptr %tmp1, align 4\n store i32 %tmp6, ptr %tmp2, align 4\n store i32 %tmp7, ptr %tmp3, align 4\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "i32_factor_3",
"test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%i32.3 = type { i32, i32, i32 }\n\ndefine void @i32_factor_3(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i32.3, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i32.3, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %i32.3, ptr %data, i64 %i, i32 2\n %tmp3 = load i32, ptr %tmp0, align 4\n %tmp4 = load i32, ptr %tmp1, align 4\n %tmp5 = load i32, ptr %tmp2, align 4\n store i32 %tmp3, ptr %tmp0, align 4\n store i32 %tmp4, ptr %tmp1, align 4\n store i32 %tmp5, ptr %tmp2, align 4\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "f64_factor_2",
"test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%f64.2 = type { double, double }\n\ndefine void @f64_factor_2(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %f64.2, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %f64.2, ptr %data, i64 %i, i32 1\n %tmp2 = load double, ptr %tmp0, align 8\n %tmp3 = load double, ptr %tmp1, align 8\n store double %tmp2, ptr %tmp0, align 8\n store double %tmp3, ptr %tmp1, align 8\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "f16_factor_4",
"test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%f16.4 = type { half, half, half, half }\n\ndefine void @f16_factor_4(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %f16.4, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %f16.4, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %f16.4, ptr %data, i64 %i, i32 2\n %tmp3 = getelementptr inbounds %f16.4, ptr %data, i64 %i, i32 3\n %tmp4 = load half, ptr %tmp0, align 2\n %tmp5 = load half, ptr %tmp1, align 2\n %tmp6 = load half, ptr %tmp2, align 2\n %tmp7 = load half, ptr %tmp3, align 2\n store half %tmp4, ptr %tmp0, align 2\n store half %tmp5, ptr %tmp1, align 2\n store half %tmp6, ptr %tmp2, align 2\n store half %tmp7, ptr %tmp3, align 2\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "i64_factor_2",
"test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%i64.2 = type { i64, i64 }\n\ndefine void @i64_factor_2(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %i64.2, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %i64.2, ptr %data, i64 %i, i32 1\n %tmp2 = load i64, ptr %tmp0, align 8\n %tmp3 = load i64, ptr %tmp1, align 8\n store i64 %tmp2, ptr %tmp0, align 8\n store i64 %tmp3, ptr %tmp1, align 8\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "f64_factor_4",
"test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%f64.4 = type { double, double, double, double }\n\ndefine void @f64_factor_4(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %f64.4, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %f64.4, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %f64.4, ptr %data, i64 %i, i32 2\n %tmp3 = getelementptr inbounds %f64.4, ptr %data, i64 %i, i32 3\n %tmp4 = load double, ptr %tmp0, align 8\n %tmp5 = load double, ptr %tmp1, align 8\n %tmp6 = load double, ptr %tmp2, align 8\n %tmp7 = load double, ptr %tmp3, align 8\n store double %tmp4, ptr %tmp0, align 8\n store double %tmp5, ptr %tmp1, align 8\n store double %tmp6, ptr %tmp2, align 8\n store double %tmp7, ptr %tmp3, align 8\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "f32_factor_4",
"test_body": "target datalayout = \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\"\ntarget triple = \"thumbv8.1m.main-none-eabi\"\n\n%f32.4 = type { float, float, float, float }\n\ndefine void @f32_factor_4(ptr %data, i64 %n) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]\n %tmp0 = getelementptr inbounds %f32.4, ptr %data, i64 %i, i32 0\n %tmp1 = getelementptr inbounds %f32.4, ptr %data, i64 %i, i32 1\n %tmp2 = getelementptr inbounds %f32.4, ptr %data, i64 %i, i32 2\n %tmp3 = getelementptr inbounds %f32.4, ptr %data, i64 %i, i32 3\n %tmp4 = load float, ptr %tmp0, align 4\n %tmp5 = load float, ptr %tmp1, align 4\n %tmp6 = load float, ptr %tmp2, align 4\n %tmp7 = load float, ptr %tmp3, align 4\n store float %tmp4, ptr %tmp0, align 4\n store float %tmp5, ptr %tmp1, align 4\n store float %tmp6, ptr %tmp2, align 4\n store float %tmp7, ptr %tmp3, align 4\n %i.next = add nuw nsw i64 %i, 1\n %cond = icmp slt i64 %i.next, %n\n br i1 %cond, label %for.body, label %for.end\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+mve.fp\" }\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"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) #1 {\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) }\nattributes #1 = { \"target-features\"=\"+64bit,+v\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "gather_interleave_group_with_dead_insert_pos",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine void @gather_interleave_group_with_dead_insert_pos(i64 %N, ptr noalias %src, ptr noalias %dst) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]\n %gep.src.0 = getelementptr i8, ptr %src, i64 %iv\n %l.dead = load i8, ptr %gep.src.0, align 1\n %iv.1 = add i64 %iv, 1\n %gep.src.1 = getelementptr i8, ptr %src, i64 %iv.1\n %l.1 = load i8, ptr %gep.src.1, align 1\n %ext = zext i8 %l.1 to i32\n %gep.dst = getelementptr i32, ptr %dst, i64 %iv\n store i32 %ext, ptr %gep.dst, align 4\n %iv.next = add nsw i64 %iv, 4\n %ec = icmp slt i64 %iv, %N\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
},
{
"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": "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
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/SystemZ/mem-interleaving-costs-03.ll",
"commands": [
"opt -mtriple=s390x-unknown-linux -mcpu=z16 -passes=loop-vectorize -debug-only=loop-vectorize -force-vector-width=4 -disable-output < %s 2>&1"
],
"tests": [
{
"test_name": "fun",
"test_body": "define noundef i32 @fun(i32 %argc, ptr nocapture readnone %argv) {\nentry:\n %l_4774.i = alloca [4 x [2 x i128]], align 8\n call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %l_4774.i)\n br label %for.cond4.preheader.i\n\nfor.cond4.preheader.i: ; preds = %for.cond4.preheader.i, %entry\n %indvars.iv8.i = phi i64 [ 0, %entry ], [ %indvars.iv.next9.i, %for.cond4.preheader.i ]\n %arrayidx10.i = getelementptr inbounds [4 x [2 x i128]], ptr %l_4774.i, i64 0, i64 %indvars.iv8.i, i64 0\n store i128 8721036757475490113, ptr %arrayidx10.i, align 8\n %arrayidx10.i.c = getelementptr inbounds [4 x [2 x i128]], ptr %l_4774.i, i64 0, i64 %indvars.iv8.i, i64 1\n store i128 8721036757475490113, ptr %arrayidx10.i.c, align 8\n %indvars.iv.next9.i = add nuw nsw i64 %indvars.iv8.i, 1\n %exitcond.not.i = icmp eq i64 %indvars.iv.next9.i, 4\n br i1 %exitcond.not.i, label %func_1.exit, label %for.cond4.preheader.i\n\nfunc_1.exit: ; preds = %for.cond4.preheader.i\n %arrayidx195.i = getelementptr inbounds [4 x [2 x i128]], ptr %l_4774.i, i64 0, i64 1\n %0 = load i128, ptr %arrayidx195.i, align 8\n %cmp200.i = icmp ne i128 %0, 0\n %conv202.i = zext i1 %cmp200.i to i64\n %call203.i = tail call i64 @safe_sub_func_int64_t_s_s(i64 noundef %conv202.i, i64 noundef 9139899272418802852)\n call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %l_4774.i)\n br label %for.cond\n\nfor.cond: ; preds = %for.cond, %func_1.exit\n br label %for.cond\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)\ndeclare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)\ndeclare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0\n\ndeclare dso_local i64 @safe_sub_func_int64_t_s_s(i64, i64)\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[VPlan] Assertion \" VPlan cost model and legacy cost model disagreed\"' failed.",
"body": "Tested using: 15106c26662a WITH commits from #107894 cherry-picked on top.\r\n```\r\n> git log --oneline\r\n2bfba9bc7d37 (HEAD -> main) !fixup add TODO\r\n28acd6af75ff Add initial loop-invariant code motion transform.\r\n15106c26662a (origin/main, origin/HEAD) [flang][runtime] Fix odd \"invalid descriptor\" runtime crash\r\n```\r\nTestcase:\r\n```c\r\nchar a;\r\nextern int b[];\r\nshort c;\r\nchar d[1];\r\nvoid checksum() {\r\n for (long e = 0; e < 3;)\r\n for (long f = 0; e < 3; e = 709692)\r\n for (; f < c; f += 4) {\r\n a = d[f];\r\n b[f] = d[f - 1];\r\n }\r\n}\r\n```\r\n`clang -march=rv64gcv -O3 red.c`\r\n\r\nTestcase:\r\n```llvm ir\r\n; ModuleID = 'reduced.bc'\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine void @g(i64 %conv) #0 {\r\nentry:\r\n br label %for.body8.us23\r\n\r\nfor.body8.us23: ; preds = %for.body8.us23, %entry\r\n %f.121.us24 = phi i64 [ %add.us30, %for.body8.us23 ], [ 0, %entry ]\r\n %arrayidx.us25 = getelementptr [1 x i8], ptr null, i64 0, i64 %f.121.us24\r\n %0 = load i8, ptr %arrayidx.us25, align 1\r\n %sub.us26 = add i64 %f.121.us24, 1\r\n %arrayidx9.us27 = getelementptr [1 x i8], ptr null, i64 0, i64 %sub.us26\r\n %1 = load i8, ptr %arrayidx9.us27, align 1\r\n %conv10.us28 = zext i8 %1 to i32\r\n %arrayidx11.us29 = getelementptr [0 x i32], ptr null, i64 0, i64 %f.121.us24\r\n store i32 %conv10.us28, ptr null, align 4\r\n %add.us30 = add nsw i64 %f.121.us24, 4\r\n %cmp6.us31 = icmp slt i64 %f.121.us24, %conv\r\n br i1 %cmp6.us31, label %for.body8.us23, label %for.cond.cleanup.split.us\r\n\r\nfor.cond.cleanup.split.us: ; preds = %for.body8.us23\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-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:7394: 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 \"g\"\r\n #0 0x00005fabff5a9d80 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x3072d80)\r\n #1 0x00005fabff5a718f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x307018f)\r\n #2 0x00005fabff5a72e5 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007fe3d2042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007fe3d20969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007fe3d20969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007fe3d20969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x00007fe3d2042476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007fe3d20287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x00007fe3d202871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x00007fe3d2039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x00005fabfe550a26 llvm::LoopVectorizationPlanner::computeBestVF() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2019a26)\r\n#12 0x00005fabfe5678fb llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20308fb)\r\n#13 0x00005fabfe56a911 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2033911)\r\n#14 0x00005fabfe56af87 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2033f87)\r\n#15 0x00005fabfd3adf96 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+0xe76f96)\r\n#16 0x00005fabff3b51ef 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+0x2e7e1ef)\r\n#17 0x00005fabfd3b11c6 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+0xe7a1c6)\r\n#18 0x00005fabff3b357b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e7c57b)\r\n#19 0x00005fabfd3ad376 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+0xe76376)\r\n#20 0x00005fabff3b40dd 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+0x2e7d0dd)\r\n#21 0x00005fabfcbd49db 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+0x69d9db)\r\n#22 0x00005fabfcbc6701 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x68f701)\r\n#23 0x00007fe3d2029d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#24 0x00007fe3d2029e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#25 0x00007fe3d2029e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#26 0x00005fabfcbbcc65 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x685c65)\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/TTchhsf9h\r\n\r\nFound via fuzzer\r\n\r\nRelated/prior issue: https://github.com/llvm/llvm-project/issues/107473\r\n\r\ncc @fhahn",
"author": "patrick-rivos",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
151699
|
https://github.com/llvm/llvm-project/issues/151699
|
crash
|
f72c8dce1586d27e4723259166a21f01499dda60
| 2025-08-01T13:34:39 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "3ee8d047109ea4bb479095f4b153c2120a8d726c",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
1238,
1243
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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": [
"getMatchingMainOpOrAltOp"
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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 3ee8d047109ea4bb479095f4b153c2120a8d726c
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Mon Aug 4 08:02:37 2025 -0700
[SLP] Fix a check for main/alternate interchanged instruction
If the instruction is checked for matching the main instruction, need to
check if the opcode of the main instruction is compatible with the
operands of the instruction. If they are not, need to check the
alternate instruction and its operands for compatibility and return
alternate instruction as a match.
Fixes #151699
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 0ca25bf89103..5a956fb733c2 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -1238,6 +1238,12 @@ public:
BinOpSameOpcodeHelper Converter(MainOp);
if (!Converter.add(I) || !Converter.add(MainOp))
return nullptr;
+ if (!Converter.hasCandidateOpcode(MainOp->getOpcode()) && isAltShuffle()) {
+ BinOpSameOpcodeHelper AltConverter(AltOp);
+ if (AltConverter.add(I) && AltConverter.add(AltOp) &&
+ AltConverter.hasCandidateOpcode(AltOp->getOpcode()))
+ return AltOp;
+ }
if (Converter.hasAltOp() && !isAltShuffle())
return nullptr;
return Converter.hasAltOp() ? AltOp : MainOp;
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/main-alternate-interechanged-detect.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine i64 @test() {\n;\nbb:\n %shl = shl i32 0, 1\n %mul = mul i32 0, 0\n %add = add i32 0, 0\n %add1 = add i32 0, 1\n br label %bb2\n\nbb2:\n %phi = phi i32 [ %shl, %bb ]\n %phi3 = phi i32 [ %add, %bb ]\n %phi4 = phi i32 [ %mul, %bb ]\n %phi5 = phi i32 [ %add1, %bb ]\n ret i64 0\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Assertion `FromCIValue.isZero() && \"Cannot convert the instruction.\"' failed.",
"body": "To reproduce run opt with the test below using -passes=slp-vectorizer:\n```\n; ModuleID = './reduced.ll'\nsource_filename = \"./reduced.ll\"\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i64 @wombat() gc \"statepoint-example\" {\nbb:\n %shl = shl i32 0, 1\n %mul = mul i32 0, 0\n %add = add i32 0, 0\n %add1 = add i32 0, 1\n br label %bb2\n\nbb2: ; preds = %bb\n %phi = phi i32 [ %shl, %bb ]\n %phi3 = phi i32 [ %add, %bb ]\n %phi4 = phi i32 [ %mul, %bb ]\n %phi5 = phi i32 [ %add1, %bb ]\n ret i64 0\n}\n```\nReproducer: https://godbolt.org/z/xzPc7WYTj\n\nStack dump:\n```\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer <source>\n1.\tRunning pass \"function(slp-vectorizer)\" on module \"<source>\"\n2.\tRunning pass \"slp-vectorizer\" on function \"wombat\"\n #0 0x00000000056729e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x56729e8)\n #1 0x000000000566f894 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x000072a8c4e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x000072a8c4e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x000072a8c4e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x000072a8c4e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x000072a8c4e2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x000072a8c4e39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x00000000034cc914 (anonymous namespace)::convertTo(llvm::Instruction*, (anonymous namespace)::InstructionsState const&) SLPVectorizer.cpp:0:0\n #9 0x000000000350e89c (anonymous namespace)::InstructionsCompatibilityAnalysis::buildOperands((anonymous namespace)::InstructionsState const&, llvm::ArrayRef<llvm::Value*>) SLPVectorizer.cpp:0:0\n#10 0x000000000357aaed llvm::slpvectorizer::BoUpSLP::buildTreeRec(llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x357aaed)\n#11 0x000000000357d1d1 llvm::slpvectorizer::BoUpSLP::buildTreeRec(llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x357d1d1)\n#12 0x00000000035ab251 llvm::SLPVectorizerPass::tryToVectorizeList(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x35ab251)\n#13 0x00000000035b0066 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#14 0x00000000035b17cf llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x35b17cf)\n#15 0x00000000035b97f6 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#16 0x00000000035ba2db llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x35ba2db)\n#17 0x0000000002db658e 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+0x2db658e)\n#18 0x0000000005464431 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5464431)\n#19 0x0000000000ebde5e 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+0xebde5e)\n#20 0x0000000005464904 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5464904)\n#21 0x00000000009637fe 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+0x9637fe)\n#22 0x00000000054624d1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x54624d1)\n#23 0x000000000096daca 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+0x96daca)\n#24 0x0000000000961b7b optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x961b7b)\n#25 0x000072a8c4e29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#26 0x000072a8c4e29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#27 0x0000000000958c35 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x958c35)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```",
"author": "TatyanaDoubts",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
91434
|
https://github.com/llvm/llvm-project/issues/91434
|
crash
|
932f0de43a9e334e161a69a50bd6b01cd51e238e
| 2024-05-08T06:10:09 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "83d9aa27680b6a7f3556fcf13ada70b4be95bab2",
"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": [
[
171,
176
]
],
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": [
"VPTypeAnalysis::inferScalarTypeForRecipe"
],
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit 83d9aa27680b6a7f3556fcf13ada70b4be95bab2
Author: Pietro Ghiglio <pietro.ghiglio@codeplay.com>
Date: Wed May 15 15:03:21 2024 +0200
[VPlan] Add scalar inferencing support for addrspace cast (#92107)
Fixes https://github.com/llvm/llvm-project/issues/91434
PR: https://github.com/llvm/llvm-project/pull/92107
diff --git a/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp b/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp
index 5f93339083f0..efe8c21874a3 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp
@@ -171,6 +171,7 @@ Type *VPTypeAnalysis::inferScalarTypeForRecipe(const VPReplicateRecipe *R) {
case Instruction::ICmp:
case Instruction::FCmp:
return IntegerType::get(Ctx, 1);
+ case Instruction::AddrSpaceCast:
case Instruction::Alloca:
case Instruction::BitCast:
case Instruction::Trunc:
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/as_cast.ll",
"commands": [
"opt -passes=loop-vectorize %s -force-vector-width=1 -force-vector-interleave=2 -S -o -"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @foo(ptr addrspace(1) %in) {\nentry:\n br label %loop\n\nloop:\n %iter = phi i64 [ %next, %loop ], [ 0, %entry ]\n %ascast = addrspacecast ptr addrspace(1) %in to ptr\n %next = add i64 %iter, 1\n %arrayidx = getelementptr inbounds i64, ptr %ascast, i64 %next\n store i64 %next, ptr %arrayidx, align 4\n\n; check that we find the two interleaved blocks with ascast, gep and store:\n\n\n %cmp = icmp eq i64 %next, 7\n br i1 %cmp, label %exit, label %loop\n\n; check that we branch to the exit block\n\nexit:\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[Loop Vectorizer] Unhandled opcode UNREACHABLE executed at llvm/llvm-project/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp:208!",
"body": "```\r\nopt -passes=loop-vectorize before-loop-vectorize.ll\r\n\r\nUnhandled opcode\r\nUNREACHABLE executed at /llvm/llvm-project/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp:208!\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: /llvm/llvm-project/build/bin/opt -passes=loop-vectorize before-loop-vectorize.ll\r\n #0 0x0000000003167161 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/llvm/llvm-project/build/bin/opt+0x3167161)\r\n #1 0x00000000031646c4 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007fcb77b7bdb0 __restore_rt (/lib64/libc.so.6+0x59db0)\r\n #3 0x00007fcb77bc842c __pthread_kill_implementation (/lib64/libc.so.6+0xa642c)\r\n #4 0x00007fcb77b7bd06 gsignal (/lib64/libc.so.6+0x59d06)\r\n #5 0x00007fcb77b4e7d3 abort (/lib64/libc.so.6+0x2c7d3)\r\n #6 0x00000000030ac16a (/llvm/llvm-project/build/bin/opt+0x30ac16a)\r\n #7 0x00000000022ffc8d llvm::VPTypeAnalysis::inferScalarTypeForRecipe(llvm::VPReplicateRecipe const*) (/llvm/llvm-project/build/bin/opt+0x22ffc8d)\r\n #8 0x00000000022ff04c llvm::VPTypeAnalysis::inferScalarType(llvm::VPValue const*) (/llvm/llvm-project/build/bin/opt+0x22ff04c)\r\n #9 0x00000000021cb7f4 llvm::InnerLoopVectorizer::scalarizeInstruction(llvm::Instruction const*, llvm::VPReplicateRecipe*, llvm::VPIteration const&, llvm::VPTransformState&) (/llvm/llvm-project/build/bin/opt+0x21cb7f4)\r\n#10 0x00000000021cecb5 llvm::VPReplicateRecipe::execute(llvm::VPTransformState&) (/llvm/llvm-project/build/bin/opt+0x21cecb5)\r\n#11 0x00000000022f834f llvm::VPBasicBlock::execute(llvm::VPTransformState*) (/llvm/llvm-project/build/bin/opt+0x22f834f)\r\n#12 0x00000000022f0130 llvm::VPRegionBlock::execute(llvm::VPTransformState*) (/llvm/llvm-project/build/bin/opt+0x22f0130)\r\n#13 0x00000000022f03d8 llvm::VPRegionBlock::execute(llvm::VPTransformState*) (/llvm/llvm-project/build/bin/opt+0x22f03d8)\r\n#14 0x00000000022fb806 llvm::VPlan::execute(llvm::VPTransformState*) (/llvm/llvm-project/build/bin/opt+0x22fb806)\r\n#15 0x00000000021e983b 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*) (/llvm/llvm-project/build/bin/opt+0x21e983b)\r\n#16 0x00000000021fbbe0 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/llvm/llvm-project/build/bin/opt+0x21fbbe0)\r\n#17 0x00000000021fde5e 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*) (/llvm/llvm-project/build/bin/opt+0x21fde5e)\r\n#18 0x00000000021fef78 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/llvm/llvm-project/build/bin/opt+0x21fef78)\r\n#19 0x0000000001125c8e llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/llvm/llvm-project/build/bin/opt+0x1125c8e)\r\n#20 0x0000000002f8671a llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/llvm/llvm-project/build/bin/opt+0x2f8671a)\r\n#21 0x000000000082c95e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/llvm/llvm-project/build/bin/opt+0x82c95e)\r\n#22 0x0000000002f853cd llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/llvm/llvm-project/build/bin/opt+0x2f853cd)\r\n#23 0x000000000082da6e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/llvm/llvm-project/build/bin/opt+0x82da6e)\r\n#24 0x0000000002f832cc llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/llvm/llvm-project/build/bin/opt+0x2f832cc)\r\n#25 0x00000000007a0d5d 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/llvm-project/build/bin/opt+0x7a0d5d)\r\n#26 0x0000000000793a7c optMain (/llvm/llvm-project/build/bin/opt+0x793a7c)\r\n#27 0x00007fcb77b66e50 __libc_start_call_main (/lib64/libc.so.6+0x44e50)\r\n#28 0x00007fcb77b66efc __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x44efc)\r\n#29 0x0000000000789e15 _start (/llvm/llvm-project/build/bin/opt+0x789e15)\r\nAborted (core dumped)\r\n```\r\nInput IR file before-loop-vectorize.ll is:\r\n```\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\n%\"class.sycl::_V1::range\" = type { %\"class.sycl::_V1::detail::array\" }\r\n%\"class.sycl::_V1::detail::array\" = type { [1 x i64] }\r\n\r\n$_ZTSN4sycl3_V16detail18RoundedRangeKernelINS0_4itemILi1ELb1EEELi1EZZ12foo_parallelRNS0_5queueERNS0_6bufferIfLi1ENS1_17aligned_allocatorIfEEvEEmENKUlRNS0_7handlerEE_clESD_EUlNS0_2idILi1EEEE_EE = comdat any\r\n\r\n$_ZTSZZ12foo_parallelRN4sycl3_V15queueERNS0_6bufferIfLi1ENS0_6detail17aligned_allocatorIfEEvEEmENKUlRNS0_7handlerEE_clESA_EUlNS0_2idILi1EEEE_ = comdat any\r\n\r\n$_ZTSZZ15foo_single_taskRN4sycl3_V15queueERNS0_6bufferIfLi1ENS0_6detail17aligned_allocatorIfEEvEEmENKUlRNS0_7handlerEE_clESA_EUlvE_ = comdat any\r\n\r\n; Function Attrs: convergent norecurse nounwind\r\ndefine weak_odr dso_local spir_kernel void @_ZTSN4sycl3_V16detail18RoundedRangeKernelINS0_4itemILi1ELb1EEELi1EZZ12foo_parallelRNS0_5queueERNS0_6bufferIfLi1ENS1_17aligned_allocatorIfEEvEEmENKUlRNS0_7handlerEE_clESD_EUlNS0_2idILi1EEEE_EE(ptr noundef byval(%\"class.sycl::_V1::range\") align 8 %_arg_UserRange, ptr addrspace(1) noundef align 4 %_arg_acc, ptr noundef byval(%\"class.sycl::_V1::range\") align 8 %_arg_acc3) local_unnamed_addr #0 comdat !srcloc !7 !kernel_arg_buffer_location !8 !kernel_arg_runtime_aligned !9 !kernel_arg_exclusive_ptr !9 !sycl_fixed_targets !10 !sycl_kernel_omit_args !11 {\r\nentry:\r\n %0 = load i64, ptr %_arg_UserRange, align 8\r\n %agg.tmp7.sroa.0.0.copyload = load i64, ptr %_arg_acc3, align 8\r\n %add.ptr.i = getelementptr inbounds float, ptr addrspace(1) %_arg_acc, i64 %agg.tmp7.sroa.0.0.copyload\r\n %call.i = tail call i64 @_Z21__spirv_WorkgroupId_xv() #5, !noalias !12\r\n %call1.i = tail call i64 @_Z23__spirv_WorkgroupSize_xv() #5, !noalias !12\r\n %mul.i = mul i64 %call1.i, %call.i\r\n %call2.i = tail call i64 @_Z27__spirv_LocalInvocationId_xv() #5, !noalias !12\r\n %add.i = add i64 %mul.i, %call2.i\r\n %call3.i = tail call i64 @_Z22__spirv_GlobalOffset_xv() #5, !noalias !12\r\n %add4.i = add i64 %add.i, %call3.i\r\n %call.i1 = tail call i64 @_Z23__spirv_NumWorkgroups_xv() #5, !noalias !12\r\n %call1.i2 = tail call i64 @_Z23__spirv_WorkgroupSize_xv() #5, !noalias !12\r\n %mul.i3 = mul i64 %call1.i2, %call.i1\r\n %call.i.i.i9.i.i = tail call noundef i64 @_Z22__spirv_GlobalOffset_xv() #6, !noalias !12\r\n %cmp6.not.i.not.i = icmp ult i64 %add4.i, %0\r\n br i1 %cmp6.not.i.not.i, label %for.body.i.preheader, label %_ZNK4sycl3_V16detail18RoundedRangeKernelINS0_4itemILi1ELb1EEELi1EZZ12foo_parallelRNS0_5queueERNS0_6bufferIfLi1ENS1_17aligned_allocatorIfEEvEEmENKUlRNS0_7handlerEE_clESD_EUlNS0_2idILi1EEEE_EclES4_.exit\r\n\r\nfor.body.i.preheader: ; preds = %entry\r\n br label %for.body.i\r\n\r\nfor.body.i: ; preds = %for.body.i.preheader, %for.body.i\r\n %Gen.sroa.0.019.i = phi i64 [ %add.i.i, %for.body.i ], [ %add4.i, %for.body.i.preheader ]\r\n %conv.i.i = uitofp i64 %Gen.sroa.0.019.i to float\r\n %arrayidx.i.i = getelementptr inbounds float, ptr addrspace(1) %add.ptr.i, i64 %Gen.sroa.0.019.i\r\n %arrayidx.ascast.i.i = addrspacecast ptr addrspace(1) %arrayidx.i.i to ptr\r\n store float %conv.i.i, ptr %arrayidx.ascast.i.i, align 4, !tbaa !17\r\n %add.i.i = add i64 %Gen.sroa.0.019.i, %mul.i3\r\n %cmp6.i.not.i = icmp ult i64 %add.i.i, %0\r\n br i1 %cmp6.i.not.i, label %for.body.i, label %_ZNK4sycl3_V16detail18RoundedRangeKernelINS0_4itemILi1ELb1EEELi1EZZ12foo_parallelRNS0_5queueERNS0_6bufferIfLi1ENS1_17aligned_allocatorIfEEvEEmENKUlRNS0_7handlerEE_clESD_EUlNS0_2idILi1EEEE_EclES4_.exit.loopexit, !llvm.loop !21\r\n\r\n_ZNK4sycl3_V16detail18RoundedRangeKernelINS0_4itemILi1ELb1EEELi1EZZ12foo_parallelRNS0_5queueERNS0_6bufferIfLi1ENS1_17aligned_allocatorIfEEvEEmENKUlRNS0_7handlerEE_clESD_EUlNS0_2idILi1EEEE_EclES4_.exit.loopexit: ; preds = %for.body.i\r\n br label %_ZNK4sycl3_V16detail18RoundedRangeKernelINS0_4itemILi1ELb1EEELi1EZZ12foo_parallelRNS0_5queueERNS0_6bufferIfLi1ENS1_17aligned_allocatorIfEEvEEmENKUlRNS0_7handlerEE_clESD_EUlNS0_2idILi1EEEE_EclES4_.exit\r\n\r\n_ZNK4sycl3_V16detail18RoundedRangeKernelINS0_4itemILi1ELb1EEELi1EZZ12foo_parallelRNS0_5queueERNS0_6bufferIfLi1ENS1_17aligned_allocatorIfEEvEEmENKUlRNS0_7handlerEE_clESD_EUlNS0_2idILi1EEEE_EclES4_.exit: ; preds = %_ZNK4sycl3_V16detail18RoundedRangeKernelINS0_4itemILi1ELb1EEELi1EZZ12foo_parallelRNS0_5queueERNS0_6bufferIfLi1ENS1_17aligned_allocatorIfEEvEEmENKUlRNS0_7handlerEE_clESD_EUlNS0_2idILi1EEEE_EclES4_.exit.loopexit, %entry\r\n ret void\r\n}\r\n\r\n; Function Attrs: convergent nounwind\r\ndeclare dso_local noundef i64 @_Z22__spirv_GlobalOffset_xv() local_unnamed_addr #1\r\n\r\n; Function Attrs: convergent norecurse nounwind\r\ndefine weak_odr dso_local spir_kernel void @_ZTSZZ12foo_parallelRN4sycl3_V15queueERNS0_6bufferIfLi1ENS0_6detail17aligned_allocatorIfEEvEEmENKUlRNS0_7handlerEE_clESA_EUlNS0_2idILi1EEEE_(ptr addrspace(1) noundef align 4 %_arg_acc, ptr noundef byval(%\"class.sycl::_V1::range\") align 8 %_arg_acc3) local_unnamed_addr #0 comdat !srcloc !23 !kernel_arg_buffer_location !24 !kernel_arg_runtime_aligned !25 !kernel_arg_exclusive_ptr !25 !sycl_fixed_targets !10 !sycl_kernel_omit_args !26 {\r\nentry:\r\n %agg.tmp6.sroa.0.0.copyload = load i64, ptr %_arg_acc3, align 8\r\n %add.ptr.i = getelementptr inbounds float, ptr addrspace(1) %_arg_acc, i64 %agg.tmp6.sroa.0.0.copyload\r\n %call.i = tail call i64 @_Z21__spirv_WorkgroupId_xv() #5, !noalias !27\r\n %call1.i = tail call i64 @_Z23__spirv_WorkgroupSize_xv() #5, !noalias !27\r\n %mul.i = mul i64 %call1.i, %call.i\r\n %call2.i = tail call i64 @_Z27__spirv_LocalInvocationId_xv() #5, !noalias !27\r\n %add.i = add i64 %mul.i, %call2.i\r\n %call3.i = tail call i64 @_Z22__spirv_GlobalOffset_xv() #5, !noalias !27\r\n %add4.i = add i64 %add.i, %call3.i\r\n %call.i1 = tail call i64 @_Z23__spirv_NumWorkgroups_xv() #5, !noalias !27\r\n %call1.i2 = tail call i64 @_Z23__spirv_WorkgroupSize_xv() #5, !noalias !27\r\n %call.i.i.i9.i.i = tail call noundef i64 @_Z22__spirv_GlobalOffset_xv() #6, !noalias !27\r\n %cmp.i.i = icmp ult i64 %add4.i, 2147483648\r\n tail call void @llvm.assume(i1 %cmp.i.i)\r\n %conv.i = uitofp i64 %add4.i to float\r\n %arrayidx.i = getelementptr inbounds float, ptr addrspace(1) %add.ptr.i, i64 %add4.i\r\n %arrayidx.ascast.i = addrspacecast ptr addrspace(1) %arrayidx.i to ptr\r\n store float %conv.i, ptr %arrayidx.ascast.i, align 4, !tbaa !17\r\n ret void\r\n}\r\n\r\n; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\r\ndeclare void @llvm.assume(i1 noundef) #2\r\n\r\n; Function Attrs: mustprogress norecurse nounwind\r\ndefine weak_odr dso_local spir_kernel void @_ZTSZZ15foo_single_taskRN4sycl3_V15queueERNS0_6bufferIfLi1ENS0_6detail17aligned_allocatorIfEEvEEmENKUlRNS0_7handlerEE_clESA_EUlvE_(i64 noundef %_arg_n, ptr addrspace(1) noundef align 4 %_arg_acc, ptr noundef byval(%\"class.sycl::_V1::range\") align 8 %_arg_acc3) local_unnamed_addr #3 comdat !srcloc !32 !kernel_arg_buffer_location !8 !kernel_arg_runtime_aligned !9 !kernel_arg_exclusive_ptr !9 !sycl_fixed_targets !10 !sycl_kernel_omit_args !11 {\r\nentry:\r\n %agg.tmp6.sroa.0.0.copyload = load i64, ptr %_arg_acc3, align 8\r\n %add.ptr.i = getelementptr inbounds float, ptr addrspace(1) %_arg_acc, i64 %agg.tmp6.sroa.0.0.copyload\r\n %cmp.i12.not = icmp eq i64 %_arg_n, 0\r\n br i1 %cmp.i12.not, label %_ZZZ15foo_single_taskRN4sycl3_V15queueERNS0_6bufferIfLi1ENS0_6detail17aligned_allocatorIfEEvEEmENKUlRNS0_7handlerEE_clESA_ENKUlvE_clEv.exit, label %for.body.i.preheader\r\n\r\nfor.body.i.preheader: ; preds = %entry\r\n %xtraiter = and i64 %_arg_n, 7\r\n %0 = icmp ult i64 %_arg_n, 8\r\n br i1 %0, label %_ZZZ15foo_single_taskRN4sycl3_V15queueERNS0_6bufferIfLi1ENS0_6detail17aligned_allocatorIfEEvEEmENKUlRNS0_7handlerEE_clESA_ENKUlvE_clEv.exit.loopexit.unr-lcssa, label %for.body.i.preheader.new\r\n\r\nfor.body.i.preheader.new: ; preds = %for.body.i.preheader\r\n %unroll_iter = and i64 %_arg_n, -8\r\n br label %for.body.i\r\n\r\nfor.body.i: ; preds = %for.body.i, %for.body.i.preheader.new\r\n %i.0.i13 = phi i64 [ 0, %for.body.i.preheader.new ], [ %inc.i.7, %for.body.i ]\r\n %conv.i = uitofp i64 %i.0.i13 to float\r\n %arrayidx.i = getelementptr inbounds float, ptr addrspace(1) %add.ptr.i, i64 %i.0.i13\r\n %arrayidx.ascast.i = addrspacecast ptr addrspace(1) %arrayidx.i to ptr\r\n store float %conv.i, ptr %arrayidx.ascast.i, align 4, !tbaa !17\r\n %inc.i = or disjoint i64 %i.0.i13, 1\r\n %conv.i.1 = uitofp i64 %inc.i to float\r\n %arrayidx.i.1 = getelementptr inbounds float, ptr addrspace(1) %add.ptr.i, i64 %inc.i\r\n %arrayidx.ascast.i.1 = addrspacecast ptr addrspace(1) %arrayidx.i.1 to ptr\r\n store float %conv.i.1, ptr %arrayidx.ascast.i.1, align 4, !tbaa !17\r\n %inc.i.1 = or disjoint i64 %i.0.i13, 2\r\n %conv.i.2 = uitofp i64 %inc.i.1 to float\r\n %arrayidx.i.2 = getelementptr inbounds float, ptr addrspace(1) %add.ptr.i, i64 %inc.i.1\r\n %arrayidx.ascast.i.2 = addrspacecast ptr addrspace(1) %arrayidx.i.2 to ptr\r\n store float %conv.i.2, ptr %arrayidx.ascast.i.2, align 4, !tbaa !17\r\n %inc.i.2 = or disjoint i64 %i.0.i13, 3\r\n %conv.i.3 = uitofp i64 %inc.i.2 to float\r\n %arrayidx.i.3 = getelementptr inbounds float, ptr addrspace(1) %add.ptr.i, i64 %inc.i.2\r\n %arrayidx.ascast.i.3 = addrspacecast ptr addrspace(1) %arrayidx.i.3 to ptr\r\n store float %conv.i.3, ptr %arrayidx.ascast.i.3, align 4, !tbaa !17\r\n %inc.i.3 = or disjoint i64 %i.0.i13, 4\r\n %conv.i.4 = uitofp i64 %inc.i.3 to float\r\n %arrayidx.i.4 = getelementptr inbounds float, ptr addrspace(1) %add.ptr.i, i64 %inc.i.3\r\n %arrayidx.ascast.i.4 = addrspacecast ptr addrspace(1) %arrayidx.i.4 to ptr\r\n store float %conv.i.4, ptr %arrayidx.ascast.i.4, align 4, !tbaa !17\r\n %inc.i.4 = or disjoint i64 %i.0.i13, 5\r\n %conv.i.5 = uitofp i64 %inc.i.4 to float\r\n %arrayidx.i.5 = getelementptr inbounds float, ptr addrspace(1) %add.ptr.i, i64 %inc.i.4\r\n %arrayidx.ascast.i.5 = addrspacecast ptr addrspace(1) %arrayidx.i.5 to ptr\r\n store float %conv.i.5, ptr %arrayidx.ascast.i.5, align 4, !tbaa !17\r\n %inc.i.5 = or disjoint i64 %i.0.i13, 6\r\n %conv.i.6 = uitofp i64 %inc.i.5 to float\r\n %arrayidx.i.6 = getelementptr inbounds float, ptr addrspace(1) %add.ptr.i, i64 %inc.i.5\r\n %arrayidx.ascast.i.6 = addrspacecast ptr addrspace(1) %arrayidx.i.6 to ptr\r\n store float %conv.i.6, ptr %arrayidx.ascast.i.6, align 4, !tbaa !17\r\n %inc.i.6 = or disjoint i64 %i.0.i13, 7\r\n %conv.i.7 = uitofp i64 %inc.i.6 to float\r\n %arrayidx.i.7 = getelementptr inbounds float, ptr addrspace(1) %add.ptr.i, i64 %inc.i.6\r\n %arrayidx.ascast.i.7 = addrspacecast ptr addrspace(1) %arrayidx.i.7 to ptr\r\n store float %conv.i.7, ptr %arrayidx.ascast.i.7, align 4, !tbaa !17\r\n %inc.i.7 = add nuw i64 %i.0.i13, 8\r\n %niter.ncmp.7 = icmp eq i64 %inc.i.7, %unroll_iter\r\n br i1 %niter.ncmp.7, label %_ZZZ15foo_single_taskRN4sycl3_V15queueERNS0_6bufferIfLi1ENS0_6detail17aligned_allocatorIfEEvEEmENKUlRNS0_7handlerEE_clESA_ENKUlvE_clEv.exit.loopexit.unr-lcssa, label %for.body.i, !llvm.loop !33\r\n\r\n_ZZZ15foo_single_taskRN4sycl3_V15queueERNS0_6bufferIfLi1ENS0_6detail17aligned_allocatorIfEEvEEmENKUlRNS0_7handlerEE_clESA_ENKUlvE_clEv.exit.loopexit.unr-lcssa: ; preds = %for.body.i, %for.body.i.preheader\r\n %i.0.i13.unr = phi i64 [ 0, %for.body.i.preheader ], [ %unroll_iter, %for.body.i ]\r\n %lcmp.mod.not = icmp eq i64 %xtraiter, 0\r\n br i1 %lcmp.mod.not, label %_ZZZ15foo_single_taskRN4sycl3_V15queueERNS0_6bufferIfLi1ENS0_6detail17aligned_allocatorIfEEvEEmENKUlRNS0_7handlerEE_clESA_ENKUlvE_clEv.exit, label %for.body.i.epil\r\n\r\nfor.body.i.epil: ; preds = %_ZZZ15foo_single_taskRN4sycl3_V15queueERNS0_6bufferIfLi1ENS0_6detail17aligned_allocatorIfEEvEEmENKUlRNS0_7handlerEE_clESA_ENKUlvE_clEv.exit.loopexit.unr-lcssa, %for.body.i.epil\r\n %i.0.i13.epil = phi i64 [ %inc.i.epil, %for.body.i.epil ], [ %i.0.i13.unr, %_ZZZ15foo_single_taskRN4sycl3_V15queueERNS0_6bufferIfLi1ENS0_6detail17aligned_allocatorIfEEvEEmENKUlRNS0_7handlerEE_clESA_ENKUlvE_clEv.exit.loopexit.unr-lcssa ]\r\n %epil.iter = phi i64 [ %epil.iter.next, %for.body.i.epil ], [ 0, %_ZZZ15foo_single_taskRN4sycl3_V15queueERNS0_6bufferIfLi1ENS0_6detail17aligned_allocatorIfEEvEEmENKUlRNS0_7handlerEE_clESA_ENKUlvE_clEv.exit.loopexit.unr-lcssa ]\r\n %conv.i.epil = uitofp i64 %i.0.i13.epil to float\r\n %arrayidx.i.epil = getelementptr inbounds float, ptr addrspace(1) %add.ptr.i, i64 %i.0.i13.epil\r\n %arrayidx.ascast.i.epil = addrspacecast ptr addrspace(1) %arrayidx.i.epil to ptr\r\n store float %conv.i.epil, ptr %arrayidx.ascast.i.epil, align 4, !tbaa !17\r\n %inc.i.epil = add nuw nsw i64 %i.0.i13.epil, 1\r\n %epil.iter.next = add nuw nsw i64 %epil.iter, 1\r\n %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter\r\n br i1 %epil.iter.cmp.not, label %_ZZZ15foo_single_taskRN4sycl3_V15queueERNS0_6bufferIfLi1ENS0_6detail17aligned_allocatorIfEEvEEmENKUlRNS0_7handlerEE_clESA_ENKUlvE_clEv.exit, label %for.body.i.epil, !llvm.loop !34\r\n\r\n_ZZZ15foo_single_taskRN4sycl3_V15queueERNS0_6bufferIfLi1ENS0_6detail17aligned_allocatorIfEEvEEmENKUlRNS0_7handlerEE_clESA_ENKUlvE_clEv.exit: ; preds = %for.body.i.epil, %_ZZZ15foo_single_taskRN4sycl3_V15queueERNS0_6bufferIfLi1ENS0_6detail17aligned_allocatorIfEEvEEmENKUlRNS0_7handlerEE_clESA_ENKUlvE_clEv.exit.loopexit.unr-lcssa, %entry\r\n ret void\r\n}\r\n\r\n; Function Attrs: convergent nounwind\r\ndeclare dso_local i64 @_Z21__spirv_WorkgroupId_xv() local_unnamed_addr #4\r\n\r\n; Function Attrs: convergent nounwind\r\ndeclare dso_local i64 @_Z23__spirv_WorkgroupSize_xv() local_unnamed_addr #4\r\n\r\n; Function Attrs: convergent nounwind\r\ndeclare dso_local i64 @_Z27__spirv_LocalInvocationId_xv() local_unnamed_addr #4\r\n\r\n; Function Attrs: convergent nounwind\r\ndeclare dso_local i64 @_Z23__spirv_NumWorkgroups_xv() local_unnamed_addr #4\r\n\r\nattributes #0 = { convergent norecurse nounwind \"min-legal-vector-width\"=\"0\" \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"sycl-module-id\"=\"native_cpu.cpp\" \"sycl-optlevel\"=\"2\" \"target-cpu\"=\"x86-64\" \"target-features\"=\"+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87\" \"tune-cpu\"=\"generic\" \"uniform-work-group-size\"=\"true\" }\r\nattributes #1 = { convergent nounwind \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"x86-64\" \"target-features\"=\"+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87\" \"tune-cpu\"=\"generic\" }\r\nattributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\r\nattributes #3 = { mustprogress norecurse nounwind \"min-legal-vector-width\"=\"0\" \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"sycl-module-id\"=\"native_cpu.cpp\" \"sycl-optlevel\"=\"2\" \"sycl-single-task\" \"target-cpu\"=\"x86-64\" \"target-features\"=\"+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87\" \"tune-cpu\"=\"generic\" \"uniform-work-group-size\"=\"true\" }\r\nattributes #4 = { convergent nounwind \"frame-pointer\"=\"all\" \"no-builtins\" \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"x86-64\" \"target-features\"=\"+avx,+avx2,+avx512f,+cmov,+crc32,+cx8,+evex512,+f16c,+fma,+fxsr,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave\" \"tune-cpu\"=\"generic\" }\r\nattributes #5 = { convergent nobuiltin nounwind \"no-builtins\" }\r\nattributes #6 = { convergent nounwind }\r\n\r\n!opencl.spir.version = !{!0}\r\n!spirv.Source = !{!1}\r\n!llvm.ident = !{!2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2}\r\n!llvm.module.flags = !{!3, !4, !5, !6}\r\n\r\n!0 = !{i32 1, i32 2}\r\n!1 = !{i32 4, i32 100000}\r\n!2 = !{!\"clang version 19.0.0git (https://github.com/intel/llvm.git f56d7d7ffd798e78146510bef7ba02575d53bbb2)\"}\r\n!3 = !{i32 1, !\"wchar_size\", i32 4}\r\n!4 = !{i32 1, !\"is-native-cpu\", i32 1}\r\n!5 = !{i32 7, !\"uwtable\", i32 2}\r\n!6 = !{i32 7, !\"frame-pointer\", i32 2}\r\n!7 = !{i32 8377463}\r\n!8 = !{i32 -1, i32 -1, i32 -1}\r\n!9 = !{i1 false, i1 true, i1 false}\r\n!10 = !{}\r\n!11 = !{i1 false, i1 false, i1 true, i1 true, i1 false}\r\n!12 = !{!13, !15}\r\n!13 = distinct !{!13, !14, !\"_ZN4sycl3_V16detail7Builder7getItemILi1ELb1EEENSt9enable_ifIXT0_EKNS0_4itemIXT_EXT0_EEEE4typeEv: %agg.result\"}\r\n!14 = distinct !{!14, !\"_ZN4sycl3_V16detail7Builder7getItemILi1ELb1EEENSt9enable_ifIXT0_EKNS0_4itemIXT_EXT0_EEEE4typeEv\"}\r\n!15 = distinct !{!15, !16, !\"_ZN4sycl3_V16detail7Builder10getElementILi1ELb1EEEDTcl7getItemIXT_EXT0_EEEEPNS0_4itemIXT_EXT0_EEE: %agg.result\"}\r\n!16 = distinct !{!16, !\"_ZN4sycl3_V16detail7Builder10getElementILi1ELb1EEEDTcl7getItemIXT_EXT0_EEEEPNS0_4itemIXT_EXT0_EEE\"}\r\n!17 = !{!18, !18, i64 0}\r\n!18 = !{!\"float\", !19, i64 0}\r\n!19 = !{!\"omnipotent char\", !20, i64 0}\r\n!20 = !{!\"Simple C++ TBAA\"}\r\n!21 = distinct !{!21, !22}\r\n!22 = !{!\"llvm.loop.mustprogress\"}\r\n!23 = !{i32 738}\r\n!24 = !{i32 -1, i32 -1}\r\n!25 = !{i1 true, i1 false}\r\n!26 = !{i1 false, i1 true, i1 true, i1 false}\r\n!27 = !{!28, !30}\r\n!28 = distinct !{!28, !29, !\"_ZN4sycl3_V16detail7Builder7getItemILi1ELb1EEENSt9enable_ifIXT0_EKNS0_4itemIXT_EXT0_EEEE4typeEv: %agg.result\"}\r\n!29 = distinct !{!29, !\"_ZN4sycl3_V16detail7Builder7getItemILi1ELb1EEENSt9enable_ifIXT0_EKNS0_4itemIXT_EXT0_EEEE4typeEv\"}\r\n!30 = distinct !{!30, !31, !\"_ZN4sycl3_V16detail7Builder10getElementILi1ELb1EEEDTcl7getItemIXT_EXT0_EEEEPNS0_4itemIXT_EXT0_EEE: %agg.result\"}\r\n!31 = distinct !{!31, !\"_ZN4sycl3_V16detail7Builder10getElementILi1ELb1EEEDTcl7getItemIXT_EXT0_EEEEPNS0_4itemIXT_EXT0_EEE\"}\r\n!32 = !{i32 1035}\r\n!33 = distinct !{!33, !22}\r\n!34 = distinct !{!34, !35}\r\n!35 = !{!\"llvm.loop.unroll.disable\"}\r\n\r\n```",
"author": "wenju-he",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "PietroGhg",
"body": "Hi, this should be addressed by https://github.com/llvm/llvm-project/pull/92107"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
112078
|
https://github.com/llvm/llvm-project/issues/112078
|
miscompilation
|
39aae575744de7ae77e755142e0746a5b473b3ed
| 2024-10-12T04:08:35 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "9edc454ee601e04500529c98b753d3bd8f427d01",
"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": [
[
935,
943
],
[
945,
955
],
[
3362,
3370
]
],
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": [
"InstCombinerImpl::foldAndOrOfICmps",
"foldIsPowerOf2OrZero"
],
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 9edc454ee601e04500529c98b753d3bd8f427d01
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Mon Oct 14 20:52:55 2024 +0800
[InstCombine] Drop range attributes in `foldIsPowerOf2OrZero` (#112178)
Closes https://github.com/llvm/llvm-project/issues/112078.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index 453071f3f982..64bee4ab974e 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -935,9 +935,11 @@ static Value *foldSignedTruncationCheck(ICmpInst *ICmp0, ICmpInst *ICmp1,
/// Fold (icmp eq ctpop(X) 1) | (icmp eq X 0) into (icmp ult ctpop(X) 2) and
/// fold (icmp ne ctpop(X) 1) & (icmp ne X 0) into (icmp ugt ctpop(X) 1).
-/// Also used for logical and/or, must be poison safe.
+/// Also used for logical and/or, must be poison safe if range attributes are
+/// dropped.
static Value *foldIsPowerOf2OrZero(ICmpInst *Cmp0, ICmpInst *Cmp1, bool IsAnd,
- InstCombiner::BuilderTy &Builder) {
+ InstCombiner::BuilderTy &Builder,
+ InstCombinerImpl &IC) {
CmpInst::Predicate Pred0, Pred1;
Value *X;
if (!match(Cmp0, m_ICmp(Pred0, m_Intrinsic<Intrinsic::ctpop>(m_Value(X)),
@@ -945,11 +947,19 @@ static Value *foldIsPowerOf2OrZero(ICmpInst *Cmp0, ICmpInst *Cmp1, bool IsAnd,
!match(Cmp1, m_ICmp(Pred1, m_Specific(X), m_ZeroInt())))
return nullptr;
- Value *CtPop = Cmp0->getOperand(0);
- if (IsAnd && Pred0 == ICmpInst::ICMP_NE && Pred1 == ICmpInst::ICMP_NE)
+ auto *CtPop = cast<Instruction>(Cmp0->getOperand(0));
+ if (IsAnd && Pred0 == ICmpInst::ICMP_NE && Pred1 == ICmpInst::ICMP_NE) {
+ // Drop range attributes and re-infer them in the next iteration.
+ CtPop->dropPoisonGeneratingAnnotations();
+ IC.addToWorklist(CtPop);
return Builder.CreateICmpUGT(CtPop, ConstantInt::get(CtPop->getType(), 1));
- if (!IsAnd && Pred0 == ICmpInst::ICMP_EQ && Pred1 == ICmpInst::ICMP_EQ)
+ }
+ if (!IsAnd && Pred0 == ICmpInst::ICMP_EQ && Pred1 == ICmpInst::ICMP_EQ) {
+ // Drop range attributes and re-infer them in the next iteration.
+ CtPop->dropPoisonGeneratingAnnotations();
+ IC.addToWorklist(CtPop);
return Builder.CreateICmpULT(CtPop, ConstantInt::get(CtPop->getType(), 2));
+ }
return nullptr;
}
@@ -3362,9 +3372,9 @@ Value *InstCombinerImpl::foldAndOrOfICmps(ICmpInst *LHS, ICmpInst *RHS,
/*IsLogical*/ false, Builder, Q))
return V;
- if (Value *V = foldIsPowerOf2OrZero(LHS, RHS, IsAnd, Builder))
+ if (Value *V = foldIsPowerOf2OrZero(LHS, RHS, IsAnd, Builder, *this))
return V;
- if (Value *V = foldIsPowerOf2OrZero(RHS, LHS, IsAnd, Builder))
+ if (Value *V = foldIsPowerOf2OrZero(RHS, LHS, IsAnd, Builder, *this))
return V;
// TODO: One of these directions is fine with logical and/or, the other could
|
[
{
"file": "llvm/test/Transforms/InstCombine/ispow2.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "is_pow2or0_decrement_op",
"test_body": "define i1 @is_pow2or0_decrement_op(i8 %x) {\n %dec = add i8 %x, -1\n %and = and i8 %dec, %x\n %cmp = icmp eq i8 %and, 0\n ret i1 %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2_negate_op_vec",
"test_body": "define <2 x i1> @is_pow2_negate_op_vec(<2 x i32> %x) {\n %neg = sub <2 x i32> zeroinitializer, %x\n %and = and <2 x i32> %neg, %x\n %cmp = icmp eq <2 x i32> %and, %x\n %notzero = icmp ne <2 x i32> %x, zeroinitializer\n %r = and <2 x i1> %cmp, %notzero\n ret <2 x i1> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2_ctpop_wrong_cmp_op1_logical",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2_ctpop_wrong_cmp_op1_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ult i32 %t0, 3\n %notzero = icmp ne i32 %x, 0\n %r = select i1 %notzero, i1 %cmp, i1 false\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2_negate_op",
"test_body": "define i1 @is_pow2_negate_op(i32 %x) {\n %neg = sub i32 0, %x\n %and = and i32 %neg, %x\n %cmp = icmp eq i32 %and, %x\n %notzero = icmp ne i32 %x, 0\n %r = and i1 %notzero, %cmp\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "not_pow2_nz_known_bits",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @not_pow2_nz_known_bits(i32 %xin) {\n %x = or i32 %xin, 1\n %cnt = call i32 @llvm.ctpop.i32(i32 %x)\n %r = icmp ne i32 %cnt, 1\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2_nz_known_bits",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2_nz_known_bits(i32 %xin) {\n %x = or i32 %xin, 64\n %cnt = call i32 @llvm.ctpop.i32(i32 %x)\n %r = icmp eq i32 %cnt, 1\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_power2_or_zero_with_range",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_power2_or_zero_with_range(i32 %x) {\n %ctpop = call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp eq i32 %ctpop, 1\n %notzero = icmp eq i32 %x, 0\n %res = select i1 %notzero, i1 true, i1 %cmp\n ret i1 %res\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "blsmsk_is_p2_or_z",
"test_body": "define i1 @blsmsk_is_p2_or_z(i32 %xx, i32 %yy) {\n %x = or i32 %xx, %yy\n %xm1 = add i32 %x, -1\n %y = xor i32 %x, %xm1\n %r = icmp uge i32 %x, %y\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2nor0_ctpop_commute_vec",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <2 x i8> @llvm.ctpop.v2i8(<2 x i8>) #0\n\ndefine <2 x i1> @isnot_pow2nor0_ctpop_commute_vec(<2 x i8> %x) {\n %t0 = tail call <2 x i8> @llvm.ctpop.v2i8(<2 x i8> %x)\n %cmp = icmp ne <2 x i8> %t0, splat (i8 1)\n %notzero = icmp ne <2 x i8> %x, zeroinitializer\n %r = and <2 x i1> %notzero, %cmp\n ret <2 x i1> %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2or0_ctpop_wrong_pred1",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2or0_ctpop_wrong_pred1(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ne i32 %t0, 1\n %iszero = icmp eq i32 %x, 0\n %r = or i1 %iszero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2_non_zero_ne_1",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #1\n\ndefine i1 @is_pow2_non_zero_ne_1(i32 %x) {\n %notzero = icmp ne i32 %x, 0\n call void @llvm.assume(i1 %notzero)\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ne i32 %t0, 1\n ret i1 %cmp\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\nattributes #1 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "blsmsk_is_p2_or_z_fail",
"test_body": "define i1 @blsmsk_is_p2_or_z_fail(i32 %xx, i32 %yy) {\n %x = or i32 %xx, %yy\n %xm1 = add i32 %x, -1\n %y = xor i32 %x, %xm1\n %r = icmp ugt i32 %x, %y\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "blsmsk_is_p2_or_z_uge_xy_fail",
"test_body": "define i1 @blsmsk_is_p2_or_z_uge_xy_fail(i8 %xx, i8 %yy) {\n %x = or i8 %xx, %yy\n %xm1 = add i8 %x, -1\n %y = xor i8 %x, %xm1\n %r = icmp uge i8 %x, %y\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2or0_ctpop_logical_extra_uses",
"test_body": "declare void @use(i32)\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndeclare void @use_i1(i1)\n\ndefine i1 @is_pow2or0_ctpop_logical_extra_uses(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n call void @use(i32 %t0)\n %cmp = icmp eq i32 %t0, 1\n call void @use_i1(i1 %cmp)\n %iszero = icmp eq i32 %x, 0\n call void @use_i1(i1 %iszero)\n %r = select i1 %iszero, i1 true, i1 %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2_ctpop_commute_vec",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <2 x i8> @llvm.ctpop.v2i8(<2 x i8>) #0\n\ndefine <2 x i1> @isnot_pow2_ctpop_commute_vec(<2 x i8> %x) {\n %t0 = tail call <2 x i8> @llvm.ctpop.v2i8(<2 x i8> %x)\n %cmp = icmp ugt <2 x i8> %t0, splat (i8 1)\n %iszero = icmp eq <2 x i8> %x, zeroinitializer\n %r = or <2 x i1> %cmp, %iszero\n ret <2 x i1> %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "blsmsk_isnt_p2_or_z_fail_wrong_add",
"test_body": "define i1 @blsmsk_isnt_p2_or_z_fail_wrong_add(i32 %x, i32 %z) {\n %xm1 = add i32 %z, -1\n %y = xor i32 %x, %xm1\n %r = icmp ult i32 %y, %x\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2_ctpop_wrong_pred2",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2_ctpop_wrong_pred2(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ult i32 %t0, 2\n %cmp2 = icmp sgt i32 %x, 0\n %r = and i1 %cmp2, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2or0_ctpop_swap_cmp",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2or0_ctpop_swap_cmp(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp eq i32 %t0, 1\n %iszero = icmp eq i32 %x, 0\n %r = or i1 %cmp, %iszero\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2or0_ctpop_commute_vec_wrong_pred3",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <2 x i8> @llvm.ctpop.v2i8(<2 x i8>) #0\n\ndefine <2 x i1> @is_pow2or0_ctpop_commute_vec_wrong_pred3(<2 x i8> %x) {\n %t0 = tail call <2 x i8> @llvm.ctpop.v2i8(<2 x i8> %x)\n %cmp = icmp eq <2 x i8> %t0, splat (i8 1)\n %iszero = icmp eq <2 x i8> %x, zeroinitializer\n %r = and <2 x i1> %cmp, %iszero\n ret <2 x i1> %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2_decrement_op_logical",
"test_body": "define i1 @is_pow2_decrement_op_logical(i8 %x) {\n %dec = add i8 %x, -1\n %and = and i8 %dec, %x\n %cmp = icmp eq i8 %and, 0\n %notzero = icmp ne i8 %x, 0\n %r = select i1 %cmp, i1 %notzero, i1 false\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2or0_negate_op_vec",
"test_body": "define <2 x i1> @isnot_pow2or0_negate_op_vec(<2 x i32> %x) {\n %neg = sub <2 x i32> zeroinitializer, %x\n %and = and <2 x i32> %neg, %x\n %cmp = icmp ne <2 x i32> %and, %x\n ret <2 x i1> %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2or0_ctpop_commute_vec",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <2 x i8> @llvm.ctpop.v2i8(<2 x i8>) #0\n\ndefine <2 x i1> @is_pow2or0_ctpop_commute_vec(<2 x i8> %x) {\n %t0 = tail call <2 x i8> @llvm.ctpop.v2i8(<2 x i8> %x)\n %cmp = icmp eq <2 x i8> %t0, splat (i8 1)\n %iszero = icmp eq <2 x i8> %x, zeroinitializer\n %r = or <2 x i1> %iszero, %cmp\n ret <2 x i1> %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2_negate_op_logical",
"test_body": "define i1 @is_pow2_negate_op_logical(i32 %x) {\n %neg = sub i32 0, %x\n %and = and i32 %neg, %x\n %cmp = icmp eq i32 %and, %x\n %notzero = icmp ne i32 %x, 0\n %r = select i1 %notzero, i1 %cmp, i1 false\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2nor0_ctpop",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2nor0_ctpop(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ne i32 %t0, 1\n %notzero = icmp ne i32 %x, 0\n %r = and i1 %notzero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "blsmsk_isnt_p2_or_z_ult_xy_fail",
"test_body": "define i1 @blsmsk_isnt_p2_or_z_ult_xy_fail(i8 %xx, i8 %yy) {\n %x = or i8 %xx, %yy\n %xm1 = add i8 %x, -1\n %y = xor i8 %x, %xm1\n %r = icmp ult i8 %x, %y\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2nor0_wrong_pred3_ctpop_commute_vec",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <2 x i8> @llvm.ctpop.v2i8(<2 x i8>) #0\n\ndefine <2 x i1> @isnot_pow2nor0_wrong_pred3_ctpop_commute_vec(<2 x i8> %x) {\n %t0 = tail call <2 x i8> @llvm.ctpop.v2i8(<2 x i8> %x)\n %cmp = icmp ne <2 x i8> %t0, splat (i8 1)\n %notzero = icmp ne <2 x i8> %x, zeroinitializer\n %r = or <2 x i1> %cmp, %notzero\n ret <2 x i1> %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2or0_negate_op_vec",
"test_body": "define <2 x i1> @is_pow2or0_negate_op_vec(<2 x i32> %x) {\n %neg = sub <2 x i32> zeroinitializer, %x\n %and = and <2 x i32> %neg, %x\n %cmp = icmp eq <2 x i32> %and, %x\n ret <2 x i1> %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2or0_negate_op",
"test_body": "define i1 @isnot_pow2or0_negate_op(i32 %x) {\n %neg = sub i32 0, %x\n %and = and i32 %neg, %x\n %cmp = icmp ne i32 %and, %x\n ret i1 %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "not_pow2_or_z_known_bits_fail_wrong_cmp",
"test_body": "define <2 x i1> @not_pow2_or_z_known_bits_fail_wrong_cmp(<2 x i32> %xin) {\n %x = or <2 x i32> %xin, splat (i32 64)\n %cnt = call <2 x i32> @llvm.ctpop.v2i32(<2 x i32> %x)\n %r = icmp ugt <2 x i32> %cnt, splat (i32 2)\n ret <2 x i1> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <2 x i32> @llvm.ctpop.v2i32(<2 x i32>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2_ctpop_wrong_cmp_op2",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2_ctpop_wrong_cmp_op2(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ult i32 %t0, 2\n %notzero = icmp ne i32 %x, 1\n %r = and i1 %notzero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2_ctpop_logical",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2_ctpop_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ult i32 %t0, 2\n %notzero = icmp ne i32 %x, 0\n %r = select i1 %notzero, i1 %cmp, i1 false\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2_decrement_op_logical",
"test_body": "define i1 @isnot_pow2_decrement_op_logical(i8 %x) {\n %dec = add i8 %x, -1\n %and = and i8 %dec, %x\n %cmp = icmp ne i8 %and, 0\n %iszero = icmp eq i8 %x, 0\n %r = select i1 %iszero, i1 true, i1 %cmp\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2_negate_op_logical",
"test_body": "define i1 @isnot_pow2_negate_op_logical(i32 %x) {\n %neg = sub i32 0, %x\n %and = and i32 %neg, %x\n %cmp = icmp ne i32 %and, %x\n %iszero = icmp eq i32 %x, 0\n %r = select i1 %cmp, i1 true, i1 %iszero\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2or0_ctpop",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2or0_ctpop(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp eq i32 %t0, 1\n %iszero = icmp eq i32 %x, 0\n %r = or i1 %iszero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "blsmsk_is_p2_or_z_uge_yx",
"test_body": "define i1 @blsmsk_is_p2_or_z_uge_yx(i8 %xx, i8 %yy) {\n %x = or i8 %xx, %yy\n %xm1 = add i8 %x, -1\n %y = xor i8 %x, %xm1\n %r = icmp uge i8 %y, %x\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "has_single_bit_inv",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @has_single_bit_inv(i32 %x) {\nentry:\n %cmp1 = icmp eq i32 %x, 0\n %popcnt = call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %x)\n %cmp2 = icmp ugt i32 %popcnt, 1\n %sel = select i1 %cmp1, i1 true, i1 %cmp2\n ret i1 %sel\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2or0_negate_op",
"test_body": "define i1 @is_pow2or0_negate_op(i32 %x) {\n %neg = sub i32 0, %x\n %and = and i32 %neg, %x\n %cmp = icmp eq i32 %and, %x\n ret i1 %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "blsmsk_isnt_p2_or_z_ugt_yx_fail",
"test_body": "define i1 @blsmsk_isnt_p2_or_z_ugt_yx_fail(i8 %xx, i8 %yy) {\n %x = or i8 %xx, %yy\n %xm1 = add i8 %x, -1\n %y = xor i8 %x, %xm1\n %r = icmp ugt i8 %y, %x\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "blsmsk_isnt_p2_or_z_fail",
"test_body": "define i1 @blsmsk_isnt_p2_or_z_fail(i32 %x) {\n %xm1 = add i32 %x, -1\n %y = xor i32 %x, %xm1\n %r = icmp ule i32 %y, %x\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2_decrement_op_vec",
"test_body": "define <2 x i1> @is_pow2_decrement_op_vec(<2 x i8> %x) {\n %dec = add <2 x i8> %x, splat (i8 -1)\n %and = and <2 x i8> %dec, %x\n %cmp = icmp eq <2 x i8> %and, zeroinitializer\n %notzero = icmp ne <2 x i8> %x, zeroinitializer\n %r = and <2 x i1> %notzero, %cmp\n ret <2 x i1> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2nor0_ctpop_extra_uses",
"test_body": "declare void @use(i32)\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndeclare void @use_i1(i1)\n\ndefine i1 @isnot_pow2nor0_ctpop_extra_uses(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n call void @use(i32 %t0)\n %cmp = icmp ne i32 %t0, 1\n call void @use_i1(i1 %cmp)\n %notzero = icmp ne i32 %x, 0\n call void @use_i1(i1 %notzero)\n %r = and i1 %notzero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2nor0_ctpop_wrong_pred1",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2nor0_ctpop_wrong_pred1(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp eq i32 %t0, 1\n %notzero = icmp ne i32 %x, 0\n %r = and i1 %notzero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2_ctpop",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2_ctpop(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ugt i32 %t0, 1\n %iszero = icmp eq i32 %x, 0\n %r = or i1 %iszero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "blsmsk_isnt_p2_or_z_fail_multiuse",
"test_body": "declare void @use.i32(i32)\n\ndefine i1 @blsmsk_isnt_p2_or_z_fail_multiuse(i32 %x) {\n %xm1 = add i32 %x, -1\n %y = xor i32 %x, %xm1\n call void @use.i32(i32 %y)\n %r = icmp ult i32 %y, %x\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2or0_ctpop_wrong_pred2_logical",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2or0_ctpop_wrong_pred2_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ne i32 %t0, 1\n %iszero = icmp ne i32 %x, 0\n %r = select i1 %iszero, i1 true, i1 %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2_ctpop_extra_uses",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndeclare void @use_i1(i1)\n\ndefine i1 @is_pow2_ctpop_extra_uses(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ult i32 %t0, 2\n call void @use_i1(i1 %cmp)\n %notzero = icmp ne i32 %x, 0\n call void @use_i1(i1 %notzero)\n %r = and i1 %notzero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "blsmsk_isnt_p2_or_z_ult_yx",
"test_body": "define i1 @blsmsk_isnt_p2_or_z_ult_yx(i8 %xx, i8 %yy) {\n %x = or i8 %xx, %yy\n %xm1 = add i8 %x, -1\n %y = xor i8 %x, %xm1\n %r = icmp ult i8 %y, %x\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2or0_ctpop_wrong_cmp_op1_logical",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2or0_ctpop_wrong_cmp_op1_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp eq i32 %t0, 3\n %iszero = icmp eq i32 %x, 0\n %r = select i1 %iszero, i1 true, i1 %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "blsmsk_isnt_p2_or_z_fail_bad_xor",
"test_body": "define i1 @blsmsk_isnt_p2_or_z_fail_bad_xor(i32 %x, i32 %z) {\n %xm1 = add i32 %x, -1\n %y = xor i32 %z, %xm1\n %r = icmp ult i32 %y, %x\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2or0_negate_op_extra_use2",
"test_body": "declare void @use(i32)\n\ndefine i1 @is_pow2or0_negate_op_extra_use2(i32 %x) {\n %neg = sub i32 0, %x\n %and = and i32 %neg, %x\n call void @use(i32 %and)\n %cmp = icmp eq i32 %and, %x\n ret i1 %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2_negate_op",
"test_body": "define i1 @isnot_pow2_negate_op(i32 %x) {\n %neg = sub i32 0, %x\n %and = and i32 %neg, %x\n %cmp = icmp ne i32 %and, %x\n %iszero = icmp eq i32 %x, 0\n %r = or i1 %cmp, %iszero\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2or0_negate_op_extra_use1",
"test_body": "declare void @use(i32)\n\ndefine i1 @is_pow2or0_negate_op_extra_use1(i32 %x) {\n %neg = sub i32 0, %x\n call void @use(i32 %neg)\n %and = and i32 %neg, %x\n %cmp = icmp eq i32 %and, %x\n ret i1 %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2_ctpop_wrong_cmp_op1_logical",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2_ctpop_wrong_cmp_op1_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ugt i32 %t0, 2\n %iszero = icmp eq i32 %x, 0\n %r = select i1 %iszero, i1 true, i1 %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2_ctpop_wrong_cmp_op2_logical",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2_ctpop_wrong_cmp_op2_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ugt i32 %t0, 1\n %iszero = icmp eq i32 %x, 1\n %r = select i1 %iszero, i1 true, i1 %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2_ctpop_wrong_cmp_op1",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2_ctpop_wrong_cmp_op1(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ult i32 %t0, 3\n %notzero = icmp ne i32 %x, 0\n %r = and i1 %notzero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2or0_ctpop_commute_vec_wrong_cmp_op1",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <2 x i8> @llvm.ctpop.v2i8(<2 x i8>) #0\n\ndefine <2 x i1> @is_pow2or0_ctpop_commute_vec_wrong_cmp_op1(<2 x i8> %x) {\n %t0 = tail call <2 x i8> @llvm.ctpop.v2i8(<2 x i8> %x)\n %cmp = icmp eq <2 x i8> %t0, <i8 -1, i8 1>\n %iszero = icmp eq <2 x i8> %x, zeroinitializer\n %r = or <2 x i1> %cmp, %iszero\n ret <2 x i1> %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2_ctpop_wrong_pred2_logical",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2_ctpop_wrong_pred2_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ugt i32 %t0, 1\n %cmp2 = icmp slt i32 %x, 0\n %r = select i1 %cmp2, i1 true, i1 %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2_ctpop_extra_uses_logical",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndeclare void @use_i1(i1)\n\ndefine i1 @is_pow2_ctpop_extra_uses_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ult i32 %t0, 2\n call void @use_i1(i1 %cmp)\n %notzero = icmp ne i32 %x, 0\n call void @use_i1(i1 %notzero)\n %r = select i1 %notzero, i1 %cmp, i1 false\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2or0_negate_op_commute3",
"test_body": "define i1 @isnot_pow2or0_negate_op_commute3(i32 %p) {\n %x = urem i32 42, %p\n %neg = sub i32 0, %x\n %and = and i32 %x, %neg\n %cmp = icmp ne i32 %x, %and\n ret i1 %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2_ctpop_wrong_cmp_op2_logical",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2_ctpop_wrong_cmp_op2_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ult i32 %t0, 2\n %notzero = icmp ne i32 %x, 1\n %r = select i1 %notzero, i1 %cmp, i1 false\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2_non_zero_eq_1",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #1\n\ndefine i1 @is_pow2_non_zero_eq_1(i32 %x) {\n %notzero = icmp ne i32 %x, 0\n call void @llvm.assume(i1 %notzero)\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp eq i32 %t0, 1\n ret i1 %cmp\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\nattributes #1 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2nor0_ctpop_logical_extra_uses",
"test_body": "declare void @use(i32)\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndeclare void @use_i1(i1)\n\ndefine i1 @isnot_pow2nor0_ctpop_logical_extra_uses(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n call void @use(i32 %t0)\n %cmp = icmp ne i32 %t0, 1\n call void @use_i1(i1 %cmp)\n %notzero = icmp ne i32 %x, 0\n call void @use_i1(i1 %notzero)\n %r = select i1 %notzero, i1 %cmp, i1 false\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2or0_ctpop_wrong_pred2",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2or0_ctpop_wrong_pred2(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ne i32 %t0, 1\n %iszero = icmp ne i32 %x, 0\n %r = or i1 %iszero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2_ctpop_wrong_cmp_op2",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2_ctpop_wrong_cmp_op2(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ugt i32 %t0, 1\n %iszero = icmp eq i32 %x, 1\n %r = or i1 %iszero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2_ctpop_wrong_pred1",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2_ctpop_wrong_pred1(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ugt i32 %t0, 2\n %notzero = icmp ne i32 %x, 0\n %r = and i1 %notzero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2_ctpop_extra_uses_logical",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndeclare void @use_i1(i1)\n\ndefine i1 @isnot_pow2_ctpop_extra_uses_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ugt i32 %t0, 1\n call void @use_i1(i1 %cmp)\n %iszero = icmp eq i32 %x, 0\n call void @use_i1(i1 %iszero)\n %r = select i1 %iszero, i1 true, i1 %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2or0_ctpop_extra_uses",
"test_body": "declare void @use(i32)\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndeclare void @use_i1(i1)\n\ndefine i1 @is_pow2or0_ctpop_extra_uses(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n call void @use(i32 %t0)\n %cmp = icmp eq i32 %t0, 1\n call void @use_i1(i1 %cmp)\n %iszero = icmp eq i32 %x, 0\n call void @use_i1(i1 %iszero)\n %r = or i1 %iszero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2_non_zero_ult_2",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #1\n\ndefine i1 @is_pow2_non_zero_ult_2(i32 %x) {\n %notzero = icmp ne i32 %x, 0\n call void @llvm.assume(i1 %notzero)\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ult i32 %t0, 2\n ret i1 %cmp\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\nattributes #1 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2_ctpop_commute_vec",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <2 x i8> @llvm.ctpop.v2i8(<2 x i8>) #0\n\ndefine <2 x i1> @is_pow2_ctpop_commute_vec(<2 x i8> %x) {\n %t0 = tail call <2 x i8> @llvm.ctpop.v2i8(<2 x i8> %x)\n %cmp = icmp ult <2 x i8> %t0, splat (i8 2)\n %notzero = icmp ne <2 x i8> %x, zeroinitializer\n %r = and <2 x i1> %cmp, %notzero\n ret <2 x i1> %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2_decrement_op",
"test_body": "define i1 @isnot_pow2_decrement_op(i8 %x) {\n %dec = add i8 %x, -1\n %and = and i8 %dec, %x\n %cmp = icmp ne i8 %and, 0\n %iszero = icmp eq i8 %x, 0\n %r = or i1 %iszero, %cmp\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2nor0_ctpop_wrong_cmp_op1_logical",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2nor0_ctpop_wrong_cmp_op1_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ne i32 %t0, 5\n %notzero = icmp ne i32 %x, 0\n %r = select i1 %notzero, i1 %cmp, i1 false\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2_ctpop_wrong_pred1_logical",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2_ctpop_wrong_pred1_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ugt i32 %t0, 2\n %notzero = icmp ne i32 %x, 0\n %r = select i1 %notzero, i1 %cmp, i1 false\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2or0_decrement_op_vec",
"test_body": "define <2 x i1> @isnot_pow2or0_decrement_op_vec(<2 x i8> %x) {\n %dec = add <2 x i8> %x, splat (i8 -1)\n %and = and <2 x i8> %dec, %x\n %cmp = icmp ne <2 x i8> %and, zeroinitializer\n ret <2 x i1> %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2_ctpop_wrong_pred2_logical",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2_ctpop_wrong_pred2_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ult i32 %t0, 2\n %cmp2 = icmp sgt i32 %x, 0\n %r = select i1 %cmp2, i1 %cmp, i1 false\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "blsmsk_isnt_p2_or_z_ugt_xy",
"test_body": "define i1 @blsmsk_isnt_p2_or_z_ugt_xy(i8 %xx, i8 %yy) {\n %x = or i8 %xx, %yy\n %xm1 = add i8 %x, -1\n %y = xor i8 %x, %xm1\n %r = icmp ugt i8 %x, %y\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2nor0_ctpop_commute_vec_wrong_cmp_op1",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <2 x i8> @llvm.ctpop.v2i8(<2 x i8>) #0\n\ndefine <2 x i1> @isnot_pow2nor0_ctpop_commute_vec_wrong_cmp_op1(<2 x i8> %x) {\n %t0 = tail call <2 x i8> @llvm.ctpop.v2i8(<2 x i8> %x)\n %cmp = icmp ne <2 x i8> %t0, <i8 0, i8 -1>\n %notzero = icmp ne <2 x i8> %x, zeroinitializer\n %r = and <2 x i1> %cmp, %notzero\n ret <2 x i1> %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2nor0_ctpop_wrong_pred2_logical",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2nor0_ctpop_wrong_pred2_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp eq i32 %t0, 1\n %notzero = icmp eq i32 %x, 0\n %r = select i1 %notzero, i1 %cmp, i1 false\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2or0_negate_op_commute1",
"test_body": "define i1 @is_pow2or0_negate_op_commute1(i32 %p) {\n %x = srem i32 42, %p\n %neg = sub i32 0, %x\n %and = and i32 %x, %neg\n %cmp = icmp eq i32 %and, %x\n ret i1 %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2_or_z_known_bits",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2_or_z_known_bits(i32 %xin) {\n %x = or i32 %xin, -2147483648\n %cnt = call i32 @llvm.ctpop.i32(i32 %x)\n %r = icmp ult i32 %cnt, 2\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2or0_decrement_op_vec",
"test_body": "define <2 x i1> @is_pow2or0_decrement_op_vec(<2 x i8> %x) {\n %dec = add <2 x i8> %x, splat (i8 -1)\n %and = and <2 x i8> %dec, %x\n %cmp = icmp eq <2 x i8> %and, zeroinitializer\n ret <2 x i1> %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2_decrement_op",
"test_body": "define i1 @is_pow2_decrement_op(i8 %x) {\n %dec = add i8 %x, -1\n %and = and i8 %dec, %x\n %cmp = icmp eq i8 %and, 0\n %notzero = icmp ne i8 %x, 0\n %r = and i1 %cmp, %notzero\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2_ctpop_wrong_pred2",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2_ctpop_wrong_pred2(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ugt i32 %t0, 1\n %cmp2 = icmp slt i32 %x, 0\n %r = or i1 %cmp2, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2_ctpop_logical",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2_ctpop_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ugt i32 %t0, 1\n %iszero = icmp eq i32 %x, 0\n %r = select i1 %iszero, i1 true, i1 %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2or0_negate_op_commute2",
"test_body": "define i1 @isnot_pow2or0_negate_op_commute2(i32 %p) {\n %x = urem i32 42, %p\n %neg = sub i32 0, %x\n %and = and i32 %neg, %x\n %cmp = icmp ne i32 %x, %and\n ret i1 %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "blsmsk_is_p2_or_z_fail_bad_cmp",
"test_body": "define i1 @blsmsk_is_p2_or_z_fail_bad_cmp(i32 %x, i32 %z) {\n %xm1 = add i32 %x, -1\n %y = xor i32 %x, %xm1\n %r = icmp uge i32 %y, %z\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2_decrement_op_vec",
"test_body": "define <2 x i1> @isnot_pow2_decrement_op_vec(<2 x i8> %x) {\n %dec = add <2 x i8> %x, splat (i8 -1)\n %and = and <2 x i8> %dec, %x\n %cmp = icmp ne <2 x i8> %and, zeroinitializer\n %iszero = icmp eq <2 x i8> %x, zeroinitializer\n %r = or <2 x i1> %cmp, %iszero\n ret <2 x i1> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2or0_ctpop_wrong_cmp_op1",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2or0_ctpop_wrong_cmp_op1(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp eq i32 %t0, 2\n %iszero = icmp eq i32 %x, 0\n %r = or i1 %iszero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "blsmsk_is_p2_or_z_ule_yx_fail",
"test_body": "define i1 @blsmsk_is_p2_or_z_ule_yx_fail(i8 %xx, i8 %yy) {\n %x = or i8 %xx, %yy\n %xm1 = add i8 %x, -1\n %y = xor i8 %x, %xm1\n %r = icmp ule i8 %y, %x\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "not_pow2_or_z_known_bits",
"test_body": "define <2 x i1> @not_pow2_or_z_known_bits(<2 x i32> %xin) {\n %x = or <2 x i32> %xin, splat (i32 64)\n %cnt = call <2 x i32> @llvm.ctpop.v2i32(<2 x i32> %x)\n %r = icmp ugt <2 x i32> %cnt, splat (i32 1)\n ret <2 x i1> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <2 x i32> @llvm.ctpop.v2i32(<2 x i32>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2_negate_op_vec",
"test_body": "define <2 x i1> @isnot_pow2_negate_op_vec(<2 x i32> %x) {\n %neg = sub <2 x i32> zeroinitializer, %x\n %and = and <2 x i32> %neg, %x\n %cmp = icmp ne <2 x i32> %and, %x\n %iszero = icmp eq <2 x i32> %x, zeroinitializer\n %r = or <2 x i1> %iszero, %cmp\n ret <2 x i1> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2or0_ctpop_logical",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2or0_ctpop_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp eq i32 %t0, 1\n %iszero = icmp eq i32 %x, 0\n %r = select i1 %iszero, i1 true, i1 %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2_ctpop_extra_uses",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndeclare void @use_i1(i1)\n\ndefine i1 @isnot_pow2_ctpop_extra_uses(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ugt i32 %t0, 1\n call void @use_i1(i1 %cmp)\n %iszero = icmp eq i32 %x, 0\n call void @use_i1(i1 %iszero)\n %r = or i1 %iszero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_power2_or_zero_inv_with_range",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_power2_or_zero_inv_with_range(i32 %x) {\n %ctpop = call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ne i32 %ctpop, 1\n %notzero = icmp ne i32 %x, 0\n %res = select i1 %notzero, i1 %cmp, i1 false\n ret i1 %res\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2nor0_ctpop_wrong_pred2",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2nor0_ctpop_wrong_pred2(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp eq i32 %t0, 1\n %notzero = icmp eq i32 %x, 0\n %r = and i1 %notzero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "has_single_bit",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @has_single_bit(i32 %x) {\nentry:\n %cmp1 = icmp ne i32 %x, 0\n %popcnt = call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %x)\n %cmp2 = icmp ult i32 %popcnt, 2\n %sel = select i1 %cmp1, i1 %cmp2, i1 false\n ret i1 %sel\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2_fail_pr63327",
"test_body": "define i1 @is_pow2_fail_pr63327(i32 %x) {\n %nx = sub i32 0, %x\n %x_and_nx = and i32 %x, %nx\n %r = icmp sge i32 %x_and_nx, %x\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2_ctpop",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @is_pow2_ctpop(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ult i32 %t0, 2\n %notzero = icmp ne i32 %x, 0\n %r = and i1 %notzero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2_nz_known_bits_fail_multiuse",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndeclare void @use.i32(i32)\n\ndefine i1 @is_pow2_nz_known_bits_fail_multiuse(i32 %xin) {\n %x = or i32 %xin, 64\n %cnt = call i32 @llvm.ctpop.i32(i32 %x)\n call void @use.i32(i32 %cnt)\n %r = icmp eq i32 %cnt, 1\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "blsmsk_isnt_p2_or_z",
"test_body": "define i1 @blsmsk_isnt_p2_or_z(i32 %x) {\n %xm1 = add i32 %x, -1\n %y = xor i32 %x, %xm1\n %r = icmp ult i32 %y, %x\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2or0_decrement_op",
"test_body": "define i1 @isnot_pow2or0_decrement_op(i8 %x) {\n %dec = add i8 %x, -1\n %and = and i8 %dec, %x\n %cmp = icmp ne i8 %and, 0\n ret i1 %cmp\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "not_pow2_nz_known_bits_fail_not_p2_test",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @not_pow2_nz_known_bits_fail_not_p2_test(i32 %xin) {\n %x = or i32 %xin, 1\n %cnt = call i32 @llvm.ctpop.i32(i32 %x)\n %r = icmp ne i32 %cnt, 2\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2_ctpop_wrong_cmp_op1",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2_ctpop_wrong_cmp_op1(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ugt i32 %t0, 2\n %iszero = icmp eq i32 %x, 0\n %r = or i1 %iszero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "blsmsk_is_p2_or_z_ule_xy",
"test_body": "define i1 @blsmsk_is_p2_or_z_ule_xy(i8 %xx, i8 %yy) {\n %x = or i8 %xx, %yy\n %xm1 = add i8 %x, -1\n %y = xor i8 %x, %xm1\n %r = icmp ule i8 %x, %y\n ret i1 %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "is_pow2_non_zero_ugt_1",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #1\n\ndefine i1 @is_pow2_non_zero_ugt_1(i32 %x) {\n %notzero = icmp ne i32 %x, 0\n call void @llvm.assume(i1 %notzero)\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ugt i32 %t0, 1\n ret i1 %cmp\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\nattributes #1 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2nor0_ctpop_swap_cmp",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2nor0_ctpop_swap_cmp(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ne i32 %t0, 1\n %notzero = icmp ne i32 %x, 0\n %r = and i1 %cmp, %notzero\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2nor0_ctpop_logical",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2nor0_ctpop_logical(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ne i32 %t0, 1\n %notzero = icmp ne i32 %x, 0\n %r = select i1 %notzero, i1 %cmp, i1 false\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "isnot_pow2nor0_ctpop_wrong_cmp_op1",
"test_body": "; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.ctpop.i32(i32) #0\n\ndefine i1 @isnot_pow2nor0_ctpop_wrong_cmp_op1(i32 %x) {\n %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)\n %cmp = icmp ne i32 %t0, 4\n %notzero = icmp ne i32 %x, 0\n %r = and i1 %notzero, %cmp\n ret i1 %r\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstCombine] `range` attribute should be dropped in `foldIsPowerOf2OrZero`",
"body": "Reproducer: https://alive2.llvm.org/ce/z/u62KKP (Please use latest alive2 with https://github.com/AliveToolkit/alive2/pull/1097)\r\n```\r\ndefine i1 @src(i32 %x) {\r\n %t0 = tail call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %x)\r\n %cmp = icmp ne i32 %t0, 1\r\n %notzero = icmp ne i32 %x, 0\r\n %r = select i1 %notzero, i1 %cmp, i1 false\r\n ret i1 %r\r\n}\r\n\r\ndefine i1 @tgt(i32 %x) {\r\n %t0 = tail call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %x)\r\n %r = icmp ugt i32 %t0, 1\r\n ret i1 %r\r\n}\r\n```\r\n```\r\n----------------------------------------\r\ndefine i1 @src(i32 %x) {\r\n#0:\r\n %t0 = ctpop i32 %x\r\n %#range_0_%t0 = !range i32 %t0, i32 1, i32 33\r\n %cmp = icmp ne i32 %#range_0_%t0, 1\r\n %notzero = icmp ne i32 %x, 0\r\n %r = select i1 %notzero, i1 %cmp, i1 0\r\n ret i1 %r\r\n}\r\n=>\r\ndefine i1 @tgt(i32 %x) {\r\n#0:\r\n %t0 = ctpop i32 %x\r\n %#range_0_%t0 = !range i32 %t0, i32 1, i32 33\r\n %r = icmp ugt i32 %#range_0_%t0, 1\r\n ret i1 %r\r\n}\r\nTransformation doesn't verify!\r\n\r\nERROR: Target is more poisonous than source\r\n\r\nExample:\r\ni32 %x = #x00000000 (0)\r\n\r\nSource:\r\ni32 %t0 = #x00000000 (0)\r\ni32 %#range_0_%t0 = poison\r\ni1 %cmp = poison\r\ni1 %notzero = #x0 (0)\r\ni1 %r = #x0 (0)\r\n\r\nTarget:\r\ni32 %t0 = #x00000000 (0)\r\ni32 %#range_0_%t0 = poison\r\ni1 %r = poison\r\nSource value: #x0 (0)\r\nTarget value: poison\r\n```",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
84051
|
https://github.com/llvm/llvm-project/issues/84051
|
crash
|
b64482e23eefaef7738fde35d0b7c4174aaa6597
| 2024-03-05T17:59:45 |
[
"llvm/test/Transforms/DeadStoreElimination"
] |
{
"fix_commit": "eb8f379567e8d014194faefe02ce92813e237afc",
"components": [
"DeadStoreElimination"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": [
[
1908,
1922
]
],
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": [
"tryFoldIntoCalloc"
],
"llvm/lib/Analysis/InstructionSimplify.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 eb8f379567e8d014194faefe02ce92813e237afc
Author: Florian Hahn <flo@fhahn.com>
Date: Wed Mar 6 20:08:00 2024 +0000
[DSE] Remove malloc from EarliestEscapeInfo before removing. (#84157)
Not removing the malloc from earliest escape info leaves stale entries
in the cache.
Fixes https://github.com/llvm/llvm-project/issues/84051.
PR: https://github.com/llvm/llvm-project/pull/84157
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 3d1dac5ea17e..392e6ad5a66b 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1908,15 +1908,15 @@ struct DSEState {
Malloc->getArgOperand(0), IRB, TLI);
if (!Calloc)
return false;
+
MemorySSAUpdater Updater(&MSSA);
auto *NewAccess =
Updater.createMemoryAccessAfter(cast<Instruction>(Calloc), nullptr,
MallocDef);
auto *NewAccessMD = cast<MemoryDef>(NewAccess);
Updater.insertDef(NewAccessMD, /*RenameUses=*/true);
- Updater.removeMemoryAccess(Malloc);
Malloc->replaceAllUsesWith(Calloc);
- Malloc->eraseFromParent();
+ deleteDeadInstruction(Malloc);
return true;
}
|
[
{
"file": "llvm/test/Transforms/DeadStoreElimination/malloc-earliest-escape-info-invalidation.ll",
"commands": [
"opt -p dse -S %s"
],
"tests": [
{
"test_name": "widget",
"test_body": "target datalayout = \"E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64\"\n\ndefine void @widget(ptr %a) {\nbb:\n %call = tail call ptr @malloc(i64 1)\n tail call void @llvm.memset.p0.i64(ptr %call, i8 0, i64 1, i1 false)\n %call1 = tail call noalias ptr @malloc(i64 0)\n store ptr %call1, ptr %a, align 8\n %load = load ptr, ptr %a, align 8\n %load2 = load i32, ptr %load, align 8\n %getelementptr = getelementptr i8, ptr %call1, i64 0\n %getelementptr3 = getelementptr i8, ptr %getelementptr, i64 1\n store i8 0, ptr %call1, align 1\n %getelementptr4 = getelementptr i8, ptr %getelementptr, i64 8\n store i16 0, ptr %getelementptr4, align 4\n %getelementptr5 = getelementptr i8, ptr %getelementptr, i64 12\n store i32 0, ptr %call1, align 4\n %load6 = load i32, ptr inttoptr (i64 4 to ptr), align 4\n br label %bb48\n\nbb7: ; No predecessors!\n br label %bb9\n\nbb8: ; No predecessors!\n br label %bb53\n\nbb9: ; preds = %bb43, %bb7\n %phi = phi ptr [ %call1, %bb7 ], [ %a, %bb43 ]\n %getelementptr10 = getelementptr i8, ptr %phi, i64 0\n %getelementptr11 = getelementptr i8, ptr %phi, i64 0\n %getelementptr12 = getelementptr i8, ptr %phi, i64 0\n %getelementptr13 = getelementptr i8, ptr %getelementptr12, i64 1\n store i8 0, ptr %call1, align 1\n br label %bb29\n\nbb14: ; No predecessors!\n %getelementptr15 = getelementptr i8, ptr %getelementptr10, i64 8\n %load16 = load i16, ptr %call1, align 4\n br i1 false, label %bb22, label %bb17\n\nbb17: ; preds = %bb14\n %getelementptr18 = getelementptr i8, ptr %getelementptr11, i64 8\n %load19 = load i16, ptr %call1, align 4\n %getelementptr20 = getelementptr i8, ptr %getelementptr12, i64 8\n store i16 0, ptr %call1, align 4\n %getelementptr21 = getelementptr i8, ptr %phi, i64 0\n br label %bb25\n\nbb22: ; preds = %bb14\n %getelementptr23 = getelementptr i8, ptr %phi, i64 0\n %getelementptr24 = getelementptr i8, ptr %getelementptr23, i64 12\n br label %bb25\n\nbb25: ; preds = %bb22, %bb17\n %phi26 = phi ptr [ %a, %bb17 ], [ %call1, %bb22 ]\n %phi27 = phi ptr [ %call1, %bb17 ], [ %call1, %bb22 ]\n %phi28 = phi ptr [ %call1, %bb17 ], [ %call1, %bb22 ]\n store i32 0, ptr %call1, align 4\n br label %bb29\n\nbb29: ; preds = %bb25, %bb9\n %phi30 = phi ptr [ %call1, %bb9 ], [ %call1, %bb25 ]\n %phi31 = phi ptr [ %call1, %bb9 ], [ %call1, %bb25 ]\n %load32 = load i8, ptr %call1, align 4\n %load33 = load i8, ptr %call1, align 4\n %getelementptr34 = getelementptr i8, ptr %phi31, i64 12\n %getelementptr35 = getelementptr i8, ptr %getelementptr12, i64 12\n br label %bb86\n\nbb36: ; No predecessors!\n %getelementptr37 = getelementptr i8, ptr %phi30, i64 12\n br label %bb38\n\nbb38: ; preds = %bb38, %bb36\n %getelementptr39 = getelementptr [0 x i32], ptr %getelementptr34, i64 0, i64 0\n %load40 = load i32, ptr %call1, align 4\n %getelementptr41 = getelementptr [0 x i32], ptr %getelementptr37, i64 0, i64 0\n %load42 = load i32, ptr %call1, align 4\n br label %bb38\n\nbb43: ; No predecessors!\n %getelementptr44 = getelementptr i8, ptr %getelementptr12, i64 8\n %load45 = load i16, ptr %call1, align 4\n store i16 0, ptr %call1, align 4\n store i8 0, ptr %call1, align 4\n %getelementptr46 = getelementptr i8, ptr %getelementptr12, i64 12\n store i32 0, ptr %call1, align 4\n %getelementptr47 = getelementptr i8, ptr %getelementptr12, i64 16\n store i32 0, ptr %call1, align 4\n br label %bb9\n\nbb48: ; preds = %bb48, %bb\n %getelementptr49 = getelementptr i8, ptr %call1, i64 0\n %getelementptr50 = getelementptr i8, ptr %getelementptr49, i64 1\n store i8 0, ptr %call1, align 1\n %getelementptr51 = getelementptr i8, ptr %getelementptr49, i64 8\n store i16 0, ptr %call1, align 4\n %getelementptr52 = getelementptr i8, ptr %getelementptr49, i64 12\n store i32 0, ptr %call1, align 4\n br label %bb48\n\nbb53: ; preds = %bb71, %bb8\n %phi54 = phi ptr [ %call1, %bb8 ], [ %a, %bb71 ]\n %getelementptr55 = getelementptr i8, ptr %phi54, i64 0\n %getelementptr56 = getelementptr i8, ptr %phi54, i64 0\n %getelementptr57 = getelementptr i8, ptr %phi54, i64 0\n %getelementptr58 = getelementptr i8, ptr %getelementptr57, i64 1\n br label %bb71\n\nbb59: ; No predecessors!\n %getelementptr60 = getelementptr i8, ptr %phi54, i64 0\n %getelementptr61 = getelementptr i8, ptr %getelementptr60, i64 12\n br label %bb67\n\nbb62: ; No predecessors!\n %getelementptr63 = getelementptr i8, ptr %getelementptr56, i64 8\n %load64 = load i16, ptr %call1, align 4\n %getelementptr65 = getelementptr i8, ptr %getelementptr57, i64 8\n store i16 0, ptr %call1, align 4\n %getelementptr66 = getelementptr i8, ptr %phi54, i64 0\n br label %bb67\n\nbb67: ; preds = %bb62, %bb59\n %phi68 = phi ptr [ %a, %bb62 ], [ %call1, %bb59 ]\n %phi69 = phi ptr [ %call1, %bb62 ], [ %call1, %bb59 ]\n %phi70 = phi ptr [ %call1, %bb62 ], [ %call1, %bb59 ]\n store i32 0, ptr %call1, align 4\n br label %bb71\n\nbb71: ; preds = %bb67, %bb53\n %phi72 = phi ptr [ %call1, %bb53 ], [ %call1, %bb67 ]\n %phi73 = phi ptr [ %call1, %bb53 ], [ %call1, %bb67 ]\n %load74 = load i8, ptr %call1, align 4\n %load75 = load i8, ptr %call1, align 4\n %getelementptr76 = getelementptr i8, ptr %phi72, i64 12\n %getelementptr77 = getelementptr i8, ptr %getelementptr57, i64 12\n %getelementptr78 = getelementptr [0 x i32], ptr %getelementptr76, i64 0, i64 0\n %load79 = load i32, ptr %call1, align 4\n %getelementptr80 = getelementptr [0 x i32], ptr %getelementptr77, i64 0, i64 0\n store i32 0, ptr %call1, align 4\n %load81 = load i8, ptr %call1, align 4\n %getelementptr82 = getelementptr i8, ptr %getelementptr57, i64 8\n %load83 = load i16, ptr %call1, align 4\n store i16 0, ptr %call1, align 4\n store i8 0, ptr %call1, align 4\n %getelementptr84 = getelementptr i8, ptr %getelementptr57, i64 12\n store i32 0, ptr %call1, align 4\n %getelementptr85 = getelementptr i8, ptr %getelementptr57, i64 16\n store i32 0, ptr %call1, align 4\n br label %bb53\n\nbb86: ; preds = %bb86, %bb29\n %getelementptr87 = getelementptr [0 x i32], ptr %getelementptr34, i64 0, i64 0\n %load88 = load i32, ptr %call1, align 4\n %getelementptr89 = getelementptr [0 x i32], ptr %getelementptr35, i64 0, i64 0\n store i32 0, ptr %call1, align 4\n br label %bb86\n}\n\ndeclare ptr @malloc(i64)\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\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[DSE] crash",
"body": "Reduced test case:\r\n[tc_dse.tar.gz](https://github.com/llvm/llvm-project/files/14499403/tc_dse.tar.gz)\r\n\r\nopt -mtriple=s390x-unknown-linux -mcpu=z16 -O3 -S ./tc_dse.ll\r\n\r\n#6 0x0000000005287456 llvm::BasicAAResult::aliasCheck\r\n#11 0x00000000048f0646 (anonymous namespace)::DSEState::isReadClobber\r\n14 0x00000000049004d8 llvm::DSEPass::run\r\nSegmentation fault (core dumped)\r\n\r\nThis is reported by user on F37 with clang-15, and is still failing on trunk.\r\n\r\n@fhahn @BK1603 @nikic ",
"author": "JonPsson1",
"labels": [
"release:backport",
"crash-on-valid",
"llvm:transforms"
],
"comments": [
{
"author": "nikic",
"body": "llvm-reduce result for `-passes=dse`: https://gist.github.com/nikic/d52c888425c5d4ff3fbd37b4f84778b6\r\n\r\nvalgrind reports a use-after-free. Probably not invalidating EII correctly somewhere."
},
{
"author": "fhahn",
"body": "Also reproduces with ASAn, looking now"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
77320
|
https://github.com/llvm/llvm-project/issues/77320
|
miscompilation
|
ade7ae4760a0b0e74cddd8f852830ca946295930
| 2024-01-08T14:43:50 |
[
"llvm/test/Transforms/InstSimplify"
] |
{
"fix_commit": "97e3220d6312ae00bcbe08673f218bd0f705776b",
"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": [
[
4313,
4319
]
],
"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": [
"simplifyWithOpReplaced"
],
"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 97e3220d6312ae00bcbe08673f218bd0f705776b
Author: Nikita Popov <npopov@redhat.com>
Date: Mon Jan 8 15:49:47 2024 +0100
[InstSimplify] Consider bitcast as potential cross-lane operation
The bitcast might change the number of vector lanes, in which case
it will be a cross-lane operation.
Fixes https://github.com/llvm/llvm-project/issues/77320.
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 241bdd81b75a..d0c27cae0dff 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -4313,7 +4313,7 @@ static Value *simplifyWithOpReplaced(Value *V, Value *Op, Value *RepOp,
// For vector types, the simplification must hold per-lane, so forbid
// potentially cross-lane operations like shufflevector.
if (!I->getType()->isVectorTy() || isa<ShuffleVectorInst>(I) ||
- isa<CallBase>(I))
+ isa<CallBase>(I) || isa<BitCastInst>(I))
return nullptr;
}
|
[
{
"file": "llvm/test/Transforms/InstSimplify/select.ll",
"commands": [
"opt < %s -passes=instsimplify -S"
],
"tests": [
{
"test_name": "select_vector_cmp_with_bitcasts",
"test_body": "define <4 x i32> @select_vector_cmp_with_bitcasts(<2 x i64> %x, <4 x i32> %y) {\n %x.bc = bitcast <2 x i64> %x to <4 x i32>\n %y.bc = bitcast <4 x i32> %y to <2 x i64>\n %sub = sub <2 x i64> %x, %y.bc\n %sub.bc = bitcast <2 x i64> %sub to <4 x i32>\n %cmp = icmp eq <4 x i32> %y, %x.bc\n %sel = select <4 x i1> %cmp, <4 x i32> %sub.bc, <4 x i32> zeroinitializer\n ret <4 x i32> %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "select_or_disjoint_eq",
"test_body": "define i8 @select_or_disjoint_eq(i8 %x, i8 %y) {\n %cmp = icmp eq i8 %x, %y\n %or = or disjoint i8 %x, %y\n %sel = select i1 %cmp, i8 %x, i8 %or\n ret i8 %sel\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstSimplify] Miscompile with select of vectors and bitcast",
"body": "https://alive2.llvm.org/ce/z/xhCFyk\r\n\r\n```llvm\r\ndefine <4 x i32> @src(<2 x i64> %x, <4 x i32> %y) {\r\n %x.bc = bitcast <2 x i64> %x to <4 x i32>\r\n %y.bc = bitcast <4 x i32> %y to <2 x i64>\r\n %sub = sub <2 x i64> %x, %y.bc\r\n %sub.bc = bitcast <2 x i64> %sub to <4 x i32>\r\n %cmp = icmp eq <4 x i32> %y, %x.bc\r\n %sel = select <4 x i1> %cmp, <4 x i32> %sub.bc, <4 x i32> zeroinitializer\r\n ret <4 x i32> %sel\r\n}\r\n\r\ndefine <4 x i32> @tgt(<2 x i64> %x, <4 x i32> %y) {\r\n ret <4 x i32> zeroinitializer\r\n}\r\n```",
"author": "nikic",
"labels": [
"test-suite",
"miscompilation",
"llvm:instcombine"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
82230
|
https://github.com/llvm/llvm-project/issues/82230
|
crash
|
769c22f25b81b74e4da7871d4e552584605caef1
| 2024-02-19T09:37:19 |
[
"llvm/test/DebugInfo"
] |
{
"fix_commit": "5b342e6041f8567a39354ae3c5346cf74b3bb84f",
"components": [
"IR"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
293,
299
],
[
4886,
4893
]
],
"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": null,
"llvm/lib/IR/AsmWriter.cpp": [
"DPValue::print",
"PrintCallingConv",
"getModuleFromDPI"
],
"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 5b342e6041f8567a39354ae3c5346cf74b3bb84f
Author: Stephen Tozer <stephen.tozer@sony.com>
Date: Mon Feb 19 11:38:04 2024 +0000
[RemoveDIs][DebugInfo] Check for null marker when printing DPValues (#82238)
The function to print DPValues currently tries to incorporate the
function it is part of, which is found through its marker; this means
when we try to print a DPValue with no marker, we dereference a nullptr.
We can print instructions without parents, and so the same should be
true for DPValues; this patch changes DPValue::print to check for a null
marker and avoid dereferencing it.
Fixes issue: https://github.com/llvm/llvm-project/issues/82230
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index 0ae720e8b7ce..d3c64a57f7fd 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -293,7 +293,7 @@ static const Module *getModuleFromDPI(const DPMarker *Marker) {
}
static const Module *getModuleFromDPI(const DPValue *DPV) {
- return getModuleFromDPI(DPV->getMarker());
+ return DPV->getMarker() ? getModuleFromDPI(DPV->getMarker()) : nullptr;
}
static void PrintCallingConv(unsigned cc, raw_ostream &Out) {
@@ -4886,8 +4886,9 @@ void DPValue::print(raw_ostream &ROS, ModuleSlotTracker &MST,
if (F)
MST.incorporateFunction(*F);
};
- incorporateFunction(Marker->getParent() ? Marker->getParent()->getParent()
- : nullptr);
+ incorporateFunction(Marker && Marker->getParent()
+ ? Marker->getParent()->getParent()
+ : nullptr);
AssemblyWriter W(OS, SlotTable, getModuleFromDPI(this), nullptr, IsForDebug);
W.printDPValue(*this);
}
|
[
{
"file": "llvm/test/DebugInfo/dpvalue-print-nocrash.ll",
"commands": [
"opt -passes=\"instcombine\" -debug %s -o /dev/null 2>&1"
],
"tests": [
{
"test_name": "<module>",
"test_body": ";; Tests that we can debug-print DPValues that have no markers attached.\n; REQUIRES: asserts\n\n\ndefine ptr @func_10(i32 %p_11) {\nentry:\n %conv108 = zext i32 %p_11 to i64\n tail call void @llvm.dbg.value(metadata i64 %conv108, metadata !4, metadata !DIExpression()), !dbg !12\n br label %func_29.exit\n\nfunc_29.exit: ; preds = %entry\n store i64 %conv108, ptr null, align 1\n ret ptr null\n}\n\ndeclare void @llvm.dbg.value(metadata, metadata, metadata)\n\n!llvm.dbg.cu = !{!0}\n!llvm.module.flags = !{!3}\n\n!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: \"clang\", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, retainedTypes: !2, globals: !2, splitDebugInlining: false, nameTableKind: None)\n!1 = !DIFile(filename: \"csmith5961503756960.c\", directory: \"/llvm\")\n!2 = !{}\n!3 = !{i32 2, !\"Debug Info Version\", i32 3}\n!4 = !DILocalVariable(name: \"p_31\", arg: 2, scope: !5, file: !1, line: 148, type: !7)\n!5 = distinct !DISubprogram(name: \"func_29\", scope: !1, file: !1, line: 148, type: !6, scopeLine: 149, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)\n!6 = !DISubroutineType(types: !2)\n!7 = !DIDerivedType(tag: DW_TAG_typedef, name: \"uint64_t\", file: !8, line: 60, baseType: !9)\n!8 = !DIFile(filename: \"/foo/_stdint.h\", directory: \"\")\n!9 = !DIDerivedType(tag: DW_TAG_typedef, name: \"__uint64_t\", file: !10, line: 108, baseType: !11)\n!10 = !DIFile(filename: \"/foo/_default_types.h\", directory: \"\")\n!11 = !DIBasicType(name: \"unsigned long long\", size: 64, encoding: DW_ATE_unsigned)\n!12 = !DILocation(line: 0, scope: !5)",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "opt -passes=\"instcombine\" -debug crashes with non-instrinsic debug-info",
"body": "llvm commit: d61864f813e3\r\nReproduce with:\r\n```\r\nopt -passes=\"instcombine\" -debug bbi-92509.ll -o /dev/null\r\n```\r\n[bbi-92509.ll.gz](https://github.com/llvm/llvm-project/files/14329283/bbi-92509.ll.gz)\r\n\r\nResult:\r\n```\r\nINSTCOMBINE ITERATION #1 on func_10\r\nADD: ret ptr null\r\nADD: store i64 %conv108, ptr null, align 1\r\nADD: br label %func_29.exit\r\nADD: %conv108 = zext i32 %p_11 to i64\r\nCLONE: PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: ../../main-github/llvm/build-all/bin/opt -passes=instcombine -debug bbi-92509.ll -o /dev/null\r\n #0 0x000055e12968f4a7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (../../main-github/llvm/build-all/bin/opt+0x3db14a7)\r\n #1 0x000055e12968cf7e llvm::sys::RunSignalHandlers() (../../main-github/llvm/build-all/bin/opt+0x3daef7e)\r\n #2 0x000055e12968fe6f SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007fdf33999630 __restore_rt sigaction.c:0:0\r\n #4 0x000055e12971f8e0 llvm::DPMarker::getParent() const (../../main-github/llvm/build-all/bin/opt+0x3e418e0)\r\n #5 0x000055e129761abf llvm::DPValue::print(llvm::raw_ostream&, bool) const (../../main-github/llvm/build-all/bin/opt+0x3e83abf)\r\n #6 0x000055e12a244957 llvm::InstCombinerImpl::tryToSinkInstructionDPValues(llvm::Instruction*, llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true>, false, false>, llvm::BasicBlock*, llvm::BasicBlock*, llvm::SmallVectorImpl<llvm::DPValue*>&) InstructionCombining.cpp:0:0\r\n #7 0x000055e12a242b0c llvm::InstCombinerImpl::tryToSinkInstruction(llvm::Instruction*, llvm::BasicBlock*) InstructionCombining.cpp:0:0\r\n #8 0x000055e12a2453fc llvm::InstCombinerImpl::run() InstructionCombining.cpp:0:0\r\n #9 0x000055e12a248c79 combineInstructionsOverFunction(llvm::Function&, llvm::InstructionWorklist&, llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::ProfileSummaryInfo*, llvm::LoopInfo*, llvm::InstCombineOptions const&) InstructionCombining.cpp:0:0\r\n#10 0x000055e12a2482ea llvm::InstCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x496a2ea)\r\n#11 0x000055e12a95e5bd llvm::detail::PassModel<llvm::Function, llvm::InstCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) PassBuilderPipelines.cpp:0:0\r\n#12 0x000055e12989a8e4 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x3fbc8e4)\r\n#13 0x000055e12a9644dd llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) PassBuilderPipelines.cpp:0:0\r\n#14 0x000055e12989f9ae llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x3fc19ae)\r\n#15 0x000055e12a95dd9d llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) PassBuilderPipelines.cpp:0:0\r\n#16 0x000055e129899456 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x3fbb456)\r\n#17 0x000055e12a90a42b llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (../../main-github/llvm/build-all/bin/opt+0x502c42b)\r\n#18 0x000055e129657a28 optMain (../../main-github/llvm/build-all/bin/opt+0x3d79a28)\r\n#19 0x00007fdf310cc555 __libc_start_main (/lib64/libc.so.6+0x22555)\r\n#20 0x000055e129651369 _start (../../main-github/llvm/build-all/bin/opt+0x3d73369)\r\nSegmentation fault (core dumped)\r\n```\r\n\r\nThis starts happening with a93a4ec7dd205\r\n```\r\nReapply \"[DebugInfo][RemoveDIs] Turn on non-instrinsic debug-info by default\"\r\n```\r\n",
"author": "mikaelholmen",
"labels": [
"debuginfo",
"llvm:crash",
"llvm:ir"
],
"comments": [
{
"author": "SLTozer",
"body": "Should be fixed by: [5b342e6](https://github.com/llvm/llvm-project/commit/5b342e6041f8567a39354ae3c5346cf74b3bb84f)"
},
{
"author": "mikaelholmen",
"body": "> Should be fixed by: [5b342e6](https://github.com/llvm/llvm-project/commit/5b342e6041f8567a39354ae3c5346cf74b3bb84f)\r\n\r\nYep, thanks!"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
124275
|
https://github.com/llvm/llvm-project/issues/124275
|
miscompilation
|
35df525fd00c2037ef144189ee818b7d612241ff
| 2025-01-24T14:33:26 |
[
"llvm/test/Analysis/ValueTracking"
] |
{
"fix_commit": "c2fba023475fddb893eac29dc9f34dfbdb221cd5",
"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": [
[
593,
603
],
[
610,
620
],
[
1673,
1680
],
[
1705,
1713
]
],
"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": [
"breakSelfRecursivePHI",
"computeKnownBitsFromOperator"
],
"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 c2fba023475fddb893eac29dc9f34dfbdb221cd5
Author: goldsteinn <35538541+goldsteinn@users.noreply.github.com>
Date: Tue Jan 28 15:54:00 2025 -0600
[ValueTracking] Fix bug of using wrong condition for deducing KnownBits (#124481)
- **[ValueTracking] Add test for issue 124275**
- **[ValueTracking] Fix bug of using wrong condition for deducing
KnownBits**
Fixes https://github.com/llvm/llvm-project/issues/124275
Bug was introduced by https://github.com/llvm/llvm-project/pull/114689
Now that computeKnownBits supports breaking out of recursive Phi
nodes, `IncValue` can be an operand of a different Phi than `P`. This
breaks the previous assumptions we had when using the possibly
condition at `CxtI` to constrain `IncValue`.
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index eba728c7c8c3..b63a0a07f7de 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -593,11 +593,14 @@ static bool cmpExcludesZero(CmpInst::Predicate Pred, const Value *RHS) {
}
static void breakSelfRecursivePHI(const Use *U, const PHINode *PHI,
- Value *&ValOut, Instruction *&CtxIOut) {
+ Value *&ValOut, Instruction *&CtxIOut,
+ const PHINode **PhiOut = nullptr) {
ValOut = U->get();
if (ValOut == PHI)
return;
CtxIOut = PHI->getIncomingBlock(*U)->getTerminator();
+ if (PhiOut)
+ *PhiOut = PHI;
Value *V;
// If the Use is a select of this phi, compute analysis on other arm to break
// recursion.
@@ -610,11 +613,13 @@ static void breakSelfRecursivePHI(const Use *U, const PHINode *PHI,
// incoming value to break recursion.
// TODO: We could handle any number of incoming edges as long as we only have
// two unique values.
- else if (auto *IncPhi = dyn_cast<PHINode>(ValOut);
- IncPhi && IncPhi->getNumIncomingValues() == 2) {
+ if (auto *IncPhi = dyn_cast<PHINode>(ValOut);
+ IncPhi && IncPhi->getNumIncomingValues() == 2) {
for (int Idx = 0; Idx < 2; ++Idx) {
if (IncPhi->getIncomingValue(Idx) == PHI) {
ValOut = IncPhi->getIncomingValue(1 - Idx);
+ if (PhiOut)
+ *PhiOut = IncPhi;
CtxIOut = IncPhi->getIncomingBlock(1 - Idx)->getTerminator();
break;
}
@@ -1673,8 +1678,9 @@ static void computeKnownBitsFromOperator(const Operator *I,
Known.One.setAllBits();
for (const Use &U : P->operands()) {
Value *IncValue;
+ const PHINode *CxtPhi;
Instruction *CxtI;
- breakSelfRecursivePHI(&U, P, IncValue, CxtI);
+ breakSelfRecursivePHI(&U, P, IncValue, CxtI, &CxtPhi);
// Skip direct self references.
if (IncValue == P)
continue;
@@ -1705,9 +1711,10 @@ static void computeKnownBitsFromOperator(const Operator *I,
m_Br(m_c_ICmp(Pred, m_Specific(IncValue), m_APInt(RHSC)),
m_BasicBlock(TrueSucc), m_BasicBlock(FalseSucc)))) {
// Check for cases of duplicate successors.
- if ((TrueSucc == P->getParent()) != (FalseSucc == P->getParent())) {
+ if ((TrueSucc == CxtPhi->getParent()) !=
+ (FalseSucc == CxtPhi->getParent())) {
// If we're using the false successor, invert the predicate.
- if (FalseSucc == P->getParent())
+ if (FalseSucc == CxtPhi->getParent())
Pred = CmpInst::getInversePredicate(Pred);
// Get the knownbits implied by the incoming phi condition.
auto CR = ConstantRange::makeExactICmpRegion(Pred, *RHSC);
|
[
{
"file": "llvm/test/Analysis/ValueTracking/phi-known-bits.ll",
"commands": [
"opt -O1 < %s -S"
],
"tests": [
{
"test_name": "issue_124275_wrong_br_direction",
"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@c = dso_local global i32 1, align 4\n@a = dso_local global i32 0, align 4\n@b = dso_local global i32 0, align 4\n\ndefine dso_local i32 @main() #0 {\nentry:\n %retval = alloca i32, align 4\n %d = alloca i32, align 4\n store i32 0, ptr %retval, align 4\n store i32 -1, ptr @a, align 4\n %0 = load i32, ptr @a, align 4\n %cmp = icmp ult i32 %0, 1\n br i1 %cmp, label %if.then, label %if.end\n\nif.then:\n br label %e\n\nif.end:\n %1 = load i32, ptr @c, align 4\n store i32 %1, ptr %d, align 4\n %2 = load i32, ptr %d, align 4\n %tobool = icmp ne i32 %2, 0\n br i1 %tobool, label %if.then1, label %if.end2\n\nif.then1:\n br label %e\n\ne:\n br label %if.end2\n\nif.end2:\n %3 = load i32, ptr %d, align 4\n %tobool3 = icmp ne i32 %3, 0\n br i1 %tobool3, label %if.end5, label %if.then4\n\nif.then4:\n unreachable\n\nif.end5:\n %4 = load i32, ptr @b, align 4\n %tobool6 = icmp ne i32 %4, 0\n br i1 %tobool6, label %if.then7, label %if.end8\n\nif.then7:\n br label %e\n\nif.end8:\n ret i32 0\n}\n\nattributes #0 = { noinline nounwind uwtable \"frame-pointer\"=\"all\" \"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\" }\n\n!llvm.module.flags = !{!0, !1, !2, !3, !4, !5}\n!llvm.ident = !{!6}\n\n!0 = !{i32 7, !\"Dwarf Version\", i32 4}\n!1 = !{i32 1, !\"wchar_size\", i32 4}\n!2 = !{i32 8, !\"PIC Level\", i32 2}\n!3 = !{i32 7, !\"PIE Level\", i32 2}\n!4 = !{i32 7, !\"uwtable\", i32 2}\n!5 = !{i32 7, !\"frame-pointer\", i32 2}\n!6 = !{!\"clang version 21.0.0git (https://github.com/llvm/llvm-project.git 5c3c0a8cec9205efba78583bd0b8a646270968a1)\"}\n",
"lli_expected_out": null,
"additional_args": "-src-unroll=4 -tgt-unroll=4"
}
]
}
] |
{
"title": "wrong code at -O1 and above on x86_64-linux-gnu",
"body": "It appears to be a recent regression from 19.1.0. \n\nCompiler Explorer: https://godbolt.org/z/haMfGoo6h\n\n```\n[548] % clangtk -v\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git ddd2f57b29661f21308eec0400fa92a6d075b0c6)\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[549] % \n[549] % clangtk -O1 small.c\n[550] % ./a.out\nAborted\n[551] % \n[551] % cat small.c\nint printf(const char *, ...);\nunsigned a;\nint b, c = 1;\nint main() {\n int d;\n a = -1;\n if (a < 1)\n goto e;\n d = c;\n if (d) {\n e:;\n }\n if (!d)\n __builtin_abort();\n if (b)\n goto e;\n return 0;\n}\n```",
"author": "zhendongsu",
"labels": [
"miscompilation",
"llvm:analysis"
],
"comments": [
{
"author": "zhendongsu",
"body": "Another likely related test:\n```\n[552] % clangtk -v\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git ddd2f57b29661f21308eec0400fa92a6d075b0c6)\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[553] % \n[553] % clangtk -O0 small.c\n[554] % ./a.out\n[555] % \n[555] % clangtk -O1 small.c\n[556] % timeout -s 9 5 ./a.out\nKilled\n[557] % cat small.c\nint a, b;\nint main() {\n {\n int c;\n if (a && 0)\n goto d;\n }\n int e = -~b;\n if (e) {\n d:;\n }\n while (!e)\n goto d;\n return 0;\n}\n```"
},
{
"author": "antoniofrighetto",
"body": "Reduced to:\n\n```llvm\n; opt -p instcombine small.ll\ndefine i32 @small(i32 noundef %0) {\n %2 = xor i32 %0, 1\n %3 = sub i32 0, %2\n %4 = icmp ne i32 %3, 0\n br i1 %4, label %5, label %6\n\n5: ; preds = %6, %1\n %.0 = phi i32 [ %.1, %6 ], [ %3, %1 ]\n br label %6\n\n6: ; preds = %5, %1\n %.1 = phi i32 [ %.0, %5 ], [ 0, %1 ]\n %7 = icmp ne i32 %.1, 0\n %8 = xor i1 %7, true\n br i1 %8, label %5, label %9\n\n9: ; preds = %6\n ret i32 0\n}\n```"
},
{
"author": "goldsteinn",
"body": "Fix at: https://github.com/llvm/llvm-project/pull/124481"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
153013
|
https://github.com/llvm/llvm-project/issues/153013
|
crash
|
52f7cfb5ef0a21173f0c7ae2305c76e1662831c5
| 2025-08-11T14:30:18 |
[
"llvm/test/Transforms/SCCP"
] |
{
"fix_commit": "ab323eb0c6b2ed8814c4516d4bce179d55372a5a",
"components": [
"PredicateInfo"
],
"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": [
[
291,
296
]
],
"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": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": [
"PredicateInfoBuilder::convertUsesToDFSOrdered"
],
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.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 ab323eb0c6b2ed8814c4516d4bce179d55372a5a
Author: Nikita Popov <npopov@redhat.com>
Date: Tue Aug 12 12:53:39 2025 +0200
[SCCP][PredicateInfo] Do not predicate argument of lifetime intrinsic
Replacing the argument with a no-op bitcast violates a verifier
constraint, even if only temporarily. Any replacement based on it
would result in a violation even after the copy has been removed.
Fixes https://github.com/llvm/llvm-project/issues/153013.
diff --git a/llvm/lib/Transforms/Utils/PredicateInfo.cpp b/llvm/lib/Transforms/Utils/PredicateInfo.cpp
index 38a312a3715c..13c7ad2927d1 100644
--- a/llvm/lib/Transforms/Utils/PredicateInfo.cpp
+++ b/llvm/lib/Transforms/Utils/PredicateInfo.cpp
@@ -291,6 +291,11 @@ void PredicateInfoBuilder::convertUsesToDFSOrdered(
Value *Op, SmallVectorImpl<ValueDFS> &DFSOrderedSet) {
for (auto &U : Op->uses()) {
if (auto *I = dyn_cast<Instruction>(U.getUser())) {
+ // Lifetime intrinsics must work directly on alloca, do not replace them
+ // with a predicated copy.
+ if (I->isLifetimeStartOrEnd())
+ continue;
+
ValueDFS VD;
// Put the phi node uses in the incoming block.
BasicBlock *IBlock;
|
[
{
"file": "llvm/test/Transforms/SCCP/lifetime.ll",
"commands": [
"opt -S -passes=ipsccp < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @test() {\n;\n %a = alloca [4 x i16]\n %cmp = icmp eq ptr %a, inttoptr (i64 -1 to ptr)\n br i1 %cmp, label %if, label %exit\n\nif:\n call void @llvm.lifetime.start.p0(ptr %a)\n br label %exit\n\nexit:\n ret void\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "ipsccp -> llvm.lifetime.start/end can only be used on alloca or poison",
"body": "Running ipsccp pass on IR like this\n```\ndefine void @foo() {\n %g = alloca [4 x i16], align 1\n %.not1 = icmp eq ptr %g, inttoptr (i16 -1 to ptr)\n br i1 %.not1, label %for.end35.us.lr.ph, label %for.cond5\n\nfor.end35.us.lr.ph: ; preds = %entry\n br label %for.end35.us\n\nfor.end35.us: ; preds = %for.end35.us, %for.end35.us.lr.ph\n call void @llvm.lifetime.start.p0(ptr %g)\n br label %for.end35.us\n\nfor.cond5: ; preds = %entry\n ret void\n}\n```\nresults in\n```\nlvm.lifetime.start/end can only be used on alloca or poison\n call void @llvm.lifetime.start.p0(ptr inttoptr (i16 -1 to ptr))\nLLVM ERROR: Broken module found, compilation aborted!\n```\nSee https://godbolt.org/z/jo9zqrP1x",
"author": "bjope",
"labels": [
"crash-on-valid",
"llvm:transforms"
],
"comments": [
{
"author": "XChy",
"body": "Maybe we should prevent replacing alloca with constant at `SCCPSolver::tryToReplaceWithConstant`?"
},
{
"author": "bjope",
"body": "> Maybe we should prevent replacing alloca with constant at `SCCPSolver::tryToReplaceWithConstant`?\n\nIn this case I think problem happens earlier, already when introducing an ssa.copy."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
80836
|
https://github.com/llvm/llvm-project/issues/80836
|
crash
|
ea2d9383a23ca17b9240ad64c2adc5f2b5a73dc0
| 2024-02-06T14:26:26 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "1c10821022f1799452065fb57474e894e2562b7f",
"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": [
[
2010,
2025
]
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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": [
"getCost"
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 1c10821022f1799452065fb57474e894e2562b7f
Author: David Sherwood <57997763+david-arm@users.noreply.github.com>
Date: Wed Feb 14 16:07:51 2024 +0000
[LoopVectorize] Fix divide-by-zero bug (#80836) (#81721)
When attempting to use the estimated trip count to refine the costs of
the runtime memory checks we should also check for sane trip counts to
prevent divide-by-zero faults on some platforms.
Fixes #80836
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index b39bf21cacdb..98b177cf5d2d 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -2010,16 +2010,18 @@ public:
BestTripCount = *EstimatedTC;
}
+ BestTripCount = std::max(BestTripCount, 1U);
InstructionCost NewMemCheckCost = MemCheckCost / BestTripCount;
// Let's ensure the cost is always at least 1.
NewMemCheckCost = std::max(*NewMemCheckCost.getValue(),
(InstructionCost::CostType)1);
- LLVM_DEBUG(dbgs()
- << "We expect runtime memory checks to be hoisted "
- << "out of the outer loop. Cost reduced from "
- << MemCheckCost << " to " << NewMemCheckCost << '\n');
+ if (BestTripCount > 1)
+ LLVM_DEBUG(dbgs()
+ << "We expect runtime memory checks to be hoisted "
+ << "out of the outer loop. Cost reduced from "
+ << MemCheckCost << " to " << NewMemCheckCost << '\n');
MemCheckCost = NewMemCheckCost;
}
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/low_trip_memcheck_cost.ll",
"commands": [
"opt -p loop-vectorize -debug-only=loop-vectorize -S -disable-output < %s 2>&1"
],
"tests": [
{
"test_name": "outer_known_tc3_full_range_checks",
"test_body": "target triple = \"aarch64-unknown-linux-gnu\"\n\ndefine void @outer_known_tc3_full_range_checks(ptr nocapture noundef %dst, ptr nocapture noundef readonly %src, i64 noundef %n) {\nentry:\n br label %outer.loop\n\nouter.loop: ; preds = %inner.exit, %entry\n %outer.iv = phi i64 [ 0, %entry ], [ %outer.iv.next, %inner.exit ]\n %0 = mul nsw i64 %outer.iv, %n\n br label %inner.loop\n\ninner.loop: ; preds = %inner.loop, %outer.loop\n %iv.inner = phi i64 [ 0, %outer.loop ], [ %iv.inner.next, %inner.loop ]\n %1 = add nuw nsw i64 %iv.inner, %0\n %arrayidx.us = getelementptr inbounds i32, ptr %src, i64 %1\n %2 = load i32, ptr %arrayidx.us, align 4\n %arrayidx8.us = getelementptr inbounds i32, ptr %dst, i64 %1\n %3 = load i32, ptr %arrayidx8.us, align 4\n %add9.us = add nsw i32 %3, %2\n store i32 %add9.us, ptr %arrayidx8.us, align 4\n %iv.inner.next = add nuw nsw i64 %iv.inner, 1\n %inner.exit.cond = icmp eq i64 %iv.inner.next, %n\n br i1 %inner.exit.cond, label %inner.exit, label %inner.loop\n\ninner.exit: ; preds = %inner.loop\n %outer.iv.next = add nuw nsw i64 %outer.iv, 1\n %outer.exit.cond = icmp eq i64 %outer.iv.next, 3\n br i1 %outer.exit.cond, label %outer.exit, label %outer.loop\n\nouter.exit: ; preds = %inner.exit\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "outer_pgo_minus1",
"test_body": "target triple = \"aarch64-unknown-linux-gnu\"\n\ndefine void @outer_pgo_minus1(ptr nocapture noundef %a, ptr nocapture noundef readonly %b, i64 noundef %m, i64 noundef %n) {\nentry:\n br label %outer.loop\n\nouter.loop: ; preds = %inner.exit, %entry\n %outer.iv = phi i64 [ %outer.iv.next, %inner.exit ], [ 0, %entry ]\n %mul.us = mul nsw i64 %outer.iv, %n\n br label %inner.loop\n\ninner.loop: ; preds = %inner.loop, %outer.loop\n %inner.iv = phi i64 [ 0, %outer.loop ], [ %inner.iv.next, %inner.loop ]\n %add.us = add nuw nsw i64 %inner.iv, %mul.us\n %arrayidx.us = getelementptr inbounds i8, ptr %b, i64 %add.us\n %0 = load i8, ptr %arrayidx.us, align 1\n %arrayidx7.us = getelementptr inbounds i8, ptr %a, i64 %add.us\n %1 = load i8, ptr %arrayidx7.us, align 1\n %add9.us = add i8 %1, %0\n store i8 %add9.us, ptr %arrayidx7.us, align 1\n %inner.iv.next = add nuw nsw i64 %inner.iv, 1\n %exitcond.not = icmp eq i64 %inner.iv.next, %n\n br i1 %exitcond.not, label %inner.exit, label %inner.loop\n\ninner.exit: ; preds = %inner.loop\n %outer.iv.next = add nuw nsw i64 %outer.iv, 1\n %exitcond26.not = icmp eq i64 %outer.iv.next, %m\n br i1 %exitcond26.not, label %outer.exit, label %outer.loop, !prof !0\n\nouter.exit: ; preds = %inner.exit\n ret void\n}\n\n!0 = !{!\"branch_weights\", i32 1, i32 -1}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Unhandled Floating point exception with loop-vectorize ",
"body": "Run opt with -passes=loop-vectorize \r\n\r\nhttps://godbolt.org/z/s3PWY3vhE\r\n\r\nTest.ll\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 ptr addrspace(1) @wombat(i64 %arg, ptr addrspace(1) %arg1) gc \"statepoint-example\" {\r\nbb:\r\n br label %bb2\r\n\r\nbb2: ; preds = %bb4, %bb\r\n br label %bb3\r\n\r\nbb3: ; preds = %bb3, %bb2\r\n %phi = phi i64 [ 0, %bb2 ], [ %add, %bb3 ]\r\n %add = add i64 %phi, 1\r\n %load = load i8, ptr addrspace(1) %arg1, align 1\r\n %shl = shl i64 0, 0\r\n store i16 0, ptr addrspace(1) null, align 2\r\n %icmp = icmp ult i64 %phi, %arg\r\n br i1 %icmp, label %bb3, label %bb4\r\n\r\nbb4: ; preds = %bb3\r\n br i1 false, label %bb5, label %bb2, !prof !0\r\n\r\nbb5: ; preds = %bb4\r\n ret ptr addrspace(1) null\r\n}\r\n\r\n!0 = !{!\"branch_weights\", i32 1, i32 -1}\r\n```",
"author": "TatyanaDoubts",
"labels": [
"vectorizers",
"crash-on-valid"
],
"comments": [
{
"author": "DaniilSuchkov",
"body": "It started failing after 962fbafecf4730ba84a3b9fd7a662a5c30bb2c7c\r\n```\r\nAuthor: David Sherwood <57997763+david-arm@users.noreply.github.com>\r\nDate: Fri Jan 26 14:43:48 2024 +0000\r\n\r\n [LoopVectorize] Refine runtime memory check costs when there is an outer loop (#76034)\r\n\r\n When we generate runtime memory checks for an inner loop it's\r\n possible that these checks are invariant in the outer loop and\r\n so will get hoisted out. In such cases, the effective cost of\r\n the checks should reduce to reflect the outer loop trip count.\r\n\r\n This fixes a 25% performance regression introduced by commit\r\n\r\n 49b0e6dcc296792b577ae8f0f674e61a0929b99d\r\n\r\n when building the SPEC2017 x264 benchmark with PGO, where we\r\n decided the inner loop trip count wasn't high enough to warrant\r\n the (incorrect) high cost of the runtime checks. Also, when\r\n runtime memory checks consist entirely of diff checks these are\r\n likely to be outer loop invariant.\r\n```\r\nWe have a division by 0 here https://github.com/llvm/llvm-project/commit/962fbafecf4730ba84a3b9fd7a662a5c30bb2c7c#diff-da321d454a7246f8ae276bf1db2782bf26b5210b8133cb59e4d7fd45d0905decR2114 because `getLoopEstimatedTripCount(OuterLoop)` just above that line returns 0."
},
{
"author": "david-arm",
"body": "OK thanks for raising this issue - I'll take a look this morning!"
},
{
"author": "david-arm",
"body": "I have a fix in review - https://github.com/llvm/llvm-project/pull/81721"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
105988
|
https://github.com/llvm/llvm-project/issues/105988
|
miscompilation
|
4b0c0ec6b8065e611640f44adce94e2da12b3a3a
| 2024-08-25T14:54:29 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "e1d22512906e69846c8f6a2d29b30832b7c12b46",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
15975,
15980
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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 e1d22512906e69846c8f6a2d29b30832b7c12b46
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Mon Aug 26 11:30:13 2024 -0700
[SLP]Fix minbitwidth analysis for gather nodes with icmp users.
If the node is not in MinBWs container and the user node is icmp node,
the compiler should not check the type size of the user instruction, it
is always 1 and is not good for actual bitwidth analysis.
Fixes https://github.com/llvm/llvm-project/issues/105988
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index def73e8d0c0d..ed47ed661ab9 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -15975,6 +15975,10 @@ void BoUpSLP::computeMinimumValueSizes() {
auto It = MinBWs.find(TE);
if (It != MinBWs.end() && It->second.first > UserTESz)
return true;
+ // The size of icmp is always 1 and should not be
+ // considered.
+ if (TE->getOpcode() == Instruction::ICmp)
+ return true;
return DL->getTypeSizeInBits(U->getType()) > UserTESz;
}));
})) {
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/gather-with-cmp-user.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define i1 @test(i32 %g, i16 %d) {\nentry:\n %0 = and i16 %d, 1\n %xor.i.i = xor i32 %g, 1\n %conv1.i.i = trunc i32 %xor.i.i to i8\n %notsub.i = add i8 %conv1.i.i, -1\n %cmp.i.i = icmp sgt i8 %notsub.i, -3\n %conv3.i.i = zext i1 %cmp.i.i to i32\n %cmp4.i.i = icmp sgt i32 %xor.i.i, %conv3.i.i\n %conv1.1.i.i = trunc i32 %g to i8\n %notsub25.i = add i8 %conv1.1.i.i, -1\n %cmp.1.i.i = icmp sgt i8 %notsub25.i, -3\n %conv3.1.i.i = zext i1 %cmp.1.i.i to i32\n %cmp4.1.i.i = icmp sgt i32 %g, %conv3.1.i.i\n %notsub26.i = add i8 %conv1.1.i.i, -9\n %cmp.i17.i = icmp sgt i8 %notsub26.i, -3\n %conv3.i18.i = zext i1 %cmp.i17.i to i32\n %cmp4.i19.i = icmp sgt i32 %g, %conv3.i18.i\n %notsub27.i = add i8 %conv1.i.i, -9\n %cmp.1.i22.i = icmp sgt i8 %notsub27.i, -3\n %conv3.1.i23.i = zext i1 %cmp.1.i22.i to i32\n %cmp4.1.i24.i = icmp sgt i32 %xor.i.i, %conv3.1.i23.i\n %1 = and i1 %cmp4.i19.i, %cmp4.1.i24.i\n %2 = and i1 %cmp4.i.i, %1\n %3 = and i1 %cmp4.1.i.i, %2\n ret i1 %3\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SLPVectorizer] Miscompile at O3",
"body": "Reproducer: https://gist.github.com/dtcxzyw/117dc735db97658ea852d30fd896242a\r\n```console\r\n> bin/clang -O0 test.c -w -I/usr/include/csmith && ./a.out\r\nchecksum = BDCB7A78\r\n> bin/clang -O3 test.c -w -mllvm -inline-threshold=100000 -I/usr/include/csmith && ./a.out\r\nchecksum = 9198FC41\r\n```\r\n\r\nllvm version: 1193f7d6487d2d94009f8d8d27da3907136482b9\r\n",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:SLPVectorizer"
],
"comments": [
{
"author": "dtcxzyw",
"body": "Reproducer: https://alive2.llvm.org/ce/z/GCXoe9\r\n```\r\n; bin/opt -passes=slp-vectorizer test.ll -S\r\n\r\ntarget datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine i1 @main(i32 %g.promoted.i.i, i16 %d.promoted.i.i) {\r\nentry:\r\n %0 = and i16 %d.promoted.i.i, 1\r\n %xor.i.i = xor i32 %g.promoted.i.i, 1\r\n %conv1.i.i = trunc i32 %xor.i.i to i8\r\n %notsub.i = add i8 %conv1.i.i, -1\r\n %cmp.i.i = icmp sgt i8 %notsub.i, -3\r\n %conv3.i.i = zext i1 %cmp.i.i to i32\r\n %cmp4.i.i = icmp sgt i32 %xor.i.i, %conv3.i.i\r\n %conv1.1.i.i = trunc i32 %g.promoted.i.i to i8\r\n %notsub25.i = add i8 %conv1.1.i.i, -1\r\n %cmp.1.i.i = icmp sgt i8 %notsub25.i, -3\r\n %conv3.1.i.i = zext i1 %cmp.1.i.i to i32\r\n %cmp4.1.i.i = icmp sgt i32 %g.promoted.i.i, %conv3.1.i.i\r\n %notsub26.i = add i8 %conv1.1.i.i, -9\r\n %cmp.i17.i = icmp sgt i8 %notsub26.i, -3\r\n %conv3.i18.i = zext i1 %cmp.i17.i to i32\r\n %cmp4.i19.i = icmp sgt i32 %g.promoted.i.i, %conv3.i18.i\r\n %notsub27.i = add i8 %conv1.i.i, -9\r\n %cmp.1.i22.i = icmp sgt i8 %notsub27.i, -3\r\n %conv3.1.i23.i = zext i1 %cmp.1.i22.i to i32\r\n %cmp4.1.i24.i = icmp sgt i32 %xor.i.i, %conv3.1.i23.i\r\n %1 = and i1 %cmp4.i19.i, %cmp4.1.i24.i\r\n %2 = and i1 %cmp4.i.i, %1\r\n %3 = and i1 %cmp4.1.i.i, %2\r\n ret i1 %3\r\n}\r\n```\r\nOutput:\r\n```\r\ndefine i1 @main(i32 %g.promoted.i.i, i16 %d.promoted.i.i) {\r\nentry:\r\n %0 = and i16 %d.promoted.i.i, 1\r\n %xor.i.i = xor i32 %g.promoted.i.i, 1\r\n %1 = trunc i32 %g.promoted.i.i to i8\r\n %2 = insertelement <2 x i8> poison, i8 %1, i32 0\r\n %3 = trunc i32 %xor.i.i to i8\r\n %4 = insertelement <2 x i8> %2, i8 %3, i32 1\r\n %5 = shufflevector <2 x i8> %4, <2 x i8> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>\r\n %6 = add <4 x i8> %5, <i8 -9, i8 -9, i8 -1, i8 -1>\r\n %7 = icmp sgt <4 x i8> %6, <i8 -3, i8 -3, i8 -3, i8 -3>\r\n %8 = zext <4 x i1> %7 to <4 x i8>\r\n %9 = sext <2 x i8> %4 to <2 x i32>\r\n %10 = shufflevector <2 x i32> %9, <2 x i32> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>\r\n %11 = zext <4 x i8> %8 to <4 x i32>\r\n %12 = icmp sgt <4 x i32> %10, %11\r\n %13 = call i1 @llvm.vector.reduce.and.v4i1(<4 x i1> %12)\r\n ret i1 %13\r\n}\r\n```\r\n\r\ncc @alexey-bataev "
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
155161
|
https://github.com/llvm/llvm-project/issues/155161
|
crash
|
d0246fe1e79c6ea06b6b72f66a71a96a3342aa42
| 2025-08-24T11:50:45 |
[
"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 -O{s,2,3} with \"-mllvm -unroll-threshold=20 -mllvm -inline-threshold=40\" on x86_64-linux-gnu: Assertion `MSSA->dominates(NewDef, FirstDef) && \"Should have dominated the new access\"' failed",
"body": "Compiler Explorer: https://godbolt.org/z/365eofzM4\n\nNote (seems to have fluctuated quite a bit): \n- works: 20.1.0, 19.1.0, 18.1.0, 14.0.0, 12.0.0\n- fails: trunk, 17.1.0, 16.0.0, 15.0.0, 13.0.0\n\n```\n[504] % clangtk -v\nclang version 22.0.0git (https://github.com/llvm/llvm-project.git d13f40f386b4c4db15f232c5cfb105d362b84fe2)\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 -O2 small.c; ./a.out\n[506] % clangtk -O2 -mllvm -unroll-threshold=20 -mllvm -inline-threshold=40 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 -O2 -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/bug177/red2 -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/bug177/red2 -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 -unroll-threshold=20 -mllvm -inline-threshold=40 -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-333e1a.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>,openmp-opt-cgscc,function<eager-inv;no-rerun>(sroa<modify-cfg>,early-cse<memssa>,speculative-execution<only-if-divergent-target>,jump-threading,correlated-propagation,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>,aggressive-instcombine,libcalls-shrinkwrap,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,reassociate,constraint-elimination,loop-mssa(loop-instsimplify,loop-simplifycfg,licm<no-allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-unswitch<no-nontrivial;trivial>),simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>,loop(loop-idiom,indvars,extra-simple-loop-unswitch-passes,loop-deletion,loop-unroll-full),sroa<modify-cfg>,vector-combine,mldst-motion<no-split-footer-bb>,gvn<>,sccp,bdce,instcombine<max-iterations=1;no-verify-fixpoint>,jump-threading,correlated-propagation,adce,memcpyopt,dse,move-auto-init,loop-mssa(licm<allowspeculation>),coro-elide,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>),function-attrs,function(require<should-not-run-function-passes>),coro-split,coro-annotation-elide)),function(invalidate<should-not-run-function-passes>),cgscc(devirt<4>())\" on module \"small.c\"\n4.\tRunning pass \"cgscc(devirt<4>(inline,function-attrs<skip-non-recursive-function-attrs>,openmp-opt-cgscc,function<eager-inv;no-rerun>(sroa<modify-cfg>,early-cse<memssa>,speculative-execution<only-if-divergent-target>,jump-threading,correlated-propagation,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>,aggressive-instcombine,libcalls-shrinkwrap,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,reassociate,constraint-elimination,loop-mssa(loop-instsimplify,loop-simplifycfg,licm<no-allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-unswitch<no-nontrivial;trivial>),simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>,loop(loop-idiom,indvars,extra-simple-loop-unswitch-passes,loop-deletion,loop-unroll-full),sroa<modify-cfg>,vector-combine,mldst-motion<no-split-footer-bb>,gvn<>,sccp,bdce,instcombine<max-iterations=1;no-verify-fixpoint>,jump-threading,correlated-propagation,adce,memcpyopt,dse,move-auto-init,loop-mssa(licm<allowspeculation>),coro-elide,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>),function-attrs,function(require<should-not-run-function-passes>),coro-split,coro-annotation-elide))\" on module \"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<no-nontrivial;trivial>)\" on function \"main\"\n #0 0x0000560af0d98680 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4292680)\n #1 0x0000560af0d9532f llvm::sys::RunSignalHandlers() (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x428f32f)\n #2 0x0000560af0d95482 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #3 0x00007fdeeb8b1520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #4 0x00007fdeeb9059fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #5 0x00007fdeeb9059fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #6 0x00007fdeeb9059fc pthread_kill ./nptl/pthread_kill.c:89:10\n #7 0x00007fdeeb8b1476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x00007fdeeb8977f3 abort ./stdlib/abort.c:81:7\n #9 0x00007fdeeb89771b _nl_load_domain ./intl/loadmsgcat.c:1177:9\n#10 0x00007fdeeb8a8e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n#11 0x0000560aefc8afb4 llvm::MemorySSAUpdater::fixupDefs(llvm::SmallVectorImpl<llvm::WeakVH> const&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3184fb4)\n#12 0x0000560aefc8b18f llvm::MemorySSAUpdater::insertDef(llvm::MemoryDef*, bool) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x318518f)\n#13 0x0000560af0b8d62f (anonymous namespace)::LoopPromoter::doExtraRewritesBeforeFinalDeletion() LICM.cpp:0:0\n#14 0x0000560af0f23fa7 llvm::LoadAndStorePromoter::run(llvm::SmallVectorImpl<llvm::Instruction*> const&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x441dfa7)\n#15 0x0000560af0b8acd8 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+0x4084cd8)\n#16 0x0000560af0b97d73 (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 0x0000560af0b99ba3 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+0x4093ba3)\n#18 0x0000560aede13de6 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+0x130dde6)\n#19 0x0000560af0b9f91f 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 0x0000560af0ba0f10 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+0x409af10)\n#21 0x0000560af0ba12fc 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+0x409b2fc)\n#22 0x0000560af0ba23d1 llvm::FunctionToLoopPassAdaptor::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x409c3d1)\n#23 0x0000560aede13c96 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+0x130dc96)\n#24 0x0000560af06cffa2 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+0x3bc9fa2)\n#25 0x0000560aede13f36 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+0x130df36)\n#26 0x0000560aefb18cf4 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+0x3012cf4)\n#27 0x0000560aede11206 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+0x130b206)\n#28 0x0000560aefb100dc 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+0x300a0dc)\n#29 0x0000560af1e4f9e6 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+0x53499e6)\n#30 0x0000560aefb19fbd 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+0x3013fbd)\n#31 0x0000560af1e4fa36 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+0x5349a36)\n#32 0x0000560aefb14bd7 llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x300ebd7)\n#33 0x0000560aede111b6 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+0x130b1b6)\n#34 0x0000560af06d1ef5 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+0x3bcbef5)\n#35 0x0000560af257a5b8 llvm::ModuleInlinerWrapperPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5a745b8)\n#36 0x0000560af1e4f086 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+0x5349086)\n#37 0x0000560af06d1ef5 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+0x3bcbef5)\n#38 0x0000560af1040a03 (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 0x0000560af1044b33 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+0x453eb33)\n#40 0x0000560af170a75f clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4c0475f)\n#41 0x0000560af317d50c clang::ParseAST(clang::Sema&, bool, bool) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x667750c)\n#42 0x0000560af1a2b1a9 clang::FrontendAction::Execute() (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4f251a9)\n#43 0x0000560af19a6705 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4ea0705)\n#44 0x0000560af1b1cb78 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5016b78)\n#45 0x0000560aed988c78 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xe82c78)\n#46 0x0000560aed97f27a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#47 0x0000560aed983d34 clang_main(int, char**, llvm::ToolContext const&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xe7dd34)\n#48 0x0000560aed84f1ab main (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xd491ab)\n#49 0x00007fdeeb898d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\n#50 0x00007fdeeb898e40 call_init ./csu/../csu/libc-start.c:128:20\n#51 0x00007fdeeb898e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\n#52 0x0000560aed97e9a5 _start (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xe789a5)\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 d13f40f386b4c4db15f232c5cfb105d362b84fe2)\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-7913ae.c\nclangtk: note: diagnostic msg: /tmp/small-7913ae.sh\nclangtk: note: diagnostic msg: \n\n********************\n[507] % cat small.c\nint a, b, e, f, h, i;\nvoid d(int n[]) {\n for (int c = 0; c < 10; c++)\n if (n[c])\n a = 0;\n}\nvoid g(int n[]) {\n for (int c = 0; c < 4; c++)\n if (n[c])\n return;\n __builtin_abort();\n}\nint main() {\n int k[2] = {0,0};\n k[f] = 0;\n while (h)\n d((int[]){k[1]});\n if (a) {\n int j = i;\n if (i < 0)\n goto l;\n goto m;\n l:\n j = 0;\n if (e) {\n m:\n if (e)\n goto l;\n }\n g((int[]){j});\n }\n}\n```",
"author": "zhendongsu",
"labels": [
"loopoptim",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
107051
|
https://github.com/llvm/llvm-project/issues/107051
|
crash
|
fcb7b390ccd5b4cfc71f13b5e16a846f3f400c10
| 2024-09-03T06:19:24 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "3bd161e98d89d31696002994771b7761f1c74859",
"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": [
[
1290,
1297
],
[
6194,
6199
],
[
6206,
6219
],
[
6229,
6248
]
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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::setVectorizedCallDecision",
"collectUniformsAndScalars"
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 3bd161e98d89d31696002994771b7761f1c74859
Author: Florian Hahn <flo@fhahn.com>
Date: Tue Sep 3 21:06:31 2024 +0100
[LV] Honor forced scalars in setVectorizedCallDecision.
Similarly to dd94537b4, setVectorizedCallDecision also did not consider
ForcedScalars. This lead to VPlans not reflecting the decision by the
legacy cost model (cost computation would use scalar cost, VPlan would
have VPWidenCallRecipe).
To fix this, check if the call has been forced to scalar in
setVectorizedCallDecision.
Note that this requires moving setVectorizedCallDecision after
collectLoopUniforms (which sets ForcedScalars). collectLoopUniforms does
not depend on call decisions and can safely be moved.
Fixes https://github.com/llvm/llvm-project/issues/107051.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 17050b2b433c..0200525a718d 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1290,8 +1290,8 @@ public:
if (VF.isScalar() || Uniforms.contains(VF))
return;
setCostBasedWideningDecision(VF);
- setVectorizedCallDecision(VF);
collectLoopUniforms(VF);
+ setVectorizedCallDecision(VF);
collectLoopScalars(VF);
}
@@ -6194,6 +6194,7 @@ void LoopVectorizationCostModel::setVectorizedCallDecision(ElementCount VF) {
assert(!VF.isScalar() &&
"Trying to set a vectorization decision for a scalar VF");
+ auto ForcedScalar = ForcedScalars.find(VF);
for (BasicBlock *BB : TheLoop->blocks()) {
// For each instruction in the old loop.
for (Instruction &I : *BB) {
@@ -6206,14 +6207,37 @@ void LoopVectorizationCostModel::setVectorizedCallDecision(ElementCount VF) {
InstructionCost VectorCost = InstructionCost::getInvalid();
InstructionCost IntrinsicCost = InstructionCost::getInvalid();
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
-
Function *ScalarFunc = CI->getCalledFunction();
Type *ScalarRetTy = CI->getType();
SmallVector<Type *, 4> Tys, ScalarTys;
- bool MaskRequired = Legal->isMaskRequired(CI);
for (auto &ArgOp : CI->args())
ScalarTys.push_back(ArgOp->getType());
+ // Estimate cost of scalarized vector call. The source operands are
+ // assumed to be vectors, so we need to extract individual elements from
+ // there, execute VF scalar calls, and then gather the result into the
+ // vector return value.
+ InstructionCost ScalarCallCost =
+ TTI.getCallInstrCost(ScalarFunc, ScalarRetTy, ScalarTys, CostKind);
+
+ // Compute costs of unpacking argument values for the scalar calls and
+ // packing the return values to a vector.
+ InstructionCost ScalarizationCost =
+ getScalarizationOverhead(CI, VF, CostKind);
+
+ ScalarCost = ScalarCallCost * VF.getKnownMinValue() + ScalarizationCost;
+ // Honor ForcedScalars decision.
+ // TODO: For calls, it might still be more profitable to widen. Use
+ // VPlan-based cost model to compare different options.
+ if (VF.isVector() && ForcedScalar != ForcedScalars.end() &&
+ ForcedScalar->second.contains(CI)) {
+ setCallWideningDecision(CI, VF, CM_Scalarize, nullptr,
+ Intrinsic::not_intrinsic, std::nullopt,
+ ScalarCost);
+ continue;
+ }
+
+ bool MaskRequired = Legal->isMaskRequired(CI);
// Compute corresponding vector type for return value and arguments.
Type *RetTy = ToVectorTy(ScalarRetTy, VF);
for (Type *ScalarTy : ScalarTys)
@@ -6229,20 +6253,6 @@ void LoopVectorizationCostModel::setVectorizedCallDecision(ElementCount VF) {
continue;
}
- // Estimate cost of scalarized vector call. The source operands are
- // assumed to be vectors, so we need to extract individual elements from
- // there, execute VF scalar calls, and then gather the result into the
- // vector return value.
- InstructionCost ScalarCallCost =
- TTI.getCallInstrCost(ScalarFunc, ScalarRetTy, ScalarTys, CostKind);
-
- // Compute costs of unpacking argument values for the scalar calls and
- // packing the return values to a vector.
- InstructionCost ScalarizationCost =
- getScalarizationOverhead(CI, VF, CostKind);
-
- ScalarCost = ScalarCallCost * VF.getKnownMinValue() + ScalarizationCost;
-
// Find the cost of vectorizing the call, if we can find a suitable
// vector variant of the function.
bool UsesMask = false;
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/call-costs.ll",
"commands": [
"opt -p loop-vectorize -S %s"
],
"tests": [
{
"test_name": "call_forced_scalar",
"test_body": "target triple = \"arm64-apple-macosx11.0.0\"\n\ndefine void @call_forced_scalar(ptr %src.1, ptr %src.2, 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 %0 = load i32, ptr %src.1, align 4\n %smax = tail call i32 @llvm.smax.i32(i32 %0, i32 0)\n %umin = tail call i32 @llvm.umin.i32(i32 %smax, i32 1)\n %umin.ext = zext i32 %umin to i64\n %gep.src.2 = getelementptr i8, ptr %src.2, i64 %umin.ext\n %1 = load i8, ptr %gep.src.2, align 1\n %l.ext = zext i8 %1 to i32\n %mul = mul i32 3, %l.ext\n store i32 %mul, ptr %dst.1, align 4\n %gep.dst.2 = getelementptr i32, ptr %dst.2, i64 %iv\n store i32 0, ptr %gep.dst.2, 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\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.smax.i32(i32, i32) #0\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.umin.i32(i32, i32) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "call_scalarized",
"test_body": "target triple = \"arm64-apple-macosx11.0.0\"\n\ndefine void @call_scalarized(ptr noalias %src, ptr noalias %dst, double %0) {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 100, %entry ], [ %iv.next, %loop.latch ]\n %iv.next = add i64 %iv, -1\n %gep.src = getelementptr double, ptr %src, i64 %iv.next\n %l = load double, ptr %gep.src, align 8\n %cmp295 = fcmp ugt double %0, 0.000000e+00\n %cmp299 = fcmp ugt double %l, 0.000000e+00\n %or.cond = or i1 %cmp295, %cmp299\n br i1 %or.cond, label %loop.latch, label %then\n\nthen: ; preds = %loop.header\n %sqrt = call double @llvm.sqrt.f64(double %l)\n %gep.dst = getelementptr double, ptr %dst, i64 %iv.next\n store double %sqrt, ptr %gep.dst, align 8\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n %tobool.not = icmp eq i64 %iv.next, 0\n br i1 %tobool.not, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare double @llvm.sqrt.f64(double) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "fshl_operand_first_order_recurrence",
"test_body": "target triple = \"arm64-apple-macosx11.0.0\"\n\ndefine void @fshl_operand_first_order_recurrence(ptr %dst, ptr noalias %src) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %recur = phi i64 [ 0, %entry ], [ %l, %loop ]\n %gep.src = getelementptr inbounds i64, ptr %src, i64 %iv\n %l = load i64, ptr %gep.src, align 8\n %or = tail call i64 @llvm.fshl.i64(i64 1, i64 %recur, i64 1)\n %gep.dst = getelementptr inbounds i64, ptr %dst, i64 %iv\n store i64 %or, ptr %gep.dst, align 8\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv, 100\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 i64 @llvm.fshl.i64(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": "powi_call",
"test_body": "target triple = \"arm64-apple-macosx11.0.0\"\n\ndefine void @powi_call(ptr %P) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep = getelementptr inbounds double, ptr %P, i64 %iv\n %l = load double, ptr %gep, align 8\n %powi = tail call double @llvm.powi.f64.i32(double %l, i32 3)\n store double %powi, ptr %gep, 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\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare double @llvm.powi.f64.i32(double, i32) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[clang] Assertion failed in Vectorize",
"body": "I compiled this code with -Os and a crash appeared in assertion failure:\r\n\r\n```c\r\n#include <stdint.h>\r\nint32_t *c;\r\nint8_t ****d;\r\nuint64_t g;\r\nint a();\r\nlong b(long, long h, long p3) {\r\n long e;\r\n int f = 0;\r\n if (h) {\r\n e = h;\r\n f = 1;\r\n }\r\n if (e > p3)\r\n f = 2;\r\n switch (f) {\r\n case 1:\r\n e++;\r\n case 2:\r\n e--;\r\n }\r\n if (e < h)\r\n e = h;\r\n return e;\r\n}\r\n\r\nuint8_t div_func_uint8_t_u_u(uint8_t ui1, uint8_t ui2)\r\n{\r\n return (ui1 / ui2);\r\n}\r\n\r\nuint64_t j() {\r\n uint16_t k[8];\r\n int i;\r\n for (i = 0; *c + ****d + (int)g + i < 8; i++)\r\n k[b(0, g, 0)] = 6;\r\n *c = div_func_uint8_t_u_u(k[6], a());\r\n}\r\n```\r\n\r\nThe crash is:\r\n```\r\nclang: /root/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7369: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\n```\r\n\r\nDetails can be found here: https://godbolt.org/z/T81adKPY5\r\n\r\n",
"author": "cardigan1008",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "patrick-rivos",
"body": "Unreduced LLVM IR:\r\n```llvm ir\r\n; ModuleID = '/app/example.c'\r\nsource_filename = \"/app/example.c\"\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\n@c = dso_local local_unnamed_addr global ptr null, align 8\r\n@d = dso_local local_unnamed_addr global ptr null, align 8\r\n@g = dso_local local_unnamed_addr global i64 0, align 8\r\n\r\n; Function Attrs: mustprogress nofree norecurse nosync nounwind optsize willreturn memory(none) uwtable\r\ndefine dso_local i64 @b(i64 noundef %0, i64 noundef %h, i64 noundef %p3) local_unnamed_addr #0 {\r\nentry:\r\n %tobool.not = icmp ne i64 %h, 0\r\n %spec.select = zext i1 %tobool.not to i32\r\n %cmp = icmp sgt i64 %h, %p3\r\n %f.1 = select i1 %cmp, i32 2, i32 %spec.select\r\n switch i32 %f.1, label %sw.epilog [\r\n i32 1, label %sw.bb\r\n i32 2, label %sw.bb3\r\n ]\r\n\r\nsw.bb: ; preds = %entry\r\n %inc = add nsw i64 %h, 1\r\n br label %sw.bb3\r\n\r\nsw.bb3: ; preds = %entry, %sw.bb\r\n %e.1 = phi i64 [ %h, %entry ], [ %inc, %sw.bb ]\r\n %dec = add nsw i64 %e.1, -1\r\n br label %sw.epilog\r\n\r\nsw.epilog: ; preds = %sw.bb3, %entry\r\n %e.2 = phi i64 [ %h, %entry ], [ %dec, %sw.bb3 ]\r\n %spec.select14 = tail call i64 @llvm.smax.i64(i64 %e.2, i64 %h)\r\n ret i64 %spec.select14\r\n}\r\n\r\n; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)\r\ndeclare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1\r\n\r\n; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)\r\ndeclare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1\r\n\r\n; Function Attrs: mustprogress nofree norecurse nosync nounwind optsize willreturn memory(none) uwtable\r\ndefine dso_local noundef zeroext i8 @div_func_uint8_t_u_u(i8 noundef zeroext %ui1, i8 noundef zeroext %ui2) local_unnamed_addr #0 {\r\nentry:\r\n %0 = udiv i8 %ui1, %ui2\r\n ret i8 %0\r\n}\r\n\r\n; Function Attrs: nounwind optsize uwtable\r\ndefine dso_local i64 @j() local_unnamed_addr #2 {\r\nentry:\r\n %k = alloca [8 x i16], align 16\r\n call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %k) #5\r\n %0 = load ptr, ptr @c, align 8, !tbaa !6\r\n %1 = load i32, ptr %0, align 4, !tbaa !10\r\n %2 = load ptr, ptr @d, align 8, !tbaa !6\r\n %3 = load ptr, ptr %2, align 8, !tbaa !6\r\n %4 = load ptr, ptr %3, align 8, !tbaa !6\r\n %5 = load ptr, ptr %4, align 8, !tbaa !6\r\n %6 = load i8, ptr %5, align 1, !tbaa !12\r\n %conv = sext i8 %6 to i32\r\n %7 = load i64, ptr @g, align 8, !tbaa !13\r\n %conv1 = trunc i64 %7 to i32\r\n %invariant.op = add i32 %conv, %conv1\r\n %add3.reass12 = add i32 %1, %invariant.op\r\n %cmp13 = icmp slt i32 %add3.reass12, 8\r\n br i1 %cmp13, label %for.body.lr.ph, label %for.end\r\n\r\nfor.body.lr.ph: ; preds = %entry\r\n %tobool.not.i = icmp ne i64 %7, 0\r\n %spec.select.i = zext i1 %tobool.not.i to i32\r\n %cmp.i = icmp sgt i64 %7, 0\r\n %f.1.i = select i1 %cmp.i, i32 2, i32 %spec.select.i\r\n %inc.i = add nsw i64 %7, 1\r\n br label %for.body\r\n\r\nfor.body: ; preds = %for.body.lr.ph, %b.exit\r\n %i.014 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %b.exit ]\r\n switch i32 %f.1.i, label %b.exit [\r\n i32 1, label %sw.bb.i\r\n i32 2, label %sw.bb3.i\r\n ]\r\n\r\nsw.bb.i: ; preds = %for.body\r\n br label %sw.bb3.i\r\n\r\nsw.bb3.i: ; preds = %sw.bb.i, %for.body\r\n %e.1.i = phi i64 [ %7, %for.body ], [ %inc.i, %sw.bb.i ]\r\n %dec.i = add nsw i64 %e.1.i, -1\r\n br label %b.exit\r\n\r\nb.exit: ; preds = %for.body, %sw.bb3.i\r\n %e.2.i = phi i64 [ %7, %for.body ], [ %dec.i, %sw.bb3.i ]\r\n %spec.select14.i = tail call i64 @llvm.smax.i64(i64 %e.2.i, i64 %7)\r\n %arrayidx = getelementptr inbounds [8 x i16], ptr %k, i64 0, i64 %spec.select14.i\r\n store i16 6, ptr %arrayidx, align 2, !tbaa !15\r\n %inc = add nuw nsw i32 %i.014, 1\r\n %add = add i32 %1, %inc\r\n %add3.reass = add i32 %add, %invariant.op\r\n %cmp = icmp slt i32 %add3.reass, 8\r\n br i1 %cmp, label %for.body, label %for.end.loopexit, !llvm.loop !17\r\n\r\nfor.end.loopexit: ; preds = %b.exit\r\n %arrayidx5.phi.trans.insert = getelementptr inbounds i8, ptr %k, i64 12\r\n %.pre = load i16, ptr %arrayidx5.phi.trans.insert, align 4, !tbaa !15\r\n %8 = trunc i16 %.pre to i8\r\n br label %for.end\r\n\r\nfor.end: ; preds = %for.end.loopexit, %entry\r\n %conv6 = phi i8 [ %8, %for.end.loopexit ], [ undef, %entry ]\r\n %call7 = tail call i32 (...) @a() #6\r\n %conv8 = trunc i32 %call7 to i8\r\n %9 = udiv i8 %conv6, %conv8\r\n %conv10 = zext i8 %9 to i32\r\n %10 = load ptr, ptr @c, align 8, !tbaa !6\r\n store i32 %conv10, ptr %10, align 4, !tbaa !10\r\n call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %k) #5\r\n ret i64 undef\r\n}\r\n\r\n; Function Attrs: optsize\r\ndeclare i32 @a(...) local_unnamed_addr #3\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\r\ndeclare i64 @llvm.smax.i64(i64, i64) #4\r\n\r\nattributes #0 = { mustprogress nofree norecurse nosync nounwind optsize willreturn memory(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\" }\r\nattributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }\r\nattributes #2 = { nounwind optsize uwtable \"min-legal-vector-width\"=\"0\" \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"x86-64\" \"target-features\"=\"+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87\" \"tune-cpu\"=\"generic\" }\r\nattributes #3 = { optsize \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"x86-64\" \"target-features\"=\"+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87\" \"tune-cpu\"=\"generic\" }\r\nattributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\r\nattributes #5 = { nounwind }\r\nattributes #6 = { nounwind optsize }\r\n\r\n!llvm.module.flags = !{!0, !1, !2, !3, !4}\r\n!llvm.ident = !{!5}\r\n\r\n!0 = !{i32 7, !\"Dwarf Version\", i32 4}\r\n!1 = !{i32 1, !\"wchar_size\", i32 4}\r\n!2 = !{i32 8, !\"PIC Level\", i32 2}\r\n!3 = !{i32 7, !\"PIE Level\", i32 2}\r\n!4 = !{i32 7, !\"uwtable\", i32 2}\r\n!5 = !{!\"clang version 20.0.0git (https://github.com/llvm/llvm-project.git b6597f521d8a040f2b9fee54b3f89c380de8e432)\"}\r\n!6 = !{!7, !7, i64 0}\r\n!7 = !{!\"any pointer\", !8, i64 0}\r\n!8 = !{!\"omnipotent char\", !9, i64 0}\r\n!9 = !{!\"Simple C/C++ TBAA\"}\r\n!10 = !{!11, !11, i64 0}\r\n!11 = !{!\"int\", !8, i64 0}\r\n!12 = !{!8, !8, i64 0}\r\n!13 = !{!14, !14, i64 0}\r\n!14 = !{!\"long\", !8, i64 0}\r\n!15 = !{!16, !16, i64 0}\r\n!16 = !{!\"short\", !8, i64 0}\r\n!17 = distinct !{!17, !18}\r\n!18 = !{!\"llvm.loop.mustprogress\"}\r\n```\r\n\r\nhttps://godbolt.org/z/Yo1crEjGG\r\n\r\ncc @fhahn "
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
119002
|
https://github.com/llvm/llvm-project/issues/119002
|
crash
|
6797b0f0c002c9f3dda7a2b502ddf33e2c8f6777
| 2024-12-06T17:29:17 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "376dad72abb4960cd93e37e3e98de3950b5c3dfe",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
16215,
16220
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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 376dad72abb4960cd93e37e3e98de3950b5c3dfe
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Fri Dec 6 13:39:05 2024 -0800
[SLP]Move resulting vector before inert point, if the late generated buildvector fully matched
If the perfect diamond match was detected for the postponed buildvectors
and the vector for the previous node comes after the current node, need
to move the vector register before the current inserting point to
prevent compiler crash.
Fixes #119002
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 51841a842ce0..50590e51ae0e 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -16215,6 +16215,11 @@ BoUpSLP::vectorizeTree(const ExtraValueToDebugLocsMap &ExternallyUsedValues,
}
Builder.SetCurrentDebugLocation(UserI->getDebugLoc());
Value *Vec = vectorizeTree(TE, /*PostponedPHIs=*/false);
+ if (auto *VecI = dyn_cast<Instruction>(Vec);
+ VecI && VecI->getParent() == Builder.GetInsertBlock() &&
+ Builder.GetInsertPoint()->comesBefore(VecI))
+ VecI->moveBeforePreserving(*Builder.GetInsertBlock(),
+ Builder.GetInsertPoint());
if (Vec->getType() != PrevVec->getType()) {
assert(Vec->getType()->isIntOrIntVectorTy() &&
PrevVec->getType()->isIntOrIntVectorTy() &&
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/perfect-matched-reused-bv.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -mattr=+avx512f < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define void @test() {\nbb:\n br label %bb1\n\nbb1: ; preds = %bb4, %bb\n %phi = phi i32 [ 0, %bb ], [ %add6, %bb4 ]\n %phi2 = phi i32 [ 0, %bb ], [ %add, %bb4 ]\n %or = or i32 %phi2, 0\n %or3 = or i32 %phi, 0\n br i1 false, label %bb7, label %bb4\n\nbb4: ; preds = %bb1\n %add = add i32 0, 0\n %add5 = add i32 0, 0\n %add6 = add i32 %phi, 0\n br i1 false, label %bb7, label %bb1\n\nbb7: ; preds = %bb4, %bb1\n %phi8 = phi i32 [ %or, %bb1 ], [ %add5, %bb4 ]\n %phi9 = phi i32 [ %or3, %bb1 ], [ %add6, %bb4 ]\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Instruction does not dominate all uses! LLVM ERROR: Broken module found, compilation aborted! (yet another)",
"body": "To reproduce run the test below with -passes slp-vectorizer\n```\n; ModuleID = './reduced.ll'\nsource_filename = \"./reduced.ll\"\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @wombat() #0 gc \"statepoint-example\" {\nbb:\n br label %bb1\n\nbb1: ; preds = %bb4, %bb\n %phi = phi i32 [ 0, %bb ], [ %add6, %bb4 ]\n %phi2 = phi i32 [ 0, %bb ], [ %add, %bb4 ]\n %or = or i32 %phi2, 0\n %or3 = or i32 %phi, 0\n br i1 false, label %bb7, label %bb4\n\nbb4: ; preds = %bb1\n %add = add i32 0, 0\n %add5 = add i32 0, 0\n %add6 = add i32 %phi, 0\n br i1 false, label %bb7, label %bb1\n\nbb7: ; preds = %bb4, %bb1\n %phi8 = phi i32 [ %or, %bb1 ], [ %add5, %bb4 ]\n %phi9 = phi i32 [ %or3, %bb1 ], [ %add6, %bb4 ]\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+prfchw,-cldemote,+avx,+aes,+sahf,+pclmul,-xop,+crc32,-amx-fp8,+xsaves,-avx512fp16,-usermsr,-sm4,-egpr,+sse4.1,-avx512ifma,+xsave,+sse4.2,-tsxldtrk,-sm3,-ptwrite,-widekl,-movrs,+invpcid,+64bit,+xsavec,-avx10.1-512,-avx512vpopcntdq,+cmov,-avx512vp2intersect,+avx512cd,+movbe,-avxvnniint8,-ccmp,-amx-int8,-kl,-avx10.1-256,+evex512,-avxvnni,+rtm,+adx,+avx2,-hreset,-movdiri,-serialize,-sha512,-vpclmulqdq,+avx512vl,-uintr,-cf,+clflushopt,-raoint,-cmpccxadd,+bmi,-amx-tile,+sse,-avx10.2-256,-gfni,-avxvnniint16,-amx-fp16,-zu,-ndd,+xsaveopt,+rdrnd,+avx512f,-amx-bf16,-avx512bf16,-avx512vnni,-push2pop2,+cx8,+avx512bw,+sse3,+pku,-nf,-amx-tf32,-amx-avx512,+fsgsbase,-clzero,-mwaitx,-lwp,+lzcnt,-sha,-movdir64b,-ppx,-wbnoinvd,-enqcmd,-amx-transpose,-avx10.2-512,-avxneconvert,-tbm,-pconfig,-amx-complex,+ssse3,+cx16,+bmi2,+fma,+popcnt,-avxifma,+f16c,-avx512bitalg,-rdpru,+clwb,+mmx,+sse2,+rdseed,-avx512vbmi2,-prefetchi,-amx-movrs,-rdpid,-fma4,-avx512vbmi,-shstk,-vaes,-waitpkg,-sgx,+fxsr,+avx512dq,-sse4a,-avx512f\" }\n```\nReproducer: https://godbolt.org/z/Kqddzds1c\n\nStack dump:\n```\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes slp-vectorizer <source>\n1.\tRunning pass \"verify\" on module \"<source>\"\n #0 0x00000000051b4a48 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x51b4a48)\n #1 0x00000000051b243c SignalHandler(int) Signals.cpp:0:0\n #2 0x00007c6fb5442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007c6fb54969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007c6fb5442476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007c6fb54287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x00000000007e2469 llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0\n #7 0x00000000050f32d8 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x50f32d8)\n #8 0x0000000004ff2498 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4ff2498)\n #9 0x00000000009057ae llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9057ae)\n#10 0x0000000004fb1d10 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4fb1d10)\n#11 0x0000000000910d7a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x910d7a)\n#12 0x00000000009033f9 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9033f9)\n#13 0x00007c6fb5429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#14 0x00007c6fb5429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#15 0x00000000008facde _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8facde)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```",
"author": "TatyanaDoubts",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
110382
|
https://github.com/llvm/llvm-project/issues/110382
|
crash
|
72a957ba4c8ef059f1572f6d4ee0cba8dc615268
| 2024-09-28T19:00:52 |
[
"llvm/test/Transforms/VectorCombine"
] |
{
"fix_commit": "c136d3237a3c6230cfe1ab3f0f6790f903c54a27",
"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": [
[
1984,
2016
],
[
2038,
2044
]
],
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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::foldShuffleToIdentity"
],
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 c136d3237a3c6230cfe1ab3f0f6790f903c54a27
Author: David Green <david.green@arm.com>
Date: Wed Oct 9 16:20:03 2024 +0100
[VectorCombine] Do not try to operate on OperandBundles. (#111635)
This bails out if we see an intrinsic with an operand bundle on it, to
make sure we don't process the bundles incorrectly.
Fixes #110382.
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index a2ab5d966640..627edb680dfa 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -1984,33 +1984,35 @@ bool VectorCombine::foldShuffleToIdentity(Instruction &I) {
// We need each element to be the same type of value, and check that each
// element has a single use.
- if (all_of(drop_begin(Item), [Item](InstLane IL) {
- Value *FrontV = Item.front().first->get();
- if (!IL.first)
- return true;
- Value *V = IL.first->get();
- if (auto *I = dyn_cast<Instruction>(V); I && !I->hasOneUse())
- return false;
- if (V->getValueID() != FrontV->getValueID())
- return false;
- if (auto *CI = dyn_cast<CmpInst>(V))
- if (CI->getPredicate() != cast<CmpInst>(FrontV)->getPredicate())
- return false;
- if (auto *CI = dyn_cast<CastInst>(V))
- if (CI->getSrcTy() != cast<CastInst>(FrontV)->getSrcTy())
- return false;
- if (auto *SI = dyn_cast<SelectInst>(V))
- if (!isa<VectorType>(SI->getOperand(0)->getType()) ||
- SI->getOperand(0)->getType() !=
- cast<SelectInst>(FrontV)->getOperand(0)->getType())
- return false;
- if (isa<CallInst>(V) && !isa<IntrinsicInst>(V))
- return false;
- auto *II = dyn_cast<IntrinsicInst>(V);
- return !II || (isa<IntrinsicInst>(FrontV) &&
- II->getIntrinsicID() ==
- cast<IntrinsicInst>(FrontV)->getIntrinsicID());
- })) {
+ auto CheckLaneIsEquivalentToFirst = [Item](InstLane IL) {
+ Value *FrontV = Item.front().first->get();
+ if (!IL.first)
+ return true;
+ Value *V = IL.first->get();
+ if (auto *I = dyn_cast<Instruction>(V); I && !I->hasOneUse())
+ return false;
+ if (V->getValueID() != FrontV->getValueID())
+ return false;
+ if (auto *CI = dyn_cast<CmpInst>(V))
+ if (CI->getPredicate() != cast<CmpInst>(FrontV)->getPredicate())
+ return false;
+ if (auto *CI = dyn_cast<CastInst>(V))
+ if (CI->getSrcTy() != cast<CastInst>(FrontV)->getSrcTy())
+ return false;
+ if (auto *SI = dyn_cast<SelectInst>(V))
+ if (!isa<VectorType>(SI->getOperand(0)->getType()) ||
+ SI->getOperand(0)->getType() !=
+ cast<SelectInst>(FrontV)->getOperand(0)->getType())
+ return false;
+ if (isa<CallInst>(V) && !isa<IntrinsicInst>(V))
+ return false;
+ auto *II = dyn_cast<IntrinsicInst>(V);
+ return !II || (isa<IntrinsicInst>(FrontV) &&
+ II->getIntrinsicID() ==
+ cast<IntrinsicInst>(FrontV)->getIntrinsicID() &&
+ !II->hasOperandBundles());
+ };
+ if (all_of(drop_begin(Item), CheckLaneIsEquivalentToFirst)) {
// Check the operator is one that we support.
if (isa<BinaryOperator, CmpInst>(FrontU)) {
// We exclude div/rem in case they hit UB from poison lanes.
@@ -2038,7 +2040,8 @@ bool VectorCombine::foldShuffleToIdentity(Instruction &I) {
Worklist.push_back(generateInstLaneVectorFromOperand(Item, 2));
continue;
} else if (auto *II = dyn_cast<IntrinsicInst>(FrontU);
- II && isTriviallyVectorizable(II->getIntrinsicID())) {
+ II && isTriviallyVectorizable(II->getIntrinsicID()) &&
+ !II->hasOperandBundles()) {
for (unsigned Op = 0, E = II->getNumOperands() - 1; Op < E; Op++) {
if (isVectorIntrinsicWithScalarOpAtArg(II->getIntrinsicID(), Op)) {
if (!all_of(drop_begin(Item), [Item, Op](InstLane &IL) {
|
[
{
"file": "llvm/test/Transforms/VectorCombine/AArch64/shuffletoidentity.ll",
"commands": [
"opt -passes=vector-combine -S %s"
],
"tests": [
{
"test_name": "add_same_operands",
"test_body": "target triple = \"aarch64\"\n\ndefine <4 x i32> @add_same_operands(<4 x i32> %x) {\n %shuf = shufflevector <4 x i32> %x, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %add = add <4 x i32> %shuf, %shuf\n %revshuf = shufflevector <4 x i32> %add, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n ret <4 x i32> %revshuf\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "extrause_add_same_operands",
"test_body": "target triple = \"aarch64\"\n\ndefine <4 x i32> @extrause_add_same_operands(<4 x i32> %x) {\n %shuf = shufflevector <4 x i32> %x, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %add = add <4 x i32> %shuf, %shuf\n %revshuf = shufflevector <4 x i32> %add, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %add2 = add <4 x i32> %shuf, %revshuf\n ret <4 x i32> %add2\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "callinst2",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x half> @callinst2(<8 x half> %a) {\n %ab = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = call <4 x half> @llvm.fabs.v4f16(<4 x half> %at)\n %abb = call <4 x half> @othercall(<4 x half> %ab)\n %r = shufflevector <4 x half> %abt, <4 x half> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x half> %r\n}\n\ndeclare <4 x half> @othercall(<4 x half>)\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x half> @llvm.fabs.v4f16(<4 x half>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "poison_intrinsic",
"test_body": "target triple = \"aarch64\"\n\ndefine <4 x i32> @poison_intrinsic(<2 x i16> %l256) {\n %l266 = call <2 x i16> @llvm.abs.v2i16(<2 x i16> %l256, i1 false)\n %l267 = zext <2 x i16> %l266 to <2 x i32>\n %l271 = shufflevector <2 x i32> %l267, <2 x i32> poison, <4 x i32> <i32 0, i32 1, i32 poison, i32 poison>\n ret <4 x i32> %l271\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <2 x i16> @llvm.abs.v2i16(<2 x i16>, i1 immarg) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "splattwice",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x half> @splattwice(<8 x half> %a, <8 x half> %b) {\n %as = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> zeroinitializer\n %bs = shufflevector <8 x half> %b, <8 x half> poison, <4 x i32> zeroinitializer\n %ab1 = fadd <4 x half> %as, %bs\n %ab2 = fadd <4 x half> %as, %bs\n %r = shufflevector <4 x half> %ab1, <4 x half> %ab2, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x half> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "fadd_mismatched_types",
"test_body": "target triple = \"aarch64\"\n\ndefine <4 x float> @fadd_mismatched_types(<4 x float> %x, <4 x float> %y) {\n %shuf.x = shufflevector <4 x float> %x, <4 x float> poison, <2 x i32> <i32 0, i32 2>\n %shuf.y = shufflevector <4 x float> %y, <4 x float> poison, <2 x i32> <i32 1, i32 3>\n %fadd = fadd fast <2 x float> %shuf.x, %shuf.y\n %extshuf = shufflevector <2 x float> %fadd, <2 x float> poison, <4 x i32> <i32 0, i32 2, i32 1, i32 3>\n ret <4 x float> %extshuf\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "intrinsics_minmax",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i8> @intrinsics_minmax(<8 x i8> %a, <8 x i8> %b) {\n %ab = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %bb = shufflevector <8 x i8> %b, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %bt = shufflevector <8 x i8> %b, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = call <4 x i8> @llvm.smin.v4i8(<4 x i8> %at, <4 x i8> %bt)\n %abb = call <4 x i8> @llvm.smin.v4i8(<4 x i8> %ab, <4 x i8> %bb)\n %abt1 = call <4 x i8> @llvm.smax.v4i8(<4 x i8> %abt, <4 x i8> %bt)\n %abb1 = call <4 x i8> @llvm.smax.v4i8(<4 x i8> %abb, <4 x i8> %bb)\n %abt2 = call <4 x i8> @llvm.umin.v4i8(<4 x i8> %abt1, <4 x i8> %bt)\n %abb2 = call <4 x i8> @llvm.umin.v4i8(<4 x i8> %abb1, <4 x i8> %bb)\n %abt3 = call <4 x i8> @llvm.umax.v4i8(<4 x i8> %abt2, <4 x i8> %bt)\n %abb3 = call <4 x i8> @llvm.umax.v4i8(<4 x i8> %abb2, <4 x i8> %bb)\n %r = shufflevector <4 x i8> %abt3, <4 x i8> %abb3, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i8> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x i8> @llvm.smax.v4i8(<4 x i8>, <4 x i8>) #0\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x i8> @llvm.smin.v4i8(<4 x i8>, <4 x i8>) #0\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x i8> @llvm.umax.v4i8(<4 x i8>, <4 x i8>) #0\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x i8> @llvm.umin.v4i8(<4 x i8>, <4 x i8>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "constantdiff2",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i8> @constantdiff2(<8 x i8> %a) {\n %ab = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = add <4 x i8> %at, <i8 1, i8 2, i8 3, i8 4>\n %abb = add <4 x i8> %ab, <i8 1, i8 2, i8 3, i8 4>\n %r = shufflevector <4 x i8> %abt, <4 x i8> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i8> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "fcmpsel",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i8> @fcmpsel(<8 x half> %a, <8 x half> %b, <8 x i8> %c, <8 x i8> %d) {\n %ab = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %bb = shufflevector <8 x half> %b, <8 x half> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %bt = shufflevector <8 x half> %b, <8 x half> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %cb = shufflevector <8 x i8> %c, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %ct = shufflevector <8 x i8> %c, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %db = shufflevector <8 x i8> %d, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %dt = shufflevector <8 x i8> %d, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt1 = fcmp olt <4 x half> %at, %bt\n %abb1 = fcmp olt <4 x half> %ab, %bb\n %abt = select <4 x i1> %abt1, <4 x i8> %ct, <4 x i8> %dt\n %abb = select <4 x i1> %abb1, <4 x i8> %cb, <4 x i8> %db\n %r = shufflevector <4 x i8> %abt, <4 x i8> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i8> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "inner_shuffle",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i8> @inner_shuffle(<8 x i8> %a, <8 x i8> %b, <8 x i8> %c) {\n %ab = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>\n %at = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 4, i32 5, i32 6, i32 7>\n %bb = shufflevector <8 x i8> %b, <8 x i8> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>\n %bt = shufflevector <8 x i8> %b, <8 x i8> poison, <4 x i32> <i32 4, i32 5, i32 6, i32 7>\n %cs = shufflevector <8 x i8> %c, <8 x i8> poison, <4 x i32> zeroinitializer\n %abt = mul <4 x i8> %at, %bt\n %abb = mul <4 x i8> %ab, %bb\n %abt2 = shufflevector <4 x i8> %abt, <4 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %abb2 = shufflevector <4 x i8> %abb, <4 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %abt3 = add <4 x i8> %abt2, %cs\n %abb3 = add <4 x i8> %abb2, %cs\n %r = shufflevector <4 x i8> %abt3, <4 x i8> %abb3, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i8> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "zext_types",
"test_body": "target triple = \"aarch64\"\n\ndefine void @zext_types(<8 x i16> %a, <8 x i32> %b, ptr %p) {\n %ab = shufflevector <8 x i16> %a, <8 x i16> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>\n %at = shufflevector <8 x i32> %b, <8 x i32> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7>\n %ab1 = zext <4 x i16> %ab to <4 x i64>\n %at1 = zext <4 x i32> %at to <4 x i64>\n %r = shufflevector <4 x i64> %ab1, <4 x i64> %at1, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>\n store <8 x i64> %r, ptr %p, align 64\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "add_different_operands",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i8> @add_different_operands(<8 x i8> %a, <8 x i8> %b) {\n %ab = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %bb = shufflevector <8 x i8> %b, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %bt = shufflevector <8 x i8> %b, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = add <4 x i8> %at, %bt\n %abb = add <4 x i8> %ab, %bb\n %r = shufflevector <4 x i8> %abt, <4 x i8> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i8> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "constantdiff",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i8> @constantdiff(<8 x i8> %a) {\n %ab = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = add <4 x i8> %at, <i8 1, i8 2, i8 3, i8 4>\n %abb = add <4 x i8> %ab, <i8 5, i8 6, i8 7, i8 8>\n %r = shufflevector <4 x i8> %abt, <4 x i8> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i8> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "extrause_add_different_operands",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i8> @extrause_add_different_operands(<8 x i8> %a, <8 x i8> %b) {\n %ab = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %bb = shufflevector <8 x i8> %b, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %bt = shufflevector <8 x i8> %b, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = add <4 x i8> %at, %bt\n %abb = add <4 x i8> %ab, %bb\n call void @use(<4 x i8> %abb)\n %r = shufflevector <4 x i8> %abt, <4 x i8> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i8> %r\n}\n\ndeclare void @use(<4 x i8>)\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "icmpsel_diffentcond",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i8> @icmpsel_diffentcond(<8 x i8> %a, <8 x i8> %b, <8 x i8> %c, <8 x i8> %d) {\n %ab = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %bb = shufflevector <8 x i8> %b, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %bt = shufflevector <8 x i8> %b, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %cb = shufflevector <8 x i8> %c, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %ct = shufflevector <8 x i8> %c, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %db = shufflevector <8 x i8> %d, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %dt = shufflevector <8 x i8> %d, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt1 = icmp slt <4 x i8> %at, %bt\n %abb1 = icmp ult <4 x i8> %ab, %bb\n %abt = select <4 x i1> %abt1, <4 x i8> %ct, <4 x i8> %dt\n %abb = select <4 x i1> %abb1, <4 x i8> %cb, <4 x i8> %db\n %r = shufflevector <4 x i8> %abt, <4 x i8> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i8> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "exttrunc",
"test_body": "target triple = \"aarch64\"\n\ndefine void @exttrunc(<8 x i32> %a, <8 x i32> %b, ptr %p) {\n %ab = shufflevector <8 x i32> %a, <8 x i32> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>\n %at = shufflevector <8 x i32> %a, <8 x i32> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7>\n %bb = shufflevector <8 x i32> %b, <8 x i32> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>\n %bt = shufflevector <8 x i32> %b, <8 x i32> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7>\n %ab1 = zext <4 x i32> %ab to <4 x i64>\n %at1 = zext <4 x i32> %at to <4 x i64>\n %bb1 = sext <4 x i32> %bb to <4 x i64>\n %bt1 = sext <4 x i32> %bt to <4 x i64>\n %abb = add <4 x i64> %ab1, %bb1\n %abt = add <4 x i64> %at1, %bt1\n %abb1 = trunc <4 x i64> %abb to <4 x i32>\n %abt1 = trunc <4 x i64> %abt to <4 x i32>\n %r = shufflevector <4 x i32> %abb1, <4 x i32> %abt1, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>\n store <8 x i32> %r, ptr %p, align 32\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "lrint",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i32> @lrint(<8 x half> %a) {\n %ab = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = call <4 x i32> @llvm.lrint.v4i32.v4f16(<4 x half> %at)\n %abb = call <4 x i32> @llvm.lrint.v4i32.v4f16(<4 x half> %ab)\n %r = shufflevector <4 x i32> %abt, <4 x i32> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i32> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x i32> @llvm.lrint.v4i32.v4f16(<4 x half>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "fadd",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x half> @fadd(<8 x half> %a, <8 x half> %b) {\n %ab = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %bb = shufflevector <8 x half> %b, <8 x half> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %bt = shufflevector <8 x half> %b, <8 x half> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = fadd <4 x half> %at, %bt\n %abb = fadd <4 x half> %ab, %bb\n %r = shufflevector <4 x half> %abt, <4 x half> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x half> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "abs_different",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i8> @abs_different(<8 x i8> %a) {\n %ab = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = call <4 x i8> @llvm.abs.v4i8(<4 x i8> %at, i1 true)\n %abb = call <4 x i8> @llvm.abs.v4i8(<4 x i8> %ab, i1 false)\n %r = shufflevector <4 x i8> %abt, <4 x i8> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i8> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x i8> @llvm.abs.v4i8(<4 x i8>, i1 immarg) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "wrong_addsub",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i8> @wrong_addsub(<8 x i8> %a, <8 x i8> %b) {\n %ab = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %bb = shufflevector <8 x i8> %b, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %bt = shufflevector <8 x i8> %b, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = add <4 x i8> %at, %bt\n %abb = sub <4 x i8> %ab, %bb\n %r = shufflevector <4 x i8> %abt, <4 x i8> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i8> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "single_zext",
"test_body": "target triple = \"aarch64\"\n\ndefine <4 x i64> @single_zext(<4 x i32> %x) {\n %shuf = shufflevector <4 x i32> %x, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %zext = zext <4 x i32> %shuf to <4 x i64>\n %revshuf = shufflevector <4 x i64> %zext, <4 x i64> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n ret <4 x i64> %revshuf\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "v8f64interleave",
"test_body": "target triple = \"aarch64\"\n\ndefine void @v8f64interleave(i64 %0, ptr %1, ptr %x, double %z) {\nentry:\n %broadcast.splatinsert = insertelement <2 x double> poison, double %z, i64 0\n %broadcast.splat = shufflevector <2 x double> %broadcast.splatinsert, <2 x double> poison, <2 x i32> zeroinitializer\n %wide.vec = load <16 x double>, ptr %1, align 8\n %strided.vec = shufflevector <16 x double> %wide.vec, <16 x double> poison, <2 x i32> <i32 0, i32 8>\n %strided.vec27 = shufflevector <16 x double> %wide.vec, <16 x double> poison, <2 x i32> <i32 1, i32 9>\n %strided.vec28 = shufflevector <16 x double> %wide.vec, <16 x double> poison, <2 x i32> <i32 2, i32 10>\n %strided.vec29 = shufflevector <16 x double> %wide.vec, <16 x double> poison, <2 x i32> <i32 3, i32 11>\n %strided.vec30 = shufflevector <16 x double> %wide.vec, <16 x double> poison, <2 x i32> <i32 4, i32 12>\n %strided.vec31 = shufflevector <16 x double> %wide.vec, <16 x double> poison, <2 x i32> <i32 5, i32 13>\n %strided.vec32 = shufflevector <16 x double> %wide.vec, <16 x double> poison, <2 x i32> <i32 6, i32 14>\n %strided.vec33 = shufflevector <16 x double> %wide.vec, <16 x double> poison, <2 x i32> <i32 7, i32 15>\n %2 = fmul fast <2 x double> %strided.vec, %broadcast.splat\n %3 = getelementptr inbounds double, ptr %x, i64 %0\n %wide.vec34 = load <16 x double>, ptr %3, align 8\n %strided.vec35 = shufflevector <16 x double> %wide.vec34, <16 x double> poison, <2 x i32> <i32 0, i32 8>\n %strided.vec36 = shufflevector <16 x double> %wide.vec34, <16 x double> poison, <2 x i32> <i32 1, i32 9>\n %strided.vec37 = shufflevector <16 x double> %wide.vec34, <16 x double> poison, <2 x i32> <i32 2, i32 10>\n %strided.vec38 = shufflevector <16 x double> %wide.vec34, <16 x double> poison, <2 x i32> <i32 3, i32 11>\n %strided.vec39 = shufflevector <16 x double> %wide.vec34, <16 x double> poison, <2 x i32> <i32 4, i32 12>\n %strided.vec40 = shufflevector <16 x double> %wide.vec34, <16 x double> poison, <2 x i32> <i32 5, i32 13>\n %strided.vec41 = shufflevector <16 x double> %wide.vec34, <16 x double> poison, <2 x i32> <i32 6, i32 14>\n %strided.vec42 = shufflevector <16 x double> %wide.vec34, <16 x double> poison, <2 x i32> <i32 7, i32 15>\n %4 = fadd fast <2 x double> %strided.vec35, %2\n %5 = fmul fast <2 x double> %strided.vec27, %broadcast.splat\n %6 = fadd fast <2 x double> %strided.vec36, %5\n %7 = fmul fast <2 x double> %strided.vec28, %broadcast.splat\n %8 = fadd fast <2 x double> %strided.vec37, %7\n %9 = fmul fast <2 x double> %strided.vec29, %broadcast.splat\n %10 = fadd fast <2 x double> %strided.vec38, %9\n %11 = fmul fast <2 x double> %strided.vec30, %broadcast.splat\n %12 = fadd fast <2 x double> %strided.vec39, %11\n %13 = fmul fast <2 x double> %strided.vec31, %broadcast.splat\n %14 = fadd fast <2 x double> %strided.vec40, %13\n %15 = fmul fast <2 x double> %strided.vec32, %broadcast.splat\n %16 = fadd fast <2 x double> %strided.vec41, %15\n %17 = or disjoint i64 %0, 7\n %18 = fmul fast <2 x double> %strided.vec33, %broadcast.splat\n %19 = getelementptr inbounds double, ptr %x, i64 %17\n %20 = fadd fast <2 x double> %strided.vec42, %18\n %21 = getelementptr inbounds i8, ptr %19, i64 -56\n %22 = shufflevector <2 x double> %4, <2 x double> %6, <4 x i32> <i32 0, i32 1, i32 2, i32 3>\n %23 = shufflevector <2 x double> %8, <2 x double> %10, <4 x i32> <i32 0, i32 1, i32 2, i32 3>\n %24 = shufflevector <2 x double> %12, <2 x double> %14, <4 x i32> <i32 0, i32 1, i32 2, i32 3>\n %25 = shufflevector <2 x double> %16, <2 x double> %20, <4 x i32> <i32 0, i32 1, i32 2, i32 3>\n %26 = shufflevector <4 x double> %22, <4 x double> %23, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>\n %27 = shufflevector <4 x double> %24, <4 x double> %25, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>\n %interleaved.vec = shufflevector <8 x double> %26, <8 x double> %27, <16 x i32> <i32 0, i32 2, i32 4, i32 6, i32 8, i32 10, i32 12, i32 14, i32 1, i32 3, i32 5, i32 7, i32 9, i32 11, i32 13, i32 15>\n store <16 x double> %interleaved.vec, ptr %21, align 8\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "singleop",
"test_body": "target triple = \"aarch64\"\n\ndefine <4 x i8> @singleop(<4 x i8> %a, <4 x i8> %b) {\n %a1 = shufflevector <4 x i8> %a, <4 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %b1 = shufflevector <4 x i8> %b, <4 x i8> poison, <4 x i32> zeroinitializer\n %a2 = zext <4 x i8> %a1 to <4 x i16>\n %b2 = zext <4 x i8> %b1 to <4 x i16>\n %ab = add <4 x i16> %a2, %b2\n %t = trunc <4 x i16> %ab to <4 x i8>\n %r = shufflevector <4 x i8> %t, <4 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n ret <4 x i8> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "not_bitcast",
"test_body": "target triple = \"aarch64\"\n\ndefine i32 @not_bitcast(<4 x i8> %x) {\n %shuf = shufflevector <4 x i8> %x, <4 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %bitcast = bitcast <4 x i8> %shuf to i32\n ret i32 %bitcast\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "zext_chain",
"test_body": "target triple = \"aarch64\"\n\ndefine <4 x i64> @zext_chain(<4 x i16> %x) {\n %shuf = shufflevector <4 x i16> %x, <4 x i16> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %zext = zext <4 x i16> %shuf to <4 x i32>\n %sext = sext <4 x i32> %zext to <4 x i64>\n %revshuf = shufflevector <4 x i64> %sext, <4 x i64> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n ret <4 x i64> %revshuf\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "intrinsics_different",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i8> @intrinsics_different(<8 x i8> %a, <8 x i8> %b) {\n %ab = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %bb = shufflevector <8 x i8> %b, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %bt = shufflevector <8 x i8> %b, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = call <4 x i8> @llvm.smin.v4i8(<4 x i8> %at, <4 x i8> %bt)\n %abb = call <4 x i8> @llvm.umin.v4i8(<4 x i8> %ab, <4 x i8> %bb)\n %r = shufflevector <4 x i8> %abt, <4 x i8> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i8> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x i8> @llvm.smin.v4i8(<4 x i8>, <4 x i8>) #0\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x i8> @llvm.umin.v4i8(<4 x i8>, <4 x i8>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "operandbundles_second",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i8> @operandbundles_second(<8 x i8> %a) {\n %ab = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = call <4 x i8> @llvm.abs.v4i8(<4 x i8> %at, i1 false)\n %abb = call <4 x i8> @llvm.abs.v4i8(<4 x i8> %ab, i1 false) [ \"jl_roots\"(ptr addrspace(10) null, ptr addrspace(10) null) ]\n %r = shufflevector <4 x i8> %abt, <4 x i8> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i8> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x i8> @llvm.abs.v4i8(<4 x i8>, i1 immarg) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "cast_mismatched_types",
"test_body": "target triple = \"aarch64\"\n\ndefine <4 x i64> @cast_mismatched_types(<4 x i32> %x) {\n %shuf = shufflevector <4 x i32> %x, <4 x i32> poison, <2 x i32> <i32 0, i32 2>\n %zext = zext <2 x i32> %shuf to <2 x i64>\n %extshuf = shufflevector <2 x i64> %zext, <2 x i64> poison, <4 x i32> <i32 0, i32 2, i32 1, i32 3>\n ret <4 x i64> %extshuf\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "operandbundles_first",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i8> @operandbundles_first(<8 x i8> %a) {\n %ab = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = call <4 x i8> @llvm.abs.v4i8(<4 x i8> %at, i1 false) [ \"jl_roots\"(ptr addrspace(10) null, ptr addrspace(10) null) ]\n %abb = call <4 x i8> @llvm.abs.v4i8(<4 x i8> %ab, i1 false)\n %r = shufflevector <4 x i8> %abt, <4 x i8> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i8> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x i8> @llvm.abs.v4i8(<4 x i8>, i1 immarg) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "wrong_lanes",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i8> @wrong_lanes(<8 x i8> %a, <8 x i8> %b) {\n %ab = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %bb = shufflevector <8 x i8> %b, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %bt = shufflevector <8 x i8> %b, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = add <4 x i8> %at, %bt\n %abb = add <4 x i8> %ab, %bb\n %r = shufflevector <4 x i8> %abt, <4 x i8> %abb, <8 x i32> <i32 6, i32 7, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i8> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "first_scalar_select",
"test_body": "target triple = \"aarch64\"\n\ndefine <2 x float> @first_scalar_select(<2 x float> %0, <2 x float> %1, float %x) {\nentry:\n %cmp.i903 = fcmp ogt float %x, 0.000000e+00\n %sel1639 = select i1 %cmp.i903, <2 x float> %0, <2 x float> %1\n %2 = fcmp ogt <2 x float> %0, zeroinitializer\n %sel48.i913 = select <2 x i1> %2, <2 x float> %0, <2 x float> %1\n %3 = shufflevector <2 x float> %sel1639, <2 x float> %sel48.i913, <2 x i32> <i32 0, i32 3>\n ret <2 x float> %3\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "splat0",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x half> @splat0(<8 x half> %a, <8 x half> %b) {\n %ab = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %bs = shufflevector <8 x half> %b, <8 x half> poison, <4 x i32> zeroinitializer\n %abt = fadd <4 x half> %at, %bs\n %abb = fadd <4 x half> %ab, %bs\n %r = shufflevector <4 x half> %abt, <4 x half> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x half> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "splatandidentity",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x half> @splatandidentity(<8 x half> %a, <8 x half> %b) {\n %ab = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %bs = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> zeroinitializer\n %abt = fadd <4 x half> %at, %bs\n %abb = fadd <4 x half> %ab, %bs\n %r = shufflevector <4 x half> %abt, <4 x half> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x half> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "trivial",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i8> @trivial(<8 x i8> %a) {\n %ab = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %r = shufflevector <4 x i8> %at, <4 x i8> %ab, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i8> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "constantsplat",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i8> @constantsplat(<8 x i8> %a) {\n %ab = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = add <4 x i8> %at, splat (i8 10)\n %abb = add <4 x i8> %ab, splat (i8 10)\n %r = shufflevector <4 x i8> %abt, <4 x i8> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i8> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "bitcast_srcty_mismatch",
"test_body": "target triple = \"aarch64\"\n\ndefine void @bitcast_srcty_mismatch() {\nentry:\n %shuffle.i.i = shufflevector <2 x i64> zeroinitializer, <2 x i64> zeroinitializer, <2 x i32> <i32 1, i32 3>\n %0 = bitcast <4 x i32> zeroinitializer to <4 x float>\n %1 = bitcast <2 x i64> %shuffle.i.i to <4 x float>\n %shufp.i196 = shufflevector <4 x float> %0, <4 x float> %1, <4 x i32> <i32 2, i32 1, i32 4, i32 7>\n store <4 x float> %shufp.i196, ptr null, align 16\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "zext_add_chain",
"test_body": "target triple = \"aarch64\"\n\ndefine <4 x i64> @zext_add_chain(<4 x i32> %x) {\n %shuf = shufflevector <4 x i32> %x, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %zext = zext <4 x i32> %shuf to <4 x i64>\n %add = add <4 x i64> %zext, %zext\n %revshuf = shufflevector <4 x i64> %add, <4 x i64> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n ret <4 x i64> %revshuf\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "add_chain",
"test_body": "target triple = \"aarch64\"\n\ndefine <4 x i32> @add_chain(<4 x i32> %x) {\n %shuf = shufflevector <4 x i32> %x, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %add = add <4 x i32> %shuf, %shuf\n %add2 = add <4 x i32> %add, %add\n %revshuf = shufflevector <4 x i32> %add2, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n ret <4 x i32> %revshuf\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "splat2",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x half> @splat2(<8 x half> %a, <8 x half> %b) {\n %ab = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %bs = shufflevector <8 x half> %b, <8 x half> poison, <4 x i32> <i32 2, i32 2, i32 2, i32 2>\n %abt = fadd <4 x half> %at, %bs\n %abb = fadd <4 x half> %ab, %bs\n %r = shufflevector <4 x half> %abt, <4 x half> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x half> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "trunc",
"test_body": "target triple = \"aarch64\"\n\ndefine void @trunc(<8 x i64> %a, <8 x i64> %b, ptr %p) {\n %ab = shufflevector <8 x i64> %a, <8 x i64> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>\n %at = shufflevector <8 x i64> %a, <8 x i64> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7>\n %abb1 = trunc <4 x i64> %ab to <4 x i32>\n %abt1 = trunc <4 x i64> %at to <4 x i32>\n %r = shufflevector <4 x i32> %abb1, <4 x i32> %abt1, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>\n store <8 x i32> %r, ptr %p, align 32\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "sext",
"test_body": "target triple = \"aarch64\"\n\ndefine void @sext(<8 x i16> %a, <8 x i16> %b, ptr %p) {\n %ab = shufflevector <8 x i16> %a, <8 x i16> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>\n %at = shufflevector <8 x i16> %a, <8 x i16> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7>\n %bb = shufflevector <8 x i16> %b, <8 x i16> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>\n %bt = shufflevector <8 x i16> %b, <8 x i16> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7>\n %ab1 = sext <4 x i16> %ab to <4 x i32>\n %at1 = sext <4 x i16> %at to <4 x i32>\n %bb1 = sext <4 x i16> %bb to <4 x i32>\n %bt1 = sext <4 x i16> %bt to <4 x i32>\n %abb = add <4 x i32> %ab1, %bb1\n %abt = add <4 x i32> %at1, %bt1\n %r = shufflevector <4 x i32> %abb, <4 x i32> %abt, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>\n store <8 x i32> %r, ptr %p, align 32\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "powi",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x half> @powi(<8 x half> %a) {\n %ab = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = call <4 x half> @llvm.powi.v4f16.i32(<4 x half> %at, i32 10)\n %abb = call <4 x half> @llvm.powi.v4f16.i32(<4 x half> %ab, i32 10)\n %r = shufflevector <4 x half> %abt, <4 x half> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x half> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x half> @llvm.powi.v4f16.i32(<4 x half>, i32) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "callinst",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x half> @callinst(<8 x half> %a) {\n %ab = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = call <4 x half> @othercall(<4 x half> %at)\n %abb = call <4 x half> @llvm.fabs.v4f16(<4 x half> %ab)\n %r = shufflevector <4 x half> %abt, <4 x half> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x half> %r\n}\n\ndeclare <4 x half> @othercall(<4 x half>)\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x half> @llvm.fabs.v4f16(<4 x half>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "fma",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x half> @fma(<8 x half> %a, <8 x half> %b, <8 x half> %c) {\n %ab = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %bb = shufflevector <8 x half> %b, <8 x half> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %bt = shufflevector <8 x half> %b, <8 x half> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %cb = shufflevector <8 x half> %c, <8 x half> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %ct = shufflevector <8 x half> %c, <8 x half> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abb = call <4 x half> @llvm.fma.v4f16(<4 x half> %ab, <4 x half> %bb, <4 x half> %cb)\n %abt = call <4 x half> @llvm.fma.v4f16(<4 x half> %at, <4 x half> %bt, <4 x half> %ct)\n %r = shufflevector <4 x half> %abt, <4 x half> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x half> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x half> @llvm.fma.v4f16(<4 x half>, <4 x half>, <4 x half>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "extrause_shuffle",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i8> @extrause_shuffle(<8 x i8> %a, <8 x i8> %b) {\n %ab = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %bb = shufflevector <8 x i8> %b, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %bt = shufflevector <8 x i8> %b, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n call void @use(<4 x i8> %bt)\n %abt = add <4 x i8> %at, %bt\n %abb = add <4 x i8> %ab, %bb\n %r = shufflevector <4 x i8> %abt, <4 x i8> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i8> %r\n}\n\ndeclare void @use(<4 x i8>)\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "intrinsics_addsat",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i8> @intrinsics_addsat(<8 x i8> %a, <8 x i8> %b) {\n %ab = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %bb = shufflevector <8 x i8> %b, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %bt = shufflevector <8 x i8> %b, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = call <4 x i8> @llvm.sadd.sat.v4i8(<4 x i8> %at, <4 x i8> %bt)\n %abb = call <4 x i8> @llvm.sadd.sat.v4i8(<4 x i8> %ab, <4 x i8> %bb)\n %abt1 = call <4 x i8> @llvm.ssub.sat.v4i8(<4 x i8> %abt, <4 x i8> %bt)\n %abb1 = call <4 x i8> @llvm.ssub.sat.v4i8(<4 x i8> %abb, <4 x i8> %bb)\n %abt2 = call <4 x i8> @llvm.uadd.sat.v4i8(<4 x i8> %abt1, <4 x i8> %bt)\n %abb2 = call <4 x i8> @llvm.uadd.sat.v4i8(<4 x i8> %abb1, <4 x i8> %bb)\n %abt3 = call <4 x i8> @llvm.usub.sat.v4i8(<4 x i8> %abt2, <4 x i8> %bt)\n %abb3 = call <4 x i8> @llvm.usub.sat.v4i8(<4 x i8> %abb2, <4 x i8> %bb)\n %r = shufflevector <4 x i8> %abt3, <4 x i8> %abb3, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i8> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x i8> @llvm.sadd.sat.v4i8(<4 x i8>, <4 x i8>) #0\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x i8> @llvm.ssub.sat.v4i8(<4 x i8>, <4 x i8>) #0\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x i8> @llvm.uadd.sat.v4i8(<4 x i8>, <4 x i8>) #0\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x i8> @llvm.usub.sat.v4i8(<4 x i8>, <4 x i8>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "zext",
"test_body": "target triple = \"aarch64\"\n\ndefine void @zext(<8 x i16> %a, <8 x i16> %b, ptr %p) {\n %ab = shufflevector <8 x i16> %a, <8 x i16> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>\n %at = shufflevector <8 x i16> %a, <8 x i16> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7>\n %bb = shufflevector <8 x i16> %b, <8 x i16> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>\n %bt = shufflevector <8 x i16> %b, <8 x i16> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7>\n %ab1 = zext <4 x i16> %ab to <4 x i32>\n %at1 = zext <4 x i16> %at to <4 x i32>\n %bb1 = zext <4 x i16> %bb to <4 x i32>\n %bt1 = zext <4 x i16> %bt to <4 x i32>\n %abb = add <4 x i32> %ab1, %bb1\n %abt = add <4 x i32> %at1, %bt1\n %r = shufflevector <4 x i32> %abb, <4 x i32> %abt, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>\n store <8 x i32> %r, ptr %p, align 32\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "div",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i8> @div(<8 x i8> %a, <8 x i8> %b) {\n %ab = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %bb = shufflevector <8 x i8> %b, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %bt = shufflevector <8 x i8> %b, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = udiv <4 x i8> %at, %bt\n %abb = udiv <4 x i8> %ab, %bb\n %r = shufflevector <4 x i8> %abt, <4 x i8> %abb, <8 x i32> <i32 7, i32 poison, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i8> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"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
},
{
"test_name": "not_bitcast2",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i16> @not_bitcast2(<4 x i32> %x, <8 x i16> %y) {\n %cast = bitcast <4 x i32> %x to <8 x i16>\n %out = shufflevector <8 x i16> %y, <8 x i16> %cast, <8 x i32> <i32 8, i32 1, i32 10, i32 3, i32 12, i32 5, i32 14, i32 7>\n ret <8 x i16> %out\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "abs",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i8> @abs(<8 x i8> %a) {\n %ab = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = call <4 x i8> @llvm.abs.v4i8(<4 x i8> %at, i1 false)\n %abb = call <4 x i8> @llvm.abs.v4i8(<4 x i8> %ab, i1 false)\n %r = shufflevector <4 x i8> %abt, <4 x i8> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i8> %r\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x i8> @llvm.abs.v4i8(<4 x i8>, i1 immarg) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "maximal_legal_fpmath",
"test_body": "target triple = \"aarch64\"\n\ndefine void @maximal_legal_fpmath(ptr %addr1, ptr %addr2, ptr %result, float %val) {\n %splatinsert = insertelement <4 x float> poison, float %val, i64 0\n %incoming.vec = shufflevector <4 x float> %splatinsert, <4 x float> poison, <4 x i32> zeroinitializer\n %vec1 = load <16 x float>, ptr %addr1, align 4\n %strided.vec1 = shufflevector <16 x float> %vec1, <16 x float> poison, <4 x i32> <i32 0, i32 4, i32 8, i32 12>\n %strided.vec2 = shufflevector <16 x float> %vec1, <16 x float> poison, <4 x i32> <i32 1, i32 5, i32 9, i32 13>\n %strided.vec3 = shufflevector <16 x float> %vec1, <16 x float> poison, <4 x i32> <i32 2, i32 6, i32 10, i32 14>\n %strided.vec4 = shufflevector <16 x float> %vec1, <16 x float> poison, <4 x i32> <i32 3, i32 7, i32 11, i32 15>\n %vec2 = load <16 x float>, ptr %addr2, align 4\n %strided.vec6 = shufflevector <16 x float> %vec2, <16 x float> poison, <4 x i32> <i32 0, i32 4, i32 8, i32 12>\n %strided.vec7 = shufflevector <16 x float> %vec2, <16 x float> poison, <4 x i32> <i32 1, i32 5, i32 9, i32 13>\n %strided.vec8 = shufflevector <16 x float> %vec2, <16 x float> poison, <4 x i32> <i32 2, i32 6, i32 10, i32 14>\n %strided.vec9 = shufflevector <16 x float> %vec2, <16 x float> poison, <4 x i32> <i32 3, i32 7, i32 11, i32 15>\n %1 = fmul fast <4 x float> %incoming.vec, %strided.vec6\n %2 = fadd fast <4 x float> %strided.vec1, %1\n %3 = fmul contract <4 x float> %incoming.vec, %strided.vec7\n %4 = fadd fast <4 x float> %strided.vec2, %3\n %5 = fmul reassoc contract <4 x float> %incoming.vec, %strided.vec8\n %6 = fadd fast <4 x float> %strided.vec3, %5\n %7 = fmul reassoc contract <4 x float> %incoming.vec, %strided.vec9\n %8 = fadd reassoc contract <4 x float> %strided.vec4, %7\n %9 = shufflevector <4 x float> %2, <4 x float> %4, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>\n %10 = shufflevector <4 x float> %6, <4 x float> %8, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>\n %interleaved.vec = shufflevector <8 x float> %9, <8 x float> %10, <16 x i32> <i32 0, i32 4, i32 8, i32 12, i32 1, i32 5, i32 9, i32 13, i32 2, i32 6, i32 10, i32 14, i32 3, i32 7, i32 11, i32 15>\n store <16 x float> %interleaved.vec, ptr %result, align 4\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "not_zext",
"test_body": "target triple = \"aarch64\"\n\ndefine <4 x i64> @not_zext(<4 x i32> %x) {\n %zext = zext <4 x i32> %x to <4 x i64>\n %revshuf = shufflevector <4 x i64> %zext, <4 x i64> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n ret <4 x i64> %revshuf\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "undeflane",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i8> @undeflane(<8 x i8> %a, <8 x i8> %b) {\n %ab = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %bb = shufflevector <8 x i8> %b, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %bt = shufflevector <8 x i8> %b, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = add <4 x i8> %at, %bt\n %abb = add <4 x i8> %ab, %bb\n %r = shufflevector <4 x i8> %abt, <4 x i8> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 poison, i32 1, i32 0>\n ret <8 x i8> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "operandbundles",
"test_body": "target triple = \"aarch64\"\n\ndefine <16 x i64> @operandbundles(<4 x i64> %a, <4 x i64> %b, <4 x i64> %c) {\n %call = call <4 x i64> @llvm.fshl.v4i64(<4 x i64> %a, <4 x i64> %b, <4 x i64> %c) [ \"jl_roots\"(ptr addrspace(10) null, ptr addrspace(10) null) ]\n %shufflevector = shufflevector <4 x i64> %call, <4 x i64> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>\n %shufflevector1 = shufflevector <16 x i64> %shufflevector, <16 x i64> undef, <16 x i32> <i32 0, i32 1, i32 2, i32 3, 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 ret <16 x i64> %shufflevector1\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare <4 x i64> @llvm.fshl.v4i64(<4 x i64>, <4 x i64>, <4 x i64>) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "fneg",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x half> @fneg(<8 x half> %a, <8 x half> %b) {\n %ab = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = fneg <4 x half> %at\n %abb = fneg <4 x half> %ab\n %r = shufflevector <4 x half> %abt, <4 x half> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x half> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "icmpsel",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x i8> @icmpsel(<8 x i8> %a, <8 x i8> %b, <8 x i8> %c, <8 x i8> %d) {\n %ab = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x i8> %a, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %bb = shufflevector <8 x i8> %b, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %bt = shufflevector <8 x i8> %b, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %cb = shufflevector <8 x i8> %c, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %ct = shufflevector <8 x i8> %c, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %db = shufflevector <8 x i8> %d, <8 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %dt = shufflevector <8 x i8> %d, <8 x i8> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt1 = icmp slt <4 x i8> %at, %bt\n %abb1 = icmp slt <4 x i8> %ab, %bb\n %abt = select <4 x i1> %abt1, <4 x i8> %ct, <4 x i8> %dt\n %abb = select <4 x i1> %abb1, <4 x i8> %cb, <4 x i8> %db\n %r = shufflevector <4 x i8> %abt, <4 x i8> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x i8> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "szext",
"test_body": "target triple = \"aarch64\"\n\ndefine void @szext(<8 x i32> %a, <8 x i32> %b, ptr %p) {\n %ab = shufflevector <8 x i32> %a, <8 x i32> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>\n %at = shufflevector <8 x i32> %a, <8 x i32> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7>\n %ab1 = sext <4 x i32> %ab to <4 x i64>\n %at1 = zext <4 x i32> %at to <4 x i64>\n %r = shufflevector <4 x i64> %ab1, <4 x i64> %at1, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>\n store <8 x i64> %r, ptr %p, align 64\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "constantsplatf",
"test_body": "target triple = \"aarch64\"\n\ndefine <8 x half> @constantsplatf(<8 x half> %a) {\n %ab = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %at = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4>\n %abt = fadd <4 x half> %at, splat (half 0xH4900)\n %abb = fadd <4 x half> %ab, splat (half 0xH4900)\n %r = shufflevector <4 x half> %abt, <4 x half> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>\n ret <8 x half> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "not_zext2",
"test_body": "target triple = \"aarch64\"\n\ndefine <4 x i64> @not_zext2(<4 x i32> %x) {\n %shuf = shufflevector <4 x i32> %x, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>\n %zext = zext <4 x i32> %shuf to <4 x i64>\n ret <4 x i64> %zext\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Assertion Failure in Vector Combine",
"body": "Runnning vector-combine pass on \r\n```llvm\r\nsource_filename = \"text\"\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:10:11:12:13\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine nonnull ptr addrspace(10) @wombat() {\r\n %call = call <4 x i64> @llvm.fshl.v4i64(<4 x i64> zeroinitializer, <4 x i64> zeroinitializer, <4 x i64> <i64 45, i64 45, i64 45, i64 45>) [ \"jl_roots\"(ptr addrspace(10) null, ptr addrspace(10) null) ]\r\n %shufflevector = shufflevector <4 x i64> %call, <4 x i64> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>\r\n %shufflevector1 = shufflevector <16 x i64> %shufflevector, <16 x i64> undef, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>\r\n ret ptr addrspace(10) null\r\n}\r\n\r\ndeclare <4 x i64> @llvm.fshl.v4i64(<4 x i64>, <4 x i64>, <4 x i64>)\r\n```\r\nproduces\r\n```\r\nopt: /root/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From*) [with To = llvm::FixedVectorType; From = llvm::Type]: 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.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=vector-combine <source>\r\n1.\tRunning pass \"function(vector-combine)\" on module \"<source>\"\r\n2.\tRunning pass \"vector-combine\" on function \"wombat\"\r\n #0 0x0000000005079b38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5079b38)\r\n #1 0x00000000050774ec SignalHandler(int) Signals.cpp:0:0\r\n #2 0x000074d0dce42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x000074d0dce969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x000074d0dce42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x000074d0dce287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x000074d0dce2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x000074d0dce39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x0000000004186458 (anonymous namespace)::VectorCombine::foldShuffleToIdentity(llvm::Instruction&) VectorCombine.cpp:0:0\r\n #9 0x0000000004190f01 (anonymous namespace)::VectorCombine::run()::'lambda'(llvm::Instruction&)::operator()(llvm::Instruction&) const (.isra.0) VectorCombine.cpp:0:0\r\n#10 0x0000000004191c25 llvm::VectorCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4191c25)\r\n#11 0x0000000002f2defe llvm::detail::PassModel<llvm::Function, llvm::VectorCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2f2defe)\r\n#12 0x0000000004e7c978 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e7c978)\r\n#13 0x0000000000e157ce 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+0xe157ce)\r\n#14 0x0000000004e7b39e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e7b39e)\r\n#15 0x0000000000e14f7e 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+0xe14f7e)\r\n#16 0x0000000004e7add0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e7add0)\r\n#17 0x0000000000904cc2 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+0x904cc2)\r\n#18 0x00000000008f7b4c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8f7b4c)\r\n#19 0x000074d0dce29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#20 0x000074d0dce29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#21 0x00000000008ef61e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8ef61e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```\r\nGodbolt: https://godbolt.org/z/MGefYs3M5",
"author": "Zentrik",
"labels": [
"release:backport",
"vectorizers",
"crash"
],
"comments": [
{
"author": "Heresh83",
"body": "> Runnning vector-combine pass on \n> ```llvm\n> source_filename = \"text\"\n> 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:10:11:12:13\"\n> target triple = \"x86_64-unknown-linux-gnu\"\n> \n> define nonnull ptr addrspace(10) @wombat() {\n> %call = call <4 x i64> @llvm.fshl.v4i64(<4 x i64> zeroinitializer, <4 x i64> zeroinitializer, <4 x i64> <i64 45, i64 45, i64 45, i64 45>) [ \"jl_roots\"(ptr addrspace(10) null, ptr addrspace(10) null) ]\n> %shufflevector = shufflevector <4 x i64> %call, <4 x i64> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>\n> %shufflevector1 = shufflevector <16 x i64> %shufflevector, <16 x i64> undef, <16 x i32> <i32 0, i32 1, i32 2, i32 3, 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> ret ptr addrspace(10) null\n> }\n> \n> declare <4 x i64> @llvm.fshl.v4i64(<4 x i64>, <4 x i64>, <4 x i64>)\n> ```\n> produces\n> ```\n> opt: /root/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From*) [with To = llvm::FixedVectorType; From = llvm::Type]: Assertion `isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"' failed.\n> PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\n> Stack dump:\n> 0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=vector-combine <source>\n> 1.\tRunning pass \"function(vector-combine)\" on module \"<source>\"\n> 2.\tRunning pass \"vector-combine\" on function \"wombat\"\n> #0 0x0000000005079b38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5079b38)\n> #1 0x00000000050774ec SignalHandler(int) Signals.cpp:0:0\n> #2 0x000074d0dce42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n> #3 0x000074d0dce969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n> #4 0x000074d0dce42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n> #5 0x000074d0dce287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n> #6 0x000074d0dce2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n> #7 0x000074d0dce39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n> #8 0x0000000004186458 (anonymous namespace)::VectorCombine::foldShuffleToIdentity(llvm::Instruction&) VectorCombine.cpp:0:0\n> #9 0x0000000004190f01 (anonymous namespace)::VectorCombine::run()::'lambda'(llvm::Instruction&)::operator()(llvm::Instruction&) const (.isra.0) VectorCombine.cpp:0:0\n> #10 0x0000000004191c25 llvm::VectorCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4191c25)\n> #11 0x0000000002f2defe llvm::detail::PassModel<llvm::Function, llvm::VectorCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2f2defe)\n> #12 0x0000000004e7c978 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e7c978)\n> #13 0x0000000000e157ce 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+0xe157ce)\n> #14 0x0000000004e7b39e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e7b39e)\n> #15 0x0000000000e14f7e 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+0xe14f7e)\n> #16 0x0000000004e7add0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e7add0)\n> #17 0x0000000000904cc2 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+0x904cc2)\n> #18 0x00000000008f7b4c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8f7b4c)\n> #19 0x000074d0dce29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n> #20 0x000074d0dce29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n> #21 0x00000000008ef61e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8ef61e)\n> Program terminated with signal: SIGSEGV\n> Compiler returned: 139\n> ```\n> Godbolt: https://godbolt.org/z/MGefYs3M5\n\n"
},
{
"author": "RKSimon",
"body": "Looks like foldShuffleToIdentity is attempting to fold the operand bundle on the fshl call"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
120076
|
https://github.com/llvm/llvm-project/issues/120076
|
miscompilation
|
2402bccc805614069efb0a47e1ef43349ea7ba1e
| 2024-12-16T13:09:17 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "d1a7225076218ce224cd29c74259b715b393dc9d",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
2931,
2943
],
[
17515,
17522
],
[
17528,
17533
],
[
17623,
17630
],
[
17926,
17931
],
[
17949,
17954
],
[
18071,
18078
],
[
18206,
18212
],
[
18214,
18219
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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",
"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 d1a7225076218ce224cd29c74259b715b393dc9d
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Mon Dec 16 07:52:32 2024 -0800
[SLP]Check if the node must keep its original bitwidth
Need to check if during previous analysis the node has requested to keep
its original bitwidth to avoid incorrect codegen.
Fixes #120076
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 3bd983ee6e12..d967813075bb 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -2931,13 +2931,11 @@ private:
/// truncation. We collect the entries that will be demoted in ToDemote.
/// \param E Node for analysis
/// \param ToDemote indices of the nodes to be demoted.
- bool collectValuesToDemote(const TreeEntry &E, bool IsProfitableToDemoteRoot,
- unsigned &BitWidth,
- SmallVectorImpl<unsigned> &ToDemote,
- DenseSet<const TreeEntry *> &Visited,
- unsigned &MaxDepthLevel,
- bool &IsProfitableToDemote,
- bool IsTruncRoot) const;
+ bool collectValuesToDemote(
+ const TreeEntry &E, bool IsProfitableToDemoteRoot, unsigned &BitWidth,
+ SmallVectorImpl<unsigned> &ToDemote, DenseSet<const TreeEntry *> &Visited,
+ const SmallDenseSet<unsigned, 8> &NodesToKeepBWs, unsigned &MaxDepthLevel,
+ bool &IsProfitableToDemote, bool IsTruncRoot) const;
/// Check if the operands on the edges \p Edges of the \p UserTE allows
/// reordering (i.e. the operands can be reordered because they have only one
@@ -17515,8 +17513,8 @@ unsigned BoUpSLP::getVectorElementSize(Value *V) {
bool BoUpSLP::collectValuesToDemote(
const TreeEntry &E, bool IsProfitableToDemoteRoot, unsigned &BitWidth,
SmallVectorImpl<unsigned> &ToDemote, DenseSet<const TreeEntry *> &Visited,
- unsigned &MaxDepthLevel, bool &IsProfitableToDemote,
- bool IsTruncRoot) const {
+ const SmallDenseSet<unsigned, 8> &NodesToKeepBWs, unsigned &MaxDepthLevel,
+ bool &IsProfitableToDemote, bool IsTruncRoot) const {
// We can always demote constants.
if (all_of(E.Scalars, IsaPred<Constant>))
return true;
@@ -17528,6 +17526,10 @@ bool BoUpSLP::collectValuesToDemote(
return true;
}
+ // Check if the node was analyzed already and must keep its original bitwidth.
+ if (NodesToKeepBWs.contains(E.Idx))
+ return false;
+
// If the value is not a vectorized instruction in the expression and not used
// by the insertelement instruction and not used in multiple vector nodes, it
// cannot be demoted.
@@ -17623,8 +17625,8 @@ bool BoUpSLP::collectValuesToDemote(
for (const TreeEntry *Op : Operands) {
unsigned Level = InitLevel;
if (!collectValuesToDemote(*Op, IsProfitableToDemoteRoot, BitWidth,
- ToDemote, Visited, Level, IsProfitableToDemote,
- IsTruncRoot)) {
+ ToDemote, Visited, NodesToKeepBWs, Level,
+ IsProfitableToDemote, IsTruncRoot)) {
if (!IsProfitableToDemote)
return false;
NeedToExit = true;
@@ -17926,6 +17928,7 @@ void BoUpSLP::computeMinimumValueSizes() {
bool IsTruncRoot = false;
bool IsProfitableToDemoteRoot = !IsStoreOrInsertElt;
SmallVector<unsigned> RootDemotes;
+ SmallDenseSet<unsigned, 8> NodesToKeepBWs;
if (NodeIdx != 0 &&
VectorizableTree[NodeIdx]->State == TreeEntry::Vectorize &&
VectorizableTree[NodeIdx]->getOpcode() == Instruction::Trunc) {
@@ -17949,6 +17952,7 @@ void BoUpSLP::computeMinimumValueSizes() {
// Check if the root is trunc and the next node is gather/buildvector, then
// keep trunc in scalars, which is free in most cases.
if (E.isGather() && IsTruncRoot && E.UserTreeIndices.size() == 1 &&
+ !NodesToKeepBWs.contains(E.Idx) &&
E.Idx > (IsStoreOrInsertElt ? 2u : 1u) &&
all_of(E.Scalars, [&](Value *V) {
return V->hasOneUse() || isa<Constant>(V) ||
@@ -18071,8 +18075,8 @@ void BoUpSLP::computeMinimumValueSizes() {
bool NeedToDemote = IsProfitableToDemote;
if (!collectValuesToDemote(E, IsProfitableToDemoteRoot, MaxBitWidth,
- ToDemote, Visited, MaxDepthLevel, NeedToDemote,
- IsTruncRoot) ||
+ ToDemote, Visited, NodesToKeepBWs, MaxDepthLevel,
+ NeedToDemote, IsTruncRoot) ||
(MaxDepthLevel <= Limit &&
!(((Opcode == Instruction::SExt || Opcode == Instruction::ZExt) &&
(!IsTopRoot || !(IsStoreOrInsertElt || UserIgnoreList) ||
@@ -18206,7 +18210,7 @@ void BoUpSLP::computeMinimumValueSizes() {
});
}
- // If the maximum bit width we compute is less than the with of the roots'
+ // If the maximum bit width we compute is less than the width of the roots'
// type, we can proceed with the narrowing. Otherwise, do nothing.
if (MaxBitWidth == 0 ||
MaxBitWidth >=
@@ -18214,6 +18218,7 @@ void BoUpSLP::computeMinimumValueSizes() {
->getBitWidth()) {
if (UserIgnoreList)
AnalyzedMinBWVals.insert(TreeRoot.begin(), TreeRoot.end());
+ NodesToKeepBWs.insert(ToDemote.begin(), ToDemote.end());
continue;
}
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/minbw-node-used-twice.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define i8 @test() {\nentry:\n %conv4.i.i = zext i16 0 to i32\n %conv7.i.i = sext i16 0 to i32\n %cmp8.i.i = icmp slt i32 %conv7.i.i, %conv4.i.i\n %conv9.i.i = zext i1 %cmp8.i.i to i32\n %or10.i.i = or i32 %conv9.i.i, %conv4.i.i\n %cmp11.i.i = icmp eq i32 %or10.i.i, %conv4.i.i\n %sub.i.i79.peel.i = sub i16 0, 1\n %xor5.i81.peel.i = zext i16 %sub.i.i79.peel.i to i32\n %conv7.i84.peel.i = sext i16 0 to i32\n %cmp8.i85.peel.i = icmp slt i32 %conv7.i84.peel.i, %xor5.i81.peel.i\n %conv9.i86.peel.i = zext i1 %cmp8.i85.peel.i to i32\n %or10.i87.peel.i = or i32 %conv9.i86.peel.i, %xor5.i81.peel.i\n %cmp11.i88.peel.i = icmp eq i32 %or10.i87.peel.i, %xor5.i81.peel.i\n %conv13.i89.peel.i = zext i1 %cmp8.i85.peel.i to i8\n ret i8 %conv13.i89.peel.i\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SLPVectorizer] Miscompile at O3",
"body": "Reproducer: https://alive2.llvm.org/ce/z/_88AAB\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 i8 @func_129() {\nentry:\n %conv4.i.i = zext i16 0 to i32\n %conv7.i.i = sext i16 0 to i32\n %cmp8.i.i = icmp slt i32 %conv7.i.i, %conv4.i.i\n %conv9.i.i = zext i1 %cmp8.i.i to i32\n %or10.i.i = or i32 %conv9.i.i, %conv4.i.i\n %cmp11.i.i = icmp eq i32 %or10.i.i, %conv4.i.i\n %sub.i.i79.peel.i = sub i16 0, 1\n %xor5.i81.peel.i = zext i16 %sub.i.i79.peel.i to i32\n %conv7.i84.peel.i = sext i16 0 to i32\n %cmp8.i85.peel.i = icmp slt i32 %conv7.i84.peel.i, %xor5.i81.peel.i\n %conv9.i86.peel.i = zext i1 %cmp8.i85.peel.i to i32\n %or10.i87.peel.i = or i32 %conv9.i86.peel.i, %xor5.i81.peel.i\n %cmp11.i88.peel.i = icmp eq i32 %or10.i87.peel.i, %xor5.i81.peel.i\n %conv13.i89.peel.i = zext i1 %cmp8.i85.peel.i to i8\n ret i8 %conv13.i89.peel.i\n}\n```\n```\ndefine i8 @func_129() {\nentry:\n %sub.i.i79.peel.i = sub i16 0, 1\n %0 = insertelement <2 x i16> <i16 poison, i16 0>, i16 %sub.i.i79.peel.i, i32 0\n %1 = icmp slt <2 x i16> zeroinitializer, %0\n %2 = zext <2 x i1> %1 to <2 x i16>\n %3 = or <2 x i16> %2, %0\n %4 = icmp eq <2 x i16> %3, %0\n %5 = extractelement <2 x i1> %1, i32 0\n %conv13.i89.peel.i = zext i1 %5 to i8\n ret i8 %conv13.i89.peel.i\n}\n```\n```\n----------------------------------------\ndefine i8 @src() {\nentry:\n %sub.i.i79.peel.i = sub i16 0, 1\n %xor5.i81.peel.i = zext i16 %sub.i.i79.peel.i to i32\n %conv7.i84.peel.i = sext i16 0 to i32\n %cmp8.i85.peel.i = icmp slt i32 %conv7.i84.peel.i, %xor5.i81.peel.i\n %conv13.i89.peel.i = zext i1 %cmp8.i85.peel.i to i8\n ret i8 %conv13.i89.peel.i\n}\n=>\ndefine i8 @tgt() {\nentry:\n %sub.i.i79.peel.i = sub i16 0, 1\n %#0 = insertelement <2 x i16> { poison, 0 }, i16 %sub.i.i79.peel.i, i32 0\n %#1 = icmp slt <2 x i16> { 0, 0 }, %#0\n %#5 = extractelement <2 x i1> %#1, i32 0\n %conv13.i89.peel.i = zext i1 %#5 to i8\n ret i8 %conv13.i89.peel.i\n}\nTransformation doesn't verify!\n\nERROR: Value mismatch\n\nExample:\n\nSource:\ni16 %sub.i.i79.peel.i = #xffff (65535, -1)\ni32 %xor5.i81.peel.i = #x0000ffff (65535)\ni32 %conv7.i84.peel.i = #x00000000 (0)\ni1 %cmp8.i85.peel.i = #x1 (1)\ni8 %conv13.i89.peel.i = #x01 (1)\n\nTarget:\ni16 %sub.i.i79.peel.i = #xffff (65535, -1)\n<2 x i16> %#0 = < #xffff (65535, -1), #x0000 (0) >\n<2 x i1> %#1 = < #x0 (0), #x0 (0) >\ni1 %#5 = #x0 (0)\ni8 %conv13.i89.peel.i = #x00 (0)\nSource value: #x01 (1)\nTarget value: #x00 (0)\n```\n",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:SLPVectorizer"
],
"comments": [
{
"author": "fhahn",
"body": "cc @alexey-bataev \n"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
112460
|
https://github.com/llvm/llvm-project/issues/112460
|
miscompilation
|
65cf7afb6d9d8c6137b90d909ee4fcf251439f48
| 2024-10-16T01:34:25 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "e56e9dd8adca2e86f22783bf5e745ee1ba7ead5f",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
14953,
14958
],
[
17095,
17100
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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",
"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 e56e9dd8adca2e86f22783bf5e745ee1ba7ead5f
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Fri Oct 18 13:32:41 2024 -0700
[SLP]Fix minbitwidth emission and analysis for freeze instruction
Need to add minbw emission and analysis for freeze instruction to fix
incorrect signedness propagation.
Fixes #112460
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 53632efe913e..e7b52fbdcc3b 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -14953,6 +14953,12 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
return E->VectorizedValue;
}
+ if (Op->getType() != VecTy) {
+ assert((It != MinBWs.end() || getOperandEntry(E, 0)->isGather() ||
+ MinBWs.contains(getOperandEntry(E, 0))) &&
+ "Expected item in MinBWs.");
+ Op = Builder.CreateIntCast(Op, VecTy, GetOperandSignedness(0));
+ }
Value *V = Builder.CreateFreeze(Op);
V = FinalShuffle(V, E);
@@ -17095,6 +17101,8 @@ bool BoUpSLP::collectValuesToDemote(
return TryProcessInstruction(
BitWidth, {getOperandEntry(&E, 0), getOperandEntry(&E, 1)});
}
+ case Instruction::Freeze:
+ return TryProcessInstruction(BitWidth, getOperandEntry(&E, 0));
case Instruction::Shl: {
// If we are truncating the result of this SHL, and if it's a shift of an
// inrange amount, we can always perform a SHL in a smaller type.
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/freeze-signedness-missed.ll",
"commands": [
"opt -S --passes=slp-vectorizer < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define i32 @test(i1 %.b, i8 %conv18, i32 %k.promoted61) {\n %not..b79 = xor i1 %.b, true\n %1 = zext i1 %not..b79 to i8\n %cmp.i51 = icmp eq i8 %1, 0\n %cond.i55 = freeze i8 %1\n %.cmp = icmp ugt i8 %cond.i55, %conv18\n %.urem = select i1 %.cmp, i8 0, i8 %cond.i55\n %2 = sub nuw i8 %conv18, %.urem\n %cond.in.i = select i1 %cmp.i51, i8 %conv18, i8 %2\n %not..b80 = xor i1 %.b, true\n %3 = zext i1 %not..b80 to i8\n %cmp.i51.1 = icmp eq i8 %3, 0\n %cond.i55.1 = freeze i8 %3\n %.cmp.1 = icmp ugt i8 %cond.i55.1, %conv18\n %.urem.1 = select i1 %.cmp.1, i8 0, i8 %cond.i55.1\n %4 = sub nuw i8 %conv18, %.urem.1\n %cond.in.i.1 = select i1 %cmp.i51.1, i8 %conv18, i8 %4\n %not..b81 = xor i1 %.b, true\n %5 = zext i1 %not..b81 to i8\n %cmp.i51.2 = icmp eq i8 %5, 0\n %cond.i55.2 = freeze i8 %5\n %.cmp.2 = icmp ugt i8 %cond.i55.2, %conv18\n %.urem.2 = select i1 %.cmp.2, i8 0, i8 %cond.i55.2\n %6 = sub nuw i8 %conv18, %.urem.2\n %cond.in.i.2 = select i1 %cmp.i51.2, i8 %conv18, i8 %6\n %not..b = xor i1 %.b, true\n %7 = zext i1 %not..b to i8\n %cmp.i51.3 = icmp eq i8 %7, 0\n %cond.i55.3 = freeze i8 %7\n %.cmp.3 = icmp ugt i8 %cond.i55.3, %conv18\n %.urem.3 = select i1 %.cmp.3, i8 0, i8 %cond.i55.3\n %8 = sub nuw i8 %conv18, %.urem.3\n %cond.in.i.3 = select i1 %cmp.i51.3, i8 %conv18, i8 %8\n %conv26 = zext nneg i8 %cond.in.i to i32\n %or = or i32 %k.promoted61, %conv26\n %conv26.1 = zext nneg i8 %cond.in.i.1 to i32\n %or.1 = or i32 %or, %conv26.1\n %conv26.2 = zext nneg i8 %cond.in.i.2 to i32\n %or.2 = or i32 %or.1, %conv26.2\n %conv26.3 = zext nneg i8 %cond.in.i.3 to i32\n %or.3 = or i32 %or.2, %conv26.3\n ret i32 %or.3\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SLPVectorizer] Miscompilation at -O2",
"body": "Reproducer: https://alive2.llvm.org/ce/z/Tw0oUm\r\n```\r\n; bin/opt -passes=slp-vectorizer test.ll -S\r\ndefine i32 @src(i1 %.b, i8 %conv18, i32 %k.promoted61) {\r\n %not..b79 = xor i1 %.b, true\r\n %3 = zext i1 %not..b79 to i8\r\n %cmp.i51 = icmp eq i8 %3, 0\r\n %cond.i55.frozen = freeze i8 %3\r\n %.cmp = icmp ugt i8 %cond.i55.frozen, %conv18\r\n %.urem = select i1 %.cmp, i8 0, i8 %cond.i55.frozen\r\n %4 = sub nuw i8 %conv18, %.urem\r\n %cond.in.i = select i1 %cmp.i51, i8 %conv18, i8 %4\r\n %not..b80 = xor i1 %.b, true\r\n %5 = zext i1 %not..b80 to i8\r\n %cmp.i51.1 = icmp eq i8 %5, 0\r\n %cond.i55.frozen.1 = freeze i8 %5\r\n %.cmp.1 = icmp ugt i8 %cond.i55.frozen.1, %conv18\r\n %.urem.1 = select i1 %.cmp.1, i8 0, i8 %cond.i55.frozen.1\r\n %6 = sub nuw i8 %conv18, %.urem.1\r\n %cond.in.i.1 = select i1 %cmp.i51.1, i8 %conv18, i8 %6\r\n %not..b81 = xor i1 %.b, true\r\n %7 = zext i1 %not..b81 to i8\r\n %cmp.i51.2 = icmp eq i8 %7, 0\r\n %cond.i55.frozen.2 = freeze i8 %7\r\n %.cmp.2 = icmp ugt i8 %cond.i55.frozen.2, %conv18\r\n %.urem.2 = select i1 %.cmp.2, i8 0, i8 %cond.i55.frozen.2\r\n %8 = sub nuw i8 %conv18, %.urem.2\r\n %cond.in.i.2 = select i1 %cmp.i51.2, i8 %conv18, i8 %8\r\n %not..b = xor i1 %.b, true\r\n %9 = zext i1 %not..b to i8\r\n %cmp.i51.3 = icmp eq i8 %9, 0\r\n %cond.i55.frozen.3 = freeze i8 %9\r\n %.cmp.3 = icmp ugt i8 %cond.i55.frozen.3, %conv18\r\n %.urem.3 = select i1 %.cmp.3, i8 0, i8 %cond.i55.frozen.3\r\n %10 = sub nuw i8 %conv18, %.urem.3\r\n %cond.in.i.3 = select i1 %cmp.i51.3, i8 %conv18, i8 %10\r\n %conv26 = zext nneg i8 %cond.in.i to i32\r\n %or = or i32 %k.promoted61, %conv26\r\n %conv26.1 = zext nneg i8 %cond.in.i.1 to i32\r\n %or.1 = or i32 %or, %conv26.1\r\n %conv26.2 = zext nneg i8 %cond.in.i.2 to i32\r\n %or.2 = or i32 %or.1, %conv26.2\r\n %conv26.3 = zext nneg i8 %cond.in.i.3 to i32\r\n %or.3 = or i32 %or.2, %conv26.3\r\n ret i32 %or.3\r\n}\r\n```\r\n```\r\ndefine i32 @src(i1 %.b, i8 %conv18, i32 %k.promoted61) {\r\n %1 = insertelement <4 x i1> poison, i1 %.b, i32 0\r\n %2 = shufflevector <4 x i1> %1, <4 x i1> poison, <4 x i32> zeroinitializer\r\n %3 = xor <4 x i1> %2, <i1 true, i1 true, i1 true, i1 true>\r\n %4 = zext <4 x i1> %3 to <4 x i8>\r\n %5 = icmp eq <4 x i8> %4, zeroinitializer\r\n %6 = freeze <4 x i1> %3\r\n %7 = sext <4 x i1> %6 to <4 x i8>\r\n %8 = insertelement <4 x i8> poison, i8 %conv18, i32 0\r\n %9 = shufflevector <4 x i8> %8, <4 x i8> poison, <4 x i32> zeroinitializer\r\n %10 = icmp ugt <4 x i8> %7, %9\r\n %11 = select <4 x i1> %10, <4 x i8> zeroinitializer, <4 x i8> %7\r\n %12 = sub nuw <4 x i8> %9, %11\r\n %13 = select <4 x i1> %5, <4 x i8> %9, <4 x i8> %12\r\n %14 = zext <4 x i8> %13 to <4 x i32>\r\n %15 = call i32 @llvm.vector.reduce.or.v4i32(<4 x i32> %14)\r\n %op.rdx = or i32 %15, %k.promoted61\r\n ret i32 %op.rdx\r\n}\r\n```\r\n```\r\nTransformation doesn't verify!\r\n\r\nERROR: Value mismatch\r\n\r\nExample:\r\ni1 %.b = #x0 (0)\r\ni8 %conv18 = #x01 (1)\r\ni32 %k.promoted61 = #x00000000 (0)\r\n\r\nSource:\r\ni1 %not..b79 = #x1 (1)\r\ni8 %#1 = #x01 (1)\r\ni1 %cmp.i51 = #x0 (0)\r\ni8 %cond.i55.frozen = #x01 (1)\r\ni1 %.cmp = #x0 (0)\r\ni8 %.urem = #x01 (1)\r\ni8 %#2 = #x00 (0)\r\ni8 %cond.in.i = #x00 (0)\r\ni1 %not..b80 = #x1 (1)\r\ni8 %#3 = #x01 (1)\r\ni1 %cmp.i51.1 = #x0 (0)\r\ni8 %cond.i55.frozen.1 = #x01 (1)\r\ni1 %.cmp.1 = #x0 (0)\r\ni8 %.urem.1 = #x01 (1)\r\ni8 %#4 = #x00 (0)\r\ni8 %cond.in.i.1 = #x00 (0)\r\ni1 %not..b81 = #x1 (1)\r\ni8 %#5 = #x01 (1)\r\ni1 %cmp.i51.2 = #x0 (0)\r\ni8 %cond.i55.frozen.2 = #x01 (1)\r\ni1 %.cmp.2 = #x0 (0)\r\ni8 %.urem.2 = #x01 (1)\r\ni8 %#6 = #x00 (0)\r\ni8 %cond.in.i.2 = #x00 (0)\r\ni1 %not..b = #x1 (1)\r\ni8 %#7 = #x01 (1)\r\ni1 %cmp.i51.3 = #x0 (0)\r\ni8 %cond.i55.frozen.3 = #x01 (1)\r\ni1 %.cmp.3 = #x0 (0)\r\ni8 %.urem.3 = #x01 (1)\r\ni8 %#8 = #x00 (0)\r\ni8 %cond.in.i.3 = #x00 (0)\r\ni32 %conv26 = #x00000000 (0)\r\ni32 %or = #x00000000 (0)\r\ni32 %conv26.1 = #x00000000 (0)\r\ni32 %or.1 = #x00000000 (0)\r\ni32 %conv26.2 = #x00000000 (0)\r\ni32 %or.2 = #x00000000 (0)\r\ni32 %conv26.3 = #x00000000 (0)\r\ni32 %or.3 = #x00000000 (0)\r\n\r\nTarget:\r\n<4 x i1> %#1 = < #x0 (0), poison, poison, poison >\r\n<4 x i1> %#2 = < #x0 (0), #x0 (0), #x0 (0), #x0 (0) >\r\n<4 x i1> %#3 = < #x1 (1), #x1 (1), #x1 (1), #x1 (1) >\r\n<4 x i8> %#4 = < #x01 (1), #x01 (1), #x01 (1), #x01 (1) >\r\n<4 x i1> %#5 = < #x0 (0), #x0 (0), #x0 (0), #x0 (0) >\r\n<4 x i1> %#6 = < #x1 (1), #x1 (1), #x1 (1), #x1 (1) >\r\n<4 x i8> %#7 = < #xff (255, -1), #xff (255, -1), #xff (255, -1), #xff (255, -1) >\r\n<4 x i8> %#8 = < #x01 (1), poison, poison, poison >\r\n<4 x i8> %#9 = < #x01 (1), #x01 (1), #x01 (1), #x01 (1) >\r\n<4 x i1> %#10 = < #x1 (1), #x1 (1), #x1 (1), #x1 (1) >\r\n<4 x i8> %#11 = < #x00 (0), #x00 (0), #x00 (0), #x00 (0) >\r\n<4 x i8> %#12 = < #x01 (1), #x01 (1), #x01 (1), #x01 (1) >\r\n<4 x i8> %#13 = < #x01 (1), #x01 (1), #x01 (1), #x01 (1) >\r\n<4 x i32> %#14 = < #x00000001 (1), #x00000001 (1), #x00000001 (1), #x00000001 (1) >\r\ni32 %#15 = #x00000001 (1)\r\ni32 %op.rdx = #x00000001 (1)\r\nSource value: #x00000000 (0)\r\nTarget value: #x00000001 (1)\r\n```\r\n\r\nllvm version: 69f7758ddba662b63667507f2c472c008909dd7e\r\ncc @alexey-bataev ",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:SLPVectorizer"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
139202
|
https://github.com/llvm/llvm-project/issues/139202
|
miscompilation
|
8bd35ca41253ea36fff78d5acf59956a30b6555b
| 2025-05-09T03:49:41 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "c807395011a027caae9ac196edfac328fb90443a",
"components": [
"LoopAccessAnalysis",
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
1584,
1590
],
[
2216,
2222
],
[
3619,
3627
],
[
5368,
5374
],
[
5442,
5448
],
[
5540,
5547
],
[
5868,
5874
],
[
5894,
5900
],
[
5921,
5931
],
[
6051,
6059
],
[
6061,
6069
],
[
6081,
6089
],
[
6122,
6128
],
[
6165,
6174
],
[
6427,
6434
],
[
6441,
6450
],
[
6494,
6503
],
[
7007,
7013
],
[
7999,
8005
],
[
8027,
8040
],
[
8046,
8052
],
[
8130,
8144
],
[
8154,
8160
],
[
8176,
8186
],
[
8191,
8206
],
[
8231,
8240
],
[
8249,
8255
],
[
8259,
8265
],
[
8267,
8273
],
[
8280,
8288
],
[
8291,
8298
],
[
8454,
8481
],
[
8698,
8709
],
[
9299,
9308
],
[
10751,
10757
],
[
11950,
11956
],
[
18270,
18281
],
[
21133,
21150
],
[
21155,
21161
],
[
21171,
21177
],
[
21204,
21210
],
[
21505,
21511
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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": [
[
853,
863
]
],
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": [
[
1541,
1551
],
[
1570,
1576
],
[
1585,
1591
],
[
1594,
1603
],
[
1616,
1629
],
[
1654,
1660
]
],
"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::canFormVector",
"BoUpSLP::canMapToVector",
"BoUpSLP::canVectorizeLoads",
"BoUpSLP::collectUserStores",
"BoUpSLP::findReusedOrderedScalars",
"BoUpSLP::getScalarsVectorizationState",
"BoUpSLP::transformNodes",
"BoUpSLP::tryToVectorizeGatheredLoads",
"BoUpSLP::vectorizeTree",
"SLPVectorizerPass::vectorizeStores",
"buildCompressMask",
"clearVectorizedStores",
"clusterSortPtrAccesses",
"combineOrders",
"fixupOrderingIndices",
"gatherPossiblyVectorizableLoads",
"getPointerDiff",
"getShallowScore",
"getStores",
"insertOrLookup",
"isMaskedLoadCompress",
"isStridedLoad",
"rebase"
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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": [
"llvm::getPointersDiff",
"llvm::getPtrStride",
"llvm::isConsecutiveAccess",
"llvm::sortPtrAccesses"
],
"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 c807395011a027caae9ac196edfac328fb90443a
Author: Ramkumar Ramachandra <ramkumar.ramachandra@codasip.com>
Date: Thu May 15 10:08:05 2025 +0100
[LAA/SLP] Don't truncate APInt in getPointersDiff (#139941)
Change getPointersDiff to return an std::optional<int64_t>, and fill
this value with using APInt::trySExtValue. This simple change requires
changes to other functions in LAA, and major changes in SLPVectorizer
changing types from 32-bit to 64-bit.
Fixes #139202.
diff --git a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
index f715e0ec8dbb..fea2ede8b5ab 100644
--- a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
+++ b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
@@ -853,11 +853,10 @@ getPtrStride(PredicatedScalarEvolution &PSE, Type *AccessTy, Value *Ptr,
/// is a simple API that does not depend on the analysis pass.
/// \param StrictCheck Ensure that the calculated distance matches the
/// type-based one after all the bitcasts removal in the provided pointers.
-std::optional<int> getPointersDiff(Type *ElemTyA, Value *PtrA, Type *ElemTyB,
- Value *PtrB, const DataLayout &DL,
- ScalarEvolution &SE,
- bool StrictCheck = false,
- bool CheckType = true);
+std::optional<int64_t>
+getPointersDiff(Type *ElemTyA, Value *PtrA, Type *ElemTyB, Value *PtrB,
+ const DataLayout &DL, ScalarEvolution &SE,
+ bool StrictCheck = false, bool CheckType = true);
/// Attempt to sort the pointers in \p VL and return the sorted indices
/// in \p SortedIndices, if reordering is required.
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index af1a3c593c51..ab407e945bc5 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -1541,11 +1541,11 @@ llvm::getPtrStride(PredicatedScalarEvolution &PSE, Type *AccessTy, Value *Ptr,
return std::nullopt;
}
-std::optional<int> llvm::getPointersDiff(Type *ElemTyA, Value *PtrA,
- Type *ElemTyB, Value *PtrB,
- const DataLayout &DL,
- ScalarEvolution &SE, bool StrictCheck,
- bool CheckType) {
+std::optional<int64_t> llvm::getPointersDiff(Type *ElemTyA, Value *PtrA,
+ Type *ElemTyB, Value *PtrB,
+ const DataLayout &DL,
+ ScalarEvolution &SE,
+ bool StrictCheck, bool CheckType) {
assert(PtrA && PtrB && "Expected non-nullptr pointers.");
// Make sure that A and B are different pointers.
@@ -1570,7 +1570,7 @@ std::optional<int> llvm::getPointersDiff(Type *ElemTyA, Value *PtrA,
const Value *PtrB1 = PtrB->stripAndAccumulateConstantOffsets(
DL, OffsetB, /*AllowNonInbounds=*/true);
- int Val;
+ std::optional<int64_t> Val;
if (PtrA1 == PtrB1) {
// Retrieve the address space again as pointer stripping now tracks through
// `addrspacecast`.
@@ -1585,7 +1585,7 @@ std::optional<int> llvm::getPointersDiff(Type *ElemTyA, Value *PtrA,
OffsetB = OffsetB.sextOrTrunc(IdxWidth);
OffsetB -= OffsetA;
- Val = OffsetB.getSExtValue();
+ Val = OffsetB.trySExtValue();
} else {
// Otherwise compute the distance with SCEV between the base pointers.
const SCEV *PtrSCEVA = SE.getSCEV(PtrA);
@@ -1594,10 +1594,14 @@ std::optional<int> llvm::getPointersDiff(Type *ElemTyA, Value *PtrA,
SE.computeConstantDifference(PtrSCEVB, PtrSCEVA);
if (!Diff)
return std::nullopt;
- Val = Diff->getSExtValue();
+ Val = Diff->trySExtValue();
}
- int Size = DL.getTypeStoreSize(ElemTyA);
- int Dist = Val / Size;
+
+ if (!Val)
+ return std::nullopt;
+
+ int64_t Size = DL.getTypeStoreSize(ElemTyA);
+ int64_t Dist = *Val / Size;
// Ensure that the calculated distance matches the type-based one after all
// the bitcasts removal in the provided pointers.
@@ -1616,14 +1620,15 @@ bool llvm::sortPtrAccesses(ArrayRef<Value *> VL, Type *ElemTy,
// first pointer in the array.
Value *Ptr0 = VL[0];
- using DistOrdPair = std::pair<int64_t, int>;
+ using DistOrdPair = std::pair<int64_t, unsigned>;
auto Compare = llvm::less_first();
std::set<DistOrdPair, decltype(Compare)> Offsets(Compare);
Offsets.emplace(0, 0);
bool IsConsecutive = true;
for (auto [Idx, Ptr] : drop_begin(enumerate(VL))) {
- std::optional<int> Diff = getPointersDiff(ElemTy, Ptr0, ElemTy, Ptr, DL, SE,
- /*StrictCheck=*/true);
+ std::optional<int64_t> Diff =
+ getPointersDiff(ElemTy, Ptr0, ElemTy, Ptr, DL, SE,
+ /*StrictCheck=*/true);
if (!Diff)
return false;
@@ -1654,7 +1659,7 @@ bool llvm::isConsecutiveAccess(Value *A, Value *B, const DataLayout &DL,
return false;
Type *ElemTyA = getLoadStoreType(A);
Type *ElemTyB = getLoadStoreType(B);
- std::optional<int> Diff =
+ std::optional<int64_t> Diff =
getPointersDiff(ElemTyA, PtrA, ElemTyB, PtrB, DL, SE,
/*StrictCheck=*/true, CheckType);
return Diff && *Diff == 1;
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index d8cf6b82a197..eb339282fdae 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -1584,7 +1584,7 @@ static void addMask(SmallVectorImpl<int> &Mask, ArrayRef<int> SubMask,
/// before: 6 9 5 4 9 2 1 0
/// after: 6 3 5 4 7 2 1 0
static void fixupOrderingIndices(MutableArrayRef<unsigned> Order) {
- const unsigned Sz = Order.size();
+ const size_t Sz = Order.size();
SmallBitVector UnusedIndices(Sz, /*t=*/true);
SmallBitVector MaskedIndices(Sz);
for (unsigned I = 0; I < Sz; ++I) {
@@ -2216,7 +2216,7 @@ public:
!LI2->isSimple())
return CheckSameEntryOrFail();
- std::optional<int> Dist = getPointersDiff(
+ std::optional<int64_t> Dist = getPointersDiff(
LI1->getType(), LI1->getPointerOperand(), LI2->getType(),
LI2->getPointerOperand(), DL, SE, /*StrictCheck=*/true);
if (!Dist || *Dist == 0) {
@@ -3619,9 +3619,10 @@ private:
/// vector loads/masked gathers instead of regular gathers. Later these loads
/// are reshufled to build final gathered nodes.
void tryToVectorizeGatheredLoads(
- const SmallMapVector<std::tuple<BasicBlock *, Value *, Type *>,
- SmallVector<SmallVector<std::pair<LoadInst *, int>>>,
- 8> &GatheredLoads);
+ const SmallMapVector<
+ std::tuple<BasicBlock *, Value *, Type *>,
+ SmallVector<SmallVector<std::pair<LoadInst *, int64_t>>>, 8>
+ &GatheredLoads);
/// Helper for `findExternalStoreUsersReorderIndices()`. It iterates over the
/// users of \p TE and collects the stores. It returns the map from the store
@@ -5368,7 +5369,7 @@ BoUpSLP::findReusedOrderedScalars(const BoUpSLP::TreeEntry &TE,
// patterns.
SmallVector<Value *> GatheredScalars(TE.Scalars.begin(), TE.Scalars.end());
Type *ScalarTy = GatheredScalars.front()->getType();
- int NumScalars = GatheredScalars.size();
+ size_t NumScalars = GatheredScalars.size();
if (!isValidElementType(ScalarTy))
return std::nullopt;
auto *VecTy = getWidenedType(ScalarTy, NumScalars);
@@ -5442,7 +5443,7 @@ BoUpSLP::findReusedOrderedScalars(const BoUpSLP::TreeEntry &TE,
unsigned Limit = getNumElems(CurrentOrder.size(), PartSz, I);
MutableArrayRef<unsigned> Slice = CurrentOrder.slice(I * PartSz, Limit);
// Shuffle of at least 2 vectors - ignore.
- if (any_of(Slice, [&](int I) { return I != NumScalars; })) {
+ if (any_of(Slice, [&](unsigned I) { return I != NumScalars; })) {
std::fill(Slice.begin(), Slice.end(), NumScalars);
ShuffledSubMasks.set(I);
continue;
@@ -5540,8 +5541,8 @@ BoUpSLP::findReusedOrderedScalars(const BoUpSLP::TreeEntry &TE,
return std::max(Entries[I].front()->getVectorFactor(),
Entries[I].back()->getVectorFactor());
});
- int NumUndefs =
- count_if(CurrentOrder, [&](int Idx) { return Idx == NumScalars; });
+ unsigned NumUndefs =
+ count_if(CurrentOrder, [&](unsigned Idx) { return Idx == NumScalars; });
if (ShuffledSubMasks.all() || (NumScalars > 2 && NumUndefs >= NumScalars / 2))
return std::nullopt;
return std::move(CurrentOrder);
@@ -5868,7 +5869,11 @@ static bool buildCompressMask(ArrayRef<Value *> PointerOps,
Value *Ptr0 = Order.empty() ? PointerOps.front() : PointerOps[Order.front()];
for (unsigned I : seq<unsigned>(1, Sz)) {
Value *Ptr = Order.empty() ? PointerOps[I] : PointerOps[Order[I]];
- unsigned Pos = *getPointersDiff(ScalarTy, Ptr0, ScalarTy, Ptr, DL, SE);
+ std::optional<int64_t> OptPos =
+ getPointersDiff(ScalarTy, Ptr0, ScalarTy, Ptr, DL, SE);
+ if (!OptPos || OptPos > std::numeric_limits<unsigned>::max())
+ return false;
+ unsigned Pos = static_cast<unsigned>(*OptPos);
CompressMask[I] = Pos;
if (!Stride)
continue;
@@ -5894,7 +5899,7 @@ static bool isMaskedLoadCompress(
VectorType *&LoadVecTy) {
InterleaveFactor = 0;
Type *ScalarTy = VL.front()->getType();
- const unsigned Sz = VL.size();
+ const size_t Sz = VL.size();
auto *VecTy = getWidenedType(ScalarTy, Sz);
constexpr TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
SmallVector<int> Mask;
@@ -5921,11 +5926,11 @@ static bool isMaskedLoadCompress(
Ptr0 = PointerOps[Order.front()];
PtrN = PointerOps[Order.back()];
}
- std::optional<int> Diff =
+ std::optional<int64_t> Diff =
getPointersDiff(ScalarTy, Ptr0, ScalarTy, PtrN, DL, SE);
if (!Diff)
return false;
- const unsigned MaxRegSize =
+ const size_t MaxRegSize =
TTI.getRegisterBitWidth(TargetTransformInfo::RGK_FixedWidthVector)
.getFixedValue();
// Check for very large distances between elements.
@@ -6051,9 +6056,10 @@ static bool isStridedLoad(ArrayRef<Value *> VL, ArrayRef<Value *> PointerOps,
ArrayRef<unsigned> Order,
const TargetTransformInfo &TTI, const DataLayout &DL,
ScalarEvolution &SE,
- const bool IsAnyPointerUsedOutGraph, const int Diff) {
- const unsigned Sz = VL.size();
- const unsigned AbsoluteDiff = std::abs(Diff);
+ const bool IsAnyPointerUsedOutGraph,
+ const int64_t Diff) {
+ const size_t Sz = VL.size();
+ const uint64_t AbsoluteDiff = std::abs(Diff);
Type *ScalarTy = VL.front()->getType();
auto *VecTy = getWidenedType(ScalarTy, Sz);
if (IsAnyPointerUsedOutGraph ||
@@ -6061,9 +6067,9 @@ static bool isStridedLoad(ArrayRef<Value *> VL, ArrayRef<Value *> PointerOps,
(Sz > MinProfitableStridedLoads ||
(AbsoluteDiff <= MaxProfitableLoadStride * Sz &&
AbsoluteDiff % Sz == 0 && has_single_bit(AbsoluteDiff / Sz)))) ||
- Diff == -(static_cast<int>(Sz) - 1)) {
- int Stride = Diff / static_cast<int>(Sz - 1);
- if (Diff != Stride * static_cast<int>(Sz - 1))
+ Diff == -(static_cast<int64_t>(Sz) - 1)) {
+ int64_t Stride = Diff / static_cast<int64_t>(Sz - 1);
+ if (Diff != Stride * static_cast<int64_t>(Sz - 1))
return false;
Align Alignment =
cast<LoadInst>(Order.empty() ? VL.front() : VL[Order.front()])
@@ -6081,9 +6087,9 @@ static bool isStridedLoad(ArrayRef<Value *> VL, ArrayRef<Value *> PointerOps,
}
// Iterate through all pointers and check if all distances are
// unique multiple of Dist.
- SmallSet<int, 4> Dists;
+ SmallSet<int64_t, 4> Dists;
for (Value *Ptr : PointerOps) {
- int Dist = 0;
+ int64_t Dist = 0;
if (Ptr == PtrN)
Dist = Diff;
else if (Ptr != Ptr0)
@@ -6122,7 +6128,7 @@ BoUpSLP::canVectorizeLoads(ArrayRef<Value *> VL, const Value *VL0,
// Make sure all loads in the bundle are simple - we can't vectorize
// atomic or volatile loads.
PointerOps.clear();
- const unsigned Sz = VL.size();
+ const size_t Sz = VL.size();
PointerOps.resize(Sz);
auto *POIter = PointerOps.begin();
for (Value *V : VL) {
@@ -6165,10 +6171,10 @@ BoUpSLP::canVectorizeLoads(ArrayRef<Value *> VL, const Value *VL0,
Ptr0 = PointerOps[Order.front()];
PtrN = PointerOps[Order.back()];
}
- std::optional<int> Diff =
+ std::optional<int64_t> Diff =
getPointersDiff(ScalarTy, Ptr0, ScalarTy, PtrN, *DL, *SE);
// Check that the sorted loads are consecutive.
- if (static_cast<unsigned>(*Diff) == Sz - 1)
+ if (static_cast<uint64_t>(*Diff) == Sz - 1)
return LoadsState::Vectorize;
if (isMaskedLoadCompress(VL, PointerOps, Order, *TTI, *DL, *SE, *AC, *DT,
*TLI, [&](Value *V) {
@@ -6427,8 +6433,9 @@ static bool clusterSortPtrAccesses(ArrayRef<Value *> VL,
// Map from bases to a vector of (Ptr, Offset, OrigIdx), which we insert each
// Ptr into, sort and return the sorted indices with values next to one
// another.
- SmallMapVector<std::pair<BasicBlock *, Value *>,
- SmallVector<SmallVector<std::tuple<Value *, int, unsigned>>>, 8>
+ SmallMapVector<
+ std::pair<BasicBlock *, Value *>,
+ SmallVector<SmallVector<std::tuple<Value *, int64_t, unsigned>>>, 8>
Bases;
Bases
.try_emplace(std::make_pair(
@@ -6441,10 +6448,10 @@ static bool clusterSortPtrAccesses(ArrayRef<Value *> VL,
getUnderlyingObject(Ptr, RecursionMaxDepth));
bool Found = any_of(Bases.try_emplace(Key).first->second,
[&, &Cnt = Cnt, &Ptr = Ptr](auto &Base) {
- std::optional<int> Diff = getPointersDiff(
- ElemTy, std::get<0>(Base.front()), ElemTy,
- Ptr, DL, SE,
- /*StrictCheck=*/true);
+ std::optional<int64_t> Diff =
+ getPointersDiff(ElemTy, std::get<0>(Base.front()),
+ ElemTy, Ptr, DL, SE,
+ /*StrictCheck=*/true);
if (!Diff)
return false;
@@ -6494,10 +6501,11 @@ static bool clusterSortPtrAccesses(ArrayRef<Value *> VL,
for (auto &Vec : Base.second) {
if (Vec.size() > 1) {
stable_sort(Vec, llvm::less_second());
- int InitialOffset = std::get<1>(Vec[0]);
+ int64_t InitialOffset = std::get<1>(Vec[0]);
bool AnyConsecutive =
all_of(enumerate(Vec), [InitialOffset](const auto &P) {
- return std::get<1>(P.value()) == int(P.index()) + InitialOffset;
+ return std::get<1>(P.value()) ==
+ int64_t(P.index()) + InitialOffset;
});
// Fill SortedIndices array only if it looks worth-while to sort the
// ptrs.
@@ -7007,7 +7015,7 @@ static void combineOrders(MutableArrayRef<unsigned> Order,
ArrayRef<unsigned> SecondaryOrder) {
assert((SecondaryOrder.empty() || Order.size() == SecondaryOrder.size()) &&
"Expected same size of orders");
- unsigned Sz = Order.size();
+ size_t Sz = Order.size();
SmallBitVector UsedIndices(Sz);
for (unsigned Idx : seq<unsigned>(0, Sz)) {
if (Order[Idx] != Sz)
@@ -7999,7 +8007,7 @@ BoUpSLP::collectUserStores(const BoUpSLP::TreeEntry *TE) const {
if (StoresVec.size() > Lane)
continue;
if (!StoresVec.empty()) {
- std::optional<int> Diff = getPointersDiff(
+ std::optional<int64_t> Diff = getPointersDiff(
SI->getValueOperand()->getType(), SI->getPointerOperand(),
SI->getValueOperand()->getType(),
StoresVec.front()->getPointerOperand(), *DL, *SE,
@@ -8027,14 +8035,14 @@ bool BoUpSLP::canFormVector(ArrayRef<StoreInst *> StoresVec,
// To avoid calling getPointersDiff() while sorting we create a vector of
// pairs {store, offset from first} and sort this instead.
- SmallVector<std::pair<int, unsigned>> StoreOffsetVec;
+ SmallVector<std::pair<int64_t, unsigned>> StoreOffsetVec;
StoreInst *S0 = StoresVec[0];
StoreOffsetVec.emplace_back(0, 0);
Type *S0Ty = S0->getValueOperand()->getType();
Value *S0Ptr = S0->getPointerOperand();
for (unsigned Idx : seq<unsigned>(1, StoresVec.size())) {
StoreInst *SI = StoresVec[Idx];
- std::optional<int> Diff =
+ std::optional<int64_t> Diff =
getPointersDiff(S0Ty, S0Ptr, SI->getValueOperand()->getType(),
SI->getPointerOperand(), *DL, *SE,
/*StrictCheck=*/true);
@@ -8046,7 +8054,7 @@ bool BoUpSLP::canFormVector(ArrayRef<StoreInst *> StoresVec,
return false;
sort(StoreOffsetVec, llvm::less_first());
unsigned Idx = 0;
- int PrevDist = 0;
+ int64_t PrevDist = 0;
for (const auto &P : StoreOffsetVec) {
if (Idx > 0 && P.first != PrevDist + 1)
return false;
@@ -8130,15 +8138,15 @@ void BoUpSLP::buildTree(ArrayRef<Value *> Roots) {
static void gatherPossiblyVectorizableLoads(
const BoUpSLP &R, ArrayRef<Value *> VL, const DataLayout &DL,
ScalarEvolution &SE, const TargetTransformInfo &TTI,
- SmallVectorImpl<SmallVector<std::pair<LoadInst *, int>>> &GatheredLoads,
+ SmallVectorImpl<SmallVector<std::pair<LoadInst *, int64_t>>> &GatheredLoads,
bool AddNew = true) {
if (VL.empty())
return;
Type *ScalarTy = getValueType(VL.front());
if (!isValidElementType(ScalarTy))
return;
- SmallVector<SmallVector<std::pair<LoadInst *, int>>> ClusteredLoads;
- SmallVector<DenseMap<int, LoadInst *>> ClusteredDistToLoad;
+ SmallVector<SmallVector<std::pair<LoadInst *, int64_t>>> ClusteredLoads;
+ SmallVector<DenseMap<int64_t, LoadInst *>> ClusteredDistToLoad;
for (Value *V : VL) {
auto *LI = dyn_cast<LoadInst>(V);
if (!LI)
@@ -8154,7 +8162,7 @@ static void gatherPossiblyVectorizableLoads(
RecursionMaxDepth) &&
"Expected loads with the same type, same parent and same "
"underlying pointer.");
- std::optional<int> Dist = getPointersDiff(
+ std::optional<int64_t> Dist = getPointersDiff(
LI->getType(), LI->getPointerOperand(), Data.front().first->getType(),
Data.front().first->getPointerOperand(), DL, SE,
/*StrictCheck=*/true);
@@ -8176,11 +8184,11 @@ static void gatherPossiblyVectorizableLoads(
}
}
auto FindMatchingLoads =
- [&](ArrayRef<std::pair<LoadInst *, int>> Loads,
- SmallVectorImpl<SmallVector<std::pair<LoadInst *, int>>>
+ [&](ArrayRef<std::pair<LoadInst *, int64_t>> Loads,
+ SmallVectorImpl<SmallVector<std::pair<LoadInst *, int64_t>>>
&GatheredLoads,
SetVector<unsigned> &ToAdd, SetVector<unsigned> &Repeated,
- int &Offset, unsigned &Start) {
+ int64_t &Offset, unsigned &Start) {
if (Loads.empty())
return GatheredLoads.end();
LoadInst *LI = Loads.front().first;
@@ -8191,16 +8199,16 @@ static void gatherPossiblyVectorizableLoads(
if (LI->getParent() != Data.front().first->getParent() ||
LI->getType() != Data.front().first->getType())
continue;
- std::optional<int> Dist =
+ std::optional<int64_t> Dist =
getPointersDiff(LI->getType(), LI->getPointerOperand(),
Data.front().first->getType(),
Data.front().first->getPointerOperand(), DL, SE,
/*StrictCheck=*/true);
if (!Dist)
continue;
- SmallSet<int, 4> DataDists;
+ SmallSet<int64_t, 4> DataDists;
SmallPtrSet<LoadInst *, 4> DataLoads;
- for (std::pair<LoadInst *, int> P : Data) {
+ for (std::pair<LoadInst *, int64_t> P : Data) {
DataDists.insert(P.second);
DataLoads.insert(P.first);
}
@@ -8231,10 +8239,10 @@ static void gatherPossiblyVectorizableLoads(
ToAdd.clear();
return GatheredLoads.end();
};
- for (ArrayRef<std::pair<LoadInst *, int>> Data : ClusteredLoads) {
+ for (ArrayRef<std::pair<LoadInst *, int64_t>> Data : ClusteredLoads) {
unsigned Start = 0;
SetVector<unsigned> ToAdd, LocalToAdd, Repeated;
- int Offset = 0;
+ int64_t Offset = 0;
auto *It = FindMatchingLoads(Data, GatheredLoads, LocalToAdd, Repeated,
Offset, Start);
while (It != GatheredLoads.end()) {
@@ -8249,7 +8257,7 @@ static void gatherPossiblyVectorizableLoads(
return !ToAdd.contains(Idx) && !Repeated.contains(Idx);
})) {
auto AddNewLoads =
- [&](SmallVectorImpl<std::pair<LoadInst *, int>> &Loads) {
+ [&](SmallVectorImpl<std::pair<LoadInst *, int64_t>> &Loads) {
for (unsigned Idx : seq<unsigned>(Data.size())) {
if (ToAdd.contains(Idx) || Repeated.contains(Idx))
continue;
@@ -8259,7 +8267,7 @@ static void gatherPossiblyVectorizableLoads(
if (!AddNew) {
LoadInst *LI = Data.front().first;
It = find_if(
- GatheredLoads, [&](ArrayRef<std::pair<LoadInst *, int>> PD) {
+ GatheredLoads, [&](ArrayRef<std::pair<LoadInst *, int64_t>> PD) {
return PD.front().first->getParent() == LI->getParent() &&
PD.front().first->getType() == LI->getType();
});
@@ -8267,7 +8275,7 @@ static void gatherPossiblyVectorizableLoads(
AddNewLoads(*It);
It = std::find_if(
std::next(It), GatheredLoads.end(),
- [&](ArrayRef<std::pair<LoadInst *, int>> PD) {
+ [&](ArrayRef<std::pair<LoadInst *, int64_t>> PD) {
return PD.front().first->getParent() == LI->getParent() &&
PD.front().first->getType() == LI->getType();
});
@@ -8280,9 +8288,10 @@ static void gatherPossiblyVectorizableLoads(
}
void BoUpSLP::tryToVectorizeGatheredLoads(
- const SmallMapVector<std::tuple<BasicBlock *, Value *, Type *>,
- SmallVector<SmallVector<std::pair<LoadInst *, int>>>,
- 8> &GatheredLoads) {
+ const SmallMapVector<
+ std::tuple<BasicBlock *, Value *, Type *>,
+ SmallVector<SmallVector<std::pair<LoadInst *, int64_t>>>, 8>
+ &GatheredLoads) {
GatheredLoadsEntriesFirst = VectorizableTree.size();
SmallVector<SmallPtrSet<const Value *, 4>> LoadSetsToVectorize(
@@ -8291,8 +8300,8 @@ void BoUpSLP::tryToVectorizeGatheredLoads(
Set.insert_range(VectorizableTree[Idx]->Scalars);
// Sort loads by distance.
- auto LoadSorter = [](const std::pair<LoadInst *, int> &L1,
- const std::pair<LoadInst *, int> &L2) {
+ auto LoadSorter = [](const std::pair<LoadInst *, int64_t> &L1,
+ const std::pair<LoadInst *, int64_t> &L2) {
return L1.second > L2.second;
};
@@ -8454,28 +8463,30 @@ void BoUpSLP::tryToVectorizeGatheredLoads(
};
auto ProcessGatheredLoads =
[&, &TTI = *TTI](
- ArrayRef<SmallVector<std::pair<LoadInst *, int>>> GatheredLoads,
+ ArrayRef<SmallVector<std::pair<LoadInst *, int64_t>>> GatheredLoads,
bool Final = false) {
SmallVector<LoadInst *> NonVectorized;
- for (ArrayRef<std::pair<LoadInst *, int>> LoadsDists : GatheredLoads) {
+ for (ArrayRef<std::pair<LoadInst *, int64_t>> LoadsDists :
+ GatheredLoads) {
if (LoadsDists.size() <= 1) {
NonVectorized.push_back(LoadsDists.back().first);
continue;
}
- SmallVector<std::pair<LoadInst *, int>> LocalLoadsDists(LoadsDists);
+ SmallVector<std::pair<LoadInst *, int64_t>> LocalLoadsDists(
+ LoadsDists);
SmallVector<LoadInst *> OriginalLoads(make_first_range(LoadsDists));
stable_sort(LocalLoadsDists, LoadSorter);
SmallVector<LoadInst *> Loads;
unsigned MaxConsecutiveDistance = 0;
unsigned CurrentConsecutiveDist = 1;
- int LastDist = LocalLoadsDists.front().second;
+ int64_t LastDist = LocalLoadsDists.front().second;
bool AllowMaskedGather = IsMaskedGatherSupported(OriginalLoads);
- for (const std::pair<LoadInst *, int> &L : LocalLoadsDists) {
+ for (const std::pair<LoadInst *, int64_t> &L : LocalLoadsDists) {
if (isVectorized(L.first))
continue;
assert(LastDist >= L.second &&
"Expected first distance always not less than second");
- if (static_cast<unsigned>(LastDist - L.second) ==
+ if (static_cast<uint64_t>(LastDist - L.second) ==
CurrentConsecutiveDist) {
++CurrentConsecutiveDist;
MaxConsecutiveDistance =
@@ -8698,12 +8709,12 @@ void BoUpSLP::tryToVectorizeGatheredLoads(
if (!Ref.empty() && !NonVectorized.empty() &&
std::accumulate(
Ref.begin(), Ref.end(), 0u,
- [](unsigned S,
- ArrayRef<std::pair<LoadInst *, int>> LoadsDists) -> unsigned {
- return S + LoadsDists.size();
- }) != NonVectorized.size() &&
+ [](unsigned S, ArrayRef<std::pair<LoadInst *, int64_t>> LoadsDists)
+ -> unsigned { return S + LoadsDists.size(); }) !=
+ NonVectorized.size() &&
IsMaskedGatherSupported(NonVectorized)) {
- SmallVector<SmallVector<std::pair<LoadInst *, int>>> FinalGatheredLoads;
+ SmallVector<SmallVector<std::pair<LoadInst *, int64_t>>>
+ FinalGatheredLoads;
for (LoadInst *LI : NonVectorized) {
// Reinsert non-vectorized loads to other list of loads with the same
// base pointers.
@@ -9299,10 +9310,10 @@ BoUpSLP::TreeEntry::EntryState BoUpSLP::getScalarsVectorizationState(
Ptr0 = PointerOps[CurrentOrder.front()];
PtrN = PointerOps[CurrentOrder.back()];
}
- std::optional<int> Dist =
+ std::optional<int64_t> Dist =
getPointersDiff(ScalarTy, Ptr0, ScalarTy, PtrN, *DL, *SE);
// Check that the sorted pointer operands are consecutive.
- if (static_cast<unsigned>(*Dist) == VL.size() - 1)
+ if (static_cast<uint64_t>(*Dist) == VL.size() - 1)
return TreeEntry::Vectorize;
}
@@ -10751,7 +10762,7 @@ unsigned BoUpSLP::canMapToVector(Type *T) const {
if (!isValidElementType(EltTy))
return 0;
- uint64_t VTSize = DL->getTypeStoreSizeInBits(getWidenedType(EltTy, N));
+ size_t VTSize = DL->getTypeStoreSizeInBits(getWidenedType(EltTy, N));
if (VTSize < MinVecRegSize || VTSize > MaxVecRegSize ||
VTSize != DL->getTypeStoreSizeInBits(T))
return 0;
@@ -11950,7 +11961,7 @@ void BoUpSLP::transformNodes() {
// A list of loads to be gathered during the vectorization process. We can
// try to vectorize them at the end, if profitable.
SmallMapVector<std::tuple<BasicBlock *, Value *, Type *>,
- SmallVector<SmallVector<std::pair<LoadInst *, int>>>, 8>
+ SmallVector<SmallVector<std::pair<LoadInst *, int64_t>>>, 8>
GatheredLoads;
for (std::unique_ptr<TreeEntry> &TE : VectorizableTree) {
@@ -18270,12 +18281,13 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) {
Value *Ptr0 = cast<LoadInst>(E->Scalars.front())->getPointerOperand();
Value *PtrN = cast<LoadInst>(E->Scalars.back())->getPointerOperand();
PO = IsReverseOrder ? PtrN : Ptr0;
- std::optional<int> Diff = getPointersDiff(
+ std::optional<int64_t> Diff = getPointersDiff(
VL0->getType(), Ptr0, VL0->getType(), PtrN, *DL, *SE);
Type *StrideTy = DL->getIndexType(PO->getType());
Value *StrideVal;
if (Diff) {
- int Stride = *Diff / (static_cast<int>(E->Scalars.size()) - 1);
+ int64_t Stride =
+ *Diff / (static_cast<int64_t>(E->Scalars.size()) - 1);
StrideVal =
ConstantInt::get(StrideTy, (IsReverseOrder ? -1 : 1) * Stride *
DL->getTypeAllocSize(ScalarTy));
@@ -21133,18 +21145,18 @@ public:
/// \p PtrDist.
/// Does nothing if there is already a store with that \p PtrDist.
/// \returns The previously associated Instruction index, or std::nullopt
- std::optional<unsigned> insertOrLookup(unsigned InstrIdx, int PtrDist) {
+ std::optional<unsigned> insertOrLookup(unsigned InstrIdx, int64_t PtrDist) {
auto [It, Inserted] = Instrs.emplace(PtrDist, InstrIdx);
- return Inserted ? std::nullopt : std::optional<unsigned>(It->second);
+ return Inserted ? std::nullopt : std::make_optional(It->second);
}
- using DistToInstMap = std::map<int, unsigned>;
+ using DistToInstMap = std::map<int64_t, unsigned>;
const DistToInstMap &getStores() const { return Instrs; }
/// If \p SI is related to this group of stores, return the distance of its
/// pointer operand to the one the group's BaseInstr.
- std::optional<int> getPointerDiff(StoreInst &SI, const DataLayout &DL,
- ScalarEvolution &SE) const {
+ std::optional<int64_t> getPointerDiff(StoreInst &SI, const DataLayout &DL,
+ ScalarEvolution &SE) const {
StoreInst &BaseStore = *AllStores[BaseInstrIdx];
return getPointersDiff(
BaseStore.getValueOperand()->getType(), BaseStore.getPointerOperand(),
@@ -21155,7 +21167,7 @@ public:
/// Recompute the pointer distances to be based on \p NewBaseInstIdx.
/// Stores whose index is less than \p MinSafeIdx will be dropped.
void rebase(unsigned MinSafeIdx, unsigned NewBaseInstIdx,
- int DistFromCurBase) {
+ int64_t DistFromCurBase) {
DistToInstMap PrevSet = std::move(Instrs);
reset(NewBaseInstIdx);
@@ -21171,7 +21183,7 @@ public:
/// Remove all stores that have been vectorized from this group.
void clearVectorizedStores(const BoUpSLP::ValueSet &VectorizedStores) {
DistToInstMap::reverse_iterator LastVectorizedStore = find_if(
- reverse(Instrs), [&](const std::pair<int, unsigned> &DistAndIdx) {
+ reverse(Instrs), [&](const std::pair<int64_t, unsigned> &DistAndIdx) {
return VectorizedStores.contains(AllStores[DistAndIdx.second]);
});
@@ -21204,7 +21216,7 @@ bool SLPVectorizerPass::vectorizeStores(
bool Changed = false;
auto TryToVectorize = [&](const RelatedStoreInsts::DistToInstMap &StoreSeq) {
- int PrevDist = -1;
+ int64_t PrevDist = -1;
BoUpSLP::ValueList Operands;
// Collect the chain into a list.
for (auto [Idx, Data] : enumerate(StoreSeq)) {
@@ -21505,7 +21517,7 @@ bool SLPVectorizerPass::vectorizeStores(
// dependencies and no need to waste compile time to try to vectorize them.
// - Try to vectorize the sequence {1, {1, 0}, {3, 2}}.
auto FillStoresSet = [&](unsigned Idx, StoreInst *SI) {
- std::optional<int> PtrDist;
+ std::optional<int64_t> PtrDist;
auto *RelatedStores = find_if(
SortedStores, [&PtrDist, SI, this](const RelatedStoreInsts &StoreSeq) {
PtrDist = StoreSeq.getPointerDiff(*SI, *DL, *SE);
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/long-pointer-distance.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-grtev4-linux-gnu < %s -mattr=+avx"
],
"tests": [
{
"test_name": "test",
"test_body": "define void @test(ptr %this) {\nentry:\n store i64 1, ptr %this, align 8\n %b = getelementptr i8, ptr %this, i64 8\n store i64 2, ptr %b, align 8\n %c = getelementptr i8, ptr %this, i64 4294967312\n store i64 3, ptr %c, align 8\n %d = getelementptr i8, ptr %this, i64 4294967320\n store i64 4, ptr %d, align 8\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SLPV] Pointer offsets truncated to 32-bits, resulting in wrong code",
"body": "Consider:\n\n```\n$ cat t.ll\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-grtev4-linux-gnu\"\n\ndefine void @_ZN12_GLOBAL__N_111LargeObjectILm4294967296EEC2Em(ptr %this) #0 {\nentry:\n store i64 1, ptr %this, align 8\n %b = getelementptr i8, ptr %this, i64 8\n store i64 2, ptr %b, align 8\n %c = getelementptr i8, ptr %this, i64 u0x100000010\n store i64 3, ptr %c, align 8\n %d = getelementptr i8, ptr %this, i64 u0x100000018\n store i64 4, ptr %d, align 8\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+aes,+avx,+cmov,+crc32,+cx16,+cx8,+fxsr,+mmx,+pclmul,+popcnt,+prfchw,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave\" }\n\n$ opt -passes=slp-vectorizer t.ll -S -o -\n; ModuleID = 't.ll'\nsource_filename = \"t.ll\"\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-grtev4-linux-gnu\"\n\ndefine void @_ZN12_GLOBAL__N_111LargeObjectILm4294967296EEC2Em(ptr %this) #0 {\nentry:\n store <4 x i64> <i64 1, i64 2, i64 3, i64 4>, ptr %this, align 8\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+aes,+avx,+cmov,+crc32,+cx16,+cx8,+fxsr,+mmx,+pclmul,+popcnt,+prfchw,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave\" }\n```\n\nClearly, somewhere inside SLPV, the GEP offsets here are truncated from 64-bits to 32. To quickly check SLPV with static analysis, I did this:\n\n```\n$ ninja opt # build everything once\n$ touch ../llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n$ CCC_OVERRIDE_OPTIONS='+-Wshorten-64-to-32' ninja opt | tee slpv-truncations.txt\n...\n```\n\nUnfortunately, there are 733 hits:\n```\n$ grep warning: slpv-truncations.txt | wc -l\n 733\n```\n\nThis is not a recent regression, it goes back to LLVM 14 and earlier: https://godbolt.org/z/9baE551T7 LLVM 14 is just as far back as the IR is parseable out of the box.\n\nI think the next move here would be to do a global search & replace of getZExtValue with some variant that asserts when the result is wider than 32-bits, or to focus only on the warnings that include getZExtValue in the warning text snippet.",
"author": "rnk",
"labels": [
"miscompilation",
"llvm:SLPVectorizer",
"llvm:analysis"
],
"comments": [
{
"author": "alexey-bataev",
"body": "LoopAccessAnalysis.cpp, getPointersDiff() returns distance -16 for pointers %b and %d, there is an implicit cast from int64_t to int, which looses the info\nhttps://github.com/llvm/llvm-project/blob/9eeae5a5de41b22d31d9037be2acc45dd7af4192/llvm/lib/Analysis/LoopAccessAnalysis.cpp#L1598\nhttps://github.com/llvm/llvm-project/blob/9eeae5a5de41b22d31d9037be2acc45dd7af4192/llvm/lib/Analysis/LoopAccessAnalysis.cpp#L1589\n"
}
]
}
| true |
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
| null |
84709
|
https://github.com/llvm/llvm-project/issues/84709
|
crash
|
4d0f79e346ceb0ddb25a94053c612a5b34a72100
| 2024-03-11T03:25:11 |
[
"llvm/test/Transforms/LoopStrengthReduce"
] |
{
"fix_commit": "beba307c5bc206168bdea3b893e02ea31579fe62",
"components": [
"LoopStrengthReduce"
],
"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": [
[
6971,
6976
],
[
6989,
6994
]
],
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.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": [
"ReduceLoopStrength"
],
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.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 beba307c5bc206168bdea3b893e02ea31579fe62
Author: Nikita Popov <npopov@redhat.com>
Date: Tue Mar 12 16:23:25 2024 +0100
[LSR] Clear SCEVExpander before deleting phi nodes
Fixes https://github.com/llvm/llvm-project/issues/84709.
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 8b078ddc4e74..c4e1a0db8b32 100644
--- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -6971,6 +6971,7 @@ static bool ReduceLoopStrength(Loop *L, IVUsers &IU, ScalarEvolution &SE,
Rewriter.setDebugType(DEBUG_TYPE);
#endif
unsigned numFolded = Rewriter.replaceCongruentIVs(L, &DT, DeadInsts, &TTI);
+ Rewriter.clear();
if (numFolded) {
Changed = true;
RecursivelyDeleteTriviallyDeadInstructionsPermissive(DeadInsts, &TLI,
@@ -6989,6 +6990,7 @@ static bool ReduceLoopStrength(Loop *L, IVUsers &IU, ScalarEvolution &SE,
SCEVExpander Rewriter(SE, DL, "lsr", true);
int Rewrites = rewriteLoopExitValues(L, &LI, &TLI, &SE, &TTI, Rewriter, &DT,
UnusedIndVarInLoop, DeadInsts);
+ Rewriter.clear();
if (Rewrites) {
Changed = true;
RecursivelyDeleteTriviallyDeadInstructionsPermissive(DeadInsts, &TLI,
|
[
{
"file": "llvm/test/Transforms/LoopStrengthReduce/pr84709.ll",
"commands": [
"opt -S -passes=loop-reduce < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define i64 @test() {\nbb:\n br label %bb1\n\nbb1: ; preds = %bb5, %bb\n %phi = phi i8 [ %zext6, %bb5 ], [ 0, %bb ]\n br label %bb2\n\nbb2: ; preds = %bb2, %bb1\n %phi3 = phi i8 [ %add, %bb2 ], [ %phi, %bb1 ]\n %phi4 = phi i32 [ 0, %bb2 ], [ 1, %bb1 ]\n %add = add i8 %phi3, 1\n br i1 true, label %bb5, label %bb2\n\nbb5: ; preds = %bb2\n %zext = zext i8 %add to i32\n %icmp = icmp sge i32 %phi4, 0\n %zext6 = zext i1 %icmp to i8\n br label %bb1\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[LSR] crashed on \"asserting value handle still pointed to this value!\"",
"body": "https://godbolt.org/z/MWWcGdxT5\r\nLSR crashed when deleting dead PHIs ",
"author": "coderchenlin",
"labels": [
"llvm:crash",
"llvm:transforms"
],
"comments": [
{
"author": "coderchenlin",
"body": "I will give a resolution to fix it later."
},
{
"author": "coderchenlin",
"body": " #84777 For this case, I think we should not set the value with nullptr when the value's uses are not empty. "
},
{
"author": "nikic",
"body": "Reduced:\r\n```llvm\r\ndefine i64 @test() {\r\nbb:\r\n br label %bb1\r\n\r\nbb1:\r\n %phi = phi i8 [ %zext6, %bb5 ], [ 0, %bb ]\r\n br label %bb2\r\n\r\nbb2:\r\n %phi3 = phi i8 [ %add, %bb2 ], [ %phi, %bb1 ]\r\n %phi4 = phi i32 [ 0, %bb2 ], [ 1, %bb1 ]\r\n %add = add i8 %phi3, 1\r\n br i1 true, label %bb5, label %bb2\r\n\r\nbb5:\r\n %zext = zext i8 %add to i32\r\n %icmp = icmp sge i32 %phi4, 0\r\n %zext6 = zext i1 %icmp to i8\r\n br label %bb1\r\n}\r\n```"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
114191
|
https://github.com/llvm/llvm-project/issues/114191
|
miscompilation
|
e577f14b670ee2ae6bb717133310b215be4331b3
| 2024-10-30T07:41:28 |
[
"llvm/test/Transforms/InstCombine",
"llvm/test/Transforms/InstSimplify"
] |
{
"fix_commit": "a77dedcacb4c5eb221395b69877981dd6ad98989",
"components": [
"IR",
"InstCombine",
"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": [
[
1158,
1186
],
[
1189,
1194
],
[
2138,
2166
]
],
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": [
[
1095,
1113
]
],
"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": [
[
902,
912
]
],
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": [
[
102,
107
]
],
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.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": [
"InstCombinerImpl::commonIDivTransforms",
"InstCombinerImpl::commonIRemTransforms",
"foldIDivShl"
],
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": [
"simplifyDivRem"
],
"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::ConstantFoldBinaryInstruction"
],
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.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 a77dedcacb4c5eb221395b69877981dd6ad98989
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Fri Nov 1 22:56:22 2024 +0800
[InstSimplify][InstCombine][ConstantFold] Move vector div/rem by zero fold to InstCombine (#114280)
Previously we fold `div/rem X, C` into `poison` if any element of the
constant divisor `C` is zero or undef. However, it is incorrect when
threading udiv over an vector select:
https://alive2.llvm.org/ce/z/3Ninx5
```
define <2 x i32> @vec_select_udiv_poison(<2 x i1> %x) {
%sel = select <2 x i1> %x, <2 x i32> <i32 -1, i32 -1>, <2 x i32> <i32 0, i32 1>
%div = udiv <2 x i32> <i32 42, i32 -7>, %sel
ret <2 x i32> %div
}
```
In this case, `threadBinOpOverSelect` folds `udiv <i32 42, i32 -7>, <i32
-1, i32 -1>` and `udiv <i32 42, i32 -7>, <i32 0, i32 1>` into
`zeroinitializer` and `poison`, respectively. One solution is to
introduce a new flag indicating that we are threading over a vector
select. But it requires to modify both `InstSimplify` and
`ConstantFold`.
However, this optimization doesn't provide benefits to real-world
programs:
https://dtcxzyw.github.io/llvm-opt-benchmark/coverage/data/zyw/opt-ci/actions-runner/_work/llvm-opt-benchmark/llvm-opt-benchmark/llvm/llvm-project/llvm/lib/IR/ConstantFold.cpp.html#L908
https://dtcxzyw.github.io/llvm-opt-benchmark/coverage/data/zyw/opt-ci/actions-runner/_work/llvm-opt-benchmark/llvm-opt-benchmark/llvm/llvm-project/llvm/lib/Analysis/InstructionSimplify.cpp.html#L1107
This patch moves the fold into InstCombine to avoid breaking numerous
existing tests.
Fixes #114191 and #113866 (only poison-safety issue).
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index d08be1e55c85..2cb2612bf611 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -1095,19 +1095,6 @@ static Value *simplifyDivRem(Instruction::BinaryOps Opcode, Value *Op0,
if (match(Op1, m_Zero()))
return PoisonValue::get(Ty);
- // If any element of a constant divisor fixed width vector is zero or undef
- // the behavior is undefined and we can fold the whole op to poison.
- auto *Op1C = dyn_cast<Constant>(Op1);
- auto *VTy = dyn_cast<FixedVectorType>(Ty);
- if (Op1C && VTy) {
- unsigned NumElts = VTy->getNumElements();
- for (unsigned i = 0; i != NumElts; ++i) {
- Constant *Elt = Op1C->getAggregateElement(i);
- if (Elt && (Elt->isNullValue() || Q.isUndefValue(Elt)))
- return PoisonValue::get(Ty);
- }
- }
-
// poison / X -> poison
// poison % X -> poison
if (isa<PoisonValue>(Op0))
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index 07dfbc41e79b..c2780faee403 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -902,11 +902,6 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, Constant *C1,
Constant *ExtractIdx = ConstantInt::get(Ty, i);
Constant *LHS = ConstantExpr::getExtractElement(C1, ExtractIdx);
Constant *RHS = ConstantExpr::getExtractElement(C2, ExtractIdx);
-
- // If any element of a divisor vector is zero, the whole op is poison.
- if (Instruction::isIntDivRem(Opcode) && RHS->isNullValue())
- return PoisonValue::get(VTy);
-
Constant *Res = ConstantExpr::isDesirableBinOp(Opcode)
? ConstantExpr::get(Opcode, LHS, RHS)
: ConstantFoldBinaryInstruction(Opcode, LHS, RHS);
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
index 7a060cdab2d3..adbd9186c59c 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
+++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
@@ -102,6 +102,7 @@ public:
Instruction *visitSRem(BinaryOperator &I);
Instruction *visitFRem(BinaryOperator &I);
bool simplifyDivRemOfSelectWithZeroOp(BinaryOperator &I);
+ Instruction *commonIDivRemTransforms(BinaryOperator &I);
Instruction *commonIRemTransforms(BinaryOperator &I);
Instruction *commonIDivTransforms(BinaryOperator &I);
Instruction *visitUDiv(BinaryOperator &I);
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
index b9c165da906d..f85a3c936513 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
@@ -1158,29 +1158,39 @@ static Value *foldIDivShl(BinaryOperator &I, InstCombiner::BuilderTy &Builder) {
return nullptr;
}
-/// This function implements the transforms common to both integer division
-/// instructions (udiv and sdiv). It is called by the visitors to those integer
-/// division instructions.
-/// Common integer divide transforms
-Instruction *InstCombinerImpl::commonIDivTransforms(BinaryOperator &I) {
- if (Instruction *Phi = foldBinopWithPhiOperands(I))
- return Phi;
-
+/// Common integer divide/remainder transforms
+Instruction *InstCombinerImpl::commonIDivRemTransforms(BinaryOperator &I) {
+ assert(I.isIntDivRem() && "Unexpected instruction");
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
- bool IsSigned = I.getOpcode() == Instruction::SDiv;
+
+ // If any element of a constant divisor fixed width vector is zero or undef
+ // the behavior is undefined and we can fold the whole op to poison.
+ auto *Op1C = dyn_cast<Constant>(Op1);
Type *Ty = I.getType();
+ auto *VTy = dyn_cast<FixedVectorType>(Ty);
+ if (Op1C && VTy) {
+ unsigned NumElts = VTy->getNumElements();
+ for (unsigned i = 0; i != NumElts; ++i) {
+ Constant *Elt = Op1C->getAggregateElement(i);
+ if (Elt && (Elt->isNullValue() || isa<UndefValue>(Elt)))
+ return replaceInstUsesWith(I, PoisonValue::get(Ty));
+ }
+ }
+
+ if (Instruction *Phi = foldBinopWithPhiOperands(I))
+ return Phi;
// The RHS is known non-zero.
if (Value *V = simplifyValueKnownNonZero(I.getOperand(1), *this, I))
return replaceOperand(I, 1, V);
- // Handle cases involving: [su]div X, (select Cond, Y, Z)
- // This does not apply for fdiv.
+ // Handle cases involving: div/rem X, (select Cond, Y, Z)
if (simplifyDivRemOfSelectWithZeroOp(I))
return &I;
// If the divisor is a select-of-constants, try to constant fold all div ops:
- // C / (select Cond, TrueC, FalseC) --> select Cond, (C / TrueC), (C / FalseC)
+ // C div/rem (select Cond, TrueC, FalseC) --> select Cond, (C div/rem TrueC),
+ // (C div/rem FalseC)
// TODO: Adapt simplifyDivRemOfSelectWithZeroOp to allow this and other folds.
if (match(Op0, m_ImmConstant()) &&
match(Op1, m_Select(m_Value(), m_ImmConstant(), m_ImmConstant()))) {
@@ -1189,6 +1199,21 @@ Instruction *InstCombinerImpl::commonIDivTransforms(BinaryOperator &I) {
return R;
}
+ return nullptr;
+}
+
+/// This function implements the transforms common to both integer division
+/// instructions (udiv and sdiv). It is called by the visitors to those integer
+/// division instructions.
+/// Common integer divide transforms
+Instruction *InstCombinerImpl::commonIDivTransforms(BinaryOperator &I) {
+ if (Instruction *Res = commonIDivRemTransforms(I))
+ return Res;
+
+ Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
+ bool IsSigned = I.getOpcode() == Instruction::SDiv;
+ Type *Ty = I.getType();
+
const APInt *C2;
if (match(Op1, m_APInt(C2))) {
Value *X;
@@ -2138,29 +2163,11 @@ static Instruction *simplifyIRemMulShl(BinaryOperator &I,
/// remainder instructions.
/// Common integer remainder transforms
Instruction *InstCombinerImpl::commonIRemTransforms(BinaryOperator &I) {
- if (Instruction *Phi = foldBinopWithPhiOperands(I))
- return Phi;
+ if (Instruction *Res = commonIDivRemTransforms(I))
+ return Res;
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
- // The RHS is known non-zero.
- if (Value *V = simplifyValueKnownNonZero(I.getOperand(1), *this, I))
- return replaceOperand(I, 1, V);
-
- // Handle cases involving: rem X, (select Cond, Y, Z)
- if (simplifyDivRemOfSelectWithZeroOp(I))
- return &I;
-
- // If the divisor is a select-of-constants, try to constant fold all rem ops:
- // C % (select Cond, TrueC, FalseC) --> select Cond, (C % TrueC), (C % FalseC)
- // TODO: Adapt simplifyDivRemOfSelectWithZeroOp to allow this and other folds.
- if (match(Op0, m_ImmConstant()) &&
- match(Op1, m_Select(m_Value(), m_ImmConstant(), m_ImmConstant()))) {
- if (Instruction *R = FoldOpIntoSelect(I, cast<SelectInst>(Op1),
- /*FoldWithMultiUse*/ true))
- return R;
- }
-
if (isa<Constant>(Op1)) {
if (Instruction *Op0I = dyn_cast<Instruction>(Op0)) {
if (SelectInst *SI = dyn_cast<SelectInst>(Op0I)) {
|
[
{
"file": "llvm/test/Transforms/InstCombine/div.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "sdiv_constant_dividend_select_of_constants_divisor_vec",
"test_body": "define <2 x i8> @sdiv_constant_dividend_select_of_constants_divisor_vec(i1 %b) {\n %s = select i1 %b, <2 x i8> <i8 12, i8 -5>, <2 x i8> <i8 -4, i8 4>\n %r = sdiv <2 x i8> <i8 42, i8 -42>, %s\n ret <2 x i8> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "udiv_constant_dividend_select_of_constants_divisor_vec",
"test_body": "define <2 x i8> @udiv_constant_dividend_select_of_constants_divisor_vec(i1 %b) {\n %s = select i1 %b, <2 x i8> <i8 12, i8 -5>, <2 x i8> <i8 -4, i8 4>\n %r = udiv <2 x i8> <i8 42, i8 -42>, %s\n ret <2 x i8> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "sdiv_constant_dividend_select_of_constants_divisor_vec_ub1",
"test_body": "define <2 x i8> @sdiv_constant_dividend_select_of_constants_divisor_vec_ub1(i1 %b) {\n %s = select i1 %b, <2 x i8> <i8 0, i8 -5>, <2 x i8> <i8 -4, i8 4>\n %r = sdiv <2 x i8> <i8 42, i8 -42>, %s\n ret <2 x i8> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "udiv_constant_dividend_select_of_constants_divisor_vec_ub1",
"test_body": "define <2 x i8> @udiv_constant_dividend_select_of_constants_divisor_vec_ub1(i1 %b) {\n %s = select i1 %b, <2 x i8> <i8 0, i8 -5>, <2 x i8> <i8 -4, i8 4>\n %r = udiv <2 x i8> <i8 42, i8 -42>, %s\n ret <2 x i8> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/InstCombine/rem.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "urem_constant_dividend_select_of_constants_divisor_vec_ub1",
"test_body": "define <2 x i8> @urem_constant_dividend_select_of_constants_divisor_vec_ub1(i1 %b) {\n %s = select i1 %b, <2 x i8> <i8 0, i8 -5>, <2 x i8> <i8 -4, i8 4>\n %r = urem <2 x i8> <i8 42, i8 -42>, %s\n ret <2 x i8> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "urem_constant_dividend_select_of_constants_divisor_vec",
"test_body": "define <2 x i8> @urem_constant_dividend_select_of_constants_divisor_vec(i1 %b) {\n %s = select i1 %b, <2 x i8> <i8 12, i8 -5>, <2 x i8> <i8 -4, i8 4>\n %r = urem <2 x i8> <i8 42, i8 -42>, %s\n ret <2 x i8> %r\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/InstCombine/vector-udiv.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "vec_select_udiv_poison",
"test_body": "define <2 x i32> @vec_select_udiv_poison(<2 x i1> %x) {\n %sel = select <2 x i1> %x, <2 x i32> splat (i32 -1), <2 x i32> <i32 0, i32 1>\n %div = udiv <2 x i32> <i32 42, i32 -7>, %sel\n ret <2 x i32> %div\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_v4i32_zext_shl_const_pow2",
"test_body": "define <4 x i32> @test_v4i32_zext_shl_const_pow2(<4 x i32> %a0, <4 x i16> %a1) {\n %1 = shl <4 x i16> <i16 4, i16 8, i16 16, i16 32>, %a1\n %2 = zext <4 x i16> %1 to <4 x i32>\n %3 = udiv <4 x i32> %a0, %2\n ret <4 x i32> %3\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/InstSimplify/div.ll",
"commands": [
"opt < %s -passes=instsimplify -S"
],
"tests": [
{
"test_name": "udiv_zero_elt_vec",
"test_body": "define <2 x i8> @udiv_zero_elt_vec(<2 x i8> %x) {\n %div = udiv <2 x i8> %x, <i8 0, i8 42>\n ret <2 x i8> %div\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "sdiv_zero_elt_vec",
"test_body": "define <2 x i8> @sdiv_zero_elt_vec(<2 x i8> %x) {\n %div = sdiv <2 x i8> %x, <i8 -42, i8 0>\n ret <2 x i8> %div\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "udiv_poison_elt_vec",
"test_body": "define <2 x i8> @udiv_poison_elt_vec(<2 x i8> %x) {\n %div = udiv <2 x i8> %x, <i8 poison, i8 42>\n ret <2 x i8> %div\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "sdiv_zero_elt_vec_constfold",
"test_body": "define <2 x i8> @sdiv_zero_elt_vec_constfold(<2 x i8> %x) {\n %div = sdiv <2 x i8> <i8 1, i8 2>, <i8 0, i8 -42>\n ret <2 x i8> %div\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "sdiv_poison_elt_vec",
"test_body": "define <2 x i8> @sdiv_poison_elt_vec(<2 x i8> %x) {\n %div = sdiv <2 x i8> %x, <i8 -42, i8 poison>\n ret <2 x i8> %div\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "udiv_zero_elt_vec_constfold",
"test_body": "define <2 x i8> @udiv_zero_elt_vec_constfold(<2 x i8> %x) {\n %div = udiv <2 x i8> <i8 1, i8 2>, <i8 42, i8 0>\n ret <2 x i8> %div\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "zero_dividend_vector_poison_elt",
"test_body": "define <2 x i32> @zero_dividend_vector_poison_elt(<2 x i32> %A) {\n %B = sdiv <2 x i32> <i32 0, i32 poison>, %A\n ret <2 x i32> %B\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/InstSimplify/rem.ll",
"commands": [
"opt < %s -passes=instsimplify -S"
],
"tests": [
{
"test_name": "srem_zero_elt_vec_constfold",
"test_body": "define <2 x i8> @srem_zero_elt_vec_constfold(<2 x i8> %x) {\n %rem = srem <2 x i8> <i8 1, i8 2>, <i8 0, i8 -42>\n ret <2 x i8> %rem\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "urem_zero_elt_vec",
"test_body": "define <2 x i8> @urem_zero_elt_vec(<2 x i8> %x) {\n %rem = urem <2 x i8> %x, <i8 0, i8 42>\n ret <2 x i8> %rem\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "urem_zero_elt_vec_constfold",
"test_body": "define <2 x i8> @urem_zero_elt_vec_constfold(<2 x i8> %x) {\n %rem = urem <2 x i8> <i8 1, i8 2>, <i8 42, i8 0>\n ret <2 x i8> %rem\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "srem_undef_elt_vec",
"test_body": "define <2 x i8> @srem_undef_elt_vec(<2 x i8> %x) {\n %rem = srem <2 x i8> %x, <i8 -42, i8 undef>\n ret <2 x i8> %rem\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "urem_undef_elt_vec",
"test_body": "define <2 x i8> @urem_undef_elt_vec(<2 x i8> %x) {\n %rem = urem <2 x i8> %x, <i8 undef, i8 42>\n ret <2 x i8> %rem\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "zero_dividend_vector_poison_elt",
"test_body": "define <2 x i32> @zero_dividend_vector_poison_elt(<2 x i32> %A) {\n %B = urem <2 x i32> <i32 poison, i32 0>, %A\n ret <2 x i32> %B\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "srem_zero_elt_vec",
"test_body": "define <2 x i8> @srem_zero_elt_vec(<2 x i8> %x) {\n %rem = srem <2 x i8> %x, <i8 -42, i8 0>\n ret <2 x i8> %rem\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[InstCombine] miscompilation of `or` of vectors",
"body": "Alive2 report: https://alive2.llvm.org/ce/z/LyM8sY\r\n\r\n```llvm\r\n----------------------------------------\r\ndefine <2 x i32> @or_sext_to_sel_constant_vec.3(<2 x i1> %y) {\r\n#0:\r\n %sext = sext <2 x i1> %y to <2 x i32>\r\n %#1 = or <2 x i32> %sext, { 0, 1 }\r\n %#2 = udiv <2 x i32> { 42, 4294967289 }, %#1\r\n ret <2 x i32> %#2\r\n}\r\n=>\r\ndefine <2 x i32> @or_sext_to_sel_constant_vec.3(<2 x i1> %y) {\r\n#0:\r\n ret <2 x i32> { 0, 0 }\r\n}\r\nTransformation doesn't verify!\r\n\r\nERROR: Value mismatch\r\n\r\nExample:\r\n<2 x i1> %y = < #x1 (1), #x0 (0) >\r\n\r\nSource:\r\n<2 x i32> %sext = < #xffffffff (4294967295, -1), #x00000000 (0) >\r\n<2 x i32> %#1 = < #xffffffff (4294967295, -1), #x00000001 (1) >\r\n<2 x i32> %#2 = < #x00000000 (0), #xfffffff9 (4294967289, -7) >\r\n\r\nTarget:\r\nSource value: < #x00000000 (0), #xfffffff9 (4294967289, -7) >\r\nTarget value: < #x00000000 (0), #x00000000 (0) >\r\n\r\n\r\n----------------------------------------\r\ndefine <2 x i32> @or_sext_to_sel_constant_vec.2(<2 x i1> %y) {\r\n#0:\r\n %sext = sext <2 x i1> %y to <2 x i32>\r\n %#1 = or <2 x i32> %sext, { 0, 1 }\r\n %#2 = sdiv <2 x i32> { 42, 4294967289 }, %#1\r\n %#3 = udiv exact <2 x i32> %#2, %#2\r\n %#4 = or <2 x i32> %#2, %#2\r\n ret <2 x i32> %#4\r\n}\r\n=>\r\ndefine <2 x i32> @or_sext_to_sel_constant_vec.2(<2 x i1> %y) {\r\n#0:\r\n ret <2 x i32> { 4294967254, 7 }\r\n}\r\nTransformation doesn't verify!\r\n\r\nERROR: Value mismatch\r\n\r\nExample:\r\n<2 x i1> %y = < #x1 (1), #x0 (0) >\r\n\r\nSource:\r\n<2 x i32> %sext = < #xffffffff (4294967295, -1), #x00000000 (0) >\r\n<2 x i32> %#1 = < #xffffffff (4294967295, -1), #x00000001 (1) >\r\n<2 x i32> %#2 = < #xffffffd6 (4294967254, -42), #xfffffff9 (4294967289, -7) >\r\n<2 x i32> %#3 = < #x00000001 (1), #x00000001 (1) >\r\n<2 x i32> %#4 = < #xffffffd6 (4294967254, -42), #xfffffff9 (4294967289, -7) >\r\n\r\nTarget:\r\nSource value: < #xffffffd6 (4294967254, -42), #xfffffff9 (4294967289, -7) >\r\nTarget value: < #xffffffd6 (4294967254, -42), #x00000007 (7) >\r\n\r\nSummary:\r\n 0 correct transformations\r\n 2 incorrect transformations\r\n 0 failed-to-prove transformations\r\n 0 Alive2 errors\r\n```",
"author": "bongjunj",
"labels": [
"miscompilation",
"llvm:instcombine",
"llvm:analysis"
],
"comments": [
{
"author": "dtcxzyw",
"body": "@bongjunj Feel free to ping me if you find new InstCombine miscompilation bugs without involving undef values/NaN payloads."
},
{
"author": "dtcxzyw",
"body": "https://github.com/llvm/llvm-project/blob/eac2c182c6f852fc187af9952250a43d6fb17b28/llvm/lib/Analysis/InstructionSimplify.cpp#L1098-L1109\r\n\r\nWe cannot do this simplification when threading udiv over selects.\r\n "
}
]
}
| true |
{
"is_single_file_fix": false,
"is_single_func_fix": false
}
| null |
77064
|
https://github.com/llvm/llvm-project/issues/77064
|
crash
|
255f95a40377677dd762df5a1aa65bcbb4f75c79
| 2024-01-05T09:28:42 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "a001e9718fd974859f2797a9f9ed7bf87d364e4f",
"components": [
"SimplifyLibCalls"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
3735,
3760
]
],
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.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": [
"LibCallSimplifier::optimizeCall"
],
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.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 a001e9718fd974859f2797a9f9ed7bf87d364e4f
Author: Nikita Popov <npopov@redhat.com>
Date: Fri Jan 5 10:41:44 2024 +0100
[SimplifyLibCalls] Don't try to manually reprocess calls
The current code for reprocessing the result of fortified libcall
simplifications is not correct, because we might simplify to an
argument of the original call, and if that is again a libcall,
mistakenly think that this is actually the simplification result.
Instead of trying to fix this, simply remove the code entirely,
because InstCombine nowadays correctly handles reprocessing of
SimplifyLibCall results.
Fixes https://github.com/llvm/llvm-project/issues/77064.
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index 760a626c8b6f..a7cd68e860e4 100644
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -3735,26 +3735,8 @@ Value *LibCallSimplifier::optimizeCall(CallInst *CI, IRBuilderBase &Builder) {
// Also try to simplify calls to fortified library functions.
if (Value *SimplifiedFortifiedCI =
- FortifiedSimplifier.optimizeCall(CI, Builder)) {
- // Try to further simplify the result.
- CallInst *SimplifiedCI = dyn_cast<CallInst>(SimplifiedFortifiedCI);
- if (SimplifiedCI && SimplifiedCI->getCalledFunction()) {
- // Ensure that SimplifiedCI's uses are complete, since some calls have
- // their uses analyzed.
- replaceAllUsesWith(CI, SimplifiedCI);
-
- // Set insertion point to SimplifiedCI to guarantee we reach all uses
- // we might replace later on.
- IRBuilderBase::InsertPointGuard Guard(Builder);
- Builder.SetInsertPoint(SimplifiedCI);
- if (Value *V = optimizeStringMemoryLibCall(SimplifiedCI, Builder)) {
- // If we were able to further simplify, remove the now redundant call.
- substituteInParent(SimplifiedCI, V);
- return V;
- }
- }
+ FortifiedSimplifier.optimizeCall(CI, Builder))
return SimplifiedFortifiedCI;
- }
// Then check for known library functions.
if (TLI->getLibFunc(*Callee, Func) && isLibFuncEmittable(M, TLI, Func)) {
|
[
{
"file": "llvm/test/Transforms/InstCombine/pr77064.ll",
"commands": [
"opt -S -passes=instcombine < %s"
],
"tests": [
{
"test_name": "main",
"test_body": "define void @main(ptr %ptr) {\n %opendir = call fastcc ptr @opendir(ptr %ptr)\n %memset = call ptr @__memset_chk(ptr %opendir, i32 0, i64 596, i64 -1)\n ret void\n}\n\ndeclare ptr @__memset_chk(ptr, i32, i64, i64)\n\ndeclare fastcc ptr @opendir(ptr)\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SimplifyLibCalls] Calling convention assertion fails",
"body": "```llvm\r\n; RUN: opt -S -passes=instcombine\r\ndefine void @main(ptr %ptr) {\r\n %opendir = call fastcc ptr @opendir(ptr %ptr)\r\n %memset = call ptr @__memset_chk(ptr %opendir, i32 0, i64 596, i64 -1)\r\n ret void\r\n}\r\n\r\ndeclare ptr @__memset_chk(ptr, i32, i64, i64)\r\n\r\ndeclare fastcc ptr @opendir(ptr)\r\n```\r\n\r\n> opt: /home/npopov/repos/llvm-project/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:3488: Value *llvm::LibCallSimplifier::optimizeStringMemoryLibCall(CallInst *, IRBuilderBase &): Assertion `(ignoreCallingConv(Func) || TargetLibraryInfoImpl::isCallingConvCCompatible(CI)) && \"Optimizing string/memory libcall would change the calling convention\"' failed.\r\n\r\nEncountered when building openjpeg2.",
"author": "nikic",
"labels": [
"llvm:crash",
"llvm:instcombine"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
114947
|
https://github.com/llvm/llvm-project/issues/114947
|
miscompilation
|
1e5bfac933ea90ec4361446398551dd6b967c67f
| 2024-11-05T07:42:44 |
[
"llvm/test/Transforms/SCCP"
] |
{
"fix_commit": "cd88bfcb5906049e1387b856fc7256e5fae22e5f",
"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": [
[
1266,
1279
],
[
1298,
1344
]
],
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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": [
"llvm::ConstantFoldBinaryOpOperands",
"llvm::ConstantFoldCompareInstOperands",
"llvm::ConstantFoldFPInstOperands",
"llvm::FlushFPConstant"
],
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 cd88bfcb5906049e1387b856fc7256e5fae22e5f
Author: Matt Arsenault <Matthew.Arsenault@amd.com>
Date: Wed Nov 13 07:43:50 2024 -0800
ConstantFolding: Do not fold fcmp of denormal without known mode (#115407)
Fixes #114947
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 88db315ffd0b..1971c28fc4c4 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -1266,14 +1266,16 @@ Constant *llvm::ConstantFoldCompareInstOperands(
return ConstantFoldCompareInstOperands(Predicate, Ops1, Ops0, DL, TLI);
}
- // Flush any denormal constant float input according to denormal handling
- // mode.
- Ops0 = FlushFPConstant(Ops0, I, /* IsOutput */ false);
- if (!Ops0)
- return nullptr;
- Ops1 = FlushFPConstant(Ops1, I, /* IsOutput */ false);
- if (!Ops1)
- return nullptr;
+ if (CmpInst::isFPPredicate(Predicate)) {
+ // Flush any denormal constant float input according to denormal handling
+ // mode.
+ Ops0 = FlushFPConstant(Ops0, I, /*IsOutput=*/false);
+ if (!Ops0)
+ return nullptr;
+ Ops1 = FlushFPConstant(Ops1, I, /*IsOutput=*/false);
+ if (!Ops1)
+ return nullptr;
+ }
return ConstantFoldCompareInstruction(Predicate, Ops0, Ops1);
}
@@ -1298,47 +1300,110 @@ Constant *llvm::ConstantFoldBinaryOpOperands(unsigned Opcode, Constant *LHS,
return ConstantFoldBinaryInstruction(Opcode, LHS, RHS);
}
-Constant *llvm::FlushFPConstant(Constant *Operand, const Instruction *I,
- bool IsOutput) {
- if (!I || !I->getParent() || !I->getFunction())
- return Operand;
+static ConstantFP *flushDenormalConstant(Type *Ty, const APFloat &APF,
+ DenormalMode::DenormalModeKind Mode) {
+ switch (Mode) {
+ case DenormalMode::Dynamic:
+ return nullptr;
+ case DenormalMode::IEEE:
+ return ConstantFP::get(Ty->getContext(), APF);
+ case DenormalMode::PreserveSign:
+ return ConstantFP::get(
+ Ty->getContext(),
+ APFloat::getZero(APF.getSemantics(), APF.isNegative()));
+ case DenormalMode::PositiveZero:
+ return ConstantFP::get(Ty->getContext(),
+ APFloat::getZero(APF.getSemantics(), false));
+ default:
+ break;
+ }
- ConstantFP *CFP = dyn_cast<ConstantFP>(Operand);
- if (!CFP)
- return Operand;
+ llvm_unreachable("unknown denormal mode");
+}
+
+/// Return the denormal mode that can be assumed when executing a floating point
+/// operation at \p CtxI.
+static DenormalMode getInstrDenormalMode(const Instruction *CtxI, Type *Ty) {
+ if (!CtxI || !CtxI->getParent() || !CtxI->getFunction())
+ return DenormalMode::getDynamic();
+ return CtxI->getFunction()->getDenormalMode(Ty->getFltSemantics());
+}
+static ConstantFP *flushDenormalConstantFP(ConstantFP *CFP,
+ const Instruction *Inst,
+ bool IsOutput) {
const APFloat &APF = CFP->getValueAPF();
- // TODO: Should this canonicalize nans?
if (!APF.isDenormal())
- return Operand;
+ return CFP;
- Type *Ty = CFP->getType();
- DenormalMode DenormMode =
- I->getFunction()->getDenormalMode(Ty->getFltSemantics());
- DenormalMode::DenormalModeKind Mode =
- IsOutput ? DenormMode.Output : DenormMode.Input;
- switch (Mode) {
- default:
- llvm_unreachable("unknown denormal mode");
- case DenormalMode::Dynamic:
- return nullptr;
- case DenormalMode::IEEE:
+ DenormalMode Mode = getInstrDenormalMode(Inst, CFP->getType());
+ return flushDenormalConstant(CFP->getType(), APF,
+ IsOutput ? Mode.Output : Mode.Input);
+}
+
+Constant *llvm::FlushFPConstant(Constant *Operand, const Instruction *Inst,
+ bool IsOutput) {
+ if (ConstantFP *CFP = dyn_cast<ConstantFP>(Operand))
+ return flushDenormalConstantFP(CFP, Inst, IsOutput);
+
+ if (isa<ConstantAggregateZero, UndefValue, ConstantExpr>(Operand))
return Operand;
- case DenormalMode::PreserveSign:
- if (APF.isDenormal()) {
- return ConstantFP::get(
- Ty->getContext(),
- APFloat::getZero(Ty->getFltSemantics(), APF.isNegative()));
+
+ Type *Ty = Operand->getType();
+ VectorType *VecTy = dyn_cast<VectorType>(Ty);
+ if (VecTy) {
+ if (auto *Splat = dyn_cast_or_null<ConstantFP>(Operand->getSplatValue())) {
+ ConstantFP *Folded = flushDenormalConstantFP(Splat, Inst, IsOutput);
+ if (!Folded)
+ return nullptr;
+ return ConstantVector::getSplat(VecTy->getElementCount(), Folded);
}
- return Operand;
- case DenormalMode::PositiveZero:
- if (APF.isDenormal()) {
- return ConstantFP::get(Ty->getContext(),
- APFloat::getZero(Ty->getFltSemantics(), false));
+
+ Ty = VecTy->getElementType();
+ }
+
+ if (const auto *CV = dyn_cast<ConstantVector>(Operand)) {
+ SmallVector<Constant *, 16> NewElts;
+ for (unsigned i = 0, e = CV->getNumOperands(); i != e; ++i) {
+ Constant *Element = CV->getAggregateElement(i);
+ if (isa<UndefValue>(Element)) {
+ NewElts.push_back(Element);
+ continue;
+ }
+
+ ConstantFP *CFP = dyn_cast<ConstantFP>(Element);
+ if (!CFP)
+ return nullptr;
+
+ ConstantFP *Folded = flushDenormalConstantFP(CFP, Inst, IsOutput);
+ if (!Folded)
+ return nullptr;
+ NewElts.push_back(Folded);
}
- return Operand;
+
+ return ConstantVector::get(NewElts);
+ }
+
+ if (const auto *CDV = dyn_cast<ConstantDataVector>(Operand)) {
+ SmallVector<Constant *, 16> NewElts;
+ for (unsigned I = 0, E = CDV->getNumElements(); I < E; ++I) {
+ const APFloat &Elt = CDV->getElementAsAPFloat(I);
+ if (!Elt.isDenormal()) {
+ NewElts.push_back(ConstantFP::get(Ty, Elt));
+ } else {
+ DenormalMode Mode = getInstrDenormalMode(Inst, Ty);
+ ConstantFP *Folded =
+ flushDenormalConstant(Ty, Elt, IsOutput ? Mode.Output : Mode.Input);
+ if (!Folded)
+ return nullptr;
+ NewElts.push_back(Folded);
+ }
+ }
+
+ return ConstantVector::get(NewElts);
}
- return Operand;
+
+ return nullptr;
}
Constant *llvm::ConstantFoldFPInstOperands(unsigned Opcode, Constant *LHS,
|
[
{
"file": "llvm/test/Transforms/SCCP/no-fold-fcmp-dynamic-denormal-mode-issue114947.ll",
"commands": [
"opt -S -passes=ipsccp < %s"
],
"tests": [
{
"test_name": "no_fold_fcmp_denormal_double_ieee_dynamic_vector_nonsplat",
"test_body": "define <2 x i1> @no_fold_fcmp_denormal_double_ieee_dynamic_vector_nonsplat() #0 {\n %cmp = fcmp une <2 x double> <double 0x8000000000000, double 1.000000e+00>, zeroinitializer\n ret <2 x i1> %cmp\n}\n\nattributes #0 = { \"denormal-fp-math\"=\"ieee,dynamic\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "fold_fcmp_nondenormal_double_ieee_dynamic_vector_nonsplat_undef",
"test_body": "define <3 x i1> @fold_fcmp_nondenormal_double_ieee_dynamic_vector_nonsplat_undef() #0 {\n %cmp = fcmp une <3 x double> <double 2.000000e+00, double undef, double 4.000000e+00>, <double 1.000000e+00, double undef, double 4.000000e+00>\n ret <3 x i1> %cmp\n}\n\nattributes #0 = { \"denormal-fp-math\"=\"ieee,dynamic\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "no_fold_fcmp_denormal_double_ieee_dynamic_denormal_undef",
"test_body": "define i1 @no_fold_fcmp_denormal_double_ieee_dynamic_denormal_undef() #0 {\n %cmp = fcmp une double 0x8000000000000, undef\n ret i1 %cmp\n}\n\nattributes #0 = { \"denormal-fp-math\"=\"ieee,dynamic\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "fold_fcmp_nondenormal_double_ieee_dynamic_vector_nonsplat",
"test_body": "define <2 x i1> @fold_fcmp_nondenormal_double_ieee_dynamic_vector_nonsplat() #0 {\n %cmp = fcmp une <2 x double> <double 2.000000e+00, double 4.000000e+00>, <double 2.000000e+00, double 8.000000e+00>\n ret <2 x i1> %cmp\n}\n\nattributes #0 = { \"denormal-fp-math\"=\"ieee,dynamic\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "fold_fcmp_nondenormal_double_ieee_dynamic_vector_splat",
"test_body": "define <2 x i1> @fold_fcmp_nondenormal_double_ieee_dynamic_vector_splat() #0 {\n %cmp = fcmp une <2 x double> splat (double 2.000000e+00), zeroinitializer\n ret <2 x i1> %cmp\n}\n\nattributes #0 = { \"denormal-fp-math\"=\"ieee,dynamic\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "fold_fcmp_nondenormal_double_ieee_dynamic",
"test_body": "define i1 @fold_fcmp_nondenormal_double_ieee_dynamic() #0 {\n %cmp = fcmp une double 2.000000e+00, 0.000000e+00\n ret i1 %cmp\n}\n\nattributes #0 = { \"denormal-fp-math\"=\"ieee,dynamic\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "fold_fcmp_nondenormal_double_ieee_dynamic_zero",
"test_body": "define <2 x i1> @fold_fcmp_nondenormal_double_ieee_dynamic_zero() #0 {\n %cmp = fcmp une <2 x double> zeroinitializer, zeroinitializer\n ret <2 x i1> %cmp\n}\n\nattributes #0 = { \"denormal-fp-math\"=\"ieee,dynamic\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "no_fold_fcmp_denormal_double_ieee_dynamic_denormal_poison",
"test_body": "define i1 @no_fold_fcmp_denormal_double_ieee_dynamic_denormal_poison() #0 {\n %cmp = fcmp une double 0x8000000000000, poison\n ret i1 %cmp\n}\n\nattributes #0 = { \"denormal-fp-math\"=\"ieee,dynamic\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "no_fold_fcmp_denormal_double_ieee_dynamic_vector_splat",
"test_body": "define <2 x i1> @no_fold_fcmp_denormal_double_ieee_dynamic_vector_splat() #0 {\n %cmp = fcmp une <2 x double> splat (double 0x8000000000000), zeroinitializer\n ret <2 x i1> %cmp\n}\n\nattributes #0 = { \"denormal-fp-math\"=\"ieee,dynamic\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "no_fold_fcmp_denormal_double_ieee_dynamic",
"test_body": "define i1 @no_fold_fcmp_denormal_double_ieee_dynamic() #0 {\n %cmp = fcmp une double 0x8000000000000, 0.000000e+00\n ret i1 %cmp\n}\n\nattributes #0 = { \"denormal-fp-math\"=\"ieee,dynamic\" }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "`fcmp` miscompiled to a constant",
"body": "Alive2 report: https://alive2.llvm.org/ce/z/324E7x\r\n\r\n```llvm\r\n----------------------------------------\r\ndefine i1 @fcmp_double_dynamic_dynamic.2() denormal-fp-math=dynamic,dynamic {\r\n#0:\r\n %cmp = fcmp une double 0x0008000000000000, -0.000000\r\n ret i1 %cmp\r\n}\r\n=>\r\ndefine i1 @fcmp_double_dynamic_dynamic.2() nofree noundef willreturn denormal-fp-math=dynamic,dynamic memory(none) {\r\n#0:\r\n ret i1 1\r\n}\r\nTransformation doesn't verify!\r\n\r\nERROR: Value mismatch\r\n\r\nExample:\r\n\r\nSource:\r\ni1 %cmp = #x0 (0)\r\n\r\nTarget:\r\nSource value: #x0 (0)\r\nTarget value: #x1 (1)\r\n\r\nSummary:\r\n 0 correct transformations\r\n 1 incorrect transformations\r\n 0 failed-to-prove transformations\r\n 0 Alive2 errors\r\n```\r\n",
"author": "bongjunj",
"labels": [
"miscompilation",
"floating-point",
"llvm:analysis"
],
"comments": [
{
"author": "arsenm",
"body": "I don't see the issue? Those values are in fact not equal, so this is true. Alive bug? "
},
{
"author": "jcranmer-intel",
"body": "it's comparing a denormal to 0, and the `denormal-fp-mode` is set to `dynamic`, so `fcmp` may or may not be flushing denormals to 0."
},
{
"author": "arsenm",
"body": "InstCombine doesn't fold this, IPSCCP does "
},
{
"author": "nikic",
"body": "I expect this is because we got through ValueLattice comparison, which does not have access to the denormal mode: https://github.com/llvm/llvm-project/blob/9501af5f92bb31fa9527d12a4b17b88d9fd651c4/llvm/lib/Analysis/ValueLattice.cpp#L28-L29\r\n\r\nReally, the constant folding implementation should be defaulting to the conservatively correct behavior if the denormal mode is unknown."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
107198
|
https://github.com/llvm/llvm-project/issues/107198
|
crash
|
c2b92a4250b3f514685676ba8985ea73450f14d3
| 2024-09-04T08:17:58 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "d65ff3e9364536f9e0bd5f1c1bace626c256a2ad",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
7780,
7785
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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::canMapToVector"
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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 d65ff3e9364536f9e0bd5f1c1bace626c256a2ad
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Wed Sep 4 05:12:17 2024 -0700
[SLP]Fix PR107198: add a check for empty complex type
Need to check if the complex type is empty before trying to dig in,
trying to find vectorizable type
Fixes https://github.com/llvm/llvm-project/issues/107198
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 19b95cf473e9..a2af7f4e1b01 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -7780,6 +7780,8 @@ unsigned BoUpSLP::canMapToVector(Type *T) const {
Type *EltTy = T;
while (isa<StructType, ArrayType, FixedVectorType>(EltTy)) {
+ if (EltTy->isEmptyTy())
+ return 0;
if (auto *ST = dyn_cast<StructType>(EltTy)) {
// Check that struct is homogeneous.
for (const auto *Ty : ST->elements())
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/empty-struct.ll",
"commands": [
"opt -S --passes=slp-vectorizer < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define { { {}, {}, {}, {}, {}, {}, {} } } @test({ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, { {}, {}, {}, {}, {}, {}, {} }, { {} } } %0) {\n %2 = extractvalue { {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, { {}, {}, {}, {}, {}, {}, {} }, { {} } } %0, 18\n %3 = insertvalue { { {}, {}, {}, {}, {}, {}, {} } } undef, { {}, {}, {}, {}, {}, {}, {} } %2, 0\n ret { { {}, {}, {}, {}, {}, {}, {} } } %3\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Crash on slp-vectorizer",
"body": "When running `/opt/llvm-19/bin/opt -O3 -S bug.ll` opt crashes with the following:\r\n\r\n(tested on 19 rc2 and rc4 and 18)\r\n```\r\n/opt/llvm-19/bin/llvm-config --version\r\n19.1.0-rc2\r\n\r\n/opt/llvm-19/bin/opt: WARNING: failed to create target machine for 'arm64-apple-darwin23.6.0': unable to get target for 'arm64-apple-darwin23.6.0', see --version and --triple.\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/llvm-19/bin/opt -O3 -S bug.ll\r\n1.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,chr,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"lol.ll\"\r\n2.\tRunning pass \"slp-vectorizer\" on function \"bug\"\r\n #0 0x00005558779163f7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/admin/repos/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:13\r\n #1 0x0000555877914570 llvm::sys::RunSignalHandlers() /home/admin/repos/llvm-project/llvm/lib/Support/Signals.cpp:106:18\r\n #2 0x0000555877916d9a SignalHandler(int) /home/admin/repos/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1\r\n #3 0x00007fb7b7e5b050 (/lib/x86_64-linux-gnu/libc.so.6+0x3c050)\r\n #4 0x0000555878d08ae0 llvm::slpvectorizer::BoUpSLP::canMapToVector(llvm::Type*) const /home/admin/repos/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:0:0\r\n #5 0x0000555878d3ca29 llvm::SLPVectorizerPass::vectorizeInsertValueInst(llvm::InsertValueInst*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, bool) /home/admin/repos/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:18336:8\r\n #6 0x0000555878d3d459 llvm::SLPVectorizerPass::vectorizeInserts(llvm::SmallSetVector<llvm::Instruction*, 8u>&, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) /home/admin/repos/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:0:11\r\n #7 0x0000555878d3e35b llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&)::$_172::operator()(bool) const /home/admin/repos/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:18847:20\r\n #8 0x0000555878d34039 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) /home/admin/repos/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:18963:18\r\n #9 0x0000555878d31968 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) /home/admin/repos/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:15865:13\r\n#10 0x0000555878d31431 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/admin/repos/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:15796:18\r\n#11 0x0000555878921dfd llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/admin/repos/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:90:5\r\n#12 0x0000555877ab570d llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/admin/repos/llvm-project/llvm/include/llvm/IR/PassManagerImpl.h:85:8\r\n#13 0x00005558785d887d 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/admin/repos/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:90:5\r\n#14 0x0000555877ab94f0 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /home/admin/repos/llvm-project/llvm/lib/IR/PassManager.cpp:129:23\r\n#15 0x00005558785d86cd llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /home/admin/repos/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:90:5\r\n#16 0x0000555877ab44ed llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /home/admin/repos/llvm-project/llvm/include/llvm/IR/PassManagerImpl.h:85:8\r\n#17 0x00005558788ca8c9 llvm::SmallPtrSetImplBase::isSmall() const /home/admin/repos/llvm-project/llvm/include/llvm/ADT/SmallPtrSet.h:197:33\r\n#18 0x00005558788ca8c9 llvm::SmallPtrSetImplBase::~SmallPtrSetImplBase() /home/admin/repos/llvm-project/llvm/include/llvm/ADT/SmallPtrSet.h:84:10\r\n#19 0x00005558788ca8c9 llvm::PreservedAnalyses::~PreservedAnalyses() /home/admin/repos/llvm-project/llvm/include/llvm/IR/Analysis.h:111:7\r\n#20 0x00005558788ca8c9 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/admin/repos/llvm-project/llvm/tools/opt/NewPMDriver.cpp:547:3\r\n#21 0x00005558778e5779 optMain /home/admin/repos/llvm-project/llvm/tools/opt/optdriver.cpp:739:12\r\n#22 0x00007fb7b7e4624a (/lib/x86_64-linux-gnu/libc.so.6+0x2724a)\r\n#23 0x00007fb7b7e46305 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x27305)\r\n#24 0x00005558778dfd21 _start (/opt/llvm-19/bin/opt+0xf17d21)\r\nSegmentation fault\r\n```\r\n\r\n```llvmir\r\n; ModuleID = 'LLVMDialectModule'\r\nsource_filename = \"LLVMDialectModule\"\r\ntarget datalayout = \"e-m:o-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"arm64-apple-darwin23.6.0\"\r\n\r\ndefine { { {}, {}, {}, {}, {}, {}, {} } } @\"bug\"({ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, { {}, {}, {}, {}, {}, {}, {} }, { {} } } %0) {\r\n %2 = extractvalue { {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, { {}, {}, {}, {}, {}, {}, {} }, { {} } } %0, 18\r\n %3 = insertvalue { { {}, {}, {}, {}, {}, {}, {} } } undef, { {}, {}, {}, {}, {}, {}, {} } %2, 0\r\n ret { { {}, {}, {}, {}, {}, {}, {} } } %3\r\n}\r\n\r\n!llvm.module.flags = !{!0}\r\n\r\n!0 = !{i32 2, !\"Debug Info Version\", i32 3}\r\n```",
"author": "edg-l",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": [
{
"author": "edg-l",
"body": "one question, will this be included in llvm 19?"
},
{
"author": "alexey-bataev",
"body": "Not sure, it is not an immediate regression from 18 to 19, and it is too late, I think, to include it into 19"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
141968
|
https://github.com/llvm/llvm-project/issues/141968
|
crash
|
389e9d3a422f17356d1f90913b891d23011ae5b3
| 2025-05-29T15:40:08 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "b8c4eea3d8b2a2df9442319de14ef38c2492428d",
"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": [
[
1015,
1027
]
],
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 b8c4eea3d8b2a2df9442319de14ef38c2492428d
Author: Ramkumar Ramachandra <ramkumar.ramachandra@codasip.com>
Date: Mon Jun 2 15:56:35 2025 +0200
[VPlan] Simplify PredPHI LiveIn -> LiveIn (#142271)
5f39be5 ([VPlan] Use InstSimplifyFolder instead of TargetFolder) updated
simplifyRecipe to fold live-ins to Values that are not necessarily
Constant, but forgot to update the corresponding PredPHI folder, which
still folds PredPHI constant -> constant. Update it to fold PredPHI
LiveIn -> LiveIn.
Fixes #141968.
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 5b42a9056b69..348100124ba3 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -1015,13 +1015,11 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
.Default([](auto *) { return false; }))
return;
- // Fold PredPHI constant -> constant.
+ // Fold PredPHI LiveIn -> LiveIn.
if (auto *PredPHI = dyn_cast<VPPredInstPHIRecipe>(&R)) {
VPValue *Op = PredPHI->getOperand(0);
- if (!Op->isLiveIn() || !Op->getLiveInIRValue())
- return;
- if (auto *C = dyn_cast<Constant>(Op->getLiveInIRValue()))
- PredPHI->replaceAllUsesWith(Plan->getOrAddLiveIn(C));
+ if (Op->isLiveIn())
+ PredPHI->replaceAllUsesWith(Op);
}
VPValue *A;
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/X86/pr141968-instsimplifyfolder.ll",
"commands": [
"opt -passes=loop-vectorize -S %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ntarget triple = \"x86_64\"\n\ndefine i8 @pr141968(i1 %cond, i8 %v) {\n;\nentry:\n %zext.true = zext i1 true to i16\n %sext = sext i8 %v to i16\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i8 [ %iv.next, %loop.latch ], [ 0, %entry ]\n br i1 %cond, label %loop.latch, label %cond.false\n\ncond.false: ; preds = %loop.header\n %sdiv = sdiv i16 %sext, %zext.true\n %sdiv.trunc = trunc i16 %sdiv to i8\n br label %loop.latch\n\nloop.latch: ; preds = %cond.false, %loop.header\n %ret = phi i8 [ %sdiv.trunc, %cond.false ], [ 0, %loop.header ]\n %iv.next = add i8 %iv, 1\n %exitcond = icmp eq i8 %iv.next, 0\n br i1 %exitcond, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret i8 %ret\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[LoopVectorize] Assertion `PredicatingBB && \"Predicated block has no single predecessor.\"' failed.",
"body": "Crash reproducer:\n```\n; bin/opt -passes=loop-vectorize test.ll -S\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i32 @main(i1 %cmp.i679.i.i.i, ptr %p) {\nentry:\n br label %for.cond1.preheader.i\n\nfor.cond1.preheader.i: ; preds = %for.cond1.preheader.i, %entry\n %indvars.iv.i = phi i64 [ 0, %entry ], [ %indvars.iv.next.i, %for.cond1.preheader.i ]\n %arrayidx.i = getelementptr [256 x i32], ptr %p, i64 0, i64 %indvars.iv.i\n store i32 0, ptr %arrayidx.i, align 4\n %indvars.iv.next.i = add i64 %indvars.iv.i, 1\n %exitcond.not.i = icmp eq i64 %indvars.iv.i, 1\n br i1 %exitcond.not.i, label %crc32_gentab.exit, label %for.cond1.preheader.i\n\ncrc32_gentab.exit: ; preds = %for.cond1.preheader.i\n %div.rhs.trunc.i.i.i.i = sext i8 1 to i16\n %0 = trunc i32 0 to i16\n br label %for.body222.i.i.i\n\nfor.body222.i.i.i: ; preds = %safe_mod_func_int32_t_s_s.exit.i.i.i, %crc32_gentab.exit\n %p_188.addr.2816.i.i.i = phi i16 [ 0, %crc32_gentab.exit ], [ %inc272.i.i.i, %safe_mod_func_int32_t_s_s.exit.i.i.i ]\n br i1 %cmp.i679.i.i.i, label %safe_mod_func_int32_t_s_s.exit.i.i.i, label %cond.false.i683.i.i.i\n\ncond.false.i683.i.i.i: ; preds = %for.body222.i.i.i\n %div16.i.i.i.i = sdiv i16 %0, %div.rhs.trunc.i.i.i.i\n %1 = zext i16 %div16.i.i.i.i to i32\n br label %safe_mod_func_int32_t_s_s.exit.i.i.i\n\nsafe_mod_func_int32_t_s_s.exit.i.i.i: ; preds = %cond.false.i683.i.i.i, %for.body222.i.i.i\n %cond.i684.i.i.i = phi i32 [ %1, %cond.false.i683.i.i.i ], [ 0, %for.body222.i.i.i ]\n %inc272.i.i.i = add i16 %p_188.addr.2816.i.i.i, 1\n %exitcond.not.i.i.i = icmp eq i16 %inc272.i.i.i, 0\n br i1 %exitcond.not.i.i.i, label %if.else417.i.i.i, label %for.body222.i.i.i\n\nif.else417.i.i.i: ; preds = %safe_mod_func_int32_t_s_s.exit.i.i.i\n ret i32 %cond.i684.i.i.i\n}\n```\n```\nopt: /home/dtcxzyw/WorkSpace/Projects/compilers/llvm-project/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp:2885: virtual void llvm::VPPredInstPHIRecipe::execute(llvm::VPTransformState&): Assertion `PredicatingBB && \"Predicated block has no single predecessor.\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0. Program arguments: bin/opt -passes=loop-vectorize reduced.ll -S\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 \"main\"\n #0 0x00007088da627ab2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.21.0git+0x227ab2)\n #1 0x00007088da62498f llvm::sys::RunSignalHandlers() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.21.0git+0x22498f)\n #2 0x00007088da624ad4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #3 0x00007088da045330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)\n #4 0x00007088da09eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #5 0x00007088da09eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #6 0x00007088da09eb2c pthread_kill ./nptl/pthread_kill.c:89:10\n #7 0x00007088da04527e raise ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x00007088da0288ff abort ./stdlib/abort.c:81:7\n #9 0x00007088da02881b _nl_load_domain ./intl/loadmsgcat.c:1177:9\n#10 0x00007088da03b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)\n#11 0x00007088d38e230e llvm::VPPredInstPHIRecipe::execute(llvm::VPTransformState&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.21.0git+0x2e230e)\n#12 0x00007088d3889738 llvm::VPBasicBlock::executeRecipes(llvm::VPTransformState*, llvm::BasicBlock*) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.21.0git+0x289738)\n#13 0x00007088d389abd5 llvm::VPBasicBlock::execute(llvm::VPTransformState*) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.21.0git+0x29abd5)\n#14 0x00007088d388c05d llvm::VPRegionBlock::execute(llvm::VPTransformState*) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.21.0git+0x28c05d)\n#15 0x00007088d389cff5 llvm::VPlan::execute(llvm::VPTransformState*) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.21.0git+0x29cff5)\n#16 0x00007088d36f1382 llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.21.0git+0xf1382)\n#17 0x00007088d3709d6f llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.21.0git+0x109d6f)\n#18 0x00007088d370bf11 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.21.0git+0x10bf11)\n#19 0x00007088d370c586 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.21.0git+0x10c586)\n#20 0x00007088d42ec9c5 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMPasses.so.21.0git+0xec9c5)\n#21 0x00007088d1127444 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.21.0git+0x327444)\n#22 0x00007088d90db9b5 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.21.0git+0xdb9b5)\n#23 0x00007088d1127960 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.21.0git+0x327960)\n#24 0x00007088d90dc375 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.21.0git+0xdc375)\n#25 0x00007088d1128ae5 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.21.0git+0x328ae5)\n#26 0x00007088da7912e9 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.21.0git+0x2c2e9)\n#27 0x00007088da79c306 optMain (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.21.0git+0x37306)\n#28 0x00007088da02a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3\n#29 0x00007088da02a28b call_init ./csu/../csu/libc-start.c:128:20\n#30 0x00007088da02a28b __libc_start_main ./csu/../csu/libc-start.c:347:5\n#31 0x000064bed9823095 _start (bin/opt+0x1095)\nAborted (core dumped)\n```\nllvm version: 94bcd9ceedc7e194b6296e4a293c60b8e38d1b67",
"author": "dtcxzyw",
"labels": [
"vectorizers",
"crash-on-valid",
"generated by fuzzer"
],
"comments": [
{
"author": "gregbedwell",
"body": "We've hit this as well in our testing.\nhttps://godbolt.org/z/hjGqcsWso\n\n```\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-unknown\"\n\ndefine i8 @g(i1 %cmp3) {\nentry:\n %0 = zext i1 true to i16\n %div.lhs.trunc = sext i8 0 to i16\n br label %for.body\n\nfor.body: ; preds = %cond.end, %entry\n %b.014 = phi i8 [ %inc, %cond.end ], [ 0, %entry ]\n br i1 %cmp3, label %cond.end, label %cond.false\n\ncond.false: ; preds = %for.body\n %div13 = sdiv i16 %div.lhs.trunc, %0\n %1 = trunc i16 %div13 to i8\n br label %cond.end\n\ncond.end: ; preds = %cond.false, %for.body\n %cond = phi i8 [ %1, %cond.false ], [ 0, %for.body ]\n %inc = add i8 %b.014, 1\n %exitcond.not = icmp eq i8 %inc, 0\n br i1 %exitcond.not, label %for.end, label %for.body\n\nfor.end: ; preds = %cond.end\n ret i8 %cond\n}\n```\n\n```\nopt: /root/llvm-project/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp:2885: virtual void llvm::VPPredInstPHIRecipe::execute(llvm::VPTransformState&): Assertion `PredicatingBB && \"Predicated block has no single predecessor.\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S --passes=loop-vectorize <source>\n1.\tRunning pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"<source>\"\n2.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"g\"\n #0 0x0000000005603c18 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5603c18)\n #1 0x00000000056015a4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x000071a65b642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x000071a65b6969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x000071a65b642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x000071a65b6287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x000071a65b62871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x000071a65b639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x00000000035fc5b7 llvm::VPPredInstPHIRecipe::execute(llvm::VPTransformState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x35fc5b7)\n #9 0x00000000035a9a8a llvm::VPBasicBlock::executeRecipes(llvm::VPTransformState*, llvm::BasicBlock*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x35a9a8a)\n#10 0x00000000035bc70d llvm::VPBasicBlock::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x35bc70d)\n#11 0x00000000035afb81 llvm::VPRegionBlock::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x35afb81)\n#12 0x00000000035bf201 llvm::VPlan::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x35bf201)\n#13 0x0000000003459b9b llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3459b9b)\n#14 0x0000000003470889 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3470889)\n#15 0x0000000003472670 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3472670)\n#16 0x0000000003472cc3 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3472cc3)\n#17 0x0000000002d824be 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+0x2d824be)\n#18 0x00000000053fa1f0 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x53fa1f0)\n#19 0x0000000000e91dde 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+0xe91dde)\n#20 0x00000000053fa703 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x53fa703)\n#21 0x0000000000e90c2e 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+0xe90c2e)\n#22 0x00000000053f8320 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x53f8320)\n#23 0x00000000009519ea 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+0x9519ea)\n#24 0x00000000009451bc optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9451bc)\n#25 0x000071a65b629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#26 0x000071a65b629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#27 0x000000000093cdf5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x93cdf5)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```\n\nBisected to 5f39be591714eba1be413e2b3ed6fc152a15bb8e"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
94328
|
https://github.com/llvm/llvm-project/issues/94328
|
crash
|
098bd842a7e50853fa231f8b73c24ec5006fe063
| 2024-06-04T09:16:11 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "008df3cf85e9bb1532c079bfd7a7a00e90e0a3c6",
"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": [
[
3914,
3932
],
[
9516,
9521
]
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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",
"VPReplicateRecipe::execute"
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 008df3cf85e9bb1532c079bfd7a7a00e90e0a3c6
Author: Florian Hahn <flo@fhahn.com>
Date: Fri Jul 19 12:02:25 2024 +0100
[LV] Check isPredInst instead of isScalarWithPred in uniform analysis. (#98892)
Any instruction marked as uniform will result in a uniform
VPReplicateRecipe. If it requires predication, it will be placed in a
replicate region, even if isScalarWithPredication returns false.
Check isPredicatedInst instead of isScalarWithPredication to avoid
generating uniform VPReplicateRecipes placed inside a replicate region.
This fixes an assertion when using scalable VFs.
Fixes https://github.com/llvm/llvm-project/issues/80416.
Fixes https://github.com/llvm/llvm-project/issues/94328.
Fixes https://github.com/llvm/llvm-project/issues/99625.
PR: https://github.com/llvm/llvm-project/pull/98892
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index fbca4cdcbcfc..cceed75aa50b 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -3914,19 +3914,19 @@ void LoopVectorizationCostModel::collectLoopUniforms(ElementCount VF) {
SetVector<Instruction *> Worklist;
// Add uniform instructions demanding lane 0 to the worklist. Instructions
- // that are scalar with predication must not be considered uniform after
+ // that require predication must not be considered uniform after
// vectorization, because that would create an erroneous replicating region
// where only a single instance out of VF should be formed.
- // TODO: optimize such seldom cases if found important, see PR40816.
auto addToWorklistIfAllowed = [&](Instruction *I) -> void {
if (isOutOfScope(I)) {
LLVM_DEBUG(dbgs() << "LV: Found not uniform due to scope: "
<< *I << "\n");
return;
}
- if (isScalarWithPredication(I, VF)) {
- LLVM_DEBUG(dbgs() << "LV: Found not uniform being ScalarWithPredication: "
- << *I << "\n");
+ if (isPredicatedInst(I)) {
+ LLVM_DEBUG(
+ dbgs() << "LV: Found not uniform due to requiring predication: " << *I
+ << "\n");
return;
}
LLVM_DEBUG(dbgs() << "LV: Found uniform instruction: " << *I << "\n");
@@ -9516,6 +9516,8 @@ void VPInterleaveRecipe::execute(VPTransformState &State) {
void VPReplicateRecipe::execute(VPTransformState &State) {
Instruction *UI = getUnderlyingInstr();
if (State.Instance) { // Generate a single instance.
+ assert((State.VF.isScalar() || !isUniform()) &&
+ "uniform recipe shouldn't be predicated");
assert(!State.VF.isScalable() && "Can't scalarize a scalable vector");
State.ILV->scalarizeInstruction(UI, this, *State.Instance, State);
// Insert scalar instance packing it into a vector.
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/divs-with-scalable-vfs.ll",
"commands": [
"opt -p loop-vectorize -mtriple aarch64 -mcpu=neoverse-v1 -S %s"
],
"tests": [
{
"test_name": "udiv_urem_feeding_gep",
"test_body": "define void @udiv_urem_feeding_gep(i64 %x, ptr %dst, i64 %N) {\nentry:\n %mul.1.i = mul i64 %x, %x\n %mul.2.i = mul i64 %mul.1.i, %x\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %div.i = udiv i64 %iv, %mul.2.i\n %rem.i = urem i64 %iv, %mul.2.i\n %div.1.i = udiv i64 %rem.i, %mul.1.i\n %rem.1.i = urem i64 %rem.i, %mul.1.i\n %div.2.i = udiv i64 %rem.1.i, %x\n %rem.2.i = urem i64 %rem.1.i, %x\n %mul.i = mul i64 %x, %div.i\n %add.i = add i64 %mul.i, %div.1.i\n %mul.1.i9 = mul i64 %add.i, %x\n %add.1.i = add i64 %mul.1.i9, %div.2.i\n %mul.2.i11 = mul i64 %add.1.i, %x\n %add.2.i = add i64 %mul.2.i11, %rem.2.i\n %sext.i = shl i64 %add.2.i, 32\n %conv6.i = ashr i64 %sext.i, 32\n %gep = getelementptr i64, ptr %dst, i64 %conv6.i\n store i64 %div.i, ptr %gep, align 4\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv, %N\n br i1 %exitcond.not, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "sdiv_feeding_gep_predicated",
"test_body": "define void @sdiv_feeding_gep_predicated(ptr %dst, i32 %x, i64 %M, i64 %conv6, i64 %N) {\nentry:\n %conv61 = zext i32 %x to i64\n br label %loop\n\nloop: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %c = icmp ule i64 %iv, %M\n br i1 %c, label %then, label %loop.latch\n\nthen: ; preds = %loop\n %div18 = sdiv i64 %M, %conv6\n %conv20 = trunc i64 %div18 to i32\n %mul30 = mul i64 %div18, %conv61\n %sub31 = sub i64 %iv, %mul30\n %conv34 = trunc i64 %sub31 to i32\n %mul35 = mul i32 %x, %conv20\n %add36 = add i32 %mul35, %conv34\n %idxprom = sext i32 %add36 to i64\n %gep = getelementptr double, ptr %dst, i64 %idxprom\n store double 0.000000e+00, ptr %gep, align 8\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop\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.latch\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "sdiv_feeding_gep",
"test_body": "define void @sdiv_feeding_gep(ptr %dst, i32 %x, i64 %M, i64 %conv6, i64 %N) {\nentry:\n %conv61 = zext i32 %x to i64\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %div18 = sdiv i64 %M, %conv6\n %conv20 = trunc i64 %div18 to i32\n %mul30 = mul i64 %div18, %conv61\n %sub31 = sub i64 %iv, %mul30\n %conv34 = trunc i64 %sub31 to i32\n %mul35 = mul i32 %x, %conv20\n %add36 = add i32 %mul35, %conv34\n %idxprom = sext i32 %add36 to i64\n %gep = getelementptr double, ptr %dst, i64 %idxprom\n store double 0.000000e+00, ptr %gep, align 8\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
}
]
}
] |
{
"title": "[VPlan] Report \"Assertion `!State->VF.isScalable() && \"VF is assumed to be non scalable.\"' failed\"",
"body": "The IR is put at the end.\r\n\r\nCompile command is `opt -passes=loop-vectorize -prefer-predicate-over-epilogue=predicate-else-scalar-epilogue`\r\n\r\nThe error is\r\n```\r\nopt: /root/llvm-project/llvm/lib/Transforms/Vectorize/VPlan.cpp:734: virtual void llvm::VPRegionBlock::execute(llvm::VPTransformState*): Assertion `!State->VF.isScalable() && \"VF is assumed to be non scalable.\"' failed.\r\n```\r\n\r\nIt can be seen at https://godbolt.org/z/s4bqzdKPP\r\n\r\n```\r\n; ModuleID = 'test.cpp'\r\nsource_filename = \"test.cpp\"\r\ntarget datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"aarch64-unknown-linux-gnu\"\r\n\r\n%struct.ident_t = type { i32, i32, i32, i32, ptr }\r\n\r\n@0 = private unnamed_addr constant [23 x i8] c\";unknown;unknown;0;0;;\\00\", align 1\r\n@1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 514, i32 0, i32 22, ptr @0 }, align 8\r\n@2 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 22, ptr @0 }, align 8\r\n\r\n; Function Attrs: mustprogress nounwind uwtable vscale_range(1,16)\r\ndefine dso_local void @_Z4testiiPdS_(i32 noundef %nx, i32 noundef %ik, ptr noundef %out, ptr noundef %rspace) local_unnamed_addr #0 {\r\nentry:\r\n %nx.addr = alloca i32, align 4\r\n %ik.addr = alloca i32, align 4\r\n %out.addr = alloca ptr, align 8\r\n %rspace.addr = alloca ptr, align 8\r\n store i32 %nx, ptr %nx.addr, align 4\r\n store i32 %ik, ptr %ik.addr, align 4\r\n store ptr %out, ptr %out.addr, align 8\r\n store ptr %rspace, ptr %rspace.addr, align 8\r\n call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr nonnull @2, i32 4, ptr nonnull @_Z4testiiPdS_.omp_outlined, ptr nonnull %nx.addr, ptr nonnull %ik.addr, ptr nonnull %out.addr, ptr nonnull %rspace.addr)\r\n ret void\r\n}\r\n\r\n; Function Attrs: alwaysinline norecurse nounwind uwtable vscale_range(1,16)\r\ndefine internal void @_Z4testiiPdS_.omp_outlined(ptr noalias nocapture noundef readonly %.global_tid., ptr noalias nocapture noundef readnone %.bound_tid., ptr noalias nocapture noundef nonnull readonly align 4 dereferenceable(4) %nx, ptr noalias nocapture noundef nonnull readonly align 4 dereferenceable(4) %ik, ptr noalias nocapture noundef nonnull readonly align 8 dereferenceable(8) %out, ptr noalias nocapture noundef nonnull readonly align 8 dereferenceable(8) %rspace) #1 {\r\nentry:\r\n %.omp.lb = alloca i64, align 8\r\n %.omp.ub = alloca i64, align 8\r\n %.omp.stride = alloca i64, align 8\r\n %.omp.is_last = alloca i32, align 4\r\n %0 = load i32, ptr %nx, align 4\r\n %1 = load i32, ptr %ik, align 4\r\n %cmp = icmp sgt i32 %0, 0\r\n %cmp8 = icmp sgt i32 %1, 0\r\n %or.cond = select i1 %cmp, i1 %cmp8, i1 false\r\n br i1 %or.cond, label %omp.precond.then, label %omp.precond.end\r\n\r\nomp.precond.then: ; preds = %entry\r\n %conv = zext i32 %0 to i64\r\n %conv6 = zext i32 %1 to i64\r\n %mul = mul nuw nsw i64 %conv6, %conv\r\n %sub7 = add nsw i64 %mul, -1\r\n call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %.omp.lb) #3\r\n store i64 0, ptr %.omp.lb, align 8\r\n call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %.omp.ub) #3\r\n store i64 %sub7, ptr %.omp.ub, align 8\r\n call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %.omp.stride) #3\r\n store i64 1, ptr %.omp.stride, align 8\r\n call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %.omp.is_last) #3\r\n store i32 0, ptr %.omp.is_last, align 4\r\n %2 = load i32, ptr %.global_tid., align 4\r\n call void @__kmpc_for_static_init_8(ptr nonnull @1, i32 %2, i32 33, ptr nonnull %.omp.is_last, ptr nonnull %.omp.lb, ptr nonnull %.omp.ub, ptr nonnull %.omp.stride, i64 1, i64 512)\r\n %3 = load i64, ptr %.omp.ub, align 8\r\n %cond60 = call i64 @llvm.smin.i64(i64 %3, i64 %sub7)\r\n store i64 %cond60, ptr %.omp.ub, align 8\r\n %4 = load i64, ptr %.omp.lb, align 8\r\n %cmp12.not61 = icmp sgt i64 %4, %cond60\r\n br i1 %cmp12.not61, label %omp.dispatch.end, label %omp.inner.for.cond.preheader.lr.ph\r\n\r\nomp.inner.for.cond.preheader.lr.ph: ; preds = %omp.precond.then\r\n br label %omp.inner.for.cond.preheader\r\n\r\nomp.inner.for.cond.preheader: ; preds = %omp.inner.for.cond.preheader.lr.ph, %omp.dispatch.inc\r\n %5 = phi i64 [ %4, %omp.inner.for.cond.preheader.lr.ph ], [ %add42, %omp.dispatch.inc ]\r\n %cond62 = phi i64 [ %cond60, %omp.inner.for.cond.preheader.lr.ph ], [ %cond, %omp.dispatch.inc ]\r\n %smax = call i64 @llvm.smax.i64(i64 %cond62, i64 %5)\r\n %6 = add i64 %smax, 1\r\n %7 = load ptr, ptr %rspace, align 8\r\n %8 = load ptr, ptr %out, align 8\r\n br label %omp.inner.for.body\r\n\r\nomp.inner.for.body: ; preds = %omp.inner.for.cond.preheader, %omp.inner.for.body\r\n %.omp.iv.059 = phi i64 [ %5, %omp.inner.for.cond.preheader ], [ %add41, %omp.inner.for.body ]\r\n %div18 = sdiv i64 %.omp.iv.059, %conv6\r\n %conv20 = trunc i64 %div18 to i32\r\n %mul30 = mul nsw i64 %div18, %conv6\r\n %sub31 = sub nsw i64 %.omp.iv.059, %mul30\r\n %conv34 = trunc i64 %sub31 to i32\r\n %mul35 = mul nsw i32 %1, %conv20\r\n %add36 = add nsw i32 %mul35, %conv34\r\n %idxprom = sext i32 %add36 to i64\r\n %arrayidx = getelementptr inbounds double, ptr %7, i64 %idxprom\r\n %9 = load double, ptr %arrayidx, align 8\r\n %arrayidx40 = getelementptr inbounds double, ptr %8, i64 %idxprom\r\n store double %9, ptr %arrayidx40, align 8\r\n %add41 = add i64 %.omp.iv.059, 1\r\n %exitcond = icmp ne i64 %add41, %6\r\n br i1 %exitcond, label %omp.inner.for.body, label %omp.dispatch.inc\r\n\r\nomp.dispatch.inc: ; preds = %omp.inner.for.body\r\n %10 = load i64, ptr %.omp.stride, align 8\r\n %add42 = add nsw i64 %10, %5\r\n store i64 %add42, ptr %.omp.lb, align 8\r\n %add43 = add nsw i64 %10, %cond62\r\n %cond = call i64 @llvm.smin.i64(i64 %add43, i64 %sub7)\r\n store i64 %cond, ptr %.omp.ub, align 8\r\n %cmp12.not = icmp sgt i64 %add42, %cond\r\n br i1 %cmp12.not, label %omp.dispatch.cond.omp.dispatch.end_crit_edge, label %omp.inner.for.cond.preheader\r\n\r\nomp.dispatch.cond.omp.dispatch.end_crit_edge: ; preds = %omp.dispatch.inc\r\n br label %omp.dispatch.end\r\n\r\nomp.dispatch.end: ; preds = %omp.dispatch.cond.omp.dispatch.end_crit_edge, %omp.precond.then\r\n call void @__kmpc_for_static_fini(ptr nonnull @1, i32 %2)\r\n call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %.omp.is_last) #3\r\n call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %.omp.stride) #3\r\n call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %.omp.ub) #3\r\n call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %.omp.lb) #3\r\n br label %omp.precond.end\r\n\r\nomp.precond.end: ; preds = %omp.dispatch.end, %entry\r\n ret void\r\n}\r\n\r\n; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)\r\ndeclare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2\r\n\r\n; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)\r\ndeclare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2\r\n\r\n; Function Attrs: nounwind\r\ndeclare void @__kmpc_for_static_init_8(ptr, i32, i32, ptr, ptr, ptr, ptr, i64, i64) local_unnamed_addr #3\r\n\r\n; Function Attrs: nounwind\r\ndeclare void @__kmpc_for_static_fini(ptr, i32) local_unnamed_addr #3\r\n\r\n; Function Attrs: nounwind\r\ndeclare void @__kmpc_fork_call(ptr, i32, ptr, ...) local_unnamed_addr #3\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\r\ndeclare i64 @llvm.smin.i64(i64, i64) #4\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\r\ndeclare i64 @llvm.smax.i64(i64, i64) #4\r\n\r\nattributes #0 = { mustprogress nounwind uwtable vscale_range(1,16) \"frame-pointer\"=\"non-leaf\" \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"generic\" \"target-features\"=\"+fp-armv8,+fullfp16,+neon,+sve,+v8a,-fmv\" }\r\nattributes #1 = { alwaysinline norecurse nounwind uwtable vscale_range(1,16) \"frame-pointer\"=\"non-leaf\" \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"generic\" \"target-features\"=\"+fp-armv8,+fullfp16,+neon,+sve,+v8a,-fmv\" }\r\nattributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }\r\nattributes #3 = { nounwind }\r\nattributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\r\n\r\n```",
"author": "eastB233",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "eastB233",
"body": "Simpler test case is\r\n```c\r\nextern const int npy;\r\nextern const int nx;\r\ndouble* rspace;\r\n\r\nvoid recip2real(double* out, const double factor)\r\n{\r\n#ifdef _OPENMP\r\n#pragma omp parallel for collapse(2)\r\n#endif\r\n for (int ix = 0; ix < nx; ++ix)\r\n {\r\n for (int ipy = 0; ipy < npy; ++ipy) {\r\n out[ix * npy + ipy] += factor * rspace[ix * npy + ipy];\r\n }\r\n }\r\n}\r\n```\r\n\r\nCommand is `clang -O3 -march=armv9-a -fopenmp -mllvm -prefer-predicate-over-epilogue=predicate-else-scalar-epilogue -S`\r\n\r\nIt can be seen at https://godbolt.org/z/6MGsecEr5"
},
{
"author": "eastB233",
"body": "I don't know much about VPlan, and as far as I understand by tracing the code,\r\n\r\n### first, it fails at the following VPlan\r\n```\r\nVPlan 'Initial VPlan for VF={vscale x 1,vscale x 2},UF>=1' {\r\nvp<%2> = original trip-count\r\n\r\nph:\r\n EMIT vp<%2> = EXPAND SCEV (1 + (-1 * %5) + ((-1 + ((zext i32 %0 to i64) * (sext i32 %1 to i64)))<nsw> smin %4))\r\nNo successors\r\n\r\nvector.ph:\r\n EMIT vp<%3> = TC > VF ? TC - VF : 0 vp<%2>\r\n EMIT vp<%4> = VF * Part + ir<0>\r\n EMIT vp<%5> = active lane mask vp<%4>, vp<%2>\r\nSuccessor(s): vector loop\r\n\r\n<x1> vector loop: {\r\n vector.body:\r\n EMIT vp<%6> = CANONICAL-INDUCTION\r\n ACTIVE-LANE-MASK-PHI vp<%7> = phi vp<%5>, vp<%27>\r\n vp<%8> = DERIVED-IV ir<%5> + vp<%6> * ir<1>\r\n vp<%9> = SCALAR-STEPS vp<%8>, ir<1>\r\n Successor(s): pred.sdiv\r\n\r\n <xVFxUF> pred.sdiv: {\r\n pred.sdiv.entry:\r\n BRANCH-ON-MASK vp<%7>\r\n Successor(s): pred.sdiv.if, pred.sdiv.continue\r\n\r\n pred.sdiv.if:\r\n CLONE ir<%div24> = sdiv vp<%9>, ir<%conv6>\r\n Successor(s): pred.sdiv.continue\r\n\r\n pred.sdiv.continue:\r\n PHI-PREDICATED-INSTRUCTION vp<%11> = ir<%div24>\r\n No successors\r\n }\r\n Successor(s): omp.inner.for.body.0\r\n\r\n omp.inner.for.body.0:\r\n CLONE ir<%conv26> = trunc vp<%11>\r\n CLONE ir<%mul36> = mul nsw vp<%11>, ir<%conv6>\r\n CLONE ir<%sub37> = sub nsw vp<%9>, ir<%mul36>\r\n CLONE ir<%conv40> = trunc ir<%sub37>\r\n CLONE ir<%mul41> = mul nsw ir<%1>, ir<%conv26>\r\n CLONE ir<%add42> = add nsw ir<%mul41>, ir<%conv40>\r\n CLONE ir<%idxprom> = sext ir<%add42>\r\n CLONE ir<%arrayidx> = getelementptr inbounds ir<%6>, ir<%idxprom>\r\n WIDEN ir<%8> = load ir<%arrayidx>, vp<%7>\r\n WIDEN ir<%mul43> = fmul contract ir<%2>, ir<%8>\r\n CLONE ir<%arrayidx47> = getelementptr inbounds ir<%7>, ir<%idxprom>\r\n WIDEN ir<%9> = load ir<%arrayidx47>, vp<%7>\r\n WIDEN ir<%add48> = fadd contract ir<%mul43>, ir<%9>\r\n WIDEN store ir<%arrayidx47>, ir<%add48>, vp<%7>\r\n EMIT vp<%25> = VF * UF + vp<%6>\r\n EMIT vp<%26> = VF * Part + vp<%6>\r\n EMIT vp<%27> = active lane mask vp<%26>, vp<%3>\r\n EMIT vp<%28> = not vp<%27>\r\n EMIT branch-on-cond vp<%28>\r\n No successors\r\n}\r\nSuccessor(s): middle.block\r\n```\r\n\r\nVPRegion `pred.sdiv` fails at assertion\r\n```c++\r\nvoid VPRegionBlock::execute(VPTransformState *State) {\r\n...\r\n if (!isReplicator()) {\r\n...\r\n return;\r\n }\r\n...\r\n for (...) {\r\n assert(!State->VF.isScalable() && \"VF is assumed to be non scalable.\");\r\n }\r\n}\r\n```\r\nI think VPRegion `pred.sdiv` should have `isReplicator() == false` or `pred.sdiv` just should not exist.\r\n\r\n### second, I find VPRegion `pred.sdiv` is splitted from `WorkList`\r\n```c++\r\nstatic void addReplicateRegions(VPlan &Plan) {\r\n SmallVector<VPReplicateRecipe *> WorkList;\r\n for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(\r\n vp_depth_first_deep(Plan.getEntry()))) {\r\n for (VPRecipeBase &R : *VPBB)\r\n if (auto *RepR = dyn_cast<VPReplicateRecipe>(&R)) {\r\n if (RepR->isPredicated())\r\n WorkList.push_back(RepR);\r\n }\r\n }\r\n...\r\n}\r\n```\r\nby VPRecipe `CLONE ir<%div24> = sdiv ir<%.omp.iv.065>, ir<%conv6>, vp<%7>`, where the instruction is `%div24 = sdiv i64 %.omp.iv.065, %conv6`\r\nI think this VPRecipe should have `isPredicated() == false` here, so it will not be splitted.\r\n\r\n### third, I find this VPRecipe is created here\r\n```c++\r\nVPRecipeOrVPValueTy VPRecipeBuilder::handleReplication(...) {\r\n bool IsUniform = LoopVectorizationPlanner::getDecisionAndClampRange(\r\n [&](ElementCount VF) { return CM.isUniformAfterVectorization(I, VF); },\r\n Range);\r\n\r\n bool IsPredicated = CM.isPredicatedInst(I);\r\n...\r\n VPValue *BlockInMask = nullptr;\r\n if (!IsPredicated) {\r\n // Finalize the recipe for Instr, first if it is not predicated.\r\n LLVM_DEBUG(dbgs() << \"LV: Scalarizing:\" << *I << \"\\n\");\r\n } else {\r\n LLVM_DEBUG(dbgs() << \"LV: Scalarizing and predicating:\" << *I << \"\\n\");\r\n // Instructions marked for predication are replicated and a mask operand is\r\n // added initially. Masked replicate recipes will later be placed under an\r\n // if-then construct to prevent side-effects. Generate recipes to compute\r\n // the block mask for this region.\r\n BlockInMask = createBlockInMask(I->getParent(), Plan);\r\n }\r\n\r\n auto *Recipe = new VPReplicateRecipe(I, Plan.mapToVPValues(I->operands()),\r\n IsUniform, BlockInMask);\r\n return toVPRecipeResult(Recipe);\r\n}\r\n```\r\nI notice that instruction `I` (`%div24 = sdiv i64 %.omp.iv.065, %conv6`) do not need to vectorize, because function `isScalarAfterVectorization` returns true and `I` is just used to calculate the index.\r\nIt seems reasonable that a `scalar` instruction does not need `Predicated`.\r\n\r\n### So I try the following modification,\r\n```diff\r\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\r\nindex 907b8ce002e8..76a5704a61c5 100644\r\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\r\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\r\n@@ -9819,7 +9819,9 @@ VPRecipeOrVPValueTy VPRecipeBuilder::handleReplication(Instruction *I,\r\n [&](ElementCount VF) { return CM.isUniformAfterVectorization(I, VF); },\r\n Range);\r\n\r\n- bool IsPredicated = CM.isPredicatedInst(I);\r\n+ bool IsPredicated = LoopVectorizationPlanner::getDecisionAndClampRange(\r\n+ [&](ElementCount VF) { return CM.isPredicatedInst(I) && !CM.isScalarAfterVectorization(I, VF); },\r\n+ Range);\r\n\r\n // Even if the instruction is not marked as uniform, there are certain\r\n // intrinsic calls that can be effectively treated as such, so we check for\r\n```\r\n\r\nJust my guess, I'm not sure if it is correct direction."
},
{
"author": "eastB233",
"body": "Ping @fhahn "
},
{
"author": "eastB233",
"body": "I think I misunderstand something, and the changes above may be wrong.\r\n\r\nAnd I have another way. In instruction `%div24 = sdiv i64 %.omp.iv.065, %conv6`, `%conv6` is invariant in loop, so it seems we do not need `Predicated`.\r\n\r\nI try the following patch,\r\n```diff\r\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\r\nindex c7c19ef456c7..f294703e1529 100644\r\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\r\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\r\n@@ -3856,21 +3856,21 @@ bool LoopVectorizationCostModel::isPredicatedInst(Instruction *I) const {\r\n !Legal->blockNeedsPredication(I->getParent()))\r\n return false;\r\n return true;\r\n }\r\n case Instruction::UDiv:\r\n case Instruction::SDiv:\r\n case Instruction::SRem:\r\n case Instruction::URem:\r\n // TODO: We can use the loop-preheader as context point here and get\r\n // context sensitive reasoning\r\n- return !isSafeToSpeculativelyExecute(I);\r\n+ return !isSafeToSpeculativelyExecute(I) && !Legal->isInvariant(I->getOperand(1));\r\n case Instruction::Call:\r\n return Legal->isMaskRequired(I);\r\n }\r\n }\r\n\r\n std::pair<InstructionCost, InstructionCost>\r\n LoopVectorizationCostModel::getDivRemSpeculationCost(Instruction *I,\r\n ElementCount VF) const {\r\n assert(I->getOpcode() == Instruction::UDiv ||\r\n I->getOpcode() == Instruction::SDiv ||\r\n\r\n```"
},
{
"author": "eastB233",
"body": "ping @sdesmalen-arm @davemgreen @paulwalker-arm "
},
{
"author": "fhahn",
"body": "@eastB233 unfortunately I don't think this change is correct, e.g. consider https://github.com/llvm/llvm-project/blob/967eba07549d64f15e7a91e798aa46214704f62b/llvm/test/Transforms/LoopVectorize/X86/divs-with-tail-folding.ll#L251 when the sdiv/udiv is executed conditionally in the loop"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
113143
|
https://github.com/llvm/llvm-project/issues/113143
|
crash
|
42ba452aa94e4da277842d8990ad958a6256e558
| 2024-10-21T10:11:54 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "9e03920cbf946e7ba282e99213707643a23ae5fb",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
12466,
12472
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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 9e03920cbf946e7ba282e99213707643a23ae5fb
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Mon Oct 21 08:57:36 2024 -0700
[SLP]Ignore root gather node, when searching for reuses
Root gather/buildvector node should be ignored when SLP vectorizer tries
to find matching gather nodes, vectorized earlier. This node is
definitely the last one in the pipeline and it does not have users. It
may cause the compiler crash
Fixes #113143
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 1098bf578d2d..a11e3f3815cb 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -12466,7 +12466,7 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
// Build a list of tree entries where V is used.
SmallPtrSet<const TreeEntry *, 4> VToTEs;
for (const TreeEntry *TEPtr : ValueToGatherNodes.find(V)->second) {
- if (TEPtr == TE)
+ if (TEPtr == TE || TEPtr->Idx == 0)
continue;
assert(any_of(TEPtr->Scalars,
[&](Value *V) { return GatheredScalars.contains(V); }) &&
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/root-gather-reused-scalar.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "test",
"test_body": "define void @test(ptr %a, i32 %0, i32 %1, i1 %cmp1) {\nentry:\n %2 = load i32, ptr %a, align 4\n %tobool10.not = icmp eq i32 %0, 0\n %cmp4.3 = icmp ne i32 %1, 0\n %3 = and i1 %cmp4.3, %tobool10.not\n %cmp2.2 = xor i1 %tobool10.not, true\n %conv3.2 = zext i1 %cmp2.2 to i32\n %cmp4.2 = icmp ne i32 %2, %conv3.2\n %cmp2.1 = xor i1 %cmp1, true\n %conv3.1 = zext i1 %cmp2.1 to i32\n %cmp4.1 = icmp ne i32 %2, %conv3.1\n %4 = select i1 %3, i1 %cmp4.2, i1 false\n %5 = select i1 %4, i1 %cmp4.1, i1 false\n %and.3 = zext i1 %5 to i32\n store i32 %and.3, ptr %a, align 4\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "clang crashes on valid code at -O2 on x86_64-linux-gnu: Assertion `TEPtr->UserTreeIndices.size() == 1 && \"Expected only single user of a gather node.\"' failed ",
"body": "It appears to be a recent regression as it doesn't reproduce with 19.1.0 and earlier. \r\n\r\nCompiler Explorer: https://godbolt.org/z/a1W3c5ard\r\n\r\n```\r\n[523] % clangtk -v\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git df8b785838a2db01b4d056e603f7317209accefb)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\r\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nCandidate multilib: .;@m64\r\nSelected multilib: .;@m64\r\n[524] % \r\n[524] % clangtk -O2 small.c\r\nclang-20: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:12559: std::optional<llvm::TargetTransformInfo::ShuffleKind> llvm::slpvectorizer::BoUpSLP::isGatherShuffledSingleRegisterEntry(const llvm::slpvectorizer::BoUpSLP::TreeEntry*, llvm::ArrayRef<llvm::Value*>, llvm::MutableArrayRef<int>, llvm::SmallVectorImpl<const llvm::slpvectorizer::BoUpSLP::TreeEntry*>&, unsigned int, bool): Assertion `TEPtr->UserTreeIndices.size() == 1 && \"Expected only single user of a gather node.\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/20241020-clangtk-m64-O2-build-231331/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20241020-clangtk-m64-O2-build-231331/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/20 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-572b89.o -x c small.c\r\n1.\t<eof> parser at end of file\r\n2.\tOptimizer\r\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"small.c\"\r\n4.\tRunning pass \"slp-vectorizer\" on function \"main\"\r\n #0 0x0000560576c8b9af llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x43f29af)\r\n #1 0x0000560576c89184 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007f4623c27420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #3 0x00007f462365e00b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #4 0x00007f462363d859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\r\n #5 0x00007f462363d729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #6 0x00007f462363d729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #7 0x00007f462364efd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #8 0x0000560578707edc llvm::slpvectorizer::BoUpSLP::isGatherShuffledSingleRegisterEntry(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::MutableArrayRef<int>, llvm::SmallVectorImpl<llvm::slpvectorizer::BoUpSLP::TreeEntry const*>&, unsigned int, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5e6eedc)\r\n #9 0x0000560578708cd8 llvm::slpvectorizer::BoUpSLP::isGatherShuffledEntry(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallVectorImpl<int>&, llvm::SmallVectorImpl<llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, 6u>>&, unsigned int, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5e6fcd8)\r\n#10 0x000056057870a6f3 llvm::InstructionCost llvm::slpvectorizer::BoUpSLP::processBuildVector<llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator, llvm::InstructionCost, llvm::TargetTransformInfo, llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP, llvm::SmallPtrSetImpl<llvm::Value*>>(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::Type*, llvm::TargetTransformInfo&, llvm::ArrayRef<llvm::Value*>&, llvm::slpvectorizer::BoUpSLP&, llvm::SmallPtrSetImpl<llvm::Value*>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5e716f3)\r\n#11 0x000056057870cde7 llvm::slpvectorizer::BoUpSLP::getEntryCost(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallPtrSetImpl<llvm::Value*>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5e73de7)\r\n#12 0x0000560578745f69 llvm::slpvectorizer::BoUpSLP::getTreeCost(llvm::ArrayRef<llvm::Value*>) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5eacf69)\r\n#13 0x000056057874b57b (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&) SLPVectorizer.cpp:0:0\r\n#14 0x000056057874eb79 llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5eb5b79)\r\n#15 0x000056057875349b llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (.constprop.0) SLPVectorizer.cpp:0:0\r\n#16 0x0000560578757d50 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5ebed50)\r\n#17 0x000056057875e590 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\r\n#18 0x000056057875f263 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5ec6263)\r\n#19 0x00005605781e0e66 llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5947e66)\r\n#20 0x0000560576614891 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3d7b891)\r\n#21 0x000056057410e656 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x1875656)\r\n#22 0x00005605766131fd llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3d7a1fd)\r\n#23 0x000056057410d196 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x1874196)\r\n#24 0x0000560576612c31 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3d79c31)\r\n#25 0x0000560576f44dd3 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#26 0x0000560576f483a8 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x46af3a8)\r\n#27 0x000056057764462c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4dab62c)\r\n#28 0x000056057951629c clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x6c7d29c)\r\n#29 0x0000560577644a48 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4daba48)\r\n#30 0x000056057790d3d9 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x50743d9)\r\n#31 0x00005605778895ce clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4ff05ce)\r\n#32 0x00005605779f9f26 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5160f26)\r\n#33 0x0000560573cd1fe5 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x1438fe5)\r\n#34 0x0000560573cc9afa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#35 0x0000560573cce52e clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x143552e)\r\n#36 0x0000560573bba67b main (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x132167b)\r\n#37 0x00007f462363f083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#38 0x0000560573cc958e _start (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x143058e)\r\nclangtk: error: unable to execute command: Aborted\r\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git df8b785838a2db01b4d056e603f7317209accefb)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nclangtk: note: diagnostic msg: \r\n********************\r\n\r\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\r\nPreprocessed source(s) and associated run script(s) are located at:\r\nclangtk: note: diagnostic msg: /tmp/small-d99d4e.c\r\nclangtk: note: diagnostic msg: /tmp/small-d99d4e.sh\r\nclangtk: note: diagnostic msg: \r\n\r\n********************\r\n[525] % \r\n[525] % cat small.c\r\nint a, b, c, d, e, f;\r\nint main() {\r\n for (f = 0; f < 4; f++) {\r\n d &= (((a > 0) != b) != c) && b;\r\n for (b = 0; b < 1; b++)\r\n if (e)\r\n break;\r\n }\r\n return 0;\r\n}\r\n```\r\n\r\n",
"author": "zhendongsu",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
77468
|
https://github.com/llvm/llvm-project/issues/77468
|
crash
|
39b2104b4a4e0990eddc763eab99b28e8deab953
| 2024-01-09T13:19:28 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "59d6f033a25d161e494457e8bb6e30375eb7f40f",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
895,
901
],
[
948,
953
],
[
979,
995
]
],
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 59d6f033a25d161e494457e8bb6e30375eb7f40f
Author: Florian Hahn <flo@fhahn.com>
Date: Fri Jan 12 13:14:13 2024 +0000
[VPlan] Support narrowing widened loads in truncateToMinimimalBitwidths.
MinBWs may also contain widened load instructions, handle them by only
narrowing their result.
Fixes https://github.com/llvm/llvm-project/issues/77468
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 5c430620a2dc..b3694e74a385 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -895,7 +895,10 @@ void VPlanTransforms::truncateToMinimalBitwidths(
vp_depth_first_deep(Plan.getVectorLoopRegion()))) {
for (VPRecipeBase &R : make_early_inc_range(*VPBB)) {
if (!isa<VPWidenRecipe, VPWidenCastRecipe, VPReplicateRecipe,
- VPWidenSelectRecipe>(&R))
+ VPWidenSelectRecipe, VPWidenMemoryInstructionRecipe>(&R))
+ continue;
+ if (isa<VPWidenMemoryInstructionRecipe>(&R) &&
+ cast<VPWidenMemoryInstructionRecipe>(&R)->isStore())
continue;
VPValue *ResultVPV = R.getVPSingleValue();
@@ -948,6 +951,23 @@ void VPlanTransforms::truncateToMinimalBitwidths(
auto *NewResTy = IntegerType::get(Ctx, NewResSizeInBits);
+ // Any wrapping introduced by shrinking this operation shouldn't be
+ // considered undefined behavior. So, we can't unconditionally copy
+ // arithmetic wrapping flags to VPW.
+ if (auto *VPW = dyn_cast<VPRecipeWithIRFlags>(&R))
+ VPW->dropPoisonGeneratingFlags();
+
+ // Extend result to original width.
+ auto *Ext = new VPWidenCastRecipe(Instruction::ZExt, ResultVPV, OldResTy);
+ Ext->insertAfter(&R);
+ ResultVPV->replaceAllUsesWith(Ext);
+ Ext->setOperand(0, ResultVPV);
+
+ if (isa<VPWidenMemoryInstructionRecipe>(&R)) {
+ assert(!cast<VPWidenMemoryInstructionRecipe>(&R)->isStore() && "stores cannot be narrowed");
+ continue;
+ }
+
// Shrink operands by introducing truncates as needed.
unsigned StartIdx = isa<VPWidenSelectRecipe>(&R) ? 1 : 0;
for (unsigned Idx = StartIdx; Idx != R.getNumOperands(); ++Idx) {
@@ -979,17 +999,6 @@ void VPlanTransforms::truncateToMinimalBitwidths(
}
}
- // Any wrapping introduced by shrinking this operation shouldn't be
- // considered undefined behavior. So, we can't unconditionally copy
- // arithmetic wrapping flags to VPW.
- if (auto *VPW = dyn_cast<VPRecipeWithIRFlags>(&R))
- VPW->dropPoisonGeneratingFlags();
-
- // Extend result to original width.
- auto *Ext = new VPWidenCastRecipe(Instruction::ZExt, ResultVPV, OldResTy);
- Ext->insertAfter(&R);
- ResultVPV->replaceAllUsesWith(Ext);
- Ext->setOperand(0, ResultVPV);
}
}
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/trunc-loads-p16.ll",
"commands": [
"opt -p loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -S %s"
],
"tests": [
{
"test_name": "pr77468",
"test_body": "target datalayout = \"p:16:16\"\n\ndefine void @pr77468(ptr noalias %src, ptr noalias %dst, i1 %x) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i16 [ 0, %entry ], [ %iv.next, %loop ]\n %gep.src = getelementptr i32, ptr %src, i16 %iv\n %l = load i32, ptr %gep.src, align 1\n %x.ext = zext i1 %x to i32\n %and = and i32 %x.ext, %l\n %gep.dst = getelementptr i16, ptr %dst, i16 %iv\n %t = trunc i32 %and to i16\n store i16 %t, ptr %gep.dst, align 2\n %iv.next = add i16 %iv, 1\n %exitcond.not = icmp eq i16 %iv.next, 100\n br i1 %exitcond.not, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Assertion `MinBWs.size() == NumProcessedRecipes && \"some entries in MinBWs haven't been processed\"' failed. for opt -passes=loop-vectorize",
"body": "llvm commit: c1ed45a271145\r\nReproduce with: ```opt -passes=\"loop-vectorize\" bbi-90681_2.ll -S -o /dev/null -mtriple=x86_64```\r\nResult:\r\n```\r\nopt: ../lib/Transforms/Vectorize/VPlanTransforms.cpp:997: static void llvm::VPlanTransforms::truncateToMinimalBitwidths(llvm::VPlan &, const MapVector<llvm::Instruction *, uint64_t> &, llvm::LLVMContext &): Assertion `MinBWs.size() == NumProcessedRecipes && \"some entries in MinBWs haven't been processed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: ../../main-github/llvm/build-all/bin/opt -passes=loop-vectorize bbi-90681_2.ll -S -o /dev/null -mtriple=x86_64\r\n #0 0x0000563bdd2b15d7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (../../main-github/llvm/build-all/bin/opt+0x63c95d7)\r\n #1 0x0000563bdd2af12e llvm::sys::RunSignalHandlers() (../../main-github/llvm/build-all/bin/opt+0x63c712e)\r\n #2 0x0000563bdd2b1c9f SignalHandler(int) (../../main-github/llvm/build-all/bin/opt+0x63c9c9f)\r\n #3 0x00007f87a7de7630 __restore_rt (/lib64/libpthread.so.0+0xf630)\r\n #4 0x00007f87a552e387 raise (/lib64/libc.so.6+0x36387)\r\n #5 0x00007f87a552fa78 abort (/lib64/libc.so.6+0x37a78)\r\n #6 0x00007f87a55271a6 __assert_fail_base (/lib64/libc.so.6+0x2f1a6)\r\n #7 0x00007f87a5527252 (/lib64/libc.so.6+0x2f252)\r\n #8 0x0000563bdd584d86 (../../main-github/llvm/build-all/bin/opt+0x669cd86)\r\n #9 0x0000563bdd50f875 llvm::LoopVectorizationPlanner::buildVPlansWithVPRecipes(llvm::ElementCount, llvm::ElementCount) (../../main-github/llvm/build-all/bin/opt+0x6627875)\r\n#10 0x0000563bdd50eeec llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (../../main-github/llvm/build-all/bin/opt+0x6626eec)\r\n#11 0x0000563bdd522bc9 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (../../main-github/llvm/build-all/bin/opt+0x663abc9)\r\n#12 0x0000563bdd5289b3 llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (../../main-github/llvm/build-all/bin/opt+0x66409b3)\r\n#13 0x0000563bdd529318 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x6641318)\r\n#14 0x0000563bdd4cafad llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x65e2fad)\r\n#15 0x0000563bdcce36d4 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x5dfb6d4)\r\n#16 0x0000563bdb09c87d llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x41b487d)\r\n#17 0x0000563bdcce7abe llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x5dffabe)\r\n#18 0x0000563bdb09c61d llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x41b461d)\r\n#19 0x0000563bdcce27f6 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x5dfa7f6)\r\n#20 0x0000563bdabb7143 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (../../main-github/llvm/build-all/bin/opt+0x3ccf143)\r\n#21 0x0000563bdabc5844 main (../../main-github/llvm/build-all/bin/opt+0x3cdd844)\r\n#22 0x00007f87a551a555 __libc_start_main (/lib64/libc.so.6+0x22555)\r\n#23 0x0000563bdabb12e9 _start (../../main-github/llvm/build-all/bin/opt+0x3cc92e9)\r\nAbort (core dumped)\r\n```\r\n[bbi-90681_2.ll.gz](https://github.com/llvm/llvm-project/files/13874170/bbi-90681_2.ll.gz)\r\n",
"author": "mikaelholmen",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "mikaelholmen",
"body": "This starts happening with 70535f5e609f747c28\r\n```\r\n[VPlan] Replace IR based truncateToMinimalBitwidths with VPlan version.\r\n```\r\nPing @fhahn \r\n"
},
{
"author": "mikaelholmen",
"body": "Thanks!"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
124759
|
https://github.com/llvm/llvm-project/issues/124759
|
crash
|
b923f6cf8faca82b8df2a936d8ff36a6125aedcc
| 2025-01-28T14:48:43 |
[
"llvm/test/Analysis/LoopAccessAnalysis"
] |
{
"fix_commit": "275baedfde9dcd344bc4f11f552b046a69a4bf3f",
"components": [
"LoopAccessAnalysis"
],
"bug_location_lineno": {
"llvm/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": [
[
1362,
1369
],
[
1443,
1450
]
],
"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": [
"AccessAnalysis::processMemAccesses"
],
"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 275baedfde9dcd344bc4f11f552b046a69a4bf3f
Author: Florian Hahn <flo@fhahn.com>
Date: Fri Feb 28 20:56:12 2025 +0000
[LAA] Consider accessed addrspace when mapping underlying obj to access. (#129087)
In some cases, it is possible for the same underlying object to be
accessed via pointers to different address spaces. This could lead to
pointers from different address spaces ending up in the same dependency
set, which isn't allowed (and triggers an assertion).
Update the mapping from underlying object -> last access to also include
the accessing address space.
Fixes https://github.com/llvm/llvm-project/issues/124759.
PR: https://github.com/llvm/llvm-project/pull/129087
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index cf3bb6a8eae1..38ee82b77a94 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -1362,8 +1362,10 @@ void AccessAnalysis::processMemAccesses() {
bool SetHasWrite = false;
- // Map of pointers to last access encountered.
- typedef DenseMap<const Value*, MemAccessInfo> UnderlyingObjToAccessMap;
+ // Map of (pointer to underlying objects, accessed address space) to last
+ // access encountered.
+ typedef DenseMap<std::pair<const Value *, unsigned>, MemAccessInfo>
+ UnderlyingObjToAccessMap;
UnderlyingObjToAccessMap ObjToLastAccess;
// Set of access to check after all writes have been processed.
@@ -1443,8 +1445,10 @@ void AccessAnalysis::processMemAccesses() {
UnderlyingObj->getType()->getPointerAddressSpace()))
continue;
- auto [It, Inserted] =
- ObjToLastAccess.try_emplace(UnderlyingObj, Access);
+ auto [It, Inserted] = ObjToLastAccess.try_emplace(
+ {UnderlyingObj,
+ cast<PointerType>(Ptr->getType())->getAddressSpace()},
+ Access);
if (!Inserted) {
DepCands.unionSets(Access, It->second);
It->second = Access;
|
[
{
"file": "llvm/test/Analysis/LoopAccessAnalysis/underlying-object-different-address-spaces.ll",
"commands": [
"opt -passes='print<access-info>' -disable-output %s 2>&1"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\n; Test case for https://github.com/llvm/llvm-project/issues/124759. The same\n; underlying object is access through pointers with different address spaces.\ndefine void @same_underlying_object_different_address_spaces(ptr %dst1.as1, ptr %dst2.as1) {\n;\nentry:\n %alloc = alloca i8, i64 0, align 128\n %as3 = addrspacecast ptr %alloc to ptr addrspace(3)\n %as4 = addrspacecast ptr %alloc to ptr addrspace(4)\n br label %loop\n\nloop:\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n store i32 0, ptr addrspace(4) %as4, align 4\n store i32 0, ptr %dst1.as1, align 4\n %l = load i64, ptr addrspace(3) %as3, align 4\n store i64 %l, ptr %dst2.as1, align 4\n %iv.next = add i64 %iv, 1\n %c = icmp eq i64 %iv.next, 100\n br i1 %c, label %loop, label %exit\n\nexit:\n ret void\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "LoopVectorizer `assert(AddressSpace == AS && with addrspacecast` is hit",
"body": "The following code produces an assert in RuntimeCheckingPtrGroup::addPointer()\n\n\n``` llvm\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-unknown-elf\"\n\ndefine void @__mux_host_0(ptr addrspace(1) %_arg_resultPtr, ptr addrspace(1) %add.ptr.i.sroa_idx.i.i.i.i) {\nloopIR.i.preheader:\n %0 = alloca i8, i64 0, align 128\n %_arg_localAccessor = addrspacecast ptr %0 to ptr addrspace(3)\n %arrayidx.ascast.i.i.i.i.i.i = addrspacecast ptr %0 to ptr addrspace(4)\n br label %loopIR2.i\n\nloopIR2.i: ; preds = %loopIR2.i, %loopIR.i.preheader\n %1 = phi i64 [ 0, %loopIR.i.preheader ], [ %3, %loopIR2.i ]\n store i32 0, ptr addrspace(4) %arrayidx.ascast.i.i.i.i.i.i, align 4\n store float 0.000000e+00, ptr addrspace(1) %add.ptr.i.sroa_idx.i.i.i.i, align 4\n %2 = load i64, ptr addrspace(3) %_arg_localAccessor, align 4\n store i64 0, ptr addrspace(1) %_arg_resultPtr, align 4\n %3 = add i64 %1, 1\n br i1 false, label %loopIR2.i, label %exitIR.i\n\nexitIR.i: ; preds = %loopIR2.i\n ret void\n}\n```\n\nThis crashes with `opt --passes loop-vectorize /tmp/reduced.ll -S -o -` as follows:\n\n```\n./bin/opt --passes loop-vectorize /tmp/reduced.ll -S -o -\nopt: /home/colin/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp:423: bool llvm::RuntimeCheckingPtrGroup::addPointer(unsigned int, const llvm::SCEV*, const llvm::SCEV*, unsigned int, bool, llvm::ScalarEvolution&): Assertion `AddressSpace == AS && \"all pointers in a checking group must be in the same address space\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0. Program arguments: ./bin/opt --passes loop-vectorize /tmp/reduced.ll -S -o -\n1. Running pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"/tmp/reduced.ll\"\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"__mux_host_0\"\n #0 0x00005a58a99c2ddc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/colin/llvm-project/llvm/lib/Support/Unix/Signals.inc:798:22\n #1 0x00005a58a99c31fd PrintStackTraceSignalHandler(void*) /home/colin/llvm-project/llvm/lib/Support/Unix/Signals.inc:874:1\n #2 0x00005a58a99c0663 llvm::sys::RunSignalHandlers() /home/colin/llvm-project/llvm/lib/Support/Signals.cpp:105:20\n #3 0x00005a58a99c2674 SignalHandler(int) /home/colin/llvm-project/llvm/lib/Support/Unix/Signals.inc:415:1\n #4 0x00007c96b3242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #5 0x00007c96b32969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #6 0x00007c96b32969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #7 0x00007c96b32969fc pthread_kill ./nptl/pthread_kill.c:89:10\n #8 0x00007c96b3242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\n #9 0x00007c96b32287f3 abort ./stdlib/abort.c:81:7\n#10 0x00007c96b322871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\n#11 0x00007c96b3239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n#12 0x00005a58a8936a8b llvm::RuntimeCheckingPtrGroup::addPointer(unsigned int, llvm::SCEV const*, llvm::SCEV const*, unsigned int, bool, llvm::ScalarEvolution&) /home/colin/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp:429:37\n#13 0x00005a58a8936a20 llvm::RuntimeCheckingPtrGroup::addPointer(unsigned int, llvm::RuntimePointerChecking const&) /home/colin/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp:413:20\n#14 0x00005a58a8936f8d llvm::RuntimePointerChecking::groupChecks(llvm::EquivalenceClasses<llvm::PointerIntPair<llvm::Value*, 1u, bool, llvm::PointerLikeTypeTraits<llvm::Value*>, llvm::PointerIntPairInfo<llvm::Value*, 1u, llvm::PointerLikeTypeTraits<llvm::Value*>>>, std::less<llvm::PointerIntPair<llvm::Value*, 1u, bool, llvm::PointerLikeTypeTraits<llvm::Value*>, llvm::PointerIntPairInfo<llvm::Value*, 1u, llvm::PointerLikeTypeTraits<llvm::Value*>>>>>&, bool) /home/colin/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp:554:11\n#15 0x00005a58a893678d llvm::RuntimePointerChecking::generateChecks(llvm::EquivalenceClasses<llvm::PointerIntPair<llvm::Value*, 1u, bool, llvm::PointerLikeTypeTraits<llvm::Value*>, llvm::PointerIntPairInfo<llvm::Value*, 1u, llvm::PointerLikeTypeTraits<llvm::Value*>>>, std::less<llvm::PointerIntPair<llvm::Value*, 1u, bool, llvm::PointerLikeTypeTraits<llvm::Value*>, llvm::PointerIntPairInfo<llvm::Value*, 1u, llvm::PointerLikeTypeTraits<llvm::Value*>>>>>&, bool) /home/colin/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp:389:26\n#16 0x00005a58a893a016 (anonymous namespace)::AccessAnalysis::canCheckPtrAtRT(llvm::RuntimePointerChecking&, llvm::ScalarEvolution*, llvm::Loop*, llvm::DenseMap<llvm::Value*, llvm::SCEV const*, llvm::DenseMapInfo<llvm::Value*, void>, llvm::detail::DenseMapPair<llvm::Value*, llvm::SCEV const*>> const&, llvm::Value*&, bool) /home/colin/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp:1243:3\n#17 0x00005a58a8940750 llvm::LoopAccessInfo::analyzeLoop(llvm::AAResults*, llvm::LoopInfo const*, llvm::TargetLibraryInfo const*, llvm::DominatorTree*) /home/colin/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp:2638:31\n#18 0x00005a58a89422b3 llvm::LoopAccessInfo::LoopAccessInfo(llvm::Loop*, llvm::ScalarEvolution*, llvm::TargetTransformInfo const*, llvm::TargetLibraryInfo const*, llvm::AAResults*, llvm::DominatorTree*, llvm::LoopInfo*) /home/colin/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp:3028:15\n#19 0x00005a58a894ae40 std::_MakeUniq<llvm::LoopAccessInfo>::__single_object std::make_unique<llvm::LoopAccessInfo, llvm::Loop*, llvm::ScalarEvolution*, llvm::TargetTransformInfo*&, llvm::TargetLibraryInfo const*&, llvm::AAResults*, llvm::DominatorTree*, llvm::LoopInfo*>(llvm::Loop*&&, llvm::ScalarEvolution*&&, llvm::TargetTransformInfo*&, llvm::TargetLibraryInfo const*&, llvm::AAResults*&&, llvm::DominatorTree*&&, llvm::LoopInfo*&&) /usr/include/c++/11/bits/unique_ptr.h:962:30\n#20 0x00005a58a8942883 llvm::LoopAccessInfoManager::getInfo(llvm::Loop&) /home/colin/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp:3084:41\n#21 0x00005a58a831900e llvm::LoopVectorizationLegality::canVectorizeMemory() /home/colin/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp:1208:7\n#22 0x00005a58a831bc45 llvm::LoopVectorizationLegality::canVectorize(bool) /home/colin/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp:1840:7\n#23 0x00005a58a800b8b5 llvm::LoopVectorizePass::processLoop(llvm::Loop*) /home/colin/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10349:7\n#24 0x00005a58a800dde6 llvm::LoopVectorizePass::runImpl(llvm::Function&) /home/colin/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10779:27\n#25 0x00005a58a800e133 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/colin/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10816:39\n#26 0x00005a58a65ef71b llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/colin/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:92:3\n#27 0x00005a58a96e6133 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/colin/llvm-project/llvm/include/llvm/IR/PassManagerImpl.h:85:18\n#28 0x00005a58a4a21a65 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/colin/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:92:3\n#29 0x00005a58a96e513e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /home/colin/llvm-project/llvm/lib/IR/PassManager.cpp:129:23\n#30 0x00005a58a4a21995 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /home/colin/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:92:3\n#31 0x00005a58a96e5d5f llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /home/colin/llvm-project/llvm/include/llvm/IR/PassManagerImpl.h:85:18\n#32 0x00005a58a476e632 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) /home/colin/llvm-project/llvm/tools/opt/NewPMDriver.cpp:541:10\n#33 0x00005a58a473c69f optMain /home/colin/llvm-project/llvm/tools/opt/optdriver.cpp:739:27\n#34 0x00005a58a4739e81 main /home/colin/llvm-project/llvm/tools/opt/opt.cpp:25:64\n#35 0x00007c96b3229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\n#36 0x00007c96b3229e40 call_init ./csu/../csu/libc-start.c:128:20\n#37 0x00007c96b3229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\n#38 0x00005a58a4739d65 _start (./bin/opt+0xb93d65)\n```\n\nI've done some debugging and in `RuntimeCheckingPtrGroup::addPointer()` II can see the first two elements if RTCheck have the same dependency set but different address spaces.\n\nI did try removing the dependency set being equal continuing the loop here https://github.com/llvm/llvm-project/blob/main/llvm/lib/Analysis/LoopAccessAnalysis.cpp#L1219\n\n``` cpp\n // Only need to check pointers between two different dependency sets.\n if (RtCheck.Pointers[i].DependencySetId ==\n RtCheck.Pointers[j].DependencySetId)\n continue;\n```\nThis does seem to fix the issue but I was wary on whether this was just another symptom rather than the proper fix.\n",
"author": "coldav",
"labels": [
"release:backport",
"release:cherry-pick-failed",
"crash",
"llvm:analysis"
],
"comments": [
{
"author": "coldav",
"body": "Since nobody is looking at this, and it shows up as an assert for this, I'll try upstreaming my fix."
},
{
"author": "fhahn",
"body": "@coldav sorry I missed this one. I think skipping the check you mentioned is probably not the right fix. I am looking into avoiding grouping pointers with different address spaces in the same dependency set.\n\nI am not super familiar with address space semantics, I am not sure if it is valid to access the same object with pointers to different address spaces?"
},
{
"author": "hvdijk",
"body": "> I am not super familiar with address space semantics, I am not sure if it is valid to access the same object with pointers to different address spaces?\n\nIt depends on the address spaces. Address spaces may or may not overlap. If they do not overlap, then LLVM can assume that an object accessed from one address space and an object accessed from another do not alias. If the address spaces do overlap, however, that assumption is not valid. For the X86 target, address spaces 1-255 are reserved for user-defined code (https://llvm.org/docs/CodeGenerator.html#x86-address-spaces-supported) and interpreted for codegen purposes as aliases for address space zero, meaning all these address spaces overlap exactly."
},
{
"author": "fhahn",
"body": "Put up https://github.com/llvm/llvm-project/pull/129087 to avoid adding pointers from different addrspaces in the same dependency set"
},
{
"author": "coldav",
"body": "Thanks @fhahn "
},
{
"author": "fhahn",
"body": "Manual PR to pick https://github.com/llvm/llvm-project/pull/129317"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
101337
|
https://github.com/llvm/llvm-project/issues/101337
|
crash
|
1b936e4812ab395328203f65cacd4ffe02bb318e
| 2024-07-31T14:11:24 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "cd08fadd03904806fa26a1f117879ddae34fbf67",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
7080,
7086
]
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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::cost"
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit cd08fadd03904806fa26a1f117879ddae34fbf67
Author: Florian Hahn <flo@fhahn.com>
Date: Mon Aug 12 14:45:43 2024 +0100
[LV] Include chains feeding inductions in cost precomputation.
Include chain of ops feeding inductions in cost precomputation for
inductions, not just the induction increment. In VPlan, those
instructions will be cleaned up, as both phi and increment are generated
by VPWidenIntOrFpInductionRecipe independently.
Fixes https://github.com/llvm/llvm-project/issues/101337.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 542d74ef0e1e..41e4b0fcd9b0 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7080,7 +7080,16 @@ InstructionCost LoopVectorizationPlanner::cost(VPlan &Plan,
for (const auto &[IV, IndDesc] : Legal->getInductionVars()) {
Instruction *IVInc = cast<Instruction>(
IV->getIncomingValueForBlock(OrigLoop->getLoopLatch()));
- SmallVector<Instruction *> IVInsts = {IV, IVInc};
+ SmallVector<Instruction *> IVInsts = {IVInc};
+ for (unsigned I = 0; I != IVInsts.size(); I++) {
+ for (Value *Op : IVInsts[I]->operands()) {
+ auto *OpI = dyn_cast<Instruction>(Op);
+ if (Op == IV || !OpI || !OrigLoop->contains(OpI) || !Op->hasOneUse())
+ continue;
+ IVInsts.push_back(OpI);
+ }
+ }
+ IVInsts.push_back(IV);
for (User *U : IV->users()) {
auto *CI = cast<Instruction>(U);
if (!CostCtx.CM.isOptimizableIVTruncate(CI, VF))
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/X86/induction-costs.ll",
"commands": [
"opt -p loop-vectorize -mtriple=x86_64-apple-macosx -S %s"
],
"tests": [
{
"test_name": "iv_and_step_trunc",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine i16 @iv_and_step_trunc() {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %rec = phi i16 [ 0, %entry ], [ %rec.next, %loop ]\n %iv.next = add i64 %iv, 1\n %0 = trunc i64 %iv to i16\n %1 = trunc i64 %iv.next to i16\n %rec.next = mul i16 %0, %1\n %ec = icmp eq i64 %iv, 1\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i16 %rec\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "wombat2",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine void @wombat2(i32 %arg, ptr %dst) #0 {\nentry:\n %mul = mul i32 %arg, 3\n %zext = zext i32 %arg to i64\n br label %loop\n\nloop: ; preds = %loop, %entry\n %phi = phi i64 [ 4, %entry ], [ %add, %loop ]\n %phi2 = phi i32 [ %mul, %entry ], [ %trunc.1, %loop ]\n %getelementptr = getelementptr i32, ptr %dst, i64 %phi\n %and = and i32 %phi2, 12\n store i32 %and, ptr %getelementptr, align 4\n %mul3 = mul i64 %phi, %zext\n %add = add i64 %phi, 1\n %icmp = icmp ugt i64 %phi, 65\n %trunc.0 = trunc i64 %mul3 to i60\n %trunc.1 = trunc i60 %trunc.0 to i32\n br i1 %icmp, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { \"target-cpu\"=\"skylake-avx512\" \"target-features\"=\"-avx512f\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "with_dead_use",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine void @with_dead_use(i32 %arg, ptr %dst) #0 {\nentry:\n %mul = mul i32 %arg, 3\n %zext = zext i32 %arg to i64\n br label %loop\n\nloop: ; preds = %loop, %entry\n %phi = phi i64 [ 4, %entry ], [ %add, %loop ]\n %phi2 = phi i32 [ %mul, %entry ], [ %trunc, %loop ]\n %getelementptr = getelementptr i32, ptr %dst, i64 %phi\n %and = and i32 %phi2, 12\n store i32 %and, ptr %getelementptr, align 4\n %mul3 = mul i64 %phi, %zext\n %add = add i64 %phi, 1\n %icmp = icmp ugt i64 %phi, 65\n %trunc = trunc i64 %mul3 to i32\n %dead.and = and i32 %trunc, 123\n br i1 %icmp, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { \"target-cpu\"=\"skylake-avx512\" \"target-features\"=\"-avx512f\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_scalar_predicated_cost",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine i32 @test_scalar_predicated_cost(i64 %x, i64 %y, ptr %A) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %cmp9.not = icmp ule i64 %iv, %y\n br i1 %cmp9.not, label %loop.latch, label %if.then\n\nif.then: ; preds = %loop.header\n %or = or i64 %x, %iv\n %gep = getelementptr i32, ptr %A, i64 %iv\n %t = trunc i64 %or to i32\n store i32 %t, ptr %gep, align 4\n br label %loop.latch\n\nloop.latch: ; preds = %if.then, %loop.header\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv, 100\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret i32 0\n}\n\nattributes #0 = { \"min-legal-vector-width\"=\"0\" \"target-cpu\"=\"skylake-avx512\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "truncated_ivs_with_wide_and_scalar_uses",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine void @truncated_ivs_with_wide_and_scalar_uses(i1 %c, ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.16 = trunc i64 %iv to i16\n %iv.32 = trunc i64 %iv to i32\n %gep = getelementptr i16, ptr %dst, i32 %iv.32\n %sel = select i1 %c, i16 %iv.16, i16 10\n store i16 %sel, ptr %gep, align 2\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv, 64\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "multiple_truncated_ivs_with_wide_uses",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine void @multiple_truncated_ivs_with_wide_uses(i1 %c, ptr %A, ptr %B) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.16 = trunc i64 %iv to i16\n %iv.32 = trunc i64 %iv to i32\n %sel = select i1 %c, i16 %iv.16, i16 10\n %gep.A = getelementptr i16, ptr %A, i64 %iv\n store i16 %sel, ptr %gep.A, align 2\n %gep.B = getelementptr i32, ptr %B, i64 %iv\n store i32 %iv.32, ptr %gep.B, align 4\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv, 64\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "wide_iv_trunc_reuse",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine void @wide_iv_trunc_reuse(ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 1, %entry ], [ %iv.next, %loop ]\n %iv.2 = phi i32 [ 0, %entry ], [ %iv.trunc, %loop ]\n store i32 %iv.2, ptr %dst, align 4\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv, 0\n %iv.trunc = trunc i64 %iv to i32\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "iv_used_widened_and_truncated",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine i32 @iv_used_widened_and_truncated(ptr %dst, i64 %N) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep = getelementptr { i32, [8 x i32] }, ptr %dst, i64 %iv\n %t = trunc i64 %iv to i32\n store i32 %t, ptr %gep, align 8\n %iv.next = add i64 %iv, 1\n %c = icmp eq i64 %iv, %N\n br i1 %c, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i32 0\n}\n\nattributes #0 = { \"min-legal-vector-width\"=\"0\" \"target-cpu\"=\"skylake-avx512\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "wombat",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine void @wombat(i32 %arg, ptr %dst) #0 {\nentry:\n %mul = mul i32 %arg, 3\n %zext = zext i32 %arg to i64\n br label %loop\n\nloop: ; preds = %loop, %entry\n %phi = phi i64 [ 4, %entry ], [ %add, %loop ]\n %phi2 = phi i32 [ %mul, %entry ], [ %trunc, %loop ]\n %getelementptr = getelementptr i32, ptr %dst, i64 %phi\n %and = and i32 %phi2, 12\n store i32 %and, ptr %getelementptr, align 4\n %mul3 = mul i64 %phi, %zext\n %add = add i64 %phi, 1\n %icmp = icmp ugt i64 %phi, 65\n %trunc = trunc i64 %mul3 to i32\n br i1 %icmp, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { \"target-cpu\"=\"skylake-avx512\" \"target-features\"=\"-avx512f\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "wide_iv_trunc",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine void @wide_iv_trunc(ptr %dst, i64 %N) {\nentry:\n %cmp = icmp ult i64 %N, 8\n br i1 %cmp, label %loop, label %exit\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.trunc = trunc i64 %iv to i32\n store i32 %iv.trunc, ptr %dst, align 4\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv, %N\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop, %entry\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "multiple_pointer_ivs_with_scalar_uses_only",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine void @multiple_pointer_ivs_with_scalar_uses_only(ptr %A, ptr %B) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv.1 = phi i32 [ 100, %entry ], [ %dec, %loop ]\n %iv.2 = phi i32 [ 2048, %entry ], [ %add38, %loop ]\n %ptr.iv.1 = phi ptr [ %A, %entry ], [ %outptr.0, %loop ]\n %ptr.iv.2 = phi ptr [ %B, %entry ], [ %incdec.ptr36, %loop ]\n %ptr.iv.3 = phi ptr [ %B, %entry ], [ %incdec.ptr33, %loop ]\n %incdec.ptr33 = getelementptr i8, ptr %ptr.iv.3, i64 1\n %0 = load i8, ptr %ptr.iv.3, align 1\n %conv34 = zext i8 %0 to i32\n %incdec.ptr36 = getelementptr i8, ptr %ptr.iv.2, i64 1\n %1 = load i8, ptr %ptr.iv.2, align 1\n %conv37 = zext i8 %1 to i32\n %add38 = add i32 %conv34, %conv37\n %shr42 = lshr i32 %iv.2, 1\n %conv43 = trunc i32 %shr42 to i8\n store i8 %conv43, ptr %ptr.iv.1, align 1\n %dec = add i32 %iv.1, 1\n %outptr.0 = getelementptr i8, ptr %ptr.iv.1, i64 2\n %cmp30.not = icmp eq i32 %dec, 0\n br i1 %cmp30.not, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { \"min-legal-vector-width\"=\"0\" \"target-cpu\"=\"skylake-avx512\" }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Assertion `VF.Width == BestVF && \"VPlan cost model and legacy cost model disagreed\"' failed.",
"body": "To reproduce run opt with \r\n```\r\n-passes=loop-vectorize --mcpu=skylake-avx512 --mattr=+prfchw,-cldemote,+avx,+aes,+sahf,+pclmul,-xop,+crc32,+xsaves,-avx512fp16,-usermsr,-sm4,-egpr,+sse4.1,-avx512ifma,+xsave,+sse4.2,-tsxldtrk,-sm3,-ptwrite,-widekl,+invpcid,+64bit,+xsavec,-avx10.1-512,-avx512vpopcntdq,+cmov,-avx512vp2intersect,+avx512cd,+movbe,-avxvnniint8,-ccmp,-amx-int8,-kl,-avx10.1-256,+evex512,-avxvnni,+rtm,+adx,+avx2,-hreset,-movdiri,-serialize,-sha512,-vpclmulqdq,+avx512vl,-uintr,-cf,+clflushopt,-raoint,-cmpccxadd,+bmi,-amx-tile,+sse,-gfni,-avxvnniint16,-amx-fp16,-zu,-ndd,+xsaveopt,+rdrnd,+avx512f,-amx-bf16,-avx512bf16,-avx512vnni,-push2pop2,+cx8,+avx512bw,+sse3,+pku,-nf,+fsgsbase,-clzero,-mwaitx,-lwp,+lzcnt,-sha,-movdir64b,-ppx,-wbnoinvd,-enqcmd,-avxneconvert,-tbm,-pconfig,-amx-complex,+ssse3,+cx16,+bmi2,+fma,+popcnt,-avxifma,+f16c,-avx512bitalg,-rdpru,+clwb,+mmx,+sse2,+rdseed,-avx512vbmi2,-prefetchi,-rdpid,-fma4,-avx512vbmi,-shstk,-vaes,-waitpkg,-sgx,+fxsr,+avx512dq,-sse4a,-avx512f\r\n```\r\nwith the following test:\r\n```\r\n; ModuleID = './reduced.ll'\r\nsource_filename = \"./reduced.ll\"\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine void @wombat(i32 %arg) #0 gc \"statepoint-example\" {\r\nbb:\r\n %mul = mul i32 %arg, 3\r\n %zext = zext i32 %arg to i64\r\n br label %bb1\r\n\r\nbb1: ; preds = %bb1, %bb\r\n %phi = phi i64 [ %add, %bb1 ], [ 4, %bb ]\r\n %phi2 = phi i32 [ %trunc, %bb1 ], [ %mul, %bb ]\r\n %getelementptr = getelementptr i32, ptr addrspace(1) null, i64 %phi\r\n %and = and i32 %phi2, 0\r\n store i32 0, ptr addrspace(1) %getelementptr, align 4\r\n %mul3 = mul i64 %phi, %zext\r\n %add = add i64 %phi, 1\r\n %icmp = icmp ugt i64 %phi, 65\r\n %trunc = trunc i64 %mul3 to i32\r\n br i1 %icmp, label %bb4, label %bb1\r\n\r\nbb4: ; preds = %bb1\r\n ret void\r\n}\r\n```\r\nReproducer: https://godbolt.org/z/nPsP7h51n\r\n\r\nStack dump:\r\n```\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=loop-vectorize --mcpu=skylake-avx512 --mattr=+prfchw,-cldemote,+avx,+aes,+sahf,+pclmul,-xop,+crc32,+xsaves,-avx512fp16,-usermsr,-sm4,-egpr,+sse4.1,-avx512ifma,+xsave,+sse4.2,-tsxldtrk,-sm3,-ptwrite,-widekl,+invpcid,+64bit,+xsavec,-avx10.1-512,-avx512vpopcntdq,+cmov,-avx512vp2intersect,+avx512cd,+movbe,-avxvnniint8,-ccmp,-amx-int8,-kl,-avx10.1-256,+evex512,-avxvnni,+rtm,+adx,+avx2,-hreset,-movdiri,-serialize,-sha512,-vpclmulqdq,+avx512vl,-uintr,-cf,+clflushopt,-raoint,-cmpccxadd,+bmi,-amx-tile,+sse,-gfni,-avxvnniint16,-amx-fp16,-zu,-ndd,+xsaveopt,+rdrnd,+avx512f,-amx-bf16,-avx512bf16,-avx512vnni,-push2pop2,+cx8,+avx512bw,+sse3,+pku,-nf,+fsgsbase,-clzero,-mwaitx,-lwp,+lzcnt,-sha,-movdir64b,-ppx,-wbnoinvd,-enqcmd,-avxneconvert,-tbm,-pconfig,-amx-complex,+ssse3,+cx16,+bmi2,+fma,+popcnt,-avxifma,+f16c,-avx512bitalg,-rdpru,+clwb,+mmx,+sse2,+rdseed,-avx512vbmi2,-prefetchi,-rdpid,-fma4,-avx512vbmi,-shstk,-vaes,-waitpkg,-sgx,+fxsr,+avx512dq,-sse4a,-avx512f <source>\r\n1.\tRunning pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"<source>\"\r\n2.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"wombat\"\r\n #0 0x0000000004f053c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f053c8)\r\n #1 0x0000000004f02b3c SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007458cc042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x00007458cc0969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x00007458cc042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x00007458cc0287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00007458cc02871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x00007458cc039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x0000000003f83f37 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3f83f37)\r\n #9 0x0000000003f86659 llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3f86659)\r\n#10 0x0000000003f86cd2 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3f86cd2)\r\n#11 0x0000000002e596ce llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2e596ce)\r\n#12 0x0000000004d02758 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d02758)\r\n#13 0x0000000000de089e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xde089e)\r\n#14 0x0000000004d0114e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d0114e)\r\n#15 0x0000000000de0eee llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xde0eee)\r\n#16 0x0000000004cff2b0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4cff2b0)\r\n#17 0x00000000008e3752 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8e3752)\r\n#18 0x00000000008d667c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8d667c)\r\n#19 0x00007458cc029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#20 0x00007458cc029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#21 0x00000000008cdade _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8cdade)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```",
"author": "TatyanaDoubts",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "patrick-rivos",
"body": "Potentially related: https://github.com/llvm/llvm-project/issues/100591"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
126181
|
https://github.com/llvm/llvm-project/issues/126181
|
miscompilation
|
317a644ae6d501f1a1ec54d17ea8559bcdea35c0
| 2025-02-07T05:51:32 |
[
"llvm/test/Transforms/DeadStoreElimination"
] |
{
"fix_commit": "2d31a12dbe2339d20844ede70cbb54dbaf4ceea9",
"components": [
"DeadStoreElimination"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": [
[
2283,
2289
]
],
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": null,
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": [
"DSEState::getInitializesArgMemLoc"
],
"llvm/lib/Analysis/InstructionSimplify.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 2d31a12dbe2339d20844ede70cbb54dbaf4ceea9
Author: Nikita Popov <npopov@redhat.com>
Date: Mon Feb 10 10:34:03 2025 +0100
[DSE] Don't use initializes on byval argument (#126259)
There are two ways we can fix this problem, depending on how the
semantics of byval and initializes should interact:
* Don't infer initializes on byval arguments. initializes on byval
refers to the original caller memory (or having both attributes is made
a verifier error).
* Infer initializes on byval, but don't use it in DSE. initializes on
byval refers to the callee copy. This matches the semantics of readonly
on byval. This is slightly more powerful, for example, we could do a
backend optimization where byval + initializes will allocate the full
size of byval on the stack but not copy over the parts covered by
initializes.
I went with the second variant here, skipping byval + initializes in DSE
(FunctionAttrs already doesn't propagate initializes past byval). I'm
open to going in the other direction though.
Fixes https://github.com/llvm/llvm-project/issues/126181.
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 05b4f176bfc3..38454053b039 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -2283,7 +2283,9 @@ DSEState::getInitializesArgMemLoc(const Instruction *I) {
for (unsigned Idx = 0, Count = CB->arg_size(); Idx < Count; ++Idx) {
ConstantRangeList Inits;
Attribute InitializesAttr = CB->getParamAttr(Idx, Attribute::Initializes);
- if (InitializesAttr.isValid())
+ // initializes on byval arguments refers to the callee copy, not the
+ // original memory the caller passed in.
+ if (InitializesAttr.isValid() && !CB->isByValArgument(Idx))
Inits = InitializesAttr.getValueAsConstantRangeList();
Value *CurArg = CB->getArgOperand(Idx);
|
[
{
"file": "llvm/test/Transforms/DeadStoreElimination/inter-procedural.ll",
"commands": [
"opt < %s -passes=dse -enable-dse-initializes-attr-improvement -S"
],
"tests": [
{
"test_name": "test_byval",
"test_body": "%struct.a = type { i32, i64, i32, i32 }\n\n@e = dso_local global { i32, [4 x i8], i64, i32, i32 } { i32 5, [4 x i8] zeroinitializer, i64 0, i32 1, i32 90986701 }, align 8\n\ndefine i8 @ad(ptr byval(%struct.a) %ah) {\nentry:\n store i32 0, ptr %ah, align 8\n %call = call i64 @af(ptr %ah)\n %0 = load i8, ptr %ah, align 1\n ret i8 %0\n}\n\ndefine i64 @af(ptr byval(%struct.a) initializes((0, 24)) %am) {\nentry:\n call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %am, ptr noundef nonnull align 8 dereferenceable(24) @e, i64 24, i1 false)\n ret i64 0\n}\n\ndefine i32 @main() {\n %res = call i8 @ad(ptr @e)\n %val = sext i8 %res to i32\n ret i32 %val\n}\n",
"lli_expected_out": "",
"additional_args": null
}
]
}
] |
{
"title": "[FuncAttrs] `initializes` is incorrectly set on parameters with `byval`",
"body": "Reproducer: https://godbolt.org/z/Mcx1nY4E7\n```\n; bin/opt -passes=function-attrs reduced.ll -S\n%struct.a = type { i32, i64, i32, i32 }\n\n@e = dso_local global { i32, [4 x i8], i64, i32, i32 } { i32 5, [4 x i8] zeroinitializer, i64 0, i32 1, i32 90986701 }, align 8\n\ndefine i8 @ad(ptr byval(%struct.a) %ah) {\nentry:\n store i32 0, ptr %ah, align 8\n %call = call i64 @af(ptr %ah)\n %0 = load i8, ptr %ah, align 1\n ret i8 %0\n}\n\ndefine i64 @af(ptr byval(%struct.a) %am) {\nentry:\n call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %am, ptr noundef nonnull align 8 dereferenceable(24) @e, i64 24, i1 false)\n ret i64 0\n}\n\n```\n```\ndefine i8 @ad(ptr byval(%struct.a) captures(none) initializes((0, 4)) %ah) #0 {\n store i32 0, ptr %ah, align 8\n %call = call i64 @af(ptr %ah)\n %0 = load i8, ptr %ah, align 1\n ret i8 %0\n}\n\ndefine noundef i64 @af(ptr writeonly byval(%struct.a) captures(none) initializes((0, 24)) %am) #0 {\n call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %am, ptr noundef nonnull align 8 dereferenceable(24) @e, i64 24, i1 false)\n ret i64 0\n}\n```\nAfter DSE:\n```\ndefine i8 @ad(ptr byval(%struct.a) captures(none) initializes((0, 4)) %ah) #0 {\n %call = call i64 @af(ptr %ah)\n %0 = load i8, ptr %ah, align 1\n ret i8 %0\n}\n\ndefine noundef i64 @af(ptr writeonly byval(%struct.a) captures(none) initializes((0, 24)) %am) #0 {\n ret i64 0\n}\n```\n\nllvm version: d21fc58aeeaa7f0369a24dbe70a0360e0edbf76f\n",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:transforms"
],
"comments": [
{
"author": "nikic",
"body": "> We should also emit the padding for %struct.a.\n\nWithout commenting on whether we should or shouldn't, why is not having the padding a miscompile? As this is not a packed struct, for a i64:64 target, LLVM will implicitly insert the padding and it should have the correct size."
},
{
"author": "dtcxzyw",
"body": "> As this is not a packed struct, for a i64:64 target, LLVM will implicitly insert the padding and it should have the correct size.\n\nSorry. It is a DSE bug.\n"
},
{
"author": "dtcxzyw",
"body": "cc @haopliu "
},
{
"author": "nikic",
"body": "@dtcxzyw I think your new IR is over-reduced. You have `initializes((0, 24)` on `@af`, so I think eliminating the store is correct."
},
{
"author": "dtcxzyw",
"body": "> [@dtcxzyw](https://github.com/dtcxzyw) I think your new IR is over-reduced. You have `initializes((0, 24)` on `@af`, so I think eliminating the store is correct.\n\nFixed."
},
{
"author": "nikic",
"body": "There are two ways we can fix this, depending on what we want the semantics to do:\n\n 1. Don't infer initializes on byval arguments. initializes on byval refers to the original caller memory (or having both attributes is made a verifier error).\n 2. Infer initializes on byval, but don't use it in DSE. initializes on byval refers to the callee copy. This matches the semantics of readonly on byval.\n\nI think variant 2 is marginally more powerful. For example, we could do a backend optimization where byval + initializes will allocate the full size of byval on the stack but not copy over the parts covered by initializes."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
142522
|
https://github.com/llvm/llvm-project/issues/142522
|
crash
|
dc513fa8dc361cb71a2c607f2bd75d812f31459b
| 2025-06-03T03:01:15 |
[
"llvm/test/Transforms/SimplifyCFG"
] |
{
"fix_commit": "7e1fa09ce2a228c949ce4490c98f2c73ed8ada00",
"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": [
[
8108,
8113
],
[
8165,
8170
]
],
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.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": [
"passingValueIsAlwaysUndefined"
],
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.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 7e1fa09ce2a228c949ce4490c98f2c73ed8ada00
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Wed Jun 4 12:37:30 2025 +0800
[SimplifyCFG] Bail out on vector GEPs in `passingValueIsAlwaysUndefined` (#142526)
Closes https://github.com/llvm/llvm-project/issues/142522.
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 245d0c4f073d..e221022bb836 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -8108,6 +8108,7 @@ bool SimplifyCFGOpt::simplifyCondBranch(BranchInst *BI, IRBuilder<> &Builder) {
/// Check if passing a value to an instruction will cause undefined behavior.
static bool passingValueIsAlwaysUndefined(Value *V, Instruction *I, bool PtrValueMayBeModified) {
+ assert(V->getType() == I->getType() && "Mismatched types");
Constant *C = dyn_cast<Constant>(V);
if (!C)
return false;
@@ -8165,6 +8166,10 @@ static bool passingValueIsAlwaysUndefined(Value *V, Instruction *I, bool PtrValu
// Look through GEPs. A load from a GEP derived from NULL is still undefined
if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(User))
if (GEP->getPointerOperand() == I) {
+ // The type of GEP may differ from the type of base pointer.
+ // Bail out on vector GEPs, as they are not handled by other checks.
+ if (GEP->getType()->isVectorTy())
+ return false;
// The current base address is null, there are four cases to consider:
// getelementptr (TY, null, 0) -> null
// getelementptr (TY, null, not zero) -> may be modified
|
[
{
"file": "llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll",
"commands": [
"opt < %s -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S"
],
"tests": [
{
"test_name": "test9_gep_splat",
"test_body": "declare void @fn_arg_vec(<2 x ptr>)\n\ndefine void @test9_gep_splat(i1 %X, ptr %Y) {\nentry:\n br i1 %X, label %if, label %else\n\nif: ; preds = %entry\n br label %else\n\nelse: ; preds = %if, %entry\n %phi = phi ptr [ %Y, %entry ], [ null, %if ]\n %gep = getelementptr i8, ptr %phi, <2 x i64> zeroinitializer\n call void @fn_arg_vec(<2 x ptr> %gep)\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test9",
"test_body": "declare ptr @fn_nonnull_noundef_arg(ptr noundef nonnull)\n\ndefine void @test9(i1 %X, ptr %Y) {\nentry:\n br i1 %X, label %if, label %else\n\nif: ; preds = %entry\n br label %else\n\nelse: ; preds = %if, %entry\n %phi = phi ptr [ %Y, %entry ], [ null, %if ]\n %0 = call ptr @fn_nonnull_noundef_arg(ptr %phi)\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SimplifyCFG] Assertion `getArgOperand(ArgNo)->getType()->isPointerTy() && \"Argument must be a pointer\"' failed.",
"body": "Reproducer:\n```\n; bin/opt -passes=simplifycfg test.ll -S\ndefine void @test9(i1 %X, ptr %Y) {\nentry:\n br i1 %X, label %if, label %else\nif:\n br label %else\nelse:\n %phi = phi ptr [ %Y, %entry ], [ null, %if ]\n %gep = getelementptr i8, ptr %phi, <2 x i64> zeroinitializer\n call void @fn_arg_vec(<2 x ptr> %gep)\n ret void\n}\n\ndeclare void @fn_arg_vec(<2 x ptr>)\n```\n```\nopt: /home/dtcxzyw/WorkSpace/Projects/compilers/llvm-project/llvm/lib/IR/Instructions.cpp:446: bool llvm::CallBase::paramHasNonNullAttr(unsigned int, bool) const: Assertion `getArgOperand(ArgNo)->getType()->isPointerTy() && \"Argument must be a pointer\"' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\nStack dump:\n0. Program arguments: bin/opt -passes=simplifycfg test.ll -S\n1. Running pass \"function(simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-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>)\" on module \"test.ll\"\n2. Running pass \"simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-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>\" on function \"test9\"\n #0 0x000073bf132279f2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.21.0git+0x2279f2)\n #1 0x000073bf132248cf llvm::sys::RunSignalHandlers() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.21.0git+0x2248cf)\n #2 0x000073bf13224a14 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #3 0x000073bf12c45330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)\n #4 0x000073bf12c9eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #5 0x000073bf12c9eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #6 0x000073bf12c9eb2c pthread_kill ./nptl/pthread_kill.c:89:10\n #7 0x000073bf12c4527e raise ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x000073bf12c288ff abort ./stdlib/abort.c:81:7\n #9 0x000073bf12c2881b _nl_load_domain ./intl/loadmsgcat.c:1177:9\n#10 0x000073bf12c3b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)\n#11 0x000073bf098908a3 llvm::CallBase::paramHasNonNullAttr(unsigned int, bool) const (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.21.0git+0x2908a3)\n#12 0x000073bf0a6c321f passingValueIsAlwaysUndefined(llvm::Value*, llvm::Instruction*, bool) SimplifyCFG.cpp:0:0\n#13 0x000073bf0a6c30db passingValueIsAlwaysUndefined(llvm::Value*, llvm::Instruction*, bool) SimplifyCFG.cpp:0:0\n#14 0x000073bf0a6c61ab (anonymous namespace)::SimplifyCFGOpt::speculativelyExecuteBB(llvm::BranchInst*, llvm::BasicBlock*) SimplifyCFG.cpp:0:0\n#15 0x000073bf0a6daeb2 (anonymous namespace)::SimplifyCFGOpt::simplifyCondBranch(llvm::BranchInst*, llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>&) SimplifyCFG.cpp:0:0\n#16 0x000073bf0a6dc91e llvm::simplifyCFG(llvm::BasicBlock*, llvm::TargetTransformInfo const&, llvm::DomTreeUpdater*, llvm::SimplifyCFGOptions const&, llvm::ArrayRef<llvm::WeakVH>) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMTransformUtils.so.21.0git+0x2dc91e)\n#17 0x000073bf0afb76c6 iterativelySimplifyCFG(llvm::Function&, llvm::TargetTransformInfo const&, llvm::DomTreeUpdater*, llvm::SimplifyCFGOptions const&) SimplifyCFGPass.cpp:0:0\n#18 0x000073bf0afb852c simplifyFunctionCFGImpl(llvm::Function&, llvm::TargetTransformInfo const&, llvm::DominatorTree*, llvm::SimplifyCFGOptions const&) SimplifyCFGPass.cpp:0:0\n#19 0x000073bf0afb93b5 simplifyFunctionCFG(llvm::Function&, llvm::TargetTransformInfo const&, llvm::DominatorTree*, llvm::SimplifyCFGOptions const&) SimplifyCFGPass.cpp:0:0\n#20 0x000073bf0afb9510 llvm::SimplifyCFGPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMScalarOpts.so.21.0git+0x3b9510)\n#21 0x000073bf0cfac495 llvm::detail::PassModel<llvm::Function, llvm::SimplifyCFGPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libPolly.so.21.0git+0x1ac495)\n#22 0x000073bf09927164 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.21.0git+0x327164)\n#23 0x000073bf11edb7c5 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.21.0git+0xdb7c5)\n#24 0x000073bf09927680 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.21.0git+0x327680)\n#25 0x000073bf11edc185 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.21.0git+0xdc185)\n#26 0x000073bf09928805 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.21.0git+0x328805)\n#27 0x000073bf135203d9 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.21.0git+0x2d3d9)\n#28 0x000073bf1352b416 optMain (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.21.0git+0x38416)\n#29 0x000073bf12c2a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3\n#30 0x000073bf12c2a28b call_init ./csu/../csu/libc-start.c:128:20\n#31 0x000073bf12c2a28b __libc_start_main ./csu/../csu/libc-start.c:347:5\n#32 0x000056ddb347a095 _start (bin/opt+0x1095)\n\nAborted (core dumped)\n```\nReported by https://github.com/llvm/llvm-project/pull/125383#issuecomment-2932967834\n\n",
"author": "dtcxzyw",
"labels": [
"crash-on-valid",
"llvm:transforms"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
84025
|
https://github.com/llvm/llvm-project/issues/84025
|
miscompilation
|
f51ade25b9205efee09a4915031848cebe772805
| 2024-03-05T15:07:55 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "e96c0c1d5e0a9916098b1a31acb006ea6c1108fb",
"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": [
[
2167,
2180
]
],
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.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": [
"collectInsertionElements"
],
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.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 e96c0c1d5e0a9916098b1a31acb006ea6c1108fb
Author: Quentin Dian <dianqk@dianqk.net>
Date: Wed Mar 6 06:16:28 2024 +0800
[InstCombine] Fix shift calculation in InstCombineCasts (#84027)
Fixes #84025.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index 33ed1d557537..45afa6363ae0 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -2167,14 +2167,14 @@ static bool collectInsertionElements(Value *V, unsigned Shift,
Type *ElementIntTy = IntegerType::get(C->getContext(), ElementSize);
for (unsigned i = 0; i != NumElts; ++i) {
- unsigned ShiftI = Shift + i * ElementSize;
+ unsigned ShiftI = i * ElementSize;
Constant *Piece = ConstantFoldBinaryInstruction(
Instruction::LShr, C, ConstantInt::get(C->getType(), ShiftI));
if (!Piece)
return false;
Piece = ConstantExpr::getTrunc(Piece, ElementIntTy);
- if (!collectInsertionElements(Piece, ShiftI, Elements, VecEltTy,
+ if (!collectInsertionElements(Piece, ShiftI + Shift, Elements, VecEltTy,
isBigEndian))
return false;
}
|
[
{
"file": "llvm/test/Transforms/InstCombine/bitcast.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "bitcast_from_single_element_pointer_vector_to_pointer",
"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\"\ntarget triple = \"x86_64-apple-darwin10.0.0\"\n\ndefine ptr @bitcast_from_single_element_pointer_vector_to_pointer(<1 x ptr> %ptrvec) {\n %ptr = bitcast <1 x ptr> %ptrvec to ptr\n ret ptr %ptr\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "bitcast_shl",
"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\"\ntarget triple = \"x86_64-apple-darwin10.0.0\"\n\ndefine <4 x i32> @bitcast_shl(i32 %arg) {\n %i = zext i32 %arg to i64\n %i1 = shl i64 %i, 32\n %i2 = or i64 %i1, 65\n %i3 = zext i64 %i2 to i128\n %i4 = shl i128 %i3, 64\n %i5 = bitcast i128 %i4 to <4 x i32>\n ret <4 x i32> %i5\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "select_bitcast_unsized_pointer",
"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\"\ntarget triple = \"x86_64-apple-darwin10.0.0\"\n\ndeclare void @f1()\n\ndeclare void @f2()\n\ndefine ptr @select_bitcast_unsized_pointer(i1 %c) {\n %s = select i1 %c, ptr @f1, ptr @f2\n ret ptr %s\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "InstCombine calculated a wrong `insertelement` instruction",
"body": "I tried this IR:\r\n\r\n```llvm\r\ndefine <4 x i32> @src(i32 %arg) {\r\n %i = zext i32 %arg to i64\r\n %i1 = shl i64 %i, 32\r\n %i2 = or i64 %i1, 65\r\n %i3 = zext i64 %i2 to i128\r\n %i4 = shl i128 %i3, 64\r\n %i5 = bitcast i128 %i4 to <4 x i32>\r\n ret <4 x i32> %i5\r\n}\r\n\r\ndefine <4 x i32> @tgt(i32 %arg) {\r\n %i5 = insertelement <4 x i32> <i32 0, i32 0, i32 0, i32 poison>, i32 %arg, i64 3\r\n ret <4 x i32> %i5\r\n}\r\n```\r\n\r\nI expect `src` to be:\r\n\r\n```llvm\r\ndefine <4 x i32> @src(i32 %arg) {\r\n %i5 = insertelement <4 x i32> <i32 0, i32 0, i32 65, i32 poison>, i32 %arg, i64 3\r\n ret <4 x i32> %i5\r\n}\r\n```\r\n\r\nBut I'm getting the same instructions as `tgt`.\r\n\r\nGodbolt: https://llvm.godbolt.org/z/KnMEY4rTq\r\nAlive2: https://alive2.llvm.org/ce/z/7FIJNi\r\nFrom: https://github.com/rust-lang/rust/issues/121996",
"author": "DianQK",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": [
{
"author": "cbeuw",
"body": "Looks like this bug is almost 11 years old: https://github.com/llvm/llvm-project/commit/feb34713d531d1f48c37116e8cab84814202d057! Thanks for fixing"
},
{
"author": "DianQK",
"body": "> Looks like this bug is almost 11 years old: [feb3471](https://github.com/llvm/llvm-project/commit/feb34713d531d1f48c37116e8cab84814202d057)! Thanks for fixing\r\n\r\nBased on my experience, we likely have many more latent bugs. :)"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
91957
|
https://github.com/llvm/llvm-project/issues/91957
|
miscompilation
|
c2a9a974ca85e4ac4509e368d4b9acae7e67bf71
| 2024-05-13T13:05:21 |
[
"llvm/test/Transforms/LICM"
] |
{
"fix_commit": "70091dc943ade280d75cea1e5ea5e93d9a8f934a",
"components": [
"LICM"
],
"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": [
[
2751,
2757
],
[
2759,
2766
]
],
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.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": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": [
"hoistMulAddAssociation"
],
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.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 70091dc943ade280d75cea1e5ea5e93d9a8f934a
Author: Antonio Frighetto <me@antoniofrighetto.com>
Date: Sat May 18 16:52:17 2024 +0200
[LICM] Invalidate cached SCEV results in `hoistMulAddAssociation`
While reassociating expressions, LICM is required to invalidate SCEV
results, as otherwise subsequent passes in the pipeline that leverage
LICM foldings (e.g. IndVars), may reason on invalid expressions; thus
miscompiling. This is achieved by rewriting the reassociable
instruction from scratch.
Fixes: https://github.com/llvm/llvm-project/issues/91957.
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index 6aa4188d1cc4..5eccf7b4adb6 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -2751,7 +2751,7 @@ static bool hoistMulAddAssociation(Instruction &I, Loop &L,
IRBuilder<> Builder(Preheader->getTerminator());
for (auto *U : Changes) {
assert(L.isLoopInvariant(U->get()));
- Instruction *Ins = cast<Instruction>(U->getUser());
+ auto *Ins = cast<BinaryOperator>(U->getUser());
Value *Mul;
if (I.getType()->isIntOrIntVectorTy()) {
Mul = Builder.CreateMul(U->get(), Factor, "factor.op.mul");
@@ -2759,8 +2759,20 @@ static bool hoistMulAddAssociation(Instruction &I, Loop &L,
Ins->dropPoisonGeneratingFlags();
} else
Mul = Builder.CreateFMulFMF(U->get(), Factor, Ins, "factor.op.fmul");
- U->set(Mul);
+
+ // Rewrite the reassociable instruction.
+ unsigned OpIdx = U->getOperandNo();
+ auto *LHS = OpIdx == 0 ? Mul : Ins->getOperand(0);
+ auto *RHS = OpIdx == 1 ? Mul : Ins->getOperand(1);
+ auto *NewBO = BinaryOperator::Create(Ins->getOpcode(), LHS, RHS,
+ Ins->getName() + ".reass", Ins);
+ NewBO->copyIRFlags(Ins);
+ if (VariantOp == Ins)
+ VariantOp = NewBO;
+ Ins->replaceAllUsesWith(NewBO);
+ eraseInstruction(*Ins, SafetyInfo, MSSAU);
}
+
I.replaceAllUsesWith(VariantOp);
eraseInstruction(I, SafetyInfo, MSSAU);
return true;
|
[
{
"file": "llvm/test/Transforms/LICM/update-scev-after-hoist.ll",
"commands": [
"opt -S -passes='loop-unroll,loop-mssa(licm,indvars)' -unroll-count=4 < %s 2>&1"
],
"tests": [
{
"test_name": "main",
"test_body": "define i16 @main() {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %mul = phi i16 [ 1, %entry ], [ %mul.n, %loop ]\n %div = phi i16 [ 32767, %entry ], [ %div.n, %loop ]\n %mul.n = mul i16 %mul, 2\n %div.n = sdiv i16 %div, 2\n %cmp = icmp sgt i16 %div, 0\n br i1 %cmp, label %loop, label %end\n\nend: ; preds = %loop\n ret i16 %mul\n}\n",
"lli_expected_out": null,
"additional_args": "-src-unroll=16 -tgt-unroll=16"
}
]
}
] |
{
"title": "Miscompile with opt -passes=\"loop-unroll,loop-mssa(licm,indvars)\" -unroll-count=4 ",
"body": "llvm commit: e76b257483e6c\r\nReproduce with:\r\n```opt -passes=\"loop-unroll,loop-mssa(licm,indvars)\" -unroll-count=4 bbi-95405.ll -S -o -```\r\n\r\nThe input function returns 32768, but after running the passes as above we get\r\n```\r\ndefine i16 @foo() {\r\nentry:\r\n br label %loop\r\n\r\nloop: ; preds = %loop, %entry\r\n br i1 false, label %loop, label %end, !llvm.loop !0\r\n\r\nend: ; preds = %loop\r\n ret i16 8192\r\n}\r\n\r\n!0 = distinct !{!0, !1}\r\n!1 = !{!\"llvm.loop.unroll.disable\"}\r\n```\r\nSo now the function returns 8192 instead.\r\n\r\nIf I extract the IR after loop-unroll or licm and run the rest of the passes instead I get the correct result.\r\n\r\n[bbi-95405.ll.gz](https://github.com/llvm/llvm-project/files/15294896/bbi-95405.ll.gz)\r\n",
"author": "mikaelholmen",
"labels": [
"miscompilation",
"llvm:transforms"
],
"comments": [
{
"author": "mikaelholmen",
"body": "This starts happening with https://github.com/llvm/llvm-project/pull/67736 , commit 2dd52046816\r\n```\r\nRecommit \"[LICM] Support integer mul/add in hoistFPAssociation. (#67736)\"\r\n\r\nWith a fix for build bot failure. I was accessing the type of a deleted\r\nInstruction.\r\n\r\nOriginal message:\r\n\r\nThe reassociation this is trying to repair can happen for integer types\r\ntoo.\r\n\r\nThis patch adds support for integer mul/add to hoistFPAssociation. The\r\nfunction has been renamed to hoistMulAddAssociation. I've used separate\r\nstatistics and limits for integer to allow tuning flexibility.\r\n```\r\n"
},
{
"author": "nikic",
"body": "Without looking into this in detail, it's possible that the way the LICM code modifies instructions in place results incorrect cached SCEV results."
},
{
"author": "mikaelholmen",
"body": "> Without looking into this in detail, it's possible that the way the LICM code modifies instructions in place results incorrect cached SCEV results.\r\n\r\nI added some printouts and see that when IndVarSimplify run rewriteLoopExitValues we do\r\n```\r\nconst SCEV *ExitValue = SE->getSCEVAtScope(Inst, L->getParentLoop());\r\n```\r\nfor Inst being\r\n```\r\n%mul.n = mul i16 %mul, 8\r\n```\r\nand then we get the SCEV\r\n```\r\n(2 * %mul)\r\n```\r\nwhich looks wrong.\r\n\r\nIf I split up the pipeline in several opt runs we instead get the SCEV\r\n```\r\n(8 * %mul)\r\n```\r\nwhich looks more reasonable (and then we also get the correct result).\r\nLICM changed\r\n```\r\n%mul.n = mul i16 %mul, 2\r\n```\r\nto\r\n```\r\n%mul.n = mul i16 %mul, 8\r\n```\r\nso yeah, it should perhaps do something (more) about SCEV."
},
{
"author": "mikaelholmen",
"body": "@antoniofrighetto : nice that you work on this!\r\n\r\nBut oh it's annoying that I don't get any emails from github about that there was activity here with a linked PR with a fix etc even if I wrote this issue. :( I do get emails when there are comments but not when the issue was assigned or the PR was created. :("
},
{
"author": "antoniofrighetto",
"body": "@mikaelholmen This is a bit inconvenient indeed, GH doesn’t seem to send notifications wrt that :( Closed this, thanks for reporting!"
},
{
"author": "mikaelholmen",
"body": "> @mikaelholmen This is a bit inconvenient indeed, GH doesn’t seem to send notifications wrt that :( Closed this, thanks for reporting!\r\n\r\nThank you!"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
115149
|
https://github.com/llvm/llvm-project/issues/115149
|
miscompilation
|
0f44d72e0ee74970cf696ff4c791f63e0c3fa9b4
| 2024-11-06T11:22:14 |
[
"llvm/test/Transforms/InstCombine"
] |
{
"fix_commit": "929cbe7f596733f85cd274485acc19442dd34a80",
"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": [
[
545,
551
]
],
"llvm/lib/Transforms/Vectorize/VPlanConstruction.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": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": [
"InstCombinerImpl::foldPHIArgGEPIntoPHI"
],
"llvm/lib/Transforms/Vectorize/VPlanConstruction.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 929cbe7f596733f85cd274485acc19442dd34a80
Author: Antonio Frighetto <me@antoniofrighetto.com>
Date: Tue Nov 12 19:02:04 2024 +0100
[InstCombine] Intersect nowrap flags between geps while folding into phi
A miscompilation issue has been addressed with refined checking.
Fixes: https://github.com/llvm/llvm-project/issues/115149.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp b/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
index cb5c44730512..1fcf1c570add 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
@@ -545,7 +545,8 @@ Instruction *InstCombinerImpl::foldPHIArgGEPIntoPHI(PHINode &PN) {
// especially bad when the PHIs are in the header of a loop.
bool NeededPhi = false;
- GEPNoWrapFlags NW = GEPNoWrapFlags::all();
+ // Remember flags of the first phi-operand getelementptr.
+ GEPNoWrapFlags NW = FirstInst->getNoWrapFlags();
// Scan to see if all operands are the same opcode, and all have one user.
for (Value *V : drop_begin(PN.incoming_values())) {
|
[
{
"file": "llvm/test/Transforms/InstCombine/opaque-ptr.ll",
"commands": [
"opt -S -passes=instcombine < %s"
],
"tests": [
{
"test_name": "phi_of_gep_flags_1",
"test_body": "define ptr @phi_of_gep_flags_1(i1 %c, ptr %p) {\n br i1 %c, label %if, label %else\n\nif: ; preds = %0\n %gep1 = getelementptr inbounds i32, ptr %p, i64 1\n br label %join\n\nelse: ; preds = %0\n %gep2 = getelementptr nusw nuw i32, ptr %p, i64 1\n br label %join\n\njoin: ; preds = %else, %if\n %phi = phi ptr [ %gep1, %if ], [ %gep2, %else ]\n ret ptr %phi\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/InstCombine/phi.ll",
"commands": [
"opt < %s -passes=instcombine -S"
],
"tests": [
{
"test_name": "wrong_gep_arg_into_phi",
"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 i64 @wrong_gep_arg_into_phi(ptr noundef %ptr) {\nentry:\n %add.ptr = getelementptr i8, ptr %ptr, i64 1\n br label %for.cond\n\nfor.cond: ; preds = %for.cond, %entry\n %.pn = phi ptr [ %add.ptr, %entry ], [ %incdec.ptr, %for.cond ]\n %val = load i8, ptr %.pn, align 1\n %cond = icmp ne i8 %val, 0\n %incdec.ptr = getelementptr inbounds nuw i8, ptr %.pn, i64 1\n br i1 %cond, label %for.cond, label %exit\n\nexit: ; preds = %for.cond\n ret i64 0\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[clang] Miscompile with -O3 and -O0/1/2 since 18.1.0",
"body": "When I compiled this code with -O0/1/2, its output is 0. However, with -O3, it returned 143:\r\n\r\n```c\r\nint printf(const char *, ...);\r\nchar a, b;\r\nint c;\r\nchar *e = &b;\r\nint f(char *g, int *k) {\r\n char *d = g + *k;\r\n for (; *d && *d <= ' '; d++)\r\n ;\r\n if (*d)\r\n return 0;\r\n return 1;\r\n}\r\nint l(int g) {\r\n char h[] = {a, a, a};\r\n int i[] = {g};\r\n int j = f(h, i);\r\n return j;\r\n}\r\nlong m() {\r\n *e = 255;\r\n for (; l(b + 1);)\r\n return 0;\r\n for (;;)\r\n ;\r\n}\r\nint main() {\r\n m();\r\n printf(\"%d\\n\", c);\r\n}\r\n```\r\n\r\nDetails can be found here: https://godbolt.org/z/dnvvTPror",
"author": "cardigan1008",
"labels": [
"miscompilation",
"llvm:instcombine"
],
"comments": [
{
"author": "antoniofrighetto",
"body": "This looks like a nasty one. Getting the optimized IR via -O3 and setting noinline/optnone to main, we get: https://llvm.godbolt.org/z/vaPvs6d16. \r\n\r\nThis is the initial assembly output with -O1 (which leads to the infinite loop):\r\n\r\n```asm\r\nmain: # @main\r\n push rax\r\n mov rax, qword ptr [e]\r\n mov byte ptr [rax], -1\r\n movsx rax, byte ptr [b]\r\n mov cl, byte ptr [a]\r\n mov byte ptr [rsp + 6], cl\r\n mov byte ptr [rsp + 7], cl\r\n lea rdx, [rsp + 5]\r\n add rdx, rax\r\n mov rax, rdx\r\n.LBB0_1: # %for.cond.i.i.i\r\n add rax, 1\r\n mov cl, byte ptr [rdx + 1]\r\n ...\r\n```\r\nWhereas this is with -O0 (returns 0):\r\n```asm\r\nmain: # @main\r\n sub rsp, 24\r\n mov rax, qword ptr [e]\r\n mov byte ptr [rax], -1\r\n movsx rcx, byte ptr [b]\r\n mov al, byte ptr [a]\r\n mov byte ptr [rsp + 22], al\r\n mov byte ptr [rsp + 23], al\r\n lea rax, [rsp + 21]\r\n add rax, rcx\r\n mov qword ptr [rsp + 8], rax # 8-byte Spill\r\n.LBB0_1: # %for.cond.i.i.i\r\n mov rcx, qword ptr [rsp + 8] # 8-byte Reload\r\n mov rax, rcx\r\n add rax, 1\r\n mov dl, byte ptr [rcx + 1]\r\n```\r\nIn the optimized one, $rdx is set to point to $rsp+0x5, part of the stack slot containing $rax (undef), later dereferenced to set the condition leading to the loop. Initially I thought some bug in regalloc, but to me it seems more something in prologepiloginserter. Function prologue / epilogue seems set up correctly with triple arm64-apple-macosx."
},
{
"author": "antoniofrighetto",
"body": "Looking at the IR better, it seems like InstCombine performs a wrong optimization immediately after inlining `l` into `m`, probably related with default argument conversion done by operator + (which should include integer promotion on types smaller than integer). Alive2 seems to confirm it: https://alive2.llvm.org/ce/z/XAzrip."
},
{
"author": "antoniofrighetto",
"body": "Reduced to:\r\n```llvm\r\n@a = global i8 0, align 1\r\n\r\ndefine i64 @src(i8 noundef %arg) {\r\nentry:\r\n %h.i = alloca [3 x i8], align 1\r\n %conv = sext i8 %arg to i32\r\n %add = add nsw i32 %conv, 1\r\n %2 = load i8, ptr @a, align 1\r\n store i8 %2, ptr %h.i, align 1\r\n %idx.ext.i.i = sext i32 %add to i64\r\n %add.ptr.i.i = getelementptr inbounds i8, ptr %h.i, i64 %idx.ext.i.i\r\n br label %for.cond.i.i\r\n\r\nfor.cond.i.i: ; preds = %for.cond.i.i, %entry\r\n %d.0.i.i = phi ptr [ %add.ptr.i.i, %entry ], [ %incdec.ptr.i.i, %for.cond.i.i ]\r\n %3 = load i8, ptr %d.0.i.i, align 1\r\n %tobool.not.i.i = icmp ne i8 %3, 0\r\n %incdec.ptr.i.i = getelementptr inbounds nuw i8, ptr %d.0.i.i, i64 1\r\n br i1 %tobool.not.i.i, label %for.cond.i.i, label %l.exit\r\n\r\nl.exit: ; preds = %for.cond.i.i\r\n ret i64 0\r\n}\r\n```\r\nWrong sext of add of sext simplified to sext leads to wrong gep offset: https://alive2.llvm.org/ce/z/JaR4j9."
},
{
"author": "AZero13",
"body": "Can we backport this to 19.x?"
},
{
"author": "antoniofrighetto",
"body": "Should be fixed in 929cbe7f596733f85cd274485acc19442dd34a80, thanks for reporting!"
},
{
"author": "AZero13",
"body": "@antoniofrighetto can we please backport this "
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
113516
|
https://github.com/llvm/llvm-project/issues/113516
|
crash
|
0aec4d2b78a08f5f3e4b0ad0340a99e486d00110
| 2024-10-24T03:05:37 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "d2e7ee77d33e8b3be3b1d4e9bc5bc4c60b62b554",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
16118,
16124
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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 d2e7ee77d33e8b3be3b1d4e9bc5bc4c60b62b554
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Thu Oct 24 08:15:21 2024 -0700
[SLP]Do not check for clustered loads only
Since SLP support "clusterization" of the non-load instructions, the
restriction for reduced values for loads only should be removed to avoid
compiler crash.
Fixes #113516
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index f76e913a57d5..012d85353f08 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -16118,7 +16118,7 @@ BoUpSLP::vectorizeTree(const ExtraValueToDebugLocsMap &ExternallyUsedValues,
for (Instruction *I : RemovedInsts) {
const TreeEntry *IE = getTreeEntry(I);
if (IE->Idx != 0 &&
- !(VectorizableTree.front()->isGather() && isa<LoadInst>(I) &&
+ !(VectorizableTree.front()->isGather() &&
!IE->UserTreeIndices.empty() &&
any_of(IE->UserTreeIndices,
[&](const EdgeInfo &EI) {
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/X86/non-load-reduced-as-part-of-bv.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"
],
"tests": [
{
"test_name": "foo",
"test_body": "define i1 @foo() {\nentry:\n %tobool.not.not509.i.1311.i.i = icmp ne i32 0, 0\n %cmp80.1319.i.i189 = icmp sgt i32 0, 0\n %tobool.not.not509.i.1.1.i.i = icmp ne i32 0, 0\n %cmp80.1.1.i.i190 = icmp sgt i32 0, 0\n %tobool.not.not509.i.2329.i.i = icmp ne i32 0, 0\n %storemerge.2333.i.i = select i1 %tobool.not.not509.i.2329.i.i, i32 0, i32 0\n %cmp80.2337.i.i192 = icmp sgt i32 0, 0\n %tobool.not.not509.i.1.2.i.i = icmp ne i32 %storemerge.2333.i.i, 0\n %cmp80.1.2.i.i193 = icmp sgt i32 0, 0\n %cmp80.1.2.i.i = select i1 %tobool.not.not509.i.1.2.i.i, i1 %cmp80.1.2.i.i193, i1 false\n %0 = select i1 %cmp80.1.2.i.i, i1 %tobool.not.not509.i.2329.i.i, i1 false\n %1 = select i1 %0, i1 %cmp80.2337.i.i192, i1 false\n %2 = select i1 %1, i1 false, i1 false\n %3 = select i1 %2, i1 %tobool.not.not509.i.1.1.i.i, i1 false\n %4 = select i1 %3, i1 %cmp80.1.1.i.i190, i1 false\n %5 = select i1 %4, i1 %tobool.not.not509.i.1311.i.i, i1 false\n %6 = select i1 %5, i1 %cmp80.1319.i.i189, i1 false\n ret i1 %6\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SLPVectorizer] Assertion `(I->use_empty() || all_of(I->uses(), [&](Use &U) { return isDeleted( cast<Instruction>(U.getUser())); })) && \"trying to erase instruction with users.\"' failed.",
"body": "Reduced reproducer: https://godbolt.org/z/azEc6zjod\r\n```\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine i1 @foo() {\r\nentry:\r\n %tobool.not.not509.i.1311.i.i = icmp ne i32 0, 0\r\n %cmp80.1319.i.i189 = icmp sgt i32 0, 0\r\n %tobool.not.not509.i.1.1.i.i = icmp ne i32 0, 0\r\n %cmp80.1.1.i.i190 = icmp sgt i32 0, 0\r\n %tobool.not.not509.i.2329.i.i = icmp ne i32 0, 0\r\n %storemerge.2333.i.i = select i1 %tobool.not.not509.i.2329.i.i, i32 0, i32 0\r\n %cmp80.2337.i.i192 = icmp sgt i32 0, 0\r\n %tobool.not.not509.i.1.2.i.i = icmp ne i32 %storemerge.2333.i.i, 0\r\n %cmp80.1.2.i.i193 = icmp sgt i32 0, 0\r\n %cmp80.1.2.i.i = select i1 %tobool.not.not509.i.1.2.i.i, i1 %cmp80.1.2.i.i193, i1 false\r\n %0 = select i1 %cmp80.1.2.i.i, i1 %tobool.not.not509.i.2329.i.i, i1 false\r\n %1 = select i1 %0, i1 %cmp80.2337.i.i192, i1 false\r\n %2 = select i1 %1, i1 false, i1 false\r\n %3 = select i1 %2, i1 %tobool.not.not509.i.1.1.i.i, i1 false\r\n %4 = select i1 %3, i1 %cmp80.1.1.i.i190, i1 false\r\n %5 = select i1 %4, i1 %tobool.not.not509.i.1311.i.i, i1 false\r\n %6 = select i1 %5, i1 %cmp80.1319.i.i189, i1 false\r\n ret i1 %6\r\n}\r\n```\r\n```\r\nopt: /root/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:2748: void llvm::slpvectorizer::BoUpSLP::removeInstructionsAndOperands(llvm::ArrayRef<U*>) [with T = llvm::Instruction]: Assertion `(I->use_empty() || all_of(I->uses(), [&](Use &U) { return isDeleted( cast<Instruction>(U.getUser())); })) && \"trying to erase instruction with users.\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\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 \"foo\"\r\n #0 0x00000000050d8608 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x50d8608)\r\n #1 0x00000000050d5fbc SignalHandler(int) Signals.cpp:0:0\r\n #2 0x000071afd7642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x000071afd76969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x000071afd7642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x000071afd76287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x000071afd762871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x000071afd7639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x000000000414e3af void llvm::slpvectorizer::BoUpSLP::removeInstructionsAndOperands<llvm::Instruction>(llvm::ArrayRef<llvm::Instruction*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x414e3af)\r\n #9 0x00000000041aa335 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::SmallDenseSet<llvm::Value*, 4u, llvm::DenseMapInfo<llvm::Value*, void>> const&, llvm::Instruction*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41aa335)\r\n#10 0x00000000041bcd90 (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&) SLPVectorizer.cpp:0:0\r\n#11 0x00000000041bfb71 llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41bfb71)\r\n#12 0x00000000041c431b llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (.constprop.0) SLPVectorizer.cpp:0:0\r\n#13 0x00000000041c8ae8 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41c8ae8)\r\n#14 0x00000000041cf231 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\r\n#15 0x00000000041cfedb llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41cfedb)\r\n#16 0x0000000002f64f0e llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2f64f0e)\r\n#17 0x0000000004ed9788 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4ed9788)\r\n#18 0x0000000000e2773e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe2773e)\r\n#19 0x0000000004ed81ae llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4ed81ae)\r\n#20 0x0000000000e26e8e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe26e8e)\r\n#21 0x0000000004ed7be0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4ed7be0)\r\n#22 0x000000000090a07a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x90a07a)\r\n#23 0x00000000008fce7c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8fce7c)\r\n#24 0x000071afd7629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#25 0x000071afd7629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#26 0x00000000008f493e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8f493e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```\r\nllvm version: 33363521ca24f912cc25530f6cecbca53acce8a3",
"author": "dtcxzyw",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
113462
|
https://github.com/llvm/llvm-project/issues/113462
|
crash
|
3605d9a456185f4af78c01a2684b822b57bca9b0
| 2024-10-23T14:33:27 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "b65b2b4ab60763515694c740935989f908a03312",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
9840,
9852
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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": [
"computeExtractCost"
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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 b65b2b4ab60763515694c740935989f908a03312
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Wed Oct 23 12:03:38 2024 -0700
[SLP]Expand vector to the whole register size in extracts adjustment
Need to expand the number of elements to the whole register to correctly
process estimation and avoid compiler crash.
Fixes #113462
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index d824c40c401d..889c4d94ba5e 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -9840,13 +9840,14 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
::getShuffleCost(TTI, *RegShuffleKind,
getWidenedType(ScalarTy, EltsPerVector), SubMask);
}
+ const unsigned BaseVF = getFullVectorNumberOfElements(
+ *R.TTI, VL.front()->getType(), alignTo(NumElts, EltsPerVector));
for (unsigned Idx : Indices) {
- assert((Idx + EltsPerVector) <= alignTo(NumElts, EltsPerVector) &&
+ assert((Idx + EltsPerVector) <= BaseVF &&
"SK_ExtractSubvector index out of range");
- Cost += ::getShuffleCost(
- TTI, TTI::SK_ExtractSubvector,
- getWidenedType(ScalarTy, alignTo(NumElts, EltsPerVector)), {},
- CostKind, Idx, getWidenedType(ScalarTy, EltsPerVector));
+ Cost += ::getShuffleCost(TTI, TTI::SK_ExtractSubvector,
+ getWidenedType(ScalarTy, BaseVF), {}, CostKind,
+ Idx, getWidenedType(ScalarTy, EltsPerVector));
}
// Second attempt to check, if just a permute is better estimated than
// subvector extract.
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/partial-register-extract.ll",
"commands": [
"opt -S --passes=slp-vectorizer < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "target datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndeclare void @callee(i32, i64)\n\ndefine i32 @main(i32 %g_274.promoted2477.i.i.i, ptr %p) {\nentry:\n %g_274.promoted2477.i.i.i1 = load i32, ptr %p, align 4\n br i1 false, label %for.inc347.i.i.i, label %for.cond159.preheader.i.i.i\n\nfor.cond159.preheader.i.i.i: ; preds = %entry\n %tobool239.not.us.i.i.i.not = icmp eq i32 %g_274.promoted2477.i.i.i1, 0\n %tobool239.not.us.i.1.i.i = icmp eq i32 %g_274.promoted2477.i.i.i1, 0\n %tobool239.not.us.i.3.i.i = icmp eq i32 %g_274.promoted2477.i.i.i1, 0\n %0 = or i1 %tobool239.not.us.i.3.i.i, %tobool239.not.us.i.1.i.i\n %tobool239.not.us.i.4.i.i = icmp eq i32 %g_274.promoted2477.i.i.i1, 0\n %inc34.i21362404.us.v.i.4.i.i = select i1 %tobool239.not.us.i.4.i.i, i64 0, i64 0\n %tobool239.not.us.i.5.i.i = icmp eq i32 0, 0\n %inc34.i21362404.us.v.i.5.i.i = select i1 %tobool239.not.us.i.5.i.i, i64 0, i64 0\n %inc34.i21362404.us.i.5.i.i = or i64 %inc34.i21362404.us.v.i.4.i.i, %inc34.i21362404.us.v.i.5.i.i\n %1 = or i1 %tobool239.not.us.i.5.i.i, %tobool239.not.us.i.4.i.i\n %inc34.i21362404.us.v.i.6.i.i = select i1 false, i64 0, i64 0\n %inc34.i21362404.us.i.6.i.i = or i64 %inc34.i21362404.us.i.5.i.i, %inc34.i21362404.us.v.i.6.i.i\n %tobool239.not.us.i.7.i.i = icmp eq i32 0, 0\n %inc34.i21362404.us.v.i.7.i.i = select i1 false, i64 0, i64 0\n %inc34.i21362404.us.i.7.i.i = or i64 %inc34.i21362404.us.i.6.i.i, %inc34.i21362404.us.v.i.7.i.i\n %inc34.i21362404.us.v.i.8.i.i = select i1 false, i64 0, i64 0\n %inc34.i21362404.us.i.8.i.i = or i64 %inc34.i21362404.us.i.7.i.i, %inc34.i21362404.us.v.i.8.i.i\n %inc34.i21362404.us.v.i.9.i.i = select i1 false, i64 0, i64 0\n %inc34.i21362404.us.i.9.i.i = or i64 %inc34.i21362404.us.i.8.i.i, %inc34.i21362404.us.v.i.9.i.i\n %tobool239.not.us.i.10.i.i = icmp eq i32 0, 0\n %tobool239.not.us.i.11.i.i = icmp eq i32 0, 0\n %2 = or i1 %tobool239.not.us.i.11.i.i, %tobool239.not.us.i.10.i.i\n %tobool239.not.us.i.12.i.i = icmp eq i32 %g_274.promoted2477.i.i.i, 0\n %3 = or i1 %tobool239.not.us.i.12.i.i, %2\n %tobool239.not.us.i.13.i.i = icmp eq i32 0, 0\n %tobool239.not.us.i.14.i.i = icmp eq i32 0, 0\n %4 = or i1 %tobool239.not.us.i.14.i.i, %tobool239.not.us.i.13.i.i\n %tobool239.not.us.i.16.i.i = icmp eq i32 0, 0\n %tobool239.not.us.i.17.i.i = icmp eq i32 0, 0\n %5 = or i1 %tobool239.not.us.i.17.i.i, %tobool239.not.us.i.16.i.i\n %tobool239.not.us.i.18.i.i = icmp eq i32 0, 0\n %6 = or i1 %tobool239.not.us.i.18.i.i, %5\n %tobool239.not.us.i.19.i.i = icmp eq i32 0, 0\n %tobool239.not.us.i.20.i.i = icmp eq i32 0, 0\n %7 = or i1 %tobool239.not.us.i.20.i.i, %tobool239.not.us.i.19.i.i\n %tobool239.not.us.i.21.i.i = icmp eq i32 0, 0\n %8 = or i1 %tobool239.not.us.i.21.i.i, %7\n %tobool239.not.us.i.22.i.i = icmp eq i32 0, 0\n %tobool239.not.us.i.23.i.i = icmp eq i32 0, 0\n %9 = or i1 %tobool239.not.us.i.23.i.i, %tobool239.not.us.i.22.i.i\n %tobool239.not.us.i.24.i.i = icmp eq i32 0, 0\n %10 = or i1 %tobool239.not.us.i.24.i.i, %9\n %11 = select i1 %10, i1 true, i1 %8\n %12 = select i1 %11, i1 true, i1 %6\n %13 = select i1 %12, i1 true, i1 %4\n %14 = select i1 %13, i1 true, i1 %3\n %15 = select i1 %14, i1 true, i1 %tobool239.not.us.i.7.i.i\n %16 = select i1 %15, i1 true, i1 %1\n %17 = or i1 %0, %tobool239.not.us.i.i.i.not\n %18 = select i1 %16, i1 true, i1 %17\n %and252.us.i.24.i.i = select i1 %18, i32 0, i32 0\n br label %for.inc347.i.i.i\n\nfor.inc347.i.i.i: ; preds = %for.cond159.preheader.i.i.i, %entry\n %g_202.promoted.i.i.i = phi i32 [ %and252.us.i.24.i.i, %for.cond159.preheader.i.i.i ], [ 0, %entry ]\n %.us-phi24612468.i.i.i = phi i64 [ %inc34.i21362404.us.i.9.i.i, %for.cond159.preheader.i.i.i ], [ 0, %entry ]\n call void @callee(i32 %g_202.promoted.i.i.i, i64 %.us-phi24612468.i.i.i)\n ret i32 0\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SLPVectorizer] Assertion `(Idx + EltsPerVector) <= alignTo(NumElts, EltsPerVector) && \"SK_ExtractSubvector index out of range\"' failed.",
"body": "Reproducer: https://godbolt.org/z/fxYWYnWKs\r\n```\r\n; bin/opt -passes=slp-vectorizer reduced.ll -S\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndeclare void @callee(i32, i64)\r\n\r\ndefine i32 @main(i32 %g_274.promoted2477.i.i.i, ptr %p) {\r\nentry:\r\n %g_274.promoted2477.i.i.i1 = load i32, ptr %p, align 4\r\n br i1 false, label %for.inc347.i.i.i, label %for.cond159.preheader.i.i.i\r\n\r\nfor.cond159.preheader.i.i.i: ; preds = %entry\r\n %tobool239.not.us.i.i.i.not = icmp eq i32 %g_274.promoted2477.i.i.i1, 0\r\n %tobool239.not.us.i.1.i.i = icmp eq i32 %g_274.promoted2477.i.i.i1, 0\r\n %tobool239.not.us.i.3.i.i = icmp eq i32 %g_274.promoted2477.i.i.i1, 0\r\n %0 = or i1 %tobool239.not.us.i.3.i.i, %tobool239.not.us.i.1.i.i\r\n %tobool239.not.us.i.4.i.i = icmp eq i32 %g_274.promoted2477.i.i.i1, 0\r\n %inc34.i21362404.us.v.i.4.i.i = select i1 %tobool239.not.us.i.4.i.i, i64 0, i64 0\r\n %tobool239.not.us.i.5.i.i = icmp eq i32 0, 0\r\n %inc34.i21362404.us.v.i.5.i.i = select i1 %tobool239.not.us.i.5.i.i, i64 0, i64 0\r\n %inc34.i21362404.us.i.5.i.i = or i64 %inc34.i21362404.us.v.i.4.i.i, %inc34.i21362404.us.v.i.5.i.i\r\n %1 = or i1 %tobool239.not.us.i.5.i.i, %tobool239.not.us.i.4.i.i\r\n %inc34.i21362404.us.v.i.6.i.i = select i1 false, i64 0, i64 0\r\n %inc34.i21362404.us.i.6.i.i = or i64 %inc34.i21362404.us.i.5.i.i, %inc34.i21362404.us.v.i.6.i.i\r\n %tobool239.not.us.i.7.i.i = icmp eq i32 0, 0\r\n %inc34.i21362404.us.v.i.7.i.i = select i1 false, i64 0, i64 0\r\n %inc34.i21362404.us.i.7.i.i = or i64 %inc34.i21362404.us.i.6.i.i, %inc34.i21362404.us.v.i.7.i.i\r\n %inc34.i21362404.us.v.i.8.i.i = select i1 false, i64 0, i64 0\r\n %inc34.i21362404.us.i.8.i.i = or i64 %inc34.i21362404.us.i.7.i.i, %inc34.i21362404.us.v.i.8.i.i\r\n %inc34.i21362404.us.v.i.9.i.i = select i1 false, i64 0, i64 0\r\n %inc34.i21362404.us.i.9.i.i = or i64 %inc34.i21362404.us.i.8.i.i, %inc34.i21362404.us.v.i.9.i.i\r\n %tobool239.not.us.i.10.i.i = icmp eq i32 0, 0\r\n %tobool239.not.us.i.11.i.i = icmp eq i32 0, 0\r\n %2 = or i1 %tobool239.not.us.i.11.i.i, %tobool239.not.us.i.10.i.i\r\n %tobool239.not.us.i.12.i.i = icmp eq i32 %g_274.promoted2477.i.i.i, 0\r\n %3 = or i1 %tobool239.not.us.i.12.i.i, %2\r\n %tobool239.not.us.i.13.i.i = icmp eq i32 0, 0\r\n %tobool239.not.us.i.14.i.i = icmp eq i32 0, 0\r\n %4 = or i1 %tobool239.not.us.i.14.i.i, %tobool239.not.us.i.13.i.i\r\n %tobool239.not.us.i.16.i.i = icmp eq i32 0, 0\r\n %tobool239.not.us.i.17.i.i = icmp eq i32 0, 0\r\n %5 = or i1 %tobool239.not.us.i.17.i.i, %tobool239.not.us.i.16.i.i\r\n %tobool239.not.us.i.18.i.i = icmp eq i32 0, 0\r\n %6 = or i1 %tobool239.not.us.i.18.i.i, %5\r\n %tobool239.not.us.i.19.i.i = icmp eq i32 0, 0\r\n %tobool239.not.us.i.20.i.i = icmp eq i32 0, 0\r\n %7 = or i1 %tobool239.not.us.i.20.i.i, %tobool239.not.us.i.19.i.i\r\n %tobool239.not.us.i.21.i.i = icmp eq i32 0, 0\r\n %8 = or i1 %tobool239.not.us.i.21.i.i, %7\r\n %tobool239.not.us.i.22.i.i = icmp eq i32 0, 0\r\n %tobool239.not.us.i.23.i.i = icmp eq i32 0, 0\r\n %9 = or i1 %tobool239.not.us.i.23.i.i, %tobool239.not.us.i.22.i.i\r\n %tobool239.not.us.i.24.i.i = icmp eq i32 0, 0\r\n %10 = or i1 %tobool239.not.us.i.24.i.i, %9\r\n %11 = select i1 %10, i1 true, i1 %8\r\n %12 = select i1 %11, i1 true, i1 %6\r\n %13 = select i1 %12, i1 true, i1 %4\r\n %14 = select i1 %13, i1 true, i1 %3\r\n %15 = select i1 %14, i1 true, i1 %tobool239.not.us.i.7.i.i\r\n %16 = select i1 %15, i1 true, i1 %1\r\n %17 = or i1 %0, %tobool239.not.us.i.i.i.not\r\n %18 = select i1 %16, i1 true, i1 %17\r\n %and252.us.i.24.i.i = select i1 %18, i32 0, i32 0\r\n br label %for.inc347.i.i.i\r\n\r\nfor.inc347.i.i.i: ; preds = %for.cond159.preheader.i.i.i, %entry\r\n %g_202.promoted.i.i.i = phi i32 [ %and252.us.i.24.i.i, %for.cond159.preheader.i.i.i ], [ 0, %entry ]\r\n %.us-phi24612468.i.i.i = phi i64 [ %inc34.i21362404.us.i.9.i.i, %for.cond159.preheader.i.i.i ], [ 0, %entry ]\r\n call void @callee(i32 %g_202.promoted.i.i.i, i64 %.us-phi24612468.i.i.i)\r\n ret i32 0\r\n}\r\n```\r\n```\r\nopt: /root/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:9844: llvm::InstructionCost llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator::computeExtractCost(llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<int>, llvm::ArrayRef<std::optional<llvm::TargetTransformInfo::ShuffleKind> >, unsigned int): Assertion `(Idx + EltsPerVector) <= alignTo(NumElts, EltsPerVector) && \"SK_ExtractSubvector index out of range\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer <source>\r\n1.\tRunning pass \"function(slp-vectorizer)\" on module \"<source>\"\r\n2.\tRunning pass \"slp-vectorizer\" on function \"main\"\r\n #0 0x00000000050d8608 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x50d8608)\r\n #1 0x00000000050d5fbc SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007ed1b9642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x00007ed1b96969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x00007ed1b9642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x00007ed1b96287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00007ed1b962871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x00007ed1b9639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x000000000413c75f llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator::computeExtractCost(llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<int>, llvm::ArrayRef<std::optional<llvm::TargetTransformInfo::ShuffleKind>>, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x413c75f)\r\n #9 0x0000000004140d8b llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator::adjustExtracts(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::MutableArrayRef<int>, llvm::ArrayRef<std::optional<llvm::TargetTransformInfo::ShuffleKind>>, unsigned int, bool&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4140d8b)\r\n#10 0x000000000417b42a llvm::InstructionCost llvm::slpvectorizer::BoUpSLP::processBuildVector<llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator, llvm::InstructionCost, llvm::TargetTransformInfo, llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP, llvm::SmallPtrSetImpl<llvm::Value*>>(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::Type*, llvm::TargetTransformInfo&, llvm::ArrayRef<llvm::Value*>&, llvm::slpvectorizer::BoUpSLP&, llvm::SmallPtrSetImpl<llvm::Value*>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x417b42a)\r\n#11 0x000000000417cae7 llvm::slpvectorizer::BoUpSLP::getEntryCost(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallPtrSetImpl<llvm::Value*>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x417cae7)\r\n#12 0x00000000041b6e11 llvm::slpvectorizer::BoUpSLP::getTreeCost(llvm::ArrayRef<llvm::Value*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41b6e11)\r\n#13 0x00000000041bc5df (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&) SLPVectorizer.cpp:0:0\r\n#14 0x00000000041bfb71 llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41bfb71)\r\n#15 0x00000000041c431b llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (.constprop.0) SLPVectorizer.cpp:0:0\r\n#16 0x00000000041c856e llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41c856e)\r\n#17 0x00000000041cf231 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\r\n#18 0x00000000041cfedb llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41cfedb)\r\n#19 0x0000000002f64f0e llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2f64f0e)\r\n#20 0x0000000004ed9788 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4ed9788)\r\n#21 0x0000000000e2773e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe2773e)\r\n#22 0x0000000004ed81ae llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4ed81ae)\r\n#23 0x0000000000e26e8e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe26e8e)\r\n#24 0x0000000004ed7be0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4ed7be0)\r\n#25 0x000000000090a07a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x90a07a)\r\n#26 0x00000000008fce7c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8fce7c)\r\n#27 0x00007ed1b9629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#28 0x00007ed1b9629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#29 0x00000000008f493e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8f493e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```\r\n\r\nllvm version: 8a9921f5692ab33451d11454b40a023ca0965a69\r\n",
"author": "dtcxzyw",
"labels": [
"llvm:SLPVectorizer",
"crash-on-valid"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
143513
|
https://github.com/llvm/llvm-project/issues/143513
|
crash
|
cf637b7e3554976419a0d672ad4c252137dc34f3
| 2025-06-10T12:05:35 |
[
"llvm/test/Transforms/PhaseOrdering",
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "0108a5908cab5e418c683ef9b6e1810755344b5e",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
12085,
12091
],
[
12130,
12136
],
[
12152,
12159
],
[
12171,
12182
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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": [
"computeExtractCost"
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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 0108a5908cab5e418c683ef9b6e1810755344b5e
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Tue Jun 17 07:55:52 2025 -0700
[SLP]Fix a crash on an subvector size calculation for non-power-of-2 vector
Patch fixes cost estimation for the extractelements from non-power-of-2
vectors, defined as subvector extracts. In this case the subvector size
might be not adjusted to a whole register size, need to get the minimum
between whole vector size and the actual difference to prevent compiler
crash.
Fixes #143513
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index d811e9d77d18..4551a365a696 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -12085,7 +12085,8 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
// FIXME: this must be moved to TTI for better estimation.
unsigned EltsPerVector = getPartNumElems(VL.size(), NumParts);
auto CheckPerRegistersShuffle = [&](MutableArrayRef<int> Mask,
- SmallVectorImpl<unsigned> &Indices)
+ SmallVectorImpl<unsigned> &Indices,
+ SmallVectorImpl<unsigned> &SubVecSizes)
-> std::optional<TTI::ShuffleKind> {
if (NumElts <= EltsPerVector)
return std::nullopt;
@@ -12130,7 +12131,9 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
return std::min(S, I);
}),
EltsPerVector);
- Indices.push_back(OffsetReg1 % NumElts);
+ unsigned Index = OffsetReg1 % NumElts;
+ Indices.push_back(Index);
+ SubVecSizes.push_back(std::min(NumElts - Index, EltsPerVector));
}
Idx = I - OffsetReg1;
}
@@ -12152,8 +12155,9 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
SmallVector<int> SubMask(EltsPerVector, PoisonMaskElem);
copy(MaskSlice, SubMask.begin());
SmallVector<unsigned, 2> Indices;
+ SmallVector<unsigned, 2> SubVecSizes;
std::optional<TTI::ShuffleKind> RegShuffleKind =
- CheckPerRegistersShuffle(SubMask, Indices);
+ CheckPerRegistersShuffle(SubMask, Indices, SubVecSizes);
if (!RegShuffleKind) {
if (*ShuffleKinds[Part] != TTI::SK_PermuteSingleSrc ||
!ShuffleVectorInst::isIdentityMask(
@@ -12171,12 +12175,12 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
}
const unsigned BaseVF = getFullVectorNumberOfElements(
*R.TTI, VL.front()->getType(), alignTo(NumElts, EltsPerVector));
- for (unsigned Idx : Indices) {
- assert((Idx + EltsPerVector) <= BaseVF &&
+ for (const auto [Idx, SubVecSize] : zip(Indices, SubVecSizes)) {
+ assert((Idx + SubVecSize) <= BaseVF &&
"SK_ExtractSubvector index out of range");
Cost += ::getShuffleCost(TTI, TTI::SK_ExtractSubvector,
getWidenedType(ScalarTy, BaseVF), {}, CostKind,
- Idx, getWidenedType(ScalarTy, EltsPerVector));
+ Idx, getWidenedType(ScalarTy, SubVecSize));
}
// Second attempt to check, if just a permute is better estimated than
// subvector extract.
|
[
{
"file": "llvm/test/Transforms/PhaseOrdering/X86/hadd.ll",
"commands": [
"opt < %s -O3 -S -mtriple=x86_64-- -mcpu=x86-64",
"opt < %s -O3 -S -mtriple=x86_64-- -mcpu=x86-64-v2",
"opt < %s -O3 -S -mtriple=x86_64-- -mcpu=x86-64-v3",
"opt < %s -O3 -S -mtriple=x86_64-- -mcpu=x86-64-v4",
"opt < %s -passes=\"default<O3>\" -S -mtriple=x86_64-- -mcpu=x86-64",
"opt < %s -passes=\"default<O3>\" -S -mtriple=x86_64-- -mcpu=x86-64-v2",
"opt < %s -passes=\"default<O3>\" -S -mtriple=x86_64-- -mcpu=x86-64-v3",
"opt < %s -passes=\"default<O3>\" -S -mtriple=x86_64-- -mcpu=x86-64-v4"
],
"tests": [
{
"test_name": "add_v16i16_0123u56789uBCDEF",
"test_body": "define <16 x i16> @add_v16i16_0123u56789uBCDEF(<16 x i16> %a, <16 x i16> %b) {\n %a0 = extractelement <16 x i16> %a, i32 0\n %a1 = extractelement <16 x i16> %a, i32 1\n %a2 = extractelement <16 x i16> %a, i32 2\n %a3 = extractelement <16 x i16> %a, i32 3\n %a4 = extractelement <16 x i16> %a, i32 4\n %a5 = extractelement <16 x i16> %a, i32 5\n %a6 = extractelement <16 x i16> %a, i32 6\n %a7 = extractelement <16 x i16> %a, i32 7\n %a8 = extractelement <16 x i16> %a, i32 8\n %a9 = extractelement <16 x i16> %a, i32 9\n %aA = extractelement <16 x i16> %a, i32 10\n %aB = extractelement <16 x i16> %a, i32 11\n %aC = extractelement <16 x i16> %a, i32 12\n %aD = extractelement <16 x i16> %a, i32 13\n %aE = extractelement <16 x i16> %a, i32 14\n %aF = extractelement <16 x i16> %a, i32 15\n %a01 = add i16 %a0, %a1\n %a23 = add i16 %a2, %a3\n %a45 = add i16 %a4, %a5\n %a67 = add i16 %a6, %a7\n %a89 = add i16 %a8, %a9\n %aAB = add i16 %aA, %aB\n %aCD = add i16 %aC, %aD\n %aEF = add i16 %aE, %aF\n %b0 = extractelement <16 x i16> %b, i32 0\n %b1 = extractelement <16 x i16> %b, i32 1\n %b2 = extractelement <16 x i16> %b, i32 2\n %b3 = extractelement <16 x i16> %b, i32 3\n %b4 = extractelement <16 x i16> %b, i32 4\n %b5 = extractelement <16 x i16> %b, i32 5\n %b6 = extractelement <16 x i16> %b, i32 6\n %b7 = extractelement <16 x i16> %b, i32 7\n %b8 = extractelement <16 x i16> %b, i32 8\n %b9 = extractelement <16 x i16> %b, i32 9\n %bA = extractelement <16 x i16> %b, i32 10\n %bB = extractelement <16 x i16> %b, i32 11\n %bC = extractelement <16 x i16> %b, i32 12\n %bD = extractelement <16 x i16> %b, i32 13\n %bE = extractelement <16 x i16> %b, i32 14\n %bF = extractelement <16 x i16> %b, i32 15\n %b01 = add i16 %b0, %b1\n %b23 = add i16 %b2, %b3\n %b45 = add i16 %b4, %b5\n %b67 = add i16 %b6, %b7\n %b89 = add i16 %b8, %b9\n %bAB = add i16 %bA, %bB\n %bCD = add i16 %bC, %bD\n %bEF = add i16 %bE, %bF\n %hadd0 = insertelement <16 x i16> poison, i16 %a01, i32 0\n %hadd1 = insertelement <16 x i16> %hadd0, i16 %a23, i32 1\n %hadd2 = insertelement <16 x i16> %hadd1, i16 %a45, i32 2\n %hadd3 = insertelement <16 x i16> %hadd2, i16 %a67, i32 3\n %hadd4 = insertelement <16 x i16> %hadd3, i16 %b01, i32 4\n %hadd5 = insertelement <16 x i16> %hadd4, i16 %b23, i32 5\n %hadd6 = insertelement <16 x i16> %hadd5, i16 %b45, i32 6\n %hadd7 = insertelement <16 x i16> %hadd6, i16 %b67, i32 7\n %hadd8 = insertelement <16 x i16> %hadd7, i16 %a89, i32 8\n %hadd9 = insertelement <16 x i16> %hadd8, i16 %aAB, i32 9\n %haddA = insertelement <16 x i16> %hadd9, i16 %aCD, i32 10\n %haddB = insertelement <16 x i16> %haddA, i16 %aEF, i32 11\n %haddC = insertelement <16 x i16> %haddB, i16 %b89, i32 12\n %haddD = insertelement <16 x i16> %haddC, i16 %bAB, i32 13\n %haddE = insertelement <16 x i16> %haddD, i16 %bCD, i32 14\n %haddF = insertelement <16 x i16> %haddE, i16 %bEF, i32 15\n %result = shufflevector <16 x i16> %haddF, <16 x i16> %a, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 poison, i32 5, i32 6, i32 7, i32 8, i32 9, i32 poison, i32 11, i32 12, i32 13, i32 14, i32 15>\n ret <16 x i16> %result\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "add_v16i16_0123456789ABCDEF",
"test_body": "define <16 x i16> @add_v16i16_0123456789ABCDEF(<16 x i16> %a, <16 x i16> %b) {\n %a0 = extractelement <16 x i16> %a, i32 0\n %a1 = extractelement <16 x i16> %a, i32 1\n %a2 = extractelement <16 x i16> %a, i32 2\n %a3 = extractelement <16 x i16> %a, i32 3\n %a4 = extractelement <16 x i16> %a, i32 4\n %a5 = extractelement <16 x i16> %a, i32 5\n %a6 = extractelement <16 x i16> %a, i32 6\n %a7 = extractelement <16 x i16> %a, i32 7\n %a8 = extractelement <16 x i16> %a, i32 8\n %a9 = extractelement <16 x i16> %a, i32 9\n %aA = extractelement <16 x i16> %a, i32 10\n %aB = extractelement <16 x i16> %a, i32 11\n %aC = extractelement <16 x i16> %a, i32 12\n %aD = extractelement <16 x i16> %a, i32 13\n %aE = extractelement <16 x i16> %a, i32 14\n %aF = extractelement <16 x i16> %a, i32 15\n %a01 = add i16 %a0, %a1\n %a23 = add i16 %a2, %a3\n %a45 = add i16 %a4, %a5\n %a67 = add i16 %a6, %a7\n %a89 = add i16 %a8, %a9\n %aAB = add i16 %aA, %aB\n %aCD = add i16 %aC, %aD\n %aEF = add i16 %aE, %aF\n %b0 = extractelement <16 x i16> %b, i32 0\n %b1 = extractelement <16 x i16> %b, i32 1\n %b2 = extractelement <16 x i16> %b, i32 2\n %b3 = extractelement <16 x i16> %b, i32 3\n %b4 = extractelement <16 x i16> %b, i32 4\n %b5 = extractelement <16 x i16> %b, i32 5\n %b6 = extractelement <16 x i16> %b, i32 6\n %b7 = extractelement <16 x i16> %b, i32 7\n %b8 = extractelement <16 x i16> %b, i32 8\n %b9 = extractelement <16 x i16> %b, i32 9\n %bA = extractelement <16 x i16> %b, i32 10\n %bB = extractelement <16 x i16> %b, i32 11\n %bC = extractelement <16 x i16> %b, i32 12\n %bD = extractelement <16 x i16> %b, i32 13\n %bE = extractelement <16 x i16> %b, i32 14\n %bF = extractelement <16 x i16> %b, i32 15\n %b01 = add i16 %b0, %b1\n %b23 = add i16 %b2, %b3\n %b45 = add i16 %b4, %b5\n %b67 = add i16 %b6, %b7\n %b89 = add i16 %b8, %b9\n %bAB = add i16 %bA, %bB\n %bCD = add i16 %bC, %bD\n %bEF = add i16 %bE, %bF\n %hadd0 = insertelement <16 x i16> poison, i16 %a01, i32 0\n %hadd1 = insertelement <16 x i16> %hadd0, i16 %a23, i32 1\n %hadd2 = insertelement <16 x i16> %hadd1, i16 %a45, i32 2\n %hadd3 = insertelement <16 x i16> %hadd2, i16 %a67, i32 3\n %hadd4 = insertelement <16 x i16> %hadd3, i16 %b01, i32 4\n %hadd5 = insertelement <16 x i16> %hadd4, i16 %b23, i32 5\n %hadd6 = insertelement <16 x i16> %hadd5, i16 %b45, i32 6\n %hadd7 = insertelement <16 x i16> %hadd6, i16 %b67, i32 7\n %hadd8 = insertelement <16 x i16> %hadd7, i16 %a89, i32 8\n %hadd9 = insertelement <16 x i16> %hadd8, i16 %aAB, i32 9\n %haddA = insertelement <16 x i16> %hadd9, i16 %aCD, i32 10\n %haddB = insertelement <16 x i16> %haddA, i16 %aEF, i32 11\n %haddC = insertelement <16 x i16> %haddB, i16 %b89, i32 12\n %haddD = insertelement <16 x i16> %haddC, i16 %bAB, i32 13\n %haddE = insertelement <16 x i16> %haddD, i16 %bCD, i32 14\n %haddF = insertelement <16 x i16> %haddE, i16 %bEF, i32 15\n %result = shufflevector <16 x i16> %haddF, <16 x i16> %a, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>\n ret <16 x i16> %result\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/PhaseOrdering/X86/hsub.ll",
"commands": [
"opt < %s -O3 -S -mtriple=x86_64-- -mcpu=x86-64",
"opt < %s -O3 -S -mtriple=x86_64-- -mcpu=x86-64-v2",
"opt < %s -O3 -S -mtriple=x86_64-- -mcpu=x86-64-v3",
"opt < %s -O3 -S -mtriple=x86_64-- -mcpu=x86-64-v4",
"opt < %s -passes=\"default<O3>\" -S -mtriple=x86_64-- -mcpu=x86-64",
"opt < %s -passes=\"default<O3>\" -S -mtriple=x86_64-- -mcpu=x86-64-v2",
"opt < %s -passes=\"default<O3>\" -S -mtriple=x86_64-- -mcpu=x86-64-v3",
"opt < %s -passes=\"default<O3>\" -S -mtriple=x86_64-- -mcpu=x86-64-v4"
],
"tests": [
{
"test_name": "sub_v16i16_0123456789ABCDEF",
"test_body": "define <16 x i16> @sub_v16i16_0123456789ABCDEF(<16 x i16> %a, <16 x i16> %b) {\n %a0 = extractelement <16 x i16> %a, i32 0\n %a1 = extractelement <16 x i16> %a, i32 1\n %a2 = extractelement <16 x i16> %a, i32 2\n %a3 = extractelement <16 x i16> %a, i32 3\n %a4 = extractelement <16 x i16> %a, i32 4\n %a5 = extractelement <16 x i16> %a, i32 5\n %a6 = extractelement <16 x i16> %a, i32 6\n %a7 = extractelement <16 x i16> %a, i32 7\n %a8 = extractelement <16 x i16> %a, i32 8\n %a9 = extractelement <16 x i16> %a, i32 9\n %aA = extractelement <16 x i16> %a, i32 10\n %aB = extractelement <16 x i16> %a, i32 11\n %aC = extractelement <16 x i16> %a, i32 12\n %aD = extractelement <16 x i16> %a, i32 13\n %aE = extractelement <16 x i16> %a, i32 14\n %aF = extractelement <16 x i16> %a, i32 15\n %a01 = sub i16 %a0, %a1\n %a23 = sub i16 %a2, %a3\n %a45 = sub i16 %a4, %a5\n %a67 = sub i16 %a6, %a7\n %a89 = sub i16 %a8, %a9\n %aAB = sub i16 %aA, %aB\n %aCD = sub i16 %aC, %aD\n %aEF = sub i16 %aE, %aF\n %b0 = extractelement <16 x i16> %b, i32 0\n %b1 = extractelement <16 x i16> %b, i32 1\n %b2 = extractelement <16 x i16> %b, i32 2\n %b3 = extractelement <16 x i16> %b, i32 3\n %b4 = extractelement <16 x i16> %b, i32 4\n %b5 = extractelement <16 x i16> %b, i32 5\n %b6 = extractelement <16 x i16> %b, i32 6\n %b7 = extractelement <16 x i16> %b, i32 7\n %b8 = extractelement <16 x i16> %b, i32 8\n %b9 = extractelement <16 x i16> %b, i32 9\n %bA = extractelement <16 x i16> %b, i32 10\n %bB = extractelement <16 x i16> %b, i32 11\n %bC = extractelement <16 x i16> %b, i32 12\n %bD = extractelement <16 x i16> %b, i32 13\n %bE = extractelement <16 x i16> %b, i32 14\n %bF = extractelement <16 x i16> %b, i32 15\n %b01 = sub i16 %b0, %b1\n %b23 = sub i16 %b2, %b3\n %b45 = sub i16 %b4, %b5\n %b67 = sub i16 %b6, %b7\n %b89 = sub i16 %b8, %b9\n %bAB = sub i16 %bA, %bB\n %bCD = sub i16 %bC, %bD\n %bEF = sub i16 %bE, %bF\n %hsub0 = insertelement <16 x i16> poison, i16 %a01, i32 0\n %hsub1 = insertelement <16 x i16> %hsub0, i16 %a23, i32 1\n %hsub2 = insertelement <16 x i16> %hsub1, i16 %a45, i32 2\n %hsub3 = insertelement <16 x i16> %hsub2, i16 %a67, i32 3\n %hsub4 = insertelement <16 x i16> %hsub3, i16 %b01, i32 4\n %hsub5 = insertelement <16 x i16> %hsub4, i16 %b23, i32 5\n %hsub6 = insertelement <16 x i16> %hsub5, i16 %b45, i32 6\n %hsub7 = insertelement <16 x i16> %hsub6, i16 %b67, i32 7\n %hsub8 = insertelement <16 x i16> %hsub7, i16 %a89, i32 8\n %hsub9 = insertelement <16 x i16> %hsub8, i16 %aAB, i32 9\n %hsubA = insertelement <16 x i16> %hsub9, i16 %aCD, i32 10\n %hsubB = insertelement <16 x i16> %hsubA, i16 %aEF, i32 11\n %hsubC = insertelement <16 x i16> %hsubB, i16 %b89, i32 12\n %hsubD = insertelement <16 x i16> %hsubC, i16 %bAB, i32 13\n %hsubE = insertelement <16 x i16> %hsubD, i16 %bCD, i32 14\n %hsubF = insertelement <16 x i16> %hsubE, i16 %bEF, i32 15\n %result = shufflevector <16 x i16> %hsubF, <16 x i16> %a, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>\n ret <16 x i16> %result\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "sub_v16i16_0123u56789uBCDEF",
"test_body": "define <16 x i16> @sub_v16i16_0123u56789uBCDEF(<16 x i16> %a, <16 x i16> %b) {\n %a0 = extractelement <16 x i16> %a, i32 0\n %a1 = extractelement <16 x i16> %a, i32 1\n %a2 = extractelement <16 x i16> %a, i32 2\n %a3 = extractelement <16 x i16> %a, i32 3\n %a4 = extractelement <16 x i16> %a, i32 4\n %a5 = extractelement <16 x i16> %a, i32 5\n %a6 = extractelement <16 x i16> %a, i32 6\n %a7 = extractelement <16 x i16> %a, i32 7\n %a8 = extractelement <16 x i16> %a, i32 8\n %a9 = extractelement <16 x i16> %a, i32 9\n %aA = extractelement <16 x i16> %a, i32 10\n %aB = extractelement <16 x i16> %a, i32 11\n %aC = extractelement <16 x i16> %a, i32 12\n %aD = extractelement <16 x i16> %a, i32 13\n %aE = extractelement <16 x i16> %a, i32 14\n %aF = extractelement <16 x i16> %a, i32 15\n %a01 = sub i16 %a0, %a1\n %a23 = sub i16 %a2, %a3\n %a45 = sub i16 %a4, %a5\n %a67 = sub i16 %a6, %a7\n %a89 = sub i16 %a8, %a9\n %aAB = sub i16 %aA, %aB\n %aCD = sub i16 %aC, %aD\n %aEF = sub i16 %aE, %aF\n %b0 = extractelement <16 x i16> %b, i32 0\n %b1 = extractelement <16 x i16> %b, i32 1\n %b2 = extractelement <16 x i16> %b, i32 2\n %b3 = extractelement <16 x i16> %b, i32 3\n %b4 = extractelement <16 x i16> %b, i32 4\n %b5 = extractelement <16 x i16> %b, i32 5\n %b6 = extractelement <16 x i16> %b, i32 6\n %b7 = extractelement <16 x i16> %b, i32 7\n %b8 = extractelement <16 x i16> %b, i32 8\n %b9 = extractelement <16 x i16> %b, i32 9\n %bA = extractelement <16 x i16> %b, i32 10\n %bB = extractelement <16 x i16> %b, i32 11\n %bC = extractelement <16 x i16> %b, i32 12\n %bD = extractelement <16 x i16> %b, i32 13\n %bE = extractelement <16 x i16> %b, i32 14\n %bF = extractelement <16 x i16> %b, i32 15\n %b01 = sub i16 %b0, %b1\n %b23 = sub i16 %b2, %b3\n %b45 = sub i16 %b4, %b5\n %b67 = sub i16 %b6, %b7\n %b89 = sub i16 %b8, %b9\n %bAB = sub i16 %bA, %bB\n %bCD = sub i16 %bC, %bD\n %bEF = sub i16 %bE, %bF\n %hsub0 = insertelement <16 x i16> poison, i16 %a01, i32 0\n %hsub1 = insertelement <16 x i16> %hsub0, i16 %a23, i32 1\n %hsub2 = insertelement <16 x i16> %hsub1, i16 %a45, i32 2\n %hsub3 = insertelement <16 x i16> %hsub2, i16 %a67, i32 3\n %hsub4 = insertelement <16 x i16> %hsub3, i16 %b01, i32 4\n %hsub5 = insertelement <16 x i16> %hsub4, i16 %b23, i32 5\n %hsub6 = insertelement <16 x i16> %hsub5, i16 %b45, i32 6\n %hsub7 = insertelement <16 x i16> %hsub6, i16 %b67, i32 7\n %hsub8 = insertelement <16 x i16> %hsub7, i16 %a89, i32 8\n %hsub9 = insertelement <16 x i16> %hsub8, i16 %aAB, i32 9\n %hsubA = insertelement <16 x i16> %hsub9, i16 %aCD, i32 10\n %hsubB = insertelement <16 x i16> %hsubA, i16 %aEF, i32 11\n %hsubC = insertelement <16 x i16> %hsubB, i16 %b89, i32 12\n %hsubD = insertelement <16 x i16> %hsubC, i16 %bAB, i32 13\n %hsubE = insertelement <16 x i16> %hsubD, i16 %bCD, i32 14\n %hsubF = insertelement <16 x i16> %hsubE, i16 %bEF, i32 15\n %result = shufflevector <16 x i16> %hsubF, <16 x i16> %a, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 poison, i32 5, i32 6, i32 7, i32 8, i32 9, i32 poison, i32 11, i32 12, i32 13, i32 14, i32 15>\n ret <16 x i16> %result\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/SLPVectorizer/SystemZ/non-power-2-subvector-extract.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=s390x-ibm-linux -mcpu=z13 -slp-max-reg-size=256 -slp-vectorize-hor-store -slp-vectorize-non-power-of-2 < %s"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\n@c = external global [1 x [10 x i32]]\n@j.0 = external global i32\n\ndefine void @p() {\n;\nentry:\n %arrayidx12.promoted.5.i = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 200), align 4\n %conv14.5.i = xor i32 %arrayidx12.promoted.5.i, 1\n store i32 %conv14.5.i, ptr getelementptr inbounds nuw (i8, ptr @c, i64 200), align 4\n %arrayidx12.promoted.5.i.1 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 204), align 4\n %conv14.5.i.1 = xor i32 %arrayidx12.promoted.5.i.1, 1\n store i32 %conv14.5.i.1, ptr getelementptr inbounds nuw (i8, ptr @c, i64 204), align 4\n %arrayidx12.promoted.5.i.2 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 208), align 4\n %conv14.5.i.2 = xor i32 %arrayidx12.promoted.5.i.2, 1\n store i32 %conv14.5.i.2, ptr getelementptr inbounds nuw (i8, ptr @c, i64 208), align 4\n %arrayidx12.promoted.1.i.3 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 52), align 4\n %conv14.1.i.3 = xor i32 %arrayidx12.promoted.1.i.3, 1\n store i32 %conv14.1.i.3, ptr getelementptr inbounds nuw (i8, ptr @c, i64 52), align 4\n %arrayidx12.promoted.5.i.3 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 212), align 4\n %conv14.5.i.3 = xor i32 %arrayidx12.promoted.5.i.3, 1\n store i32 %conv14.5.i.3, ptr getelementptr inbounds nuw (i8, ptr @c, i64 212), align 4\n %arrayidx12.promoted.6.i.3 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 252), align 4\n %conv14.6.i.3 = xor i32 %arrayidx12.promoted.6.i.3, 1\n %or.1.5.i.3 = or i32 %arrayidx12.promoted.1.i.3, %arrayidx12.promoted.5.i.3\n store i32 %conv14.6.i.3, ptr getelementptr inbounds nuw (i8, ptr @c, i64 252), align 4\n store i32 %or.1.5.i.3, ptr @j.0, align 4\n %arrayidx12.promoted.1.i.4 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 56), align 4\n %conv14.1.i.4 = xor i32 %arrayidx12.promoted.1.i.4, 1\n store i32 %conv14.1.i.4, ptr getelementptr inbounds nuw (i8, ptr @c, i64 56), align 4\n %arrayidx12.promoted.5.i.4 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 216), align 4\n %conv14.5.i.4 = xor i32 %arrayidx12.promoted.5.i.4, 1\n store i32 %conv14.5.i.4, ptr getelementptr inbounds nuw (i8, ptr @c, i64 216), align 4\n %arrayidx12.promoted.6.i.4 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 256), align 4\n %conv14.6.i.4 = xor i32 %arrayidx12.promoted.6.i.4, 1\n store i32 %conv14.6.i.4, ptr getelementptr inbounds nuw (i8, ptr @c, i64 256), align 4\n %arrayidx12.promoted.1.i.5 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 60), align 4\n %conv14.1.i.5 = xor i32 %arrayidx12.promoted.1.i.5, 1\n store i32 %conv14.1.i.5, ptr getelementptr inbounds nuw (i8, ptr @c, i64 60), align 4\n %arrayidx12.promoted.5.i.5 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 220), align 4\n %conv14.5.i.5 = xor i32 %arrayidx12.promoted.5.i.5, 1\n store i32 %conv14.5.i.5, ptr getelementptr inbounds nuw (i8, ptr @c, i64 220), align 4\n %arrayidx12.promoted.6.i.5 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 260), align 4\n %conv14.6.i.5 = xor i32 %arrayidx12.promoted.6.i.5, 1\n %0 = or i32 %arrayidx12.promoted.6.i.4, %arrayidx12.promoted.1.i.5\n %or.1.5.i.5 = or i32 %0, %arrayidx12.promoted.5.i.5\n %or.1.6.i.5 = or i32 %or.1.5.i.5, %arrayidx12.promoted.6.i.5\n store i32 %conv14.6.i.5, ptr getelementptr inbounds nuw (i8, ptr @c, i64 260), align 4\n store i32 %or.1.6.i.5, ptr @j.0, align 4\n %arrayidx12.promoted.1.i.6 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 64), align 4\n %conv14.1.i.6 = xor i32 %arrayidx12.promoted.1.i.6, 1\n store i32 %conv14.1.i.6, ptr getelementptr inbounds nuw (i8, ptr @c, i64 64), align 4\n %arrayidx12.promoted.5.i.6 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 224), align 4\n %conv14.5.i.6 = xor i32 %arrayidx12.promoted.5.i.6, 1\n store i32 %conv14.5.i.6, ptr getelementptr inbounds nuw (i8, ptr @c, i64 224), align 4\n %arrayidx12.promoted.6.i.6 = load i32, ptr getelementptr inbounds nuw (i8, ptr @c, i64 264), align 4\n %conv14.6.i.6 = xor i32 %arrayidx12.promoted.6.i.6, 1\n store i32 %conv14.6.i.6, ptr getelementptr inbounds nuw (i8, ptr @c, i64 264), align 4\n ret void\n}",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "SLP Vectorizer Options trigger Assertion in cost computation on `s390x`",
"body": "While running experiments with `csmith`, i ran into the following example (already reduced with `cvise`):\n```C\nstatic int c[][10];\nshort d;\nlong *e;\nlong f;\nint g, k;\nchar h, i;\nstatic int j[3];\nvoid l();\nstatic int *m() {\n short *n = &d;\n d = 0;\n for (; d <= 2;)\n if (*n)\n ;\n else\n return j;\n return &g;\n}\nvoid p() { l(); }\nvoid l() {\n int *q;\n h = 0;\n for (; h <= 6; h++) {\n int **r = &q;\n *e = 4073709551615;\n *r = m();\n k = 0;\n for (; k <= 6; k++) {\n i = 2;\n for (; i <= 6; i++)\n **r |= c[k][h] ^= f;\n }\n }\n}\n```\n When compiling this with the options\n```\n -O3 \\\n -S \\\n -w \\\n -c \\\n -o a.out \\\n --target=s390x-ibm-linux \\\n -march=z13 \\\n -mllvm -slp-max-reg-size=256 \\\n -mllvm -slp-vectorize-hor-store \\\n -mllvm -slp-vectorize-non-power-of-2 \\\n -mllvm -enable-tbaa=false \\\n```\nThe assertion `(Idx + EltsPerVector) <= BaseVF && \"SK_ExtractSubvector index out of range\"` fails in `llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator::computeExtractCost`. This does not seem to be an issue on X86.\n\n[repro.tar.gz](https://github.com/user-attachments/files/20672338/repro.tar.gz)",
"author": "dominik-steenken",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
122558
|
https://github.com/llvm/llvm-project/issues/122558
|
crash
|
25f28ddd69ed2453726c0934ba6feea8ae6f10f8
| 2025-01-11T00:36:48 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "1de3dc7d23dd6b856efad3a3a04f2396328726d7",
"components": [
"LoopVectorize"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
4052,
4058
],
[
4064,
4069
]
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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::computeMaxVF"
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 1de3dc7d23dd6b856efad3a3a04f2396328726d7
Author: Florian Hahn <flo@fhahn.com>
Date: Tue Jan 14 22:07:38 2025 +0000
[LV] Bail out early if BTC+1 wraps.
Currently we fail to detect the case where BTC + 1 wraps, i.e. the
vector trip count is 0, In those cases, the minimum iteration count
check will fail, and the vector code will never be executed.
Explicitly check for this condition in computeMaxVF and avoid trying to
vectorize alltogether.
Note that a number of tests needed to be updated, because the vector
loop would never be executed given the input IR.
Fixes https://github.com/llvm/llvm-project/issues/122558.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 744faef19243..fe2fb5e9faae 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -4052,7 +4052,8 @@ LoopVectorizationCostModel::computeMaxVF(ElementCount UserVF, unsigned UserIC) {
return FixedScalableVFPair::getNone();
}
- unsigned TC = PSE.getSE()->getSmallConstantTripCount(TheLoop);
+ ScalarEvolution *SE = PSE.getSE();
+ unsigned TC = SE->getSmallConstantTripCount(TheLoop);
unsigned MaxTC = PSE.getSmallConstantMaxTripCount();
LLVM_DEBUG(dbgs() << "LV: Found trip count: " << TC << '\n');
if (TC != MaxTC)
@@ -4064,6 +4065,22 @@ LoopVectorizationCostModel::computeMaxVF(ElementCount UserVF, unsigned UserIC) {
return FixedScalableVFPair::getNone();
}
+ // If BTC matches the widest induction type and is -1 then the trip count
+ // computation will wrap to 0 and the vector trip count will be 0. Do not try
+ // to vectorize.
+ const SCEV *BTC = SE->getBackedgeTakenCount(TheLoop);
+ if (!isa<SCEVCouldNotCompute>(BTC) &&
+ BTC->getType()->getScalarSizeInBits() >=
+ Legal->getWidestInductionType()->getScalarSizeInBits() &&
+ SE->isKnownPredicate(CmpInst::ICMP_EQ, BTC,
+ SE->getMinusOne(BTC->getType()))) {
+ reportVectorizationFailure(
+ "Trip count computation wrapped",
+ "backedge-taken count is -1, loop trip count wrapped to 0",
+ "TripCountWrapped", ORE, TheLoop);
+ return FixedScalableVFPair::getNone();
+ }
+
switch (ScalarEpilogueStatus) {
case CM_ScalarEpilogueAllowed:
return computeFeasibleMaxVF(MaxTC, UserVF, false);
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-dot-product-epilogue.ll",
"commands": [
"opt -mattr=+dotprod -passes=loop-vectorize -force-vector-interleave=1 -S < %s"
],
"tests": [
{
"test_name": "dotp",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i32 @dotp(ptr %a, ptr %b) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = zext i8 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %accum\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n ret i32 %add\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-dot-product-mixed.ll",
"commands": [
"opt -passes=loop-vectorize -enable-epilogue-vectorization=false -mattr=+i8mm,+dotprod -S < %s",
"opt -passes=loop-vectorize -enable-epilogue-vectorization=false -mattr=+dotprod -S < %s"
],
"tests": [
{
"test_name": "dotp_z_s",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i32 @dotp_z_s(ptr %a, ptr %b) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = sext i8 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %accum\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n ret i32 %add\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "dotp_s_z",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i32 @dotp_s_z(ptr %a, ptr %b) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = sext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = zext i8 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %accum\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n ret i32 %add\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-dot-product-neon.ll",
"commands": [
"opt -passes=loop-vectorize -enable-epilogue-vectorization=false -mattr=+neon,+dotprod -force-vector-interleave=1 -S < %s",
"opt -passes=loop-vectorize -enable-epilogue-vectorization=false -mattr=+neon,+dotprod -S < %s",
"opt -passes=loop-vectorize -enable-epilogue-vectorization=false -mattr=+neon,+dotprod -force-vector-interleave=1 -vectorizer-maximize-bandwidth -S < %s"
],
"tests": [
{
"test_name": "dotp_unrolled",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\ndefine i32 @dotp_unrolled(i32 %num_out, i64 %num_in, ptr %a, ptr %b) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum3 = phi i32 [ 0, %entry ], [ %add.a3, %for.body ]\n %accum2 = phi i32 [ 0, %entry ], [ %add.a2, %for.body ]\n %accum1 = phi i32 [ 0, %entry ], [ %add.a1, %for.body ]\n %accum0 = phi i32 [ 0, %entry ], [ %add.a0, %for.body ]\n %gep.a0 = getelementptr inbounds i8, ptr %a, i64 %iv\n %gep.b0 = getelementptr inbounds i8, ptr %b, i64 %iv\n %offset.1 = or disjoint i64 %iv, 1\n %gep.a1 = getelementptr inbounds i8, ptr %a, i64 %offset.1\n %gep.b1 = getelementptr inbounds i8, ptr %b, i64 %offset.1\n %offset.2 = or disjoint i64 %iv, 2\n %gep.a2 = getelementptr inbounds i8, ptr %a, i64 %offset.2\n %gep.b2 = getelementptr inbounds i8, ptr %b, i64 %offset.2\n %offset.3 = or disjoint i64 %iv, 3\n %gep.a3 = getelementptr inbounds i8, ptr %a, i64 %offset.3\n %gep.b3 = getelementptr inbounds i8, ptr %b, i64 %offset.3\n %load.a0 = load i8, ptr %gep.a0, align 1\n %ext.a0 = sext i8 %load.a0 to i32\n %load.b0 = load i8, ptr %gep.b0, align 1\n %ext.b0 = sext i8 %load.b0 to i32\n %mul.a0 = mul nsw i32 %ext.b0, %ext.a0\n %add.a0 = add nsw i32 %mul.a0, %accum0\n %load.a1 = load i8, ptr %gep.a1, align 1\n %ext.a1 = sext i8 %load.a1 to i32\n %load.b1 = load i8, ptr %gep.b1, align 1\n %ext.b1 = sext i8 %load.b1 to i32\n %mul.a1 = mul nsw i32 %ext.a1, %ext.b1\n %add.a1 = add nsw i32 %mul.a1, %accum1\n %load.a2 = load i8, ptr %gep.a2, align 1\n %ext.a2 = sext i8 %load.a2 to i32\n %load.b2 = load i8, ptr %gep.b2, align 1\n %ext.b2 = sext i8 %load.b2 to i32\n %mul.a2 = mul nsw i32 %ext.a2, %ext.b2\n %add.a2 = add nsw i32 %mul.a2, %accum2\n %load.a3 = load i8, ptr %gep.a3, align 1\n %ext.a3 = sext i8 %load.a3 to i32\n %load.b3 = load i8, ptr %gep.b3, align 1\n %ext.b3 = sext i8 %load.b3 to i32\n %mul.a3 = mul nsw i32 %ext.a3, %ext.b3\n %add.a3 = add nsw i32 %mul.a3, %accum3\n %iv.next = add nuw nsw i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, %num_in\n br i1 %exitcond.not, label %exit, label %for.body\n\nexit: ; preds = %for.body\n %result0 = add nsw i32 %add.a0, %add.a1\n %result1 = add nsw i32 %add.a2, %add.a3\n %result = add nsw i32 %result0, %result1\n ret i32 %result\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "dotp",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\ndefine i32 @dotp(ptr %a, ptr %b) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = zext i8 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %accum\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n ret i32 %add\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "not_dotp_predicated_pragma",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\ndefine i32 @not_dotp_predicated_pragma(i64 %N, ptr %a, ptr %b) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr inbounds i8, ptr %b, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = sext i8 %load.a to i32\n %gep.a2 = getelementptr inbounds i8, ptr %a, i64 %iv\n %load.b = load i8, ptr %gep.a2, align 1\n %ext.b = sext i8 %load.b to i32\n %mul = mul nsw i32 %ext.b, %ext.a\n %add = add nsw i32 %mul, %accum\n %iv.next = add nuw nsw i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, %N\n br i1 %exitcond.not, label %exit, label %for.body, !llvm.loop !0\n\nexit: ; preds = %for.body\n ret i32 %add\n}\n\n!0 = distinct !{!0, !1, !2, !3}\n!1 = !{!\"llvm.loop.mustprogress\"}\n!2 = !{!\"llvm.loop.vectorize.predicate.enable\", i1 true}\n!3 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "not_dotp_not_loop_carried",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\ndefine i32 @not_dotp_not_loop_carried(ptr %a, ptr %b) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %mul, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = zext i8 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %accum\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n ret i32 %add\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "not_dotp_different_types",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\ndefine i32 @not_dotp_different_types(ptr %a, ptr %b) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i16, ptr %gep.b, align 2\n %ext.b = zext i16 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %accum\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n ret i32 %add\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "not_dotp_not_phi",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\ndefine i32 @not_dotp_not_phi(ptr %a, ptr %b) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = zext i8 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %ext.b\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n ret i32 %add\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "not_dotp_extend_user",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\ndefine i32 @not_dotp_extend_user(ptr %a, ptr %b) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = zext i8 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %accum\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n %result = add i32 %add, %ext.b\n ret i32 %result\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "not_dotp_predicated",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\ndefine i32 @not_dotp_predicated(i64 %N, ptr %a, ptr %b) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr inbounds i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = sext i8 %load.a to i32\n %gep.b = getelementptr inbounds i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = sext i8 %load.b to i32\n %mul = mul nsw i32 %ext.b, %ext.a\n %add = add nsw i32 %mul, %accum\n %iv.next = add nuw nsw i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, %N\n br i1 %exitcond.not, label %exit, label %for.body\n\nexit: ; preds = %for.body\n ret i32 %add\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-dot-product.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-interleave=1 -enable-epilogue-vectorization=false -S < %s",
"opt -passes=loop-vectorize -enable-epilogue-vectorization=false -S < %s",
"opt -passes=loop-vectorize -force-vector-interleave=1 -vectorizer-maximize-bandwidth -enable-epilogue-vectorization=false -S < %s"
],
"tests": [
{
"test_name": "not_dotp_not_phi2",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine void @not_dotp_not_phi2(ptr %matrix, i32 %n) #0 {\nentry:\n %cmp = icmp sgt i32 %n, 0\n br i1 %cmp, label %for.preheader, label %exit\n\nfor.preheader: ; preds = %entry\n %load.a = load i8, ptr null, align 1\n %load.a1 = load i8, ptr inttoptr (i64 1 to ptr), align 1\n %a.ext = sext i8 %load.a to i32\n %a.ext1 = sext i8 %load.a1 to i32\n br label %for.body\n\nfor.body: ; preds = %for.body, %for.preheader\n %iv = phi i32 [ %iv.next, %for.body ], [ 0, %for.preheader ]\n %ptr = phi ptr [ %scevgep, %for.body ], [ %matrix, %for.preheader ]\n %accum = phi i32 [ %add.1, %for.body ], [ 0, %for.preheader ]\n %gep.b = getelementptr i8, ptr %ptr, i64 1\n %gep.b1 = getelementptr i8, ptr %ptr, i64 2\n %load.b = load i8, ptr %gep.b, align 1\n %b.ext = sext i8 %load.b to i32\n %mul = mul nsw i32 %a.ext, %b.ext\n %add = add i32 %mul, %accum\n %load.b1 = load i8, ptr %gep.b1, align 1\n %b.ext1 = sext i8 %load.b1 to i32\n %mul.1 = mul nsw i32 %a.ext1, %b.ext1\n %add.1 = add i32 %mul.1, %add\n %scevgep = getelementptr i8, ptr %ptr, i64 16\n %iv.next = add nuw nsw i32 %iv, 1\n %exitcond.not = icmp eq i32 %iv.next, %n\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n %add.1.lcssa = phi i32 [ %add.1, %for.body ]\n %add.float = sitofp i32 %add.1.lcssa to float\n br label %exit\n\nexit: ; preds = %for.exit, %entry\n %result = phi float [ 0.000000e+00, %entry ], [ %add.float, %for.exit ]\n store float %result, ptr %matrix, align 4\n ret void\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "not_dotp_ext_outside_plan2",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i64 @not_dotp_ext_outside_plan2(ptr %a, i16 %b, i64 %n) #0 {\nentry:\n %cmp = icmp eq i64 %n, 0\n br i1 %cmp, label %exit, label %for.ph\n\nfor.ph: ; preds = %entry\n %ext.b = zext i16 %b to i64\n br label %for.body\n\nfor.body: ; preds = %for.body, %for.ph\n %iv = phi i64 [ 0, %for.ph ], [ %iv.next, %for.body ]\n %accum = phi i64 [ 0, %for.ph ], [ %add, %for.body ]\n %gep.a = getelementptr inbounds nuw i16, ptr %a, i64 %iv\n %load.a = load i16, ptr %gep.a, align 2\n %ext.a = zext i16 %load.a to i64\n %mul = mul nuw nsw i64 %ext.b, %ext.a\n %add = add i64 %mul, %accum\n %iv.next = add nuw nsw i64 %iv, 1\n %cmp.1 = icmp eq i64 %iv.next, %n\n br i1 %cmp.1, label %exit, label %for.body\n\nexit: ; preds = %for.body, %entry\n %result = phi i64 [ 0, %entry ], [ %add, %for.body ]\n ret i64 %result\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "dotp_unrolled",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i32 @dotp_unrolled(i32 %num_out, i64 %num_in, ptr %a, ptr %b) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum3 = phi i32 [ 0, %entry ], [ %add.a3, %for.body ]\n %accum2 = phi i32 [ 0, %entry ], [ %add.a2, %for.body ]\n %accum1 = phi i32 [ 0, %entry ], [ %add.a1, %for.body ]\n %accum0 = phi i32 [ 0, %entry ], [ %add.a0, %for.body ]\n %gep.a0 = getelementptr inbounds i8, ptr %a, i64 %iv\n %gep.b0 = getelementptr inbounds i8, ptr %b, i64 %iv\n %offset.1 = or disjoint i64 %iv, 1\n %gep.a1 = getelementptr inbounds i8, ptr %a, i64 %offset.1\n %gep.b1 = getelementptr inbounds i8, ptr %b, i64 %offset.1\n %offset.2 = or disjoint i64 %iv, 2\n %gep.a2 = getelementptr inbounds i8, ptr %a, i64 %offset.2\n %gep.b2 = getelementptr inbounds i8, ptr %b, i64 %offset.2\n %offset.3 = or disjoint i64 %iv, 3\n %gep.a3 = getelementptr inbounds i8, ptr %a, i64 %offset.3\n %gep.b3 = getelementptr inbounds i8, ptr %b, i64 %offset.3\n %load.a0 = load i8, ptr %gep.a0, align 1\n %ext.a0 = sext i8 %load.a0 to i32\n %load.b0 = load i8, ptr %gep.b0, align 1\n %ext.b0 = sext i8 %load.b0 to i32\n %mul.a0 = mul nsw i32 %ext.b0, %ext.a0\n %add.a0 = add nsw i32 %mul.a0, %accum0\n %load.a1 = load i8, ptr %gep.a1, align 1\n %ext.a1 = sext i8 %load.a1 to i32\n %load.b1 = load i8, ptr %gep.b1, align 1\n %ext.b1 = sext i8 %load.b1 to i32\n %mul.a1 = mul nsw i32 %ext.a1, %ext.b1\n %add.a1 = add nsw i32 %mul.a1, %accum1\n %load.a2 = load i8, ptr %gep.a2, align 1\n %ext.a2 = sext i8 %load.a2 to i32\n %load.b2 = load i8, ptr %gep.b2, align 1\n %ext.b2 = sext i8 %load.b2 to i32\n %mul.a2 = mul nsw i32 %ext.a2, %ext.b2\n %add.a2 = add nsw i32 %mul.a2, %accum2\n %load.a3 = load i8, ptr %gep.a3, align 1\n %ext.a3 = sext i8 %load.a3 to i32\n %load.b3 = load i8, ptr %gep.b3, align 1\n %ext.b3 = sext i8 %load.b3 to i32\n %mul.a3 = mul nsw i32 %ext.a3, %ext.b3\n %add.a3 = add nsw i32 %mul.a3, %accum3\n %iv.next = add nuw nsw i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, %num_in\n br i1 %exitcond.not, label %exit, label %for.body\n\nexit: ; preds = %for.body\n %result0 = add nsw i32 %add.a0, %add.a1\n %result1 = add nsw i32 %add.a2, %add.a3\n %result = add nsw i32 %result0, %result1\n ret i32 %result\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "dotp",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i32 @dotp(ptr %a, ptr %b) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = zext i8 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %accum\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n ret i32 %add\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "not_dotp_predicated_pragma",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i32 @not_dotp_predicated_pragma(i64 %N, ptr %a, ptr %b) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr inbounds i8, ptr %b, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = sext i8 %load.a to i32\n %gep.a2 = getelementptr inbounds i8, ptr %a, i64 %iv\n %load.b = load i8, ptr %gep.a2, align 1\n %ext.b = sext i8 %load.b to i32\n %mul = mul nsw i32 %ext.b, %ext.a\n %add = add nsw i32 %mul, %accum\n %iv.next = add nuw nsw i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, %N\n br i1 %exitcond.not, label %exit, label %for.body, !llvm.loop !0\n\nexit: ; preds = %for.body\n ret i32 %add\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n\n!0 = distinct !{!0, !1, !2, !3}\n!1 = !{!\"llvm.loop.mustprogress\"}\n!2 = !{!\"llvm.loop.vectorize.predicate.enable\", i1 true}\n!3 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "dotp_cost_disagreement",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i64 @dotp_cost_disagreement(ptr %a, ptr %b) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %i.iv = phi i64 [ 0, %entry ], [ %i.iv.next, %for.body ]\n %sum = phi i64 [ 0, %entry ], [ %add, %for.body ]\n %arrayidx = getelementptr inbounds nuw i8, ptr %a, i64 %i.iv\n %0 = load i8, ptr %arrayidx, align 1\n %conv = zext i8 %0 to i64\n %i.iv.next = add nuw nsw i64 %i.iv, 1\n %arrayidx2 = getelementptr inbounds nuw i8, ptr %b, i64 %i.iv.next\n %1 = load i8, ptr %arrayidx2, align 1\n %conv3 = zext i8 %1 to i64\n %mul = mul nuw nsw i64 %conv3, %conv\n %add = add i64 %sum, %mul\n %exitcond.not = icmp eq i64 %i.iv.next, 16\n br i1 %exitcond.not, label %exit, label %for.body\n\nexit: ; preds = %for.body\n ret i64 %add\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "not_dotp_not_loop_carried",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i32 @not_dotp_not_loop_carried(ptr %a, ptr %b) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %mul, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = zext i8 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %accum\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n ret i32 %add\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "not_dotp_different_types",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i32 @not_dotp_different_types(ptr %a, ptr %b) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i16, ptr %gep.b, align 2\n %ext.b = zext i16 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %accum\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n ret i32 %add\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "not_dotp_not_phi",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i32 @not_dotp_not_phi(ptr %a, ptr %b) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = zext i8 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %ext.b\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n ret i32 %add\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "not_dotp_extend_user",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i32 @not_dotp_extend_user(ptr %a, ptr %b) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = zext i8 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %accum\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n %result = add i32 %add, %ext.b\n ret i32 %result\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "not_dotp_ext_outside_plan",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i64 @not_dotp_ext_outside_plan(ptr %a, i16 %b, i64 %n) #0 {\nentry:\n %cmp = icmp eq i64 %n, 0\n br i1 %cmp, label %exit, label %for.ph\n\nfor.ph: ; preds = %entry\n %ext.b = zext i16 %b to i64\n br label %for.body\n\nfor.body: ; preds = %for.body, %for.ph\n %iv = phi i64 [ 0, %for.ph ], [ %iv.next, %for.body ]\n %accum = phi i64 [ 0, %for.ph ], [ %add, %for.body ]\n %gep.a = getelementptr inbounds nuw i16, ptr %a, i64 %iv\n %load.a = load i16, ptr %gep.a, align 2\n %ext.a = zext i16 %load.a to i64\n %mul = mul nuw nsw i64 %ext.a, %ext.b\n %add = add i64 %mul, %accum\n %iv.next = add nuw nsw i64 %iv, 1\n %cmp.1 = icmp eq i64 %iv.next, %n\n br i1 %cmp.1, label %exit, label %for.body\n\nexit: ; preds = %for.body, %entry\n %result = phi i64 [ 0, %entry ], [ %add, %for.body ]\n ret i64 %result\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "not_dotp_predicated",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\n; Function Attrs: vscale_range(1,16)\ndefine i32 @not_dotp_predicated(i64 %N, ptr %a, ptr %b) #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr inbounds i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = sext i8 %load.a to i32\n %gep.b = getelementptr inbounds i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = sext i8 %load.b to i32\n %mul = mul nsw i32 %ext.b, %ext.a\n %add = add nsw i32 %mul, %accum\n %iv.next = add nuw nsw i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, %N\n br i1 %exitcond.not, label %exit, label %for.body\n\nexit: ; preds = %for.body\n ret i32 %add\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-no-dotprod.ll",
"commands": [
"opt -passes=loop-vectorize -enable-epilogue-vectorization=false -mattr=+neon -S < %s"
],
"tests": [
{
"test_name": "not_dotp",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\ndefine i32 @not_dotp(ptr %a, ptr %b) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = zext i8 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %accum\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1000\n br i1 %exitcond.not, label %for.exit, label %for.body\n\nfor.exit: ; preds = %for.body\n ret i32 %add\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/store-costs-sve.ll",
"commands": [
"opt -p loop-vectorize -S %s",
"opt -p loop-vectorize -prefer-predicate-over-epilogue=predicate-else-scalar-epilogue -S %s"
],
"tests": [
{
"test_name": "trunc_store",
"test_body": "target datalayout = \"e-m:o-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"arm64-apple-macosx14.0.0\"\n\n; Function Attrs: vscale_range(1,16)\ndefine void @trunc_store(ptr %dst, ptr %src, i16 %x) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %x.ext = zext i16 %x to i64\n %l = load i64, ptr %src, align 8\n %and = and i64 %l, %x.ext\n %trunc = trunc i64 %and to i8\n %gep = getelementptr i8, ptr %dst, i64 %iv\n store i8 %trunc, ptr %gep, align 1\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv.next, 1000\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { vscale_range(1,16) \"target-features\"=\"+sve\" }\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/AArch64/vplan-printing.ll",
"commands": [
"opt -mattr=+neon,+dotprod -passes=loop-vectorize -debug-only=loop-vectorize -force-vector-interleave=1 -disable-output %s 2>&1"
],
"tests": [
{
"test_name": "print_partial_reduction",
"test_body": "target datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"aarch64-none-unknown-elf\"\n\ndefine i32 @print_partial_reduction(ptr %a, ptr %b) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]\n %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]\n %gep.a = getelementptr i8, ptr %a, i64 %iv\n %load.a = load i8, ptr %gep.a, align 1\n %ext.a = zext i8 %load.a to i32\n %gep.b = getelementptr i8, ptr %b, i64 %iv\n %load.b = load i8, ptr %gep.b, align 1\n %ext.b = zext i8 %load.b to i32\n %mul = mul i32 %ext.b, %ext.a\n %add = add i32 %mul, %accum\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv.next, 1024\n br i1 %exitcond.not, label %exit, label %for.body\n\nexit: ; preds = %for.body\n ret i32 %add\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/Hexagon/maximum-vf-crash.ll",
"commands": [
"opt -mtriple=hexagon -hexagon-autohvx -passes=loop-vectorize -S < %s 2>&1"
],
"tests": [
{
"test_name": "f",
"test_body": "target datalayout = \"e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048\"\n\n; Function Attrs: optsize\ndefine i32 @f(ptr %src) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %g.016 = phi i32 [ 0, %entry ], [ %g.1.lcssa, %loop ]\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %0 = load i8, ptr %src, align 1\n %g.1.lcssa = add i32 %g.016, 1\n %iv.next = add nsw i32 %iv, 1\n %exitcond = icmp eq i32 %iv.next, 1000\n br i1 %exitcond, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i32 %g.1.lcssa\n}\n\nattributes #0 = { optsize \"target-features\"=\"+hvx-length128b\" }\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/X86/cost-constant-known-via-scev.ll",
"commands": [
"opt -p loop-vectorize -S %s"
],
"tests": [
{
"test_name": "second_lshr_operand_zero_via_scev",
"test_body": "target datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i64 @second_lshr_operand_zero_via_scev() {\nentry:\n %ext.0 = sext i8 0 to i32\n br label %loops\n\nloops: ; preds = %loops, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loops ]\n %red = phi i64 [ 0, %entry ], [ %red.next, %loops ]\n %c = icmp eq i64 %iv, 0\n %and = and i64 %iv, 0\n %0 = trunc i64 %iv to i32\n %shr = lshr i32 %0, %ext.0\n %conv.1 = zext i32 %shr to i64\n %red.next.v = select i1 %c, i64 %and, i64 %conv.1\n %red.next = or i64 %red.next.v, %red\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv.next, 1000\n br i1 %ec, label %exit, label %loops\n\nexit: ; preds = %loops\n %res = phi i64 [ %red.next, %loops ]\n ret i64 %res\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/X86/cost-model.ll",
"commands": [
"opt < %s -passes=loop-vectorize -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7-avx -S"
],
"tests": [
{
"test_name": "narrowed_reduction",
"test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-apple-macosx10.8.0\"\n\ndefine i32 @narrowed_reduction(ptr %a, i1 %cmp) #0 {\nentry:\n %conv = zext i1 %cmp to i32\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 1, %entry ], [ %inc, %loop ]\n %or13 = phi i32 [ 0, %entry ], [ %or, %loop ]\n %and = and i32 %or13, 1\n %or = or i32 %and, %conv\n %inc = add i32 %iv, 1\n %ec = icmp eq i32 %iv, 16\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i32 %or\n}\n\nattributes #0 = { \"target-cpu\"=\"penryn\" }\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/X86/drop-poison-generating-flags.ll",
"commands": [
"opt %s -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -S"
],
"tests": [
{
"test_name": "drop_zext_nneg",
"test_body": "target datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-pc-linux-gnu\"\n\n; Function Attrs: noinline nounwind uwtable\ndefine void @drop_zext_nneg(ptr noalias %p, ptr noalias %p1) #0 {\nentry:\n br label %body\n\nbody: ; preds = %else, %entry\n %iv = phi i64 [ %next, %else ], [ 0, %entry ]\n %0 = trunc i64 %iv to i32\n %c = icmp eq i32 %0, 0\n br i1 %c, label %then, label %else\n\nthen: ; preds = %body\n %zext = zext nneg i32 %0 to i64\n %idx1 = getelementptr double, ptr %p, i64 %zext\n %idx2 = getelementptr double, ptr %p, i64 %zext\n %1 = load double, ptr %idx2, align 8\n br label %else\n\nelse: ; preds = %then, %body\n %phi = phi double [ %1, %then ], [ 0.000000e+00, %body ]\n store double %phi, ptr %p1, align 8\n %next = add i64 %iv, 1\n %cmp = icmp eq i64 %next, 1024\n br i1 %cmp, label %exit, label %body\n\nexit: ; preds = %else\n ret void\n}\n\nattributes #0 = { noinline nounwind uwtable \"target-features\"=\"+avx512bw,+avx512cd,+avx512dq,+avx512f,+avx512vl\" }\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/X86/interleave-cost.ll",
"commands": [
"opt -p loop-vectorize -S %s"
],
"tests": [
{
"test_name": "test_free_instructions_feeding_geps_for_interleave_groups",
"test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-apple-macosx10.15.0\"\n\ndefine void @test_free_instructions_feeding_geps_for_interleave_groups(ptr noalias %p.invar, ptr noalias %dst.1, ptr noalias %dst.2) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %l.0 = load float, ptr %p.invar, align 4\n %iv.mul = shl i64 %iv, 2\n %gep.dst.19 = getelementptr float, ptr %dst.1, i64 %iv.mul\n store float %l.0, ptr %gep.dst.19, align 4\n %l.1 = load float, ptr %p.invar, align 4\n %add.1 = or disjoint i64 %iv.mul, 1\n %gep.dst.119 = getelementptr float, ptr %dst.1, i64 %add.1\n store float %l.1, ptr %gep.dst.119, align 4\n %add.2 = or disjoint i64 %iv.mul, 2\n %gep.dst.129 = getelementptr float, ptr %dst.1, i64 %add.2\n store float 0.000000e+00, ptr %gep.dst.129, align 4\n %add.3 = or disjoint i64 %iv.mul, 3\n %gep.dst.140 = getelementptr float, ptr %dst.1, i64 %add.3\n store float 0.000000e+00, ptr %gep.dst.140, align 4\n %l.2 = load float, ptr %p.invar, align 4\n %gep.dst.247 = getelementptr float, ptr %dst.2, i64 %iv.mul\n store float %l.2, ptr %gep.dst.247, align 4\n %gep.dst.255 = getelementptr float, ptr %dst.2, i64 %add.1\n store float 0.000000e+00, ptr %gep.dst.255, align 4\n %gep.dst.265 = getelementptr float, ptr %dst.2, i64 %add.2\n store float 0.000000e+00, ptr %gep.dst.265, align 4\n %gep.dst.276 = getelementptr float, ptr %dst.2, i64 %add.3\n store float 0.000000e+00, ptr %gep.dst.276, align 4\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv.next, 1024\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/X86/replicate-uniform-call.ll",
"commands": [
"opt -p loop-vectorize -S %s"
],
"tests": [
{
"test_name": "smax_call_uniform",
"test_body": "target datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @smax_call_uniform(ptr %dst, i64 %x) {\nentry:\n %c = icmp ult i8 -68, -69\n %mul = mul nuw nsw i64 %x, 0\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n br i1 %c, label %loop.latch, label %else\n\nelse: ; preds = %loop.header\n %rem = urem i64 %mul, %x\n %smax = tail call i64 @llvm.smax.i64(i64 %rem, i64 0)\n br label %loop.latch\n\nloop.latch: ; preds = %else, %loop.header\n %p = phi i64 [ 1, %loop.header ], [ %smax, %else ]\n %add = add i64 %p, 1\n %gep = getelementptr i64, ptr %dst, i64 %add\n store i64 0, ptr %gep, align 8\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv.next, 1024\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i64 @llvm.smax.i64(i64, i64) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/epilog-vectorization-vector-trip-count-zero.ll",
"commands": [
"opt -p loop-vectorize -force-vector-width=2 -epilogue-vectorization-force-VF=2 -S %s"
],
"tests": [
{
"test_name": "vector_trip_count_0_as_btc_is_all_1",
"test_body": "target datalayout = \"E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64\"\n\ndefine void @vector_trip_count_0_as_btc_is_all_1(ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.next = add i32 %iv, -1\n %gep = getelementptr inbounds i32, ptr %dst, i32 %iv\n store i32 %iv.next, ptr %gep, align 4\n %ec = icmp eq i32 %iv.next, 0\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"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, 1000\n br i1 %cond, label %End, label %Loop\n\nEnd: ; preds = %Loop\n %res.1 = fadd double %for.1, %for.2\n %res.2 = fadd double %res.1, %for.3\n ret double %res.2\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/if-pred-stores.ll",
"commands": [
"opt -S -vectorize-num-stores-pred=1 -force-vector-width=1 -force-vector-interleave=2 -passes=loop-vectorize,simplifycfg -verify-loop-info -simplifycfg-require-and-preserve-domtree=1 < %s",
"opt -S -vectorize-num-stores-pred=1 -force-vector-width=1 -force-vector-interleave=2 -passes=loop-vectorize -verify-loop-info < %s",
"opt -S -vectorize-num-stores-pred=1 -force-vector-width=2 -force-vector-interleave=1 -passes=loop-vectorize,simplifycfg -verify-loop-info -simplifycfg-require-and-preserve-domtree=1 < %s"
],
"tests": [
{
"test_name": "minimal_bit_widths_with_aliasing_store",
"test_body": "target datalayout = \"e-m:o-i64:64-f80:128-n8:16:32:64-S128\"\n\ndefine void @minimal_bit_widths_with_aliasing_store(i1 %c, ptr %ptr) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.inc, %entry\n %tmp0 = phi i64 [ %tmp6, %for.inc ], [ 0, %entry ]\n %tmp1 = phi i64 [ %tmp7, %for.inc ], [ 1000, %entry ]\n %tmp2 = getelementptr i8, ptr %ptr, i64 %tmp0\n %tmp3 = load i8, ptr %tmp2, align 1\n store i8 0, ptr %tmp2, align 1\n br i1 %c, label %if.then, label %for.inc\n\nif.then: ; preds = %for.body\n %tmp4 = zext i8 %tmp3 to i32\n %tmp5 = trunc i32 %tmp4 to i8\n store i8 %tmp5, ptr %tmp2, align 1\n br label %for.inc\n\nfor.inc: ; preds = %if.then, %for.body\n %tmp6 = add nuw nsw i64 %tmp0, 1\n %tmp7 = add i64 %tmp1, -1\n %tmp8 = icmp eq i64 %tmp7, 0\n br i1 %tmp8, label %for.end, label %for.body\n\nfor.end: ; preds = %for.inc\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/induction.ll",
"commands": [
"opt < %s -passes=loop-vectorize -force-vector-interleave=1 -force-vector-width=2 -force-widen-divrem-via-safe-divisor=0 -S",
"opt < %s -passes=loop-vectorize,instcombine -force-vector-interleave=1 -force-vector-width=2 -force-widen-divrem-via-safe-divisor=0 -S",
"opt < %s -passes=loop-vectorize,instcombine -force-vector-interleave=2 -force-vector-width=2 -force-widen-divrem-via-safe-divisor=0 -S",
"opt < %s -passes=loop-vectorize -force-vector-interleave=2 -force-vector-width=2 -force-widen-divrem-via-safe-divisor=0 -S",
"opt < %s -passes=loop-vectorize,instcombine -force-vector-interleave=2 -force-vector-width=4 -force-widen-divrem-via-safe-divisor=0 -enable-interleaved-mem-accesses -S"
],
"tests": [
{
"test_name": "max_i32_backedgetaken",
"test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine i32 @max_i32_backedgetaken() {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %a.0 = phi i32 [ 1, %entry ], [ %a.0.and, %loop ]\n %b.0 = phi i32 [ 0, %entry ], [ %b.next, %loop ]\n %a.0.and = and i32 %a.0, 4\n %b.next = add i32 %b.0, -1\n %ec = icmp eq i32 %b.next, 0\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i32 %a.0.and\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/interleave-and-scalarize-only.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-width=1 -force-vector-interleave=2 -debug -disable-output %s 2>&1",
"opt -passes=loop-vectorize -force-vector-width=1 -force-vector-interleave=2 -S %s"
],
"tests": [
{
"test_name": "scalarize_ptrtoint",
"test_body": "define void @scalarize_ptrtoint(ptr %src, ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep = getelementptr ptr, ptr %src, i64 %iv\n %l = load ptr, ptr %gep, align 8\n %cast = ptrtoint ptr %l to i64\n %add = add i64 %cast, 10\n %cast.2 = inttoptr i64 %add to ptr\n store ptr %cast.2, ptr %dst, align 8\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv.next, 1024\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/is_fpclass.ll",
"commands": [
"opt < %s -passes=loop-vectorize -force-vector-width=2 -S"
],
"tests": [
{
"test_name": "d",
"test_body": "define void @d() {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %i = phi i64 [ 0, %entry ], [ %i7, %loop ]\n %i3 = load float, ptr null, align 4\n %i4 = getelementptr float, ptr @d, i64 %i\n %i5 = tail call i1 @llvm.is.fpclass.f32(float %i3, i32 0)\n %i6 = select i1 %i5, float 0.000000e+00, float 0.000000e+00\n store float %i6, ptr %i4, align 4\n %i7 = add i64 %i, 1\n %i8 = icmp eq i64 %i7, 128\n br i1 %i8, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i1 @llvm.is.fpclass.f32(float, i32 immarg) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/optimal-epilog-vectorization.ll",
"commands": [
"opt -passes='loop-vectorize' -force-vector-width=4 -enable-epilogue-vectorization -epilogue-vectorization-force-VF=4 -S %s",
"opt -passes='loop-vectorize' -enable-epilogue-vectorization -epilogue-vectorization-force-VF=2 -S %s"
],
"tests": [
{
"test_name": "multiple_ivs_wide",
"test_body": "target datalayout = \"e-m:e-i64:64-n32:64-v128:128:128\"\n\ndefine void @multiple_ivs_wide(ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.2 = phi i32 [ -64, %entry ], [ %iv.2.next, %loop ]\n %iv.next = add i32 %iv, 2\n %iv.2.next = add i32 %iv.2, 2\n %gep = getelementptr inbounds i32, ptr %dst, i32 %iv\n store i32 %iv.2.next, ptr %gep, align 4\n %ec = icmp eq i32 %iv.next, 128\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/runtime-checks-hoist.ll",
"commands": [
"opt < %s -passes='loop-vectorize' -force-vector-interleave=1 -S -force-vector-width=4 -debug-only=loop-accesses,loop-vectorize,loop-utils"
],
"tests": [
{
"test_name": "stride_check_known_via_loop_guard",
"test_body": "target datalayout = \"e-m:e-i64:64-i128:128-n32:64-S128\"\n\ndefine void @stride_check_known_via_loop_guard(ptr %C, ptr %A, i32 %Acols) {\nentry:\n %pre.c = icmp ugt i32 %Acols, 0\n br i1 %pre.c, label %exit, label %outer.header\n\nouter.header: ; preds = %outer.latch, %entry\n %outer.iv = phi i32 [ 0, %entry ], [ %outer.iv.next, %outer.latch ]\n %mul.us = mul i32 %outer.iv, %Acols\n %arrayidx.us = getelementptr double, ptr %A, i32 %mul.us\n br label %inner\n\ninner: ; preds = %inner, %outer.header\n %inner.iv = phi i32 [ 0, %outer.header ], [ %inner.iv.next, %inner ]\n %gep.C = getelementptr inbounds double, ptr %C, i32 %inner.iv\n %l = load double, ptr %arrayidx.us, align 8\n store double %l, ptr %gep.C, align 8\n %inner.iv.next = add i32 %inner.iv, 1\n %inner.c = icmp eq i32 %inner.iv.next, 1000\n br i1 %inner.c, label %outer.latch, label %inner\n\nouter.latch: ; preds = %inner\n %outer.iv.next = add i32 %outer.iv, 1\n %outer.c = icmp ult i32 %outer.iv, 128\n br i1 %outer.c, label %exit, label %outer.header\n\nexit: ; preds = %outer.latch, %entry\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/scev-predicate-reasoning.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -lv-strided-pointer-ivs=true -S %s"
],
"tests": [
{
"test_name": "step_direction_unknown",
"test_body": "define void @step_direction_unknown(i32 %arg, ptr %dst) {\nentry:\n %add = add i32 %arg, 1\n br label %loop\n\nloop: ; preds = %loop, %entry\n %phi = phi i64 [ 0, %entry ], [ %add2, %loop ]\n %trunc = trunc i64 %phi to i32\n %mul = mul i32 %add, %trunc\n %zext = zext i32 %mul to i64\n %getelementptr = getelementptr double, ptr %dst, i64 %zext\n store double 0.000000e+00, ptr %getelementptr, align 8\n %add2 = add i64 %phi, 1\n %icmp = icmp eq i64 %add2, 1024\n br i1 %icmp, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "integer_induction_wraps_scev_predicate_known",
"test_body": "define void @integer_induction_wraps_scev_predicate_known(i32 %x, ptr %call, ptr %start) {\nentry:\n %mul = shl i32 %x, 1\n br label %for.cond\n\nfor.cond: ; preds = %for.cond, %entry\n %iv = phi i32 [ 30, %entry ], [ %inc, %for.cond ]\n %p.0 = phi ptr [ %start, %entry ], [ %add.ptr, %for.cond ]\n %add.ptr = getelementptr i8, ptr %p.0, i32 %mul\n %arrayidx = getelementptr ptr, ptr %call, i32 %iv\n store ptr %p.0, ptr %arrayidx, align 4\n %inc = add i32 %iv, 1\n %tobool.not = icmp eq i32 %iv, 1024\n br i1 %tobool.not, label %for.end, label %for.cond\n\nfor.end: ; preds = %for.cond\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/LoopVectorize/vplan-sink-scalars-and-merge-vf1.ll",
"commands": [
"opt -passes=loop-vectorize -force-vector-interleave=2 -force-vector-width=1 -debug -disable-output %s 2>&1"
],
"tests": [
{
"test_name": "sink_with_sideeffects",
"test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n\ndefine void @sink_with_sideeffects(i1 %c, ptr %ptr) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.inc, %entry\n %tmp0 = phi i64 [ %tmp6, %for.inc ], [ 0, %entry ]\n %tmp1 = phi i64 [ %tmp7, %for.inc ], [ 1024, %entry ]\n %tmp2 = getelementptr i8, ptr %ptr, i64 %tmp0\n %tmp3 = load i8, ptr %tmp2, align 1\n store i8 0, ptr %tmp2, align 1\n %tmp4 = zext i8 %tmp3 to i32\n %tmp5 = trunc i32 %tmp4 to i8\n br i1 %c, label %if.then, label %for.inc\n\nif.then: ; preds = %for.body\n store i8 %tmp5, ptr %tmp2, align 1\n br label %for.inc\n\nfor.inc: ; preds = %if.then, %for.body\n %tmp6 = add nuw nsw i64 %tmp0, 1\n %tmp7 = add i64 %tmp1, -1\n %tmp8 = icmp eq i64 %tmp7, 0\n br i1 %tmp8, label %for.end, label %for.body\n\nfor.end: ; preds = %for.inc\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[LoopVectorizer] Assertion `EPResumeVal && \"must have a resume value for the canonical IV\"' failed.",
"body": "clang -Wno-incompatible-pointer-types -O3 -march=z13 -S -c crash19.i -o a.out -w -mllvm -disable-licm-promotion -mllvm -epilogue-vectorization-force-VF=2 \n\n[crash19.tar.gz](https://github.com/user-attachments/files/18383534/crash19.tar.gz)\n\n#9 0x000002aa3ff5e440 preparePlanForEpilogueVectorLoop\n#12 0x000002aa3ffa098a llvm::LoopVectorizePass::run\n\n@bmahjour \n@fhahn ",
"author": "JonPsson1",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "fhahn",
"body": "@JonPsson1 Was the test case fuzzer generated? Just curious, because it had a loop with unsigned max as iteration count."
},
{
"author": "JonPsson1",
"body": "> [@JonPsson1](https://github.com/JonPsson1) Was the test case fuzzer generated? Just curious, because it had a loop with unsigned max as iteration count.\n\nNo, it was a CSmith test case."
},
{
"author": "fhahn",
"body": "@JonPsson1 Could you check if it fixes the full reproducer? If not, it would be great if you could share the full reproducer?"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
100591
|
https://github.com/llvm/llvm-project/issues/100591
|
crash
|
71801707e33c235656b172fa7dfb8662473a95c2
| 2024-07-25T16:31:43 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "e9e3a183d6d8d8729223b7131aa57fd9f02f0440",
"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": [
[
6730,
6738
],
[
6765,
6770
],
[
6789,
6796
]
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 e9e3a183d6d8d8729223b7131aa57fd9f02f0440
Author: Florian Hahn <flo@fhahn.com>
Date: Sun Aug 18 12:51:17 2024 +0100
[LV] Don't cost branches and conditions to empty blocks.
Update the legacy cost model skip branches with successors blocks
that are empty or only contain dead instructions, together with their
conditions. Such branches and conditions won't result in any
generated code and will be cleaned up by VPlan transforms.
This fixes a difference between the legacy and VPlan-based cost model.
When running LV in its usual pipeline position, such dead blocks should
already have been cleaned up, but they might be generated manually or by
fuzzers.
Fixes https://github.com/llvm/llvm-project/issues/100591.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 27e99694aafd..55c0ba3dd8f9 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -6730,9 +6730,12 @@ void LoopVectorizationCostModel::collectValuesToIgnore() {
return RequiresScalarEpilogue &&
!TheLoop->contains(cast<Instruction>(U)->getParent());
};
+
+ LoopBlocksDFS DFS(TheLoop);
+ DFS.perform(LI);
MapVector<Value *, SmallVector<Value *>> DeadInvariantStoreOps;
- for (BasicBlock *BB : TheLoop->blocks())
- for (Instruction &I : *BB) {
+ for (BasicBlock *BB : reverse(make_range(DFS.beginRPO(), DFS.endRPO())))
+ for (Instruction &I : reverse(*BB)) {
// Find all stores to invariant variables. Since they are going to sink
// outside the loop we do not need calculate cost for them.
StoreInst *SI;
@@ -6765,6 +6768,13 @@ void LoopVectorizationCostModel::collectValuesToIgnore() {
Value *PointerOp = getLoadStorePointerOperand(&I);
DeadInterleavePointerOps.push_back(PointerOp);
}
+
+ // Queue branches for analysis. They are dead, if their successors only
+ // contain dead instructions.
+ if (auto *Br = dyn_cast<BranchInst>(&I)) {
+ if (Br->isConditional())
+ DeadOps.push_back(&I);
+ }
}
// Mark ops feeding interleave group members as free, if they are only used
@@ -6789,8 +6799,36 @@ void LoopVectorizationCostModel::collectValuesToIgnore() {
// Mark ops that would be trivially dead and are only used by ignored
// instructions as free.
BasicBlock *Header = TheLoop->getHeader();
+
+ // Returns true if the block contains only dead instructions. Such blocks will
+ // be removed by VPlan-to-VPlan transforms and won't be considered by the
+ // VPlan-based cost model, so skip them in the legacy cost-model as well.
+ auto IsEmptyBlock = [this](BasicBlock *BB) {
+ return all_of(*BB, [this](Instruction &I) {
+ return ValuesToIgnore.contains(&I) || VecValuesToIgnore.contains(&I) ||
+ (isa<BranchInst>(&I) && !cast<BranchInst>(&I)->isConditional());
+ });
+ };
for (unsigned I = 0; I != DeadOps.size(); ++I) {
auto *Op = dyn_cast<Instruction>(DeadOps[I]);
+
+ // Check if the branch should be considered dead.
+ if (auto *Br = dyn_cast_or_null<BranchInst>(Op)) {
+ BasicBlock *ThenBB = Br->getSuccessor(0);
+ BasicBlock *ElseBB = Br->getSuccessor(1);
+ bool ThenEmpty = IsEmptyBlock(ThenBB);
+ bool ElseEmpty = IsEmptyBlock(ElseBB);
+ if ((ThenEmpty && ElseEmpty) ||
+ (ThenEmpty && ThenBB->getSingleSuccessor() == ElseBB &&
+ ElseBB->phis().empty()) ||
+ (ElseEmpty && ElseBB->getSingleSuccessor() == ThenBB &&
+ ThenBB->phis().empty())) {
+ VecValuesToIgnore.insert(Br);
+ DeadOps.push_back(Br->getCondition());
+ }
+ continue;
+ }
+
// Skip any op that shouldn't be considered dead.
if (!Op || !TheLoop->contains(Op) ||
(isa<PHINode>(Op) && Op->getParent() == Header) ||
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/RISCV/blocks-with-dead-instructions.ll",
"commands": [
"opt -p loop-vectorize -S %s"
],
"tests": [
{
"test_name": "block_with_dead_inst_1",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @block_with_dead_inst_1(ptr %src, i64 %N) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %loop.latch\n\nthen: ; preds = %loop.header\n %dead.gep = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %0 = icmp eq i64 %iv.next, %N\n br i1 %0, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "multiple_blocks_with_dead_insts_4",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @multiple_blocks_with_dead_insts_4(ptr %src, i64 %N) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %else\n\nthen: ; preds = %loop.header\n br label %then.1\n\nthen.1: ; preds = %then\n %dead.gep.1 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nelse: ; preds = %loop.header\n %dead.gep.2 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %else, %then.1\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %ec = icmp eq i64 %iv.next, %N\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "empty_block_with_phi_1",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @empty_block_with_phi_1(ptr %src, i64 %N) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i32 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i32 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %loop.latch\n\nthen: ; preds = %loop.header\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n %p = phi i16 [ %l, %loop.header ], [ 99, %then ]\n store i16 %p, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 1\n %0 = icmp eq i64 %iv.next, %N\n br i1 %0, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "multiple_blocks_with_dead_insts_3",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @multiple_blocks_with_dead_insts_3(ptr %src) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 0, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %else\n\nthen: ; preds = %loop.header\n %dead.gep.1 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nelse: ; preds = %loop.header\n %dead.gep.2 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %else, %then\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %ec = icmp eq i64 %iv.next, 1000\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "multiple_blocks_with_dead_inst_multiple_successors_5",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @multiple_blocks_with_dead_inst_multiple_successors_5(ptr %src) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %else\n\nthen: ; preds = %loop.header\n br label %then.1\n\nthen.1: ; preds = %then\n %dead.gep.1 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nelse: ; preds = %loop.header\n br label %else.2\n\nelse.2: ; preds = %else\n %dead.gep.2 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %else.2, %then.1\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %ec = icmp eq i64 %iv.next, 1000\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "multiple_blocks_with_dead_inst_multiple_successors_6",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @multiple_blocks_with_dead_inst_multiple_successors_6(ptr %src, i1 %ic, i64 %N) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %else\n\nthen: ; preds = %loop.header\n br i1 %ic, label %then.1, label %else\n\nthen.1: ; preds = %then\n %dead.gep.1 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nelse: ; preds = %then, %loop.header\n br label %else.2\n\nelse.2: ; preds = %else\n %dead.gep.2 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %else.2, %then.1\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %ec = icmp eq i64 %iv.next, %N\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "empty_block_with_phi_2",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @empty_block_with_phi_2(ptr %src, i64 %N) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i32 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i32 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %loop.latch, label %else\n\nelse: ; preds = %loop.header\n br label %loop.latch\n\nloop.latch: ; preds = %else, %loop.header\n %p = phi i16 [ %l, %loop.header ], [ 99, %else ]\n store i16 %p, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 1\n %0 = icmp eq i64 %iv.next, %N\n br i1 %0, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "block_with_dead_inst_2",
"test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @block_with_dead_inst_2(ptr %src) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 0, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %loop.latch, label %else\n\nelse: ; preds = %loop.header\n %dead.gep = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %else, %loop.header\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %ec = icmp eq i64 %iv.next, 1000\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[VPlan] Assertion `VF.Width == Width && \"VPlan cost model and legacy cost model disagreed\"' failed.",
"body": "Tested using 51d4980a133db12888207698e39c469cb7055cac\r\n\r\nTestcase:\r\n```llvm ir\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine void @f() #0 {\r\nentry:\r\n br label %for.body\r\n\r\nfor.cond.cleanup: ; preds = %cond.end7\r\n ret void\r\n\r\nfor.body: ; preds = %cond.end7, %entry\r\n %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %cond.end7 ]\r\n %xor1315 = phi i32 [ 0, %entry ], [ %xor, %cond.end7 ]\r\n %xor = xor i32 0, 0\r\n %arrayidx = getelementptr [1 x i16], ptr null, i64 0, i64 %indvars.iv\r\n %0 = load i16, ptr %arrayidx, align 2\r\n %tobool1.not = icmp eq i16 %0, 0\r\n br i1 %tobool1.not, label %cond.false, label %cond.end7\r\n\r\ncond.false: ; preds = %for.body\r\n %arrayidx3 = getelementptr [1 x i64], ptr null, i64 0, i64 %indvars.iv\r\n br label %cond.end7\r\n\r\ncond.end7: ; preds = %cond.false, %for.body\r\n %indvars.iv.next = add nsw i64 %indvars.iv, 3\r\n %1 = icmp eq i64 %indvars.iv.next, 0\r\n br i1 %1, label %for.cond.cleanup, label %for.body\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\nBacktrace:\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:10123: 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 \"f\"\r\n #0 0x00005e0a0dd8f3b0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2f1f3b0)\r\n #1 0x00005e0a0dd8c7cf llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2f1c7cf)\r\n #2 0x00005e0a0dd8c925 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x000073a243a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x000073a243a969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x000073a243a969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x000073a243a969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x000073a243a42476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x000073a243a287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x000073a243a2871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x000073a243a39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x00005e0a0cdaadd8 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f3add8)\r\n#12 0x00005e0a0cdad991 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+0x1f3d991)\r\n#13 0x00005e0a0cdae110 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f3e110)\r\n#14 0x00005e0a0bc1fda6 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+0xdafda6)\r\n#15 0x00005e0a0dba750e 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+0x2d3750e)\r\n#16 0x00005e0a0bc22f36 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+0xdb2f36)\r\n#17 0x00005e0a0dba629b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2d3629b)\r\n#18 0x00005e0a0bc1f286 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+0xdaf286)\r\n#19 0x00005e0a0dba43ed 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+0x2d343ed)\r\n#20 0x00005e0a0b4686b6 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+0x5f86b6)\r\n#21 0x00005e0a0b45a2f1 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5ea2f1)\r\n#22 0x000073a243a29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#23 0x000073a243a29e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#24 0x000073a243a29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#25 0x00005e0a0b450185 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5e0185)\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/TnYreKbqn\r\n\r\n@fhahn \r\n\r\nFound via fuzzer.",
"author": "patrick-rivos",
"labels": [
"vectorizers",
"crash"
],
"comments": [
{
"author": "fhahn",
"body": "Another case with dead instructions that get simplified by VPlan-DCE :/"
},
{
"author": "patrick-rivos",
"body": "Just to add a bit of context here: I'm hitting this assertion >300 times a day so I've allowlisted it in the fuzzer I run. There are likely other interesting cases where this assertion triggers but I don't have the bandwidth to deduplicate this failure to pull out those cases. :-("
},
{
"author": "preames",
"body": "> Just to add a bit of context here: I'm hitting this assertion >300 times a day so I've allowlisted it in the fuzzer I run. There are likely other interesting cases where this assertion triggers but I don't have the bandwidth to deduplicate this failure to pull out those cases. :-(\r\n\r\n@fhahn This assertion is triggering in a large number of fuzzer runs, and we have some reason to believe there are other failures be masked by this one. (We have at least one instance of this found so far by accident.) This needs to be either fixed or reverted so that tree is green. "
},
{
"author": "fhahn",
"body": "Will look into a fix now that I'm back. The crash should not reproduce with `opt -passes='instcombine,simplifycfg,loop-vectorize'` for all instances of the same underlying issue."
},
{
"author": "nikic",
"body": "@fhahn I feel like at this point this assertion is doing a lot more harm than good. It's very fragile, and doesn't seem to help in finding any genuine bugs, just incidental differences in simplification power."
},
{
"author": "artagnon",
"body": "I was also looking into this bug briefly, but couldn't quite figure out why we didn't choose to rip out the legacy costing."
},
{
"author": "sjoerdmeijer",
"body": "If e9e3a183d6d8d8729223b7131aa57fd9f02f0440 was supposed to fix this, then I can confirm I am still seeing this assert. \r\n\r\nIf this is indeed something else or new, then I agree with @nikic that this assert is too fragile."
},
{
"author": "fhahn",
"body": "The assertion originally surfaced real differences that needed fixing; the fuzzer-generated issues over the last weeks mostly were due to unsimplified input, which is very difficult to completely match without actually iteratively simplifying. Seeing the recent https://github.com/llvm/llvm-project/issues/104714 with a C reproducer it was a bit surprising that dead loads (and subsequent dead blocks/conditions) survive until LoopVectorize in the default pipeline.\r\n\r\nThere will be a number of code changes over the next few weeks/months which may introduce unintended divergences the assert is supposed to catch. For that reason it would be beneficial to keep the assert.\r\n\r\nIdeally we would only check if no extra simplifications have been applied on the selected VPlan, which should be possible to check once #103033 lands.\r\n\r\nWe could also guard it with an option, similar to InstCombine's fix point iteration assertion, which can also trigger asserts by default on valid IR input.\r\n\r\n> If [e9e3a18](https://github.com/llvm/llvm-project/commit/e9e3a183d6d8d8729223b7131aa57fd9f02f0440) was supposed to fix this, then I can confirm I am still seeing this assert.\r\n> \r\n\r\nCould you share the reproducer somewhere? Would be good to check if this is due to the simplification issue mentioned above or a genuine divergence"
},
{
"author": "sjoerdmeijer",
"body": "> Could you share the reproducer somewhere? Would be good to check if this is due to the simplification issue mentioned above or a genuine divergence\r\n\r\nThis runs in the same assert with `opt -S -passes=loop-vectorize`: \r\n\r\n```\r\ntarget datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32\"\r\ntarget triple = \"aarch64-unknown-linux-gnu\"\r\n\r\ndefine void @foo() #0 {\r\nentry:\r\n br label %for.body315.us.us\r\n\r\nfor.body315.us.us: ; preds = %cond.end388.us.us, %entry\r\n %indvars.iv10421 = phi i64 [ %indvars.iv.next1043, %cond.end388.us.us ], [ 0, %entry ]\r\n br i1 false, label %cond.end388.us.us, label %cond.true380.us.us\r\n\r\ncond.true380.us.us: ; preds = %for.body315.us.us\r\n %0 = load i32, ptr null, align 4\r\n br label %cond.end388.us.us\r\n\r\ncond.end388.us.us: ; preds = %cond.true380.us.us, %for.body315.us.us\r\n %indvars.iv.next1043 = add i64 %indvars.iv10421, 1\r\n %cmp313.us.us = icmp slt i64 %indvars.iv10421, 1\r\n br i1 %cmp313.us.us, label %for.body315.us.us, label %for.cond311.for.cond.cleanup314_crit_edge.loopexit, !llvm.loop !0\r\n\r\nfor.cond311.for.cond.cleanup314_crit_edge.loopexit: ; preds = %cond.end388.us.us\r\n ret void\r\n}\r\n\r\nattributes #0 = { \"target-cpu\"=\"neoverse-v2\" }\r\n\r\n!0 = distinct !{!0, !1, !2, !3}\r\n!1 = !{!\"llvm.loop.mustprogress\"}\r\n!2 = !{!\"llvm.loop.vectorize.predicate.enable\", i1 true}\r\n!3 = !{!\"llvm.loop.vectorize.enable\", i1 true}\r\n```"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
151686
|
https://github.com/llvm/llvm-project/issues/151686
|
crash
|
55c2b273ea5d3b949c6431d429a4da20612d9808
| 2025-08-01T10:41:30 |
[
"llvm/test/Transforms/LoopVectorize"
] |
{
"fix_commit": "eee9755881bf39bc15e6e05697abbbfabb51cb78",
"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": [
[
9788,
9793
]
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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": [
"preparePlanForEpilogueVectorLoop"
],
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.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 eee9755881bf39bc15e6e05697abbbfabb51cb78
Author: Florian Hahn <flo@fhahn.com>
Date: Fri Aug 1 20:54:38 2025 +0100
[LV] Refine check to find epilogue IV resume value.
Make sure to check that the vector trip count is containedin the list of
incoming values to serve as tie-breaker with phis with all-zero incoming
values.
Fixes https://github.com/llvm/llvm-project/issues/151686.
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 20528089c000..b4ea70e0e5cc 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -9788,6 +9788,10 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
match(
P.getIncomingValueForBlock(EPI.MainLoopIterationCountCheck),
m_SpecificInt(0)) &&
+ any_of(P.incoming_values(),
+ [&EPI](Value *Inc) {
+ return Inc == EPI.VectorTripCount;
+ }) &&
all_of(P.incoming_values(), [&EPI](Value *Inc) {
return Inc == EPI.VectorTripCount ||
match(Inc, m_SpecificInt(0));
|
[
{
"file": "llvm/test/Transforms/LoopVectorize/X86/epilog-vectorization-inductions.ll",
"commands": [
"opt -passes=loop-vectorize -mcpu=znver2 -S %s"
],
"tests": [
{
"test_name": "multiple_inductions_start_at_0",
"test_body": "target triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i8 @multiple_inductions_start_at_0() {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.2 = phi i32 [ 0, %entry ], [ %add, %loop ]\n %add = add i32 %iv.2, -16777216\n %trunc = trunc i32 %iv.2 to i8\n %iv.next = add i32 %iv, 1\n %ec = icmp ugt i32 %iv, 1050\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n %res = phi i8 [ %trunc, %loop ]\n ret i8 %res\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "Assertion `EPResumeVal && \"must have a resume value for the canonical IV\"' failed.",
"body": "To reproduce run opt with the test below using -passes=loop-vectorize:\n```\n; ModuleID = './reduced.ll'\nsource_filename = \"./reduced.ll\"\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i32 @wombat() gc \"statepoint-example\" {\nbb:\n br label %bb2\n\nbb1: ; preds = %bb2\n %phi = phi i8 [ %trunc, %bb2 ]\n ret i32 0\n\nbb2: ; preds = %bb2, %bb\n %phi3 = phi i32 [ 0, %bb ], [ %add5, %bb2 ]\n %phi4 = phi i32 [ 0, %bb ], [ %add, %bb2 ]\n %add = add i32 %phi4, -16777216\n %trunc = trunc i32 %phi4 to i8\n %add5 = add i32 %phi3, 1\n %icmp = icmp ugt i32 %phi3, 1050\n br i1 %icmp, label %bb1, label %bb2\n}\n```\nReproducer: https://godbolt.org/z/xz3sEWhTY\nStack dump:\n```\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=loop-vectorize <source>\n1.\tRunning pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"<source>\"\n2.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"wombat\"\n #0 0x00000000056729e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x56729e8)\n #1 0x000000000566f894 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0\n #2 0x00007685c0442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #3 0x00007685c04969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #4 0x00007685c0442476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #5 0x00007685c04287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #6 0x00007685c042871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #7 0x00007685c0439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #8 0x00000000034821cd preparePlanForEpilogueVectorLoop(llvm::VPlan&, llvm::Loop*, llvm::DenseMap<llvm::SCEV const*, llvm::Value*, llvm::DenseMapInfo<llvm::SCEV const*, void>, llvm::detail::DenseMapPair<llvm::SCEV const*, llvm::Value*>> const&, llvm::EpilogueLoopVectorizationInfo const&) LoopVectorize.cpp:0:0\n #9 0x00000000034a4c56 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x34a4c56)\n#10 0x00000000034a6690 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x34a6690)\n#11 0x00000000034a6cf7 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x34a6cf7)\n#12 0x0000000002db62be 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+0x2db62be)\n#13 0x0000000005464431 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5464431)\n#14 0x0000000000ebde5e 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+0xebde5e)\n#15 0x0000000005464904 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5464904)\n#16 0x00000000009637fe 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+0x9637fe)\n#17 0x00000000054624d1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x54624d1)\n#18 0x000000000096daca 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+0x96daca)\n#19 0x0000000000961b7b optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x961b7b)\n#20 0x00007685c0429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#21 0x00007685c0429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#22 0x0000000000958c35 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x958c35)\nProgram terminated with signal: SIGSEGV\nCompiler returned: 139\n```",
"author": "TatyanaDoubts",
"labels": [
"vectorizers",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
126304
|
https://github.com/llvm/llvm-project/issues/126304
|
crash
|
fcbf04e40e66014f455a38b59993be865bc6cdfd
| 2025-02-07T20:48:01 |
[
"llvm/test/Transforms/SLPVectorizer"
] |
{
"fix_commit": "10844fb9b0b78695243391e091e17ec29295872a",
"components": [
"SLPVectorizer"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
[
5596,
5601
],
[
5626,
5632
]
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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::getReorderingData"
],
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/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 10844fb9b0b78695243391e091e17ec29295872a
Author: Alexey Bataev <a.bataev@outlook.com>
Date: Tue Feb 11 13:23:55 2025 -0800
[SLP]Fix attempt to build the reorder mask for non-adjusted reuse mask
When building the reorder for non-single use reuse mask, need to check
if the size of the mask is multiple of the number of unique scalars.
Otherwise, the compiler may crash when trying to reorder nodes.
Fixes #126304
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index e1c08077126d..fb1054ee30aa 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -5596,6 +5596,8 @@ BoUpSLP::getReorderingData(const TreeEntry &TE, bool TopToBottom) {
::getNumberOfParts(*TTI, getWidenedType(TE.Scalars.front()->getType(),
2 * TE.getVectorFactor())) == 1)
return std::nullopt;
+ if (TE.ReuseShuffleIndices.size() % Sz != 0)
+ return std::nullopt;
if (!ShuffleVectorInst::isOneUseSingleSourceMask(TE.ReuseShuffleIndices,
Sz)) {
SmallVector<int> ReorderMask(Sz, PoisonMaskElem);
@@ -5626,7 +5628,7 @@ BoUpSLP::getReorderingData(const TreeEntry &TE, bool TopToBottom) {
UsedVals.set(Val);
for (unsigned K = 0; K < NumParts; ++K) {
unsigned Idx = Val + Sz * K;
- if (Idx < VF)
+ if (Idx < VF && I + K < VF)
ResOrder[Idx] = I + K;
}
}
|
[
{
"file": "llvm/test/Transforms/SLPVectorizer/SystemZ/reuse-non-power-of-2-reorder.ll",
"commands": [
"opt -S --passes=slp-vectorizer -mtriple=systemz -mcpu=z15 < %s -slp-threshold=-100"
],
"tests": [
{
"test_name": "<module>",
"test_body": "\ndefine void @test(i32 %0, i64 %1, i32 %2, i32 %3, ptr %4) {\n;\n %6 = trunc i64 %1 to i32\n %7 = xor i32 %6, 1\n %8 = xor i32 %6, 1\n %9 = or i32 %7, %8\n %10 = xor i32 %6, 1\n %11 = or i32 %9, %10\n %12 = xor i32 %6, 1\n %13 = or i32 %11, %12\n %14 = xor i32 %6, 1\n %15 = or i32 %13, %14\n %16 = xor i32 %6, 1\n %17 = or i32 %15, %16\n %18 = xor i32 %6, 1\n %19 = or i32 %17, %18\n %20 = xor i32 %6, 1\n %21 = or i32 %19, %20\n %22 = trunc i64 %1 to i32\n %23 = xor i32 %22, 1\n %24 = or i32 %23, %21\n %25 = xor i32 %22, 1\n %26 = or i32 %24, %25\n %27 = xor i32 %22, 1\n %28 = or i32 %26, %27\n %29 = xor i32 %22, 1\n %30 = or i32 %28, %29\n %31 = xor i32 %22, 1\n %32 = or i32 %30, %31\n %33 = xor i32 %22, 1\n %34 = or i32 %32, %33\n %35 = xor i32 %22, 1\n %36 = or i32 %34, %35\n %37 = xor i32 %22, 1\n %38 = or i32 %36, %37\n %39 = trunc i64 %1 to i32\n %40 = xor i32 %39, 1\n %41 = or i32 %40, %38\n %42 = xor i32 %39, 1\n %43 = or i32 %41, %42\n %44 = xor i32 %39, 1\n %45 = or i32 %43, %44\n %46 = xor i32 %39, 1\n %47 = or i32 %45, %46\n %48 = xor i32 %39, 1\n %49 = or i32 %47, %48\n %50 = xor i32 %39, 1\n %51 = or i32 %49, %50\n %52 = xor i32 %39, 1\n %53 = or i32 %51, %52\n %54 = xor i32 %39, 1\n %55 = or i32 %53, %54\n %56 = trunc i64 %1 to i32\n %57 = xor i32 %56, 1\n %58 = or i32 %57, %55\n %59 = xor i32 %56, 1\n %60 = or i32 %58, %59\n %61 = xor i32 %56, 1\n %62 = or i32 %60, %61\n %63 = xor i32 %56, 1\n %64 = or i32 %62, %63\n %65 = xor i32 %56, 1\n %66 = or i32 %64, %65\n %67 = xor i32 %56, 1\n %68 = or i32 %66, %67\n %69 = xor i32 %56, 1\n %70 = or i32 %68, %69\n %71 = xor i32 %56, 1\n %72 = or i32 %70, %71\n %73 = trunc i64 %1 to i32\n %74 = xor i32 %73, 1\n %75 = or i32 %74, %72\n %76 = xor i32 %73, 1\n %77 = or i32 %75, %76\n %78 = xor i32 %73, 1\n %79 = or i32 %77, %78\n %80 = xor i32 %73, 1\n %81 = or i32 %79, %80\n %82 = xor i32 %73, 1\n %83 = or i32 %81, %82\n %84 = xor i32 %73, 1\n %85 = or i32 %83, %84\n %86 = xor i32 %73, 1\n %87 = or i32 %85, %86\n %88 = xor i32 %0, %73\n %89 = or i32 %87, %88\n %90 = xor i32 %0, %2\n %91 = or i32 %90, %89\n %92 = xor i32 %0, %2\n %93 = or i32 %91, %92\n %94 = xor i32 %0, %2\n %95 = or i32 %93, %94\n %96 = xor i32 %0, %2\n %97 = or i32 %95, %96\n %98 = trunc i64 %1 to i32\n %99 = xor i32 %98, 1\n %100 = xor i32 %98, 1\n %101 = or i32 %99, %100\n %102 = xor i32 %98, 1\n %103 = or i32 %101, %102\n %104 = xor i32 %98, 1\n %105 = or i32 %103, %104\n %106 = xor i32 %98, 1\n %107 = or i32 %105, %106\n %108 = xor i32 %98, 1\n %109 = or i32 %107, %108\n %110 = xor i32 %98, 1\n %111 = or i32 %109, %110\n %112 = xor i32 %0, %98\n %113 = or i32 %111, %112\n %114 = xor i32 %0, %3\n %115 = or i32 %113, %114\n %116 = xor i32 %0, %3\n %117 = or i32 %115, %116\n %118 = xor i32 %0, %3\n %119 = or i32 %117, %118\n %120 = xor i32 %0, %3\n %121 = or i32 %119, %120\n %122 = xor i32 %0, %3\n %123 = or i32 %121, %122\n %124 = xor i32 %0, %3\n %125 = or i32 %123, %124\n %126 = xor i32 %0, %3\n %127 = or i32 %125, %126\n %128 = xor i32 %0, %3\n %129 = or i32 %127, %128\n %130 = or i32 %129, %97\n store i32 %130, ptr %4, align 4\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[SLP] llvm::BitVector::set(unsigned int): Assertion `Idx < Size && \"access in bound\"' failed.",
"body": "[crash41.tar.gz](https://github.com/user-attachments/files/18712696/crash41.tar.gz)\n\nclang -O3 -march=z15 crash41.i -o a.out -w -mllvm -inline-threshold=450\n\nllvm/include/llvm/ADT/BitVector.h:358: llvm::BitVector& llvm::BitVector::set(unsigned int): Assertion `Idx < Size && \"access in bound\"' failed.\n\n#11 0x000002aa03b45768 llvm::SLPVectorizerPass::vectorizeHorReduction\n\n@alexey-bataev \n",
"author": "JonPsson1",
"labels": [
"llvm:SLPVectorizer",
"crash"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
93096
|
https://github.com/llvm/llvm-project/issues/93096
|
miscompilation
|
300e5b91144249a5b142b02d6331fcb33e13cf1d
| 2024-05-22T21:03:20 |
[
"llvm/test/Transforms/SCCP"
] |
{
"fix_commit": "27392a35ef052aa515f38359de89aced11a4363d",
"components": [
"SCCPSolver"
],
"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": [
[
43,
49
],
[
1297,
1303
],
[
1329,
1336
],
[
1534,
1541
],
[
1818,
1824
],
[
1863,
1869
]
],
"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": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": [
"SCCPInstVisitor::handleCallResult",
"SCCPInstVisitor::handleExtractOfWithOverflow",
"SCCPInstVisitor::visitBinaryOperator",
"SCCPInstVisitor::visitCastInst",
"getConstantRange"
],
"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 27392a35ef052aa515f38359de89aced11a4363d
Author: Nikita Popov <npopov@redhat.com>
Date: Thu May 23 15:14:34 2024 +0200
[SCCP] Don't allow undef ranges when performing operations (#93163)
When performing some range operation (e.g. and) on a constant range that
includes undef, we currently just ignore the undef value, which is
obviously incorrect. Instead, we can do one of two things:
* Say that the result range also includes undef.
* Treat undef as a full range.
This patch goes with the second approach -- I'd expect it to be a bit
better overall, e.g. it allows preserving the fact that a zext of a
range with undef isn't a full range.
Fixes https://github.com/llvm/llvm-project/issues/93096.
diff --git a/llvm/lib/Transforms/Utils/SCCPSolver.cpp b/llvm/lib/Transforms/Utils/SCCPSolver.cpp
index ce40e8b31b76..4f36bac11e34 100644
--- a/llvm/lib/Transforms/Utils/SCCPSolver.cpp
+++ b/llvm/lib/Transforms/Utils/SCCPSolver.cpp
@@ -43,7 +43,7 @@ static ValueLatticeElement::MergeOptions getMaxWidenStepsOpts() {
}
static ConstantRange getConstantRange(const ValueLatticeElement &LV, Type *Ty,
- bool UndefAllowed = true) {
+ bool UndefAllowed) {
assert(Ty->isIntOrIntVectorTy() && "Should be int or int vector");
if (LV.isConstantRange(UndefAllowed))
return LV.getConstantRange();
@@ -1297,7 +1297,8 @@ void SCCPInstVisitor::visitCastInst(CastInst &I) {
if (I.getDestTy()->isIntegerTy() && I.getSrcTy()->isIntOrIntVectorTy()) {
auto &LV = getValueState(&I);
- ConstantRange OpRange = getConstantRange(OpSt, I.getSrcTy());
+ ConstantRange OpRange =
+ getConstantRange(OpSt, I.getSrcTy(), /*UndefAllowed=*/false);
Type *DestTy = I.getDestTy();
// Vectors where all elements have the same known constant range are treated
@@ -1329,8 +1330,8 @@ void SCCPInstVisitor::handleExtractOfWithOverflow(ExtractValueInst &EVI,
return; // Wait to resolve.
Type *Ty = LHS->getType();
- ConstantRange LR = getConstantRange(L, Ty);
- ConstantRange RR = getConstantRange(R, Ty);
+ ConstantRange LR = getConstantRange(L, Ty, /*UndefAllowed=*/false);
+ ConstantRange RR = getConstantRange(R, Ty, /*UndefAllowed=*/false);
if (Idx == 0) {
ConstantRange Res = LR.binaryOp(WO->getBinaryOp(), RR);
mergeInValue(&EVI, ValueLatticeElement::getRange(Res));
@@ -1534,8 +1535,10 @@ void SCCPInstVisitor::visitBinaryOperator(Instruction &I) {
return markOverdefined(&I);
// Try to simplify to a constant range.
- ConstantRange A = getConstantRange(V1State, I.getType());
- ConstantRange B = getConstantRange(V2State, I.getType());
+ ConstantRange A =
+ getConstantRange(V1State, I.getType(), /*UndefAllowed=*/false);
+ ConstantRange B =
+ getConstantRange(V2State, I.getType(), /*UndefAllowed=*/false);
auto *BO = cast<BinaryOperator>(&I);
ConstantRange R = ConstantRange::getEmpty(I.getType()->getScalarSizeInBits());
@@ -1818,7 +1821,8 @@ void SCCPInstVisitor::handleCallResult(CallBase &CB) {
// Combine range info for the original value with the new range from the
// condition.
- auto CopyOfCR = getConstantRange(CopyOfVal, CopyOf->getType());
+ auto CopyOfCR = getConstantRange(CopyOfVal, CopyOf->getType(),
+ /*UndefAllowed=*/true);
auto NewCR = ImposedCR.intersectWith(CopyOfCR);
// If the existing information is != x, do not use the information from
// a chained predicate, as the != x information is more likely to be
@@ -1863,7 +1867,8 @@ void SCCPInstVisitor::handleCallResult(CallBase &CB) {
const ValueLatticeElement &State = getValueState(Op);
if (State.isUnknownOrUndef())
return;
- OpRanges.push_back(getConstantRange(State, Op->getType()));
+ OpRanges.push_back(
+ getConstantRange(State, Op->getType(), /*UndefAllowed=*/false));
}
ConstantRange Result =
|
[
{
"file": "llvm/test/Transforms/SCCP/ip-add-range-to-call.ll",
"commands": [
"opt -passes=ipsccp -S %s"
],
"tests": [
{
"test_name": "caller5",
"test_body": "declare hidden i32 @callee5(i32, i32)\n\ndefine i32 @caller5() {\n %c1 = call i32 @callee5(i32 10, i32 100)\n %c2 = call i32 @callee5(i32 20, i32 200)\n %a = add i32 %c1, %c2\n ret i32 %a\n}\n",
"lli_expected_out": null,
"additional_args": null
}
]
},
{
"file": "llvm/test/Transforms/SCCP/range-with-undef.ll",
"commands": [
"opt -S -passes=ipsccp < %s"
],
"tests": [
{
"test_name": "test_with_overflow",
"test_body": "define i9 @test_with_overflow(i1 %cond, i8 %a) {\nentry:\n br i1 %cond, label %if, label %join\n\nif: ; preds = %entry\n %a.ext = zext i8 %a to i16\n br label %join\n\njoin: ; preds = %if, %entry\n %phi = phi i16 [ undef, %entry ], [ %a.ext, %if ]\n %wo = call { i16, i1 } @llvm.uadd.with.overflow.i16(i16 %phi, i16 1)\n %add = extractvalue { i16, i1 } %wo, 0\n %trunc = trunc i16 %add to i9\n ret i9 %trunc\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare { i16, i1 } @llvm.uadd.with.overflow.i16(i16, i16) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_binop",
"test_body": "define i8 @test_binop(i1 %cond, i8 %a) {\nentry:\n br i1 %cond, label %if, label %join\n\nif: ; preds = %entry\n %a.ext = zext i8 %a to i16\n br label %join\n\njoin: ; preds = %if, %entry\n %phi = phi i16 [ undef, %entry ], [ %a.ext, %if ]\n %and = and i16 %phi, -1\n %trunc = trunc i16 %and to i8\n ret i8 %trunc\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_cast",
"test_body": "define i8 @test_cast(i1 %cond, i8 %a) {\nentry:\n br i1 %cond, label %if, label %join\n\nif: ; preds = %entry\n %a.ext = zext i8 %a to i16\n br label %join\n\njoin: ; preds = %if, %entry\n %phi = phi i16 [ undef, %entry ], [ %a.ext, %if ]\n %zext = zext i16 %phi to i32\n %trunc = trunc i32 %zext to i8\n ret i8 %trunc\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "test_intrin",
"test_body": "define i8 @test_intrin(i1 %cond, i8 %a) {\nentry:\n br i1 %cond, label %if, label %join\n\nif: ; preds = %entry\n %a.ext = zext i8 %a to i16\n br label %join\n\njoin: ; preds = %if, %entry\n %phi = phi i16 [ undef, %entry ], [ %a.ext, %if ]\n %umax = call i16 @llvm.umax.i16(i16 %phi, i16 42)\n %trunc = trunc i16 %umax to i8\n ret i8 %trunc\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i16 @llvm.umax.i16(i16, i16) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "nuw/nsw should not be added to trunc instruction when there are undef bits in the source value",
"body": "Run ipsccp on the code\r\n```\r\n; opt -passes=ipsccp -S test.ll\r\n\r\ndefine void @foo(i1 %cond1, i32 %p1) {\r\nentry:\r\n br label %loop\r\n\r\nloop:\r\n %phi1 = phi i64 [undef, %entry], [%phi2, %latch]\r\n br i1 %cond1, label %then2, label %else2\r\n\r\nthen2:\r\n %and = and i64 %phi1, -1095216660481 ; 0xFFFFFF00FFFFFFFF\r\n br label %latch\r\n\r\nelse2:\r\n %ext = zext i32 %p1 to i64 \r\n %or = or i64 %ext, 4294967296 ; 0x100000000\r\n br label %latch\r\n\r\nlatch:\r\n %phi2 = phi i64 [%and, %then2], [%or, %else2]\r\n %shr = lshr i64 %phi2, 32\r\n %res = trunc i64 %shr to i8\r\n %cond2 = call i1 @bar(i8 %res)\r\n br i1 %cond2, label %loop, label %exit\r\n\r\nexit:\r\n ret void\r\n}\r\n\r\ndeclare i1 @bar(i8)\r\n```\r\nLLVM adds nuw/nsw flags to the trunc instruction\r\n```\r\n%res = trunc nuw nsw i64 %shr to i8\r\n```\r\nIt means all high bits of %shr are 0. \r\nBut %phi1 may be undef, bits [32..39] of %and are cleared, bits[40..63] can still be undef, and later it is moved to bits[8..31] of %shr, so not all high bits of %shr are 0.\r\n",
"author": "weiguozhi",
"labels": [
"miscompilation",
"llvm:transforms"
],
"comments": [
{
"author": "nikic",
"body": "We do exclude ranges with undef here: https://github.com/llvm/llvm-project/blob/3061fed2f05cde574c84a26c702b1e7932fa4d7e/llvm/lib/Transforms/Utils/SCCPSolver.cpp#L118-L119 Maybe the undef flag doesn't get propagated properly somewhere..."
},
{
"author": "nikic",
"body": "Simplified test case:\r\n```llvm\r\ndefine i8 @src(i1 %cond, i8 %a) {\r\nentry: \r\n br i1 %cond, label %if, label %join\r\n \r\nif:\r\n %a.ext = zext i8 %a to i16 \r\n br label %join \r\n\r\njoin:\r\n %phi = phi i16 [ undef, %entry ], [ %a.ext, %if ] \r\n %and = and i16 %phi, u0x0000ffff \r\n %trunc = trunc i16 %and to i8\r\n ret i8 %trunc\r\n} \r\n```\r\nThis is indeed an issue with the propagation of the undef flag."
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": false
}
| null |
116249
|
https://github.com/llvm/llvm-project/issues/116249
|
miscompilation
|
c1f6cb74634509d0e4204dadd46566185fa33e2b
| 2024-11-14T15:57:03 |
[
"llvm/test/Transforms/IndVarSimplify"
] |
{
"fix_commit": "40a647fc7dc6048c92e2d580b61f5feca0785980",
"components": [
"IndVarSimplify"
],
"bug_location_lineno": {
"llvm/lib/Transforms/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": [
[
1530,
1535
]
],
"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": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": [
"IndVarSimplify::canonicalizeExitCondition"
],
"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 40a647fc7dc6048c92e2d580b61f5feca0785980
Author: Yingwei Zheng <dtcxzyw2333@gmail.com>
Date: Fri Nov 15 09:15:37 2024 +0800
[IndVarSimplify] Drop samesign flags after narrowing compares (#116263)
Samesign flag cannot be preserved after narrowing the compare since the
position of the sign bit is changed.
Closes https://github.com/llvm/llvm-project/issues/116249.
diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
index 2b2d516a7079..8a3e0bc3eb97 100644
--- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -1530,6 +1530,8 @@ bool IndVarSimplify::canonicalizeExitCondition(Loop *L) {
L->getLoopPreheader()->getTerminator()->getIterator());
ICmp->setOperand(Swapped ? 1 : 0, LHSOp);
ICmp->setOperand(Swapped ? 0 : 1, NewRHS);
+ // Samesign flag cannot be preserved after narrowing the compare.
+ ICmp->setSameSign(false);
if (LHS->use_empty())
DeadInsts.push_back(LHS);
};
|
[
{
"file": "llvm/test/Transforms/IndVarSimplify/finite-exit-comparisons.ll",
"commands": [
"opt -passes=indvars -S < %s -indvars-predicate-loops=0"
],
"tests": [
{
"test_name": "test_drop_icmp_samesign",
"test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64\"\n\ndefine i8 @test_drop_icmp_samesign(i1 %cond, i32 range(i32 0, 32) %x) {\nentry:\n br i1 %cond, label %for.body, label %else\n\nelse: ; preds = %entry\n %call1 = call i8 @callee()\n br label %exit\n\nfor.body: ; preds = %for.body, %entry\n %call2 = call i8 @callee()\n %ext = zext i8 %call2 to i32\n %cond2 = icmp samesign ugt i32 %x, %ext\n br i1 %cond2, label %for.body, label %exit\n\nexit: ; preds = %for.body, %else\n %res = phi i8 [ %call1, %else ], [ %call2, %for.body ]\n ret i8 %res\n}\n\ndeclare i8 @callee()\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[IndVarSimplify] samesign flag should be dropped after narrowing",
"body": "Found with https://github.com/dtcxzyw/llvm-ub-aware-interpreter.\r\nReproducer: https://alive2.llvm.org/ce/z/fcnvLv\r\n```\r\n; bin/opt -passes=indvars test.ll -S\r\ndefine i8 @test(i1 %cond, i32 range(i32 0, 32) %x) {\r\nentry:\r\n br i1 %cond, label %for.body, label %else\r\n\r\nelse:\r\n %call1 = call i8 @callee()\r\n br label %exit\r\n\r\nfor.body:\r\n %call2 = call i8 @callee()\r\n %ext = zext i8 %call2 to i32\r\n %cond2 = icmp samesign ugt i32 %x, %ext\r\n br i1 %cond2, label %for.body, label %exit\r\n\r\nexit:\r\n %res = phi i8 [ %call1, %else ], [ %call2, %for.body ]\r\n ret i8 %res\r\n}\r\n```\r\n```\r\n\r\n----------------------------------------\r\ndeclare i8 @callee()\r\n\r\ndefine i8 @test(i1 %cond, i32 %x) {\r\ninit:\r\n %#range_0_%x = !range i32 %x, i32 0, i32 32\r\n br label %entry\r\n\r\nentry:\r\n br i1 %cond, label %for.body, label %else\r\n\r\nelse:\r\n %call1 = call i8 @callee()\r\n br label %exit\r\n\r\nfor.body:\r\n %call2 = call i8 @callee()\r\n %ext = zext i8 %call2 to i32\r\n %cond2 = icmp samesign ugt i32 %#range_0_%x, %ext\r\n br i1 %cond2, label %for.body, label %exit\r\n\r\nexit:\r\n %res = phi i8 [ %call1, %else ], [ %call2, %for.body ]\r\n ret i8 %res\r\n}\r\n=>\r\ndeclare i8 @callee()\r\n\r\ndefine i8 @test(i1 %cond, i32 %x) {\r\ninit:\r\n %#range_0_%x = !range i32 %x, i32 0, i32 32\r\n br label %entry\r\n\r\nentry:\r\n br i1 %cond, label %for.body.preheader, label %else\r\n\r\nelse:\r\n %call1 = call i8 @callee()\r\n br label %exit\r\n\r\nfor.body.preheader:\r\n %#0 = trunc i32 %#range_0_%x to i8\r\n br label %for.body\r\n\r\nfor.body:\r\n %call2 = call i8 @callee()\r\n %cond2 = icmp samesign ugt i8 %#0, %call2\r\n br i1 %cond2, label %for.body, label %exit.loopexit\r\n\r\nexit.loopexit:\r\n %call2.lcssa = phi i8 [ %call2, %for.body ]\r\n br label %exit\r\n\r\nexit:\r\n %res = phi i8 [ %call1, %else ], [ %call2.lcssa, %exit.loopexit ]\r\n ret i8 %res\r\n}\r\nTransformation doesn't verify!\r\n\r\nERROR: Source is more defined than target\r\n\r\nExample:\r\ni1 %cond = #x1 (1)\r\ni32 %x = #x00000000 (0)\r\n\r\nSource:\r\ni32 %#range_0_%x = #x00000000 (0)\r\n >> Jump to %entry\r\n >> Jump to %for.body\r\ni8 %call2 = #x80 (128, -128)\r\ni32 %ext = #x00000080 (128)\r\ni1 %cond2 = #x0 (0)\r\n >> Jump to %exit\r\ni8 %res = #x80 (128, -128)\r\n\r\nSOURCE MEMORY STATE\r\n===================\r\nNON-LOCAL BLOCKS:\r\nBlock 0 >\tsize: 0\talign: 1\talloc type: 0\talive: false\taddress: 0\r\nBlock 1 >\tsize: 4\talign: 1\talloc type: 0\talive: true\taddress: 1\r\n\r\nTarget:\r\ni32 %#range_0_%x = #x00000000 (0)\r\n >> Jump to %entry\r\n >> Jump to %for.body.preheader\r\ni8 %#0 = #x00 (0)\r\n >> Jump to %for.body\r\ni8 %call2 = #x80 (128, -128)\r\ni1 %cond2 = poison\r\nUB triggered on br\r\n\r\n\r\nSummary:\r\n 0 correct transformations\r\n 1 incorrect transformations\r\n 0 failed-to-prove transformations\r\n 0 Alive2 errors\r\n```",
"author": "dtcxzyw",
"labels": [
"miscompilation",
"llvm:transforms"
],
"comments": []
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
140345
|
https://github.com/llvm/llvm-project/issues/140345
|
crash
|
3702d64801c872bf41a29b0aabda868ab3e26f12
| 2025-05-17T04:00:17 |
[
"llvm/test/Transforms/FunctionAttrs"
] |
{
"fix_commit": "e44fbea0a17f468d45de5eaef158642f067f678c",
"components": [
"FunctionAttrs"
],
"bug_location_lineno": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.h": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": [
[
675,
688
]
],
"llvm/include/llvm/Analysis/LoopAccessAnalysis.h": null,
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineInternal.h": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/include/llvm/Analysis/ScalarEvolution.h": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/include/llvm/Analysis/MemorySSAUpdater.h": null,
"llvm/include/llvm/Analysis/LoopCacheAnalysis.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/include/llvm/IR/CmpPredicate.h": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanValue.h": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Vectorize/VPlanHelpers.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/IR/Instruction.h": null,
"llvm/lib/IR/Instruction.cpp": null
},
"bug_location_funcname": {
"llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp": null,
"llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": null,
"llvm/lib/Analysis/MemorySSAUpdater.cpp": null,
"llvm/lib/Transforms/Utils/Local.cpp": null,
"llvm/lib/Transforms/Scalar/LoopDeletion.cpp": null,
"llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp": null,
"llvm/lib/Transforms/IPO/GlobalOpt.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": null,
"llvm/lib/Transforms/Vectorize/VectorCombine.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp": null,
"llvm/lib/Analysis/ConstantFolding.cpp": null,
"llvm/lib/Analysis/ScalarEvolution.cpp": null,
"llvm/lib/IR/Operator.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp": null,
"llvm/lib/Analysis/InstructionSimplify.cpp": null,
"llvm/lib/IR/AsmWriter.cpp": null,
"llvm/lib/Analysis/ValueTracking.cpp": null,
"llvm/lib/Transforms/Utils/PredicateInfo.cpp": null,
"llvm/lib/Transforms/Scalar/LoopFuse.cpp": null,
"llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp": null,
"llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": null,
"llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp": null,
"llvm/lib/Transforms/Utils/LoopPeel.cpp": null,
"llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": null,
"llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp": null,
"llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp": null,
"llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": null,
"llvm/lib/Transforms/Utils/SCCPSolver.cpp": null,
"llvm/lib/Transforms/Scalar/IndVarSimplify.cpp": null,
"llvm/lib/Transforms/IPO/FunctionAttrs.cpp": [
"getArgumentAccessInfo"
],
"llvm/lib/Analysis/LoopAccessAnalysis.cpp": null,
"llvm/lib/IR/ConstantFold.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp": null,
"llvm/lib/Transforms/Utils/SimplifyCFG.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp": null,
"llvm/lib/Transforms/Scalar/LICM.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp": null,
"llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h": null,
"llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp": null,
"llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": null,
"llvm/lib/Transforms/Coroutines/CoroSplit.cpp": null,
"llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp": null,
"llvm/include/llvm/IR/PatternMatch.h": null,
"llvm/lib/Analysis/LoopCacheAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp": null,
"llvm/lib/Transforms/IPO/SCCP.cpp": null,
"llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp": null,
"llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h": null,
"llvm/lib/Transforms/IPO/FunctionSpecialization.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp": null,
"llvm/lib/Transforms/Utils/DemoteRegToStack.cpp": null,
"llvm/lib/IR/Value.cpp": null,
"llvm/include/llvm/Analysis/AliasAnalysis.h": null,
"llvm/include/llvm/Analysis/BasicAliasAnalysis.h": null,
"llvm/lib/Analysis/BasicAliasAnalysis.cpp": null,
"llvm/lib/Transforms/Scalar/JumpThreading.cpp": null,
"llvm/lib/Analysis/Loads.cpp": null,
"llvm/lib/Transforms/Scalar/GVN.cpp": null,
"llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp": null,
"llvm/lib/Transforms/Scalar/Scalarizer.cpp": null,
"llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp": null,
"llvm/lib/IR/Instructions.cpp": null,
"llvm/lib/Transforms/Scalar/EarlyCSE.cpp": null,
"llvm/lib/Transforms/Utils/MoveAutoInit.cpp": null,
"llvm/lib/Transforms/Utils/ValueMapper.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.h": null,
"llvm/lib/Transforms/Scalar/Reassociate.cpp": null,
"llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp": null,
"llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp": null,
"llvm/lib/Transforms/Scalar/NewGVN.cpp": null,
"llvm/lib/Transforms/Scalar/BDCE.cpp": null,
"llvm/lib/Transforms/Vectorize/VPlanUtils.h": null,
"llvm/lib/Transforms/Vectorize/VPlan.cpp": null,
"llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp": null,
"llvm/lib/Analysis/VectorUtils.cpp": null,
"llvm/include/llvm/Transforms/Utils/Evaluator.h": null,
"llvm/lib/Transforms/Utils/Evaluator.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp": null,
"llvm/lib/Analysis/LazyValueInfo.cpp": null,
"llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp": null,
"llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp": null,
"llvm/lib/Transforms/IPO/AttributorAttributes.cpp": null,
"llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp": null,
"llvm/lib/Analysis/InlineCost.cpp": null,
"llvm/include/llvm/Analysis/SimplifyQuery.h": null,
"llvm/lib/Transforms/Utils/LowerSwitch.cpp": null,
"llvm/lib/Transforms/Scalar/GVNSink.cpp": null,
"llvm/include/llvm/Analysis/ValueTracking.h": null,
"llvm/lib/IR/Instruction.cpp": null
}
}
|
commit e44fbea0a17f468d45de5eaef158642f067f678c
Author: Shivam Gupta <shivam98.tkg@gmail.com>
Date: Tue Jul 1 18:34:52 2025 +0530
[FunctionAttrs] Handle ConstantRange overflow in memset initializes inference (#145739)
Avoid constructing invalid ConstantRange when Offset + Length in memset
overflows signed 64-bit integer space. This prevents assertion failures
when inferring the initializes attribute.
Fixes #140345
diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
index f918d7e059b6..f43202eea630 100644
--- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -675,14 +675,24 @@ ArgumentAccessInfo getArgumentAccessInfo(const Instruction *I,
[](Value *Length,
std::optional<int64_t> Offset) -> std::optional<ConstantRange> {
auto *ConstantLength = dyn_cast<ConstantInt>(Length);
- if (ConstantLength && Offset &&
- ConstantLength->getValue().isStrictlyPositive()) {
- return ConstantRange(
- APInt(64, *Offset, true),
- APInt(64, *Offset + ConstantLength->getSExtValue(), true));
+ if (ConstantLength && Offset) {
+ int64_t Len = ConstantLength->getSExtValue();
+
+ // Reject zero or negative lengths
+ if (Len <= 0)
+ return std::nullopt;
+
+ APInt Low(64, *Offset, true);
+ bool Overflow;
+ APInt High = Low.sadd_ov(APInt(64, Len, true), Overflow);
+ if (Overflow)
+ return std::nullopt;
+
+ return ConstantRange(Low, High);
}
return std::nullopt;
};
+
if (auto *SI = dyn_cast<StoreInst>(I)) {
if (SI->isSimple() && &SI->getOperandUse(1) == ArgUse.U) {
// Get the fixed type size of "SI". Since the access range of a write
|
[
{
"file": "llvm/test/Transforms/FunctionAttrs/initializes.ll",
"commands": [
"opt -passes=function-attrs -S < %s"
],
"tests": [
{
"test_name": "range_overflows_signed_64_bit_int",
"test_body": "define void @range_overflows_signed_64_bit_int(ptr %arg) {\n %getelementptr = getelementptr i8, ptr %arg, i64 9223372036854775804\n store i32 0, ptr %getelementptr, align 4\n ret void\n}\n",
"lli_expected_out": null,
"additional_args": null
},
{
"test_name": "memset_large_offset_nonzero_size",
"test_body": "define void @memset_large_offset_nonzero_size(ptr %dst) {\n %offset = getelementptr inbounds i8, ptr %dst, i64 9223372036854775805\n call void @llvm.memset.p0.i64(ptr %offset, i8 0, i64 3, i1 false)\n ret void\n}\n\n; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)\ndeclare void @llvm.memset.p0.i64(ptr writeonly captures(none), i8, i64, i1 immarg) #0\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }\n",
"lli_expected_out": null,
"additional_args": null
}
]
}
] |
{
"title": "[clang] Assertion `NewRange.getLower().slt(NewRange.getUpper())' failed.",
"body": "Reproducer:\nhttps://godbolt.org/z/zYorscvnP\n```c\ntypedef __SIZE_TYPE__ size_t;\nvoid *memset(void *, int, size_t);\n\nvoid foo(char *p) {\n size_t idx = __PTRDIFF_MAX__ - 3;\n\n ++idx;\n memset(p + idx, 0, 3);\n}\n```\n\nThe original reproducer of this issue is the following:\nhttps://github.com/gcc-mirror/gcc/blob/master/gcc/testsuite/gcc.dg/Wstringop-overflow-50.c\n\nBacktrace:\n```console\nclang: /root/llvm-project/llvm/lib/IR/ConstantRangeList.cpp:41: void llvm::ConstantRangeList::insert(const llvm::ConstantRange&): Assertion `NewRange.getLower().slt(NewRange.getUpper())' failed.\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\nStack dump:\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O1 <source>\n1.\t<eof> parser at end of file\n2.\tOptimizer\n3.\tRunning pass \"require<globals-aa>,function(invalidate<aa>),require<profile-summary>,cgscc(devirt<4>(inline,function-attrs<skip-non-recursive-function-attrs>,function<eager-inv;no-rerun>(sroa<modify-cfg>,early-cse<memssa>,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>,libcalls-shrinkwrap,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,loop-mssa(loop-instsimplify,loop-simplifycfg,licm<no-allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-unswitch<no-nontrivial;trivial>),simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>,loop(loop-idiom,indvars,loop-deletion,loop-unroll-full),sroa<modify-cfg>,memcpyopt,sccp,bdce,instcombine<max-iterations=1;no-verify-fixpoint>,coro-elide,adce,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>),function-attrs,function(require<should-not-run-function-passes>),coro-split,coro-annotation-elide)),function(invalidate<should-not-run-function-passes>),cgscc(devirt<4>())\" on module \"<source>\"\n4.\tRunning pass \"cgscc(devirt<4>(inline,function-attrs<skip-non-recursive-function-attrs>,function<eager-inv;no-rerun>(sroa<modify-cfg>,early-cse<memssa>,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>,libcalls-shrinkwrap,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,loop-mssa(loop-instsimplify,loop-simplifycfg,licm<no-allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-unswitch<no-nontrivial;trivial>),simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>,loop(loop-idiom,indvars,loop-deletion,loop-unroll-full),sroa<modify-cfg>,memcpyopt,sccp,bdce,instcombine<max-iterations=1;no-verify-fixpoint>,coro-elide,adce,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>),function-attrs,function(require<should-not-run-function-passes>),coro-split,coro-annotation-elide))\" on module \"<source>\"\n #0 0x0000000003f99d48 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3f99d48)\n #1 0x0000000003f979d4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3f979d4)\n #2 0x0000000003edc608 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0\n #3 0x00007ddca6042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\n #4 0x00007ddca60969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\n #5 0x00007ddca6042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\n #6 0x00007ddca60287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\n #7 0x00007ddca602871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\n #8 0x00007ddca6039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\n #9 0x00000000037b41bb llvm::ConstantRangeList::insert(llvm::ConstantRange const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x37b41bb)\n#10 0x000000000583e1cb inferInitializes(llvm::Argument&, llvm::Function&) FunctionAttrs.cpp:0:0\n#11 0x000000000583ef15 addArgumentAttrs(llvm::SmallSetVector<llvm::Function*, 8u> const&, llvm::SmallSet<llvm::Function*, 8u, std::less<llvm::Function*>>&, bool) FunctionAttrs.cpp:0:0\n#12 0x000000000584282e llvm::PostOrderFunctionAttrsPass::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x584282e)\n#13 0x000000000504fbae llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::PostOrderFunctionAttrsPass, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x504fbae)\n#14 0x0000000002dd1dd2 llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x2dd1dd2)\n#15 0x00000000051aface llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x51aface)\n#16 0x0000000002dd74a6 llvm::DevirtSCCRepeatedPass::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x2dd74a6)\n#17 0x00000000051afaee llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::DevirtSCCRepeatedPass, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x51afaee)\n#18 0x0000000002dd5376 llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x2dd5376)\n#19 0x00000000051afaae llvm::detail::PassModel<llvm::Module, llvm::ModuleToPostOrderCGSCCPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x51afaae)\n#20 0x00000000039326b0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x39326b0)\n#21 0x000000000589c503 llvm::ModuleInlinerWrapperPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x589c503)\n#22 0x000000000504fb7e llvm::detail::PassModel<llvm::Module, llvm::ModuleInlinerWrapperPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x504fb7e)\n#23 0x00000000039326b0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x39326b0)\n#24 0x000000000425330a (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 0x0000000004256381 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+0x4256381)\n#26 0x0000000004944bd0 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4944bd0)\n#27 0x000000000662d34c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x662d34c)\n#28 0x0000000004944fd8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4944fd8)\n#29 0x0000000004c3cea5 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4c3cea5)\n#30 0x0000000004bbbb3e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4bbbb3e)\n#31 0x0000000004d30a49 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4d30a49)\n#32 0x0000000000dac29f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdac29f)\n#33 0x0000000000da246a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\n#34 0x00000000049ac2c9 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0\n#35 0x0000000003edcaa4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3edcaa4)\n#36 0x00000000049ac8df clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0\n#37 0x000000000496e6ad clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x496e6ad)\n#38 0x000000000496f73e 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+0x496f73e)\n#39 0x0000000004977a25 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4977a25)\n#40 0x0000000000da8208 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xda8208)\n#41 0x0000000000c2df44 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc2df44)\n#42 0x00007ddca6029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\n#43 0x00007ddca6029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\n#44 0x0000000000da1f15 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xda1f15)\nclang: error: clang frontend command failed with exit code 134 (use -v to see invocation)\nCompiler returned: 134\n```\n",
"author": "k-arrows",
"labels": [
"ipo",
"crash",
"regression:20"
],
"comments": [
{
"author": "shafik",
"body": "Looks like a clang-20 regression: https://godbolt.org/z/Ya5zc8bf3"
},
{
"author": "xgupta",
"body": "The crash started after - 4d6e69143dc449814884ac649583d3b35bc4ae91"
}
]
}
| true |
{
"is_single_file_fix": true,
"is_single_func_fix": true
}
| null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.