aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/InstCombine/InstCombineCompares.cpp
diff options
context:
space:
mode:
authorMark Seaborn <mseaborn@chromium.org>2013-05-28 18:53:14 -0700
committerMark Seaborn <mseaborn@chromium.org>2013-05-28 18:53:14 -0700
commit8d01804c97533ed9006a65c11cade3c6b23d1c75 (patch)
treec073a4ad687e373698cdbe5d3c3735ba39c18b1a /lib/Transforms/InstCombine/InstCombineCompares.cpp
parent75e093a353d4a6420fed47fb46fb7134a922ec61 (diff)
PNaCl: Disable parts of InstCombine that introduce *.with.overflow intrinsics
Change the PNaCl ABI checker to disallow these intrinsics. Note that I had originally intended to commit this before my earlier change (https://codereview.chromium.org/15688011) that enables the ExpandArithWithOverflow pass. Enabling ExpandArithWithOverflow without changing InstCombine causes ExpandArithWithOverflow to fail on some of the *.with.overflow intrinsic calls that InstCombine introduces. This change therefore fixes some breakage. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3434 TEST=PNaCl toolchain trybots + GCC torture tests + LLVM test suite Review URL: https://codereview.chromium.org/16042011
Diffstat (limited to 'lib/Transforms/InstCombine/InstCombineCompares.cpp')
-rw-r--r--lib/Transforms/InstCombine/InstCombineCompares.cpp52
1 files changed, 31 insertions, 21 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineCompares.cpp b/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 0267117421..6eca399a40 100644
--- a/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -1942,13 +1942,17 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
//
// sum = a + b
// if (sum+128 >u 255) ... -> llvm.sadd.with.overflow.i8
- {
- ConstantInt *CI2; // I = icmp ugt (add (add A, B), CI2), CI
- if (I.getPredicate() == ICmpInst::ICMP_UGT &&
- match(Op0, m_Add(m_Add(m_Value(A), m_Value(B)), m_ConstantInt(CI2))))
- if (Instruction *Res = ProcessUGT_ADDCST_ADD(I, A, B, CI2, CI, *this))
- return Res;
+ // @LOCALMOD-BEGIN
+ // This is disabled for PNaCl, because we don't support the
+ // with.overflow intrinsics in PNaCl's stable ABI.
+ if (0) {
+ ConstantInt *CI2; // I = icmp ugt (add (add A, B), CI2), CI
+ if (I.getPredicate() == ICmpInst::ICMP_UGT &&
+ match(Op0, m_Add(m_Add(m_Value(A), m_Value(B)), m_ConstantInt(CI2))))
+ if (Instruction *Res = ProcessUGT_ADDCST_ADD(I, A, B, CI2, CI, *this))
+ return Res;
}
+ // @LOCALMOD-END
// (icmp ne/eq (sub A B) 0) -> (icmp ne/eq A, B)
if (I.isEquality() && CI->isZero() &&
@@ -2554,21 +2558,27 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
return new ICmpInst(I.getPredicate(), ConstantExpr::getNot(RHSC), A);
}
- // (a+b) <u a --> llvm.uadd.with.overflow.
- // (a+b) <u b --> llvm.uadd.with.overflow.
- if (I.getPredicate() == ICmpInst::ICMP_ULT &&
- match(Op0, m_Add(m_Value(A), m_Value(B))) &&
- (Op1 == A || Op1 == B))
- if (Instruction *R = ProcessUAddIdiom(I, Op0, *this))
- return R;
-
- // a >u (a+b) --> llvm.uadd.with.overflow.
- // b >u (a+b) --> llvm.uadd.with.overflow.
- if (I.getPredicate() == ICmpInst::ICMP_UGT &&
- match(Op1, m_Add(m_Value(A), m_Value(B))) &&
- (Op0 == A || Op0 == B))
- if (Instruction *R = ProcessUAddIdiom(I, Op1, *this))
- return R;
+ // @LOCALMOD-BEGIN
+ // This is disabled for PNaCl, because we don't support the
+ // with.overflow intrinsics in PNaCl's stable ABI.
+ if (0) {
+ // (a+b) <u a --> llvm.uadd.with.overflow.
+ // (a+b) <u b --> llvm.uadd.with.overflow.
+ if (I.getPredicate() == ICmpInst::ICMP_ULT &&
+ match(Op0, m_Add(m_Value(A), m_Value(B))) &&
+ (Op1 == A || Op1 == B))
+ if (Instruction *R = ProcessUAddIdiom(I, Op0, *this))
+ return R;
+
+ // a >u (a+b) --> llvm.uadd.with.overflow.
+ // b >u (a+b) --> llvm.uadd.with.overflow.
+ if (I.getPredicate() == ICmpInst::ICMP_UGT &&
+ match(Op1, m_Add(m_Value(A), m_Value(B))) &&
+ (Op0 == A || Op0 == B))
+ if (Instruction *R = ProcessUAddIdiom(I, Op1, *this))
+ return R;
+ }
+ // @LOCALMOD-END
}
if (I.isEquality()) {