1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -O2 \
3; RUN:   -ppc-gpr-icmps=all -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-gpr-icmps=all -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
9@glob = dso_local local_unnamed_addr global i64 0, align 8
10
11; Function Attrs: norecurse nounwind readnone
12define i64 @test_llleull(i64 %a, i64 %b) {
13; CHECK-LABEL: test_llleull:
14; CHECK:       # %bb.0: # %entry
15; CHECK-NEXT:    subc r4, r4, r3
16; CHECK-NEXT:    subfe r3, r3, r3
17; CHECK-NEXT:    addi r3, r3, 1
18; CHECK-NEXT:    blr
19entry:
20  %cmp = icmp ule i64 %a, %b
21  %conv1 = zext i1 %cmp to i64
22  ret i64 %conv1
23}
24
25; Function Attrs: norecurse nounwind readnone
26define i64 @test_llleull_sext(i64 %a, i64 %b) {
27; CHECK-LABEL: test_llleull_sext:
28; CHECK:       # %bb.0: # %entry
29; CHECK-NEXT:    subc r4, r4, r3
30; CHECK-NEXT:    subfe r3, r3, r3
31; CHECK-NEXT:    not r3, r3
32; CHECK-NEXT:    blr
33entry:
34  %cmp = icmp ule i64 %a, %b
35  %conv1 = sext i1 %cmp to i64
36  ret i64 %conv1
37}
38
39; Function Attrs: norecurse nounwind readnone
40define i64 @test_llleull_z(i64 %a) {
41; CHECK-LABEL: test_llleull_z:
42; CHECK:       # %bb.0: # %entry
43; CHECK-NEXT:    cntlzd r3, r3
44; CHECK-NEXT:    rldicl r3, r3, 58, 63
45; CHECK-NEXT:    blr
46entry:
47  %cmp = icmp ule i64 %a, 0
48  %conv1 = zext i1 %cmp to i64
49  ret i64 %conv1
50}
51
52; Function Attrs: norecurse nounwind readnone
53define i64 @test_llleull_sext_z(i64 %a) {
54; CHECK-LABEL: test_llleull_sext_z:
55; CHECK:       # %bb.0: # %entry
56; CHECK-NEXT:    addic r3, r3, -1
57; CHECK-NEXT:    subfe r3, r3, r3
58; CHECK-NEXT:    blr
59entry:
60  %cmp = icmp ule i64 %a, 0
61  %conv1 = sext i1 %cmp to i64
62  ret i64 %conv1
63}
64
65; Function Attrs: norecurse nounwind
66define dso_local void @test_llleull_store(i64 %a, i64 %b) {
67; CHECK-LABEL: test_llleull_store:
68; CHECK:       # %bb.0: # %entry
69; CHECK-NEXT:    subc r4, r4, r3
70; CHECK-NEXT:    addis r5, r2, glob@toc@ha
71; CHECK-NEXT:    subfe r3, r3, r3
72; CHECK-NEXT:    addi r3, r3, 1
73; CHECK-NEXT:    std r3, glob@toc@l(r5)
74; CHECK-NEXT:    blr
75entry:
76  %cmp = icmp ule i64 %a, %b
77  %conv1 = zext i1 %cmp to i64
78  store i64 %conv1, i64* @glob
79  ret void
80}
81
82; Function Attrs: norecurse nounwind
83define dso_local void @test_llleull_sext_store(i64 %a, i64 %b) {
84; CHECK-LABEL: test_llleull_sext_store:
85; CHECK:       # %bb.0: # %entry
86; CHECK-NEXT:    subc r4, r4, r3
87; CHECK-NEXT:    addis r5, r2, glob@toc@ha
88; CHECK-NEXT:    subfe r3, r3, r3
89; CHECK-NEXT:    not r3, r3
90; CHECK-NEXT:    std r3, glob@toc@l(r5)
91; CHECK-NEXT:    blr
92entry:
93  %cmp = icmp ule i64 %a, %b
94  %conv1 = sext i1 %cmp to i64
95  store i64 %conv1, i64* @glob
96  ret void
97}
98
99; Function Attrs: norecurse nounwind
100define dso_local void @test_llleull_z_store(i64 %a) {
101; CHECK-LABEL: test_llleull_z_store:
102; CHECK:       # %bb.0: # %entry
103; CHECK-NEXT:    cntlzd r3, r3
104; CHECK-NEXT:    addis r4, r2, glob@toc@ha
105; CHECK-NEXT:    rldicl r3, r3, 58, 63
106; CHECK-NEXT:    std r3, glob@toc@l(r4)
107; CHECK-NEXT:    blr
108entry:
109  %cmp = icmp ule i64 %a, 0
110  %conv1 = zext i1 %cmp to i64
111  store i64 %conv1, i64* @glob
112  ret void
113}
114
115; Function Attrs: norecurse nounwind
116define dso_local void @test_llleull_sext_z_store(i64 %a) {
117; CHECK-LABEL: test_llleull_sext_z_store:
118; CHECK:       # %bb.0: # %entry
119; CHECK-NEXT:    addic r3, r3, -1
120; CHECK-NEXT:    addis r4, r2, glob@toc@ha
121; CHECK-NEXT:    subfe r3, r3, r3
122; CHECK-NEXT:    std r3, glob@toc@l(r4)
123; CHECK-NEXT:    blr
124entry:
125  %cmp = icmp ule i64 %a, 0
126  %conv1 = sext i1 %cmp to i64
127  store i64 %conv1, i64* @glob
128  ret void
129}
130
131