1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch32 -mattr=+d < %s | FileCheck %s
3 ; RUN: llc --mtriple=loongarch64 -mattr=+d < %s | FileCheck %s
5 declare i32 @llvm.loongarch.csrrd.w(i32 immarg) nounwind
6 declare i32 @llvm.loongarch.csrwr.w(i32, i32 immarg) nounwind
9 define dso_local void @foo(i32 noundef signext %flag) nounwind {
11 ; CHECK: # %bb.0: # %entry
12 ; CHECK-NEXT: beqz $a0, .LBB0_2
13 ; CHECK-NEXT: # %bb.1: # %if.then
14 ; CHECK-NEXT: csrrd $a0, 2
15 ; CHECK-NEXT: ori $a0, $a0, 1
16 ; CHECK-NEXT: csrwr $a0, 2
17 ; CHECK-NEXT: .LBB0_2: # %if.end
18 ; CHECK-NEXT: csrrd $a0, 2
19 ; CHECK-NEXT: andi $a0, $a0, 1
20 ; CHECK-NEXT: bnez $a0, .LBB0_4
21 ; CHECK-NEXT: # %bb.3: # %if.then2
22 ; CHECK-NEXT: b %plt(bug)
23 ; CHECK-NEXT: .LBB0_4: # %if.end3
26 %tobool.not = icmp eq i32 %flag, 0
27 br i1 %tobool.not, label %if.end, label %if.then
29 if.then: ; preds = %entry
30 %0 = tail call i32 @llvm.loongarch.csrrd.w(i32 2)
32 %1 = tail call i32 @llvm.loongarch.csrwr.w(i32 %or, i32 2)
35 if.end: ; preds = %if.then, %entry
36 %2 = tail call i32 @llvm.loongarch.csrrd.w(i32 2)
38 %tobool1.not = icmp eq i32 %and, 0
39 br i1 %tobool1.not, label %if.then2, label %if.end3
41 if.then2: ; preds = %if.end
45 if.end3: ; preds = %if.then2, %if.end