summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2017-10-13 17:00:47 +0000
committerSanjay Patel <spatel@rotateright.com>2017-10-13 17:00:47 +0000
commit76ed9eab29dde1acd7b46fbfe8fffe7e8ce7fb40 (patch)
tree9345a5b7a00766cc7aaa9de6dbf7d8b5199f7785 /llvm/lib/Transforms/InstCombine
parent78f486d1366394e23862d47199dc7c1321ad7f75 (diff)
downloadbcm5719-llvm-76ed9eab29dde1acd7b46fbfe8fffe7e8ce7fb40.tar.gz
bcm5719-llvm-76ed9eab29dde1acd7b46fbfe8fffe7e8ce7fb40.zip
[InstCombine] use AddOne helper to reduce code; NFC
llvm-svn: 315709
Diffstat (limited to 'llvm/lib/Transforms/InstCombine')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
index 75cc683b7a6..92452d7df73 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
@@ -960,13 +960,9 @@ Instruction *InstCombiner::foldAddWithConstant(BinaryOperator &Add) {
return NV;
Value *X;
- Type *Ty = Add.getType();
- if (match(Op0, m_ZExt(m_Value(X))) &&
- X->getType()->getScalarSizeInBits() == 1) {
+ if (match(Op0, m_ZExt(m_Value(X))) && X->getType()->getScalarSizeInBits() == 1)
// zext(bool) + C -> bool ? C + 1 : C
- Constant *One = ConstantInt::get(Ty, 1);
- return SelectInst::Create(X, ConstantExpr::getAdd(Op1C, One), Op1);
- }
+ return SelectInst::Create(X, AddOne(Op1C), Op1);
const APInt *C;
if (!match(Op1, m_APInt(C)))
@@ -985,6 +981,7 @@ Instruction *InstCombiner::foldAddWithConstant(BinaryOperator &Add) {
// Is this add the last step in a convoluted sext?
// add(zext(xor i16 X, -32768), -32768) --> sext X
+ Type *Ty = Add.getType();
const APInt *C2;
if (match(Op0, m_ZExt(m_Xor(m_Value(X), m_APInt(C2)))) &&
C2->isMinSignedValue() && C2->sext(Ty->getScalarSizeInBits()) == *C)
OpenPOWER on IntegriCloud