1; Test floating-point negation on z14.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z14 | FileCheck %s
4
5; Test f32.
6define float @f1(float %f) {
7; CHECK-LABEL: f1:
8; CHECK: lcdfr %f0, %f0
9; CHECK: br %r14
10  %res = fneg float %f
11  ret float %res
12}
13
14; Test f64.
15define double @f2(double %f) {
16; CHECK-LABEL: f2:
17; CHECK: lcdfr %f0, %f0
18; CHECK: br %r14
19  %res = fneg double %f
20  ret double %res
21}
22
23; Test f128.  With the loads and stores, a pure negation would probably
24; be better implemented using an XI on the upper byte.  Do some extra
25; processing so that using FPRs is unequivocally better.
26define void @f3(fp128 *%ptr, fp128 *%ptr2) {
27; CHECK-LABEL: f3:
28; CHECK-DAG: vl [[REG1:%v[0-9]+]], 0(%r2)
29; CHECK-DAG: vl [[REG2:%v[0-9]+]], 0(%r3)
30; CHECK-DAG: wflcxb [[NEGREG1:%v[0-9]+]], [[REG1]]
31; CHECK: wfdxb [[RES:%v[0-9]+]], [[NEGREG1]], [[REG2]]
32; CHECK: vst [[RES]], 0(%r2)
33; CHECK: br %r14
34  %orig = load fp128, fp128 *%ptr
35  %negzero = fpext float -0.0 to fp128
36  %neg = fneg fp128 %orig
37  %op2 = load fp128, fp128 *%ptr2
38  %res = fdiv fp128 %neg, %op2
39  store fp128 %res, fp128 *%ptr
40  ret void
41}
42