[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp

Chris Lattner lattner at cs.uiuc.edu
Tue May 4 10:19:02 PDT 2004


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.197 -> 1.198

---
Log message:

Minor efficiency tweak, suggested by Patrick Meredith


---
Diffs of the changes:  (+4 -4)

Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.197 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.198
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.197	Sat May  1 18:27:23 2004
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Tue May  4 10:19:33 2004
@@ -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 @@
     // 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));
   }





More information about the llvm-commits mailing list