[polly] r296348 - [DeLICM] Add nomap regressions tests. NFC.

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 27 07:53:19 PST 2017


Author: meinersbur
Date: Mon Feb 27 09:53:18 2017
New Revision: 296348

URL: http://llvm.org/viewvc/llvm-project?rev=296348&view=rev
Log:
[DeLICM] Add nomap regressions tests. NFC.

These verify that some scalars are not mapped because it would be
incorrect to do so.

For these check we verify that no transformation has been executed from
output of the pass's '-analyze'. Adding optimization remarks is not useful
as it would result in too many messages, even repeated ones. I avoided
checking the '-debug-only=polly-delicm' output which is an antipattern.

Added:
    polly/trunk/test/DeLICM/nomap_alreadymapped.ll
    polly/trunk/test/DeLICM/nomap_escaping.ll
    polly/trunk/test/DeLICM/nomap_occupied.ll
    polly/trunk/test/DeLICM/nomap_readonly.ll
    polly/trunk/test/DeLICM/nomap_spuriouswrite.ll
    polly/trunk/test/DeLICM/nomap_storagesize.ll
    polly/trunk/test/DeLICM/nomap_writewrite.ll

Added: polly/trunk/test/DeLICM/nomap_alreadymapped.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/DeLICM/nomap_alreadymapped.ll?rev=296348&view=auto
==============================================================================
--- polly/trunk/test/DeLICM/nomap_alreadymapped.ll (added)
+++ polly/trunk/test/DeLICM/nomap_alreadymapped.ll Mon Feb 27 09:53:18 2017
@@ -0,0 +1,79 @@
+; RUN: opt %loadPolly -polly-delicm -analyze < %s | FileCheck %s
+;
+;    void func(double *A) {
+;      for (int j = 0; j < 2; j += 1) { /* outer */
+;        double phi1 = 0.0, phi2 = 0.0;
+;        for (int i = 0; i < 4; i += 1) { /* reduction */
+;          phi1 += 4.2;
+;          phi2 += 29.0;
+;        }
+;        A[j] = phi1 + phi2;
+;      }
+;    }
+;
+; Check that we cannot map both, %phi1 and %phi2 to A[j] (conflict).
+; Note that it is undefined which one will be mapped. We keep the test
+; symmetric so it passes if either one is mapped.
+;
+define void @func(double* noalias nonnull %A) {
+entry:
+  br label %outer.preheader
+
+outer.preheader:
+  br label %outer.for
+
+outer.for:
+  %j = phi i32 [0, %outer.preheader], [%j.inc, %outer.inc]
+  %j.cmp = icmp slt i32 %j, 2
+  br i1 %j.cmp, label %reduction.preheader, label %outer.exit
+
+
+    reduction.preheader:
+      br label %reduction.for
+
+    reduction.for:
+      %i = phi i32 [0, %reduction.preheader], [%i.inc, %reduction.inc]
+      %phi1 = phi double [0.0, %reduction.preheader], [%add1, %reduction.inc]
+      %phi2 = phi double [0.0, %reduction.preheader], [%add2, %reduction.inc]
+      %i.cmp = icmp slt i32 %i, 4
+      br i1 %i.cmp, label %body, label %reduction.exit
+
+
+
+        body:
+          %add1 = fadd double %phi1, 4.2
+          %add2 = fadd double %phi2, 29.0
+          br label %reduction.inc
+
+
+
+    reduction.inc:
+      %i.inc = add nuw nsw i32 %i, 1
+      br label %reduction.for
+
+    reduction.exit:
+      %A_idx = getelementptr inbounds double, double* %A, i32 %j
+      %sum = fadd double %phi1, %phi2
+      store double %sum, double* %A_idx
+      br label %outer.inc
+
+
+
+outer.inc:
+  %j.inc = add nuw nsw i32 %j, 1
+  br label %outer.for
+
+outer.exit:
+  br label %return
+
+return:
+  ret void
+}
+
+
+; CHECK: Statistics {
+; CHECK:     Compatible overwrites: 1
+; CHECK:     Overwrites mapped to:  1
+; CHECK:     Value scalars mapped:  2
+; CHECK:     PHI scalars mapped:    1
+; CHECK: }

