1; RUN: llc -mcpu=pwr7 < %s | FileCheck %s
2target datalayout = "E-m:e-p:32:32-i64:64-n32"
3target triple = "powerpc-unknown-linux-gnu"
4
5; Function Attrs: nounwind readnone
6define zeroext i16 @test16(i16 zeroext %x, i16 zeroext %y) #0 {
7entry:
8  %0 = xor i16 %y, %x
9  %1 = and i16 %0, 255
10  %cmp = icmp eq i16 %1, 0
11  %cmp20 = icmp ult i16 %0, 256
12  %conv25 = select i1 %cmp, i32 255, i32 0
13  %conv27 = select i1 %cmp20, i32 65280, i32 0
14  %or = or i32 %conv25, %conv27
15  %conv29 = trunc i32 %or to i16
16  ret i16 %conv29
17
18; CHECK-LABEL: @test16
19; CHECK: cmpb [[REG1:[0-9]+]], 4, 3
20; CHECK: rlwinm 3, [[REG1]], 0, 16, 31
21; CHECK: blr
22}
23
24define i32 @test32(i32 %x, i32 %y) #0 {
25entry:
26  %0 = xor i32 %y, %x
27  %1 = and i32 %0, 255
28  %cmp = icmp eq i32 %1, 0
29  %2 = and i32 %0, 65280
30  %cmp28 = icmp eq i32 %2, 0
31  %3 = and i32 %0, 16711680
32  %cmp34 = icmp eq i32 %3, 0
33  %cmp40 = icmp ult i32 %0, 16777216
34  %conv44 = select i1 %cmp, i32 255, i32 0
35  %conv45 = select i1 %cmp28, i32 65280, i32 0
36  %conv47 = select i1 %cmp34, i32 16711680, i32 0
37  %conv50 = select i1 %cmp40, i32 -16777216, i32 0
38  %or = or i32 %conv45, %conv50
39  %or49 = or i32 %or, %conv44
40  %or52 = or i32 %or49, %conv47
41  ret i32 %or52
42
43; CHECK-LABEL: @test32
44; CHECK: cmpb 3, 4, 3
45; CHECK-NOT: rlwinm
46; CHECK: blr
47}
48
49attributes #0 = { nounwind readnone }
50
51