1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -instcombine < %s | FileCheck %s
4 define i1 @test1(i16* %x) {
6 ; CHECK-NEXT: [[LOAD:%.*]] = load i16, i16* [[X:%.*]], align 4
7 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i16 [[LOAD]], 17791
8 ; CHECK-NEXT: ret i1 [[TMP1]]
10 %load = load i16, i16* %x, align 4
11 %trunc = trunc i16 %load to i8
12 %cmp1 = icmp eq i8 %trunc, 127
13 %and = and i16 %load, -256
14 %cmp2 = icmp eq i16 %and, 17664
15 %or = and i1 %cmp1, %cmp2
19 define i1 @test1_logical(i16* %x) {
20 ; CHECK-LABEL: @test1_logical(
21 ; CHECK-NEXT: [[LOAD:%.*]] = load i16, i16* [[X:%.*]], align 4
22 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i16 [[LOAD]], 17791
23 ; CHECK-NEXT: ret i1 [[TMP1]]
25 %load = load i16, i16* %x, align 4
26 %trunc = trunc i16 %load to i8
27 %cmp1 = icmp eq i8 %trunc, 127
28 %and = and i16 %load, -256
29 %cmp2 = icmp eq i16 %and, 17664
30 %or = select i1 %cmp1, i1 %cmp2, i1 false
34 define <2 x i1> @test1_vector(<2 x i16>* %x) {
35 ; CHECK-LABEL: @test1_vector(
36 ; CHECK-NEXT: [[LOAD:%.*]] = load <2 x i16>, <2 x i16>* [[X:%.*]], align 4
37 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq <2 x i16> [[LOAD]], <i16 17791, i16 17791>
38 ; CHECK-NEXT: ret <2 x i1> [[TMP1]]
40 %load = load <2 x i16>, <2 x i16>* %x, align 4
41 %trunc = trunc <2 x i16> %load to <2 x i8>
42 %cmp1 = icmp eq <2 x i8> %trunc, <i8 127, i8 127>
43 %and = and <2 x i16> %load, <i16 -256, i16 -256>
44 %cmp2 = icmp eq <2 x i16> %and, <i16 17664, i16 17664>
45 %or = and <2 x i1> %cmp1, %cmp2
49 define i1 @test2(i16* %x) {
50 ; CHECK-LABEL: @test2(
51 ; CHECK-NEXT: [[LOAD:%.*]] = load i16, i16* [[X:%.*]], align 4
52 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i16 [[LOAD]], 32581
53 ; CHECK-NEXT: ret i1 [[TMP1]]
55 %load = load i16, i16* %x, align 4
56 %and = and i16 %load, -256
57 %cmp1 = icmp eq i16 %and, 32512
58 %trunc = trunc i16 %load to i8
59 %cmp2 = icmp eq i8 %trunc, 69
60 %or = and i1 %cmp1, %cmp2
64 define i1 @test2_logical(i16* %x) {
65 ; CHECK-LABEL: @test2_logical(
66 ; CHECK-NEXT: [[LOAD:%.*]] = load i16, i16* [[X:%.*]], align 4
67 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i16 [[LOAD]], 32581
68 ; CHECK-NEXT: ret i1 [[TMP1]]
70 %load = load i16, i16* %x, align 4
71 %and = and i16 %load, -256
72 %cmp1 = icmp eq i16 %and, 32512
73 %trunc = trunc i16 %load to i8
74 %cmp2 = icmp eq i8 %trunc, 69
75 %or = select i1 %cmp1, i1 %cmp2, i1 false
79 define <2 x i1> @test2_vector(<2 x i16>* %x) {
80 ; CHECK-LABEL: @test2_vector(
81 ; CHECK-NEXT: [[LOAD:%.*]] = load <2 x i16>, <2 x i16>* [[X:%.*]], align 4
82 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq <2 x i16> [[LOAD]], <i16 32581, i16 32581>
83 ; CHECK-NEXT: ret <2 x i1> [[TMP1]]
85 %load = load <2 x i16>, <2 x i16>* %x, align 4
86 %and = and <2 x i16> %load, <i16 -256, i16 -256>
87 %cmp1 = icmp eq <2 x i16> %and, <i16 32512, i16 32512>
88 %trunc = trunc <2 x i16> %load to <2 x i8>
89 %cmp2 = icmp eq <2 x i8> %trunc, <i8 69, i8 69>
90 %or = and <2 x i1> %cmp1, %cmp2