diff options
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/README.txt | 12 | ||||
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 14 |
2 files changed, 12 insertions, 14 deletions
diff --git a/llvm/lib/Target/README.txt b/llvm/lib/Target/README.txt index 4ecacf9d010..a9aab86abda 100644 --- a/llvm/lib/Target/README.txt +++ b/llvm/lib/Target/README.txt @@ -930,6 +930,18 @@ optimized with "clang -emit-llvm-bc | opt -std-compile-opts". //===---------------------------------------------------------------------===// +int g(int x) { return (x - 10) < 0; } +Should combine to "x <= 9" (the sub has nsw). Currently not +optimized with "clang -emit-llvm-bc | opt -std-compile-opts". + +//===---------------------------------------------------------------------===// + +int g(int x) { return (x + 10) < 0; } +Should combine to "x < -10" (the add has nsw). Currently not +optimized with "clang -emit-llvm-bc | opt -std-compile-opts". + +//===---------------------------------------------------------------------===// + int f(int i, int j) { return i < j + 1; } int g(int i, int j) { return j > i - 1; } Should combine to "i <= j" (the add/sub has nsw). Currently not diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index fea0d0245c8..8c0ad525980 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -3008,20 +3008,6 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { // icmp X, X+Cst if (match(Op1, m_Add(m_Value(X), m_ConstantInt(Cst))) && Op0 == X) return FoldICmpAddOpCst(I, X, Cst, I.getSwappedPredicate()); - - ConstantInt *Cst2; - if (I.isSigned() && - match(Op1, m_ConstantInt(Cst)) && - match(Op0, m_Add(m_Value(X), m_ConstantInt(Cst2))) && - cast<BinaryOperator>(Op0)->hasNoSignedWrap()) { - // icmp X+Cst2, Cst --> icmp X, Cst-Cst2 - // iff Cst-Cst2 does not overflow - bool Overflow; - APInt NewCst = Cst->getValue().ssub_ov(Cst2->getValue(), Overflow); - if (!Overflow) - return new ICmpInst(I.getPredicate(), X, - ConstantInt::get(Cst->getType(), NewCst)); - } } return Changed ? &I : 0; } |

