blob: b9810f9f34d3e4369b1bddf7af892d2409afbfdb [file] [log] [blame]
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00001; Test floating-point negation.
2;
Ulrich Weigand49506d72015-05-05 19:28:34 +00003; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z10 | FileCheck %s
4; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 | FileCheck %s
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00005
6; Test f32.
7define float @f1(float %f) {
Stephen Lind24ab202013-07-14 06:24:09 +00008; CHECK-LABEL: f1:
Jonas Paulsson12629322015-10-01 18:12:28 +00009; CHECK: lcdfr %f0, %f0
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000010; CHECK: br %r14
11 %res = fsub float -0.0, %f
12 ret float %res
13}
14
15; Test f64.
16define double @f2(double %f) {
Stephen Lind24ab202013-07-14 06:24:09 +000017; CHECK-LABEL: f2:
Jonas Paulsson12629322015-10-01 18:12:28 +000018; CHECK: lcdfr %f0, %f0
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000019; CHECK: br %r14
20 %res = fsub double -0.0, %f
21 ret double %res
22}
23
24; Test f128. With the loads and stores, a pure negation would probably
25; be better implemented using an XI on the upper byte. Do some extra
26; processing so that using FPRs is unequivocally better.
27define void @f3(fp128 *%ptr, fp128 *%ptr2) {
Stephen Lind24ab202013-07-14 06:24:09 +000028; CHECK-LABEL: f3:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000029; CHECK: lcxbr
30; CHECK: dxbr
31; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000032 %orig = load fp128 , fp128 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000033 %negzero = fpext float -0.0 to fp128
34 %neg = fsub fp128 0xL00000000000000008000000000000000, %orig
David Blaikiea79ac142015-02-27 21:17:42 +000035 %op2 = load fp128 , fp128 *%ptr2
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000036 %res = fdiv fp128 %neg, %op2
37 store fp128 %res, fp128 *%ptr
38 ret void
39}