[polly] r271892 - [FIX] Determine insertion point during SCEV expansion
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 6 06:05:22 PDT 2016
Author: jdoerfert
Date: Mon Jun 6 08:05:21 2016
New Revision: 271892
URL: http://llvm.org/viewvc/llvm-project?rev=271892&view=rev
Log:
[FIX] Determine insertion point during SCEV expansion
Added:
polly/trunk/test/Isl/CodeGen/scop_expander_insert_point.ll
Modified:
polly/trunk/lib/Support/ScopHelper.cpp
Modified: polly/trunk/lib/Support/ScopHelper.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Support/ScopHelper.cpp?rev=271892&r1=271891&r2=271892&view=diff
==============================================================================
--- polly/trunk/lib/Support/ScopHelper.cpp (original)
+++ polly/trunk/lib/Support/ScopHelper.cpp Mon Jun 6 08:05:21 2016
@@ -280,11 +280,19 @@ private:
return visit(NewE);
}
- Instruction *StartIP = R.getEnteringBlock()->getTerminator();
+ auto *EnteringBB = R.getEnteringBlock();
Instruction *Inst = dyn_cast<Instruction>(E->getValue());
+ Instruction *IP;
+ if (Inst && !R.contains(Inst))
+ IP = Inst;
+ else if (Inst && EnteringBB->getParent() == Inst->getFunction())
+ IP = EnteringBB->getTerminator();
+ else
+ IP = EnteringBB->getParent()->getEntryBlock().getTerminator();
+
if (!Inst || (Inst->getOpcode() != Instruction::SRem &&
Inst->getOpcode() != Instruction::SDiv))
- return visitGenericInst(E, Inst, StartIP);
+ return visitGenericInst(E, Inst, IP);
const SCEV *LHSScev = SE.getSCEV(Inst->getOperand(0));
const SCEV *RHSScev = SE.getSCEV(Inst->getOperand(1));
@@ -292,11 +300,11 @@ private:
if (!SE.isKnownNonZero(RHSScev))
RHSScev = SE.getUMaxExpr(RHSScev, SE.getConstant(E->getType(), 1));
- Value *LHS = expandCodeFor(LHSScev, E->getType(), StartIP);
- Value *RHS = expandCodeFor(RHSScev, E->getType(), StartIP);
+ Value *LHS = expandCodeFor(LHSScev, E->getType(), IP);
+ Value *RHS = expandCodeFor(RHSScev, E->getType(), IP);
Inst = BinaryOperator::Create((Instruction::BinaryOps)Inst->getOpcode(),
- LHS, RHS, Inst->getName() + Name, StartIP);
+ LHS, RHS, Inst->getName() + Name, IP);
return SE.getSCEV(Inst);
}
Added: polly/trunk/test/Isl/CodeGen/scop_expander_insert_point.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/scop_expander_insert_point.ll?rev=271892&view=auto
==============================================================================
--- polly/trunk/test/Isl/CodeGen/scop_expander_insert_point.ll (added)
+++ polly/trunk/test/Isl/CodeGen/scop_expander_insert_point.ll Mon Jun 6 08:05:21 2016
@@ -0,0 +1,43 @@
+; RUN: opt %loadPolly -polly-codegen -S < %s | FileCheck %s
+;
+; CHECK: entry:
+; CHECK-NEXT: %outvalue.141.phiops = alloca i64
+; CHECK-NEXT: %.preload.s2a = alloca i8
+; CHECK-NEXT: %divpolly = sdiv i32 undef, 1
+; CHECK-NEXT: %div = sdiv i32 undef, undef
+;
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+; Function Attrs: nounwind uwtable
+define void @int_downsample() #0 {
+entry:
+ %div = sdiv i32 undef, undef
+ br label %for.cond10.preheader.lr.ph
+
+for.cond10.preheader.lr.ph: ; preds = %entry
+ br label %for.body17.lr.ph
+
+for.body17.lr.ph: ; preds = %for.end22, %for.cond10.preheader.lr.ph
+ %outcol_h.048 = phi i32 [ 0, %for.cond10.preheader.lr.ph ], [ %add31, %for.end22 ]
+ %0 = load i8*, i8** undef
+ %idx.ext = zext i32 %outcol_h.048 to i64
+ %add.ptr = getelementptr inbounds i8, i8* %0, i64 %idx.ext
+ br label %for.body17
+
+for.body17: ; preds = %for.body17, %for.body17.lr.ph
+ %outvalue.141 = phi i64 [ undef, %for.body17.lr.ph ], [ %add19, %for.body17 ]
+ %inptr.040 = phi i8* [ %add.ptr, %for.body17.lr.ph ], [ undef, %for.body17 ]
+ %1 = load i8, i8* %inptr.040
+ %add19 = add nsw i64 0, %outvalue.141
+ br i1 false, label %for.body17, label %for.end22
+
+for.end22: ; preds = %for.body17
+ %add31 = add i32 %outcol_h.048, %div
+ br i1 undef, label %for.body17.lr.ph, label %for.end32
+
+for.end32: ; preds = %for.end22
+ br label %for.end36
+
+for.end36: ; preds = %for.end32
+ ret void
+}
More information about the llvm-commits
mailing list