[llvm-commits] [llvm] r131885 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
Chris Lattner
sabre at nondot.org
Sun May 22 17:09:55 PDT 2011
Author: lattner
Date: Sun May 22 19:09:55 2011
New Revision: 131885
URL: http://llvm.org/viewvc/llvm-project?rev=131885&view=rev
Log:
use the valuetracking isPowerOfTwo function, which is more powerful than checking
for a constant directly. Thanks to Duncan for pointing this out.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp?rev=131885&r1=131884&r2=131885&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp Sun May 22 19:09:55 2011
@@ -31,13 +31,13 @@
// ((1 << A) >>u B) --> (1 << (A-B))
// Because V cannot be zero, we know that B is less than A.
- Value *A = 0, *B = 0; ConstantInt *One = 0;
- if (match(V, m_LShr(m_OneUse(m_Shl(m_ConstantInt(One), m_Value(A))),
+ Value *A = 0, *B = 0, *PowerOf2 = 0;
+ if (match(V, m_LShr(m_OneUse(m_Shl(m_Value(PowerOf2), m_Value(A))),
m_Value(B))) &&
// The "1" can be any value known to be a power of 2.
- One->getValue().isPowerOf2()) {
+ isPowerOfTwo(PowerOf2, IC.getTargetData())) {
A = IC.Builder->CreateSub(A, B, "tmp");
- return IC.Builder->CreateShl(One, A);
+ return IC.Builder->CreateShl(PowerOf2, A);
}
// TODO: Lots more we could do here:
More information about the llvm-commits
mailing list