[PATCH] D56079: Fix invalid test in Guard Widening

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 25 22:08:19 PST 2018


mkazantsev created this revision.
mkazantsev added reviewers: sanjoy, skatkov, apilipenko, reames.

One of Guard Widening tests is not checking what it is supposed to check and
contains undefined behavior. Instead of checking that we can widen the inner
guard into a containing loop's guard (which is described in the comment), it
contains a single loop with 2 latches, 2nd latch is not must-execute and the loop
is infinite, therefore no post-domination tree exists. According to the algorithm,
we should only widen if there is post-domination between two guards, and it
seems that if there are no exit blocks from the loop, we cannot rely on PDT.

This patch alters the test so that it checks what it is supposed to check. Now it
has 2 loops and checks the widening scenario described in the comment.


https://reviews.llvm.org/D56079

Files:
  test/Transforms/GuardWidening/basic.ll


Index: test/Transforms/GuardWidening/basic.ll
===================================================================
--- test/Transforms/GuardWidening/basic.ll
+++ test/Transforms/GuardWidening/basic.ll
@@ -271,20 +271,25 @@
 define void @f_11(i32 %a, i1 %cond_0, i1 %cond_1) {
 ; CHECK-LABEL: @f_11(
 entry:
-  br label %inner
+  br label %outer_header
 
-inner:
-; CHECK: inner:
-; CHECK:  %wide.chk = and i1 %cond_0, %cond_1
-; CHECK:  call void (i1, ...) @llvm.experimental.guard(i1 %wide.chk) [ "deopt"() ]
-; CHECK:  br i1 undef, label %inner, label %outer
+outer_header:
+; CHECK:      outer_header:
+; CHECK-NEXT:   %wide.chk = and i1 %cond_0, %cond_1
+; CHECK-NEXT:   call void (i1, ...) @llvm.experimental.guard(i1 %wide.chk) [ "deopt"() ]
 
   call void(i1, ...) @llvm.experimental.guard(i1 %cond_0) [ "deopt"() ]
-  br i1 undef, label %inner, label %outer
+  br i1 undef, label %outer_header, label %inner
 
-outer:
+inner:
   call void(i1, ...) @llvm.experimental.guard(i1 %cond_1) [ "deopt"() ]
-  br label %inner
+  br label %outer_latch
+
+outer_latch:
+  br i1 undef, label %outer_header, label %exit
+
+exit:
+  ret void
 }
 
 ; Checks that we are adequately guarded against exponential-time


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56079.179496.patch
Type: text/x-patch
Size: 1207 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181226/5c0d510f/attachment.bin>


More information about the llvm-commits mailing list