aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-05-04 15:19:33 +0000
committerChris Lattner <sabre@nondot.org>2004-05-04 15:19:33 +0000
commit32ed46b36e1457b0b978cd5434cce3bdae4c914b (patch)
tree7d27c1458fe88ee192415414d675002241543d78 /lib/Transforms
parent96e68f9ab1b3dfcf3be9c8a18d82adef0ad7f3d8 (diff)
Minor efficiency tweak, suggested by Patrick Meredith
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13341 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 138dc96253..2266a70b6e 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -12,10 +12,10 @@
// simplification happens.
//
// This pass combines things like:
-// %Y = add int 1, %X
-// %Z = add int 1, %Y
+// %Y = add int %X, 1
+// %Z = add int %Y, 1
// into:
-// %Z = add int 2, %X
+// %Z = add int %X, 2
//
// This is a simple worklist driven algorithm.
//
@@ -887,7 +887,7 @@ Instruction *InstCombiner::visitRem(BinaryOperator &I) {
// if so, convert to a bitwise and.
if (ConstantUInt *C = dyn_cast<ConstantUInt>(RHS))
if (uint64_t Val = C->getValue()) // Don't break X % 0 (divide by zero)
- if (Log2(Val))
+ if (!(Val & Val-1)) // Power of 2
return BinaryOperator::create(Instruction::And, I.getOperand(0),
ConstantUInt::get(I.getType(), Val-1));
}