[LLVMbugs] [Bug 22755] New: CombineToPreIndexedLoadStore need consider ResNo in folding

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Mar 2 10:23:34 PST 2015


http://llvm.org/bugs/show_bug.cgi?id=22755

            Bug ID: 22755
           Summary: CombineToPreIndexedLoadStore need consider ResNo in
                    folding
           Product: tools
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: llc
          Assignee: unassignedbugs at nondot.org
          Reporter: yinma at codeaurora.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

In this code
  // If the offset is a constant, there may be other adds of constants that
  // can be folded with this one. We should do this to avoid having to keep
  // a copy of the original base pointer.
  SmallVector<SDNode *, 16> OtherUses;
  if (isa<ConstantSDNode>(Offset))
    for (SDNode *Use : BasePtr.getNode()->uses()) {
      if (Use == Ptr.getNode())
        continue;

      if (Use->isPredecessorOf(N))
        continue;

      if (Use->getOpcode() != ISD::ADD && Use->getOpcode() != ISD::SUB) {
        OtherUses.clear();
        break;
      }

      SDValue Op0 = Use->getOperand(0), Op1 = Use->getOperand(1);
      if (Op1.getNode() == BasePtr.getNode())
        std::swap(Op0, Op1);
      assert(Op0.getNode() == BasePtr.getNode() &&
             "Use of ADD/SUB but not an operand");

      if (!isa<ConstantSDNode>(Op1)) {
        OtherUses.clear();
        break;
      }

      // FIXME: In some cases, we can be smarter about this.
      if (Op1.getValueType() != Offset.getValueType()) {
        OtherUses.clear();
        break;
      }

      OtherUses.push_back(Use);
    }

It tried to fold two adds. However, in a situation where it is a preindex load
L converted before, it is possible that 

the input of one add is from the result of L and the input of another add is
from the updated index of L. These two adds cannot be combined together
clearly,

so we need check to make sure two adds are from the same ResNo by add code like
this 

      // FIXME: In some cases, we can be smarter about this.
      if (Op1.getValueType() != Offset.getValueType()) {
        OtherUses.clear();
        break;
      }

      // Must come from the same resNo.
      if (Op0.getResNo() != Ptr.getOperand(0).getResNo()) { 
        OtherUses.clear();
        break;
      }

      OtherUses.push_back(Use);

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150302/0901e53b/attachment.html>


More information about the llvm-bugs mailing list