[PATCH] D72021: [LegalizeVectorOps] Pas the post-UpdateNodeOperands version of Op to ExpandLoad/ExpandStore

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 30 15:25:50 PST 2019


craig.topper created this revision.
craig.topper added reviewers: efriedma, spatel, RKSimon, niravd, deadalnix.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
craig.topper updated this revision to Diff 235654.
craig.topper added a comment.

Remove stray diff that snuck in from another patch


UpdateNodeOperands might CSE to another existing node. So we should make sure we're legalizing that node otherwise we might fail to hook up the operands properly. I've moved the result registration up to the caller to avoid having to pass both Result and Op into the functions where it might be confusing which is which.

This address 2 other issues pointed out in D71861 <https://reviews.llvm.org/D71861>.


https://reviews.llvm.org/D72021

Files:
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp


Index: llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
@@ -130,7 +130,7 @@
   /// supported by the target.
   SDValue ExpandVSELECT(SDValue Op);
   SDValue ExpandSELECT(SDValue Op);
-  SDValue ExpandLoad(SDValue Op);
+  std::pair<SDValue, SDValue> ExpandLoad(SDValue Op);
   SDValue ExpandStore(SDValue Op);
   SDValue ExpandFNEG(SDValue Op);
   SDValue ExpandFSUB(SDValue Op);
@@ -265,9 +265,13 @@
           return TranslateLegalizeResults(Op, Lowered);
         }
         LLVM_FALLTHROUGH;
-      case TargetLowering::Expand:
+      case TargetLowering::Expand: {
         Changed = true;
-        return ExpandLoad(Op);
+        std::pair<SDValue, SDValue> Tmp = ExpandLoad(Result);
+        AddLegalizedOperand(Op.getValue(0), Tmp.first);
+        AddLegalizedOperand(Op.getValue(1), Tmp.second);
+        return Op.getResNo() ? Tmp.first : Tmp.second;
+      }
       }
     }
   } else if (Op.getOpcode() == ISD::STORE) {
@@ -290,9 +294,12 @@
         }
         return TranslateLegalizeResults(Op, Lowered);
       }
-      case TargetLowering::Expand:
+      case TargetLowering::Expand: {
         Changed = true;
-        return ExpandStore(Op);
+        SDValue Chain = ExpandStore(Result);
+        AddLegalizedOperand(Op, Chain);
+        return Chain;
+      }
       }
     }
   }
@@ -628,7 +635,7 @@
   return Promoted;
 }
 
-SDValue VectorLegalizer::ExpandLoad(SDValue Op) {
+std::pair<SDValue, SDValue> VectorLegalizer::ExpandLoad(SDValue Op) {
   LoadSDNode *LD = cast<LoadSDNode>(Op.getNode());
 
   EVT SrcVT = LD->getMemoryVT();
@@ -763,16 +770,12 @@
     }
   }
 
-  AddLegalizedOperand(Op.getValue(0), Value);
-  AddLegalizedOperand(Op.getValue(1), NewChain);
-
-  return (Op.getResNo() ? NewChain : Value);
+  return std::make_pair(Value, NewChain);
 }
 
 SDValue VectorLegalizer::ExpandStore(SDValue Op) {
   StoreSDNode *ST = cast<StoreSDNode>(Op.getNode());
   SDValue TF = TLI.scalarizeVectorStore(ST, DAG);
-  AddLegalizedOperand(Op, TF);
   return TF;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72021.235654.patch
Type: text/x-patch
Size: 2174 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191230/0e4bd6c5/attachment.bin>


More information about the llvm-commits mailing list