Skip to content

Commit a03535c

Browse files
committed
Add a flag to control poison-reuse guard
1 parent 3dc98c9 commit a03535c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ static const unsigned UnknownAddressSpace =
115115
DEBUG_COUNTER(StraightLineStrengthReduceCounter, "slsr-counter",
116116
"Controls whether rewriteCandidate is executed.");
117117

118+
// Only for testing.
119+
static cl::opt<bool>
120+
EnablePoisonReuseGuard("enable-poison-reuse-guard", cl::init(true),
121+
cl::desc("Enable poison-reuse guard"));
122+
118123
namespace {
119124

120125
class StraightLineStrengthReduceLegacyPass : public FunctionPass {
@@ -680,8 +685,9 @@ bool StraightLineStrengthReduce::candidatePredicate(Candidate *Basis,
680685
SmallVector<Instruction *> DropPoisonGeneratingInsts;
681686
// Ensure the IR of Basis->Ins is not more poisonous than its SCEV.
682687
if (!isSimilar(C, *Basis, K) ||
683-
!SE->canReuseInstruction(SE->getSCEV(Basis->Ins), Basis->Ins,
684-
DropPoisonGeneratingInsts))
688+
(EnablePoisonReuseGuard &&
689+
!SE->canReuseInstruction(SE->getSCEV(Basis->Ins), Basis->Ins,
690+
DropPoisonGeneratingInsts)))
685691
return false;
686692

687693
assert(DT->dominates(Basis->Ins, C.Ins));

0 commit comments

Comments
 (0)