1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -O0 -mtriple=mipsel-linux-gnu -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=MIPS32
6 tracksRegLiveness: true
11 ; MIPS32-LABEL: name: cttz_i32
12 ; MIPS32: liveins: $a0
13 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
14 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1
15 ; MIPS32: [[XOR:%[0-9]+]]:_(s32) = G_XOR [[COPY]], [[C]]
16 ; MIPS32: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C]]
17 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[XOR]], [[ADD]]
18 ; MIPS32: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 32
19 ; MIPS32: [[CTLZ:%[0-9]+]]:_(s32) = G_CTLZ [[AND]](s32)
20 ; MIPS32: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[C1]], [[CTLZ]]
21 ; MIPS32: $v0 = COPY [[SUB]](s32)
22 ; MIPS32: RetRA implicit $v0
24 %1:_(s32) = G_CTTZ %0(s32)
32 tracksRegLiveness: true
37 ; MIPS32-LABEL: name: cttz_i64
38 ; MIPS32: liveins: $a0, $a1
39 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
40 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
41 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
42 ; MIPS32: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(eq), [[COPY]](s32), [[C]]
43 ; MIPS32: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1
44 ; MIPS32: [[XOR:%[0-9]+]]:_(s32) = G_XOR [[COPY1]], [[C1]]
45 ; MIPS32: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY1]], [[C1]]
46 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[XOR]], [[ADD]]
47 ; MIPS32: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 32
48 ; MIPS32: [[CTLZ:%[0-9]+]]:_(s32) = G_CTLZ [[AND]](s32)
49 ; MIPS32: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[C2]], [[CTLZ]]
50 ; MIPS32: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[SUB]], [[C2]]
51 ; MIPS32: [[XOR1:%[0-9]+]]:_(s32) = G_XOR [[COPY]], [[C1]]
52 ; MIPS32: [[ADD2:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
53 ; MIPS32: [[AND1:%[0-9]+]]:_(s32) = G_AND [[XOR1]], [[ADD2]]
54 ; MIPS32: [[CTLZ1:%[0-9]+]]:_(s32) = G_CTLZ [[AND1]](s32)
55 ; MIPS32: [[SUB1:%[0-9]+]]:_(s32) = G_SUB [[C2]], [[CTLZ1]]
56 ; MIPS32: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
57 ; MIPS32: [[AND2:%[0-9]+]]:_(s32) = G_AND [[ICMP]], [[C3]]
58 ; MIPS32: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[AND2]](s32), [[ADD1]], [[SUB1]]
59 ; MIPS32: $v0 = COPY [[SELECT]](s32)
60 ; MIPS32: $v1 = COPY [[C]](s32)
61 ; MIPS32: RetRA implicit $v0, implicit $v1
64 %0:_(s64) = G_MERGE_VALUES %1(s32), %2(s32)
65 %3:_(s64) = G_CTTZ %0(s64)
66 %4:_(s32), %5:_(s32) = G_UNMERGE_VALUES %3(s64)
69 RetRA implicit $v0, implicit $v1
73 name: ffs_i32_expansion
75 tracksRegLiveness: true
80 ; MIPS32-LABEL: name: ffs_i32_expansion
81 ; MIPS32: liveins: $a0
82 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
83 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
84 ; MIPS32: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
85 ; MIPS32: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1
86 ; MIPS32: [[XOR:%[0-9]+]]:_(s32) = G_XOR [[COPY]], [[C2]]
87 ; MIPS32: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C2]]
88 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[XOR]], [[ADD]]
89 ; MIPS32: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 32
90 ; MIPS32: [[CTLZ:%[0-9]+]]:_(s32) = G_CTLZ [[AND]](s32)
91 ; MIPS32: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[C3]], [[CTLZ]]
92 ; MIPS32: [[ADD1:%[0-9]+]]:_(s32) = nuw nsw G_ADD [[SUB]], [[C]]
93 ; MIPS32: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(eq), [[COPY]](s32), [[C1]]
94 ; MIPS32: [[AND1:%[0-9]+]]:_(s32) = G_AND [[ICMP]], [[C]]
95 ; MIPS32: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[AND1]](s32), [[C1]], [[ADD1]]
96 ; MIPS32: $v0 = COPY [[SELECT]](s32)
97 ; MIPS32: RetRA implicit $v0
99 %2:_(s32) = G_CONSTANT i32 1
100 %4:_(s32) = G_CONSTANT i32 0
101 %1:_(s32) = G_CTTZ_ZERO_UNDEF %0(s32)
102 %3:_(s32) = nuw nsw G_ADD %1, %2
103 %5:_(s1) = G_ICMP intpred(eq), %0(s32), %4
104 %6:_(s32) = G_SELECT %5(s1), %4, %3
110 name: ffs_i64_expansion
112 tracksRegLiveness: true
117 ; MIPS32-LABEL: name: ffs_i64_expansion
118 ; MIPS32: liveins: $a0, $a1
119 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
120 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
121 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
122 ; MIPS32: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
123 ; MIPS32: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[C1]](s32), [[C1]](s32)
124 ; MIPS32: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(eq), [[COPY]](s32), [[C1]]
125 ; MIPS32: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1
126 ; MIPS32: [[XOR:%[0-9]+]]:_(s32) = G_XOR [[COPY1]], [[C2]]
127 ; MIPS32: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY1]], [[C2]]
128 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[XOR]], [[ADD]]
129 ; MIPS32: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 32
130 ; MIPS32: [[CTLZ:%[0-9]+]]:_(s32) = G_CTLZ [[AND]](s32)
131 ; MIPS32: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[C3]], [[CTLZ]]
132 ; MIPS32: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[SUB]], [[C3]]
133 ; MIPS32: [[XOR1:%[0-9]+]]:_(s32) = G_XOR [[COPY]], [[C2]]
134 ; MIPS32: [[ADD2:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C2]]
135 ; MIPS32: [[AND1:%[0-9]+]]:_(s32) = G_AND [[XOR1]], [[ADD2]]
136 ; MIPS32: [[CTLZ1:%[0-9]+]]:_(s32) = G_CTLZ [[AND1]](s32)
137 ; MIPS32: [[SUB1:%[0-9]+]]:_(s32) = G_SUB [[C3]], [[CTLZ1]]
138 ; MIPS32: [[AND2:%[0-9]+]]:_(s32) = G_AND [[ICMP]], [[C]]
139 ; MIPS32: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[AND2]](s32), [[ADD1]], [[SUB1]]
140 ; MIPS32: [[ADD3:%[0-9]+]]:_(s32) = G_ADD [[SELECT]], [[C]]
141 ; MIPS32: [[ICMP1:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), [[ADD3]](s32), [[C]]
142 ; MIPS32: [[ADD4:%[0-9]+]]:_(s32) = G_ADD [[C1]], [[C1]]
143 ; MIPS32: [[AND3:%[0-9]+]]:_(s32) = G_AND [[ICMP1]], [[C]]
144 ; MIPS32: [[ADD5:%[0-9]+]]:_(s32) = G_ADD [[ADD4]], [[AND3]]
145 ; MIPS32: [[MV1:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[ADD3]](s32), [[ADD5]](s32)
146 ; MIPS32: [[XOR2:%[0-9]+]]:_(s32) = G_XOR [[COPY]], [[C1]]
147 ; MIPS32: [[XOR3:%[0-9]+]]:_(s32) = G_XOR [[COPY1]], [[C1]]
148 ; MIPS32: [[OR:%[0-9]+]]:_(s32) = G_OR [[XOR2]], [[XOR3]]
149 ; MIPS32: [[ICMP2:%[0-9]+]]:_(s32) = G_ICMP intpred(eq), [[OR]](s32), [[C1]]
150 ; MIPS32: [[AND4:%[0-9]+]]:_(s32) = G_AND [[ICMP2]], [[C]]
151 ; MIPS32: [[SELECT1:%[0-9]+]]:_(s64) = G_SELECT [[AND4]](s32), [[MV]], [[MV1]]
152 ; MIPS32: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[SELECT1]](s64)
153 ; MIPS32: $v0 = COPY [[UV]](s32)
154 ; MIPS32: $v1 = COPY [[UV1]](s32)
155 ; MIPS32: RetRA implicit $v0, implicit $v1
158 %0:_(s64) = G_MERGE_VALUES %1(s32), %2(s32)
159 %4:_(s64) = G_CONSTANT i64 1
160 %6:_(s64) = G_CONSTANT i64 0
161 %3:_(s64) = G_CTTZ_ZERO_UNDEF %0(s64)
162 %5:_(s64) = nuw nsw G_ADD %3, %4
163 %7:_(s1) = G_ICMP intpred(eq), %0(s64), %6
164 %8:_(s64) = G_SELECT %7(s1), %6, %5
165 %9:_(s32), %10:_(s32) = G_UNMERGE_VALUES %8(s64)
168 RetRA implicit $v0, implicit $v1