1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch64 -mattr=+d < %s | FileCheck %s
4 declare i32 @llvm.loongarch.iocsrrd.b(i32) nounwind
5 declare void @llvm.loongarch.iocsrwr.b(i32, i32) nounwind
6 declare i32 @llvm.loongarch.iocsrrd.h(i32) nounwind
7 declare void @llvm.loongarch.iocsrwr.h(i32, i32) nounwind
8 declare i32 @llvm.loongarch.iocsrrd.w(i32) nounwind
9 declare void @llvm.loongarch.iocsrwr.w(i32, i32) nounwind
10 declare i64 @llvm.loongarch.iocsrrd.d(i32) nounwind
11 declare void @llvm.loongarch.iocsrwr.d(i64, i32) nounwind
14 define dso_local void @test_b(i32 noundef signext %flag) nounwind {
15 ; CHECK-LABEL: test_b:
16 ; CHECK: # %bb.0: # %entry
17 ; CHECK-NEXT: beqz $a0, .LBB0_2
18 ; CHECK-NEXT: # %bb.1: # %if.then
19 ; CHECK-NEXT: ori $a0, $zero, 2
20 ; CHECK-NEXT: iocsrrd.b $a1, $a0
21 ; CHECK-NEXT: ori $a1, $a1, 1
22 ; CHECK-NEXT: iocsrwr.b $a1, $a0
23 ; CHECK-NEXT: .LBB0_2: # %if.end
24 ; CHECK-NEXT: ori $a0, $zero, 2
25 ; CHECK-NEXT: iocsrrd.b $a0, $a0
26 ; CHECK-NEXT: andi $a0, $a0, 1
27 ; CHECK-NEXT: bnez $a0, .LBB0_4
28 ; CHECK-NEXT: # %bb.3: # %if.then2
29 ; CHECK-NEXT: b %plt(bug)
30 ; CHECK-NEXT: .LBB0_4: # %if.end3
33 %tobool.not = icmp eq i32 %flag, 0
34 br i1 %tobool.not, label %if.end, label %if.then
36 if.then: ; preds = %entry
37 %0 = tail call i32 @llvm.loongarch.iocsrrd.b(i32 2)
39 tail call void @llvm.loongarch.iocsrwr.b(i32 %or, i32 2)
42 if.end: ; preds = %if.then, %entry
43 %1 = tail call i32 @llvm.loongarch.iocsrrd.b(i32 2)
45 %tobool1.not = icmp eq i32 %and, 0
46 br i1 %tobool1.not, label %if.then2, label %if.end3
48 if.then2: ; preds = %if.end
52 if.end3: ; preds = %if.then2, %if.end
56 define dso_local void @test_h(i32 noundef signext %flag) nounwind {
57 ; CHECK-LABEL: test_h:
58 ; CHECK: # %bb.0: # %entry
59 ; CHECK-NEXT: beqz $a0, .LBB1_2
60 ; CHECK-NEXT: # %bb.1: # %if.then
61 ; CHECK-NEXT: ori $a0, $zero, 2
62 ; CHECK-NEXT: iocsrrd.h $a1, $a0
63 ; CHECK-NEXT: ori $a1, $a1, 1
64 ; CHECK-NEXT: iocsrwr.h $a1, $a0
65 ; CHECK-NEXT: .LBB1_2: # %if.end
66 ; CHECK-NEXT: ori $a0, $zero, 2
67 ; CHECK-NEXT: iocsrrd.h $a0, $a0
68 ; CHECK-NEXT: andi $a0, $a0, 1
69 ; CHECK-NEXT: bnez $a0, .LBB1_4
70 ; CHECK-NEXT: # %bb.3: # %if.then2
71 ; CHECK-NEXT: b %plt(bug)
72 ; CHECK-NEXT: .LBB1_4: # %if.end3
75 %tobool.not = icmp eq i32 %flag, 0
76 br i1 %tobool.not, label %if.end, label %if.then
78 if.then: ; preds = %entry
79 %0 = tail call i32 @llvm.loongarch.iocsrrd.h(i32 2)
81 tail call void @llvm.loongarch.iocsrwr.h(i32 %or, i32 2)
84 if.end: ; preds = %if.then, %entry
85 %1 = tail call i32 @llvm.loongarch.iocsrrd.h(i32 2)
87 %tobool1.not = icmp eq i32 %and, 0
88 br i1 %tobool1.not, label %if.then2, label %if.end3
90 if.then2: ; preds = %if.end
94 if.end3: ; preds = %if.then2, %if.end
98 define dso_local void @test_w(i32 noundef signext %flag) nounwind {
99 ; CHECK-LABEL: test_w:
100 ; CHECK: # %bb.0: # %entry
101 ; CHECK-NEXT: beqz $a0, .LBB2_2
102 ; CHECK-NEXT: # %bb.1: # %if.then
103 ; CHECK-NEXT: ori $a0, $zero, 2
104 ; CHECK-NEXT: iocsrrd.w $a1, $a0
105 ; CHECK-NEXT: ori $a1, $a1, 1
106 ; CHECK-NEXT: iocsrwr.w $a1, $a0
107 ; CHECK-NEXT: .LBB2_2: # %if.end
108 ; CHECK-NEXT: ori $a0, $zero, 2
109 ; CHECK-NEXT: iocsrrd.w $a0, $a0
110 ; CHECK-NEXT: andi $a0, $a0, 1
111 ; CHECK-NEXT: bnez $a0, .LBB2_4
112 ; CHECK-NEXT: # %bb.3: # %if.then2
113 ; CHECK-NEXT: b %plt(bug)
114 ; CHECK-NEXT: .LBB2_4: # %if.end3
117 %tobool.not = icmp eq i32 %flag, 0
118 br i1 %tobool.not, label %if.end, label %if.then
120 if.then: ; preds = %entry
121 %0 = tail call i32 @llvm.loongarch.iocsrrd.w(i32 2)
123 tail call void @llvm.loongarch.iocsrwr.w(i32 %or, i32 2)
126 if.end: ; preds = %if.then, %entry
127 %1 = tail call i32 @llvm.loongarch.iocsrrd.w(i32 2)
129 %tobool1.not = icmp eq i32 %and, 0
130 br i1 %tobool1.not, label %if.then2, label %if.end3
132 if.then2: ; preds = %if.end
133 tail call void @bug()
136 if.end3: ; preds = %if.then2, %if.end
140 define dso_local void @test_d(i32 noundef signext %flag) nounwind {
141 ; CHECK-LABEL: test_d:
142 ; CHECK: # %bb.0: # %entry
143 ; CHECK-NEXT: beqz $a0, .LBB3_2
144 ; CHECK-NEXT: # %bb.1: # %if.then
145 ; CHECK-NEXT: ori $a0, $zero, 2
146 ; CHECK-NEXT: iocsrrd.d $a1, $a0
147 ; CHECK-NEXT: ori $a1, $a1, 1
148 ; CHECK-NEXT: iocsrwr.d $a1, $a0
149 ; CHECK-NEXT: .LBB3_2: # %if.end
150 ; CHECK-NEXT: ori $a0, $zero, 2
151 ; CHECK-NEXT: iocsrrd.d $a0, $a0
152 ; CHECK-NEXT: andi $a0, $a0, 1
153 ; CHECK-NEXT: bnez $a0, .LBB3_4
154 ; CHECK-NEXT: # %bb.3: # %if.then2
155 ; CHECK-NEXT: b %plt(bug)
156 ; CHECK-NEXT: .LBB3_4: # %if.end3
159 %tobool.not = icmp eq i32 %flag, 0
160 br i1 %tobool.not, label %if.end, label %if.then
162 if.then: ; preds = %entry
163 %0 = tail call i64 @llvm.loongarch.iocsrrd.d(i32 2)
165 tail call void @llvm.loongarch.iocsrwr.d(i64 %or, i32 2)
168 if.end: ; preds = %if.then, %entry
169 %1 = tail call i64 @llvm.loongarch.iocsrrd.d(i32 2)
171 %tobool1.not = icmp eq i64 %and, 0
172 br i1 %tobool1.not, label %if.then2, label %if.end3
174 if.then2: ; preds = %if.end
175 tail call void @bug()
178 if.end3: ; preds = %if.then2, %if.end