[PATCH] GVN: If a branch has two identical successors, we cannot declare either dead.
Sanjay Patel
spatel at rotateright.com
Thu Jun 25 10:22:02 PDT 2015
I'm by no means a GVN expert, but the code change looks trivially safer, so LGTM.
I'd like to improve the test case though:
1. Please minimize/edit to make it more obvious how this can cause a miscompile.
2. Add a comment to explain why the test exists (something similar to the code comment should do it).
This may not be minimal, and with the 'undefs' I don't think it can actually cause a miscompile, but I whittled it down this far to see what happens before and after the patch:
define void @widget() {
entry:
br label %bb2
bb2:
%t1 = phi i64 [ 0, %entry ], [ %t5, %bb7 ]
%t2 = add i64 %t1, 1
%t3 = icmp ult i64 0, %t2
br i1 %t3, label %bb3, label %bb4
bb3:
%t4 = call i64 @f()
br label %bb4
bb4:
; CHECK-NOT: phi {{.*}} undef
%foo = phi i64 [ %t4, %bb3 ], [ 0, %bb2 ]
br i1 undef, label %bb5, label %bb6
bb5:
br i1 true, label %bb7, label %bb7
bb6:
br i1 true, label %bb7, label %bb7
bb7:
%t5 = add i64 %t1, 1
br i1 undef, label %bb2, label %bb8
bb8:
ret void
}
http://reviews.llvm.org/D10726
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list