1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -S -instsimplify | FileCheck %s
3
4declare i32 @llvm.bitreverse.i32(i32)
5declare <2 x i32> @llvm.bitreverse.v2i32(<2 x i32>)
6
7define i1 @test1(i32 %arg) {
8; CHECK-LABEL: @test1(
9; CHECK-NEXT:    ret i1 false
10;
11  %a = or i32 %arg, 1
12  %b = call i32 @llvm.bitreverse.i32(i32 %a)
13  %res = icmp eq i32 %b, 0
14  ret i1 %res
15}
16
17define i1 @test1v(<2 x i32> %arg) {
18; CHECK-LABEL: @test1v(
19; CHECK-NEXT:    ret i1 false
20;
21  %a = or <2 x i32> %arg, <i32 1, i32 0>
22  %b = call <2 x i32> @llvm.bitreverse.v2i32(<2 x i32> %a)
23  %c = extractelement <2 x i32> %b, i32 0
24  %res = icmp eq i32 %c, 0
25  ret i1 %res
26}
27
28define i1 @test2(i32 %arg) {
29; CHECK-LABEL: @test2(
30; CHECK-NEXT:    ret i1 false
31;
32  %a = or i32 %arg, 1024
33  %b = call i32 @llvm.bitreverse.i32(i32 %a)
34  %res = icmp eq i32 %b, 0
35  ret i1 %res
36}
37
38define i1 @test2v(<2 x i32> %arg) {
39; CHECK-LABEL: @test2v(
40; CHECK-NEXT:    ret i1 false
41;
42  %a = or <2 x i32> %arg, <i32 0, i32 1024>
43  %b = call <2 x i32> @llvm.bitreverse.v2i32(<2 x i32> %a)
44  %c = extractelement <2 x i32> %b, i32 1
45  %res = icmp eq i32 %c, 0
46  ret i1 %res
47}
48
49define i1 @test3(i32 %arg) {
50; CHECK-LABEL: @test3(
51; CHECK-NEXT:    ret i1 false
52;
53  %a = and i32 %arg, 1
54  %b = call i32 @llvm.bitreverse.i32(i32 %a)
55  %and = and i32 %b, 1
56  %res = icmp eq i32 %and, 1
57  ret i1 %res
58}
59
60define i1 @test3v(<2 x i32> %arg) {
61; CHECK-LABEL: @test3v(
62; CHECK-NEXT:    ret i1 false
63;
64  %a = and <2 x i32> %arg, <i32 1, i32 -1>
65  %b = call <2 x i32> @llvm.bitreverse.v2i32(<2 x i32> %a)
66  %and = and <2 x i32> %b, <i32 1, i32 -1>
67  %ext = extractelement <2 x i32> %and, i32 0
68  %res = icmp eq i32 %ext, 1
69  ret i1 %res
70}
71