xref: /aosp_15_r20/external/llvm/test/CodeGen/SystemZ/fp-move-09.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; Test moves between FPRs and GPRs for z196 and zEC12.
2*9880d681SAndroid Build Coastguard Worker;
3*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z196 | FileCheck %s
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Worker; Check that moves from i32s to floats can use high registers.
6*9880d681SAndroid Build Coastguard Workerdefine float @f1(i16 *%ptr) {
7*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f1:
8*9880d681SAndroid Build Coastguard Worker; CHECK: llhh [[REG:%r[0-5]]], 0(%r2)
9*9880d681SAndroid Build Coastguard Worker; CHECK: oihh [[REG]], 16256
10*9880d681SAndroid Build Coastguard Worker; CHECK: ldgr %f0, [[REG]]
11*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14
12*9880d681SAndroid Build Coastguard Worker  %base = load i16 , i16 *%ptr
13*9880d681SAndroid Build Coastguard Worker  %ext = zext i16 %base to i32
14*9880d681SAndroid Build Coastguard Worker  %full = or i32 %ext, 1065353216
15*9880d681SAndroid Build Coastguard Worker  %res = bitcast i32 %full to float
16*9880d681SAndroid Build Coastguard Worker  ret float %res
17*9880d681SAndroid Build Coastguard Worker}
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Worker; Check that moves from floats to i32s can use high registers.
20*9880d681SAndroid Build Coastguard Worker; This "store the low byte" technique is used by llvmpipe, for example.
21*9880d681SAndroid Build Coastguard Workerdefine void @f2(float %val, i8 *%ptr) {
22*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f2:
23*9880d681SAndroid Build Coastguard Worker; CHECK: lgdr [[REG:%r[0-5]]], %f0
24*9880d681SAndroid Build Coastguard Worker; CHECK: stch [[REG]], 0(%r2)
25*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14
26*9880d681SAndroid Build Coastguard Worker  %res = bitcast float %val to i32
27*9880d681SAndroid Build Coastguard Worker  %trunc = trunc i32 %res to i8
28*9880d681SAndroid Build Coastguard Worker  store i8 %trunc, i8 *%ptr
29*9880d681SAndroid Build Coastguard Worker  ret void
30*9880d681SAndroid Build Coastguard Worker}
31*9880d681SAndroid Build Coastguard Worker
32*9880d681SAndroid Build Coastguard Worker; Like f2, but with a conditional store.
33*9880d681SAndroid Build Coastguard Workerdefine void @f3(float %val, i8 *%ptr, i32 %which) {
34*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f3:
35*9880d681SAndroid Build Coastguard Worker; CHECK: ciblh %r3, 0, 0(%r14)
36*9880d681SAndroid Build Coastguard Worker
37*9880d681SAndroid Build Coastguard Worker; CHECK: lgdr [[REG:%r[0-5]]], %f0
38*9880d681SAndroid Build Coastguard Worker; CHECK: stch [[REG]], 0(%r2)
39*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14
40*9880d681SAndroid Build Coastguard Worker  %int = bitcast float %val to i32
41*9880d681SAndroid Build Coastguard Worker  %trunc = trunc i32 %int to i8
42*9880d681SAndroid Build Coastguard Worker  %old = load i8 , i8 *%ptr
43*9880d681SAndroid Build Coastguard Worker  %cmp = icmp eq i32 %which, 0
44*9880d681SAndroid Build Coastguard Worker  %res = select i1 %cmp, i8 %trunc, i8 %old
45*9880d681SAndroid Build Coastguard Worker  store i8 %res, i8 *%ptr
46*9880d681SAndroid Build Coastguard Worker  ret void
47*9880d681SAndroid Build Coastguard Worker}
48*9880d681SAndroid Build Coastguard Worker
49*9880d681SAndroid Build Coastguard Worker; ...and again with 16-bit memory.
50*9880d681SAndroid Build Coastguard Workerdefine void @f4(float %val, i16 *%ptr, i32 %which) {
51*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f4:
52*9880d681SAndroid Build Coastguard Worker; CHECK: ciblh %r3, 0, 0(%r14)
53*9880d681SAndroid Build Coastguard Worker; CHECK: lgdr [[REG:%r[0-5]]], %f0
54*9880d681SAndroid Build Coastguard Worker; CHECK: sthh [[REG]], 0(%r2)
55*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14
56*9880d681SAndroid Build Coastguard Worker  %int = bitcast float %val to i32
57*9880d681SAndroid Build Coastguard Worker  %trunc = trunc i32 %int to i16
58*9880d681SAndroid Build Coastguard Worker  %old = load i16 , i16 *%ptr
59*9880d681SAndroid Build Coastguard Worker  %cmp = icmp eq i32 %which, 0
60*9880d681SAndroid Build Coastguard Worker  %res = select i1 %cmp, i16 %trunc, i16 %old
61*9880d681SAndroid Build Coastguard Worker  store i16 %res, i16 *%ptr
62*9880d681SAndroid Build Coastguard Worker  ret void
63*9880d681SAndroid Build Coastguard Worker}
64