1 ; RUN: llc < %s -mcpu=pwr7 -mattr=+vsx | FileCheck %s
3 ; Also run with -schedule-ppc-vsx-fma-mutation-early as a stress test for the
4 ; live-interval-updating logic.
5 ; RUN: llc < %s -mcpu=pwr7 -mattr=+vsx -schedule-ppc-vsx-fma-mutation-early
6 target datalayout = "E-m:e-i64:64-n32:64"
7 target triple = "powerpc64-unknown-linux-gnu"
9 define void @test1(double %a, double %b, double %c, double %e, double* nocapture %d) #0 {
11 %0 = tail call double @llvm.fma.f64(double %b, double %c, double %a)
12 store double %0, double* %d, align 8
13 %1 = tail call double @llvm.fma.f64(double %b, double %e, double %a)
14 %arrayidx1 = getelementptr inbounds double* %d, i64 1
15 store double %1, double* %arrayidx1, align 8
19 ; CHECK-DAG: li [[C1:[0-9]+]], 8
20 ; CHECK-DAG: xsmaddmdp 3, 2, 1
21 ; CHECK-DAG: xsmaddadp 1, 2, 4
22 ; CHECK-DAG: stxsdx 3, 0, 7
23 ; CHECK-DAG: stxsdx 1, 7, [[C1]]
27 define void @test2(double %a, double %b, double %c, double %e, double %f, double* nocapture %d) #0 {
29 %0 = tail call double @llvm.fma.f64(double %b, double %c, double %a)
30 store double %0, double* %d, align 8
31 %1 = tail call double @llvm.fma.f64(double %b, double %e, double %a)
32 %arrayidx1 = getelementptr inbounds double* %d, i64 1
33 store double %1, double* %arrayidx1, align 8
34 %2 = tail call double @llvm.fma.f64(double %b, double %f, double %a)
35 %arrayidx2 = getelementptr inbounds double* %d, i64 2
36 store double %2, double* %arrayidx2, align 8
40 ; CHECK-DAG: li [[C1:[0-9]+]], 8
41 ; CHECK-DAG: li [[C2:[0-9]+]], 16
42 ; CHECK-DAG: xsmaddmdp 3, 2, 1
43 ; CHECK-DAG: xsmaddmdp 4, 2, 1
44 ; CHECK-DAG: xsmaddadp 1, 2, 5
45 ; CHECK-DAG: stxsdx 3, 0, 8
46 ; CHECK-DAG: stxsdx 4, 8, [[C1]]
47 ; CHECK-DAG: stxsdx 1, 8, [[C2]]
51 define void @test3(double %a, double %b, double %c, double %e, double %f, double* nocapture %d) #0 {
53 %0 = tail call double @llvm.fma.f64(double %b, double %c, double %a)
54 store double %0, double* %d, align 8
55 %1 = tail call double @llvm.fma.f64(double %b, double %e, double %a)
56 %2 = tail call double @llvm.fma.f64(double %b, double %c, double %1)
57 %arrayidx1 = getelementptr inbounds double* %d, i64 3
58 store double %2, double* %arrayidx1, align 8
59 %3 = tail call double @llvm.fma.f64(double %b, double %f, double %a)
60 %arrayidx2 = getelementptr inbounds double* %d, i64 2
61 store double %3, double* %arrayidx2, align 8
62 %arrayidx3 = getelementptr inbounds double* %d, i64 1
63 store double %1, double* %arrayidx3, align 8
67 ; CHECK-DAG: xxlor [[F1:[0-9]+]], 1, 1
68 ; CHECK-DAG: li [[C1:[0-9]+]], 24
69 ; CHECK-DAG: li [[C2:[0-9]+]], 16
70 ; CHECK-DAG: li [[C3:[0-9]+]], 8
71 ; CHECK-DAG: xsmaddmdp 4, 2, 1
72 ; CHECK-DAG: xsmaddadp 1, 2, 5
74 ; Note: We could convert this next FMA to M-type as well, but it would require
75 ; re-ordering the instructions.
76 ; CHECK-DAG: xsmaddadp [[F1]], 2, 3
78 ; CHECK-DAG: xsmaddmdp 2, 3, 4
79 ; CHECK-DAG: stxsdx [[F1]], 0, 8
80 ; CHECK-DAG: stxsdx 2, 8, [[C1]]
81 ; CHECK-DAG: stxsdx 1, 8, [[C2]]
82 ; CHECK-DAG: stxsdx 4, 8, [[C3]]
86 define void @test4(double %a, double %b, double %c, double %e, double %f, double* nocapture %d) #0 {
88 %0 = tail call double @llvm.fma.f64(double %b, double %c, double %a)
89 store double %0, double* %d, align 8
90 %1 = tail call double @llvm.fma.f64(double %b, double %e, double %a)
91 %arrayidx1 = getelementptr inbounds double* %d, i64 1
92 store double %1, double* %arrayidx1, align 8
93 %2 = tail call double @llvm.fma.f64(double %b, double %c, double %1)
94 %arrayidx3 = getelementptr inbounds double* %d, i64 3
95 store double %2, double* %arrayidx3, align 8
96 %3 = tail call double @llvm.fma.f64(double %b, double %f, double %a)
97 %arrayidx4 = getelementptr inbounds double* %d, i64 2
98 store double %3, double* %arrayidx4, align 8
101 ; CHECK-LABEL: @test4
102 ; CHECK-DAG: xxlor [[F1:[0-9]+]], 1, 1
103 ; CHECK-DAG: li [[C1:[0-9]+]], 8
104 ; CHECK-DAG: li [[C2:[0-9]+]], 16
105 ; CHECK-DAG: xsmaddmdp 4, 2, 1
107 ; Note: We could convert this next FMA to M-type as well, but it would require
108 ; re-ordering the instructions.
109 ; CHECK-DAG: xsmaddadp 1, 2, 5
111 ; CHECK-DAG: xsmaddadp [[F1]], 2, 3
112 ; CHECK-DAG: stxsdx [[F1]], 0, 8
113 ; CHECK-DAG: stxsdx 4, 8, [[C1]]
114 ; CHECK-DAG: li [[C3:[0-9]+]], 24
115 ; CHECK-DAG: xsmaddadp 4, 2, 3
116 ; CHECK-DAG: stxsdx 4, 8, [[C3]]
117 ; CHECK-DAG: stxsdx 1, 8, [[C2]]
121 declare double @llvm.fma.f64(double, double, double) #0
123 attributes #0 = { nounwind readnone }