Skip to content

Commit

Permalink
fix #951: false-positive condition for loop sinks doesn't take nonret…
Browse files Browse the repository at this point in the history
…urn functions into account
  • Loading branch information
nunoplopes committed Oct 30, 2023
1 parent 756f799 commit 6381cd9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ir/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ expr State::sinkDomain() const {

OrExpr ret;
for (auto &[src, data] : I->second) {
ret.add(data.path());
ret.add(data.path() && *data.UB());
}
return ret();
}
Expand Down
38 changes: 38 additions & 0 deletions tests/alive-tv/loops/issue951.srctgt.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
; ERROR: Source is more defined than target
; TEST-ARGS: -src-unroll=3 -tgt-unroll=3

define i8 @src(i8 %v) {
entry:
%v.nonneg = icmp sgt i8 %v, -1
br label %for.body

for.body:
%sum = phi i8 [ 0, %entry ], [ %sum.next, %for.body ]
%sum.next = add i8 %sum, %v
%overflow = icmp ult i8 %sum.next, %sum
%cmp.i5.i = xor i1 %v.nonneg, %overflow
call void @use(i1 %cmp.i5.i)
br i1 %cmp.i5.i, label %for.body, label %cleanup1.loopexit

cleanup1.loopexit:
%cmp.not.lcssa.ph = phi i8 [ %sum, %for.body ]
ret i8 %cmp.not.lcssa.ph
}

define i8 @tgt(i8 %v) {
entry:
%v.nonneg = icmp sgt i8 %v, -1
br label %for.body

for.body:
%sum = phi i8 [ 0, %entry ], [ %sum.next, %for.body ]
%sum.next = add i8 %sum, %v
call void @use(i1 %v.nonneg)
br i1 %v.nonneg, label %for.body, label %cleanup1.loopexit

cleanup1.loopexit:
%cmp.not.lcssa.ph = phi i8 [ %sum, %for.body ]
ret i8 %cmp.not.lcssa.ph
}

declare void @use(i1)

0 comments on commit 6381cd9

Please sign in to comment.