[polly] r186418 - IndependentBlock: Add option to disable scalar to array rewriting.
Hongbin Zheng
etherzhhb at gmail.com
Tue Jul 16 08:19:34 PDT 2013
Author: ether
Date: Tue Jul 16 10:19:33 2013
New Revision: 186418
URL: http://llvm.org/viewvc/llvm-project?rev=186418&view=rev
Log:
IndependentBlock: Add option to disable scalar to array rewriting.
Modified:
polly/trunk/lib/IndependentBlocks.cpp
polly/trunk/test/IndependentBlocks/inter_bb_scalar_dep.ll
polly/trunk/test/IndependentBlocks/intra_and_inter_bb_scalar_dep.ll
polly/trunk/test/IndependentBlocks/intra_bb_scalar_dep.ll
polly/trunk/test/IndependentBlocks/scalar_to_array.ll
Modified: polly/trunk/lib/IndependentBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/IndependentBlocks.cpp?rev=186418&r1=186417&r2=186418&view=diff
==============================================================================
--- polly/trunk/lib/IndependentBlocks.cpp (original)
+++ polly/trunk/lib/IndependentBlocks.cpp Tue Jul 16 10:19:33 2013
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
//
#include "polly/LinkAllPasses.h"
+#include "polly/Options.h"
#include "polly/CodeGen/BlockGenerators.h"
#include "polly/CodeGen/Cloog.h"
#include "polly/ScopDetection.h"
@@ -21,7 +22,7 @@
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/Assembly/Writer.h"
#include "llvm/Transforms/Utils/Local.h"
-
+#include "llvm/Support/CommandLine.h"
#define DEBUG_TYPE "polly-independent"
#include "llvm/Support/Debug.h"
@@ -30,6 +31,11 @@
using namespace polly;
using namespace llvm;
+static cl::opt<bool>
+DisableIntraScopScalarToArray("disable-polly-intra-scop-scalar-to-array",
+ cl::desc("Do not rewrite scalar to array to generate independent blocks"),
+ cl::Hidden, cl::init(false), cl::cat(PollyCategory));
+
namespace {
struct IndependentBlocks : public FunctionPass {
RegionInfo *RI;
@@ -379,6 +385,8 @@ bool IndependentBlocks::translateScalarT
if (isEscapeUse(U, R))
LoadOutside.push_back(U);
+ if (DisableIntraScopScalarToArray) continue;
+
if (canSynthesize(U, LI, SE, R))
continue;
@@ -465,6 +473,8 @@ bool IndependentBlocks::isIndependentBlo
}
}
+ if (DisableIntraScopScalarToArray) continue;
+
for (Instruction::op_iterator OI = Inst->op_begin(), OE = Inst->op_end();
OI != OE; ++OI) {
if (isEscapeOperand(*OI, BB, R)) {
Modified: polly/trunk/test/IndependentBlocks/inter_bb_scalar_dep.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/IndependentBlocks/inter_bb_scalar_dep.ll?rev=186418&r1=186417&r2=186418&view=diff
==============================================================================
--- polly/trunk/test/IndependentBlocks/inter_bb_scalar_dep.ll (original)
+++ polly/trunk/test/IndependentBlocks/inter_bb_scalar_dep.ll Tue Jul 16 10:19:33 2013
@@ -1,5 +1,7 @@
; RUN: opt %loadPolly -basicaa -polly-independent -S < %s | FileCheck %s
; RUN: opt %loadPolly -basicaa -polly-independent -polly-codegen-scev -S < %s | FileCheck %s
+; RUN: opt %loadPolly -basicaa -polly-independent -disable-polly-intra-scop-scalar-to-array -S < %s | FileCheck %s -check-prefix=SCALARACCESS
+; RUN: opt %loadPolly -basicaa -polly-independent -polly-codegen-scev -disable-polly-intra-scop-scalar-to-array -S < %s | FileCheck %s -check-prefix=SCALARACCESS
; void f(long A[], int N, int *init_ptr) {
; long i, j;
@@ -21,6 +23,8 @@ entry:
; CHECK: entry
; CHECK: %init.s2a = alloca i64
; CHECK: br label %for.i
+
+; SCALARACCESS-NOT: alloca
br label %for.i
for.i:
@@ -30,6 +34,7 @@ for.i:
entry.next:
%init = load i64* %init_ptr
+; SCALARACCESS-NOT: store
br label %for.j
for.j:
@@ -37,6 +42,7 @@ for.j:
%init_plus_two = add i64 %init, 2
; CHECK: %init.loadarray = load i64* %init.s2a
; CHECK: %init_plus_two = add i64 %init.loadarray, 2
+; SCALARACCESS: %init_plus_two = add i64 %init, 2
%scevgep = getelementptr i64* %A, i64 %indvar.j
store i64 %init_plus_two, i64* %scevgep
%indvar.j.next = add nsw i64 %indvar.j, 1
Modified: polly/trunk/test/IndependentBlocks/intra_and_inter_bb_scalar_dep.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/IndependentBlocks/intra_and_inter_bb_scalar_dep.ll?rev=186418&r1=186417&r2=186418&view=diff
==============================================================================
--- polly/trunk/test/IndependentBlocks/intra_and_inter_bb_scalar_dep.ll (original)
+++ polly/trunk/test/IndependentBlocks/intra_and_inter_bb_scalar_dep.ll Tue Jul 16 10:19:33 2013
@@ -1,5 +1,7 @@
; RUN: opt %loadPolly -basicaa -polly-independent -S < %s | FileCheck %s
; RUN: opt %loadPolly -basicaa -polly-independent -polly-codegen-scev -S < %s | FileCheck %s
+; RUN: opt %loadPolly -basicaa -polly-independent -disable-polly-intra-scop-scalar-to-array -S < %s | FileCheck %s -check-prefix=SCALARACCESS
+; RUN: opt %loadPolly -basicaa -polly-independent -disable-polly-intra-scop-scalar-to-array -polly-codegen-scev -S < %s | FileCheck %s -check-prefix=SCALARACCESS
; void f(long A[], int N, int *init_ptr) {
; long i, j;
@@ -22,6 +24,8 @@ entry:
; CHECK: entry
; CHECK: %init.s2a = alloca i64
; CHECK: br label %for.i
+
+; SCALARACCESS-NOT: alloca
br label %for.i
for.i:
@@ -31,6 +35,7 @@ for.i:
entry.next:
%init = load i64* %init_ptr
+; SCALARACCESS-NOT: store
br label %for.j
for.j:
@@ -44,6 +49,9 @@ for.j:
; The SCEV of %init_sum is (%init + %init_2). It is referring to both an
; UnknownValue in the same and in a different basic block. We want only the
; reference to the different basic block to be replaced.
+
+; SCALARACCESS: %init_2 = load i64* %init_ptr
+; SCALARACCESS: %init_sum = add i64 %init, %init_2
%scevgep = getelementptr i64* %A, i64 %indvar.j
store i64 %init_sum, i64* %scevgep
%indvar.j.next = add nsw i64 %indvar.j, 1
Modified: polly/trunk/test/IndependentBlocks/intra_bb_scalar_dep.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/IndependentBlocks/intra_bb_scalar_dep.ll?rev=186418&r1=186417&r2=186418&view=diff
==============================================================================
--- polly/trunk/test/IndependentBlocks/intra_bb_scalar_dep.ll (original)
+++ polly/trunk/test/IndependentBlocks/intra_bb_scalar_dep.ll Tue Jul 16 10:19:33 2013
@@ -1,5 +1,7 @@
; RUN: opt %loadPolly -basicaa -polly-independent -S < %s | FileCheck %s
; RUN: opt %loadPolly -basicaa -polly-independent -polly-codegen-scev -S < %s | FileCheck %s
+; RUN: opt %loadPolly -basicaa -polly-independent -disable-polly-intra-scop-scalar-to-array -S < %s | FileCheck %s
+; RUN: opt %loadPolly -basicaa -polly-independent -disable-polly-intra-scop-scalar-to-array -polly-codegen-scev -S < %s | FileCheck %s
; void f(long A[], int N, int *init_ptr) {
; long i, j;
Modified: polly/trunk/test/IndependentBlocks/scalar_to_array.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/IndependentBlocks/scalar_to_array.ll?rev=186418&r1=186417&r2=186418&view=diff
==============================================================================
--- polly/trunk/test/IndependentBlocks/scalar_to_array.ll (original)
+++ polly/trunk/test/IndependentBlocks/scalar_to_array.ll Tue Jul 16 10:19:33 2013
@@ -1,5 +1,7 @@
; RUN: opt %loadPolly -basicaa -polly-independent < %s -S | FileCheck %s
; RUN: opt %loadPolly -basicaa -polly-independent -polly-codegen-scev < %s -S | FileCheck %s
+; RUN: opt %loadPolly -basicaa -polly-independent -disable-polly-intra-scop-scalar-to-array -S < %s | FileCheck %s -check-prefix=SCALARACCESS
+; RUN: opt %loadPolly -basicaa -polly-independent -disable-polly-intra-scop-scalar-to-array -polly-codegen-scev < %s -S | FileCheck %s -check-prefix=SCALARACCESS
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-unknown-linux-gnu"
@@ -36,6 +38,8 @@ entry:
br label %for.cond
; CHECK: entry:
; CHECK-NOT: alloca
+; SCALARACCESS: entry:
+; SCALARACCESS-NOT: alloca
for.cond:
%indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]
@@ -51,6 +55,9 @@ for.body:
; CHECK: for.body:
; CHECK: %float = uitofp i64 %indvar to float
; CHECK: store float %float, float* %arrayidx
+; SCALARACCESS: for.body:
+; SCALARACCESS: %float = uitofp i64 %indvar to float
+; SCALARACCESS: store float %float, float* %arrayidx
for.inc:
%indvar.next = add i64 %indvar, 1
@@ -70,6 +77,9 @@ entry:
; CHECK: entry:
; CHECK: %scalar.s2a = alloca float
; CHECK: fence
+; SCALARACCESS: entry:
+; SCALARACCESS-NOT: alloca
+; SCALARACCESS: fence
for.cond:
%indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]
@@ -87,6 +97,12 @@ for.body.a:
; CHECK: store float %scalar, float* %scalar.s2a
; CHECK: br label %for.body.b
+; SCALARACCESS: for.body.a:
+; SCALARACCESS: %arrayidx = getelementptr [1024 x float]* @A, i64 0, i64 %indvar
+; SCALARACCESS: %scalar = load float* %arrayidx
+; SCALARACCESS-NOT: store
+; SCALARACCESS: br label %for.body.b
+
for.body.b:
%arrayidx2 = getelementptr [1024 x float]* @A, i64 0, i64 %indvar
%float = uitofp i64 %indvar to float
@@ -102,6 +118,14 @@ for.body.b:
; CHECK: store float %sum, float* %arrayidx2
; CHECK: br label %for.inc
+; SCALARACCESS: for.body.b:
+; SCALARACCESS: %arrayidx2 = getelementptr [1024 x float]* @A, i64 0, i64 %indvar
+; SCALARACCESS: %float = uitofp i64 %indvar to float
+; SCALARACCESS-NOT: load
+; SCALARACCESS: %sum = fadd float %scalar, %float
+; SCALARACCESS: store float %sum, float* %arrayidx2
+; SCALARACCESS: br label %for.inc
+
for.inc:
%indvar.next = add i64 %indvar, 1
br label %for.cond
@@ -114,6 +138,8 @@ return:
; It is not possible to have a scop which accesses a scalar element that is
; a global variable. All global variables are pointers containing possibly
; a single element. Hence they do not need to be handled anyways.
+; Please note that this is still required when scalar to array rewritting is
+; disabled.
; CHECK: @use_after_scop()
define i32 @use_after_scop() nounwind {
@@ -124,6 +150,10 @@ entry:
; CHECK: %scalar.s2a = alloca float
; CHECK: fence
+; SCALARACCESS: entry:
+; SCALARACCESS: %scalar.s2a = alloca float
+; SCALARACCESS: fence
+
for.head:
%indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]
br label %for.body
@@ -137,6 +167,10 @@ for.body:
; CHECK: %scalar = load float* %arrayidx
; CHECK: store float %scalar, float* %scalar.s2a
+; SCALARACCESS: for.body:
+; SCALARACCESS: %scalar = load float* %arrayidx
+; SCALARACCESS: store float %scalar, float* %scalar.s2a
+
for.inc:
%indvar.next = add i64 %indvar, 1
%exitcond = icmp ne i64 %indvar, 1024
@@ -152,6 +186,11 @@ for.after:
; CHECK: fence seq_cst
; CHECK: %return_value = fptosi float %scalar.loadoutside to i32
+; SCALARACCESS: for.after:
+; SCALARACCESS: %scalar.loadoutside = load float* %scalar.s2a
+; SCALARACCESS: fence seq_cst
+; SCALARACCESS: %return_value = fptosi float %scalar.loadoutside to i32
+
return:
ret i32 %return_value
}
@@ -187,6 +226,9 @@ for.body:
; CHECK: for.body:
; CHECK: store float %scalar, float* %arrayidx
+; SCALARACCESS: for.body:
+; SCALARACCESS: store float %scalar, float* %arrayidx
+
for.inc:
%indvar.next = add i64 %indvar, 1
br label %for.cond
More information about the llvm-commits
mailing list