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

Zhou Sheng zhousheng00 at gmail.com
Fri Mar 30 19:38:57 PDT 2007



Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.712 -> 1.713
---
Log message:

Use APInt operators to calculate the carry bits, remove this loop.


---
Diffs of the changes:  (+2 -16)

 InstructionCombining.cpp |   18 ++----------------
 1 files changed, 2 insertions(+), 16 deletions(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.712 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.713
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.712	Fri Mar 30 12:20:39 2007
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Fri Mar 30 21:38:39 2007
@@ -1243,22 +1243,8 @@
       // To compute this, we first compute the potential carry bits.  These are
       // the bits which may be modified.  I'm not aware of a better way to do
       // this scan.
-      APInt RHSVal(RHS->getValue());
-      
-      bool CarryIn = false;
-      APInt CarryBits(BitWidth, 0);
-      const uint64_t *LHSKnownZeroRawVal = LHSKnownZero.getRawData(),
-                     *RHSRawVal = RHSVal.getRawData();
-      for (uint32_t i = 0; i != RHSVal.getNumWords(); ++i) {
-        uint64_t AddVal = ~LHSKnownZeroRawVal[i] + RHSRawVal[i],
-                 XorVal = ~LHSKnownZeroRawVal[i] ^ RHSRawVal[i];
-        uint64_t WordCarryBits = AddVal ^ XorVal + CarryIn;
-        if (AddVal < RHSRawVal[i])
-          CarryIn = true;
-        else
-          CarryIn = false;
-        CarryBits.setWordToValue(i, WordCarryBits);
-      }
+      const APInt& RHSVal = RHS->getValue();
+      APInt CarryBits((~LHSKnownZero + RHSVal) ^ (~LHSKnownZero ^ RHSVal));
       
       // Now that we know which bits have carries, compute the known-1/0 sets.
       






More information about the llvm-commits mailing list