Skip to content

Commit f70e920

Browse files
authored
AMDGPU: Directly check if shrink-instructions run is post-RA (#142009)
1 parent ce9cef7 commit f70e920

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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()) &&

llvm/test/CodeGen/AMDGPU/frexp-constant-fold.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ define { <2 x float>, <2 x i32> } @frexp_zero_negzero_vector() {
108108
; CHECK-LABEL: frexp_zero_negzero_vector:
109109
; CHECK: ; %bb.0:
110110
; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
111-
; CHECK-NEXT: v_bfrev_b32_e32 v1, 1
112111
; CHECK-NEXT: v_mov_b32_e32 v0, 0
112+
; CHECK-NEXT: v_bfrev_b32_e32 v1, 1
113113
; CHECK-NEXT: v_mov_b32_e32 v2, 0
114114
; CHECK-NEXT: v_mov_b32_e32 v3, 0
115115
; CHECK-NEXT: s_setpc_b64 s[30:31]

0 commit comments

Comments
 (0)