1 ; Tests to ensure that we are not placing backedge safepoints in
2 ; loops which are clearly finite.
3 ;; RUN: opt %s -place-safepoints -S | FileCheck %s
6 ; A simple counted loop with trivially known range
7 define void @test1(i32) gc "statepoint-example" {
12 ; CHECK-NOT: statepoint
18 %counter = phi i32 [ 0 , %entry ], [ %counter.inc , %loop ]
19 %counter.inc = add i32 %counter, 1
20 %counter.cmp = icmp slt i32 %counter.inc, 16
21 br i1 %counter.cmp, label %loop, label %exit
27 ; The same counted loop, but with an unknown early exit
28 define void @test2(i32) gc "statepoint-example" {
33 ; CHECK-NOT: statepoint
39 %counter = phi i32 [ 0 , %entry ], [ %counter.inc , %continue ]
40 %counter.inc = add i32 %counter, 1
41 %counter.cmp = icmp slt i32 %counter.inc, 16
42 br i1 undef, label %continue, label %exit
45 br i1 %counter.cmp, label %loop, label %exit
51 ; The range is a 8 bit value and we can't overflow
52 define void @test3(i8 %upper) gc "statepoint-example" {
57 ; CHECK-NOT: statepoint
63 %counter = phi i8 [ 0 , %entry ], [ %counter.inc , %loop ]
64 %counter.inc = add nsw i8 %counter, 1
65 %counter.cmp = icmp slt i8 %counter.inc, %upper
66 br i1 %counter.cmp, label %loop, label %exit
73 ; This function is inlined when inserting a poll.
74 declare void @do_safepoint()
75 define void @gc.safepoint_poll() {
76 ; CHECK-LABEL: gc.safepoint_poll
78 call void @do_safepoint()