[llvm] r335694 - [X86] Don't store register and memory FMA3 opcodes in the same X86InstrFMA3Group.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 26 17:42:24 PDT 2018


Author: ctopper
Date: Tue Jun 26 17:42:24 2018
New Revision: 335694

URL: http://llvm.org/viewvc/llvm-project?rev=335694&view=rev
Log:
[X86] Don't store register and memory FMA3 opcodes in the same X86InstrFMA3Group.

Nothing was using this relationship. By splitting them we no longer need to worry about register or memory entries being empty in a group.

The memory folding tables in X86InstrInfo.cpp can be used to access this relationship if needed.

Modified:
    llvm/trunk/lib/Target/X86/X86InstrFMA3Info.cpp
    llvm/trunk/lib/Target/X86/X86InstrFMA3Info.h
    llvm/trunk/lib/Target/X86/X86InstrInfo.cpp

Modified: llvm/trunk/lib/Target/X86/X86InstrFMA3Info.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrFMA3Info.cpp?rev=335694&r1=335693&r2=335694&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrFMA3Info.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86InstrFMA3Info.cpp Tue Jun 26 17:42:24 2018
@@ -26,27 +26,28 @@ X86InstrFMA3Info *X86InstrFMA3Info::getX
   return &*X86InstrFMA3InfoObj;
 }
 
-#define FMA3BASE(R132, R213, R231, M132, M213, M231, Attrs)                    \
-  { { R132, R213, R231 }, { M132, M213, M231 }, Attrs },
-
-#define FMA3RMA(R132, R213, R231, M132, M213, M231, Attrs)                     \
-  FMA3BASE(X86::R132, X86::R213, X86::R231, X86::M132, X86::M213, X86::M231, Attrs)
-
-#define FMA3RM(R132, R213, R231, M132, M213, M231)                             \
-  FMA3RMA(R132, R213, R231, M132, M213, M231, 0)
+#define FMA3BASE(X132, X213, X231, Attrs)                                      \
+  { { X132, X213, X231 }, Attrs },
 
 #define FMA3RA(R132, R213, R231, Attrs)                                        \
-  FMA3BASE(X86::R132, X86::R213, X86::R231, 0, 0, 0, Attrs)
+  FMA3BASE(X86::R132, X86::R213, X86::R231, Attrs)
 
 #define FMA3R(R132, R213, R231)                                                \
   FMA3RA(R132, R213, R231, 0)
 
 #define FMA3MA(M132, M213, M231, Attrs)                                        \
-  FMA3BASE(0, 0, 0, X86::M132, X86::M213, X86::M231, Attrs)
+  FMA3BASE(X86::M132, X86::M213, X86::M231, Attrs)
 
 #define FMA3M(M132, M213, M231)                                                \
   FMA3MA(M132, M213, M231, 0)
 
