summaryrefslogtreecommitdiff
path: root/lib/Transforms/InstCombine
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-06-02 14:32:58 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-06-02 14:32:58 +0000
commitd958619a2dbc7422fcd342849a898790a0bb082b (patch)
treedb8b00a4db1d17641221b889d010205cdbcdecdf /lib/Transforms/InstCombine
parente53c5d3baa3d49b27b3b6ffd0b30be9dea820425 (diff)
downloadllvm-d958619a2dbc7422fcd342849a898790a0bb082b.tar.gz
llvm-d958619a2dbc7422fcd342849a898790a0bb082b.tar.bz2
llvm-d958619a2dbc7422fcd342849a898790a0bb082b.tar.xz
Add the nsw flag when we detect that an add will not signed overflow.
We already had a function for checking this, we were just using it only in specialized cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210029 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine')
-rw-r--r--lib/Transforms/InstCombine/InstCombineAddSub.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/lib/Transforms/InstCombine/InstCombineAddSub.cpp
index c37a9cf2ef..4d8a1efd64 100644
--- a/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ b/lib/Transforms/InstCombine/InstCombineAddSub.cpp
@@ -1191,6 +1191,11 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
return BinaryOperator::CreateOr(A, B);
}
+ if (!I.hasNoSignedWrap() && WillNotOverflowSignedAdd(LHS, RHS)) {
+ Changed = true;
+ I.setHasNoSignedWrap(true);
+ }
+
return Changed ? &I : nullptr;
}