|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py |
| 2 | +; RUN: llc < %s -mtriple powerpc64le -verify-machineinstrs \ |
| 3 | +; RUN: | FileCheck -check-prefix=VSX %s |
| 4 | +; RUN: llc < %s -mtriple powerpc64le -verify-machineinstrs -mattr=-vsx \ |
| 5 | +; RUN: | FileCheck -check-prefix=NO-VSX %s |
| 6 | + |
| 7 | +define double @test_mul_sub_f64(double %a, double %b, double %c) { |
| 8 | +; VSX-LABEL: test_mul_sub_f64: |
| 9 | +; VSX: # %bb.0: # %entry |
| 10 | +; VSX-NEXT: xsnmsubadp 1, 2, 3 |
| 11 | +; VSX-NEXT: blr |
| 12 | +; |
| 13 | +; NO-VSX-LABEL: test_mul_sub_f64: |
| 14 | +; NO-VSX: # %bb.0: # %entry |
| 15 | +; NO-VSX-NEXT: fnmsub 1, 2, 3, 1 |
| 16 | +; NO-VSX-NEXT: blr |
| 17 | +entry: |
| 18 | + %0 = fmul contract reassoc double %b, %c |
| 19 | + %1 = fsub contract reassoc double %a, %0 |
| 20 | + ret double %1 |
| 21 | +} |
| 22 | + |
| 23 | +define double @test_2mul_sub_f64(double %a, double %b, double %c, double %d) { |
| 24 | +; VSX-LABEL: test_2mul_sub_f64: |
| 25 | +; VSX: # %bb.0: # %entry |
| 26 | +; VSX-NEXT: xsmuldp 0, 3, 4 |
| 27 | +; VSX-NEXT: xsmsubadp 0, 1, 2 |
| 28 | +; VSX-NEXT: fmr 1, 0 |
| 29 | +; VSX-NEXT: blr |
| 30 | +; |
| 31 | +; NO-VSX-LABEL: test_2mul_sub_f64: |
| 32 | +; NO-VSX: # %bb.0: # %entry |
| 33 | +; NO-VSX-NEXT: fmul 0, 3, 4 |
| 34 | +; NO-VSX-NEXT: fmsub 1, 1, 2, 0 |
| 35 | +; NO-VSX-NEXT: blr |
| 36 | +entry: |
| 37 | + %0 = fmul contract reassoc double %a, %b |
| 38 | + %1 = fmul contract reassoc double %c, %d |
| 39 | + %2 = fsub contract reassoc double %0, %1 |
| 40 | + ret double %2 |
| 41 | +} |
| 42 | + |
| 43 | +define double @test_neg_fma_f64(double %a, double %b, double %c) { |
| 44 | +; VSX-LABEL: test_neg_fma_f64: |
| 45 | +; VSX: # %bb.0: # %entry |
| 46 | +; VSX-NEXT: xsnmsubadp 3, 1, 2 |
| 47 | +; VSX-NEXT: fmr 1, 3 |
| 48 | +; VSX-NEXT: blr |
| 49 | +; |
| 50 | +; NO-VSX-LABEL: test_neg_fma_f64: |
| 51 | +; NO-VSX: # %bb.0: # %entry |
| 52 | +; NO-VSX-NEXT: fnmsub 1, 1, 2, 3 |
| 53 | +; NO-VSX-NEXT: blr |
| 54 | +entry: |
| 55 | + %0 = fsub contract reassoc double -0.0, %a |
| 56 | + %1 = call contract reassoc double @llvm.fma.f64(double %0, double %b, |
| 57 | + double %c) |
| 58 | + ret double %1 |
| 59 | +} |
| 60 | + |
| 61 | +define float @test_mul_sub_f32(float %a, float %b, float %c) { |
| 62 | +; VSX-LABEL: test_mul_sub_f32: |
| 63 | +; VSX: # %bb.0: # %entry |
| 64 | +; VSX-NEXT: xsnmsubasp 1, 2, 3 |
| 65 | +; VSX-NEXT: blr |
| 66 | +; |
| 67 | +; NO-VSX-LABEL: test_mul_sub_f32: |
| 68 | +; NO-VSX: # %bb.0: # %entry |
| 69 | +; NO-VSX-NEXT: fnmsubs 1, 2, 3, 1 |
| 70 | +; NO-VSX-NEXT: blr |
| 71 | +entry: |
| 72 | + %0 = fmul contract reassoc float %b, %c |
| 73 | + %1 = fsub contract reassoc float %a, %0 |
| 74 | + ret float %1 |
| 75 | +} |
| 76 | + |
| 77 | +define float @test_2mul_sub_f32(float %a, float %b, float %c, float %d) { |
| 78 | +; VSX-LABEL: test_2mul_sub_f32: |
| 79 | +; VSX: # %bb.0: # %entry |
| 80 | +; VSX-NEXT: xsmulsp 0, 3, 4 |
| 81 | +; VSX-NEXT: xsmsubasp 0, 1, 2 |
| 82 | +; VSX-NEXT: fmr 1, 0 |
| 83 | +; VSX-NEXT: blr |
| 84 | +; |
| 85 | +; NO-VSX-LABEL: test_2mul_sub_f32: |
| 86 | +; NO-VSX: # %bb.0: # %entry |
| 87 | +; NO-VSX-NEXT: fmuls 0, 3, 4 |
| 88 | +; NO-VSX-NEXT: fmsubs 1, 1, 2, 0 |
| 89 | +; NO-VSX-NEXT: blr |
| 90 | +entry: |
| 91 | + %0 = fmul contract reassoc float %a, %b |
| 92 | + %1 = fmul contract reassoc float %c, %d |
| 93 | + %2 = fsub contract reassoc float %0, %1 |
| 94 | + ret float %2 |
| 95 | +} |
| 96 | + |
| 97 | +define float @test_neg_fma_f32(float %a, float %b, float %c) { |
| 98 | +; VSX-LABEL: test_neg_fma_f32: |
| 99 | +; VSX: # %bb.0: # %entry |
| 100 | +; VSX-NEXT: xsnmsubasp 3, 1, 2 |
| 101 | +; VSX-NEXT: fmr 1, 3 |
| 102 | +; VSX-NEXT: blr |
| 103 | +; |
| 104 | +; NO-VSX-LABEL: test_neg_fma_f32: |
| 105 | +; NO-VSX: # %bb.0: # %entry |
| 106 | +; NO-VSX-NEXT: fnmsubs 1, 1, 2, 3 |
| 107 | +; NO-VSX-NEXT: blr |
| 108 | +entry: |
| 109 | + %0 = fsub contract reassoc float -0.0, %a |
| 110 | + %1 = call contract reassoc float @llvm.fma.f32(float %0, float %b, float %c) |
| 111 | + ret float %1 |
| 112 | +} |
| 113 | + |
| 114 | +define <2 x double> @test_neg_fma_v2f64(<2 x double> %a, <2 x double> %b, |
| 115 | +; VSX-LABEL: test_neg_fma_v2f64: |
| 116 | +; VSX: # %bb.0: # %entry |
| 117 | +; VSX-NEXT: xvnmsubadp 36, 34, 35 |
| 118 | +; VSX-NEXT: vmr 2, 4 |
| 119 | +; VSX-NEXT: blr |
| 120 | +; |
| 121 | +; NO-VSX-LABEL: test_neg_fma_v2f64: |
| 122 | +; NO-VSX: # %bb.0: # %entry |
| 123 | +; NO-VSX-NEXT: fnmsub 1, 1, 3, 5 |
| 124 | +; NO-VSX-NEXT: fnmsub 2, 2, 4, 6 |
| 125 | +; NO-VSX-NEXT: blr |
| 126 | + <2 x double> %c) { |
| 127 | +entry: |
| 128 | + %0 = fsub contract reassoc <2 x double> <double -0.0, double -0.0>, %a |
| 129 | + %1 = call contract reassoc <2 x double> @llvm.fma.v2f64(<2 x double> %0, |
| 130 | + <2 x double> %b, |
| 131 | + <2 x double> %c) |
| 132 | + ret <2 x double> %1 |
| 133 | +} |
| 134 | + |
| 135 | +define <4 x float> @test_neg_fma_v4f32(<4 x float> %a, <4 x float> %b, |
| 136 | +; VSX-LABEL: test_neg_fma_v4f32: |
| 137 | +; VSX: # %bb.0: # %entry |
| 138 | +; VSX-NEXT: xvnmsubasp 36, 34, 35 |
| 139 | +; VSX-NEXT: vmr 2, 4 |
| 140 | +; VSX-NEXT: blr |
| 141 | +; |
| 142 | +; NO-VSX-LABEL: test_neg_fma_v4f32: |
| 143 | +; NO-VSX: # %bb.0: # %entry |
| 144 | +; NO-VSX-NEXT: vspltisb 5, -1 |
| 145 | +; NO-VSX-NEXT: vslw 5, 5, 5 |
| 146 | +; NO-VSX-NEXT: vsubfp 2, 5, 2 |
| 147 | +; NO-VSX-NEXT: vmaddfp 2, 2, 3, 4 |
| 148 | +; NO-VSX-NEXT: blr |
| 149 | + <4 x float> %c) { |
| 150 | +entry: |
| 151 | + %0 = fsub contract reassoc <4 x float> <float -0.0, float -0.0, float -0.0, |
| 152 | + float -0.0>, %a |
| 153 | + %1 = call contract reassoc <4 x float> @llvm.fma.v4f32(<4 x float> %0, |
| 154 | + <4 x float> %b, |
| 155 | + <4 x float> %c) |
| 156 | + ret <4 x float> %1 |
| 157 | +} |
| 158 | + |
| 159 | +define double @test_fast_mul_sub_f64(double %a, double %b, double %c) { |
| 160 | +; VSX-LABEL: test_fast_mul_sub_f64: |
| 161 | +; VSX: # %bb.0: # %entry |
| 162 | +; VSX-NEXT: xsnmsubadp 1, 2, 3 |
| 163 | +; VSX-NEXT: blr |
| 164 | +; |
| 165 | +; NO-VSX-LABEL: test_fast_mul_sub_f64: |
| 166 | +; NO-VSX: # %bb.0: # %entry |
| 167 | +; NO-VSX-NEXT: fnmsub 1, 2, 3, 1 |
| 168 | +; NO-VSX-NEXT: blr |
| 169 | +entry: |
| 170 | + %0 = fmul fast double %b, %c |
| 171 | + %1 = fsub fast double %a, %0 |
| 172 | + ret double %1 |
| 173 | +} |
| 174 | + |
| 175 | +define double @test_fast_2mul_sub_f64(double %a, double %b, double %c, |
| 176 | +; VSX-LABEL: test_fast_2mul_sub_f64: |
| 177 | +; VSX: # %bb.0: # %entry |
| 178 | +; VSX-NEXT: xsmuldp 0, 3, 4 |
| 179 | +; VSX-NEXT: xsmsubadp 0, 1, 2 |
| 180 | +; VSX-NEXT: fmr 1, 0 |
| 181 | +; VSX-NEXT: blr |
| 182 | +; |
| 183 | +; NO-VSX-LABEL: test_fast_2mul_sub_f64: |
| 184 | +; NO-VSX: # %bb.0: # %entry |
| 185 | +; NO-VSX-NEXT: fmul 0, 3, 4 |
| 186 | +; NO-VSX-NEXT: fmsub 1, 1, 2, 0 |
| 187 | +; NO-VSX-NEXT: blr |
| 188 | + double %d) { |
| 189 | +entry: |
| 190 | + %0 = fmul fast double %a, %b |
| 191 | + %1 = fmul fast double %c, %d |
| 192 | + %2 = fsub fast double %0, %1 |
| 193 | + ret double %2 |
| 194 | +} |
| 195 | + |
| 196 | +define double @test_fast_neg_fma_f64(double %a, double %b, double %c) { |
| 197 | +; VSX-LABEL: test_fast_neg_fma_f64: |
| 198 | +; VSX: # %bb.0: # %entry |
| 199 | +; VSX-NEXT: xsnmsubadp 3, 1, 2 |
| 200 | +; VSX-NEXT: fmr 1, 3 |
| 201 | +; VSX-NEXT: blr |
| 202 | +; |
| 203 | +; NO-VSX-LABEL: test_fast_neg_fma_f64: |
| 204 | +; NO-VSX: # %bb.0: # %entry |
| 205 | +; NO-VSX-NEXT: fnmsub 1, 1, 2, 3 |
| 206 | +; NO-VSX-NEXT: blr |
| 207 | +entry: |
| 208 | + %0 = fsub fast double -0.0, %a |
| 209 | + %1 = call fast double @llvm.fma.f64(double %0, double %b, double %c) |
| 210 | + ret double %1 |
| 211 | +} |
| 212 | + |
| 213 | +define float @test_fast_mul_sub_f32(float %a, float %b, float %c) { |
| 214 | +; VSX-LABEL: test_fast_mul_sub_f32: |
| 215 | +; VSX: # %bb.0: # %entry |
| 216 | +; VSX-NEXT: xsnmsubasp 1, 2, 3 |
| 217 | +; VSX-NEXT: blr |
| 218 | +; |
| 219 | +; NO-VSX-LABEL: test_fast_mul_sub_f32: |
| 220 | +; NO-VSX: # %bb.0: # %entry |
| 221 | +; NO-VSX-NEXT: fnmsubs 1, 2, 3, 1 |
| 222 | +; NO-VSX-NEXT: blr |
| 223 | +entry: |
| 224 | + %0 = fmul fast float %b, %c |
| 225 | + %1 = fsub fast float %a, %0 |
| 226 | + ret float %1 |
| 227 | +} |
| 228 | + |
| 229 | +define float @test_fast_2mul_sub_f32(float %a, float %b, float %c, float %d) { |
| 230 | +; VSX-LABEL: test_fast_2mul_sub_f32: |
| 231 | +; VSX: # %bb.0: # %entry |
| 232 | +; VSX-NEXT: xsmulsp 0, 3, 4 |
| 233 | +; VSX-NEXT: xsmsubasp 0, 1, 2 |
| 234 | +; VSX-NEXT: fmr 1, 0 |
| 235 | +; VSX-NEXT: blr |
| 236 | +; |
| 237 | +; NO-VSX-LABEL: test_fast_2mul_sub_f32: |
| 238 | +; NO-VSX: # %bb.0: # %entry |
| 239 | +; NO-VSX-NEXT: fmuls 0, 3, 4 |
| 240 | +; NO-VSX-NEXT: fmsubs 1, 1, 2, 0 |
| 241 | +; NO-VSX-NEXT: blr |
| 242 | +entry: |
| 243 | + %0 = fmul fast float %a, %b |
| 244 | + %1 = fmul fast float %c, %d |
| 245 | + %2 = fsub fast float %0, %1 |
| 246 | + ret float %2 |
| 247 | +} |
| 248 | + |
| 249 | +define float @test_fast_neg_fma_f32(float %a, float %b, float %c) { |
| 250 | +; VSX-LABEL: test_fast_neg_fma_f32: |
| 251 | +; VSX: # %bb.0: # %entry |
| 252 | +; VSX-NEXT: xsnmsubasp 3, 1, 2 |
| 253 | +; VSX-NEXT: fmr 1, 3 |
| 254 | +; VSX-NEXT: blr |
| 255 | +; |
| 256 | +; NO-VSX-LABEL: test_fast_neg_fma_f32: |
| 257 | +; NO-VSX: # %bb.0: # %entry |
| 258 | +; NO-VSX-NEXT: fnmsubs 1, 1, 2, 3 |
| 259 | +; NO-VSX-NEXT: blr |
| 260 | +entry: |
| 261 | + %0 = fsub fast float -0.0, %a |
| 262 | + %1 = call fast float @llvm.fma.f32(float %0, float %b, float %c) |
| 263 | + ret float %1 |
| 264 | +} |
| 265 | + |
| 266 | +define <2 x double> @test_fast_neg_fma_v2f64(<2 x double> %a, <2 x double> %b, |
| 267 | +; VSX-LABEL: test_fast_neg_fma_v2f64: |
| 268 | +; VSX: # %bb.0: # %entry |
| 269 | +; VSX-NEXT: xvnmsubadp 36, 34, 35 |
| 270 | +; VSX-NEXT: vmr 2, 4 |
| 271 | +; VSX-NEXT: blr |
| 272 | +; |
| 273 | +; NO-VSX-LABEL: test_fast_neg_fma_v2f64: |
| 274 | +; NO-VSX: # %bb.0: # %entry |
| 275 | +; NO-VSX-NEXT: fnmsub 1, 1, 3, 5 |
| 276 | +; NO-VSX-NEXT: fnmsub 2, 2, 4, 6 |
| 277 | +; NO-VSX-NEXT: blr |
| 278 | + <2 x double> %c) { |
| 279 | +entry: |
| 280 | + %0 = fsub fast <2 x double> <double -0.0, double -0.0>, %a |
| 281 | + %1 = call fast <2 x double> @llvm.fma.v2f64(<2 x double> %0, <2 x double> %b, |
| 282 | + <2 x double> %c) |
| 283 | + ret <2 x double> %1 |
| 284 | +} |
| 285 | + |
| 286 | +define <4 x float> @test_fast_neg_fma_v4f32(<4 x float> %a, <4 x float> %b, |
| 287 | +; VSX-LABEL: test_fast_neg_fma_v4f32: |
| 288 | +; VSX: # %bb.0: # %entry |
| 289 | +; VSX-NEXT: xvnmsubasp 36, 34, 35 |
| 290 | +; VSX-NEXT: vmr 2, 4 |
| 291 | +; VSX-NEXT: blr |
| 292 | +; |
| 293 | +; NO-VSX-LABEL: test_fast_neg_fma_v4f32: |
| 294 | +; NO-VSX: # %bb.0: # %entry |
| 295 | +; NO-VSX-NEXT: vspltisb 5, -1 |
| 296 | +; NO-VSX-NEXT: vslw 5, 5, 5 |
| 297 | +; NO-VSX-NEXT: vsubfp 2, 5, 2 |
| 298 | +; NO-VSX-NEXT: vmaddfp 2, 2, 3, 4 |
| 299 | +; NO-VSX-NEXT: blr |
| 300 | + <4 x float> %c) { |
| 301 | +entry: |
| 302 | + %0 = fsub fast <4 x float> <float -0.0, float -0.0, float -0.0, |
| 303 | + float -0.0>, %a |
| 304 | + %1 = call fast <4 x float> @llvm.fma.v4f32(<4 x float> %0, <4 x float> %b, |
| 305 | + <4 x float> %c) |
| 306 | + ret <4 x float> %1 |
| 307 | +} |
| 308 | + |
| 309 | +declare float @llvm.fma.f32(float %a, float %b, float %c) |
| 310 | +declare double @llvm.fma.f64(double %a, double %b, double %c) |
| 311 | +declare <4 x float> @llvm.fma.v4f32(<4 x float> %a, <4 x float> %b, |
| 312 | + <4 x float> %c) |
| 313 | +declare <2 x double> @llvm.fma.v2f64(<2 x double> %a, <2 x double> %b, |
| 314 | + <2 x double> %c) |
0 commit comments