Skip to content

Commit

Permalink
Kill the benefit check in findCands, let the cost model filters out t…
Browse files Browse the repository at this point in the history
…he root (#694)
  • Loading branch information
zhengyang92 authored and regehr committed Jan 24, 2020
1 parent d420fd1 commit 09efbd5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
13 changes: 5 additions & 8 deletions lib/Inst/Inst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1052,18 +1052,15 @@ void souper::findCands(Inst *Root, std::vector<Inst *> &Guesses,
bool WidthMustMatch, bool FilterVars, int Max) {
// breadth-first search
std::set<Inst *> Visited;
std::queue<std::tuple<Inst *,int>> Q;
Q.push(std::make_tuple(Root, 0));
std::queue<Inst *> Q;
Q.push(Root);
while (!Q.empty()) {
Inst *I;
int Benefit;
std::tie(I, Benefit) = Q.front();
Inst *I = Q.front();
Q.pop();
++Benefit;
if (Visited.insert(I).second) {
for (auto Op : I->Ops)
Q.push(std::make_tuple(Op, Benefit));
if (Benefit > 1 && I->Available && I->K != Inst::Const
Q.push(Op);
if (I->Available && I->K != Inst::Const
&& I->K != Inst::UntypedConst) {
if (WidthMustMatch && I->Width != Root->Width)
continue;
Expand Down
8 changes: 8 additions & 0 deletions test/Infer/root-ignore-cost.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
; REQUIRES: solver, synthesis
; RUN: %souper-check -infer-rhs -souper-enumerative-synthesis -souper-enumerative-synthesis-num-instructions=3 -souper-enumerative-synthesis-ignore-cost %solver %s > %t1
; RUN: %FileCheck %s < %t1

; CHECK: result %0

%0:i8 = var
infer %0
10 changes: 10 additions & 0 deletions test/Infer/root-with-cost.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
; REQUIRES: solver, synthesis
; RUN: %souper-check -infer-rhs -souper-enumerative-synthesis -souper-enumerative-synthesis-num-instructions=3 %solver %s > %t1
; RUN: %souper-check -infer-rhs -souper-enumerative-synthesis %solver %s > %t2
; RUN: %FileCheck %s < %t1
; RUN: %FileCheck %s < %t2

; CHECK: ; Failed to infer RHS

%0:i32 = var
infer %0

0 comments on commit 09efbd5

Please sign in to comment.