OLD | NEW |
---|---|
(Empty) | |
1 ; Tests for conditional branch instructions | |
2 | |
3 ; RUN: %if --need=allow_dump --need=target_MIPS32 --command %p2i \ | |
4 ; RUN: --filetype=asm --target mips32 -i %s --args -O2 --skip-unimplemented \ | |
5 ; RUN: -allow-externally-defined-symbols \ | |
6 ; RUN: | %if --need=allow_dump --need=target_MIPS32 --command FileCheck %s \ | |
7 ; RUN: --check-prefix=MIPS32 | |
8 | |
9 ; RUN: %if --need=allow_dump --need=target_MIPS32 --command %p2i \ | |
10 ; RUN: --filetype=asm --target mips32 -i %s --args -Om1 --skip-unimplemented \ | |
11 ; RUN: -allow-externally-defined-symbols \ | |
12 ; RUN: | %if --need=allow_dump --need=target_MIPS32 --command FileCheck %s \ | |
13 ; RUN: --check-prefix=MIPS32-OM1 | |
14 | |
15 define internal i32 @cond_br_eq(i32 %arg1, i32 %arg2) { | |
16 entry: | |
17 %cmp1 = icmp eq i32 %arg1, %arg2 | |
18 br i1 %cmp1, label %branch1, label %branch2 | |
19 branch1: | |
20 ret i32 1 | |
21 branch2: | |
22 ret i32 2 | |
23 } | |
24 ; MIPS32-LABEL: cond_br_eq | |
25 ; MIPS32: bne $a0, $a1, .Lcond_br_eq$branch2 | |
26 ; MIPS32-OM1: xor $v0, $v0, $v1 | |
Jim Stichnoth
2016/05/23 19:53:06
You'll want to do something like:
; MIPS32-OM1-LA
sagar.thakur
2016/05/24 05:44:36
Done.
| |
27 ; MIPS32-OM1: sltiu $v0, $v0, 1 | |
28 ; MIPS32-OM1: beqz $v0, .Lcond_br_eq$branch2 | |
29 | |
30 define internal i32 @cond_br_ne(i32 %arg1, i32 %arg2) { | |
31 entry: | |
32 %cmp1 = icmp ne i32 %arg1, %arg2 | |
33 br i1 %cmp1, label %branch1, label %branch2 | |
34 branch1: | |
35 ret i32 1 | |
36 branch2: | |
37 ret i32 2 | |
38 } | |
39 ; MIPS32-LABEL: cond_br_ne | |
40 ; MIPS32: beq $a0, $a1, .Lcond_br_ne$branch2 | |
41 ; MIPS32-OM1: xor $v0, $v0, $v1 | |
Jim Stichnoth
2016/05/23 19:53:05
Looking ahead, you may not want to hard-code regis
sagar.thakur
2016/05/24 05:44:36
Done.
| |
42 ; MIPS32-OM1: sltu $v0, $zero, $v0 | |
43 ; MIPS32-OM1: beqz $v0, .Lcond_br_ne$branch2 | |
44 | |
45 define internal i32 @cond_br_slt(i32 %arg1, i32 %arg2) { | |
46 entry: | |
47 %cmp1 = icmp slt i32 %arg1, %arg2 | |
48 br i1 %cmp1, label %branch1, label %branch2 | |
49 branch1: | |
50 ret i32 1 | |
51 branch2: | |
52 ret i32 2 | |
53 } | |
54 ; MIPS32-LABEL: cond_br_slt | |
55 ; MIPS32: slt $a0, $a0, $a1 | |
56 ; MIPS32: beqz $a0, .Lcond_br_slt$branch2 | |
57 ; MIPS32-OM1: slt $v0, $v0, $v1 | |
58 ; MIPS32-OM1: beqz $v0, .Lcond_br_slt$branch2 | |
59 | |
60 define internal i32 @cond_br_sle(i32 %arg1, i32 %arg2) { | |
61 entry: | |
62 %cmp1 = icmp sle i32 %arg1, %arg2 | |
63 br i1 %cmp1, label %branch1, label %branch2 | |
64 branch1: | |
65 ret i32 1 | |
66 branch2: | |
67 ret i32 2 | |
68 } | |
69 ; MIPS32-LABEL: cond_br_sle | |
70 ; MIPS32: slt $a1, $a1, $a0 | |
71 ; MIPS32: bnez $a1, .Lcond_br_sle$branch2 | |
72 ; MIPS32-OM1: slt $v0, $v1, $v0 | |
73 ; MIPS32-OM1: xori $v0, $v0, 1 | |
74 ; MIPS32-OM1: beqz $v0, .Lcond_br_sle$branch2 | |
75 | |
76 define internal i32 @cond_br_sgt(i32 %arg1, i32 %arg2) { | |
77 entry: | |
78 %cmp1 = icmp sgt i32 %arg1, %arg2 | |
79 br i1 %cmp1, label %branch1, label %branch2 | |
80 branch1: | |
81 ret i32 1 | |
82 branch2: | |
83 ret i32 2 | |
84 } | |
85 ; MIPS32-LABEL: cond_br_sgt | |
86 ; MIPS32: slt $a1, $a1, $a0 | |
87 ; MIPS32: beqz $a1, .Lcond_br_sgt$branch2 | |
88 ; MIPS32-OM1: slt $v0, $v1, $v0 | |
89 ; MIPS32-OM1: beqz $v0, .Lcond_br_sgt$branch2 | |
90 | |
91 define internal i32 @cond_br_sge(i32 %arg1, i32 %arg2) { | |
92 entry: | |
93 %cmp1 = icmp sge i32 %arg1, %arg2 | |
94 br i1 %cmp1, label %branch1, label %branch2 | |
95 branch1: | |
96 ret i32 1 | |
97 branch2: | |
98 ret i32 2 | |
99 } | |
100 ; MIPS32-LABEL: cond_br_sge | |
101 ; MIPS32: slt $a0, $a0, $a1 | |
102 ; MIPS32: bnez $a0, .Lcond_br_sge$branch2 | |
103 ; MIPS32-OM1: slt $v0, $v0, $v1 | |
104 ; MIPS32-OM1: xori $v0, $v0, 1 | |
105 ; MIPS32-OM1: beqz $v0, .Lcond_br_sge$branch2 | |
106 | |
107 define internal i32 @cond_br_ugt(i32 %arg1, i32 %arg2) { | |
108 entry: | |
109 %cmp1 = icmp ugt i32 %arg1, %arg2 | |
110 br i1 %cmp1, label %branch1, label %branch2 | |
111 branch1: | |
112 ret i32 1 | |
113 branch2: | |
114 ret i32 2 | |
115 } | |
116 ; MIPS32-LABEL: cond_br_ugt | |
117 ; MIPS32: sltu $a1, $a1, $a0 | |
118 ; MIPS32: beqz $a1, .Lcond_br_ugt$branch2 | |
119 ; MIPS32-OM1: sltu $v0, $v1, $v0 | |
120 ; MIPS32-OM1: beqz $v0, .Lcond_br_ugt$branch2 | |
121 | |
122 define internal i32 @cond_br_uge(i32 %arg1, i32 %arg2) { | |
123 entry: | |
124 %cmp1 = icmp uge i32 %arg1, %arg2 | |
125 br i1 %cmp1, label %branch1, label %branch2 | |
126 branch1: | |
127 ret i32 1 | |
128 branch2: | |
129 ret i32 2 | |
130 } | |
131 ; MIPS32-LABEL: cond_br_uge | |
132 ; MIPS32: sltu $a0, $a0, $a1 | |
133 ; MIPS32: bnez $a0, .Lcond_br_uge$branch2 | |
134 ; MIPS32-OM1: sltu $v0, $v0, $v1 | |
135 ; MIPS32-OM1: xori $v0, $v0, 1 | |
136 ; MIPS32-OM1: beqz $v0, .Lcond_br_uge$branch2 | |
137 | |
138 define internal i32 @cond_br_ult(i32 %arg1, i32 %arg2) { | |
139 entry: | |
140 %cmp1 = icmp ult i32 %arg1, %arg2 | |
141 br i1 %cmp1, label %branch1, label %branch2 | |
142 branch1: | |
143 ret i32 1 | |
144 branch2: | |
145 ret i32 2 | |
146 } | |
147 ; MIPS32-LABEL: cond_br_ult | |
148 ; MIPS32: sltu $a0, $a0, $a1 | |
149 ; MIPS32: beqz $a0, .Lcond_br_ult$branch2 | |
150 ; MIPS32-OM1: sltu $v0, $v0, $v1 | |
151 ; MIPS32-OM1: beqz $v0, .Lcond_br_ult$branch2 | |
152 | |
153 define internal i32 @cond_br_ule(i32 %arg1, i32 %arg2) { | |
154 entry: | |
155 %cmp1 = icmp ule i32 %arg1, %arg2 | |
156 br i1 %cmp1, label %branch1, label %branch2 | |
157 branch1: | |
158 ret i32 1 | |
159 branch2: | |
160 ret i32 2 | |
161 } | |
162 ; MIPS32-LABEL: cond_br_ule | |
163 ; MIPS32: sltu $a1, $a1, $a0 | |
164 ; MIPS32: bnez $a1, .Lcond_br_ule$branch2 | |
165 ; MIPS32-OM1: sltu $v0, $v1, $v0 | |
166 ; MIPS32-OM1: xori $v0, $v0, 1 | |
167 ; MIPS32-OM1: beqz $v0, .Lcond_br_ule$branch2 | |
OLD | NEW |