[llvm] r299871 - [InstCombine] improve variable names; NFCI
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 10 12:38:36 PDT 2017
Author: spatel
Date: Mon Apr 10 14:38:36 2017
New Revision: 299871
URL: http://llvm.org/viewvc/llvm-project?rev=299871&view=rev
Log:
[InstCombine] improve variable names; NFCI
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp?rev=299871&r1=299870&r2=299871&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Mon Apr 10 14:38:36 2017
@@ -755,7 +755,7 @@ Value *InstCombiner::FoldAndOfICmps(ICmp
return V;
// This only handles icmp of constants: (icmp1 A, C1) & (icmp2 B, C2).
- Value *Val = LHS->getOperand(0), *Val2 = RHS->getOperand(0);
+ Value *LHS0 = LHS->getOperand(0), *RHS0 = RHS->getOperand(0);
ConstantInt *LHSC = dyn_cast<ConstantInt>(LHS->getOperand(1));
ConstantInt *RHSC = dyn_cast<ConstantInt>(RHS->getOperand(1));
if (!LHSC || !RHSC)
@@ -767,7 +767,7 @@ Value *InstCombiner::FoldAndOfICmps(ICmp
// (icmp eq A, 0) & (icmp eq B, 0) --> (icmp eq (A|B), 0)
if ((PredL == ICmpInst::ICMP_ULT && LHSC->getValue().isPowerOf2()) ||
(PredL == ICmpInst::ICMP_EQ && LHSC->isZero())) {
- Value *NewOr = Builder->CreateOr(Val, Val2);
+ Value *NewOr = Builder->CreateOr(LHS0, RHS0);
return Builder->CreateICmp(PredL, NewOr, LHSC);
}
}
@@ -782,12 +782,12 @@ Value *InstCombiner::FoldAndOfICmps(ICmp
// (trunc x) == C1 & (and x, CA) == C2
// (and x, CA) == C2 & (trunc x) == C1
- if (match(Val2, m_Trunc(m_Value(V))) &&
- match(Val, m_And(m_Specific(V), m_ConstantInt(AndC)))) {
+ if (match(RHS0, m_Trunc(m_Value(V))) &&
+ match(LHS0, m_And(m_Specific(V), m_ConstantInt(AndC)))) {
SmallC = RHSC;
BigC = LHSC;
- } else if (match(Val, m_Trunc(m_Value(V))) &&
- match(Val2, m_And(m_Specific(V), m_ConstantInt(AndC)))) {
+ } else if (match(LHS0, m_Trunc(m_Value(V))) &&
+ match(RHS0, m_And(m_Specific(V), m_ConstantInt(AndC)))) {
SmallC = LHSC;
BigC = RHSC;
}
@@ -810,7 +810,7 @@ Value *InstCombiner::FoldAndOfICmps(ICmp
// FIXME: The code below is duplicated in FoldOrOfICmps.
// From here on, we only handle:
// (icmp1 A, C1) & (icmp2 A, C2) --> something simpler.
- if (Val != Val2)
+ if (LHS0 != RHS0)
return nullptr;
// ICMP_[US][GL]E X, C is folded to ICMP_[US][GL]T elsewhere.
@@ -867,14 +867,14 @@ Value *InstCombiner::FoldAndOfICmps(ICmp
llvm_unreachable("Unknown integer condition code!");
case ICmpInst::ICMP_ULT:
if (LHSC == SubOne(RHSC)) // (X != 13 & X u< 14) -> X < 13
- return Builder->CreateICmpULT(Val, LHSC);
+ return Builder->CreateICmpULT(LHS0, LHSC);
if (LHSC->isNullValue()) // (X != 0 & X u< 14) -> X-1 u< 13
- return insertRangeTest(Val, LHSC->getValue() + 1, RHSC->getValue(),
+ return insertRangeTest(LHS0, LHSC->getValue() + 1, RHSC->getValue(),
false, true);
break; // (X != 13 & X u< 15) -> no change
case ICmpInst::ICMP_SLT:
if (LHSC == SubOne(RHSC)) // (X != 13 & X s< 14) -> X < 13
- return Builder->CreateICmpSLT(Val, LHSC);
+ return Builder->CreateICmpSLT(LHS0, LHSC);
break; // (X != 13 & X s< 15) -> no change
case ICmpInst::ICMP_EQ: // (X != 13 & X == 15) -> X == 15
case ICmpInst::ICMP_UGT: // (X != 13 & X u> 15) -> X u> 15
@@ -883,9 +883,9 @@ Value *InstCombiner::FoldAndOfICmps(ICmp
case ICmpInst::ICMP_NE:
if (LHSC == SubOne(RHSC)) { // (X != 13 & X != 14) -> X-13 >u 1
Constant *AddC = ConstantExpr::getNeg(LHSC);
- Value *Add = Builder->CreateAdd(Val, AddC, Val->getName() + ".off");
+ Value *Add = Builder->CreateAdd(LHS0, AddC, LHS0->getName() + ".off");
return Builder->CreateICmpUGT(Add, ConstantInt::get(Add->getType(), 1),
- Val->getName() + ".cmp");
+ LHS0->getName() + ".cmp");
}
break; // (X != 13 & X != 15) -> no change
}
@@ -920,11 +920,11 @@ Value *InstCombiner::FoldAndOfICmps(ICmp
return RHS;
case ICmpInst::ICMP_NE:
if (RHSC == AddOne(LHSC)) // (X u> 13 & X != 14) -> X u> 14
- return Builder->CreateICmp(PredL, Val, RHSC);
+ return Builder->CreateICmp(PredL, LHS0, RHSC);
break; // (X u> 13 & X != 15) -> no change
case ICmpInst::ICMP_ULT: // (X u> 13 & X u< 15) -> (X-14) <u 1
- return insertRangeTest(Val, LHSC->getValue() + 1, RHSC->getValue(), false,
- true);
+ return insertRangeTest(LHS0, LHSC->getValue() + 1, RHSC->getValue(),
+ false, true);
}
break;
case ICmpInst::ICMP_SGT:
@@ -936,10 +936,10 @@ Value *InstCombiner::FoldAndOfICmps(ICmp
return RHS;
case ICmpInst::ICMP_NE:
if (RHSC == AddOne(LHSC)) // (X s> 13 & X != 14) -> X s> 14
- return Builder->CreateICmp(PredL, Val, RHSC);
+ return Builder->CreateICmp(PredL, LHS0, RHSC);
break; // (X s> 13 & X != 15) -> no change
case ICmpInst::ICMP_SLT: // (X s> 13 & X s< 15) -> (X-14) s< 1
- return insertRangeTest(Val, LHSC->getValue() + 1, RHSC->getValue(), true,
+ return insertRangeTest(LHS0, LHSC->getValue() + 1, RHSC->getValue(), true,
true);
}
break;
@@ -1671,25 +1671,25 @@ Value *InstCombiner::FoldOrOfICmps(ICmpI
if (Value *V = foldLogOpOfMaskedICmps(LHS, RHS, false, Builder))
return V;
- Value *Val = LHS->getOperand(0), *Val2 = RHS->getOperand(0);
+ Value *LHS0 = LHS->getOperand(0), *RHS0 = RHS->getOperand(0);
if (LHS->hasOneUse() || RHS->hasOneUse()) {
// (icmp eq B, 0) | (icmp ult A, B) -> (icmp ule A, B-1)
// (icmp eq B, 0) | (icmp ugt B, A) -> (icmp ule A, B-1)
Value *A = nullptr, *B = nullptr;
if (PredL == ICmpInst::ICMP_EQ && LHSC && LHSC->isZero()) {
- B = Val;
- if (PredR == ICmpInst::ICMP_ULT && Val == RHS->getOperand(1))
- A = Val2;
- else if (PredR == ICmpInst::ICMP_UGT && Val == Val2)
+ B = LHS0;
+ if (PredR == ICmpInst::ICMP_ULT && LHS0 == RHS->getOperand(1))
+ A = RHS0;
+ else if (PredR == ICmpInst::ICMP_UGT && LHS0 == RHS0)
A = RHS->getOperand(1);
}
// (icmp ult A, B) | (icmp eq B, 0) -> (icmp ule A, B-1)
// (icmp ugt B, A) | (icmp eq B, 0) -> (icmp ule A, B-1)
else if (PredR == ICmpInst::ICMP_EQ && RHSC && RHSC->isZero()) {
- B = Val2;
- if (PredL == ICmpInst::ICMP_ULT && Val2 == LHS->getOperand(1))
- A = Val;
- else if (PredL == ICmpInst::ICMP_UGT && Val2 == Val)
+ B = RHS0;
+ if (PredL == ICmpInst::ICMP_ULT && RHS0 == LHS->getOperand(1))
+ A = LHS0;
+ else if (PredL == ICmpInst::ICMP_UGT && LHS0 == RHS0)
A = LHS->getOperand(1);
}
if (A && B)
@@ -1713,7 +1713,7 @@ Value *InstCombiner::FoldOrOfICmps(ICmpI
if (LHSC == RHSC && PredL == PredR) {
// (icmp ne A, 0) | (icmp ne B, 0) --> (icmp ne (A|B), 0)
if (PredL == ICmpInst::ICMP_NE && LHSC->isZero()) {
- Value *NewOr = Builder->CreateOr(Val, Val2);
+ Value *NewOr = Builder->CreateOr(LHS0, RHS0);
return Builder->CreateICmp(PredL, NewOr, LHSC);
}
}
@@ -1722,15 +1722,15 @@ Value *InstCombiner::FoldOrOfICmps(ICmpI
// iff C2 + CA == C1.
if (PredL == ICmpInst::ICMP_ULT && PredR == ICmpInst::ICMP_EQ) {
ConstantInt *AddC;
- if (match(Val, m_Add(m_Specific(Val2), m_ConstantInt(AddC))))
+ if (match(LHS0, m_Add(m_Specific(RHS0), m_ConstantInt(AddC))))
if (RHSC->getValue() + AddC->getValue() == LHSC->getValue())
- return Builder->CreateICmpULE(Val, LHSC);
+ return Builder->CreateICmpULE(LHS0, LHSC);
}
// FIXME: The code below is duplicated in FoldAndOfICmps.
// From here on, we only handle:
// (icmp1 A, C1) | (icmp2 A, C2) --> something simpler.
- if (Val != Val2)
+ if (LHS0 != RHS0)
return nullptr;
// ICMP_[US][GL]E X, C is folded to ICMP_[US][GL]T elsewhere.
@@ -1793,7 +1793,7 @@ Value *InstCombiner::FoldOrOfICmps(ICmpI
if (LHSC == SubOne(RHSC)) {
// (X == 13 | X == 14) -> X-13 <u 2
Constant *AddC = ConstantExpr::getNeg(LHSC);
- Value *Add = Builder->CreateAdd(Val, AddC, Val->getName() + ".off");
+ Value *Add = Builder->CreateAdd(LHS0, AddC, LHS0->getName() + ".off");
AddC = ConstantExpr::getSub(AddOne(RHSC), LHSC);
return Builder->CreateICmpULT(Add, AddC);
}
@@ -1832,8 +1832,8 @@ Value *InstCombiner::FoldOrOfICmps(ICmpI
// this can cause overflow.
if (RHSC->isMaxValue(false))
return LHS;
- return insertRangeTest(Val, LHSC->getValue(), RHSC->getValue() + 1, false,
- false);
+ return insertRangeTest(LHS0, LHSC->getValue(), RHSC->getValue() + 1,
+ false, false);
case ICmpInst::ICMP_NE: // (X u< 13 | X != 15) -> X != 15
case ICmpInst::ICMP_ULT: // (X u< 13 | X u< 15) -> X u< 15
return RHS;
@@ -1850,7 +1850,7 @@ Value *InstCombiner::FoldOrOfICmps(ICmpI
// this can cause overflow.
if (RHSC->isMaxValue(true))
return LHS;
- return insertRangeTest(Val, LHSC->getValue(), RHSC->getValue() + 1, true,
+ return insertRangeTest(LHS0, LHSC->getValue(), RHSC->getValue() + 1, true,
false);
case ICmpInst::ICMP_NE: // (X s< 13 | X != 15) -> X != 15
case ICmpInst::ICMP_SLT: // (X s< 13 | X s< 15) -> X s< 15
More information about the llvm-commits
mailing list