[llvm] r327368 - bpf: Support subregister definition check on PHI node
Yonghong Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 12 23:47:04 PDT 2018
Author: yhs
Date: Mon Mar 12 23:47:04 2018
New Revision: 327368
URL: http://llvm.org/viewvc/llvm-project?rev=327368&view=rev
Log:
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 at netronome.com>
Signed-off-by: Yonghong Song <yhs at fb.com>
Modified:
llvm/trunk/lib/Target/BPF/BPFMIPeephole.cpp
Modified: llvm/trunk/lib/Target/BPF/BPFMIPeephole.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/BPF/BPFMIPeephole.cpp?rev=327368&r1=327367&r2=327368&view=diff
==============================================================================
--- llvm/trunk/lib/Target/BPF/BPFMIPeephole.cpp (original)
+++ llvm/trunk/lib/Target/BPF/BPFMIPeephole.cpp Mon Mar 12 23:47:04 2018
@@ -76,9 +76,23 @@ bool BPFMIPeephole::isMovFrom32Def(Machi
{
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(voi
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);
More information about the llvm-commits
mailing list