blob: 5b478177ace244897f1b19788e0708b640753970 [file] [log] [blame]
Tom Stellard82166022013-11-13 23:36:37 +00001; RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s --check-prefix=R600-CHECK
2; RUN: llc < %s -march=r600 -mcpu=SI -verify-machineinstrs | FileCheck %s --check-prefix=SI-CHECK
Tom Stellardbeed74a2013-07-23 01:47:46 +00003
Tom Stellard82166022013-11-13 23:36:37 +00004; R600-CHECK-LABEL: @fneg
5; R600-CHECK: -PV
6; SI-CHECK-LABEL: @fneg
Michel Danzer624b02a2014-02-04 07:12:38 +00007; SI-CHECK: V_XOR_B32
Tom Stellard82166022013-11-13 23:36:37 +00008define void @fneg(float addrspace(1)* %out, float %in) {
9entry:
10 %0 = fsub float -0.000000e+00, %in
11 store float %0, float addrspace(1)* %out
12 ret void
13}
14
15; R600-CHECK-LABEL: @fneg_v2
16; R600-CHECK: -PV
17; R600-CHECK: -PV
18; SI-CHECK-LABEL: @fneg_v2
Michel Danzer624b02a2014-02-04 07:12:38 +000019; SI-CHECK: V_XOR_B32
20; SI-CHECK: V_XOR_B32
Tom Stellardbeed74a2013-07-23 01:47:46 +000021define void @fneg_v2(<2 x float> addrspace(1)* nocapture %out, <2 x float> %in) {
22entry:
23 %0 = fsub <2 x float> <float -0.000000e+00, float -0.000000e+00>, %in
24 store <2 x float> %0, <2 x float> addrspace(1)* %out
25 ret void
26}
27
Tom Stellarda66cafa2013-10-23 00:44:12 +000028; R600-CHECK-LABEL: @fneg_v4
29; R600-CHECK: -PV
30; R600-CHECK: -T
31; R600-CHECK: -PV
32; R600-CHECK: -PV
33; SI-CHECK-LABEL: @fneg_v4
Michel Danzer624b02a2014-02-04 07:12:38 +000034; SI-CHECK: V_XOR_B32
35; SI-CHECK: V_XOR_B32
36; SI-CHECK: V_XOR_B32
37; SI-CHECK: V_XOR_B32
Tom Stellardbeed74a2013-07-23 01:47:46 +000038define void @fneg_v4(<4 x float> addrspace(1)* nocapture %out, <4 x float> %in) {
39entry:
40 %0 = fsub <4 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %in
41 store <4 x float> %0, <4 x float> addrspace(1)* %out
42 ret void
43}
Tom Stellardc54731a2013-07-23 23:55:03 +000044
45; DAGCombiner will transform:
46; (fneg (f32 bitcast (i32 a))) => (f32 bitcast (xor (i32 a), 0x80000000))
47; unless the target returns true for isNegFree()
48
Tom Stellard82166022013-11-13 23:36:37 +000049; R600-CHECK-LABEL: @fneg_free
50; R600-CHECK-NOT: XOR
51; R600-CHECK: -KC0[2].Z
52; SI-CHECK-LABEL: @fneg_free
53; XXX: We could use V_ADD_F32_e64 with the negate bit here instead.
Vincent Lejeune94af31f2014-05-10 19:18:33 +000054; SI-CHECK: V_SUB_F32_e64 v{{[0-9]}}, 0.000000e+00, s{{[0-9]}}, 0, 0
Tom Stellardc54731a2013-07-23 23:55:03 +000055define void @fneg_free(float addrspace(1)* %out, i32 %in) {
56entry:
57 %0 = bitcast i32 %in to float
58 %1 = fsub float 0.0, %0
59 store float %1, float addrspace(1)* %out
60 ret void
61}
Vincent Lejeune29c0c212014-05-10 19:18:39 +000062
63; SI-CHECK-LABEL: @fneg_fold
Tom Stellardb4a313a2014-08-01 00:32:39 +000064; SI-CHECK: S_LOAD_DWORD [[NEG_VALUE:s[0-9]+]], s[{{[0-9]+:[0-9]+}}], 0xb
Vincent Lejeune29c0c212014-05-10 19:18:39 +000065; SI-CHECK-NOT: V_XOR_B32
Tom Stellardb4a313a2014-08-01 00:32:39 +000066; SI-CHECK: V_MUL_F32_e64 v{{[0-9]+}}, -[[NEG_VALUE]], v{{[0-9]+}}
Vincent Lejeune29c0c212014-05-10 19:18:39 +000067define void @fneg_fold(float addrspace(1)* %out, float %in) {
68entry:
69 %0 = fsub float -0.0, %in
70 %1 = fmul float %0, %in
71 store float %1, float addrspace(1)* %out
72 ret void
73}