1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc --mtriple=loongarch64 -mattr=+d < %s | FileCheck %s 3 4;; This test checks that LLVM can do basic stripping and reapplying of branches 5;; to basic blocks. 6 7declare void @test_true() 8declare void @test_false() 9 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} 13 14define void @test_bcc_fallthrough_taken(i64 %in) nounwind { 15; CHECK-LABEL: test_bcc_fallthrough_taken: 16; CHECK: # %bb.0: 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 26; CHECK-NEXT: ret 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 32 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. 36 37true: 38 call void @test_true() 39 ret void 40 41false: 42 call void @test_false() 43 ret void 44} 45 46define void @test_bcc_fallthrough_nottaken(i64 %in) nounwind { 47; CHECK-LABEL: test_bcc_fallthrough_nottaken: 48; CHECK: # %bb.0: 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 58; CHECK-NEXT: ret 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 64 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. 68 69true: 70 call void @test_true() 71 ret void 72 73false: 74 call void @test_false() 75 ret void 76} 77