Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit c021b1e

Browse files
committed
Revert r316887 to fix buildbot failures.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316888 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 25cc518 commit c021b1e

File tree

2 files changed

+7
-228
lines changed

2 files changed

+7
-228
lines changed

lib/Transforms/Scalar/SCCP.cpp

Lines changed: 7 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include "llvm/Analysis/ConstantFolding.h"
3131
#include "llvm/Analysis/GlobalsModRef.h"
3232
#include "llvm/Analysis/TargetLibraryInfo.h"
33-
#include "llvm/Analysis/ValueLattice.h"
3433
#include "llvm/Analysis/ValueLatticeUtils.h"
3534
#include "llvm/IR/BasicBlock.h"
3635
#include "llvm/IR/CallSite.h"
@@ -71,8 +70,6 @@ STATISTIC(NumDeadBlocks , "Number of basic blocks unreachable");
7170
STATISTIC(IPNumInstRemoved, "Number of instructions removed by IPSCCP");
7271
STATISTIC(IPNumArgsElimed ,"Number of arguments constant propagated by IPSCCP");
7372
STATISTIC(IPNumGlobalConst, "Number of globals found to be constant by IPSCCP");
74-
STATISTIC(IPNumRangeInfoUsed, "Number of times constant range info was used by"
75-
"IPSCCP");
7673

7774
namespace {
7875

@@ -177,14 +174,6 @@ class LatticeVal {
177174
Val.setInt(forcedconstant);
178175
Val.setPointer(V);
179176
}
180-
181-
ValueLatticeElement toValueLattice() const {
182-
if (isOverdefined())
183-
return ValueLatticeElement::getOverdefined();
184-
if (isConstant())
185-
return ValueLatticeElement::get(getConstant());
186-
return ValueLatticeElement();
187-
}
188177
};
189178

190179
//===----------------------------------------------------------------------===//
@@ -197,8 +186,6 @@ class SCCPSolver : public InstVisitor<SCCPSolver> {
197186
const TargetLibraryInfo *TLI;
198187
SmallPtrSet<BasicBlock *, 8> BBExecutable; // The BBs that are executable.
199188
DenseMap<Value *, LatticeVal> ValueState; // The state each value is in.
200-
// The state each parameter is in.
201-
DenseMap<Value *, ValueLatticeElement> ParamState;
202189

203190
/// StructValueState - This maintains ValueState for values that have
204191
/// StructType, for example for formal arguments, calls, insertelement, etc.
@@ -325,18 +312,10 @@ class SCCPSolver : public InstVisitor<SCCPSolver> {
325312
return StructValues;
326313
}
327314

328-
ValueLatticeElement getLatticeValueFor(Value *V) {
329-
std::pair<DenseMap<Value*, ValueLatticeElement>::iterator, bool>
330-
PI = ParamState.insert(std::make_pair(V, ValueLatticeElement()));
331-
ValueLatticeElement &LV = PI.first->second;
332-
if (PI.second) {
333-
DenseMap<Value*, LatticeVal>::const_iterator I = ValueState.find(V);
334-
assert(I != ValueState.end() &&
335-
"V not found in ValueState nor Paramstate map!");
336-
LV = I->second.toValueLattice();
337-
}
338-
339-
return LV;
315+
LatticeVal getLatticeValueFor(Value *V) const {
316+
DenseMap<Value*, LatticeVal>::const_iterator I = ValueState.find(V);
317+
assert(I != ValueState.end() && "V is not in valuemap!");
318+
return I->second;
340319
}
341320

342321
/// getTrackedRetVals - Get the inferred return value map.
@@ -465,18 +444,6 @@ class SCCPSolver : public InstVisitor<SCCPSolver> {
465444
return LV;
466445
}
467446

468-
ValueLatticeElement &getParamState(Value *V) {
469-
assert(!V->getType()->isStructTy() && "Should use getStructValueState");
470-
471-
std::pair<DenseMap<Value*, ValueLatticeElement>::iterator, bool>
472-
PI = ParamState.insert(std::make_pair(V, ValueLatticeElement()));
473-
ValueLatticeElement &LV = PI.first->second;
474-
if (PI.second)
475-
LV = getValueState(V).toValueLattice();
476-
477-
return LV;
478-
}
479-
480447
/// getStructValueState - Return the LatticeVal object that corresponds to the
481448
/// value/field pair. This function handles the case when the value hasn't
482449
/// been seen yet by properly seeding constants etc.
@@ -1203,9 +1170,6 @@ void SCCPSolver::visitCallSite(CallSite CS) {
12031170
mergeInValue(getStructValueState(&*AI, i), &*AI, CallArg);
12041171
}
12051172
} else {
1206-
// Most other parts of the Solver still only use the simpler value
1207-
// lattice, so we propagate changes for parameters to both lattices.
1208-
getParamState(&*AI).mergeIn(getValueState(*CAI).toValueLattice(), DL);
12091173
mergeInValue(&*AI, getValueState(*CAI));
12101174
}
12111175
}
@@ -1596,43 +1560,6 @@ bool SCCPSolver::ResolvedUndefsIn(Function &F) {
15961560
return false;
15971561
}
15981562

