xref: /aosp_15_r20/external/llvm/test/Transforms/PlaceSafepoints/split-backedge.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker;; A very basic test to make sure that splitting the backedge keeps working
2*9880d681SAndroid Build Coastguard Worker;; RUN: opt < %s -place-safepoints -spp-split-backedge=1 -S | FileCheck %s
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Workerdefine void @test(i32, i1 %cond) gc "statepoint-example" {
5*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @test
6*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: loop.loop_crit_edge
7*9880d681SAndroid Build Coastguard Worker; CHECK: call void @do_safepoint
8*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: br label %loop
9*9880d681SAndroid Build Coastguard Workerentry:
10*9880d681SAndroid Build Coastguard Worker  br label %loop
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Workerloop:
13*9880d681SAndroid Build Coastguard Worker  br i1 %cond, label %loop, label %exit
14*9880d681SAndroid Build Coastguard Worker
15*9880d681SAndroid Build Coastguard Workerexit:
16*9880d681SAndroid Build Coastguard Worker  ret void
17*9880d681SAndroid Build Coastguard Worker}
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Worker; Test for the case where a single conditional branch jumps to two
20*9880d681SAndroid Build Coastguard Worker; different loop header blocks.  Since we're currently using LoopSimplfy
21*9880d681SAndroid Build Coastguard Worker; this doesn't hit the interesting case, but once we remove that, we need
22*9880d681SAndroid Build Coastguard Worker; to be sure this keeps working.
23*9880d681SAndroid Build Coastguard Workerdefine void @test2(i32, i1 %cond) gc "statepoint-example" {
24*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @test2
25*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: loop2.loop2_crit_edge:
26*9880d681SAndroid Build Coastguard Worker; CHECK: call void @do_safepoint
27*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: br label %loop2
28*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: loop2.loop_crit_edge:
29*9880d681SAndroid Build Coastguard Worker; CHECK: call void @do_safepoint
30*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: br label %loop
31*9880d681SAndroid Build Coastguard Workerentry:
32*9880d681SAndroid Build Coastguard Worker  br label %loop
33*9880d681SAndroid Build Coastguard Worker
34*9880d681SAndroid Build Coastguard Workerloop:
35*9880d681SAndroid Build Coastguard Worker  br label %loop2
36*9880d681SAndroid Build Coastguard Worker
37*9880d681SAndroid Build Coastguard Workerloop2:
38*9880d681SAndroid Build Coastguard Worker  br i1 %cond, label %loop, label %loop2
39*9880d681SAndroid Build Coastguard Worker}
40*9880d681SAndroid Build Coastguard Worker
41*9880d681SAndroid Build Coastguard Workerdeclare void @do_safepoint()
42*9880d681SAndroid Build Coastguard Workerdefine void @gc.safepoint_poll() {
43*9880d681SAndroid Build Coastguard Workerentry:
44*9880d681SAndroid Build Coastguard Worker  call void @do_safepoint()
45*9880d681SAndroid Build Coastguard Worker  ret void
46*9880d681SAndroid Build Coastguard Worker}