diff options
| -rw-r--r-- | polly/lib/IndependentBlocks.cpp | 18 | ||||
| -rw-r--r-- | polly/test/Isl/CodeGen/region-simplify.ll | 41 | ||||
| -rw-r--r-- | polly/test/Isl/CodeGen/scevcodegen-1.ll | 34 |
3 files changed, 89 insertions, 4 deletions
diff --git a/polly/lib/IndependentBlocks.cpp b/polly/lib/IndependentBlocks.cpp index 23e5375bcf2..e5ee36babcd 100644 --- a/polly/lib/IndependentBlocks.cpp +++ b/polly/lib/IndependentBlocks.cpp @@ -123,7 +123,7 @@ struct IndependentBlocks : public FunctionPass { // 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::translateScalarToArray(const Region *R) { 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::translateScalarToArray(Instruction *Inst, 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); } diff --git a/polly/test/Isl/CodeGen/region-simplify.ll b/polly/test/Isl/CodeGen/region-simplify.ll new file mode 100644 index 00000000000..adc8aa78e49 --- /dev/null +++ b/polly/test/Isl/CodeGen/region-simplify.ll @@ -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" } diff --git a/polly/test/Isl/CodeGen/scevcodegen-1.ll b/polly/test/Isl/CodeGen/scevcodegen-1.ll new file mode 100644 index 00000000000..e87260da729 --- /dev/null +++ b/polly/test/Isl/CodeGen/scevcodegen-1.ll @@ -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 +} |

