mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
[LICM] Hoist assumes out of loops
If we have an assume which is known to execute and whose operand is invariant, we can lift that into the pre-header. So long as we don't change which paths the assume executes on, this is a legal transformation. It's likely to be a useful canonicalization as other transforms only look for dominating assumes. Differential Revision: https://reviews.llvm.org/D50364 llvm-svn: 339481
This commit is contained in:
parent
2498063d31
commit
12e7461f52
@ -658,6 +658,15 @@ bool llvm::canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT,
|
|||||||
if (CI->mayThrow())
|
if (CI->mayThrow())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (Function *F = CI->getCalledFunction())
|
||||||
|
switch (F->getIntrinsicID()) {
|
||||||
|
default: break;
|
||||||
|
// TODO: support invariant.start, and experimental.guard here
|
||||||
|
case Intrinsic::assume:
|
||||||
|
// Assumes don't actually alias anything or throw
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
// Handle simple cases by querying alias analysis.
|
// Handle simple cases by querying alias analysis.
|
||||||
FunctionModRefBehavior Behavior = AA->getModRefBehavior(CI);
|
FunctionModRefBehavior Behavior = AA->getModRefBehavior(CI);
|
||||||
if (Behavior == FMRB_DoesNotAccessMemory)
|
if (Behavior == FMRB_DoesNotAccessMemory)
|
||||||
|
@ -36,9 +36,9 @@ for.end104:
|
|||||||
define void @f_1(i1 %cond, i32* %ptr) {
|
define void @f_1(i1 %cond, i32* %ptr) {
|
||||||
; CHECK-LABEL: @f_1(
|
; CHECK-LABEL: @f_1(
|
||||||
; CHECK-LABEL: entry:
|
; CHECK-LABEL: entry:
|
||||||
|
; CHECK: call void @llvm.assume(i1 %cond)
|
||||||
; CHECK: %val = load i32, i32* %ptr
|
; CHECK: %val = load i32, i32* %ptr
|
||||||
; CHECK-LABEL: loop:
|
; CHECK-LABEL: loop:
|
||||||
; CHECK: call void @llvm.assume(i1 %cond)
|
|
||||||
|
|
||||||
entry:
|
entry:
|
||||||
br label %loop
|
br label %loop
|
||||||
|
Loading…
Reference in New Issue
Block a user