blob: afbdbaf45f2452aefdaa1cd3202a6b5e24afaf59 [file] [log] [blame]
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00001; Test 32-bit inequality comparisons that are really between a memory halfword
2; and a constant.
3;
4; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5
6; Check the low end of the 16-bit unsigned range, with zero extension.
7define double @f1(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +00008; CHECK-LABEL: f1:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00009; CHECK: clhhsi 0(%r2), 0
Ulrich Weigand2eb027d2016-04-07 16:11:44 +000010; CHECK-NEXT: blhr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000011; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000012 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000013 %ext = zext i16 %val to i32
14 %cond = icmp ne i32 %ext, 0
15 %res = select i1 %cond, double %a, double %b
16 ret double %res
17}
18
19; Check the high end of the 16-bit unsigned range, with zero extension.
20define double @f2(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000021; CHECK-LABEL: f2:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000022; CHECK: clhhsi 0(%r2), 65535
Ulrich Weigand2eb027d2016-04-07 16:11:44 +000023; CHECK-NEXT: blhr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000024; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000025 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000026 %ext = zext i16 %val to i32
27 %cond = icmp ne i32 %ext, 65535
28 %res = select i1 %cond, double %a, double %b
29 ret double %res
30}
31
32; Check the next value up, with zero extension. The condition is always false.
33define double @f3(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000034; CHECK-LABEL: f3:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000035; CHECK-NOT: clhhsi
36; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000037 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000038 %ext = zext i16 %val to i32
39 %cond = icmp ne i32 %ext, 65536
40 %res = select i1 %cond, double %a, double %b
41 ret double %res
42}
43
44; Check comparisons with -1, with zero extension.
45; This condition is also always false.
46define double @f4(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000047; CHECK-LABEL: f4:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000048; CHECK-NOT: clhhsi
49; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000050 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000051 %ext = zext i16 %val to i32
52 %cond = icmp ne i32 %ext, -1
53 %res = select i1 %cond, double %a, double %b
54 ret double %res
55}
56
57; Check comparisons with 0, using sign extension.
58define double @f5(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000059; CHECK-LABEL: f5:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000060; CHECK: clhhsi 0(%r2), 0
Ulrich Weigand2eb027d2016-04-07 16:11:44 +000061; CHECK-NEXT: blhr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000062; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000063 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000064 %ext = sext i16 %val to i32
65 %cond = icmp ne i32 %ext, 0
66 %res = select i1 %cond, double %a, double %b
67 ret double %res
68}
69
70; Check the high end of the signed 16-bit range, using sign extension.
71define double @f6(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000072; CHECK-LABEL: f6:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000073; CHECK: clhhsi 0(%r2), 32767
Ulrich Weigand2eb027d2016-04-07 16:11:44 +000074; CHECK-NEXT: blhr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000075; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000076 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000077 %ext = sext i16 %val to i32
78 %cond = icmp ne i32 %ext, 32767
79 %res = select i1 %cond, double %a, double %b
80 ret double %res
81}
82
83; Check the next value up, using sign extension.
84; The condition is always false.
85define double @f7(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000086; CHECK-LABEL: f7:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000087; CHECK-NOT: clhhsi
88; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000089 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000090 %ext = sext i16 %val to i32
91 %cond = icmp ne i32 %ext, 32768
92 %res = select i1 %cond, double %a, double %b
93 ret double %res
94}
95
96; Check comparisons with -1, using sign extension.
97define double @f8(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000098; CHECK-LABEL: f8:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000099; CHECK: clhhsi 0(%r2), 65535
Ulrich Weigand2eb027d2016-04-07 16:11:44 +0000100; CHECK-NEXT: blhr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000101; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +0000102 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000103 %ext = sext i16 %val to i32
104 %cond = icmp ne i32 %ext, -1
105 %res = select i1 %cond, double %a, double %b
106 ret double %res
107}
108
109; Check the low end of the signed 16-bit range, using sign extension.
110define double @f9(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +0000111; CHECK-LABEL: f9:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000112; CHECK: clhhsi 0(%r2), 32768
Ulrich Weigand2eb027d2016-04-07 16:11:44 +0000113; CHECK-NEXT: blhr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000114; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +0000115 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000116 %ext = sext i16 %val to i32
117 %cond = icmp ne i32 %ext, -32768
118 %res = select i1 %cond, double %a, double %b
119 ret double %res
120}
121
122; Check the next value down, using sign extension.
123; The condition is always false.
124define double @f10(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +0000125; CHECK-LABEL: f10:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000126; CHECK-NOT: clhhsi
127; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +0000128 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000129 %ext = sext i16 %val to i32
130 %cond = icmp ne i32 %ext, -32769
131 %res = select i1 %cond, double %a, double %b
132 ret double %res
133}