1; RUN: llc < %s -mtriple=ve | FileCheck %s
2
3;;; Test ‘fneg’ Instruction
4;;;
5;;; Syntax:
6;;;   <result> = fneg [fast-math flags]* <ty> <op1>   ; yields ty:result
7;;;
8;;; Overview:
9;;;    The ‘fneg’ instruction returns the negation of its operand.
10;;;
11;;; Arguments:
12;;;   The argument to the ‘fneg’ instruction must be a floating-point or
13;;;   vector of floating-point values.
14;;;
15;;; Semantics:
16;;;
17;;;   The value produced is a copy of the operand with its sign bit flipped.
18;;;   This instruction can also take any number of fast-math flags, which are
19;;;   optimization hints to enable otherwise unsafe floating-point
20;;;   optimizations.
21;;;
22;;; Example:
23;;;   <result> = fneg float %val          ; yields float:result = -%var
24;;;
25;;; Note:
26;;;   We test only float/double/fp128.
27
28; Function Attrs: norecurse nounwind readnone
29define float @fneg_float(float %0) {
30; CHECK-LABEL: fneg_float:
31; CHECK:       # %bb.0:
32; CHECK-NEXT:    sra.l %s0, %s0, 32
33; CHECK-NEXT:    lea %s1, -2147483648
34; CHECK-NEXT:    and %s1, %s1, (32)0
35; CHECK-NEXT:    xor %s0, %s0, %s1
36; CHECK-NEXT:    sll %s0, %s0, 32
37; CHECK-NEXT:    b.l.t (, %s10)
38  %2 = fneg float %0
39  ret float %2
40}
41
42; Function Attrs: norecurse nounwind readnone
43define double @fneg_double(double %0) {
44; CHECK-LABEL: fneg_double:
45; CHECK:       # %bb.0:
46; CHECK-NEXT:    xor %s0, %s0, (1)1
47; CHECK-NEXT:    b.l.t (, %s10)
48  %2 = fneg double %0
49  ret double %2
50}
51
52; Function Attrs: norecurse nounwind readnone
53define fp128 @fneg_quad(fp128 %0) {
54; CHECK-LABEL: fneg_quad:
55; CHECK:       .LBB{{[0-9]+}}_2:
56; CHECK-NEXT:    st %s1, (, %s11)
57; CHECK-NEXT:    st %s0, 8(, %s11)
58; CHECK-NEXT:    ld1b.zx %s0, 15(, %s11)
59; CHECK-NEXT:    lea %s1, 128
60; CHECK-NEXT:    xor %s0, %s0, %s1
61; CHECK-NEXT:    st1b %s0, 15(, %s11)
62; CHECK-NEXT:    ld %s1, (, %s11)
63; CHECK-NEXT:    ld %s0, 8(, %s11)
64; CHECK-NEXT:    adds.l %s11, 16, %s11
65; CHECK-NEXT:    b.l.t (, %s10)
66  %2 = fneg fp128 %0
67  ret fp128 %2
68}
69