1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch64 -mattr=+d < %s | FileCheck %s
4 ;; This test checks that LLVM can do basic stripping and reapplying of branches
7 declare void @test_true()
8 declare void @test_false()
10 ;; !0 corresponds to a branch being taken, !1 to not being taken.
11 !0 = !{!"branch_weights", i32 64, i32 4}
12 !1 = !{!"branch_weights", i32 4, i32 64}
14 define void @test_bcc_fallthrough_taken(i64 %in) nounwind {
15 ; CHECK-LABEL: test_bcc_fallthrough_taken:
17 ; CHECK-NEXT: addi.d $sp, $sp, -16
18 ; CHECK-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
19 ; CHECK-NEXT: ori $a1, $zero, 42
20 ; CHECK-NEXT: bne $a0, $a1, .LBB0_3
21 ; CHECK-NEXT: # %bb.1: # %true
22 ; CHECK-NEXT: bl %plt(test_true)
23 ; CHECK-NEXT: .LBB0_2: # %true
24 ; CHECK-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
25 ; CHECK-NEXT: addi.d $sp, $sp, 16
27 ; CHECK-NEXT: .LBB0_3: # %false
28 ; CHECK-NEXT: bl %plt(test_false)
29 ; CHECK-NEXT: b .LBB0_2
30 %tst = icmp eq i64 %in, 42
31 br i1 %tst, label %true, label %false, !prof !0
33 ;; Expected layout order is: Entry, TrueBlock, FalseBlock
34 ;; Entry->TrueBlock is the common path, which should be taken whenever the
35 ;; conditional branch is false.
38 call void @test_true()
42 call void @test_false()
46 define void @test_bcc_fallthrough_nottaken(i64 %in) nounwind {
47 ; CHECK-LABEL: test_bcc_fallthrough_nottaken:
49 ; CHECK-NEXT: addi.d $sp, $sp, -16
50 ; CHECK-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
51 ; CHECK-NEXT: ori $a1, $zero, 42
52 ; CHECK-NEXT: beq $a0, $a1, .LBB1_3
53 ; CHECK-NEXT: # %bb.1: # %false
54 ; CHECK-NEXT: bl %plt(test_false)
55 ; CHECK-NEXT: .LBB1_2: # %true
56 ; CHECK-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
57 ; CHECK-NEXT: addi.d $sp, $sp, 16
59 ; CHECK-NEXT: .LBB1_3: # %true
60 ; CHECK-NEXT: bl %plt(test_true)
61 ; CHECK-NEXT: b .LBB1_2
62 %tst = icmp eq i64 %in, 42
63 br i1 %tst, label %true, label %false, !prof !1
65 ;; Expected layout order is: Entry, FalseBlock, TrueBlock
66 ;; Entry->FalseBlock is the common path, which should be taken whenever the
67 ;; conditional branch is false.
70 call void @test_true()
74 call void @test_false()