mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 19:52:54 +01:00
bpf: Support subregister definition check on PHI node
This patch relax the subregister definition check on Phi node. Previously, we just cancel the optimizatoin when the definition is Phi node while actually we could further check the definitions of incoming parameters of PHI node. This helps catch more elimination opportunities. Signed-off-by: Jiong Wang <jiong.wang@netronome.com> Signed-off-by: Yonghong Song <yhs@fb.com> llvm-svn: 327368
This commit is contained in:
parent
a2b4eaa164
commit
c336c5023e
@ -76,9 +76,23 @@ bool BPFMIPeephole::isMovFrom32Def(MachineInstr *MovMI)
|
||||
{
|
||||
MachineInstr *DefInsn = MRI->getVRegDef(MovMI->getOperand(1).getReg());
|
||||
|
||||
if (!DefInsn || DefInsn->isPHI())
|
||||
if (!DefInsn)
|
||||
return false;
|
||||
|
||||
if (DefInsn->isPHI()) {
|
||||
for (unsigned i = 1, e = DefInsn->getNumOperands(); i < e; i += 2) {
|
||||
MachineOperand &opnd = DefInsn->getOperand(i);
|
||||
|
||||
if (!opnd.isReg())
|
||||
return false;
|
||||
|
||||
MachineInstr *PhiDef = MRI->getVRegDef(opnd.getReg());
|
||||
// quick check on PHI incoming definitions.
|
||||
if (!PhiDef || PhiDef->isPHI() || PhiDef->getOpcode() == BPF::COPY)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (DefInsn->getOpcode() == BPF::COPY) {
|
||||
MachineOperand &opnd = DefInsn->getOperand(1);
|
||||
|
||||
@ -129,10 +143,10 @@ bool BPFMIPeephole::eliminateZExtSeq(void) {
|
||||
MovMI->getOpcode() != BPF::MOV_32_64)
|
||||
continue;
|
||||
|
||||
unsigned SubReg = MovMI->getOperand(1).getReg();
|
||||
if (!isMovFrom32Def(MovMI))
|
||||
continue;
|
||||
|
||||
unsigned SubReg = MovMI->getOperand(1).getReg();
|
||||
BuildMI(MBB, MI, MI.getDebugLoc(), TII->get(BPF::SUBREG_TO_REG), DstReg)
|
||||
.addImm(0).addReg(SubReg).addImm(BPF::sub_32);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user