[polly] r179019 - IndependentBlocks: translate out of SSA all uses escaping the region
Sebastian Pop
spop at codeaurora.org
Mon Apr 8 06:05:41 PDT 2013
Author: spop
Date: Mon Apr 8 08:05:41 2013
New Revision: 179019
URL: http://llvm.org/viewvc/llvm-project?rev=179019&view=rev
Log:
IndependentBlocks: translate out of SSA all uses escaping the region
Added:
polly/trunk/test/Isl/CodeGen/region-simplify.ll
polly/trunk/test/Isl/CodeGen/scevcodegen-1.ll
Modified:
polly/trunk/lib/IndependentBlocks.cpp
Modified: polly/trunk/lib/IndependentBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/IndependentBlocks.cpp?rev=179019&r1=179018&r2=179019&view=diff
==============================================================================
--- polly/trunk/lib/IndependentBlocks.cpp (original)
+++ polly/trunk/lib/IndependentBlocks.cpp Mon Apr 8 08:05:41 2013
@@ -123,7 +123,7 @@ struct IndependentBlocks : public Functi
// Split the exit block to hold load instructions.
bool splitExitBlock(Region *R);
-
+ bool onlyUsedInRegion(Instruction *Inst, const Region *R);
bool translateScalarToArray(BasicBlock *BB, const Region *R);
bool translateScalarToArray(Instruction *Inst, const Region *R);
bool translateScalarToArray(const Region *R);
@@ -352,9 +352,20 @@ bool IndependentBlocks::translateScalarT
return Changed;
}
+// Returns true when Inst is only used inside region R.
+bool IndependentBlocks::onlyUsedInRegion(Instruction *Inst, const Region *R) {
+ for (Instruction::use_iterator UI = Inst->use_begin(), UE = Inst->use_end();
+ UI != UE; ++UI)
+ if (Instruction *U = dyn_cast<Instruction>(*UI))
+ if (isEscapeUse(U, R))
+ return false;
+
+ return true;
+}
+
bool IndependentBlocks::translateScalarToArray(Instruction *Inst,
const Region *R) {
- if (canSynthesize(Inst, LI, SE, R))
+ if (canSynthesize(Inst, LI, SE, R) && onlyUsedInRegion(Inst, R))
return false;
SmallVector<Instruction *, 4> LoadInside, LoadOutside;
@@ -362,14 +373,13 @@ bool IndependentBlocks::translateScalarT
UI != UE; ++UI)
// Inst is referenced outside or referenced as an escaped operand.
if (Instruction *U = dyn_cast<Instruction>(*UI)) {
- BasicBlock *UParent = U->getParent();
-
if (isEscapeUse(U, R))
LoadOutside.push_back(U);
if (canSynthesize(U, LI, SE, R))
continue;
+ BasicBlock *UParent = U->getParent();
if (R->contains(UParent) && isEscapeOperand(Inst, UParent, R))
LoadInside.push_back(U);
}
Added: polly/trunk/test/Isl/CodeGen/region-simplify.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/region-simplify.ll?rev=179019&view=auto
==============================================================================
--- polly/trunk/test/Isl/CodeGen/region-simplify.ll (added)
+++ polly/trunk/test/Isl/CodeGen/region-simplify.ll Mon Apr 8 08:05:41 2013
@@ -0,0 +1,41 @@
+; RUN: opt %loadPolly -polly-region-simplify -polly-codegen-isl -polly-codegen-scev < %s
+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-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @kernel_cholesky(double* %p, [128 x double]* %A) #0 {
+entry:
+ br i1 undef, label %for.body, label %for.end57
+
+for.body: ; preds = %for.inc55, %entry
+ %i.070 = phi i32 [ %inc56, %for.inc55 ], [ 0, %entry ]
+ br i1 undef, label %for.body22, label %for.inc55
+
+for.body22: ; preds = %for.end44, %for.body
+ %sub28 = add nsw i32 %i.070, -1
+ %cmp2961 = icmp slt i32 %sub28, 0
+ %idxprom45 = sext i32 %i.070 to i64
+ br i1 %cmp2961, label %for.end44, label %for.inc42
+
+for.inc42: ; preds = %for.inc42, %for.body22
+ %k.062 = phi i32 [ %inc43, %for.inc42 ], [ 0, %for.body22 ]
+ %inc43 = add nsw i32 %k.062, 1
+ %cmp29 = icmp sgt i32 %inc43, %sub28
+ br i1 %cmp29, label %for.end44, label %for.inc42
+
+for.end44: ; preds = %for.inc42, %for.body22
+ %arrayidx46 = getelementptr inbounds double* %p, i64 %idxprom45
+ %0 = load double* %arrayidx46, align 8
+ %mul47 = fmul double undef, %0
+ %arrayidx51 = getelementptr inbounds [128 x double]* %A, i64 undef, i64 undef
+ store double %mul47, double* %arrayidx51, align 8
+ br i1 undef, label %for.body22, label %for.inc55
+
+for.inc55: ; preds = %for.end44, %for.body
+ %inc56 = add nsw i32 %i.070, 1
+ br i1 undef, label %for.body, label %for.end57
+
+for.end57: ; preds = %for.inc55, %entry
+ ret void
+}
+
+attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
Added: polly/trunk/test/Isl/CodeGen/scevcodegen-1.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/scevcodegen-1.ll?rev=179019&view=auto
==============================================================================
--- polly/trunk/test/Isl/CodeGen/scevcodegen-1.ll (added)
+++ polly/trunk/test/Isl/CodeGen/scevcodegen-1.ll Mon Apr 8 08:05:41 2013
@@ -0,0 +1,34 @@
+; RUN: opt %loadPolly -polly-region-simplify -polly-codegen-isl -polly-codegen-scev %s
+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"
+
+define void @main() nounwind {
+.split:
+ br label %.start
+
+.start:
+ %indvar15 = phi i64 [ 0, %.split ], [ %indvar.next16, %.loopexit ]
+ br i1 true, label %.preheader, label %.loop2
+
+.preheader:
+ %tmp25 = add i64 %indvar15, 1
+ br label %.loop1
+
+.loop1:
+ %indvar33 = phi i64 [ %indvar.next34, %.loop1 ], [ 0, %.preheader ]
+ %indvar.next34 = add i64 %indvar33, 1
+ %exitcond40 = icmp eq i64 %indvar.next34, 0
+ br i1 %exitcond40, label %.loop2, label %.loop1
+
+.loop2:
+ %exitcond26.old = icmp eq i64 undef, %tmp25
+ br i1 false, label %.loopexit, label %.loop2
+
+.loopexit:
+ %indvar.next16 = add i64 %indvar15, 1
+ %exitcond53 = icmp eq i64 %indvar.next16, 2048
+ br i1 %exitcond53, label %.start, label %.end
+
+.end:
+ ret void
+}
More information about the llvm-commits
mailing list