PPC: Teach FMA mutate to respect register classes.

This was causing bad code gen and assembly that won't assemble, as
mixed altivec and vsx code would end up with a vsx high register
assigned to an altivec instruction, which won't work. Constraining the
classes allows the optimization to proceed.

llvm-svn: 255299
This commit is contained in:
Kyle Butt 2015-12-10 21:28:40 +00:00
parent 28da4411df
commit 706d39a054
2 changed files with 98 additions and 2 deletions

View File

@ -220,6 +220,14 @@ protected:
if (OldFMAReg == KilledProdReg)
continue;
// If there isn't a class that fits, we can't perform the transform.
// This is needed for correctness with a mixture of VSX and Altivec
// instructions to make sure that a low VSX register is not assigned to
// the Altivec instruction.
if (!MRI.constrainRegClass(KilledProdReg,
MRI.getRegClass(OldFMAReg)))
continue;
assert(OldFMAReg == AddendMI->getOperand(0).getReg() &&
"Addend copy not tied to old FMA output!");
@ -262,8 +270,7 @@ protected:
if (UseMI == AddendMI)
continue;
UseMO.setReg(KilledProdReg);
UseMO.setSubReg(KilledProdSubReg);
UseMO.substVirtReg(KilledProdReg, KilledProdSubReg, *TRI);
}
// Extend the live intervals of the killed product operand to hold the

File diff suppressed because one or more lines are too long