mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-25 12:50:00 +00:00
An instruction in a loop is not guaranteed to be executed just because the loop
has no exit blocks. Fixes PR12706! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155884 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
973f72a29a
commit
4056a73638
@ -618,6 +618,11 @@ bool LICM::isGuaranteedToExecute(Instruction &Inst) {
|
|||||||
if (!DT->dominates(Inst.getParent(), ExitBlocks[i]))
|
if (!DT->dominates(Inst.getParent(), ExitBlocks[i]))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// As a degenerate case, if the loop is statically infinite then we haven't
|
||||||
|
// proven anything since there are no exit blocks.
|
||||||
|
if (ExitBlocks.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,3 +165,25 @@ for.inc: ; preds = %if.then, %for.body
|
|||||||
for.end: ; preds = %for.inc, %entry
|
for.end: ; preds = %for.inc, %entry
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; SDiv is unsafe to speculate inside an infinite loop.
|
||||||
|
|
||||||
|
define void @unsafe_sdiv_c(i64 %a, i64 %b, i64* %p) {
|
||||||
|
entry:
|
||||||
|
; CHECK: entry:
|
||||||
|
; CHECK-NOT: sdiv
|
||||||
|
; CHECK: br label %for.body
|
||||||
|
br label %for.body
|
||||||
|
|
||||||
|
for.body:
|
||||||
|
%c = icmp eq i64 %b, 0
|
||||||
|
br i1 %c, label %backedge, label %if.then
|
||||||
|
|
||||||
|
if.then:
|
||||||
|
%d = sdiv i64 %a, %b
|
||||||
|
store i64 %d, i64* %p
|
||||||
|
br label %backedge
|
||||||
|
|
||||||
|
backedge:
|
||||||
|
br label %for.body
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user