Added: polly/trunk/test/DeLICM/nomap_escaping.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/DeLICM/nomap_escaping.ll?rev=296348&view=auto
==============================================================================
--- polly/trunk/test/DeLICM/nomap_escaping.ll (added)
+++ polly/trunk/test/DeLICM/nomap_escaping.ll Mon Feb 27 09:53:18 2017
@@ -0,0 +1,78 @@
+; RUN: opt %loadPolly -polly-delicm -analyze < %s | FileCheck %s
+;
+;    void func(double *A) {
+;      for (int j = 0; j < 2; j += 1) { /* outer */
+;        fsomeval = 21.0 + 21.0;
+;        double phi = 0.0;
+;        for (int i = 0; i < 4; i += 1) /* reduction */
+;          phi += 4.2;
+;        A[j] = fsomeval;
+;      }
+;      g(fsomeval);
+;    }
+;
+; Check that fsomeval is not mapped to A[j] because it is escaping the SCoP.
+; Supporting this would require reloading the scalar from A[j], and/or
+; identifying the last instance of fsomeval that escapes.
+;
+define void @func(double* noalias nonnull %A) {
+entry:
+  br label %outer.preheader
+
+outer.preheader:
+  br label %outer.for
+
+outer.for:
+  %j = phi i32 [0, %outer.preheader], [%j.inc, %outer.inc]
+  %j.cmp = icmp slt i32 %j, 2
+  %fsomeval = fadd double 21.0, 21.0
+  br i1 %j.cmp, label %reduction.preheader, label %outer.exit
+
+
+    reduction.preheader:
+      br label %reduction.for
+
+    reduction.for:
+      %i = phi i32 [0, %reduction.preheader], [%i.inc, %reduction.inc]
+      %phi = phi double [0.0, %reduction.preheader], [%add, %reduction.inc]
+      %i.cmp = icmp slt i32 %i, 4
+      br i1 %i.cmp, label %body, label %reduction.exit
+
+
+
+        body:
+          %add = fadd double %phi, 4.2
+          br label %reduction.inc
+
+
+
+    reduction.inc:
+      %i.inc = add nuw nsw i32 %i, 1
+      br label %reduction.for
+
+    reduction.exit:
+      %A_idx = getelementptr inbounds double, double* %A, i32 %j
+      store double %fsomeval, double* %A_idx
+      br label %outer.inc
+
+
+
+outer.inc:
+  %j.inc = add nuw nsw i32 %j, 1
+  br label %outer.for
+
+outer.exit:
+  br label %return
+
+return:
+  call void @g(double %fsomeval)
+  ret void
+}
+
+declare void @g(double)
+
+
+; CHECK: Statistics {
+; CHECK:     Compatible overwrites: 1
+; CHECK: }
+; CHECK: No modification has been made

Added: polly/trunk/test/DeLICM/nomap_occupied.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/DeLICM/nomap_occupied.ll?rev=296348&view=auto
==============================================================================
--- polly/trunk/test/DeLICM/nomap_occupied.ll (added)
+++ polly/trunk/test/DeLICM/nomap_occupied.ll Mon Feb 27 09:53:18 2017
@@ -0,0 +1,73 @@
+; RUN: opt %loadPolly -polly-delicm -analyze < %s | FileCheck %s
+;
+;    void func(double *A) {
+;      for (int j = 0; j < 2; j += 1) { /* outer */
+;        double phi = 0.0;
+;        for (int i = 0; i < 4; i += 1) /* reduction */
+;          phi += 4.2;
+;        dummy = A[j];
+;        A[j] = phi;
+;      }
+;    }
+;
+; Check that A[j] is not used for mapping as it is still in use.
+;
+define void @func(double* noalias nonnull %A) {
+entry:
+  %fsomeval = fadd double 21.0, 21.0
+  br label %outer.preheader
+
+outer.preheader:
+  br label %outer.for
+
+outer.for:
+  %j = phi i32 [0, %outer.preheader], [%j.inc, %outer.inc]
+  %j.cmp = icmp slt i32 %j, 2
+  br i1 %j.cmp, label %reduction.preheader, label %outer.exit
+
+
+    reduction.preheader:
+      br label %reduction.for
+
+    reduction.for:
+      %i = phi i32 [0, %reduction.preheader], [%i.inc, %reduction.inc]
+      %phi = phi double [0.0, %reduction.preheader], [%add, %reduction.inc]
+      %i.cmp = icmp slt i32 %i, 4
+      br i1 %i.cmp, label %body, label %reduction.exit
+
+
+
+        body:
+          %add = fadd double %phi, 4.2
+          br label %reduction.inc
+
+
+
+    reduction.inc:
+      %i.inc = add nuw nsw i32 %i, 1
+      br label %reduction.for
+
+    reduction.exit:
+      %A_idx = getelementptr inbounds double, double* %A, i32 %j
+      %dummy = load double, double* %A_idx
+      store double %phi, double* %A_idx
+      br label %outer.inc
+
+
+
+outer.inc:
+  %j.inc = add nuw nsw i32 %j, 1
+  br label %outer.for
+
+outer.exit:
+  br label %return
+
+return:
+  ret void
+}
+
+
+; CHECK: Statistics {
+; CHECK:     Compatible overwrites: 1
+; CHECK: }
+; CHECK: No modification has been made

