Skip to content

Commit c1a8a31

Browse files
committed
recalculate the live interval of the defined register of xvmaddmdp in the VSX FMA mutation
1 parent d6344c1 commit c1a8a31

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed

llvm/lib/Target/PowerPC/PPCVSXFMAMutate.cpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -293,21 +293,11 @@ namespace {
293293
UseMO.substVirtReg(KilledProdReg, KilledProdSubReg, *TRI);
294294
}
295295

296-
// Extend the live intervals of the killed product operand to hold the
297-
// fma result.
296+
// Recalculate the live intervals of the killed product operand.
297+
LIS->removeInterval(KilledProdReg);
298+
LiveInterval &NewFMAInt =
299+
LIS->createAndComputeVirtRegInterval(KilledProdReg);
298300

299-
LiveInterval &NewFMAInt = LIS->getInterval(KilledProdReg);
300-
for (auto &AI : FMAInt) {
301-
// Don't add the segment that corresponds to the original copy.
302-
if (AI.valno == AddendValNo)
303-
continue;
304-
305-
VNInfo *NewFMAValNo =
306-
NewFMAInt.getNextValue(AI.start, LIS->getVNInfoAllocator());
307-
308-
NewFMAInt.addSegment(
309-
LiveInterval::Segment(AI.start, AI.end, NewFMAValNo));
310-
}
311301
LLVM_DEBUG(dbgs() << " extended: " << NewFMAInt << '\n');
312302

313303
// Extend the live interval of the addend source (it might end at the
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
; RUN: llc -disable-ppc-vsx-fma-mutation=false -mcpu=pwr10 -verify-machineinstrs \
2+
; RUN: -ppc-asm-full-reg-names -mtriple powerpc64-ibm-aix7.2.0.0 < %s | FileCheck %s
3+
4+
target datalayout = "E-m:a-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512"
5+
6+
define void @initial(<2 x double> %0){
7+
entry:
8+
%1 = fmul <2 x double> %0, zeroinitializer
9+
br label %for.cond251.preheader.lr.ph
10+
11+
for.cond251.preheader.lr.ph: ; preds = %for.cond251.preheader.lr.ph, %entry
12+
%2 = phi double [ %3, %for.cond251.preheader.lr.ph ], [ 0.000000e+00, %entry ]
13+
%3 = phi double [ %7, %for.cond251.preheader.lr.ph ], [ 0.000000e+00, %entry ]
14+
%add737 = fadd double %3, %2
15+
%4 = insertelement <2 x double> zeroinitializer, double %add737, i64 0
16+
%5 = fmul contract <2 x double> %4, zeroinitializer
17+
%6 = fadd contract <2 x double> %1, %5
18+
%7 = extractelement <2 x double> %6, i64 0
19+
br label %for.cond251.preheader.lr.ph
20+
}
21+
22+
; CHECK: xsadddp f4, f3, f4
23+
; CHECK-NEXT: xxmrghd vs5, vs4, vs2
24+
; CHECK-NEXT: fmr f4, f3
25+
; CHECK-NEXT: xvmaddmdp vs5, vs0, vs1
26+
; CHECK-NEXT: fmr f3, f5

0 commit comments

Comments
 (0)