fma-fneg-combine-2.ll
3.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mattr=+avx,fma | FileCheck %s --check-prefixes=CHECK,FMA3
; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mattr=+avx,fma4 | FileCheck %s --check-prefixes=CHECK,FMA4
define float @test_fneg_fma_subx_y_negz_f32(float %w, float %x, float %y, float %z) {
; FMA3-LABEL: test_fneg_fma_subx_y_negz_f32:
; FMA3: # %bb.0: # %entry
; FMA3-NEXT: vsubss %xmm0, %xmm1, %xmm0
; FMA3-NEXT: vfmadd213ss {{.*#+}} xmm0 = (xmm2 * xmm0) + xmm3
; FMA3-NEXT: retq
;
; FMA4-LABEL: test_fneg_fma_subx_y_negz_f32:
; FMA4: # %bb.0: # %entry
; FMA4-NEXT: vsubss %xmm0, %xmm1, %xmm0
; FMA4-NEXT: vfmaddss %xmm3, %xmm2, %xmm0, %xmm0
; FMA4-NEXT: retq
entry:
%subx = fsub nsz float %w, %x
%negz = fsub float -0.000000e+00, %z
%0 = tail call nsz float @llvm.fma.f32(float %subx, float %y, float %negz)
%1 = fsub float -0.000000e+00, %0
ret float %1
}
define float @test_fneg_fma_x_suby_negz_f32(float %w, float %x, float %y, float %z) {
; FMA3-LABEL: test_fneg_fma_x_suby_negz_f32:
; FMA3: # %bb.0: # %entry
; FMA3-NEXT: vsubss %xmm0, %xmm2, %xmm0
; FMA3-NEXT: vfmadd213ss {{.*#+}} xmm0 = (xmm1 * xmm0) + xmm3
; FMA3-NEXT: retq
;
; FMA4-LABEL: test_fneg_fma_x_suby_negz_f32:
; FMA4: # %bb.0: # %entry
; FMA4-NEXT: vsubss %xmm0, %xmm2, %xmm0
; FMA4-NEXT: vfmaddss %xmm3, %xmm0, %xmm1, %xmm0
; FMA4-NEXT: retq
entry:
%suby = fsub nsz float %w, %y
%negz = fsub float -0.000000e+00, %z
%0 = tail call nsz float @llvm.fma.f32(float %x, float %suby, float %negz)
%1 = fsub float -0.000000e+00, %0
ret float %1
}
define float @test_fneg_fma_subx_suby_negz_f32(float %w, float %x, float %y, float %z) {
; FMA3-LABEL: test_fneg_fma_subx_suby_negz_f32:
; FMA3: # %bb.0: # %entry
; FMA3-NEXT: vsubss %xmm1, %xmm0, %xmm1
; FMA3-NEXT: vsubss %xmm0, %xmm2, %xmm0
; FMA3-NEXT: vfmadd213ss {{.*#+}} xmm0 = (xmm1 * xmm0) + xmm3
; FMA3-NEXT: retq
;
; FMA4-LABEL: test_fneg_fma_subx_suby_negz_f32:
; FMA4: # %bb.0: # %entry
; FMA4-NEXT: vsubss %xmm1, %xmm0, %xmm1
; FMA4-NEXT: vsubss %xmm0, %xmm2, %xmm0
; FMA4-NEXT: vfmaddss %xmm3, %xmm0, %xmm1, %xmm0
; FMA4-NEXT: retq
entry:
%subx = fsub nsz float %w, %x
%suby = fsub nsz float %w, %y
%negz = fsub float -0.000000e+00, %z
%0 = tail call nsz float @llvm.fma.f32(float %subx, float %suby, float %negz)
%1 = fsub float -0.000000e+00, %0
ret float %1
}
define float @test_fneg_fma_subx_negy_negz_f32(float %w, float %x, float %y, float %z) {
; FMA3-LABEL: test_fneg_fma_subx_negy_negz_f32:
; FMA3: # %bb.0: # %entry
; FMA3-NEXT: vsubss %xmm1, %xmm0, %xmm0
; FMA3-NEXT: vfmadd213ss {{.*#+}} xmm0 = (xmm2 * xmm0) + xmm3
; FMA3-NEXT: retq
;
; FMA4-LABEL: test_fneg_fma_subx_negy_negz_f32:
; FMA4: # %bb.0: # %entry
; FMA4-NEXT: vsubss %xmm1, %xmm0, %xmm0
; FMA4-NEXT: vfmaddss %xmm3, %xmm2, %xmm0, %xmm0
; FMA4-NEXT: retq
entry:
%subx = fsub nsz float %w, %x
%negy = fsub float -0.000000e+00, %y
%negz = fsub float -0.000000e+00, %z
%0 = tail call nsz float @llvm.fma.f32(float %subx, float %negy, float %negz)
%1 = fsub float -0.000000e+00, %0
ret float %1
}
; This would crash while trying getNegatedExpression().
define float @negated_constant(float %x) {
; FMA3-LABEL: negated_constant:
; FMA3: # %bb.0:
; FMA3-NEXT: vmulss {{.*}}(%rip), %xmm0, %xmm1
; FMA3-NEXT: vfmadd132ss {{.*#+}} xmm0 = (xmm0 * mem) + xmm1
; FMA3-NEXT: retq
;
; FMA4-LABEL: negated_constant:
; FMA4: # %bb.0:
; FMA4-NEXT: vmulss {{.*}}(%rip), %xmm0, %xmm1
; FMA4-NEXT: vfmaddss %xmm1, {{.*}}(%rip), %xmm0, %xmm0
; FMA4-NEXT: retq
%m = fmul float %x, 42.0
%fma = call nsz float @llvm.fma.f32(float %x, float -42.0, float %m)
%nfma = fneg float %fma
ret float %nfma
}
declare float @llvm.fma.f32(float, float, float)