Added: polly/trunk/test/DeLICM/nomap_readonly.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/DeLICM/nomap_readonly.ll?rev=296348&view=auto
==============================================================================
--- polly/trunk/test/DeLICM/nomap_readonly.ll (added)
+++ polly/trunk/test/DeLICM/nomap_readonly.ll Mon Feb 27 09:53:18 2017
@@ -0,0 +1,73 @@
+; RUN: opt %loadPolly -polly-delicm -analyze < %s | FileCheck %s
+;
+;    void func(double *A) {
+;      fsomeval = 21.0 + 21.0;
+;      for (int j = 0; j < 2; j += 1) { /* outer */
+;        double phi = 0.0;
+;        for (int i = 0; i < 4; i += 1) /* reduction */
+;          phi += 4.2;
+;        A[j] = fsomeval;
+;      }
+;    }
+;
+; Check that fsomeval is not mapped to A[j] because it is read-only.
+; There is no advantage in mapping values not modified within the SCoP.
+;
+define void @func(double* noalias nonnull %A) {
+entry:
+  %fsomeval = fadd double 21.0, 21.0
+  br label %outer.preheader
+
+outer.preheader:
+  br label %outer.for
+
+outer.for:
+  %j = phi i32 [0, %outer.preheader], [%j.inc, %outer.inc]
+  %j.cmp = icmp slt i32 %j, 2
+  br i1 %j.cmp, label %reduction.preheader, label %outer.exit
+
+
+    reduction.preheader:
+      br label %reduction.for
+
+    reduction.for:
+      %i = phi i32 [0, %reduction.preheader], [%i.inc, %reduction.inc]
+      %phi = phi double [0.0, %reduction.preheader], [%add, %reduction.inc]
+      %i.cmp = icmp slt i32 %i, 4
+      br i1 %i.cmp, label %body, label %reduction.exit
+
+
+
+        body:
+          %add = fadd double %phi, 4.2
+          br label %reduction.inc
+
+
+
+    reduction.inc:
+      %i.inc = add nuw nsw i32 %i, 1
+      br label %reduction.for
+
+    reduction.exit:
+      %A_idx = getelementptr inbounds double, double* %A, i32 %j
+      store double %fsomeval, double* %A_idx
+      br label %outer.inc
+
+
+
+outer.inc:
+  %j.inc = add nuw nsw i32 %j, 1
+  br label %outer.for
+
+outer.exit:
+  br label %return
+
+return:
+  ret void
+}
+
+
+; CHECK: Statistics {
+; CHECK:     Compatible overwrites: 1
+; CHECK: }
+; CHECK: No modification has been made

