summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorYonghong Song <yhs@fb.com>2018-03-13 06:47:04 +0000
committerYonghong Song <yhs@fb.com>2018-03-13 06:47:04 +0000
commit1d28a759d95922068395de3a0a3d4353a63e2e07 (patch)
treedd3fa01289c6ef757a88b8eaecc8e3e73865894d /llvm/lib
parentc88bcdec432ca22258a1fd8af57d1e97dab7142f (diff)
downloadbcm5719-llvm-1d28a759d95922068395de3a0a3d4353a63e2e07.tar.gz
bcm5719-llvm-1d28a759d95922068395de3a0a3d4353a63e2e07.zip
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
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/BPF/BPFMIPeephole.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/llvm/lib/Target/BPF/BPFMIPeephole.cpp b/llvm/lib/Target/BPF/BPFMIPeephole.cpp
index b15a7e6663e..cf26f2436fa 100644
--- a/llvm/lib/Target/BPF/BPFMIPeephole.cpp
+++ b/llvm/lib/Target/BPF/BPFMIPeephole.cpp
@@ -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);
OpenPOWER on IntegriCloud