[polly] r316642 - [DeLICM] Add more tests for loop layouts. NFC.
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 26 01:03:28 PDT 2017
Author: meinersbur
Date: Thu Oct 26 01:03:28 2017
New Revision: 316642
URL: http://llvm.org/viewvc/llvm-project?rev=316642&view=rev
Log:
[DeLICM] Add more tests for loop layouts. NFC.
Added:
polly/trunk/test/DeLICM/reduction_looprotate_gvnpre_cond1.ll
polly/trunk/test/DeLICM/reduction_looprotate_gvnpre_cond2.ll
polly/trunk/test/DeLICM/reduction_looprotate_gvnpre_nopreheader.ll
polly/trunk/test/DeLICM/reduction_looprotate_licm2.ll
polly/trunk/test/DeLICM/reduction_looprotate_licm_nopreheader.ll
polly/trunk/test/DeLICM/reduction_looprotate_loopguard_gvnpre.ll
polly/trunk/test/DeLICM/reduction_looprotate_loopguard_licm1.ll
polly/trunk/test/DeLICM/reduction_looprotate_loopguard_licm2.ll
polly/trunk/test/DeLICM/reduction_looprotate_loopguard_licm3.ll
Added: polly/trunk/test/DeLICM/reduction_looprotate_gvnpre_cond1.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/DeLICM/reduction_looprotate_gvnpre_cond1.ll?rev=316642&view=auto
==============================================================================
--- polly/trunk/test/DeLICM/reduction_looprotate_gvnpre_cond1.ll (added)
+++ polly/trunk/test/DeLICM/reduction_looprotate_gvnpre_cond1.ll Thu Oct 26 01:03:28 2017
@@ -0,0 +1,126 @@
+; RUN: opt %loadPolly -polly-delicm -analyze < %s | FileCheck %s -match-full-lines
+;
+; Load (but not store) of A[j] hoisted, reduction only over some iterations.
+;
+; 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 (i != 2)
+; phi += 4.2;
+; A[j] = phi;
+; }
+; }
+; }
+;
+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]
+ %phi = phi double [0.0, %reduction.preheader], [%join, %reduction.inc]
+ br label %body
+
+
+
+ body:
+ %cond = icmp ne i32 %i, 2
+ br i1 %cond, label %body_true, label %body_join
+
+ body_true:
+ %add = fadd double %phi, 4.2
+ br label %body_join
+
+ body_join:
+ %join = phi double [%phi, %body], [%add, %body_true]
+ %A_idx = getelementptr inbounds double, double* %A, i32 %j
+ store double %join, double* %A_idx
+ br label %reduction.inc
+
+
+
+ reduction.inc:
+ %i.inc = add nuw nsw i32 %i, 1
+ %i.cmp = icmp slt i32 %i.inc, 4
+ br i1 %i.cmp, label %reduction.for, label %reduction.exit
+
+ reduction.exit:
+ 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: 2
+; CHECK: }
+
+; CHECK: After accesses {
+; CHECK-NEXT: Stmt_reduction_preheader
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_reduction_preheader[i0] -> MemRef_phi__phi[] };
+; CHECK-NEXT: new: { Stmt_reduction_preheader[i0] -> MemRef_A[i0] };
+; CHECK-NEXT: Stmt_reduction_for
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_reduction_for[i0, i1] -> MemRef_phi__phi[] };
+; CHECK-NEXT: new: { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_reduction_for[i0, i1] -> MemRef_phi[] };
+; CHECK-NEXT: new: { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: Stmt_body
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_body[i0, i1] -> MemRef_phi[] };
+; CHECK-NEXT: new: { Stmt_body[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_body[i0, i1] -> MemRef_join__phi[] };
+; CHECK-NEXT: new: { Stmt_body[i0, 2] -> MemRef_A[i0] };
+; CHECK-NEXT: Stmt_body_true
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_body_true[i0, i1] -> MemRef_phi[] };
+; CHECK-NEXT: new: { Stmt_body_true[i0, i1] -> MemRef_A[i0] : i1 <= 1; Stmt_body_true[i0, 3] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_body_true[i0, i1] -> MemRef_join__phi[] };
+; CHECK-NEXT: new: { Stmt_body_true[i0, i1] -> MemRef_A[i0] : i1 <= 1; Stmt_body_true[i0, 3] -> MemRef_A[i0] };
+; CHECK-NEXT: Stmt_body_join
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_body_join[i0, i1] -> MemRef_join[] };
+; CHECK-NEXT: new: { Stmt_body_join[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_body_join[i0, i1] -> MemRef_join__phi[] };
+; CHECK-NEXT: new: { Stmt_body_join[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
+; CHECK-NEXT: { Stmt_body_join[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: Stmt_reduction_inc
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_reduction_inc[i0, i1] -> MemRef_join[] };
+; CHECK-NEXT: new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_reduction_inc[i0, i1] -> MemRef_phi__phi[] };
+; CHECK-NEXT: new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] : i1 <= 2 };
+; CHECK-NEXT: }
Added: polly/trunk/test/DeLICM/reduction_looprotate_gvnpre_cond2.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/DeLICM/reduction_looprotate_gvnpre_cond2.ll?rev=316642&view=auto
==============================================================================
--- polly/trunk/test/DeLICM/reduction_looprotate_gvnpre_cond2.ll (added)
+++ polly/trunk/test/DeLICM/reduction_looprotate_gvnpre_cond2.ll Thu Oct 26 01:03:28 2017
@@ -0,0 +1,127 @@
+; RUN: opt %loadPolly -polly-delicm -analyze < %s | FileCheck %s -match-full-lines
+;
+; Load (but not store) of A[j] hoisted, reduction not written in all iterations.
+; FIXME: %join is not mapped because the MemoryKind::Value mapping does not
+; encompass all iterations (last iteration is unused)
+;
+; 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 (i != 2) {
+; phi += 4.2;
+; A[j] = phi;
+; }
+; }
+; }
+; }
+;
+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:
+ %A_idx = getelementptr inbounds double, double* %A, i32 %j
+ %init = load double, double* %A_idx
+ br label %reduction.for
+
+ reduction.for:
+ %i = phi i32 [0, %reduction.preheader], [%i.inc, %reduction.inc]
+ %phi = phi double [%init, %reduction.preheader], [%join, %reduction.inc]
+ br label %body
+
+
+
+ body:
+ %cond = icmp ne i32 %i, 2
+ br i1 %cond, label %body_true, label %body_join
+
+ body_true:
+ %add = fadd double %phi, 4.2
+ store double %add, double* %A_idx
+ br label %body_join
+
+ body_join:
+ %join = phi double [%phi, %body], [%add, %body_true]
+ br label %reduction.inc
+
+
+
+ reduction.inc:
+ %i.inc = add nuw nsw i32 %i, 1
+ %i.cmp = icmp slt i32 %i.inc, 4
+ br i1 %i.cmp, label %reduction.for, label %reduction.exit
+
+ reduction.exit:
+ 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: 1
+; CHECK: PHI scalars mapped: 1
+; CHECK: }
+
+; CHECK-NEXT: After accesses {
+; CHECK-NEXT: Stmt_reduction_preheader
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
+; CHECK-NEXT: { Stmt_reduction_preheader[i0] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_reduction_preheader[i0] -> MemRef_phi__phi[] };
+; CHECK-NEXT: new: { Stmt_reduction_preheader[i0] -> MemRef_A[i0] };
+; CHECK-NEXT: Stmt_reduction_for
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_reduction_for[i0, i1] -> MemRef_phi__phi[] };
+; CHECK-NEXT: new: { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_reduction_for[i0, i1] -> MemRef_phi[] };
+; CHECK-NEXT: new: { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: Stmt_body
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_body[i0, i1] -> MemRef_phi[] };
+; CHECK-NEXT: new: { Stmt_body[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_body[i0, i1] -> MemRef_join__phi[] };
+; CHECK-NEXT: Stmt_body_true
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_body_true[i0, i1] -> MemRef_phi[] };
+; CHECK-NEXT: new: { Stmt_body_true[i0, i1] -> MemRef_A[i0] : i1 <= 1; Stmt_body_true[i0, 3] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
+; CHECK-NEXT: { Stmt_body_true[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_body_true[i0, i1] -> MemRef_join__phi[] };
+; CHECK-NEXT: Stmt_body_join
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_body_join[i0, i1] -> MemRef_join[] };
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_body_join[i0, i1] -> MemRef_join__phi[] };
+; CHECK-NEXT: Stmt_reduction_inc
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_reduction_inc[i0, i1] -> MemRef_join[] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_reduction_inc[i0, i1] -> MemRef_phi__phi[] };
+; CHECK-NEXT: new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] : i1 <= 2 };
+; CHECK-NEXT: }
Added: polly/trunk/test/DeLICM/reduction_looprotate_gvnpre_nopreheader.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/DeLICM/reduction_looprotate_gvnpre_nopreheader.ll?rev=316642&view=auto
==============================================================================
--- polly/trunk/test/DeLICM/reduction_looprotate_gvnpre_nopreheader.ll (added)
+++ polly/trunk/test/DeLICM/reduction_looprotate_gvnpre_nopreheader.ll Thu Oct 26 01:03:28 2017
@@ -0,0 +1,100 @@
+; RUN: opt %loadPolly -polly-delicm -analyze < %s | FileCheck %s -match-full-lines
+;
+; Hosted reduction load (but not the store) without preheader.
+;
+; 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;
+; A[j] = phi;
+; }
+; }
+; }
+;
+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.for, label %outer.exit
+
+
+ reduction.for:
+ %i = phi i32 [0, %outer.for], [%i.inc, %reduction.inc]
+ %phi = phi double [0.0, %outer.for], [%add, %reduction.inc]
+ br label %body
+
+
+
+ body:
+ %add = fadd double %phi, 4.2
+ %A_idx = getelementptr inbounds double, double* %A, i32 %j
+ store double %add, double* %A_idx
+ br label %reduction.inc
+
+
+
+ reduction.inc:
+ %i.inc = add nuw nsw i32 %i, 1
+ %i.cmp = icmp slt i32 %i.inc, 4
+ br i1 %i.cmp, label %reduction.for, label %reduction.exit
+
+ reduction.exit:
+ 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: }
+
+; CHECK-NEXT: After accesses {
+; CHECK-NEXT: Stmt_outer_for
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_outer_for[i0] -> MemRef_phi__phi[] };
+; CHECK-NEXT: new: { Stmt_outer_for[i0] -> MemRef_A[i0] : i0 <= 1 };
+; CHECK-NEXT: Stmt_reduction_for
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_reduction_for[i0, i1] -> MemRef_phi__phi[] };
+; CHECK-NEXT: new: { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_reduction_for[i0, i1] -> MemRef_phi[] };
+; CHECK-NEXT: new: { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: Stmt_body
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_body[i0, i1] -> MemRef_add[] };
+; CHECK-NEXT: new: { Stmt_body[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_body[i0, i1] -> MemRef_phi[] };
+; CHECK-NEXT: new: { Stmt_body[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
+; CHECK-NEXT: { Stmt_body[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: Stmt_reduction_inc
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_reduction_inc[i0, i1] -> MemRef_add[] };
+; CHECK-NEXT: new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_reduction_inc[i0, i1] -> MemRef_phi__phi[] };
+; CHECK-NEXT: new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] : i1 <= 2 };
+; CHECK-NEXT: }
Added: polly/trunk/test/DeLICM/reduction_looprotate_licm2.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/DeLICM/reduction_looprotate_licm2.ll?rev=316642&view=auto
==============================================================================
--- polly/trunk/test/DeLICM/reduction_looprotate_licm2.ll (added)
+++ polly/trunk/test/DeLICM/reduction_looprotate_licm2.ll Thu Oct 26 01:03:28 2017
@@ -0,0 +1,112 @@
+; RUN: opt %loadPolly -polly-flatten-schedule -polly-delicm -analyze < %s | FileCheck %s
+;
+; Use %phi instead of the normal %add; that is, the last last iteration will
+; be ignored such the %phi cannot be written to A[3] in %body.
+;
+; void func(double *A) {
+; for (int j = 0; j < 2; j += 1) { /* outer */
+; double phi;
+; double incoming = A[j];
+; for (int i = 0; i < 4; i += 1) { /* reduction */
+; phi = incoming;
+; add = phi + 4.2;
+; incoming = add;
+; }
+; A[j] = phi;
+; }
+; }
+;
+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:
+ %A_idx = getelementptr inbounds double, double* %A, i32 %j
+ %init = load double, double* %A_idx
+ br label %reduction.for
+
+ reduction.for:
+ %i = phi i32 [0, %reduction.preheader], [%i.inc, %reduction.inc]
+ %phi = phi double [%init, %reduction.preheader], [%add, %reduction.inc]
+ br label %body
+
+
+
+ body:
+ %add = fadd double %phi, 4.2
+ br label %reduction.inc
+
+
+
+ reduction.inc:
+ %i.inc = add nuw nsw i32 %i, 1
+ %i.cmp = icmp slt i32 %i.inc, 4
+ br i1 %i.cmp, label %reduction.for, label %reduction.exit
+
+ 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: Overwrites mapped to: 1
+; CHECK: Value scalars mapped: 1
+; CHECK: PHI scalars mapped: 1
+; CHECK: }
+
+; CHECK: After accesses {
+; CHECK-NEXT: Stmt_reduction_preheader
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
+; CHECK-NEXT: { Stmt_reduction_preheader[i0] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_reduction_preheader[i0] -> MemRef_phi__phi[] };
+; CHECK-NEXT: new: { Stmt_reduction_preheader[i0] -> MemRef_A[i0] };
+; CHECK-NEXT: Stmt_reduction_for
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_reduction_for[i0, i1] -> MemRef_phi__phi[] };
+; CHECK-NEXT: new: { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_reduction_for[i0, i1] -> MemRef_phi[] };
+; CHECK-NEXT: new: { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: Stmt_body
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_body[i0, i1] -> MemRef_add[] };
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_body[i0, i1] -> MemRef_phi[] };
+; CHECK-NEXT: new: { Stmt_body[i0, i1] -> MemRef_A[i0] : 3i1 <= 22 - 14i0; Stmt_body[1, 3] -> MemRef_A[1] };
+; CHECK-NEXT: Stmt_reduction_inc
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_reduction_inc[i0, i1] -> MemRef_add[] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_reduction_inc[i0, i1] -> MemRef_phi__phi[] };
+; CHECK-NEXT: new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] : i1 <= 2 };
+; CHECK-NEXT: Stmt_reduction_exit
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
+; CHECK-NEXT: { Stmt_reduction_exit[i0] -> MemRef_A[i0] };
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_reduction_exit[i0] -> MemRef_phi[] };
+; CHECK-NEXT: new: { Stmt_reduction_exit[i0] -> MemRef_A[i0] };
+; CHECK-NEXT: }
Added: polly/trunk/test/DeLICM/reduction_looprotate_licm_nopreheader.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/DeLICM/reduction_looprotate_licm_nopreheader.ll?rev=316642&view=auto
==============================================================================
--- polly/trunk/test/DeLICM/reduction_looprotate_licm_nopreheader.ll (added)
+++ polly/trunk/test/DeLICM/reduction_looprotate_licm_nopreheader.ll Thu Oct 26 01:03:28 2017
@@ -0,0 +1,107 @@
+; RUN: opt %loadPolly -polly-delicm -analyze < %s | FileCheck %s
+;
+; Register-promoted reduction but without preheader.
+;
+; void func(double *A) {
+; for (int j = 0; j < 2; j += 1) { /* outer */
+; double phi = A[j];
+; for (int i = 0; i < 4; i += 1) /* reduction */
+; phi += 4.2;
+; A[j] = phi;
+; }
+; }
+;
+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
+ %A_idx = getelementptr inbounds double, double* %A, i32 %j
+ %init = load double, double* %A_idx
+ br i1 %j.cmp, label %reduction.for, label %outer.exit
+
+
+
+ reduction.for:
+ %i = phi i32 [0, %outer.for], [%i.inc, %reduction.inc]
+ %phi = phi double [%init, %outer.for], [%add, %reduction.inc]
+ br label %body
+
+
+
+ body:
+ %add = fadd double %phi, 4.2
+ br label %reduction.inc
+
+
+
+ reduction.inc:
+ %i.inc = add nuw nsw i32 %i, 1
+ %i.cmp = icmp slt i32 %i.inc, 4
+ br i1 %i.cmp, label %reduction.for, label %reduction.exit
+
+ reduction.exit:
+ store double %add, 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: }
+
+; CHECK: After accesses {
+; CHECK-NEXT: Stmt_outer_for
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
+; CHECK-NEXT: { Stmt_outer_for[i0] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_outer_for[i0] -> MemRef_phi__phi[] };
+; CHECK-NEXT: new: { Stmt_outer_for[i0] -> MemRef_A[i0] : i0 <= 1 };
+; CHECK-NEXT: Stmt_reduction_for
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_reduction_for[i0, i1] -> MemRef_phi__phi[] };
+; CHECK-NEXT: new: { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_reduction_for[i0, i1] -> MemRef_phi[] };
+; CHECK-NEXT: new: { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: Stmt_body
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_body[i0, i1] -> MemRef_add[] };
+; CHECK-NEXT: new: { Stmt_body[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_body[i0, i1] -> MemRef_phi[] };
+; CHECK-NEXT: new: { Stmt_body[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: Stmt_reduction_inc
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_reduction_inc[i0, i1] -> MemRef_add[] };
+; CHECK-NEXT: new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_reduction_inc[i0, i1] -> MemRef_phi__phi[] };
+; CHECK-NEXT: new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] : i1 <= 2 };
+; CHECK-NEXT: Stmt_reduction_exit
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
+; CHECK-NEXT: { Stmt_reduction_exit[i0] -> MemRef_A[i0] };
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: { Stmt_reduction_exit[i0] -> MemRef_add[] };
+; CHECK-NEXT: new: { Stmt_reduction_exit[i0] -> MemRef_A[i0] };
+; CHECK-NEXT: }
Added: polly/trunk/test/DeLICM/reduction_looprotate_loopguard_gvnpre.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/DeLICM/reduction_looprotate_loopguard_gvnpre.ll?rev=316642&view=auto
==============================================================================
--- polly/trunk/test/DeLICM/reduction_looprotate_loopguard_gvnpre.ll (added)
+++ polly/trunk/test/DeLICM/reduction_looprotate_loopguard_gvnpre.ll Thu Oct 26 01:03:28 2017
@@ -0,0 +1,105 @@
+; RUN: opt %loadPolly -polly-delicm -analyze < %s | FileCheck %s -match-full-lines
+;
+; Reduction over parametric number of elements and a loopguard if the
+; reduction loop is not executed at all. Load hoisted before loop.
+;
+; void func(double *A) {
+; for (int j = 0; j < 2; j += 1) { /* outer */
+; double phi = 0.0;
+; for (int i = 0; i < n; i += 1) { /* reduction */
+; phi += 4.2;
+; A[j] = phi;
+; }
+; }
+; }
+;
+define void @func(i32 %n, 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:
+ %guard.cmp = icmp sle i32 %n,0
+ br i1 %guard.cmp, label %reduction.exit, 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]
+ br label %body
+
+
+
+ body:
+ %add = fadd double %phi, 4.2
+ %A_idx = getelementptr inbounds double, double* %A, i32 %j
+ store double %add, double* %A_idx
+ br label %reduction.inc
+
+
+
+ reduction.inc:
+ %i.inc = add nuw nsw i32 %i, 1
+ %i.cmp = icmp slt i32 %i.inc, %n
+ br i1 %i.cmp, label %reduction.for, label %reduction.exit
+
+ reduction.exit:
+ 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: }
+
+; CHECK: After accesses {
+; CHECK-NEXT: Stmt_reduction_preheader
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_reduction_preheader[i0] -> MemRef_phi__phi[] };
+; CHECK-NEXT: new: [n] -> { Stmt_reduction_preheader[i0] -> MemRef_A[i0] : n > 0 };
+; CHECK-NEXT: Stmt_reduction_for
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_reduction_for[i0, i1] -> MemRef_phi__phi[] };
+; CHECK-NEXT: new: [n] -> { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_reduction_for[i0, i1] -> MemRef_phi[] };
+; CHECK-NEXT: new: [n] -> { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: Stmt_body
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_body[i0, i1] -> MemRef_add[] };
+; CHECK-NEXT: new: [n] -> { Stmt_body[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_body[i0, i1] -> MemRef_phi[] };
+; CHECK-NEXT: new: [n] -> { Stmt_body[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
+; CHECK-NEXT: [n] -> { Stmt_body[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: Stmt_reduction_inc
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_reduction_inc[i0, i1] -> MemRef_add[] };
+; CHECK-NEXT: new: [n] -> { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_reduction_inc[i0, i1] -> MemRef_phi__phi[] };
+; CHECK-NEXT: new: [n] -> { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] : i1 <= -2 + n };
+; CHECK-NEXT: }
Added: polly/trunk/test/DeLICM/reduction_looprotate_loopguard_licm1.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/DeLICM/reduction_looprotate_loopguard_licm1.ll?rev=316642&view=auto
==============================================================================
--- polly/trunk/test/DeLICM/reduction_looprotate_loopguard_licm1.ll (added)
+++ polly/trunk/test/DeLICM/reduction_looprotate_loopguard_licm1.ll Thu Oct 26 01:03:28 2017
@@ -0,0 +1,119 @@
+; RUN: opt %loadPolly -polly-delicm -analyze < %s | FileCheck %s -match-full-lines
+;
+; Reduction over parametric number of elements and a loopguard if the
+; reduction loop is not executed at all.
+; Reduction variable promoted to register.
+;
+; void func(double *A) {
+; for (int j = 0; j < 2; j += 1) { /* outer */
+; double phi = A[j];
+; for (int i = 0; i < n; i += 1) /* reduction */
+; phi += 4.2;
+; A[j] = phi;
+; }
+; }
+;
+define void @func(i32 %n, 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.guard, label %outer.exit
+
+
+ reduction.guard:
+ %A_idx = getelementptr inbounds double, double* %A, i32 %j
+ %init = load double, double* %A_idx
+ %guard.cmp = icmp sle i32 %n,0
+ br i1 %guard.cmp, label %reduction.exit, label %reduction.for
+
+ reduction.for:
+ %i = phi i32 [0, %reduction.guard], [%i.inc, %reduction.inc]
+ %phi = phi double [%init, %reduction.guard], [%add, %reduction.inc]
+ br label %body
+
+
+
+ body:
+ %add = fadd double %phi, 4.2
+ br label %reduction.inc
+
+
+
+ reduction.inc:
+ %i.inc = add nuw nsw i32 %i, 1
+ %i.cmp = icmp slt i32 %i.inc, %n
+ br i1 %i.cmp, label %reduction.for, label %reduction.exit
+
+ reduction.exit:
+ %result = phi double [%init, %reduction.guard], [%add, %reduction.inc]
+ store double %result, 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: 2
+; CHECK: }
+
+; CHECK: After accesses {
+; CHECK-NEXT: Stmt_reduction_guard
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
+; CHECK-NEXT: [n] -> { Stmt_reduction_guard[i0] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_reduction_guard[i0] -> MemRef_phi__phi[] };
+; CHECK-NEXT: new: [n] -> { Stmt_reduction_guard[i0] -> MemRef_A[i0] : n > 0 };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_reduction_guard[i0] -> MemRef_result__phi[] };
+; CHECK-NEXT: new: [n] -> { Stmt_reduction_guard[i0] -> MemRef_A[i0] : n <= 0 };
+; CHECK-NEXT: Stmt_reduction_for
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_reduction_for[i0, i1] -> MemRef_phi__phi[] };
+; CHECK-NEXT: new: [n] -> { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_reduction_for[i0, i1] -> MemRef_phi[] };
+; CHECK-NEXT: new: [n] -> { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: Stmt_body
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_body[i0, i1] -> MemRef_add[] };
+; CHECK-NEXT: new: [n] -> { Stmt_body[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_body[i0, i1] -> MemRef_phi[] };
+; CHECK-NEXT: new: [n] -> { Stmt_body[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: Stmt_reduction_inc
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_reduction_inc[i0, i1] -> MemRef_add[] };
+; CHECK-NEXT: new: [n] -> { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_reduction_inc[i0, i1] -> MemRef_phi__phi[] };
+; CHECK-NEXT: new: [n] -> { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] : i1 <= -2 + n };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_reduction_inc[i0, i1] -> MemRef_result__phi[] };
+; CHECK-NEXT: new: [n] -> { Stmt_reduction_inc[i0, -1 + n] -> MemRef_A[i0] };
+; CHECK-NEXT: Stmt_reduction_exit
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_reduction_exit[i0] -> MemRef_result__phi[] };
+; CHECK-NEXT: new: [n] -> { Stmt_reduction_exit[i0] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
+; CHECK-NEXT: [n] -> { Stmt_reduction_exit[i0] -> MemRef_A[i0] };
+; CHECK-NEXT: }
Added: polly/trunk/test/DeLICM/reduction_looprotate_loopguard_licm2.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/DeLICM/reduction_looprotate_loopguard_licm2.ll?rev=316642&view=auto
==============================================================================
--- polly/trunk/test/DeLICM/reduction_looprotate_loopguard_licm2.ll (added)
+++ polly/trunk/test/DeLICM/reduction_looprotate_loopguard_licm2.ll Thu Oct 26 01:03:28 2017
@@ -0,0 +1,117 @@
+; RUN: opt %loadPolly -polly-delicm -analyze < %s | FileCheck %s -match-full-lines
+;
+; Reduction over parametric number of elements and a loopguard if the
+; reduction loop is not executed at all, such that A[j] is also not written to.
+; Reduction variable promoted to register.
+;
+; void func(double *A) {
+; for (int j = 0; j < 2; j += 1) { /* outer */
+; double phi = A[j];
+; if (i > 0) {
+; for (int i = 0; i < n; i += 1) /* reduction */
+; phi += 4.2;
+; A[j] = phi;
+; }
+; }
+; }
+;
+define void @func(i32 %n, 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.guard, label %outer.exit
+
+
+ reduction.guard:
+ %A_idx = getelementptr inbounds double, double* %A, i32 %j
+ %init = load double, double* %A_idx
+ %guard.cmp = icmp sle i32 %n,0
+ br i1 %guard.cmp, label %reduction.skip, label %reduction.for
+
+ reduction.for:
+ %i = phi i32 [0, %reduction.guard], [%i.inc, %reduction.inc]
+ %phi = phi double [%init, %reduction.guard], [%add, %reduction.inc]
+ br label %body
+
+
+
+ body:
+ %add = fadd double %phi, 4.2
+ br label %reduction.inc
+
+
+
+ reduction.inc:
+ %i.inc = add nuw nsw i32 %i, 1
+ %i.cmp = icmp slt i32 %i.inc, %n
+ br i1 %i.cmp, label %reduction.for, label %reduction.exit
+
+ reduction.exit:
+ store double %add, double* %A_idx
+ br label %reduction.skip
+
+ reduction.skip:
+ 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: }
+
+; CHECK: After accesses {
+; CHECK-NEXT: Stmt_reduction_guard
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
+; CHECK-NEXT: [n] -> { Stmt_reduction_guard[i0] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_reduction_guard[i0] -> MemRef_phi__phi[] };
+; CHECK-NEXT: new: [n] -> { Stmt_reduction_guard[i0] -> MemRef_A[i0] : n > 0 };
+; CHECK-NEXT: Stmt_reduction_for
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_reduction_for[i0, i1] -> MemRef_phi__phi[] };
+; CHECK-NEXT: new: [n] -> { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_reduction_for[i0, i1] -> MemRef_phi[] };
+; CHECK-NEXT: new: [n] -> { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: Stmt_body
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_body[i0, i1] -> MemRef_add[] };
+; CHECK-NEXT: new: [n] -> { Stmt_body[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_body[i0, i1] -> MemRef_phi[] };
+; CHECK-NEXT: new: [n] -> { Stmt_body[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: Stmt_reduction_inc
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_reduction_inc[i0, i1] -> MemRef_add[] };
+; CHECK-NEXT: new: [n] -> { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_reduction_inc[i0, i1] -> MemRef_phi__phi[] };
+; CHECK-NEXT: new: [n] -> { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] : i1 <= -2 + n };
+; CHECK-NEXT: Stmt_reduction_exit
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
+; CHECK-NEXT: [n] -> { Stmt_reduction_exit[i0] -> MemRef_A[i0] };
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_reduction_exit[i0] -> MemRef_add[] };
+; CHECK-NEXT: new: [n] -> { Stmt_reduction_exit[i0] -> MemRef_A[i0] };
+; CHECK-NEXT: }
Added: polly/trunk/test/DeLICM/reduction_looprotate_loopguard_licm3.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/DeLICM/reduction_looprotate_loopguard_licm3.ll?rev=316642&view=auto
==============================================================================
--- polly/trunk/test/DeLICM/reduction_looprotate_loopguard_licm3.ll (added)
+++ polly/trunk/test/DeLICM/reduction_looprotate_loopguard_licm3.ll Thu Oct 26 01:03:28 2017
@@ -0,0 +1,120 @@
+; RUN: opt %loadPolly -polly-delicm -analyze < %s | FileCheck %s -match-full-lines
+;
+; Reduction over parametric number of elements and a loopguard if the
+; reduction loop is not executed at all, such that A[j] is also not accessed.
+; Reduction variable promoted to register.
+;
+; void func(double *A) {
+; for (int j = 0; j < 2; j += 1) { /* outer */
+; if (i > 0) {
+; double phi = A[j];
+; for (int i = 0; i < n; i += 1) /* reduction */
+; phi += 4.2;
+; A[j] = phi;
+; }
+; }
+; }
+;
+define void @func(i32 %n, 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.guard, label %outer.exit
+
+
+ reduction.guard:
+ %guard.cmp = icmp sle i32 %n,0
+ br i1 %guard.cmp, label %reduction.skip, label %reduction.preheader
+
+ reduction.preheader:
+ %A_idx = getelementptr inbounds double, double* %A, i32 %j
+ %init = load double, double* %A_idx
+ br label %reduction.for
+
+ reduction.for:
+ %i = phi i32 [0, %reduction.preheader], [%i.inc, %reduction.inc]
+ %phi = phi double [%init, %reduction.preheader], [%add, %reduction.inc]
+ br label %body
+
+
+
+ body:
+ %add = fadd double %phi, 4.2
+ br label %reduction.inc
+
+
+
+ reduction.inc:
+ %i.inc = add nuw nsw i32 %i, 1
+ %i.cmp = icmp slt i32 %i.inc, %n
+ br i1 %i.cmp, label %reduction.for, label %reduction.exit
+
+ reduction.exit:
+ store double %add, double* %A_idx
+ br label %reduction.skip
+
+ reduction.skip:
+ 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: }
+
+; CHECK: After accesses {
+; CHECK-NEXT: Stmt_reduction_preheader
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
+; CHECK-NEXT: [n] -> { Stmt_reduction_preheader[i0] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_reduction_preheader[i0] -> MemRef_phi__phi[] };
+; CHECK-NEXT: new: [n] -> { Stmt_reduction_preheader[i0] -> MemRef_A[i0] };
+; CHECK-NEXT: Stmt_reduction_for
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_reduction_for[i0, i1] -> MemRef_phi__phi[] };
+; CHECK-NEXT: new: [n] -> { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_reduction_for[i0, i1] -> MemRef_phi[] };
+; CHECK-NEXT: new: [n] -> { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: Stmt_body
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_body[i0, i1] -> MemRef_add[] };
+; CHECK-NEXT: new: [n] -> { Stmt_body[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_body[i0, i1] -> MemRef_phi[] };
+; CHECK-NEXT: new: [n] -> { Stmt_body[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: Stmt_reduction_inc
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_reduction_inc[i0, i1] -> MemRef_add[] };
+; CHECK-NEXT: new: [n] -> { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_reduction_inc[i0, i1] -> MemRef_phi__phi[] };
+; CHECK-NEXT: new: [n] -> { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] : i1 <= -2 + n };
+; CHECK-NEXT: Stmt_reduction_exit
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
+; CHECK-NEXT: [n] -> { Stmt_reduction_exit[i0] -> MemRef_A[i0] };
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [n] -> { Stmt_reduction_exit[i0] -> MemRef_add[] };
+; CHECK-NEXT: new: [n] -> { Stmt_reduction_exit[i0] -> MemRef_A[i0] };
+; CHECK-NEXT: }
More information about the llvm-commits
mailing list