summaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-06-07 04:12:35 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-06-07 04:12:35 +0000
commit68caf1727f809804b4fcfcefd475490fef9d304d (patch)
treea121ad6bd8b7b3395fa0fa675bf66948f234bff5 /lib/Transforms
parent808823cf77076a4a77937a02b0c51b315f722b7b (diff)
downloadllvm-68caf1727f809804b4fcfcefd475490fef9d304d.tar.gz
llvm-68caf1727f809804b4fcfcefd475490fef9d304d.tar.bz2
llvm-68caf1727f809804b4fcfcefd475490fef9d304d.tar.xz
Revert 209903 and 210040.
The messages were "PR19753: Optimize comparisons with "ashr exact" of a constanst." "Added support to optimize comparisons with "lshr exact" of a constant." They were not correctly handling signed/unsigned operation differences, causing pr19958. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210393 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/InstCombine/InstCombineCompares.cpp40
1 files changed, 0 insertions, 40 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineCompares.cpp b/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 13a5cd96f7..d98f966f8c 100644
--- a/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -2318,32 +2318,6 @@ static bool swapMayExposeCSEOpportunities(const Value * Op0,
return GlobalSwapBenefits > 0;
}
-// Helper function to check whether Op represents a lshr/ashr exact
-// instruction. For example:
-// (icmp (ashr exact const2, A), const1) -> icmp A, Log2(const2/const1)
-// Here if Op represents -> (ashr exact const2, A), and CI represents
-// const1, we compute Quotient as const2/const1.
-
-static bool checkShrExact(Value *Op, APInt &Quotient, const ConstantInt *CI,
- Value *&A) {
-
- ConstantInt *CI2;
- if (match(Op, m_AShr(m_ConstantInt(CI2), m_Value(A))) &&
- (cast<BinaryOperator>(Op)->isExact())) {
- Quotient = CI2->getValue().sdiv(CI->getValue());
- return true;
- }
-
- // Handle the case for lhsr.
- if (match(Op, m_LShr(m_ConstantInt(CI2), m_Value(A))) &&
- (cast<BinaryOperator>(Op)->isExact())) {
- Quotient = CI2->getValue().udiv(CI->getValue());
- return true;
- }
-
- return false;
-}
-
Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
bool Changed = false;
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
@@ -2465,20 +2439,6 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
return new ICmpInst(I.getPredicate(), A, B);
}
- // PR19753:
- // (icmp (ashr exact const2, A), const1) -> icmp A, Log2(const2/const1)
- // Cases where const1 doesn't divide const2 exactly or Quotient is not
- // exact of log2 are handled by SimplifyICmpInst call above where we
- // return false. Similar for lshr.
- {
- APInt Quotient;
- if (checkShrExact(Op0, Quotient, CI, A)) {
- unsigned shift = Quotient.logBase2();
- return new ICmpInst(I.getPredicate(), A,
- ConstantInt::get(A->getType(), shift));
- }
- }
-
// If we have an icmp le or icmp ge instruction, turn it into the
// appropriate icmp lt or icmp gt instruction. This allows us to rely on
// them being folded in the code below. The SimplifyICmpInst code has