blob: de362af2bea2b6a92a776c09766437e2b6329119 [file] [log] [blame]
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00001; Test 64-bit unsigned comparisons between memory and a constant.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4
5; Check ordered comparisons with a constant near the low end of the unsigned
6; 16-bit range.
7define double @f1(double %a, double %b, i64 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +00008; CHECK-LABEL: f1:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00009; CHECK: clghsi 0(%r2), 2
Ulrich Weigand2eb027d2016-04-07 16:11:44 +000010; CHECK-NEXT: blr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000011; CHECK: ldr %f0, %f2
12; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000013 %val = load i64 , i64 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000014 %cond = icmp ult i64 %val, 2
15 %res = select i1 %cond, double %a, double %b
16 ret double %res
17}
18
19; Check ordered comparisons with the high end of the unsigned 16-bit range.
20define double @f2(double %a, double %b, i64 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000021; CHECK-LABEL: f2:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000022; CHECK: clghsi 0(%r2), 65535
Ulrich Weigand2eb027d2016-04-07 16:11:44 +000023; CHECK-NEXT: blr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000024; CHECK: ldr %f0, %f2
25; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000026 %val = load i64 , i64 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000027 %cond = icmp ult i64 %val, 65535
28 %res = select i1 %cond, double %a, double %b
29 ret double %res
30}
31
32; Check the next value up, which can't use CLGHSI.
33define double @f3(double %a, double %b, i64 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000034; CHECK-LABEL: f3:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000035; CHECK-NOT: clghsi
36; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000037 %val = load i64 , i64 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000038 %cond = icmp ult i64 %val, 65536
39 %res = select i1 %cond, double %a, double %b
40 ret double %res
41}
42
43; Check equality comparisons with 32768, the lowest value for which
44; we prefer CLGHSI to CGHSI.
45define double @f4(double %a, double %b, i64 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000046; CHECK-LABEL: f4:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000047; CHECK: clghsi 0(%r2), 32768
Ulrich Weigand2eb027d2016-04-07 16:11:44 +000048; CHECK-NEXT: ber %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000049; CHECK: ldr %f0, %f2
50; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000051 %val = load i64 , i64 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000052 %cond = icmp eq i64 %val, 32768
53 %res = select i1 %cond, double %a, double %b
54 ret double %res
55}
56
57; Check equality comparisons with the high end of the unsigned 16-bit range.
58define double @f5(double %a, double %b, i64 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000059; CHECK-LABEL: f5:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000060; CHECK: clghsi 0(%r2), 65535
Ulrich Weigand2eb027d2016-04-07 16:11:44 +000061; CHECK-NEXT: ber %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000062; CHECK: ldr %f0, %f2
63; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000064 %val = load i64 , i64 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000065 %cond = icmp eq i64 %val, 65535
66 %res = select i1 %cond, double %a, double %b
67 ret double %res
68}
69
70; Check the next value up, which can't use CLGHSI.
71define double @f6(double %a, double %b, i64 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000072; CHECK-LABEL: f6:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000073; CHECK-NOT: clghsi
74; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000075 %val = load i64 , i64 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000076 %cond = icmp eq i64 %val, 65536
77 %res = select i1 %cond, double %a, double %b
78 ret double %res
79}
80
81; Check the high end of the CLGHSI range.
82define double @f7(double %a, double %b, i64 %i1, i64 *%base) {
Stephen Lind24ab202013-07-14 06:24:09 +000083; CHECK-LABEL: f7:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000084; CHECK: clghsi 4088(%r3), 2
Ulrich Weigand2eb027d2016-04-07 16:11:44 +000085; CHECK-NEXT: blr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000086; CHECK: ldr %f0, %f2
87; CHECK: br %r14
David Blaikie79e6c742015-02-27 19:29:02 +000088 %ptr = getelementptr i64, i64 *%base, i64 511
David Blaikiea79ac142015-02-27 21:17:42 +000089 %val = load i64 , i64 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000090 %cond = icmp ult i64 %val, 2
91 %res = select i1 %cond, double %a, double %b
92 ret double %res
93}
94
95; Check the next doubleword up, which needs separate address logic,
96define double @f8(double %a, double %b, i64 *%base) {
Stephen Lind24ab202013-07-14 06:24:09 +000097; CHECK-LABEL: f8:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000098; CHECK: aghi %r2, 4096
99; CHECK: clghsi 0(%r2), 2
Ulrich Weigand2eb027d2016-04-07 16:11:44 +0000100; CHECK-NEXT: blr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000101; CHECK: ldr %f0, %f2
102; CHECK: br %r14
David Blaikie79e6c742015-02-27 19:29:02 +0000103 %ptr = getelementptr i64, i64 *%base, i64 512
David Blaikiea79ac142015-02-27 21:17:42 +0000104 %val = load i64 , i64 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000105 %cond = icmp ult i64 %val, 2
106 %res = select i1 %cond, double %a, double %b
107 ret double %res
108}
109
110; Check negative offsets, which also need separate address logic.
111define double @f9(double %a, double %b, i64 *%base) {
Stephen Lind24ab202013-07-14 06:24:09 +0000112; CHECK-LABEL: f9:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000113; CHECK: aghi %r2, -8
114; CHECK: clghsi 0(%r2), 2
Ulrich Weigand2eb027d2016-04-07 16:11:44 +0000115; CHECK-NEXT: blr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000116; CHECK: ldr %f0, %f2
117; CHECK: br %r14
David Blaikie79e6c742015-02-27 19:29:02 +0000118 %ptr = getelementptr i64, i64 *%base, i64 -1
David Blaikiea79ac142015-02-27 21:17:42 +0000119 %val = load i64 , i64 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000120 %cond = icmp ult i64 %val, 2
121 %res = select i1 %cond, double %a, double %b
122 ret double %res
123}
124
125; Check that CLGHSI does not allow indices.
126define double @f10(double %a, double %b, i64 %base, i64 %index) {
Stephen Lind24ab202013-07-14 06:24:09 +0000127; CHECK-LABEL: f10:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000128; CHECK: agr {{%r2, %r3|%r3, %r2}}
129; CHECK: clghsi 0({{%r[23]}}), 2
Ulrich Weigand2eb027d2016-04-07 16:11:44 +0000130; CHECK-NEXT: blr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000131; CHECK: ldr %f0, %f2
132; CHECK: br %r14
133 %add = add i64 %base, %index
134 %ptr = inttoptr i64 %add to i64 *
David Blaikiea79ac142015-02-27 21:17:42 +0000135 %val = load i64 , i64 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000136 %cond = icmp ult i64 %val, 2
137 %res = select i1 %cond, double %a, double %b
138 ret double %res
139}