aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms
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
parent67f827ce5ba1296db9051892b4a8e10920053933 (diff)
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')
-rw-r--r--lib/Transforms/ExprTypeConvert.cpp4
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp1
-rw-r--r--lib/Transforms/Scalar/Reassociate.cpp52
-rw-r--r--lib/Transforms/Scalar/ScalarReplAggregates.cpp2
4 files changed, 28 insertions, 31 deletions
diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp
index 1ed804e23d..ee5549bad2 100644
--- a/lib/Transforms/ExprTypeConvert.cpp
+++ b/lib/Transforms/ExprTypeConvert.cpp
@@ -576,8 +576,8 @@ static bool OperandConvertibleToType(User *U, Value *V, const Type *Ty,
// Can convert store if the incoming value is convertible and if the
// result will preserve semantics...
const Type *Op0Ty = I->getOperand(0)->getType();
- if (!(Op0Ty->isInteger() ^ ElTy->isInteger()) &&
- !(Op0Ty->isFloatingPoint() ^ ElTy->isFloatingPoint()))
+ if (Op0Ty->isInteger() == ElTy->isInteger() &&
+ Op0Ty->isFloatingPoint() == ElTy->isFloatingPoint())
return ExpressionConvertibleToType(I->getOperand(0), ElTy, CTMap, TD);
}
return false;
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index bbf5241b34..d9ba12c784 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -1343,6 +1343,7 @@ bool GlobalOpt::ProcessInternalGlobal(GlobalVariable *GV,
if (Constant *SOVConstant = dyn_cast<Constant>(GS.StoredOnceValue))
if (GV->getType()->getElementType() != Type::Int1Ty &&
!GV->getType()->getElementType()->isFloatingPoint() &&
+ !isa<PackedType>(GV->getType()->getElementType()) &&
!GS.HasPHIUser) {
DOUT << " *** SHRINKING TO BOOL: " << *GV;
ShrinkGlobalToBoolean(GV, SOVConstant);
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]; }
- }
}
}
+ }
}
}
diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
index 60a127a921..e307ea7008 100644
--- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp
+++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
@@ -519,7 +519,7 @@ const Type *SROA::CanConvertToScalar(Value *V, bool &IsNotTrivial) {
return 0;
} else if (StoreInst *SI = dyn_cast<StoreInst>(User)) {
- // Storing the pointer, not the into the value?
+ // Storing the pointer, not into the value?
if (SI->getOperand(0) == V) return 0;
// NOTE: We could handle storing of FP imms into integers here!