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 i1 @test2(i16* %x) {
35 ; CHECK-LABEL: @test2(
36 ; CHECK-NEXT: [[LOAD:%.*]] = load i16, i16* [[X:%.*]], align 4
37 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i16 [[LOAD]], 32581
38 ; CHECK-NEXT: ret i1 [[TMP1]]
40 %load = load i16, i16* %x, align 4
41 %and = and i16 %load, -256
42 %cmp1 = icmp eq i16 %and, 32512
43 %trunc = trunc i16 %load to i8
44 %cmp2 = icmp eq i8 %trunc, 69
45 %or = and i1 %cmp1, %cmp2
49 define i1 @test2_logical(i16* %x) {
50 ; CHECK-LABEL: @test2_logical(
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 = select i1 %cmp1, i1 %cmp2, i1 false