@@ -2733,49 +2733,47 @@ static MachineInstr *swapImmOperands(MachineInstr &MI,
2733
2733
}
2734
2734
2735
2735
bool SIInstrInfo::isLegalToSwap (const MachineInstr &MI, unsigned OpIdx0,
2736
- const MachineOperand *MO0, unsigned OpIdx1,
2737
- const MachineOperand *MO1) const {
2736
+ unsigned OpIdx1) const {
2738
2737
const MCInstrDesc &InstDesc = MI.getDesc ();
2739
2738
const MCOperandInfo &OpInfo0 = InstDesc.operands ()[OpIdx0];
2740
2739
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 ;
2745
2740
2746
2741
unsigned Opc = MI.getOpcode ();
2747
2742
int Src0Idx = AMDGPU::getNamedOperandIdx (Opc, AMDGPU::OpName::src0);
2748
2743
2744
+ const MachineOperand &MO0 = MI.getOperand (OpIdx0);
2745
+ const MachineOperand &MO1 = MI.getOperand (OpIdx1);
2746
+
2749
2747
// Swap doesn't breach constant bus or literal limits
2750
2748
// It may move literal to position other than src0, this is not allowed
2751
2749
// pre-gfx10 However, most test cases need literals in Src0 for VOP
2752
2750
// FIXME: After gfx9, literal can be in place other than Src0
2753
2751
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))
2756
2754
return false ;
2757
- if ((int )OpIdx1 == Src0Idx && !MO1-> isReg () &&
2758
- !isInlineConstant (* MO1, OpInfo0))
2755
+ if ((int )OpIdx1 == Src0Idx && !MO1. isReg () &&
2756
+ !isInlineConstant (MO1, OpInfo0))
2759
2757
return false ;
2760
2758
}
2761
2759
2762
- if ((int )OpIdx1 != Src0Idx && MO0-> isReg ()) {
2763
- if (!DefinedRC1 )
2760
+ if ((int )OpIdx1 != Src0Idx && MO0. isReg ()) {
2761
+ if (OpInfo1. RegClass == - 1 )
2764
2762
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));
2767
2765
}
2768
- if ((int )OpIdx0 != Src0Idx && MO1-> isReg ()) {
2769
- if (!DefinedRC0 )
2766
+ if ((int )OpIdx0 != Src0Idx && MO1. isReg ()) {
2767
+ if (OpInfo0. RegClass == - 1 )
2770
2768
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);
2773
2771
}
2774
2772
2775
2773
// No need to check 64-bit literals since swapping does not bring new
2776
2774
// 64-bit literals into current instruction to fold to 32-bit
2777
2775
2778
- return isImmOperandLegal (MI, OpIdx1, * MO0);
2776
+ return isImmOperandLegal (MI, OpIdx1, MO0);
2779
2777
}
2780
2778
2781
2779
MachineInstr *SIInstrInfo::commuteInstructionImpl (MachineInstr &MI, bool NewMI,
@@ -2797,12 +2795,12 @@ MachineInstr *SIInstrInfo::commuteInstructionImpl(MachineInstr &MI, bool NewMI,
2797
2795
static_cast <int >(Src1Idx) &&
2798
2796
" inconsistency with findCommutedOpIndices" );
2799
2797
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))
2803
2799
return nullptr ;
2804
- }
2800
+
2805
2801
MachineInstr *CommutedMI = nullptr ;
2802
+ MachineOperand &Src0 = MI.getOperand (Src0Idx);
2803
+ MachineOperand &Src1 = MI.getOperand (Src1Idx);
2806
2804
if (Src0.isReg () && Src1.isReg ()) {
2807
2805
// Be sure to copy the source modifiers to the right place.
2808
2806
CommutedMI =
0 commit comments