64 lines · plain
1; Test moves between FPRs and GPRs for z196 and zEC12.2;3; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z196 | FileCheck %s4 5; Check that moves from i32s to floats can use high registers.6define float @f1(ptr %ptr) {7; CHECK-LABEL: f1:8; CHECK: llhh [[REG:%r[0-5]]], 0(%r2)9; CHECK: oihh [[REG]], 1625610; CHECK: ldgr %f0, [[REG]]11; CHECK: br %r1412 %base = load i16, ptr %ptr13 %ext = zext i16 %base to i3214 %full = or i32 %ext, 106535321615 %res = bitcast i32 %full to float16 ret float %res17}18 19; Check that moves from floats to i32s can use high registers.20; This "store the low byte" technique is used by llvmpipe, for example.21define void @f2(float %val, ptr %ptr) {22; CHECK-LABEL: f2:23; CHECK: lgdr [[REG:%r[0-5]]], %f024; CHECK: stch [[REG]], 0(%r2)25; CHECK: br %r1426 %res = bitcast float %val to i3227 %trunc = trunc i32 %res to i828 store i8 %trunc, ptr %ptr29 ret void30}31 32; Like f2, but with a conditional store.33define void @f3(float %val, ptr %ptr, i32 %which) {34; CHECK-LABEL: f3:35; CHECK: ciblh %r3, 0, 0(%r14)36 37; CHECK: lgdr [[REG:%r[0-5]]], %f038; CHECK: stch [[REG]], 0(%r2)39; CHECK: br %r1440 %int = bitcast float %val to i3241 %trunc = trunc i32 %int to i842 %old = load i8, ptr %ptr43 %cmp = icmp eq i32 %which, 044 %res = select i1 %cmp, i8 %trunc, i8 %old45 store i8 %res, ptr %ptr46 ret void47}48 49; ...and again with 16-bit memory.50define void @f4(float %val, ptr %ptr, i32 %which) {51; CHECK-LABEL: f4:52; CHECK: ciblh %r3, 0, 0(%r14)53; CHECK: lgdr [[REG:%r[0-5]]], %f054; CHECK: sthh [[REG]], 0(%r2)55; CHECK: br %r1456 %int = bitcast float %val to i3257 %trunc = trunc i32 %int to i1658 %old = load i16, ptr %ptr59 %cmp = icmp eq i32 %which, 060 %res = select i1 %cmp, i16 %trunc, i16 %old61 store i16 %res, ptr %ptr62 ret void63}64