1 ; RUN: opt -S -licm < %s | FileCheck %s
2 ; RUN: opt -aa-pipeline=basic-aa -passes='require<aa>,require<targetir>,require<scalar-evolution>,require<opt-remark-emit>,loop(licm)' -S %s | FileCheck %s
4 declare void @use_nothrow(i64 %a) nounwind
5 declare void @use(i64 %a)
7 define void @nothrow(i64 %x, i64 %y, i1* %cond) {
10 ; CHECK: %div = udiv i64 %x, %y
12 ; CHECK: call void @use_nothrow(i64 %div)
16 loop: ; preds = %entry, %for.inc
17 %div = udiv i64 %x, %y
21 call void @use_nothrow(i64 %div)
25 define void @throw_header(i64 %x, i64 %y, i1* %cond) {
26 ; CHECK-LABEL: throw_header
28 ; CHECK: %div = udiv i64 %x, %y
29 ; CHECK: call void @use(i64 %div)
33 loop: ; preds = %entry, %for.inc
34 %div = udiv i64 %x, %y
35 call void @use(i64 %div)
39 ; The header is known no throw, but the loop is not. We can
40 ; still lift out of the header.
41 define void @nothrow_header(i64 %x, i64 %y, i1 %cond) {
42 ; CHECK-LABEL: nothrow_header
44 ; CHECK: %div = udiv i64 %x, %y
46 ; CHECK: call void @use(i64 %div)
49 loop: ; preds = %entry, %for.inc
50 %div = udiv i64 %x, %y
51 br i1 %cond, label %loop-if, label %exit
53 call void @use(i64 %div)
58 ; Negative test - can't move out of throwing block
59 define void @nothrow_header_neg(i64 %x, i64 %y, i1 %cond) {
60 ; CHECK-LABEL: nothrow_header_neg
63 ; CHECK: %div = udiv i64 %x, %y
64 ; CHECK: call void @use(i64 %div)
67 loop: ; preds = %entry, %for.inc
70 %div = udiv i64 %x, %y
71 call void @use(i64 %div)