diff options
author | Evan Cheng <evan.cheng@apple.com> | 2012-06-21 22:52:49 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2012-06-21 22:52:49 +0000 |
commit | 32c7cc8ec9d48d2b688301e75fb6bc2d460adcbc (patch) | |
tree | 14861acb455c838f8f7025264651bf4acfadae7d /llvm/lib/Transforms/InstCombine | |
parent | 26f5a627126674e7dc82bd70c84f80afd496ff7a (diff) | |
download | bcm5719-llvm-32c7cc8ec9d48d2b688301e75fb6bc2d460adcbc.tar.gz bcm5719-llvm-32c7cc8ec9d48d2b688301e75fb6bc2d460adcbc.zip |
Look pass zext to strength reduce an udiv. Patch by David Majnemer. rdar://11721329
llvm-svn: 158946
Diffstat (limited to 'llvm/lib/Transforms/InstCombine')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp index 5168e2a113c..35a0bbb7614 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp @@ -464,9 +464,12 @@ Instruction *InstCombiner::visitUDiv(BinaryOperator &I) { // X udiv (C1 << N), where C1 is "1<<C2" --> X >> (N+C2) { const APInt *CI; Value *N; - if (match(Op1, m_Shl(m_Power2(CI), m_Value(N)))) { + if (match(Op1, m_Shl(m_Power2(CI), m_Value(N))) || + match(Op1, m_ZExt(m_Shl(m_Power2(CI), m_Value(N))))) { if (*CI != 1) N = Builder->CreateAdd(N, ConstantInt::get(I.getType(),CI->logBase2())); + if (ZExtInst *Z = dyn_cast<ZExtInst>(Op1)) + N = Builder->CreateZExt(N, Z->getDestTy()); if (I.isExact()) return BinaryOperator::CreateExactLShr(Op0, N); return BinaryOperator::CreateLShr(Op0, N); |