[AMDGPU] Fixed SIInstrInfo::getOpSize to handle subregs
authorStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
Mon, 1 Oct 2018 18:00:02 +0000 (18:00 +0000)
committerStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
Mon, 1 Oct 2018 18:00:02 +0000 (18:00 +0000)
Currently it returns incorrect operand size for a target independet
node such as COPY if operand is a register with subreg. Instead of
correct subreg size it returns a size of the whole superreg.

Differential Revision: https://reviews.llvm.org/D52736

llvm-svn: 343508

llvm/lib/Target/AMDGPU/SIInstrInfo.h

index 4685441..4214046 100644 (file)
@@ -730,6 +730,11 @@ public:
   /// This form should usually be preferred since it handles operands
   /// with unknown register classes.
   unsigned getOpSize(const MachineInstr &MI, unsigned OpNo) const {
+    const MachineOperand &MO = MI.getOperand(OpNo);
+    if (MO.isReg()) {
+      if (unsigned SubReg = MO.getSubReg())
+        return RI.getSubRegIndexLaneMask(SubReg).getNumLanes() * 4;
+    }
     return RI.getRegSizeInBits(*getOpRegClass(MI, OpNo)) / 8;
   }