summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
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
commitdd1a86d8587cef85f5711b2f47651048a49e102d (patch)
tree79570bea5301b951f81c8a2e951a740cde891264 /llvm/lib/Transforms/Scalar/InstructionCombining.cpp
parent5237476f7523c6820453377a45630f9ddabec4ed (diff)
downloadbcm5719-llvm-dd1a86d8587cef85f5711b2f47651048a49e102d.tar.gz
bcm5719-llvm-dd1a86d8587cef85f5711b2f47651048a49e102d.zip
Minor efficiency tweak, suggested by Patrick Meredith
llvm-svn: 13341
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 138dc962532..2266a70b6e6 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/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));
}
OpenPOWER on IntegriCloud