mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-26 14:33:02 +02:00
a67cf70e74
Summary: Make isGuaranteedToExecute use the isGuaranteedToTransferExecutionToSuccessor helper, and make that helper a bit more accurate. There's a potential performance impact here from assuming that arbitrary calls might not return. This probably has little impact on loads and stores to a pointer because most things alias analysis can reason about are dereferenceable anyway. The other impacts, like less aggressive hoisting of sdiv by a variable and less aggressive hoisting around volatile memory operations, are unlikely to matter for real code. This also impacts SCEV, which uses the same helper. It's a minor improvement there because we can tell that, for example, memcpy always returns normally. Strictly speaking, it's also introducing a bug, but it's not any worse than everywhere else we assume readonly functions terminate. Fixes http://llvm.org/PR27857. Reviewers: hfinkel, reames, chandlerc, sanjoy Subscribers: broune, llvm-commits Differential Revision: http://reviews.llvm.org/D21167 llvm-svn: 272489
73 lines
1.8 KiB
LLVM
73 lines
1.8 KiB
LLVM
; RUN: opt -S -licm < %s | FileCheck %s
|
|
|
|
declare void @use_nothrow(i64 %a) nounwind
|
|
declare void @use(i64 %a)
|
|
|
|
define void @nothrow(i64 %x, i64 %y, i1* %cond) {
|
|
; CHECK-LABEL: nothrow
|
|
; CHECK-LABEL: entry
|
|
; CHECK: %div = udiv i64 %x, %y
|
|
; CHECK-LABEL: loop
|
|
; CHECK: call void @use_nothrow(i64 %div)
|
|
entry:
|
|
br label %loop
|
|
|
|
loop: ; preds = %entry, %for.inc
|
|
%div = udiv i64 %x, %y
|
|
br label %loop2
|
|
|
|
loop2:
|
|
call void @use_nothrow(i64 %div)
|
|
br label %loop
|
|
}
|
|
; Negative test
|
|
define void @throw_header(i64 %x, i64 %y, i1* %cond) {
|
|
; CHECK-LABEL: throw_header
|
|
; CHECK-LABEL: loop
|
|
; CHECK: %div = udiv i64 %x, %y
|
|
; CHECK: call void @use(i64 %div)
|
|
entry:
|
|
br label %loop
|
|
|
|
loop: ; preds = %entry, %for.inc
|
|
%div = udiv i64 %x, %y
|
|
call void @use(i64 %div)
|
|
br label %loop
|
|
}
|
|
|
|
; The header is known no throw, but the loop is not. We can
|
|
; still lift out of the header.
|
|
define void @nothrow_header(i64 %x, i64 %y, i1 %cond) {
|
|
; CHECK-LABEL: nothrow_header
|
|
; CHECK-LABEL: entry
|
|
; CHECK: %div = udiv i64 %x, %y
|
|
; CHECK-LABEL: loop
|
|
; CHECK: call void @use(i64 %div)
|
|
entry:
|
|
br label %loop
|
|
loop: ; preds = %entry, %for.inc
|
|
%div = udiv i64 %x, %y
|
|
br i1 %cond, label %loop-if, label %exit
|
|
loop-if:
|
|
call void @use(i64 %div)
|
|
br label %loop
|
|
exit:
|
|
ret void
|
|
}
|
|
; Negative test - can't move out of throwing block
|
|
define void @nothrow_header_neg(i64 %x, i64 %y, i1 %cond) {
|
|
; CHECK-LABEL: nothrow_header_neg
|
|
; CHECK-LABEL: entry
|
|
; CHECK-LABEL: loop
|
|
; CHECK: %div = udiv i64 %x, %y
|
|
; CHECK: call void @use(i64 %div)
|
|
entry:
|
|
br label %loop
|
|
loop: ; preds = %entry, %for.inc
|
|
br label %loop-if
|
|
loop-if:
|
|
%div = udiv i64 %x, %y
|
|
call void @use(i64 %div)
|
|
br label %loop
|
|
}
|