aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhou Sheng <zhousheng00@gmail.com>2007-03-31 02:38:39 +0000
committerZhou Sheng <zhousheng00@gmail.com>2007-03-31 02:38:39 +0000
commitb9cb95f8e36257254530321e59eccc539189fa7a (patch)
tree7577d9760b28a5ee9888b1bb968d23afab165c9d
parentdb5c99312152b501203c042af1b6b80851f25fe7 (diff)
Use APInt operators to calculate the carry bits, remove this loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35524 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp18
1 files changed, 2 insertions, 16 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 5bbc90248b..1d172ced52 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -1243,22 +1243,8 @@ bool InstCombiner::SimplifyDemandedBits(Value *V, APInt DemandedMask,
// 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.