+#define FMA3RMA(R132, R213, R231, M132, M213, M231, Attrs)                     \
+  FMA3RA(R132, R213, R231, Attrs)                                              \
+  FMA3MA(M132, M213, M231, Attrs)
+
+#define FMA3RM(R132, R213, R231, M132, M213, M231)                             \
+  FMA3RMA(R132, R213, R231, M132, M213, M231, 0)
+
 #define FMA3_AVX2_VECTOR_GROUP(Name)                                           \
   FMA3RM(Name##132PSr, Name##213PSr, Name##231PSr,                             \
          Name##132PSm, Name##213PSm, Name##231PSm)                             \
@@ -231,17 +232,8 @@ static const X86InstrFMA3Group Groups[]
 
 X86InstrFMA3Info::X86InstrFMA3Info() {
   for (const X86InstrFMA3Group &G : Groups) {
-    if (G.RegOpcodes[0])
-      OpcodeToGroup[G.RegOpcodes[0]] = &G;
-    if (G.RegOpcodes[1])
-      OpcodeToGroup[G.RegOpcodes[1]] = &G;
-    if (G.RegOpcodes[2])
-      OpcodeToGroup[G.RegOpcodes[2]] = &G;
-    if (G.MemOpcodes[0])
-      OpcodeToGroup[G.MemOpcodes[0]] = &G;
-    if (G.MemOpcodes[1])
-      OpcodeToGroup[G.MemOpcodes[1]] = &G;
-    if (G.MemOpcodes[2])
-      OpcodeToGroup[G.MemOpcodes[2]] = &G;
+    OpcodeToGroup[G.Opcodes[0]] = &G;
+    OpcodeToGroup[G.Opcodes[1]] = &G;
+    OpcodeToGroup[G.Opcodes[2]] = &G;
   }
 }

Modified: llvm/trunk/lib/Target/X86/X86InstrFMA3Info.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrFMA3Info.h?rev=335694&r1=335693&r2=335694&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrFMA3Info.h (original)
+++ llvm/trunk/lib/Target/X86/X86InstrFMA3Info.h Tue Jun 26 17:42:24 2018
@@ -24,17 +24,11 @@
 namespace llvm {
 
 /// This class is used to group {132, 213, 231} forms of FMA opcodes together.
-/// Each of the groups has either 3 register opcodes, 3 memory opcodes,
-/// or 6 register and memory opcodes. Also, each group has an attrubutes field
-/// describing it.
+/// Each of the groups has either 3 opcodes, Also, each group has an attributes
+/// field describing it.
 struct X86InstrFMA3Group {
-  /// An array holding 3 forms of register FMA opcodes.
-  /// Entries will be 0 if there are no register opcodes in the group.
-  uint16_t RegOpcodes[3];
-
-  /// An array holding 3 forms of memory FMA opcodes.
-  /// Entries will be 0 if there are no register opcodes in the group.
-  uint16_t MemOpcodes[3];
+  /// An array holding 3 forms of FMA opcodes.
+  uint16_t Opcodes[3];
 
   /// This bitfield specifies the attributes associated with the created
   /// FMA groups of opcodes.
@@ -62,50 +56,19 @@ struct X86InstrFMA3Group {
     X86FMA3KZeroMasked = 0x4,
   };
 
-  /// Returns a memory form opcode that is the equivalent of the given register
-  /// form opcode \p RegOpcode. 0 is returned if the group does not have
-  /// either register of memory opcodes.
-  unsigned getMemOpcode(unsigned RegOpcode) const {
-    for (unsigned Form = 0; Form < 3; Form++)
-      if (RegOpcodes[Form] == RegOpcode)
-        return MemOpcodes[Form];
-    return 0;
+  /// Returns the 132 form of FMA opcode.
+  unsigned get132Opcode() const {
+    return Opcodes[Form132];
   }
 
-  /// Returns the 132 form of FMA register opcode.
-  unsigned getReg132Opcode() const {
-    assert(RegOpcodes[Form132] && "The group does not have register opcodes.");
-    return RegOpcodes[Form132];
+  /// Returns the 213 form of FMA opcode.
+  unsigned get213Opcode() const {
+    return Opcodes[Form213];
   }
 
-  /// Returns the 213 form of FMA register opcode.
-  unsigned getReg213Opcode() const {
-    assert(RegOpcodes[Form213] && "The group does not have register opcodes.");
-    return RegOpcodes[Form213];
-  }
-
-  /// Returns the 231 form of FMA register opcode.
-  unsigned getReg231Opcode() const {
-    assert(RegOpcodes[Form231] && "The group does not have register opcodes.");
-    return RegOpcodes[Form231];
-  }
-
-  /// Returns the 132 form of FMA memory opcode.
-  unsigned getMem132Opcode() const {
-    assert(MemOpcodes[Form132] && "The group does not have memory opcodes.");
-    return MemOpcodes[Form132];
-  }
-
-  /// Returns the 213 form of FMA memory opcode.
-  unsigned getMem213Opcode() const {
-    assert(MemOpcodes[Form213] && "The group does not have memory opcodes.");
-    return MemOpcodes[Form213];
-  }
-
-  /// Returns the 231 form of FMA memory opcode.
-  unsigned getMem231Opcode() const {
-    assert(MemOpcodes[Form231] && "The group does not have memory opcodes.");
-    return MemOpcodes[Form231];
+  /// Returns the 231 form of FMA opcode.
+  unsigned get231Opcode() const {
+    return Opcodes[Form231];
   }
 
   /// Returns true iff the group of FMA opcodes holds intrinsic opcodes.
@@ -123,24 +86,6 @@ struct X86InstrFMA3Group {
   bool isKMasked() const {
     return (Attributes & (X86FMA3KMergeMasked | X86FMA3KZeroMasked)) != 0;
   }
-
-  /// Returns true iff the given \p Opcode is a register opcode from the
-  /// groups of FMA opcodes.
-  bool isRegOpcodeFromGroup(unsigned Opcode) const {
-    for (unsigned Form = 0; Form < 3; Form++)
-      if (Opcode == RegOpcodes[Form])
-        return true;
-    return false;
-  }
-
-  /// Returns true iff the given \p Opcode is a memory opcode from the
-  /// groups of FMA opcodes.
-  bool isMemOpcodeFromGroup(unsigned Opcode) const {
-    for (unsigned Form = 0; Form < 3; Form++)
-      if (Opcode == MemOpcodes[Form])
-        return true;
-    return false;
-  }
 };
 
 /// This class provides information about all existing FMA3 opcodes

Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=335694&r1=335693&r2=335694&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Tue Jun 26 17:42:24 2018
@@ -6766,15 +6766,9 @@ unsigned X86InstrInfo::getFMA3OpcodeToCo
   };
 
   unsigned FMAForms[3];
-  if (FMA3Group.isRegOpcodeFromGroup(Opc)) {
-    FMAForms[0] = FMA3Group.getReg132Opcode();
-    FMAForms[1] = FMA3Group.getReg213Opcode();
-    FMAForms[2] = FMA3Group.getReg231Opcode();
-  } else {
-    FMAForms[0] = FMA3Group.getMem132Opcode();
-    FMAForms[1] = FMA3Group.getMem213Opcode();
-    FMAForms[2] = FMA3Group.getMem231Opcode();
-  }
+  FMAForms[0] = FMA3Group.get132Opcode();
+  FMAForms[1] = FMA3Group.get213Opcode();
+  FMAForms[2] = FMA3Group.get231Opcode();
   unsigned FormIndex;
   for (FormIndex = 0; FormIndex < 3; FormIndex++)
     if (Opc == FMAForms[FormIndex])




More information about the llvm-commits mailing list