[polly] r250217 - [tests] More testing for PHI-nodes in non-affine regions

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 13 13:03:09 PDT 2015


Author: grosser
Date: Tue Oct 13 15:03:09 2015
New Revision: 250217

URL: http://llvm.org/viewvc/llvm-project?rev=250217&view=rev
Log:
[tests] More testing for PHI-nodes in non-affine regions

We harden one test case by ensuring no additional stores may possibly be
introduced between the stores we check for and the basic block terminator
statements.

We also add a test case for the situation where a value that is passed from
a non-affine region to a PHI node does not dominate the exit of the non-affine
region. This case has come up in patch reviews, so we make sure it is properly
handled today and in the future.

Added:
    polly/trunk/test/Isl/CodeGen/non-affine-phi-node-expansion-4.ll
Modified:
    polly/trunk/test/Isl/CodeGen/non-affine-phi-node-expansion-3.ll

Modified: polly/trunk/test/Isl/CodeGen/non-affine-phi-node-expansion-3.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/non-affine-phi-node-expansion-3.ll?rev=250217&r1=250216&r2=250217&view=diff
==============================================================================
--- polly/trunk/test/Isl/CodeGen/non-affine-phi-node-expansion-3.ll (original)
+++ polly/trunk/test/Isl/CodeGen/non-affine-phi-node-expansion-3.ll Tue Oct 13 15:03:09 2015
@@ -20,6 +20,7 @@ loop:
 ; CHECK-NEXT: store float %p_val0, float* %merge.phiops
 ; CHECK-NEXT: store float %p_val1, float* %val1.s2a
 ; CHECK-NEXT: store float %p_val2, float* %val2.s2a
+; CHECK-NEXT: br
 
 ; FIXME -> The last two writes are not really needed and can be dropped if the
 ;          incoming block of the PHI and the value that is used share the same
@@ -30,12 +31,14 @@ branch1:
 
 ; CHECK-LABEL: polly.stmt.branch1:
 ; CHECK-NEXT:    store float %p_val1, float* %merge.phiops
+; CHECK-NEXT:    br
 
 branch2:
   br label %backedge
 
 ; CHECK-LABEL: polly.stmt.branch2:
 ; CHECK-NEXT:    store float %p_val2, float* %merge.phiops
+; CHECK-NEXT:    br
 
 backedge:
   %merge = phi float [%val0, %loop], [%val1, %branch1], [%val2, %branch2]

Added: polly/trunk/test/Isl/CodeGen/non-affine-phi-node-expansion-4.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/non-affine-phi-node-expansion-4.ll?rev=250217&view=auto
==============================================================================
--- polly/trunk/test/Isl/CodeGen/non-affine-phi-node-expansion-4.ll (added)
+++ polly/trunk/test/Isl/CodeGen/non-affine-phi-node-expansion-4.ll Tue Oct 13 15:03:09 2015
@@ -0,0 +1,57 @@
+; RUN: opt %loadPolly -polly-codegen \
+; RUN:     -S < %s | FileCheck %s
+
+define void @foo(float* %A, i1 %cond0, i1 %cond1) {
+entry:
+  br label %loop
+
+loop:
+  %indvar = phi i64 [0, %entry], [%indvar.next, %backedge]
+  %val0 = fadd float 1.0, 2.0
+  %val1 = fadd float 1.0, 2.0
+  br i1 %cond0, label %branch1, label %backedge
+
+; CHECK-LABEL: polly.stmt.loop:
+; CHECK-NEXT:    %polly.subregion.iv = phi i32 [ 0, %polly.stmt.loop.entry ]
+; CHECK-NEXT:    %p_val0 = fadd float 1.000000e+00, 2.000000e+00
+; CHECK-NEXT:    %p_val1 = fadd float 1.000000e+00, 2.000000e+00
+; CHECK-NEXT:    store float %p_val0, float* %merge.phiops
+; CHECK-NEXT:    store float %p_val1, float* %val1.s2a
+; CHECK-NEXT:    br
+
+; The interesting instruction here is %val2, which does not dominate the exit of
+; the non-affine region. Care needs to be taken when code-generating this write.
+; Specifically, at some point we modeled this scalar write, which we tried to
+; code generate in the exit block of the non-affine region.
+branch1:
+  %val2 = fadd float 1.0, 2.0
+  br i1 %cond1, label %branch2, label %backedge
+
+; CHECK-LABEL: polly.stmt.branch1:
+; CHECK-NEXT:    %p_val2 = fadd float 1.000000e+00, 2.000000e+00
+; CHECK-NEXT:    store float %p_val1, float* %merge.phiops
+; CHECK-NEXT:    store float %p_val2, float* %val2.s2a
+; CHECK-NEXT:    br
+
+; FIXME -> The two writes of %p_val1 and %p_val2 are not really needed and can
+;          be dropped if the incoming block of the PHI and the value that is
+;          used share the same non-affine region.
+
+
+branch2:
+  br label %backedge
+
+; CHECK-LABEL: polly.stmt.branch2:
+; CHECK-NEXT:    store float %p_val2, float* %merge.phiops
+; CHECK-NEXT:    br
+
+backedge:
+  %merge = phi float [%val0, %loop], [%val1, %branch1], [%val2, %branch2]
+  %indvar.next = add i64 %indvar, 1
+  store float %merge, float* %A
+  %cmp = icmp sle i64 %indvar.next, 100
+  br i1 %cmp, label %loop, label %exit
+
+exit:
+  ret void
+}




More information about the llvm-commits mailing list