Skip to content

Commit 4d06623

Browse files
authored
recalculate the live interval of the defined register of xvmaddmdp in the VSX FMA mutation pass. (#116071)
The patch fix #116061 The root cause of the assertion is that the FMA mutation pass does not update the subranges of the live interval for the defined register of the modified instruction . it recalculate the live interval of the defined register of xvmaddmdp in the VSX FMA mutation pass.
1 parent f31099c commit 4d06623

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
@@ -288,21 +288,11 @@ namespace {
288288
UseMO.substVirtReg(KilledProdReg, KilledProdSubReg, *TRI);
289289
}
290290

291-
// Extend the live intervals of the killed product operand to hold the
292-
// fma result.
291+
// Recalculate the live intervals of the killed product operand.
292+
LIS->removeInterval(KilledProdReg);
293+
LiveInterval &NewFMAInt =
294+
LIS->createAndComputeVirtRegInterval(KilledProdReg);
293295

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

308298
// Extend the live interval of the addend source (it might end at the

llvm/test/CodeGen/PowerPC/pr116071.ll

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)