llvm.org GIT mirror llvm / 92c9045
Match (fneg (fma) to vfnma. rdar://10139676 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154469 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 8 years ago
2 changed file(s) with 33 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
11381138 def : Pat<(fsub_mlx (fneg (fmul_su SPR:$a, SPR:$b)), SPR:$dstin),
11391139 (VFNMAS SPR:$dstin, SPR:$a, SPR:$b)>,
11401140 Requires<[HasVFP4,DontUseNEONForFP,FPContractions]>;
1141
1142 // Match @llvm.fma.* intrinsics
1143 def : Pat<(fneg (fma (f64 DPR:$Ddin), (f64 DPR:$Dn), (f64 DPR:$Dm))),
1144 (VFNMAD DPR:$Ddin, DPR:$Dn, DPR:$Dm)>,
1145 Requires<[HasVFP4]>;
1146 def : Pat<(fneg (fma (f32 SPR:$Sdin), (f32 SPR:$Sn), (f32 SPR:$Sm))),
1147 (VFNMAS SPR:$Sdin, SPR:$Sn, SPR:$Sm)>,
1148 Requires<[HasVFP4]>;
11411149
11421150 def VFNMSD : ADbI<0b11101, 0b01, 0, 0,
11431151 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
9898 ret <4 x float> %sub
9999 }
100100
101 define float @test_f32(float %a, float %b, float %c) nounwind readnone ssp {
101 define float @test_fma_f32(float %a, float %b, float %c) nounwind readnone ssp {
102102 entry:
103 ; CHECK: test_f32
103 ; CHECK: test_fma_f32
104104 ; CHECK: vfma.f32
105105 %call = tail call float @llvm.fma.f32(float %a, float %b, float %c) nounwind readnone
106106 ret float %call
107107 }
108108
109 define double @test_f64(double %a, double %b, double %c) nounwind readnone ssp {
109 define double @test_fma_f64(double %a, double %b, double %c) nounwind readnone ssp {
110110 entry:
111 ; CHECK: test_f64
111 ; CHECK: test_fma_f64
112112 ; CHECK: vfma.f64
113113 %call = tail call double @llvm.fma.f64(double %a, double %b, double %c) nounwind readnone
114114 ret double %call
115115 }
116116
117 define <2 x float> @test_v2f32(<2 x float> %a, <2 x float> %b, <2 x float> %c) nounwind readnone ssp {
117 define <2 x float> @test_fma_v2f32(<2 x float> %a, <2 x float> %b, <2 x float> %c) nounwind readnone ssp {
118118 entry:
119 ; CHECK: test_v2f32
119 ; CHECK: test_fma_v2f32
120120 ; CHECK: vfma.f32
121121 %0 = tail call <2 x float> @llvm.fma.v2f32(<2 x float> %a, <2 x float> %b, <2 x float> %c) nounwind
122122 ret <2 x float> %0
123123 }
124124
125 define float @test_fnma_f32(float %a, float %b, float %c) nounwind readnone ssp {
126 entry:
127 ; CHECK: test_fnma_f32
128 ; CHECK: vfnma.f32
129 %call = tail call float @llvm.fma.f32(float %a, float %b, float %c) nounwind readnone
130 %tmp1 = fsub float -0.0, %call
131 %tmp2 = fsub float %tmp1, %c
132 ret float %tmp2
133 }
134
135 define double @test_fnma_f64(double %a, double %b, double %c) nounwind readnone ssp {
136 entry:
137 ; CHECK: test_fnma_f64
138 ; CHECK: vfnma.f64
139 %call = tail call double @llvm.fma.f64(double %a, double %b, double %c) nounwind readnone
140 %tmp = fsub double -0.0, %call
141 ret double %tmp
142 }
143
125144 declare float @llvm.fma.f32(float, float, float) nounwind readnone
126145 declare double @llvm.fma.f64(double, double, double) nounwind readnone
127146 declare <2 x float> @llvm.fma.v2f32(<2 x float>, <2 x float>, <2 x float>) nounwind readnone