summaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/Reassociate.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-01-21 00:29:26 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-01-21 00:29:26 +0000
commit24d6da5fedcf39891f7d8c5b031c01324b3db545 (patch)
treee7fd1eac07e11c2f15075d23f3c07a5ff48ff1cd /lib/Transforms/Scalar/Reassociate.cpp
parent67f827ce5ba1296db9051892b4a8e10920053933 (diff)
downloadllvm-24d6da5fedcf39891f7d8c5b031c01324b3db545.tar.gz
llvm-24d6da5fedcf39891f7d8c5b031c01324b3db545.tar.bz2
llvm-24d6da5fedcf39891f7d8c5b031c01324b3db545.tar.xz
For PR970:
Clean up handling of isFloatingPoint() and dealing with PackedType. Patch by Gordon Henriksen! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33415 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/Reassociate.cpp')
-rw-r--r--lib/Transforms/Scalar/Reassociate.cpp52
1 files changed, 24 insertions, 28 deletions
diff --git a/lib/Transforms/Scalar/Reassociate.cpp b/lib/Transforms/Scalar/Reassociate.cpp
index 287bff2a2f..4fcbf35f56 100644
--- a/lib/Transforms/Scalar/Reassociate.cpp
+++ b/lib/Transforms/Scalar/Reassociate.cpp
@@ -186,11 +186,7 @@ static BinaryOperator *isReassociableOp(Value *V, unsigned Opcode) {
/// LowerNegateToMultiply - Replace 0-X with X*-1.
///
static Instruction *LowerNegateToMultiply(Instruction *Neg) {
- Constant *Cst;
- if (Neg->getType()->isFloatingPoint())
- Cst = ConstantFP::get(Neg->getType(), -1);
- else
- Cst = ConstantInt::getAllOnesValue(Neg->getType());
+ Constant *Cst = ConstantInt::getAllOnesValue(Neg->getType());
std::string NegName = Neg->getName(); Neg->setName("");
Instruction *Res = BinaryOperator::createMul(Neg->getOperand(1), Cst, NegName,
@@ -661,32 +657,32 @@ Value *Reassociate::OptimizeExpression(BinaryOperator *I,
std::map<Value*, unsigned> FactorOccurrences;
unsigned MaxOcc = 0;
Value *MaxOccVal = 0;
- if (!I->getType()->isFloatingPoint()) {
- for (unsigned i = 0, e = Ops.size(); i != e; ++i) {
- if (BinaryOperator *BOp = dyn_cast<BinaryOperator>(Ops[i].Op))
- if (BOp->getOpcode() == Instruction::Mul && BOp->use_empty()) {
- // Compute all of the factors of this added value.
- std::vector<Value*> Factors;
- FindSingleUseMultiplyFactors(BOp, Factors);
- assert(Factors.size() > 1 && "Bad linearize!");
-
- // Add one to FactorOccurrences for each unique factor in this op.
- if (Factors.size() == 2) {
- unsigned Occ = ++FactorOccurrences[Factors[0]];
- if (Occ > MaxOcc) { MaxOcc = Occ; MaxOccVal = Factors[0]; }
- if (Factors[0] != Factors[1]) { // Don't double count A*A.
- Occ = ++FactorOccurrences[Factors[1]];
- if (Occ > MaxOcc) { MaxOcc = Occ; MaxOccVal = Factors[1]; }
+ for (unsigned i = 0, e = Ops.size(); i != e; ++i) {
+ if (BinaryOperator *BOp = dyn_cast<BinaryOperator>(Ops[i].Op)) {
+ if (BOp->getOpcode() == Instruction::Mul && BOp->use_empty()) {
+ // Compute all of the factors of this added value.
+ std::vector<Value*> Factors;
+ FindSingleUseMultiplyFactors(BOp, Factors);
+ assert(Factors.size() > 1 && "Bad linearize!");
+
+ // Add one to FactorOccurrences for each unique factor in this op.
+ if (Factors.size() == 2) {
+ unsigned Occ = ++FactorOccurrences[Factors[0]];
+ if (Occ > MaxOcc) { MaxOcc = Occ; MaxOccVal = Factors[0]; }
+ if (Factors[0] != Factors[1]) { // Don't double count A*A.
+ Occ = ++FactorOccurrences[Factors[1]];
+ if (Occ > MaxOcc) { MaxOcc = Occ; MaxOccVal = Factors[1]; }
+ }
+ } else {
+ std::set<Value*> Duplicates;
+ for (unsigned i = 0, e = Factors.size(); i != e; ++i) {
+ if (Duplicates.insert(Factors[i]).second) {
+ unsigned Occ = ++FactorOccurrences[Factors[i]];
+ if (Occ > MaxOcc) { MaxOcc = Occ; MaxOccVal = Factors[i]; }
}
- } else {
- std::set<Value*> Duplicates;
- for (unsigned i = 0, e = Factors.size(); i != e; ++i)
- if (Duplicates.insert(Factors[i]).second) {
- unsigned Occ = ++FactorOccurrences[Factors[i]];
- if (Occ > MaxOcc) { MaxOcc = Occ; MaxOccVal = Factors[i]; }
- }
}
}
+ }
}
}