llvm.org GIT mirror llvm / 2d25535
[InstSimplify] Add some tests cases for selects with bittests hidden in ugt/ult/uge/ule compares. NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310868 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 2 years ago
1 changed file(s) with 58 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
159159 ret <2 x i8> %sel
160160 }
161161
162 ; TODO: we should be able to simplify this
163 define i32 @test12(i32 %X) {
164 ; CHECK-LABEL: @test12(
165 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[X:%.*]], 4
166 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X]], 3
167 ; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[AND]]
168 ; CHECK-NEXT: ret i32 [[COND]]
169 ;
170 %cmp = icmp ult i32 %X, 4
171 %and = and i32 %X, 3
172 %cond = select i1 %cmp, i32 %X, i32 %and
173 ret i32 %cond
174 }
175
176 ; Same as above, but the compare isn't canonical
177 ; TODO: we should be able to simplify this
178 define i32 @test12noncanon(i32 %X) {
179 ; CHECK-LABEL: @test12noncanon(
180 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i32 [[X:%.*]], 3
181 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X]], 3
182 ; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[AND]]
183 ; CHECK-NEXT: ret i32 [[COND]]
184 ;
185 %cmp = icmp ule i32 %X, 3
186 %and = and i32 %X, 3
187 %cond = select i1 %cmp, i32 %X, i32 %and
188 ret i32 %cond
189 }
190
191 ; TODO: we should be able to simplify this
192 define i32 @test13(i32 %X) {
193 ; CHECK-LABEL: @test13(
194 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i32 [[X:%.*]], 3
195 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X]], 3
196 ; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[AND]], i32 [[X]]
197 ; CHECK-NEXT: ret i32 [[COND]]
198 ;
199 %cmp = icmp ugt i32 %X, 3
200 %and = and i32 %X, 3
201 %cond = select i1 %cmp, i32 %and, i32 %X
202 ret i32 %cond
203 }
204
205 ; Same as above, but the compare isn't canonical
206 ; TODO: we should be able to simplify this
207 define i32 @test13noncanon(i32 %X) {
208 ; CHECK-LABEL: @test13noncanon(
209 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i32 [[X:%.*]], 4
210 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X]], 3
211 ; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[AND]], i32 [[X]]
212 ; CHECK-NEXT: ret i32 [[COND]]
213 ;
214 %cmp = icmp uge i32 %X, 4
215 %and = and i32 %X, 3
216 %cond = select i1 %cmp, i32 %and, i32 %X
217 ret i32 %cond
218 }
219
162220 define i32 @select_icmp_and_8_eq_0_or_8(i32 %x) {
163221 ; CHECK-LABEL: @select_icmp_and_8_eq_0_or_8(
164222 ; CHECK-NEXT: [[OR:%.*]] = or i32 %x, 8