blob: 68a1c0f2320bae7b161f70020be426efe1db6f4e [file] [log] [blame]
Matt Arsenault13623d02014-08-15 18:42:18 +00001; RUN: llc -march=r600 -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
2
Tom Stellard79243d92014-10-01 17:15:17 +00003; FUNC-LABEL: {{^}}fneg_f64:
Matt Arsenault13623d02014-08-15 18:42:18 +00004; SI: V_XOR_B32
5define void @fneg_f64(double addrspace(1)* %out, double %in) {
6 %fneg = fsub double -0.000000e+00, %in
7 store double %fneg, double addrspace(1)* %out
8 ret void
9}
10
Tom Stellard79243d92014-10-01 17:15:17 +000011; FUNC-LABEL: {{^}}fneg_v2f64:
Matt Arsenault13623d02014-08-15 18:42:18 +000012; SI: V_XOR_B32
13; SI: V_XOR_B32
14define void @fneg_v2f64(<2 x double> addrspace(1)* nocapture %out, <2 x double> %in) {
15 %fneg = fsub <2 x double> <double -0.000000e+00, double -0.000000e+00>, %in
16 store <2 x double> %fneg, <2 x double> addrspace(1)* %out
17 ret void
18}
19
Tom Stellard79243d92014-10-01 17:15:17 +000020; FUNC-LABEL: {{^}}fneg_v4f64:
Matt Arsenault13623d02014-08-15 18:42:18 +000021; R600: -PV
22; R600: -T
23; R600: -PV
24; R600: -PV
25
26; SI: V_XOR_B32
27; SI: V_XOR_B32
28; SI: V_XOR_B32
29; SI: V_XOR_B32
30define void @fneg_v4f64(<4 x double> addrspace(1)* nocapture %out, <4 x double> %in) {
31 %fneg = fsub <4 x double> <double -0.000000e+00, double -0.000000e+00, double -0.000000e+00, double -0.000000e+00>, %in
32 store <4 x double> %fneg, <4 x double> addrspace(1)* %out
33 ret void
34}
35
36; DAGCombiner will transform:
37; (fneg (f64 bitcast (i64 a))) => (f64 bitcast (xor (i64 a), 0x80000000))
38; unless the target returns true for isNegFree()
39
Tom Stellard79243d92014-10-01 17:15:17 +000040; FUNC-LABEL: {{^}}fneg_free_f64:
Matt Arsenault13623d02014-08-15 18:42:18 +000041; FIXME: Unnecessary copy to VGPRs
Matt Arsenault97069782014-09-30 19:49:48 +000042; SI: V_ADD_F64 {{v\[[0-9]+:[0-9]+\]}}, {{v\[[0-9]+:[0-9]+\]}}, -{{v\[[0-9]+:[0-9]+\]$}}
Matt Arsenault13623d02014-08-15 18:42:18 +000043define void @fneg_free_f64(double addrspace(1)* %out, i64 %in) {
44 %bc = bitcast i64 %in to double
45 %fsub = fsub double 0.0, %bc
46 store double %fsub, double addrspace(1)* %out
47 ret void
48}
49
Tom Stellard79243d92014-10-01 17:15:17 +000050; SI-LABEL: {{^}}fneg_fold_f64:
Matt Arsenault13623d02014-08-15 18:42:18 +000051; SI: S_LOAD_DWORDX2 [[NEG_VALUE:s\[[0-9]+:[0-9]+\]]], {{s\[[0-9]+:[0-9]+\]}}, 0xb
52; SI-NOT: XOR
Matt Arsenaultcb0ac3d2014-09-26 17:54:59 +000053; SI: V_MUL_F64 {{v\[[0-9]+:[0-9]+\]}}, -[[NEG_VALUE]], [[NEG_VALUE]]
Matt Arsenault13623d02014-08-15 18:42:18 +000054define void @fneg_fold_f64(double addrspace(1)* %out, double %in) {
55 %fsub = fsub double -0.0, %in
56 %fmul = fmul double %fsub, %in
57 store double %fmul, double addrspace(1)* %out
58 ret void
59}