1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -verify-machineinstrs -mtriple=powerpc64le-linux-gnu | FileCheck %s
4 define float @can_fma_with_fewer_uses(float %f1, float %f2, float %f3, float %f4) {
5 ; CHECK-LABEL: can_fma_with_fewer_uses:
7 ; CHECK-NEXT: xsmulsp 0, 1, 2
9 ; CHECK-NEXT: xsmaddasp 1, 3, 4
10 ; CHECK-NEXT: xsdivsp 1, 0, 1
12 %mul1 = fmul contract float %f1, %f2
13 %mul2 = fmul contract float %f3, %f4
14 %add = fadd contract float %mul1, %mul2
15 %second_use_of_mul1 = fdiv float %mul1, %add
16 ret float %second_use_of_mul1
19 ; There is no contract on the mul with no extra use so we can't fuse that.
20 ; Since we are fusing with the mul with an extra use, the fmul needs to stick
21 ; around beside the fma.
22 define float @no_fma_with_fewer_uses(float %f1, float %f2, float %f3, float %f4) {
23 ; CHECK-LABEL: no_fma_with_fewer_uses:
25 ; CHECK-NEXT: xsmulsp 3, 3, 4
26 ; CHECK-NEXT: xsmulsp 0, 1, 2
27 ; CHECK-NEXT: xsmaddasp 3, 1, 2
28 ; CHECK-NEXT: xsdivsp 1, 0, 3
30 %mul1 = fmul contract float %f1, %f2
31 %mul2 = fmul float %f3, %f4
32 %add = fadd contract float %mul1, %mul2
33 %second_use_of_mul1 = fdiv float %mul1, %add
34 ret float %second_use_of_mul1