diff options
author | Chris Lattner <sabre@nondot.org> | 2011-05-23 00:09:55 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-05-23 00:09:55 +0000 |
commit | 321c58fc41a52ccfb3aa0d2a0eeda84eb8be5dbe (patch) | |
tree | c811f86f08448ab17f0f294656e2d54bd735a552 | |
parent | 83791ced7ba2a2d43d37bb1350f28ddf83c029f9 (diff) | |
download | bcm5719-llvm-321c58fc41a52ccfb3aa0d2a0eeda84eb8be5dbe.tar.gz bcm5719-llvm-321c58fc41a52ccfb3aa0d2a0eeda84eb8be5dbe.zip |
use the valuetracking isPowerOfTwo function, which is more powerful than checking
for a constant directly. Thanks to Duncan for pointing this out.
llvm-svn: 131885
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp index 98a36545ad7..fdec6407b80 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp @@ -31,13 +31,13 @@ static Value *simplifyValueKnownNonZero(Value *V, InstCombiner &IC) { // ((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: |