1; RUN: opt < %s -instcombine -S | FileCheck %s
2
3target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4target triple = "x86_64-unknown-linux-gnu"
5
6; Should be optimized to one and.
7define i1 @test1(i32 %a, i32 %b) {
8; CHECK-LABEL: @test1(
9; CHECK-NEXT: %1 = xor i32 %a, %b
10; CHECK-NEXT: %2 = and i32 %1, 65280
11; CHECK-NEXT: %tmp = icmp ne i32 %2, 0
12; CHECK-NEXT: ret i1 %tmp
13        %tmp1 = and i32 %a, 65280               ; <i32> [#uses=1]
14        %tmp3 = and i32 %b, 65280               ; <i32> [#uses=1]
15        %tmp = icmp ne i32 %tmp1, %tmp3         ; <i1> [#uses=1]
16        ret i1 %tmp
17}
18
19define zeroext i1 @test2(i64 %A) {
20; CHECK-LABEL: @test2(
21; CHECK-NEXT: %[[trunc:.*]] = trunc i64 %A to i8
22; CHECK-NEXT: %[[icmp:.*]] = icmp sgt i8 %[[trunc]], -1
23; CHECK-NEXT: ret i1 %[[icmp]]
24  %and = and i64 %A, 128
25  %cmp = icmp eq i64 %and, 0
26  ret i1 %cmp
27}
28
29define zeroext i1 @test3(i64 %A) {
30; CHECK-LABEL: @test3(
31; CHECK-NEXT: %[[trunc:.*]] = trunc i64 %A to i8
32; CHECK-NEXT: %[[icmp:.*]] = icmp slt i8 %[[trunc]], 0
33; CHECK-NEXT: ret i1 %[[icmp]]
34  %and = and i64 %A, 128
35  %cmp = icmp ne i64 %and, 0
36  ret i1 %cmp
37}
38