[PATCH] D39835: [GVN PRE] Clear nsw/nuw for original values in LoadPRE
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 10 13:34:31 PST 2017
efriedma added a comment.
> That is just as illegal as the Scalar PRE case by the rules above, as replacing an add with an add nsw.
I agree. And in fact, NewGVN has a bug here: it will transform the following.
@H = common global i32 0
@G = common global i32 0
define i32 @test(i1 %cond, i32 %v) nounwind {
entry:
br i1 %cond, label %bb, label %bb1
bb:
%add.1 = add nuw nsw i32 %v, -1
store i32 %add.1, i32* @G, align 4
br label %merge
bb1:
%add.2 = add i32 %v, -1
store i32 %add.2, i32* @G, align 4
br label %merge
merge:
%foo = phi i32 [ %add.2, %bb1 ], [ %add.1, %bb ]
%foo2 = add i32 %v, -1
%cmp2 = icmp sgt i32 %foo2, 0
br i1 %cmp2, label %action, label %return
action:
store i32 %foo, i32* @H, align 4
br label %return
return:
%p = phi i32 [0, %merge], [1, %action]
ret i32 %p
}
But old GVN doesn't compute that equivalence, as far as I can tell.
https://reviews.llvm.org/D39835
More information about the llvm-commits
mailing list