Skip to content
This repository was archived by the owner on Oct 30, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/souper/Infer/Pruning.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class PruningManager {
llvm::KnownBits LHSKnownBitsNoSpec;
InputVarInfo LHSMustDemandedBits;
bool LHSHasPhi = false;

bool PCHasPhi = false;
PruneFunc DataflowPrune;
unsigned NumPruned;
unsigned TotalGuesses;
Expand Down
2 changes: 1 addition & 1 deletion lib/Infer/AbstractInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ namespace souper {
case Inst::Phi: {
std::vector<llvm::KnownBits> vec;
for (auto &Op : I->Ops) {
vec.emplace_back(findKnownBits(Op, CI));
vec.emplace_back(findKnownBits(Op, CI, UsePartialEval));
}
Result = mergeKnownBits(vec);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Infer/EnumerativeSynthesis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ EnumerativeSynthesis::synthesize(SMTLIBSolver *SMTSolver,
std::vector<PruneFunc> PruneFuncs = { [&Visited](Inst *I, std::vector<Inst*> &ReservedInsts) {
return CountPrune(I, ReservedInsts, Visited);
}};
if (EnableDataflowPruning) {
if (EnableDataflowPruning && BPCs.empty()) {
DataflowPruning.init();
PruneFuncs.push_back(DataflowPruning.getPruneFunc());
}
Expand Down
23 changes: 17 additions & 6 deletions lib/Infer/Pruning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ bool PruningManager::isInfeasible(souper::Inst *RHS,
}
}

if (LHSHasPhi) {
if (LHSHasPhi && !PCHasPhi) {
auto LHSCR = LHSConstantRange[I];
auto RHSCR = ConstantRangeAnalysis().findConstantRange(RHS, ConcreteInterpreters[I]);
if (!RHSCR.isFullSet()) {
Expand Down Expand Up @@ -492,17 +492,28 @@ void PruningManager::init() {
Ante = SC.IC.getInst(Inst::And, 1, {Ante, Eq});
}

if (hasGivenInst(Ante, [](Inst *I){ return I->K == Inst::Phi;})) {
PCHasPhi = true;
}

if (hasGivenInst(SC.LHS, [](Inst *I){ return I->K == Inst::Phi;})) {
LHSHasPhi = true;
}

findVars(Ante, InputVars);

InputVals = generateInputSets(InputVars);
if (!PCHasPhi) {
InputVals = generateInputSets(InputVars);
}

for (auto &&Input : InputVals) {
ConcreteInterpreters.emplace_back(SC.LHS, Input);
if (!LHSHasPhi && !PCHasPhi) {
for (auto &&Input : InputVals) {
ConcreteInterpreters.emplace_back(SC.LHS, Input);
}
}

if (hasGivenInst(SC.LHS, [](Inst *I){ return I->K == Inst::Phi;})) {
if (LHSHasPhi) {
// Have to abstract interpret LHS because of phi
LHSHasPhi = true;
for (unsigned I = 0; I < InputVals.size(); I++) {
LHSKnownBits.push_back(KnownBitsAnalysis().findKnownBits(SC.LHS, ConcreteInterpreters[I]));
LHSConstantRange.push_back(ConstantRangeAnalysis().findConstantRange(SC.LHS, ConcreteInterpreters[I]));
Expand Down