Commit 00d19664 authored by Simon Pilgrim's avatar Simon Pilgrim
Browse files

[X86] matchIndexRecursively - don't peek through SIGN_EXTEND for vector indices

Don't rely on implicit extension for gather/scatter ops
parent d43f324f
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -2225,6 +2225,8 @@ SDValue X86DAGToDAGISel::matchIndexRecursively(SDValue N,
  if (Depth >= SelectionDAG::MaxRecursionDepth)
    return N;

  EVT VT = N.getValueType();

  // index: add(x,c) -> index: x, disp + c
  if (CurDAG->isBaseWithConstantOffset(N)) {
    auto *AddVal = cast<ConstantSDNode>(N.getOperand(1));
@@ -2253,7 +2255,7 @@ SDValue X86DAGToDAGISel::matchIndexRecursively(SDValue N,

  // index: sext(add_nsw(x,c)) -> index: sext(x), disp + sext(c)
  // TODO: call matchIndexRecursively(AddSrc) if we won't corrupt sext?
  if (N.getOpcode() == ISD::SIGN_EXTEND) {
  if (N.getOpcode() == ISD::SIGN_EXTEND && !VT.isVector()) {
    SDValue Src = N.getOperand(0);
    if (Src.getOpcode() == ISD::ADD && Src->getFlags().hasNoSignedWrap()) {
      if (CurDAG->isBaseWithConstantOffset(Src)) {
@@ -2262,7 +2264,6 @@ SDValue X86DAGToDAGISel::matchIndexRecursively(SDValue N,
        uint64_t Offset = (uint64_t)AddVal->getSExtValue() * AM.Scale;
        if (!foldOffsetIntoAddress(Offset, AM)) {
          SDLoc DL(N);
          EVT VT = N.getValueType();
          SDValue ExtSrc = CurDAG->getNode(ISD::SIGN_EXTEND, DL, VT, AddSrc);
          SDValue ExtVal = CurDAG->getConstant(AddVal->getSExtValue(), DL, VT);
          SDValue ExtAdd = CurDAG->getNode(ISD::ADD, DL, VT, ExtSrc, ExtVal);