@@ -2733,49 +2733,47 @@ static MachineInstr *swapImmOperands(MachineInstr &MI,
27332733}
27342734
27352735bool SIInstrInfo::isLegalToSwap (const MachineInstr &MI, unsigned OpIdx0,
2736- const MachineOperand *MO0, unsigned OpIdx1,
2737- const MachineOperand *MO1) const {
2736+ unsigned OpIdx1) const {
27382737 const MCInstrDesc &InstDesc = MI.getDesc ();
27392738 const MCOperandInfo &OpInfo0 = InstDesc.operands ()[OpIdx0];
27402739 const MCOperandInfo &OpInfo1 = InstDesc.operands ()[OpIdx1];
2741- const TargetRegisterClass *DefinedRC1 =
2742- OpInfo1.RegClass != -1 ? RI.getRegClass (OpInfo1.RegClass ) : nullptr ;
2743- const TargetRegisterClass *DefinedRC0 =
2744- OpInfo1.RegClass != -1 ? RI.getRegClass (OpInfo0.RegClass ) : nullptr ;
27452740
27462741 unsigned Opc = MI.getOpcode ();
27472742 int Src0Idx = AMDGPU::getNamedOperandIdx (Opc, AMDGPU::OpName::src0);
27482743
2744+ const MachineOperand &MO0 = MI.getOperand (OpIdx0);
2745+ const MachineOperand &MO1 = MI.getOperand (OpIdx1);
2746+
27492747 // Swap doesn't breach constant bus or literal limits
27502748 // It may move literal to position other than src0, this is not allowed
27512749 // pre-gfx10 However, most test cases need literals in Src0 for VOP
27522750 // FIXME: After gfx9, literal can be in place other than Src0
27532751 if (isVALU (MI)) {
2754- if ((int )OpIdx0 == Src0Idx && !MO0-> isReg () &&
2755- !isInlineConstant (* MO0, OpInfo1))
2752+ if ((int )OpIdx0 == Src0Idx && !MO0. isReg () &&
2753+ !isInlineConstant (MO0, OpInfo1))
27562754 return false ;
2757- if ((int )OpIdx1 == Src0Idx && !MO1-> isReg () &&
2758- !isInlineConstant (* MO1, OpInfo0))
2755+ if ((int )OpIdx1 == Src0Idx && !MO1. isReg () &&
2756+ !isInlineConstant (MO1, OpInfo0))
27592757 return false ;
27602758 }
27612759
2762- if ((int )OpIdx1 != Src0Idx && MO0-> isReg ()) {
2763- if (!DefinedRC1 )
2760+ if ((int )OpIdx1 != Src0Idx && MO0. isReg ()) {
2761+ if (OpInfo1. RegClass == - 1 )
27642762 return OpInfo1.OperandType == MCOI::OPERAND_UNKNOWN;
2765- return isLegalRegOperand (MI, OpIdx1, * MO0) &&
2766- (!MO1-> isReg () || isLegalRegOperand (MI, OpIdx0, * MO1));
2763+ return isLegalRegOperand (MI, OpIdx1, MO0) &&
2764+ (!MO1. isReg () || isLegalRegOperand (MI, OpIdx0, MO1));
27672765 }
2768- if ((int )OpIdx0 != Src0Idx && MO1-> isReg ()) {
2769- if (!DefinedRC0 )
2766+ if ((int )OpIdx0 != Src0Idx && MO1. isReg ()) {
2767+ if (OpInfo0. RegClass == - 1 )
27702768 return OpInfo0.OperandType == MCOI::OPERAND_UNKNOWN;
2771- return (!MO0-> isReg () || isLegalRegOperand (MI, OpIdx1, * MO0)) &&
2772- isLegalRegOperand (MI, OpIdx0, * MO1);
2769+ return (!MO0. isReg () || isLegalRegOperand (MI, OpIdx1, MO0)) &&
2770+ isLegalRegOperand (MI, OpIdx0, MO1);
27732771 }
27742772
27752773 // No need to check 64-bit literals since swapping does not bring new
27762774 // 64-bit literals into current instruction to fold to 32-bit
27772775
2778- return isImmOperandLegal (MI, OpIdx1, * MO0);
2776+ return isImmOperandLegal (MI, OpIdx1, MO0);
27792777}
27802778
27812779MachineInstr *SIInstrInfo::commuteInstructionImpl (MachineInstr &MI, bool NewMI,
@@ -2797,12 +2795,12 @@ MachineInstr *SIInstrInfo::commuteInstructionImpl(MachineInstr &MI, bool NewMI,
27972795 static_cast <int >(Src1Idx) &&
27982796 " inconsistency with findCommutedOpIndices" );
27992797
2800- MachineOperand &Src0 = MI.getOperand (Src0Idx);
2801- MachineOperand &Src1 = MI.getOperand (Src1Idx);
2802- if (!isLegalToSwap (MI, Src0Idx, &Src0, Src1Idx, &Src1)) {
2798+ if (!isLegalToSwap (MI, Src0Idx, Src1Idx))
28032799 return nullptr ;
2804- }
2800+
28052801 MachineInstr *CommutedMI = nullptr ;
2802+ MachineOperand &Src0 = MI.getOperand (Src0Idx);
2803+ MachineOperand &Src1 = MI.getOperand (Src1Idx);
28062804 if (Src0.isReg () && Src1.isReg ()) {
28072805 // Be sure to copy the source modifiers to the right place.
28082806 CommutedMI =
0 commit comments