aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2004-07-18 00:32:14 +0000
committerReid Spencer <rspencer@reidspencer.com>2004-07-18 00:32:14 +0000
commit460f16c6253928519689e882a4dbb7f236f33294 (patch)
tree47aeacdbd2d4e9f7a4bb5484b2a836f5b4c0e791 /lib/Transforms
parent21cb67e16ae4741ba7b24848db6913047876c4bc (diff)
bug 122:
- Minimize redundant isa<GlobalValue> usage git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14948 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/IPO/IPConstantPropagation.cpp6
-rw-r--r--lib/Transforms/IPO/InlineSimple.cpp5
-rw-r--r--lib/Transforms/Scalar/GCSE.cpp5
-rw-r--r--lib/Transforms/Utils/SimplifyCFG.cpp3
4 files changed, 6 insertions, 13 deletions
diff --git a/lib/Transforms/IPO/IPConstantPropagation.cpp b/lib/Transforms/IPO/IPConstantPropagation.cpp
index 026dbe3e80..0195231701 100644
--- a/lib/Transforms/IPO/IPConstantPropagation.cpp
+++ b/lib/Transforms/IPO/IPConstantPropagation.cpp
@@ -82,9 +82,8 @@ bool IPCP::processFunction(Function &F) {
if (*AI == &F) return false; // Passes the function into itself
if (!ArgumentConstants[i].second) {
- if (isa<Constant>(*AI) || isa<GlobalValue>(*AI)) {
+ if (isa<Constant>(*AI)) {
Constant *C = dyn_cast<Constant>(*AI);
- if (!C) C = ConstantPointerRef::get(cast<GlobalValue>(*AI));
if (!ArgumentConstants[i].first)
ArgumentConstants[i].first = C;
@@ -114,9 +113,6 @@ bool IPCP::processFunction(Function &F) {
if (!ArgumentConstants[i].second && !AI->use_empty()) {
assert(ArgumentConstants[i].first && "Unknown constant value!");
Value *V = ArgumentConstants[i].first;
- if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(V))
- V = CPR->getValue();
-
AI->replaceAllUsesWith(V);
++NumArgumentsProped;
MadeChange = true;
diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp
index c0d97c5515..791b21356e 100644
--- a/lib/Transforms/IPO/InlineSimple.cpp
+++ b/lib/Transforms/IPO/InlineSimple.cpp
@@ -78,8 +78,7 @@ static unsigned CountCodeReductionForConstant(Value *V) {
Instruction &Inst = cast<Instruction>(**UI);
bool AllOperandsConstant = true;
for (unsigned i = 0, e = Inst.getNumOperands(); i != e; ++i)
- if (!isa<Constant>(Inst.getOperand(i)) &&
- !isa<GlobalValue>(Inst.getOperand(i)) && Inst.getOperand(i) != V) {
+ if (!isa<Constant>(Inst.getOperand(i)) && Inst.getOperand(i) != V) {
AllOperandsConstant = false;
break;
}
@@ -205,7 +204,7 @@ int SimpleInliner::getInlineCost(CallSite CS) {
// If this is a constant being passed into the function, use the argument
// weights calculated for the callee to determine how much will be folded
// away with this information.
- } else if (isa<Constant>(I) || isa<GlobalVariable>(I)) {
+ } else if (isa<Constant>(I)) {
if (ArgNo < CalleeFI.ArgumentWeights.size())
InlineCost -= CalleeFI.ArgumentWeights[ArgNo].ConstantWeight;
}
diff --git a/lib/Transforms/Scalar/GCSE.cpp b/lib/Transforms/Scalar/GCSE.cpp
index 7d93c50373..c24941320f 100644
--- a/lib/Transforms/Scalar/GCSE.cpp
+++ b/lib/Transforms/Scalar/GCSE.cpp
@@ -78,8 +78,7 @@ bool GCSE::runOnFunction(Function &F) {
VN.getEqualNumberNodes(AI, EqualValues);
if (!EqualValues.empty()) {
for (unsigned i = 0, e = EqualValues.size(); i != e; ++i)
- if (isa<Constant>(EqualValues[i]) ||
- isa<GlobalValue>(EqualValues[i])) {
+ if (isa<Constant>(EqualValues[i])) {
AI->replaceAllUsesWith(EqualValues[i]);
++NumArgsRepl;
Changed = true;
@@ -186,7 +185,7 @@ void GCSE::ReplaceInstructionWith(Instruction *I, Value *V) {
// If we are not replacing the instruction with a constant, we cannot do
// anything special.
- if (!isa<Constant>(V)) {
+ if (!isa<Constant>(V) || isa<GlobalValue>(V)) {
I->replaceAllUsesWith(V);
if (InvokeInst *II = dyn_cast<InvokeInst>(I)) {
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp
index c3ed43d1f0..cc28e54c37 100644
--- a/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -211,8 +211,7 @@ static bool DominatesMergePoint(Value *V, BasicBlock *BB, bool AllowAggressive){
if (cast<LoadInst>(I)->isVolatile())
return false;
if (!isa<AllocaInst>(I->getOperand(0)) &&
- !isa<Constant>(I->getOperand(0)) &&
- !isa<GlobalValue>(I->getOperand(0)))
+ !isa<Constant>(I->getOperand(0)))
return false;
// Finally, we have to check to make sure there are no instructions