aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2014-11-22 18:16:54 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2014-11-22 18:16:54 +0000
commita3aeb15613afba82349f5cf8575ab88475342395 (patch)
treef703343e1b64b5016a8a990d16207d83effeb0d7 /llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
parent94a272d47980c61dd8fdf839c1307de406a9a58e (diff)
downloadllvm-a3aeb15613afba82349f5cf8575ab88475342395.zip
llvm-a3aeb15613afba82349f5cf8575ab88475342395.tar.gz
llvm-a3aeb15613afba82349f5cf8575ab88475342395.tar.bz2
InstCombine: Propagate exact in (udiv (lshr X,C1),C2) -> (udiv x,C1<<C2)
llvm-svn: 222620
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
index 010625a..2befe19 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
@@ -997,9 +997,14 @@ Instruction *InstCombiner::visitUDiv(BinaryOperator &I) {
match(Op1, m_APInt(C2))) {
bool Overflow;
APInt C2ShlC1 = C2->ushl_ov(*C1, Overflow);
- if (!Overflow)
- return BinaryOperator::CreateUDiv(
+ if (!Overflow) {
+ bool IsExact = I.isExact() && match(Op0, m_Exact(m_Value()));
+ BinaryOperator *BO = BinaryOperator::CreateUDiv(
X, ConstantInt::get(X->getType(), C2ShlC1));
+ if (IsExact)
+ BO->setIsExact();
+ return BO;
+ }
}
}