@@ -33,6 +33,7 @@ class SIShrinkInstructions {
33
33
const GCNSubtarget *ST;
34
34
const SIInstrInfo *TII;
35
35
const SIRegisterInfo *TRI;
36
+ bool IsPostRA;
36
37
37
38
bool foldImmediates (MachineInstr &MI, bool TryToCommute = true ) const ;
38
39
bool shouldShrinkTrue16 (MachineInstr &MI) const ;
@@ -417,7 +418,7 @@ void SIShrinkInstructions::shrinkMadFma(MachineInstr &MI) const {
417
418
return ;
418
419
419
420
// There is no advantage to doing this pre-RA.
420
- if (!MF-> getProperties (). hasNoVRegs () )
421
+ if (!IsPostRA )
421
422
return ;
422
423
423
424
if (TII->hasAnyModifiersSet (MI))
@@ -837,6 +838,7 @@ bool SIShrinkInstructions::run(MachineFunction &MF) {
837
838
ST = &MF.getSubtarget <GCNSubtarget>();
838
839
TII = ST->getInstrInfo ();
839
840
TRI = &TII->getRegisterInfo ();
841
+ IsPostRA = MF.getProperties ().hasNoVRegs ();
840
842
841
843
unsigned VCCReg = ST->isWave32 () ? AMDGPU::VCC_LO : AMDGPU::VCC;
842
844
@@ -857,9 +859,8 @@ bool SIShrinkInstructions::run(MachineFunction &MF) {
857
859
858
860
// Test if we are after regalloc. We only want to do this after any
859
861
// optimizations happen because this will confuse them.
860
- // XXX - not exactly a check for post-regalloc run.
861
862
MachineOperand &Src = MI.getOperand (1 );
862
- if (Src.isImm () && MI. getOperand ( 0 ). getReg (). isPhysical () ) {
863
+ if (Src.isImm () && IsPostRA ) {
863
864
int32_t ModImm;
864
865
unsigned ModOpcode =
865
866
canModifyToInlineImmOp32 (TII, Src, ModImm, /* Scalar=*/ false );
@@ -948,9 +949,8 @@ bool SIShrinkInstructions::run(MachineFunction &MF) {
948
949
continue ;
949
950
}
950
951
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) {
954
954
shrinkMIMG (MI);
955
955
continue ;
956
956
}
@@ -1061,7 +1061,7 @@ bool SIShrinkInstructions::run(MachineFunction &MF) {
1061
1061
// fold an immediate into the shrunk instruction as a literal operand. In
1062
1062
// GFX10 VOP3 instructions can take a literal operand anyway, so there is
1063
1063
// no advantage to doing this.
1064
- if (ST->hasVOP3Literal () && !MF. getProperties (). hasNoVRegs () )
1064
+ if (ST->hasVOP3Literal () && !IsPostRA )
1065
1065
continue ;
1066
1066
1067
1067
if (ST->hasTrue16BitInsts () && AMDGPU::isTrue16Inst (MI.getOpcode ()) &&
0 commit comments