summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/BPF/BPFMIPeephole.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Target/BPF/BPFMIPeephole.cpp')
-rw-r--r--llvm/lib/Target/BPF/BPFMIPeephole.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/Target/BPF/BPFMIPeephole.cpp b/llvm/lib/Target/BPF/BPFMIPeephole.cpp
index 80f4437a31c..3df14b4ad5b 100644
--- a/llvm/lib/Target/BPF/BPFMIPeephole.cpp
+++ b/llvm/lib/Target/BPF/BPFMIPeephole.cpp
@@ -96,6 +96,24 @@ MachineInstr *BPFMIPeephole::getInsnDefZExtSubReg(unsigned Reg) const {
Insn->getOpcode() != BPF::MOV_32_64)
return nullptr;
+ Insn = MRI->getVRegDef(Insn->getOperand(1).getReg());
+ if (!Insn || Insn->isPHI())
+ return nullptr;
+
+ if (Insn->getOpcode() == BPF::COPY) {
+ MachineOperand &opnd = Insn->getOperand(1);
+
+ if (!opnd.isReg())
+ return nullptr;
+
+ unsigned Reg = opnd.getReg();
+ if ((TargetRegisterInfo::isVirtualRegister(Reg) &&
+ MRI->getRegClass(Reg) == &BPF::GPRRegClass) ||
+ (TargetRegisterInfo::isPhysicalRegister(Reg) &&
+ BPF::GPRRegClass.contains(Reg)))
+ return nullptr;
+ }
+
return Insn;
}
OpenPOWER on IntegriCloud