1 ; Test moves between FPRs and GPRs.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5 ; Test 32-bit moves from GPRs to FPRs. The GPR must be moved into the high
7 define float @f1(i32 %a) {
9 ; CHECK: sllg [[REGISTER:%r[0-5]]], %r2, 32
10 ; CHECK: ldgr %f0, [[REGISTER]]
11 %res = bitcast i32 %a to float
15 ; Like f1, but create a situation where the shift can be folded with
17 define float @f2(i64 %big) {
19 ; CHECK: risbg [[REGISTER:%r[0-5]]], %r2, 0, 159, 31
20 ; CHECK: ldgr %f0, [[REGISTER]]
21 %shift = lshr i64 %big, 1
22 %a = trunc i64 %shift to i32
23 %res = bitcast i32 %a to float
27 ; Another example of the same thing.
28 define float @f3(i64 %big) {
30 ; CHECK: risbg [[REGISTER:%r[0-5]]], %r2, 0, 159, 2
31 ; CHECK: ldgr %f0, [[REGISTER]]
32 %shift = ashr i64 %big, 30
33 %a = trunc i64 %shift to i32
34 %res = bitcast i32 %a to float
38 ; Like f1, but the value to transfer is already in the high 32 bits.
39 define float @f4(i64 %big) {
42 ; CHECK: risbg [[REG:%r[0-5]]], %r2, 0, 159, 0
44 ; CHECK: ldgr %f0, [[REG]]
45 %shift = ashr i64 %big, 32
46 %a = trunc i64 %shift to i32
47 %res = bitcast i32 %a to float
51 ; Test 64-bit moves from GPRs to FPRs.
52 define double @f5(i64 %a) {
54 ; CHECK: ldgr %f0, %r2
55 %res = bitcast i64 %a to double
59 ; Test 128-bit moves from GPRs to FPRs. i128 isn't a legitimate type,
60 ; so this goes through memory.
61 ; FIXME: it would be better to use one MVC here.
62 define void @f6(fp128 *%a, i128 *%b) {
69 %res = bitcast i128 %val to fp128
70 store fp128 %res, fp128 *%a
74 ; Test 32-bit moves from FPRs to GPRs. The high 32 bits of the FPR should
75 ; be moved into the low 32 bits of the GPR.
76 define i32 @f7(float %a) {
78 ; CHECK: lgdr [[REGISTER:%r[0-5]]], %f0
79 ; CHECK: srlg %r2, [[REGISTER]], 32
80 %res = bitcast float %a to i32
84 ; Test 64-bit moves from FPRs to GPRs.
85 define i64 @f8(double %a) {
87 ; CHECK: lgdr %r2, %f0
88 %res = bitcast double %a to i64
92 ; Test 128-bit moves from FPRs to GPRs, with the same restriction as f6.
93 define void @f9(fp128 *%a, i128 *%b) {
100 %res = bitcast fp128 %val to i128
101 store i128 %res, i128 *%b