@@ -33,6 +33,7 @@ class SIShrinkInstructions {
3333 const GCNSubtarget *ST;
3434 const SIInstrInfo *TII;
3535 const SIRegisterInfo *TRI;
36+ bool IsPostRA;
3637
3738 bool foldImmediates (MachineInstr &MI, bool TryToCommute = true ) const ;
3839 bool shouldShrinkTrue16 (MachineInstr &MI) const ;
@@ -417,7 +418,7 @@ void SIShrinkInstructions::shrinkMadFma(MachineInstr &MI) const {
417418 return ;
418419
419420 // There is no advantage to doing this pre-RA.
420- if (!MF-> getProperties (). hasNoVRegs () )
421+ if (!IsPostRA )
421422 return ;
422423
423424 if (TII->hasAnyModifiersSet (MI))
@@ -837,6 +838,7 @@ bool SIShrinkInstructions::run(MachineFunction &MF) {
837838 ST = &MF.getSubtarget <GCNSubtarget>();
838839 TII = ST->getInstrInfo ();
839840 TRI = &TII->getRegisterInfo ();
841+ IsPostRA = MF.getProperties ().hasNoVRegs ();
840842
841843 unsigned VCCReg = ST->isWave32 () ? AMDGPU::VCC_LO : AMDGPU::VCC;
842844
@@ -857,9 +859,8 @@ bool SIShrinkInstructions::run(MachineFunction &MF) {
857859
858860 // Test if we are after regalloc. We only want to do this after any
859861 // optimizations happen because this will confuse them.
860- // XXX - not exactly a check for post-regalloc run.
861862 MachineOperand &Src = MI.getOperand (1 );
862- if (Src.isImm () && MI. getOperand ( 0 ). getReg (). isPhysical () ) {
863+ if (Src.isImm () && IsPostRA ) {
863864 int32_t ModImm;
864865 unsigned ModOpcode =
865866 canModifyToInlineImmOp32 (TII, Src, ModImm, /* Scalar=*/ false );
@@ -948,9 +949,8 @@ bool SIShrinkInstructions::run(MachineFunction &MF) {
948949 continue ;
949950 }
950951
951- if (TII->isMIMG (MI.getOpcode ()) &&
952- ST->getGeneration () >= AMDGPUSubtarget::GFX10 &&
953- MF.getProperties ().hasNoVRegs ()) {
952+ if (IsPostRA && TII->isMIMG (MI.getOpcode ()) &&
953+ ST->getGeneration () >= AMDGPUSubtarget::GFX10) {
954954 shrinkMIMG (MI);
955955 continue ;
956956 }
@@ -1061,7 +1061,7 @@ bool SIShrinkInstructions::run(MachineFunction &MF) {
10611061 // fold an immediate into the shrunk instruction as a literal operand. In
10621062 // GFX10 VOP3 instructions can take a literal operand anyway, so there is
10631063 // no advantage to doing this.
1064- if (ST->hasVOP3Literal () && !MF. getProperties (). hasNoVRegs () )
1064+ if (ST->hasVOP3Literal () && !IsPostRA )
10651065 continue ;
10661066
10671067 if (ST->hasTrue16BitInsts () && AMDGPU::isTrue16Inst (MI.getOpcode ()) &&
0 commit comments