mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
LICM: Hoist insertvalue/extractvalue out of loops.
Fixes PR14854. llvm-svn: 171984
This commit is contained in:
parent
260d0adb19
commit
953e24a567
@ -440,13 +440,12 @@ bool LICM::canSinkOrHoistInst(Instruction &I) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only these instructions are hoistable/sinkable.
|
// Only these instructions are hoistable/sinkable.
|
||||||
bool HoistableKind = (isa<BinaryOperator>(I) || isa<CastInst>(I) ||
|
if (!isa<BinaryOperator>(I) && !isa<CastInst>(I) && !isa<SelectInst>(I) &&
|
||||||
isa<SelectInst>(I) || isa<GetElementPtrInst>(I) ||
|
!isa<GetElementPtrInst>(I) && !isa<CmpInst>(I) &&
|
||||||
isa<CmpInst>(I) || isa<InsertElementInst>(I) ||
|
!isa<InsertElementInst>(I) && !isa<ExtractElementInst>(I) &&
|
||||||
isa<ExtractElementInst>(I) ||
|
!isa<ShuffleVectorInst>(I) && !isa<ExtractValueInst>(I) &&
|
||||||
isa<ShuffleVectorInst>(I));
|
!isa<InsertValueInst>(I))
|
||||||
if (!HoistableKind)
|
return false;
|
||||||
return false;
|
|
||||||
|
|
||||||
return isSafeToExecuteUnconditionally(I);
|
return isSafeToExecuteUnconditionally(I);
|
||||||
}
|
}
|
||||||
|
@ -90,3 +90,29 @@ for.end: ; preds = %for.body
|
|||||||
|
|
||||||
declare void @foo_may_call_exit(i32)
|
declare void @foo_may_call_exit(i32)
|
||||||
|
|
||||||
|
; PR14854
|
||||||
|
; CHECK: @test5
|
||||||
|
; CHECK: extractvalue
|
||||||
|
; CHECK: br label %tailrecurse
|
||||||
|
; CHECK: tailrecurse:
|
||||||
|
; CHECK: ifend:
|
||||||
|
; CHECK: insertvalue
|
||||||
|
define { i32*, i32 } @test5(i32 %i, { i32*, i32 } %e) {
|
||||||
|
entry:
|
||||||
|
br label %tailrecurse
|
||||||
|
|
||||||
|
tailrecurse: ; preds = %then, %entry
|
||||||
|
%i.tr = phi i32 [ %i, %entry ], [ %cmp2, %then ]
|
||||||
|
%out = extractvalue { i32*, i32 } %e, 1
|
||||||
|
%d = insertvalue { i32*, i32 } %e, i32* null, 0
|
||||||
|
%cmp1 = icmp sgt i32 %out, %i.tr
|
||||||
|
br i1 %cmp1, label %then, label %ifend
|
||||||
|
|
||||||
|
then: ; preds = %tailrecurse
|
||||||
|
call void @foo()
|
||||||
|
%cmp2 = add i32 %i.tr, 1
|
||||||
|
br label %tailrecurse
|
||||||
|
|
||||||
|
ifend: ; preds = %tailrecurse
|
||||||
|
ret { i32*, i32 } %d
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user