summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--polly/lib/Transform/Simplify.cpp3
-rw-r--r--polly/test/Simplify/gemm.ll8
-rw-r--r--polly/test/Simplify/redundant_scalarwrite.ll49
-rw-r--r--polly/test/Simplify/redundant_scalarwrite___%for---%return.jscop43
-rw-r--r--polly/test/Simplify/redundant_scalarwrite___%for---%return.jscop.transformed43
5 files changed, 138 insertions, 8 deletions
diff --git a/polly/lib/Transform/Simplify.cpp b/polly/lib/Transform/Simplify.cpp
index 8322e6e2562..904030e958c 100644
--- a/polly/lib/Transform/Simplify.cpp
+++ b/polly/lib/Transform/Simplify.cpp
@@ -424,7 +424,8 @@ private:
continue;
if (!WA->isLatestArrayKind())
continue;
- if (!isa<StoreInst>(WA->getAccessInstruction()) && !WA->isPHIKind())
+ if (!isa<StoreInst>(WA->getAccessInstruction()) &&
+ !WA->isOriginalScalarKind())
continue;
llvm::Value *ReadingValue = WA->tryGetValueStored();
diff --git a/polly/test/Simplify/gemm.ll b/polly/test/Simplify/gemm.ll
index 592f0fa84a6..85f05d12469 100644
--- a/polly/test/Simplify/gemm.ll
+++ b/polly/test/Simplify/gemm.ll
@@ -24,13 +24,7 @@
; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
; CHECK-NEXT: { Stmt_bb13[i0, i1, i2] -> MemRef_tmp_0[] };
; CHECK-NEXT: new: { Stmt_bb13[i0, i1, i2] -> MemRef_C[i0, i1] };
-; CHECK-NEXT: Stmt_bb11
-; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
-; CHECK-NEXT: { Stmt_bb11[i0, i1] -> MemRef_tmp_0_lcssa__phi[] };
-; CHECK-NEXT: new: { Stmt_bb11[i0, i1] -> MemRef_C[i0, i1] };
-; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
-; CHECK-NEXT: { Stmt_bb11[i0, i1] -> MemRef_tmp_0_lcssa[] };
-; CHECK-NEXT: new: { Stmt_bb11[i0, i1] -> MemRef_C[i0, i1] };
+; CHECK-NEXT: }
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
diff --git a/polly/test/Simplify/redundant_scalarwrite.ll b/polly/test/Simplify/redundant_scalarwrite.ll
new file mode 100644
index 00000000000..c0071941575
--- /dev/null
+++ b/polly/test/Simplify/redundant_scalarwrite.ll
@@ -0,0 +1,49 @@
+; RUN: opt %loadPolly -polly-import-jscop -polly-import-jscop-postfix=transformed -polly-simplify -analyze < %s | FileCheck %s -match-full-lines
+;
+; Remove redundant scalar stores.
+;
+; for (int j = 0; j < n; j += 1) {
+; bodyA:
+; double val = A[0];
+;
+; bodyB:
+; A[0] = val;
+; }
+;
+define void @redundant_scalarwrite(i32 %n, double* noalias nonnull %A) {
+entry:
+ br label %for
+
+for:
+ %j = phi i32 [0, %entry], [%j.inc, %inc]
+ %j.cmp = icmp slt i32 %j, %n
+ br i1 %j.cmp, label %bodyA, label %exit
+
+
+ bodyA:
+ %val = load double, double* %A
+ br label %bodyB
+
+ bodyB:
+ store double %val, double* %A
+ br label %inc
+
+
+inc:
+ %j.inc = add nuw nsw i32 %j, 1
+ br label %for
+
+exit:
+ br label %return
+
+return:
+ ret void
+}
+
+
+; CHECK: Statistics {
+; CHECK: Redundant writes removed: 2
+; CHECK: }
+
+; CHECK: After accesses {
+; CHECK-NEXT: }
diff --git a/polly/test/Simplify/redundant_scalarwrite___%for---%return.jscop b/polly/test/Simplify/redundant_scalarwrite___%for---%return.jscop
new file mode 100644
index 00000000000..689c0c1f08f
--- /dev/null
+++ b/polly/test/Simplify/redundant_scalarwrite___%for---%return.jscop
@@ -0,0 +1,43 @@
+{
+ "arrays" : [
+ {
+ "name" : "MemRef_A",
+ "sizes" : [ "*" ],
+ "type" : "double"
+ }
+ ],
+ "context" : "[n] -> { : -2147483648 <= n <= 2147483647 }",
+ "name" : "%for---%return",
+ "statements" : [
+ {
+ "accesses" : [
+ {
+ "kind" : "read",
+ "relation" : "[n] -> { Stmt_bodyA[i0] -> MemRef_A[0] }"
+ },
+ {
+ "kind" : "write",
+ "relation" : "[n] -> { Stmt_bodyA[i0] -> MemRef_val[] }"
+ }
+ ],
+ "domain" : "[n] -> { Stmt_bodyA[i0] : 0 <= i0 < n }",
+ "name" : "Stmt_bodyA",
+ "schedule" : "[n] -> { Stmt_bodyA[i0] -> [i0, 0] }"
+ },
+ {
+ "accesses" : [
+ {
+ "kind" : "write",
+ "relation" : "[n] -> { Stmt_bodyB[i0] -> MemRef_A[0] }"
+ },
+ {
+ "kind" : "read",
+ "relation" : "[n] -> { Stmt_bodyB[i0] -> MemRef_val[] }"
+ }
+ ],
+ "domain" : "[n] -> { Stmt_bodyB[i0] : 0 <= i0 < n }",
+ "name" : "Stmt_bodyB",
+ "schedule" : "[n] -> { Stmt_bodyB[i0] -> [i0, 1] }"
+ }
+ ]
+}
diff --git a/polly/test/Simplify/redundant_scalarwrite___%for---%return.jscop.transformed b/polly/test/Simplify/redundant_scalarwrite___%for---%return.jscop.transformed
new file mode 100644
index 00000000000..c0183528611
--- /dev/null
+++ b/polly/test/Simplify/redundant_scalarwrite___%for---%return.jscop.transformed
@@ -0,0 +1,43 @@
+{
+ "arrays" : [
+ {
+ "name" : "MemRef_A",
+ "sizes" : [ "*" ],
+ "type" : "double"
+ }
+ ],
+ "context" : "[n] -> { : -2147483648 <= n <= 2147483647 }",
+ "name" : "%for---%return",
+ "statements" : [
+ {
+ "accesses" : [
+ {
+ "kind" : "read",
+ "relation" : "[n] -> { Stmt_bodyA[i0] -> MemRef_A[0] }"
+ },
+ {
+ "kind" : "write",
+ "relation" : "[n] -> { Stmt_bodyA[i0] -> MemRef_A[0] }"
+ }
+ ],
+ "domain" : "[n] -> { Stmt_bodyA[i0] : 0 <= i0 < n }",
+ "name" : "Stmt_bodyA",
+ "schedule" : "[n] -> { Stmt_bodyA[i0] -> [i0, 0] }"
+ },
+ {
+ "accesses" : [
+ {
+ "kind" : "write",
+ "relation" : "[n] -> { Stmt_bodyB[i0] -> MemRef_A[0] }"
+ },
+ {
+ "kind" : "read",
+ "relation" : "[n] -> { Stmt_bodyB[i0] -> MemRef_A[0] }"
+ }
+ ],
+ "domain" : "[n] -> { Stmt_bodyB[i0] : 0 <= i0 < n }",
+ "name" : "Stmt_bodyB",
+ "schedule" : "[n] -> { Stmt_bodyB[i0] -> [i0, 1] }"
+ }
+ ]
+}
OpenPOWER on IntegriCloud