mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-27 02:09:54 +00:00
[FIX] Determine insertion point during SCEV expansion
llvm-svn: 271892
This commit is contained in:
parent
edafb0595e
commit
4db8d80730
@ -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);
|
||||
}
|
||||
|
||||
|
43
polly/test/Isl/CodeGen/scop_expander_insert_point.ll
Normal file
43
polly/test/Isl/CodeGen/scop_expander_insert_point.ll
Normal file
@ -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
|
||||
}
|
Loading…
Reference in New Issue
Block a user