summaryrefslogtreecommitdiffstats
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
commit4f16402e0d0c7852f11d0a4436e23dc5feda7ff7 (patch)
tree2164d75583ce00feb4bafe6b5ea0b7ae48993514
parentafddb2c6f87475ce1a565433cd9ceebf7c3af375 (diff)
downloadbcm5719-llvm-4f16402e0d0c7852f11d0a4436e23dc5feda7ff7.tar.gz
bcm5719-llvm-4f16402e0d0c7852f11d0a4436e23dc5feda7ff7.zip
Use APInt operators to calculate the carry bits, remove this loop.
llvm-svn: 35524
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp18
1 files changed, 2 insertions, 16 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 5bbc90248b4..1d172ced525 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/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.
OpenPOWER on IntegriCloud