summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
diff options
context:
space:
mode:
authorChen Zheng <czhengsz@cn.ibm.com>2019-04-08 12:08:03 +0000
committerChen Zheng <czhengsz@cn.ibm.com>2019-04-08 12:08:03 +0000
commit923c7c9daaa5d90be4f2bcc58652a2c925a3c4db (patch)
tree12b82871558d051f2dd0a601aaa6f536cf0a3f50 /llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
parent0df95d2d31279fdeb6370e0c6d71003607af9c8d (diff)
downloadbcm5719-llvm-923c7c9daaa5d90be4f2bcc58652a2c925a3c4db.tar.gz
bcm5719-llvm-923c7c9daaa5d90be4f2bcc58652a2c925a3c4db.zip
[InstCombine] sdiv exact flag fixup.
Differential Revision: https://reviews.llvm.org/D60396 llvm-svn: 357904
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
index 6d743a26098..d5a36e025f6 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
@@ -1693,8 +1693,11 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
// 0 - (X sdiv C) -> (X sdiv -C) provided the negation doesn't overflow.
if (match(Op1, m_SDiv(m_Value(X), m_Constant(C))) && match(Op0, m_Zero()) &&
- C->isNotMinSignedValue() && !C->isOneValue())
- return BinaryOperator::CreateSDiv(X, ConstantExpr::getNeg(C));
+ C->isNotMinSignedValue() && !C->isOneValue()) {
+ auto *BO = BinaryOperator::CreateSDiv(X, ConstantExpr::getNeg(C));
+ BO->setIsExact(cast<BinaryOperator>(Op1)->isExact());
+ return BO;
+ }
// 0 - (X << Y) -> (-X << Y) when X is freely negatable.
if (match(Op1, m_Shl(m_Value(X), m_Value(Y))) && match(Op0, m_Zero()))
OpenPOWER on IntegriCloud