[X86] As per suggestion from Craig Topper and Hal Finkel, override

TargetInstrInfo::findCommutedOpIndices to enable VFMA*231 commutation, rather
than abusing commuteInstruction.

Thanks very much for the suggestion guys!

llvm-svn: 205489
This commit is contained in:
Lang Hames 2014-04-02 23:57:49 +00:00
parent 987cbaa09b
commit c59a2d0529
2 changed files with 39 additions and 40 deletions

View File

@ -2457,8 +2457,16 @@ X86InstrInfo::commuteInstruction(MachineInstr *MI, bool NewMI) const {
NewMI = false;
}
MI->setDesc(get(Opc));
// Fallthrough intended.
}
default:
return TargetInstrInfo::commuteInstruction(MI, NewMI);
}
}
bool X86InstrInfo::findCommutedOpIndices(MachineInstr *MI, unsigned &SrcOpIdx1,
unsigned &SrcOpIdx2) const {
switch (MI->getOpcode()) {
case X86::VFMADDPDr231r:
case X86::VFMADDPSr231r:
case X86::VFMADDSDr231r:
@ -2482,24 +2490,12 @@ X86InstrInfo::commuteInstruction(MachineInstr *MI, bool NewMI) const {
case X86::VFNMADDPDr231rY:
case X86::VFNMADDPSr231rY:
case X86::VFNMSUBPDr231rY:
case X86::VFNMSUBPSr231rY: {
MachineOperand &O2 = MI->getOperand(2);
MachineOperand &O3 = MI->getOperand(3);
assert(O2.isReg() && O3.isReg() &&
"Can't commute memory operands.");
unsigned O2Reg = O2.getReg();
unsigned O2SubReg = O2.getSubReg();
bool O2IsKill = O2.isKill();
O2.setReg(O3.getReg());
O2.setSubReg(O3.getSubReg());
O2.setIsKill(O3.isKill());
O3.setReg(O2Reg);
O3.setSubReg(O2SubReg);
O3.setIsKill(O2IsKill);
return MI;
}
case X86::VFNMSUBPSr231rY:
SrcOpIdx1 = 2;
SrcOpIdx2 = 3;
return true;
default:
return TargetInstrInfo::commuteInstruction(MI, NewMI);
return TargetInstrInfo::findCommutedOpIndices(MI, SrcOpIdx1, SrcOpIdx2);
}
}

View File

@ -229,6 +229,9 @@ public:
///
MachineInstr *commuteInstruction(MachineInstr *MI, bool NewMI) const override;
bool findCommutedOpIndices(MachineInstr *MI, unsigned &SrcOpIdx1,
unsigned &SrcOpIdx2) const override;
// Branch analysis.
bool isUnpredicatedTerminator(const MachineInstr* MI) const override;
bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,