1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch64 < %s | FileCheck %s
4 ;; Perform tail call optimization for duplicate returns.
9 define i32 @duplicate_returns(i32 %a, i32 %b) nounwind {
10 ; CHECK-LABEL: duplicate_returns:
11 ; CHECK: # %bb.0: # %entry
12 ; CHECK-NEXT: addi.w $a0, $a0, 0
13 ; CHECK-NEXT: beqz $a0, .LBB0_4
14 ; CHECK-NEXT: # %bb.1: # %if.else
15 ; CHECK-NEXT: addi.w $a1, $a1, 0
16 ; CHECK-NEXT: beqz $a1, .LBB0_5
17 ; CHECK-NEXT: # %bb.2: # %if.else2
18 ; CHECK-NEXT: bge $a1, $a0, .LBB0_6
19 ; CHECK-NEXT: # %bb.3: # %if.then3
20 ; CHECK-NEXT: b %plt(test2)
21 ; CHECK-NEXT: .LBB0_4: # %if.then
22 ; CHECK-NEXT: b %plt(test)
23 ; CHECK-NEXT: .LBB0_5: # %if.then2
24 ; CHECK-NEXT: b %plt(test1)
25 ; CHECK-NEXT: .LBB0_6: # %if.else3
26 ; CHECK-NEXT: b %plt(test3)
28 %cmp = icmp eq i32 %a, 0
29 br i1 %cmp, label %if.then, label %if.else
32 %call = tail call i32 @test()
36 %cmp1 = icmp eq i32 %b, 0
37 br i1 %cmp1, label %if.then2, label %if.else2
40 %call1 = tail call i32 @test1()
44 %cmp5 = icmp sgt i32 %a, %b
45 br i1 %cmp5, label %if.then3, label %if.else3
48 %call2 = tail call i32 @test2()
52 %call3 = tail call i32 @test3()
56 %retval = phi i32 [ %call, %if.then ], [ %call1, %if.then2 ], [ %call2, %if.then3 ], [ %call3, %if.else3 ]