@@ -3408,10 +3408,9 @@ void SIInstrInfo::insertSelect(MachineBasicBlock &MBB,
3408
3408
}
3409
3409
}
3410
3410
3411
- bool SIInstrInfo::isFoldableCopy (const MachineInstr &MI) {
3411
+ bool SIInstrInfo::isFoldableCopy (const MachineInstr &MI) const {
3412
3412
switch (MI.getOpcode ()) {
3413
3413
case AMDGPU::V_MOV_B16_t16_e32:
3414
- case AMDGPU::V_MOV_B16_t16_e64:
3415
3414
case AMDGPU::V_MOV_B32_e32:
3416
3415
case AMDGPU::V_MOV_B32_e64:
3417
3416
case AMDGPU::V_MOV_B64_PSEUDO:
@@ -3428,34 +3427,10 @@ bool SIInstrInfo::isFoldableCopy(const MachineInstr &MI) {
3428
3427
case AMDGPU::AV_MOV_B32_IMM_PSEUDO:
3429
3428
case AMDGPU::AV_MOV_B64_IMM_PSEUDO:
3430
3429
return true ;
3431
- default :
3432
- return false ;
3433
- }
3434
- }
3435
-
3436
- unsigned SIInstrInfo::getFoldableCopySrcIdx (const MachineInstr &MI) {
3437
- switch (MI.getOpcode ()) {
3438
- case AMDGPU::V_MOV_B16_t16_e32:
3439
3430
case AMDGPU::V_MOV_B16_t16_e64:
3440
- return 2 ;
3441
- case AMDGPU::V_MOV_B32_e32:
3442
- case AMDGPU::V_MOV_B32_e64:
3443
- case AMDGPU::V_MOV_B64_PSEUDO:
3444
- case AMDGPU::V_MOV_B64_e32:
3445
- case AMDGPU::V_MOV_B64_e64:
3446
- case AMDGPU::S_MOV_B32:
3447
- case AMDGPU::S_MOV_B64:
3448
- case AMDGPU::S_MOV_B64_IMM_PSEUDO:
3449
- case AMDGPU::COPY:
3450
- case AMDGPU::WWM_COPY:
3451
- case AMDGPU::V_ACCVGPR_WRITE_B32_e64:
3452
- case AMDGPU::V_ACCVGPR_READ_B32_e64:
3453
- case AMDGPU::V_ACCVGPR_MOV_B32:
3454
- case AMDGPU::AV_MOV_B32_IMM_PSEUDO:
3455
- case AMDGPU::AV_MOV_B64_IMM_PSEUDO:
3456
- return 1 ;
3431
+ return !hasAnyModifiersSet (MI);
3457
3432
default :
3458
- llvm_unreachable ( " MI is not a foldable copy " ) ;
3433
+ return false ;
3459
3434
}
3460
3435
}
3461
3436
@@ -3976,12 +3951,13 @@ bool SIInstrInfo::areMemAccessesTriviallyDisjoint(const MachineInstr &MIa,
3976
3951
return false ;
3977
3952
}
3978
3953
3979
- static bool getFoldableImm (Register Reg, const MachineRegisterInfo &MRI,
3980
- int64_t &Imm, MachineInstr **DefMI = nullptr ) {
3954
+ bool SIInstrInfo::getFoldableImm (Register Reg, const MachineRegisterInfo &MRI,
3955
+ int64_t &Imm,
3956
+ MachineInstr **DefMI = nullptr ) const {
3981
3957
if (Reg.isPhysical ())
3982
3958
return false ;
3983
3959
auto *Def = MRI.getUniqueVRegDef (Reg);
3984
- if (Def && SIInstrInfo:: isFoldableCopy (*Def) && Def->getOperand (1 ).isImm ()) {
3960
+ if (Def && isFoldableCopy (*Def) && Def->getOperand (1 ).isImm ()) {
3985
3961
Imm = Def->getOperand (1 ).getImm ();
3986
3962
if (DefMI)
3987
3963
*DefMI = Def;
@@ -3990,8 +3966,8 @@ static bool getFoldableImm(Register Reg, const MachineRegisterInfo &MRI,
3990
3966
return false ;
3991
3967
}
3992
3968
3993
- static bool getFoldableImm (const MachineOperand *MO, int64_t &Imm,
3994
- MachineInstr **DefMI = nullptr ) {
3969
+ bool SIInstrInfo:: getFoldableImm (const MachineOperand *MO, int64_t &Imm,
3970
+ MachineInstr **DefMI = nullptr ) const {
3995
3971
if (!MO->isReg ())
3996
3972
return false ;
3997
3973
const MachineFunction *MF = MO->getParent ()->getParent ()->getParent ();
@@ -10643,10 +10619,11 @@ bool SIInstrInfo::optimizeCompareInstr(MachineInstr &CmpInstr, Register SrcReg,
10643
10619
return false ;
10644
10620
10645
10621
int64_t Mask;
10646
- const auto isMask = [&Mask, SrcSize](const MachineOperand *MO) -> bool {
10622
+ const auto isMask = [&Mask, SrcSize,
10623
+ this ](const MachineOperand *MO) -> bool {
10647
10624
if (MO->isImm ())
10648
10625
Mask = MO->getImm ();
10649
- else if (!getFoldableImm (MO, Mask))
10626
+ else if (!this -> getFoldableImm (MO, Mask))
10650
10627
return false ;
10651
10628
Mask &= maxUIntN (SrcSize);
10652
10629
return isPowerOf2_64 (Mask);
0 commit comments