summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2013-07-13 01:16:47 +0000
committerNick Lewycky <nicholas@mxc.ca>2013-07-13 01:16:47 +0000
commit75681bb302e524460edb7c8c5c6e98792b5027a2 (patch)
tree1ce2531e7f274d9103d2cbd502a74b0453d70ee3 /lib
parent12c74dc2c2ee306f60fb39a9b2a43000e23addcc (diff)
downloadllvm-75681bb302e524460edb7c8c5c6e98792b5027a2.tar.gz
llvm-75681bb302e524460edb7c8c5c6e98792b5027a2.tar.bz2
llvm-75681bb302e524460edb7c8c5c6e98792b5027a2.tar.xz
Add a microoptimization for urem.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186235 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/InstCombine/InstCombineMulDivRem.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
index e94f71917f..eac24c6345 100644
--- a/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
+++ b/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
@@ -1125,6 +1125,13 @@ Instruction *InstCombiner::visitURem(BinaryOperator &I) {
return BinaryOperator::CreateAnd(Op0, Add);
}
+ // 1 urem X -> zext(X != 1)
+ if (match(Op0, m_One())) {
+ Value *Cmp = Builder->CreateICmpNE(Op1, Op0);
+ Value *Ext = Builder->CreateZExt(Cmp, I.getType());
+ return ReplaceInstUsesWith(I, Ext);
+ }
+
return 0;
}