1599-
static bool tryToReplaceWithConstantRange(SCCPSolver &Solver, Value *V) {
1600-
bool Changed = false;
1601-
1602-
const ValueLatticeElement &IV = Solver.getLatticeValueFor(V);
1603-
if (IV.isOverdefined())
1604-
return false;
1605-
1606-
// Currently we only use range information for integer values.
1607-
if (!(V->getType()->isIntegerTy() && IV.isConstantRange()))
1608-
return false;
1609-
1610-
for (auto UI = V->uses().begin(), E = V->uses().end(); UI != E;) {
1611-
const Use &U = *UI++;
1612-
auto *Icmp = dyn_cast<ICmpInst>(U.getUser());
1613-
if (!Icmp || !Solver.isBlockExecutable(Icmp->getParent()))
1614-
continue;
1615-
1616-
auto A = Solver.getLatticeValueFor(Icmp->getOperand(0));
1617-
auto B = Solver.getLatticeValueFor(Icmp->getOperand(1));
1618-
Constant *C = nullptr;
1619-
if (A.satisfiesPredicate(Icmp->getPredicate(), B))
1620-
C = ConstantInt::getTrue(Icmp->getType());
1621-
else if (A.satisfiesPredicate(Icmp->getInversePredicate(), B))
1622-
C = ConstantInt::getFalse(Icmp->getType());
1623-
1624-
if (C) {
1625-
Icmp->replaceAllUsesWith(C);
1626-
DEBUG(dbgs() << "Replacing " << *Icmp << " with " << *C
1627-
<< ", because of range information " << A << " " << B
1628-
<< "\n");
1629-
Icmp->eraseFromParent();
1630-
Changed = true;
1631-
}
1632-
}
1633-
return Changed;
1634-
}
1635-
16361563
static bool tryToReplaceWithConstant(SCCPSolver &Solver, Value *V) {
16371564
Constant *Const = nullptr;
16381565
if (V->getType()->isStructTy()) {
@@ -1650,19 +1577,10 @@ static bool tryToReplaceWithConstant(SCCPSolver &Solver, Value *V) {
16501577
}
16511578
Const = ConstantStruct::get(ST, ConstVals);
16521579
} else {
1653-
const ValueLatticeElement &IV = Solver.getLatticeValueFor(V);
1580+
LatticeVal IV = Solver.getLatticeValueFor(V);
16541581
if (IV.isOverdefined())
16551582
return false;
1656-
1657-
if (IV.isConstantRange()) {
1658-
if (IV.getConstantRange().isSingleElement())
1659-
Const =
1660-
ConstantInt::get(V->getType(), IV.asConstantInteger().getValue());
1661-
else
1662-
return false;
1663-
} else
1664-
Const =
1665-
IV.isConstant() ? IV.getConstant() : UndefValue::get(V->getType());
1583+
Const = IV.isConstant() ? IV.getConstant() : UndefValue::get(V->getType());
16661584
}
16671585
assert(Const && "Constant is nullptr here!");
16681586
DEBUG(dbgs() << " Constant: " << *Const << " = " << *V << '\n');
@@ -1863,14 +1781,10 @@ static bool runIPSCCP(Module &M, const DataLayout &DL,
18631781

18641782
if (Solver.isBlockExecutable(&F.front()))
18651783
for (Function::arg_iterator AI = F.arg_begin(), E = F.arg_end(); AI != E;
1866-
++AI) {
1784+
++AI)
18671785
if (!AI->use_empty() && tryToReplaceWithConstant(Solver, &*AI))
18681786
++IPNumArgsElimed;
18691787

1870-
if (!AI->use_empty() && tryToReplaceWithConstantRange(Solver, &*AI))
1871-
++IPNumRangeInfoUsed;
1872-
}
1873-
18741788
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
18751789
if (!Solver.isBlockExecutable(&*BB)) {
18761790
DEBUG(dbgs() << " BasicBlock Dead:" << *BB);

test/Transforms/SCCP/ip-constan-ranges.ll

Lines changed: 0 additions & 135 deletions
This file was deleted.

0 commit comments

Comments
 (0)