Added: polly/trunk/test/DeLICM/nomap_spuriouswrite.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/DeLICM/nomap_spuriouswrite.ll?rev=296348&view=auto
==============================================================================
--- polly/trunk/test/DeLICM/nomap_spuriouswrite.ll (added)
+++ polly/trunk/test/DeLICM/nomap_spuriouswrite.ll Mon Feb 27 09:53:18 2017
@@ -0,0 +1,84 @@
+; RUN: opt %loadPolly -polly-delicm -analyze < %s | FileCheck %s
+;
+;    void func(double *A) {
+;      for (int j = 0; j < 2; j += 1) { /* outer */
+;        double phi = 0.0;
+;        for (int i = 0; i < 4; i += 1) /* reduction */
+;          phi += 4.2;
+;        if (phi < 0.0)
+;          A[j] = undef;
+;        A[j] = phi;
+;      }
+;    }
+;
+; The MAY_WRITE in reduction.exit.true avoids that anything can be mapped to
+; A[j] because it would be overwritten by that MAY_WRITE just before the final
+; MUST_WRITE. Also nothing can be map to the MAY_WRITE itself because it is a
+; MAY_WRITE.
+;
+define void @func(double* noalias nonnull %A) {
+entry:
+  %fsomeval = fadd double 21.0, 21.0
+  br label %outer.preheader
+
+outer.preheader:
+  br label %outer.for
+
+outer.for:
+  %j = phi i32 [0, %outer.preheader], [%j.inc, %outer.inc]
+  %j.cmp = icmp slt i32 %j, 2
+  br i1 %j.cmp, label %reduction.preheader, label %outer.exit
+
+
+    reduction.preheader:
+      br label %reduction.for
+
+    reduction.for:
+      %i = phi i32 [0, %reduction.preheader], [%i.inc, %reduction.inc]
+      %phi = phi double [0.0, %reduction.preheader], [%add, %reduction.inc]
+      %i.cmp = icmp slt i32 %i, 4
+      br i1 %i.cmp, label %body, label %reduction.exit
+
+
+
+        body:
+          %add = fadd double %phi, 4.2
+          br label %reduction.inc
+
+
+
+    reduction.inc:
+      %i.inc = add nuw nsw i32 %i, 1
+      br label %reduction.for
+
+    reduction.exit:
+      %A_idx = getelementptr inbounds double, double* %A, i32 %j
+      %phi.cmp = fcmp ogt double %phi, 0.0
+      br i1 %phi.cmp, label %reduction.exit.true, label %reduction.exit.unconditional
+
+    reduction.exit.true:
+       store double undef, double* %A_idx
+       br label %reduction.exit.unconditional
+
+    reduction.exit.unconditional:
+      store double %phi, double* %A_idx
+      br label %outer.inc
+
+
+
+outer.inc:
+  %j.inc = add nuw nsw i32 %j, 1
+  br label %outer.for
+
+outer.exit:
+  br label %return
+
+return:
+  ret void
+}
+
+
+; CHECK: Statistics {
+; CHECK:     Compatible overwrites: 1
+; CHECK: }
+; CHECK: No modification has been made

Added: polly/trunk/test/DeLICM/nomap_storagesize.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/DeLICM/nomap_storagesize.ll?rev=296348&view=auto
==============================================================================
--- polly/trunk/test/DeLICM/nomap_storagesize.ll (added)
+++ polly/trunk/test/DeLICM/nomap_storagesize.ll Mon Feb 27 09:53:18 2017
@@ -0,0 +1,72 @@
+; RUN: opt %loadPolly -polly-delicm -analyze < %s | FileCheck %s
+;
+;    void func(float *A) {
+;      for (int j = 0; j < 2; j += 1) { /* outer */
+;        double phi = 0.0;
+;        for (int i = 0; i < 4; i += 1) /* reduction */
+;          phi += 4.2;
+;        A[j] = fsomeval;
+;      }
+;    }
+;
+; Check that %fphi is not mapped to A[j] because it is double-sized,
+; but A[j] stores only floats.
+;
+define void @func(float* noalias nonnull %A) {
+entry:
+  br label %outer.preheader
+
+outer.preheader:
+  br label %outer.for
+
+outer.for:
+  %j = phi i32 [0, %outer.preheader], [%j.inc, %outer.inc]
+  %j.cmp = icmp slt i32 %j, 2
+  br i1 %j.cmp, label %reduction.preheader, label %outer.exit
+
+
+    reduction.preheader:
+      br label %reduction.for
+
+    reduction.for:
+      %i = phi i32 [0, %reduction.preheader], [%i.inc, %reduction.inc]
+      %phi = phi double [0.0, %reduction.preheader], [%add, %reduction.inc]
+      %i.cmp = icmp slt i32 %i, 4
+      br i1 %i.cmp, label %body, label %reduction.exit
+
+
+
+        body:
+          %add = fadd double %phi, 4.2
+          br label %reduction.inc
+
+
+
+    reduction.inc:
+      %i.inc = add nuw nsw i32 %i, 1
+      br label %reduction.for
+
+    reduction.exit:
+      %A_idx = getelementptr inbounds float, float* %A, i32 %j
+      %fphi = fptrunc double %phi to float
+      store float %fphi, float* %A_idx
+      br label %outer.inc
+
+
+
+outer.inc:
+  %j.inc = add nuw nsw i32 %j, 1
+  br label %outer.for
+
+outer.exit:
+  br label %return
+
+return:
+  ret void
+}
+
+
+; CHECK: Statistics {
+; CHECK:     Compatible overwrites: 1
+; CHECK: }
+; CHECK: No modification has been made

