[llvm] r317915 - [X86] Merge the template method selectAddrOfGatherScatterNode into selectVectorAddr. NFCI

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 10 11:26:04 PST 2017


Author: ctopper
Date: Fri Nov 10 11:26:04 2017
New Revision: 317915

URL: http://llvm.org/viewvc/llvm-project?rev=317915&view=rev
Log:
[X86] Merge the template method selectAddrOfGatherScatterNode into selectVectorAddr. NFCI

Just need to initialize a couple variables differently based on the node type. No need for a whole separate template method.

Modified:
    llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp

Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=317915&r1=317914&r2=317915&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Fri Nov 10 11:26:04 2017
@@ -204,11 +204,6 @@ namespace {
     bool selectVectorAddr(SDNode *Parent, SDValue N, SDValue &Base,
                           SDValue &Scale, SDValue &Index, SDValue &Disp,
                           SDValue &Segment);
-    template <class GatherScatterSDNode>
-    bool selectAddrOfGatherScatterNode(GatherScatterSDNode *Parent, SDValue N,
-                                       SDValue &Base, SDValue &Scale,
-                                       SDValue &Index, SDValue &Disp,
-                                       SDValue &Segment);
     bool selectMOV64Imm32(SDValue N, SDValue &Imm);
     bool selectLEAAddr(SDValue N, SDValue &Base,
                        SDValue &Scale, SDValue &Index, SDValue &Disp,
@@ -1507,12 +1502,23 @@ bool X86DAGToDAGISel::matchAddressBase(S
   return false;
 }
 
-template <class GatherScatterSDNode>
-bool X86DAGToDAGISel::selectAddrOfGatherScatterNode(
-    GatherScatterSDNode *Mgs, SDValue N, SDValue &Base, SDValue &Scale,
-    SDValue &Index, SDValue &Disp, SDValue &Segment) {
+bool X86DAGToDAGISel::selectVectorAddr(SDNode *Parent, SDValue N, SDValue &Base,
+                                       SDValue &Scale, SDValue &Index,
+                                       SDValue &Disp, SDValue &Segment) {
+  unsigned ScalarSize;
+  if (auto Mgs = dyn_cast<MaskedGatherScatterSDNode>(Parent)) {
+    Base = Mgs->getBasePtr();
+    Index = Mgs->getIndex();
+    ScalarSize = Mgs->getValue().getScalarValueSizeInBits();
+  } else {
+    auto X86Gather = cast<X86MaskedGatherSDNode>(Parent);
+    Base = X86Gather->getBasePtr();
+    Index = X86Gather->getIndex();
+    ScalarSize = X86Gather->getValue().getScalarValueSizeInBits();
+  }
+
   X86ISelAddressMode AM;
-  unsigned AddrSpace = Mgs->getPointerInfo().getAddrSpace();
+  unsigned AddrSpace = cast<MemSDNode>(Parent)->getPointerInfo().getAddrSpace();
   // AddrSpace 256 -> GS, 257 -> FS, 258 -> SS.
   if (AddrSpace == 256)
     AM.Segment = CurDAG->getRegister(X86::GS, MVT::i16);
@@ -1522,9 +1528,6 @@ bool X86DAGToDAGISel::selectAddrOfGather
     AM.Segment = CurDAG->getRegister(X86::SS, MVT::i16);
 
   SDLoc DL(N);
-  Base = Mgs->getBasePtr();
-  Index = Mgs->getIndex();
-  unsigned ScalarSize = Mgs->getValue().getScalarValueSizeInBits();
   Scale = getI8Imm(ScalarSize/8, DL);
 
   // If Base is 0, the whole address is in index and the Scale is 1
@@ -1542,18 +1545,6 @@ bool X86DAGToDAGISel::selectAddrOfGather
   return true;
 }
 
-bool X86DAGToDAGISel::selectVectorAddr(SDNode *Parent, SDValue N, SDValue &Base,
-                                       SDValue &Scale, SDValue &Index,
-                                       SDValue &Disp, SDValue &Segment) {
-  if (auto Mgs = dyn_cast<MaskedGatherScatterSDNode>(Parent))
-    return selectAddrOfGatherScatterNode<MaskedGatherScatterSDNode>(
-        Mgs, N, Base, Scale, Index, Disp, Segment);
-  if (auto X86Gather = dyn_cast<X86MaskedGatherSDNode>(Parent))
-    return selectAddrOfGatherScatterNode<X86MaskedGatherSDNode>(
-        X86Gather, N, Base, Scale, Index, Disp, Segment);
-  return false;
-}
-
 /// Returns true if it is able to pattern match an addressing mode.
 /// It returns the operands which make up the maximal addressing mode it can
 /// match by reference.




More information about the llvm-commits mailing list