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: sllg [[REGISTER:%r[0-5]]], %r2, 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: sllg [[REGISTER:%r[0-5]]], %r2, 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) {
44 ; CHECK: ldgr %f0, %r2
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 define void @f6(fp128 *%a, i128 *%b) {
68 %res = bitcast i128 %val to fp128
69 store fp128 %res, fp128 *%a
73 ; Test 32-bit moves from FPRs to GPRs. The high 32 bits of the FPR should
74 ; be moved into the low 32 bits of the GPR.
75 define i32 @f7(float %a) {
77 ; CHECK: lgdr [[REGISTER:%r[0-5]]], %f0
78 ; CHECK: srlg %r2, [[REGISTER]], 32
79 %res = bitcast float %a to i32
83 ; Test 64-bit moves from FPRs to GPRs.
84 define i64 @f8(double %a) {
86 ; CHECK: lgdr %r2, %f0
87 %res = bitcast double %a to i64
91 ; Test 128-bit moves from FPRs to GPRs, with the same restriction as f6.
92 define void @f9(fp128 *%a, i128 *%b) {
99 %res = bitcast fp128 %val to i128
100 store i128 %res, i128 *%b