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 i32 0, align 4
11
12; Function Attrs: norecurse nounwind readnone
13define signext i32 @test_iltsi(i32 signext %a, i32 signext %b) {
14; CHECK-LABEL: test_iltsi:
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 i32 %a, %b
21  %conv = zext i1 %cmp to i32
22  ret i32 %conv
23}
24
25; Function Attrs: norecurse nounwind readnone
26define signext i32 @test_iltsi_sext(i32 signext %a, i32 signext %b) {
27; CHECK-LABEL: test_iltsi_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 i32 %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_iltsi_sext_z(i32 signext %a) {
40; CHECK-LABEL: test_iltsi_sext_z:
41; CHECK:       # BB#0: # %entry
42; CHECK-NEXT:    srawi r3, r3, 31
43; CHECK-NEXT:    blr
44entry:
45  %cmp = icmp slt i32 %a, 0
46  %sub = sext i1 %cmp to i32
47  ret i32 %sub
48}
49
50; Function Attrs: norecurse nounwind
51define void @test_iltsi_store(i32 signext %a, i32 signext %b) {
52; CHECK-LABEL: test_iltsi_store:
53; CHECK:       # BB#0: # %entry
54; CHECK:         sub [[REG:r[0-9]+]], r3, r4
55; CHECK:         rldicl {{r[0-9]+}}, [[REG]], 1, 63
56entry:
57  %cmp = icmp slt i32 %a, %b
58  %conv = zext i1 %cmp to i32
59  store i32 %conv, i32* @glob, align 4
60  ret void
61}
62
63; Function Attrs: norecurse nounwind
64define void @test_iltsi_sext_store(i32 signext %a, i32 signext %b) {
65; CHECK-LABEL: test_iltsi_sext_store:
66; CHECK:       # BB#0: # %entry
67; CHECK:         sub [[REG:r[0-9]+]], r3, r4
68; CHECK:         sradi {{r[0-9]+}}, [[REG]], 63
69entry:
70  %cmp = icmp slt i32 %a, %b
71  %sub = sext i1 %cmp to i32
72  store i32 %sub, i32* @glob, align 4
73  ret void
74}
75
76; Function Attrs: norecurse nounwind
77define void @test_iltsi_sext_z_store(i32 signext %a) {
78; CHECK-LABEL: test_iltsi_sext_z_store:
79; CHECK:    srawi {{r[0-9]+}}, r3, 31
80; CHECK:    blr
81entry:
82  %cmp = icmp slt i32 %a, 0
83  %sub = sext i1 %cmp to i32
84  store i32 %sub, i32* @glob, align 4
85  ret void
86}
87