diff options
Diffstat (limited to 'lib/Transforms/InstCombine/InstCombineAddSub.cpp')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineAddSub.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/lib/Transforms/InstCombine/InstCombineAddSub.cpp index 4ff005e26c..89cc540da7 100644 --- a/lib/Transforms/InstCombine/InstCombineAddSub.cpp +++ b/lib/Transforms/InstCombine/InstCombineAddSub.cpp @@ -147,8 +147,13 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) { return BinaryOperator::CreateXor(LHS, RHS); // X + X --> X << 1 - if (LHS == RHS && I.getType()->isIntegerTy()) - return BinaryOperator::CreateShl(LHS, ConstantInt::get(I.getType(), 1)); + if (LHS == RHS && I.getType()->isIntegerTy()) { + BinaryOperator *New = + BinaryOperator::CreateShl(LHS, ConstantInt::get(I.getType(), 1)); + New->setHasNoSignedWrap(I.hasNoSignedWrap()); + New->setHasNoUnsignedWrap(I.hasNoUnsignedWrap()); + return New; + } // -A + B --> B - A // -A + -B --> -(A + B) |