1 ; Test all condition-code masks that are relevant for CRJ.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
8 define void @f1(i32 %target) {
10 ; CHECK: .cfi_def_cfa_offset
11 ; CHECK: .L[[LABEL:.*]]:
12 ; CHECK: crje %r2, {{%r[0-9]+}}, .L[[LABEL]]
15 %val = call i32 @foo()
16 %cond = icmp eq i32 %val, %target
17 br i1 %cond, label %loop, label %exit
22 define void @f2(i32 %target) {
24 ; CHECK: .cfi_def_cfa_offset
25 ; CHECK: .L[[LABEL:.*]]:
26 ; CHECK: crjlh %r2, {{%r[0-9]+}}, .L[[LABEL]]
29 %val = call i32 @foo()
30 %cond = icmp ne i32 %val, %target
31 br i1 %cond, label %loop, label %exit
36 define void @f3(i32 %target) {
38 ; CHECK: .cfi_def_cfa_offset
39 ; CHECK: .L[[LABEL:.*]]:
40 ; CHECK: crjle %r2, {{%r[0-9]+}}, .L[[LABEL]]
43 %val = call i32 @foo()
44 %cond = icmp sle i32 %val, %target
45 br i1 %cond, label %loop, label %exit
50 define void @f4(i32 %target) {
52 ; CHECK: .cfi_def_cfa_offset
53 ; CHECK: .L[[LABEL:.*]]:
54 ; CHECK: crjl %r2, {{%r[0-9]+}}, .L[[LABEL]]
57 %val = call i32 @foo()
58 %cond = icmp slt i32 %val, %target
59 br i1 %cond, label %loop, label %exit
64 define void @f5(i32 %target) {
66 ; CHECK: .cfi_def_cfa_offset
67 ; CHECK: .L[[LABEL:.*]]:
68 ; CHECK: crjh %r2, {{%r[0-9]+}}, .L[[LABEL]]
71 %val = call i32 @foo()
72 %cond = icmp sgt i32 %val, %target
73 br i1 %cond, label %loop, label %exit
78 define void @f6(i32 %target) {
80 ; CHECK: .cfi_def_cfa_offset
81 ; CHECK: .L[[LABEL:.*]]:
82 ; CHECK: crjhe %r2, {{%r[0-9]+}}, .L[[LABEL]]
85 %val = call i32 @foo()
86 %cond = icmp sge i32 %val, %target
87 br i1 %cond, label %loop, label %exit
92 ; Check that CRJ is used for checking equality with a zero-extending
94 define void @f7(i8 *%targetptr) {
96 ; CHECK: .cfi_def_cfa_offset
97 ; CHECK: .L[[LABEL:.*]]:
98 ; CHECK: llc [[REG:%r[0-5]]],
99 ; CHECK: crje %r2, [[REG]], .L[[LABEL]]
102 %val = call i32 @foo()
103 %byte = load i8, i8 *%targetptr
104 %target = zext i8 %byte to i32
105 %cond = icmp eq i32 %val, %target
106 br i1 %cond, label %loop, label %exit
111 ; ...and zero-extending i16 loads.
112 define void @f8(i16 *%targetptr) {
114 ; CHECK: .cfi_def_cfa_offset
115 ; CHECK: .L[[LABEL:.*]]:
116 ; CHECK: llh [[REG:%r[0-5]]],
117 ; CHECK: crje %r2, [[REG]], .L[[LABEL]]
120 %val = call i32 @foo()
121 %half = load i16, i16 *%targetptr
122 %target = zext i16 %half to i32
123 %cond = icmp eq i32 %val, %target
124 br i1 %cond, label %loop, label %exit
129 ; ...unless the address is a global.
130 define void @f9(i16 *%targetptr) {
132 ; CHECK: .cfi_def_cfa_offset
133 ; CHECK: .L[[LABEL:.*]]:
134 ; CHECK: clhrl %r2, g1
135 ; CHECK: je .L[[LABEL]]
138 %val = call i32 @foo()
139 %half = load i16, i16 *@g1
140 %target = zext i16 %half to i32
141 %cond = icmp eq i32 %val, %target
142 br i1 %cond, label %loop, label %exit
147 ; Check that CRJ is used for checking order between two zero-extending
148 ; byte loads, even if the original comparison was unsigned.
149 define void @f10(i8 *%targetptr1) {
151 ; CHECK: .cfi_def_cfa_offset
152 ; CHECK: .L[[LABEL:.*]]:
153 ; CHECK-DAG: llc [[REG1:%r[0-5]]], 0(
154 ; CHECK-DAG: llc [[REG2:%r[0-5]]], 1(
155 ; CHECK: crjl [[REG1]], [[REG2]], .L[[LABEL]]
158 %val = call i32 @foo()
159 %targetptr2 = getelementptr i8, i8 *%targetptr1, i64 1
160 %byte1 = load i8, i8 *%targetptr1
161 %byte2 = load i8, i8 *%targetptr2
162 %ext1 = zext i8 %byte1 to i32
163 %ext2 = zext i8 %byte2 to i32
164 %cond = icmp ult i32 %ext1, %ext2
165 br i1 %cond, label %loop, label %exit
170 ; ...likewise halfword loads.
171 define void @f11(i16 *%targetptr1) {
173 ; CHECK: .cfi_def_cfa_offset
174 ; CHECK: .L[[LABEL:.*]]:
175 ; CHECK-DAG: llh [[REG1:%r[0-5]]], 0(
176 ; CHECK-DAG: llh [[REG2:%r[0-5]]], 2(
177 ; CHECK: crjl [[REG1]], [[REG2]], .L[[LABEL]]
180 %val = call i32 @foo()
181 %targetptr2 = getelementptr i16, i16 *%targetptr1, i64 1
182 %half1 = load i16, i16 *%targetptr1
183 %half2 = load i16, i16 *%targetptr2
184 %ext1 = zext i16 %half1 to i32
185 %ext2 = zext i16 %half2 to i32
186 %cond = icmp ult i32 %ext1, %ext2
187 br i1 %cond, label %loop, label %exit