1; XFAIL: *
2; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -O2 \
3; RUN:   -ppc-asm-full-reg-names -mcpu=pwr8 < %s | FileCheck %s \
4; RUN:  --implicit-check-not cmpw --implicit-check-not cmpd --implicit-check-not cmpl
5; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O2 \
6; RUN:   -ppc-asm-full-reg-names -mcpu=pwr8 < %s | FileCheck %s \
7; RUN:  --implicit-check-not cmpw --implicit-check-not cmpd --implicit-check-not cmpl
8; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
9
10@glob = common local_unnamed_addr global i8 0, align 1
11
12; Function Attrs: norecurse nounwind readnone
13define signext i32 @test_iltsc(i8 signext %a, i8 signext %b) {
14; CHECK-LABEL: test_iltsc:
15; CHECK:       # BB#0: # %entry
16; CHECK-NEXT:    sub [[REG:r[0-9]+]], r3, r4
17; CHECK-NEXT:    rldicl r3, [[REG]], 1, 63
18; CHECK-NEXT:    blr
19entry:
20  %cmp = icmp slt i8 %a, %b
21  %conv2 = zext i1 %cmp to i32
22  ret i32 %conv2
23}
24
25; Function Attrs: norecurse nounwind readnone
26define signext i32 @test_iltsc_sext(i8 signext %a, i8 signext %b) {
27; CHECK-LABEL: test_iltsc_sext:
28; CHECK:       # BB#0: # %entry
29; CHECK-NEXT:    sub [[REG:r[0-9]+]], r3, r4
30; CHECK-NEXT:    sradi r3, [[REG]], 63
31; CHECK-NEXT:    blr
32entry:
33  %cmp = icmp slt i8 %a, %b
34  %sub = sext i1 %cmp to i32
35  ret i32 %sub
36}
37
38; Function Attrs: norecurse nounwind readnone
39define signext i32 @test_iltsc_sext_z(i8 signext %a) {
40; CHECK-LABEL: test_iltsc_sext_z:
41; CHECK:       srawi r3, r3, 31
42; CHECK-NEXT:  blr
43entry:
44  %cmp = icmp slt i8 %a, 0
45  %sub = sext i1 %cmp to i32
46  ret i32 %sub
47}
48
49; Function Attrs: norecurse nounwind
50define void @test_iltsc_store(i8 signext %a, i8 signext %b) {
51; CHECK-LABEL: test_iltsc_store:
52; CHECK:       # BB#0: # %entry
53; CHECK:         sub [[REG:r[0-9]+]], r3, r4
54; CHECK:         rldicl {{r[0-9]+}}, [[REG]], 1, 63
55entry:
56  %cmp = icmp slt i8 %a, %b
57  %conv3 = zext i1 %cmp to i8
58  store i8 %conv3, i8* @glob, align 1
59  ret void
60}
61
62; Function Attrs: norecurse nounwind
63define void @test_iltsc_sext_store(i8 signext %a, i8 signext %b) {
64; CHECK-LABEL: test_iltsc_sext_store:
65; CHECK:       # BB#0: # %entry
66; CHECK:         sub [[REG:r[0-9]+]], r3, r4
67; CHECK:         sradi {{r[0-9]+}}, [[REG]], 63
68entry:
69  %cmp = icmp slt i8 %a, %b
70  %conv3 = sext i1 %cmp to i8
71  store i8 %conv3, i8* @glob, align 1
72  ret void
73}
74
75; Function Attrs: norecurse nounwind
76define void @test_iltsc_sext_z_store(i8 signext %a) {
77; CHECK-LABEL: test_iltsc_sext_z_store:
78; CHECK: srwi {{r[0-9]+}}, r3, 7
79entry:
80  %cmp = icmp slt i8 %a, 0
81  %conv2 = sext i1 %cmp to i8
82  store i8 %conv2, i8* @glob, align 1
83  ret void
84}
85