1; RUN: opt -S -instcombine < %s | FileCheck %s
2
3define i1 @test1(i16* %x) {
4  %load = load i16* %x, align 4
5  %trunc = trunc i16 %load to i8
6  %cmp1 = icmp eq i8 %trunc, 127
7  %and = and i16 %load, -256
8  %cmp2 = icmp eq i16 %and, 17664
9  %or = and i1 %cmp1, %cmp2
10  ret i1 %or
11; CHECK-LABEL: @test1(
12; CHECK-NEXT: load i16
13; CHECK-NEXT: icmp eq i16 %load, 17791
14; CHECK-NEXT: ret i1
15}
16
17define i1 @test2(i16* %x) {
18  %load = load i16* %x, align 4
19  %and = and i16 %load, -256
20  %cmp1 = icmp eq i16 %and, 32512
21  %trunc = trunc i16 %load to i8
22  %cmp2 = icmp eq i8 %trunc, 69
23  %or = and i1 %cmp1, %cmp2
24  ret i1 %or
25; CHECK-LABEL: @test2(
26; CHECK-NEXT: load i16
27; CHECK-NEXT: icmp eq i16 %load, 32581
28; CHECK-NEXT: ret i1
29}
30