1; RUN: llc < %s -march=ppc32 -fp-contract=fast -mattr=-vsx | FileCheck %s
2; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -fp-contract=fast -mattr=+vsx -mcpu=pwr7 | FileCheck -check-prefix=CHECK-VSX %s
3
4define double @test_FMADD_EXT1(float %A, float %B, double %C) {
5    %D = fmul float %A, %B          ; <float> [#uses=1]
6    %E = fpext float %D to double   ; <double> [#uses=1]
7    %F = fadd double %E, %C         ; <double> [#uses=1]
8    ret double %F
9; CHECK-LABEL: test_FMADD_EXT1:
10; CHECK: fmadd
11; CHECK-NEXT: blr
12
13; CHECK-VSX-LABEL: test_FMADD_EXT1:
14; CHECK-VSX: xsmaddmdp
15; CHECK-VSX-NEXT: blr
16}
17
18define double @test_FMADD_EXT2(float %A, float %B, double %C) {
19    %D = fmul float %A, %B          ; <float> [#uses=1]
20    %E = fpext float %D to double   ; <double> [#uses=1]
21    %F = fadd double %C, %E         ; <double> [#uses=1]
22    ret double %F
23; CHECK-LABEL: test_FMADD_EXT2:
24; CHECK: fmadd
25; CHECK-NEXT: blr
26
27; CHECK-VSX-LABEL: test_FMADD_EXT2:
28; CHECK-VSX: xsmaddmdp
29; CHECK-VSX-NEXT: blr
30}
31
32define double @test_FMSUB_EXT1(float %A, float %B, double %C) {
33    %D = fmul float %A, %B          ; <float> [#uses=1]
34    %E = fpext float %D to double   ; <double> [#uses=1]
35    %F = fsub double %E, %C         ; <double> [#uses=1]
36    ret double %F
37; CHECK-LABEL: test_FMSUB_EXT1:
38; CHECK: fmsub
39; CHECK-NEXT: blr
40
41; CHECK-VSX-LABEL: test_FMSUB_EXT1:
42; CHECK-VSX: xsmsubmdp
43; CHECK-VSX-NEXT: blr
44}
45
46define double @test_FMSUB_EXT2(float %A, float %B, double %C) {
47    %D = fmul float %A, %B          ; <float> [#uses=1]
48    %E = fpext float %D to double   ; <double> [#uses=1]
49    %F = fsub double %C, %E         ; <double> [#uses=1]
50    ret double %F
51; CHECK-LABEL: test_FMSUB_EXT2:
52; CHECK: fnmsub
53; CHECK-NEXT: blr
54
55; CHECK-VSX-LABEL: test_FMSUB_EXT2:
56; CHECK-VSX: xsnmsubmdp
57; CHECK-VSX-NEXT: fmr
58; CHECK-VSX-NEXT: blr
59}
60
61define double @test_FMSUB_EXT3(float %A, float %B, double %C) {
62    %D = fmul float %A, %B          ; <float> [#uses=1]
63    %E = fsub float -0.000000e+00, %D ;		<float> [#uses=1]
64    %F = fpext float %E to double   ; <double> [#uses=1]
65    %G = fsub double %F, %C         ; <double> [#uses=1]
66    ret double %G
67; CHECK-LABEL: test_FMSUB_EXT3:
68; CHECK: fneg
69; CHECK-NEXT: fmsub
70; CHECK-NEXT: blr
71
72; CHECK-VSX-LABEL: test_FMSUB_EXT3:
73; CHECK-VSX: xsnegdp
74; CHECK-VSX-NEXT: xsmsubmdp
75; CHECK-VSX-NEXT: blr
76}
77
78define double @test_FMSUB_EXT4(float %A, float %B, double %C) {
79    %D = fmul float %A, %B          ; <float> [#uses=1]
80    %E = fpext float %D to double   ; <double> [#uses=1]
81    %F = fsub double -0.000000e+00, %E ;		<double> [#uses=1]
82    %G = fsub double %F, %C         ; <double> [#uses=1]
83    ret double %G
84; CHECK-LABEL: test_FMSUB_EXT4:
85; CHECK: fneg
86; CHECK-NEXT: fmsub
87; CHECK-NEXT: blr
88
89; CHECK-VSX-LABEL: test_FMSUB_EXT4:
90; CHECK-VSX: xsnegdp
91; CHECK-VSX-NEXT: xsmsubmdp
92; CHECK-VSX-NEXT: blr
93}