Added: polly/trunk/test/DeLICM/nomap_writewrite.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/DeLICM/nomap_writewrite.ll?rev=296348&view=auto
==============================================================================
--- polly/trunk/test/DeLICM/nomap_writewrite.ll (added)
+++ polly/trunk/test/DeLICM/nomap_writewrite.ll Mon Feb 27 09:53:18 2017
@@ -0,0 +1,88 @@
+; RUN: opt %loadPolly -polly-delicm -analyze < %s | FileCheck %s
+;
+;    void func(double *A) {
+;      for (int j = 0; j < 2; j += 1) { /* outer */
+;        double phi = 0.0;
+;        for (int i = 0; i < 4; i += 1) /* reduction */
+;          if (phi < 0.0)
+;            A[j] = undef;
+;          phi += 4.2;
+;        A[j] = phi;
+;      }
+;    }
+;
+; The MAY_WRITE in reduction.for.true conflict with a write of %phi to
+; A[j] if %phi would be mapped to it. Being a MAY_WRITE avoids being target
+; of a mapping itself.
+;
+; TODO: There is actually no reason why these conflict. The MAY_WRITE is an
+; explicit write, defined to occur always before all implicit writes as the
+; write of %phi would be. There is currently no differentiation between
+; implicit and explicit writes in Polly.
+;
+define void @func(double* noalias nonnull %A) {
+entry:
+  %fsomeval = fadd double 21.0, 21.0
+  br label %outer.preheader
+
+outer.preheader:
+  br label %outer.for
+
+outer.for:
+  %j = phi i32 [0, %outer.preheader], [%j.inc, %outer.inc]
+  %j.cmp = icmp slt i32 %j, 2
+  br i1 %j.cmp, label %reduction.preheader, label %outer.exit
+
+
+    reduction.preheader:
+      br label %reduction.for
+
+    reduction.for:
+      %i = phi i32 [0, %reduction.preheader], [%i.inc, %reduction.inc]
+      %phi = phi double [0.0, %reduction.preheader], [%add, %reduction.inc]
+      %A_idx = getelementptr inbounds double, double* %A, i32 %j
+      %phi.cmp = fcmp ogt double %phi, 0.0
+      br i1 %phi.cmp, label %reduction.for.true, label %reduction.for.unconditional
+
+    reduction.for.true:
+       store double undef, double* %A_idx
+       br label %reduction.for.unconditional
+
+    reduction.for.unconditional:
+      %i.cmp = icmp slt i32 %i, 4
+      br i1 %i.cmp, label %body, label %reduction.exit
+
+
+
+        body:
+          %add = fadd double %phi, 4.2
+          br label %reduction.inc
+
+
+
+    reduction.inc:
+      %i.inc = add nuw nsw i32 %i, 1
+      br label %reduction.for
+
+    reduction.exit:
+      store double %phi, double* %A_idx
+      br label %outer.inc
+
+
+
+outer.inc:
+  %j.inc = add nuw nsw i32 %j, 1
+  br label %outer.for
+
+outer.exit:
+  br label %return
+
+return:
+  ret void
+}
+
+
+; CHECK: Statistics {
+; CHECK:     Compatible overwrites: 1
+; CHECK: }
+; CHECK: No modification has been made




More information about the llvm-commits mailing list