summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2010-11-17 19:11:46 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2010-11-17 19:11:46 +0000
commit07726c7d526788c92099a2fffedd88eb15aae28e (patch)
tree150434bda9a33565d95f56dce992a9785b030d98 /llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
parentb94e5a33b372eaa88361576722b605e4f8c5d07a (diff)
downloadbcm5719-llvm-07726c7d526788c92099a2fffedd88eb15aae28e.tar.gz
bcm5719-llvm-07726c7d526788c92099a2fffedd88eb15aae28e.zip
InstCombine: Add a missing irem identity (X % X -> 0).
llvm-svn: 119538
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
index c2ae4cc6371..1433f7bbc94 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
@@ -551,6 +551,10 @@ Instruction *InstCombiner::commonIRemTransforms(BinaryOperator &I) {
if (Instruction *common = commonRemTransforms(I))
return common;
+ // X % X == 0
+ if (Op0 == Op1)
+ return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
+
// 0 % X == 0 for integer, we don't need to preserve faults!
if (Constant *LHS = dyn_cast<Constant>(Op0))
if (LHS->isNullValue())
OpenPOWER on IntegriCloud