blob: aa6df209035bfbf9c40aca18f5ae730e6b5d69b9 [file] [log] [blame]
Marek Olsakfa6607d2015-02-11 14:26:46 +00001; RUN: llc -march=amdgcn -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=GCN -check-prefix=FUNC %s
2; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=VI -check-prefix=GCN -check-prefix=FUNC %s
Matt Arsenault13623d02014-08-15 18:42:18 +00003
Tom Stellard79243d92014-10-01 17:15:17 +00004; FUNC-LABEL: {{^}}fneg_f64:
Marek Olsakfa6607d2015-02-11 14:26:46 +00005; GCN: v_xor_b32
Matt Arsenault13623d02014-08-15 18:42:18 +00006define void @fneg_f64(double addrspace(1)* %out, double %in) {
7 %fneg = fsub double -0.000000e+00, %in
8 store double %fneg, double addrspace(1)* %out
9 ret void
10}
11
Tom Stellard79243d92014-10-01 17:15:17 +000012; FUNC-LABEL: {{^}}fneg_v2f64:
Marek Olsakfa6607d2015-02-11 14:26:46 +000013; GCN: v_xor_b32
14; GCN: v_xor_b32
Matt Arsenault13623d02014-08-15 18:42:18 +000015define void @fneg_v2f64(<2 x double> addrspace(1)* nocapture %out, <2 x double> %in) {
16 %fneg = fsub <2 x double> <double -0.000000e+00, double -0.000000e+00>, %in
17 store <2 x double> %fneg, <2 x double> addrspace(1)* %out
18 ret void
19}
20
Tom Stellard79243d92014-10-01 17:15:17 +000021; FUNC-LABEL: {{^}}fneg_v4f64:
Matt Arsenault13623d02014-08-15 18:42:18 +000022; R600: -PV
23; R600: -T
24; R600: -PV
25; R600: -PV
26
Marek Olsakfa6607d2015-02-11 14:26:46 +000027; GCN: v_xor_b32
28; GCN: v_xor_b32
29; GCN: v_xor_b32
30; GCN: v_xor_b32
Matt Arsenault13623d02014-08-15 18:42:18 +000031define void @fneg_v4f64(<4 x double> addrspace(1)* nocapture %out, <4 x double> %in) {
32 %fneg = fsub <4 x double> <double -0.000000e+00, double -0.000000e+00, double -0.000000e+00, double -0.000000e+00>, %in
33 store <4 x double> %fneg, <4 x double> addrspace(1)* %out
34 ret void
35}
36
37; DAGCombiner will transform:
38; (fneg (f64 bitcast (i64 a))) => (f64 bitcast (xor (i64 a), 0x80000000))
39; unless the target returns true for isNegFree()
40
Tom Stellard79243d92014-10-01 17:15:17 +000041; FUNC-LABEL: {{^}}fneg_free_f64:
Matt Arsenault20711b72015-02-20 22:10:45 +000042; GCN: v_add_f64 {{v\[[0-9]+:[0-9]+\]}}, 0, -{{s\[[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
Marek Olsakfa6607d2015-02-11 14:26:46 +000050; GCN-LABEL: {{^}}fneg_fold_f64:
Tom Stellard326d6ec2014-11-05 14:50:53 +000051; SI: s_load_dwordx2 [[NEG_VALUE:s\[[0-9]+:[0-9]+\]]], {{s\[[0-9]+:[0-9]+\]}}, 0xb
Marek Olsakfa6607d2015-02-11 14:26:46 +000052; VI: s_load_dwordx2 [[NEG_VALUE:s\[[0-9]+:[0-9]+\]]], {{s\[[0-9]+:[0-9]+\]}}, 0x2c
53; GCN-NOT: xor
54; GCN: v_mul_f64 {{v\[[0-9]+:[0-9]+\]}}, -[[NEG_VALUE]], [[NEG_VALUE]]
Matt Arsenault13623d02014-08-15 18:42:18 +000055define void @fneg_fold_f64(double addrspace(1)* %out, double %in) {
56 %fsub = fsub double -0.0, %in
57 %fmul = fmul double %fsub, %in
58 store double %fmul, double addrspace(1)* %out
59 ret void
60}