[llvm] 6155fa6 - [X86] X86FixupVectorConstantsPass - pull out the hasAVX2() test and use single ConvertToBroadcast call. NFC.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 2 10:32:46 PDT 2023


Author: Simon Pilgrim
Date: 2023-11-02T17:32:25Z
New Revision: 6155fa69fdb6eb7bb579d7425272418d940c1033

URL: https://github.com/llvm/llvm-project/commit/6155fa69fdb6eb7bb579d7425272418d940c1033
DIFF: https://github.com/llvm/llvm-project/commit/6155fa69fdb6eb7bb579d7425272418d940c1033.diff

LOG: [X86] X86FixupVectorConstantsPass - pull out the hasAVX2() test and use single ConvertToBroadcast call. NFC.

Matches AVX512 ConvertToBroadcast calls and makes it easier to add extension support in the future.

Added: 
    

Modified: 
    llvm/lib/Target/X86/X86FixupVectorConstants.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86FixupVectorConstants.cpp b/llvm/lib/Target/X86/X86FixupVectorConstants.cpp
index 94e221fd877cbb9..d4d5cd8c3e16a4f 100644
--- a/llvm/lib/Target/X86/X86FixupVectorConstants.cpp
+++ b/llvm/lib/Target/X86/X86FixupVectorConstants.cpp
@@ -9,7 +9,7 @@
 // This file examines all full size vector constant pool loads and attempts to
 // replace them with smaller constant pool entries, including:
 // * Converting AVX512 memory-fold instructions to their broadcast-fold form
-// * TODO: Broadcasting of full width loads.
+// * Broadcasting of full width loads.
 // * TODO: Sign/Zero extension of full width loads.
 //
 //===----------------------------------------------------------------------===//
@@ -230,6 +230,7 @@ bool X86FixupVectorConstantsPass::processInstruction(MachineFunction &MF,
                                                      MachineInstr &MI) {
   unsigned Opc = MI.getOpcode();
   MachineConstantPool *CP = MI.getParent()->getParent()->getConstantPool();
+  bool HasAVX2 = ST->hasAVX2();
   bool HasDQI = ST->hasDQI();
   bool HasBWI = ST->hasBWI();
 
@@ -309,19 +310,19 @@ bool X86FixupVectorConstantsPass::processInstruction(MachineFunction &MF,
     /* Integer Loads */
   case X86::VMOVDQArm:
   case X86::VMOVDQUrm:
-    if (ST->hasAVX2())
-      return ConvertToBroadcast(0, 0, X86::VPBROADCASTQrm, X86::VPBROADCASTDrm,
-                                X86::VPBROADCASTWrm, X86::VPBROADCASTBrm, 1);
-    return ConvertToBroadcast(0, 0, X86::VMOVDDUPrm, X86::VBROADCASTSSrm, 0, 0,
-                              1);
+    return ConvertToBroadcast(
+        0, 0, HasAVX2 ? X86::VPBROADCASTQrm : X86::VMOVDDUPrm,
+        HasAVX2 ? X86::VPBROADCASTDrm : X86::VBROADCASTSSrm,
+        HasAVX2 ? X86::VPBROADCASTWrm : 0, HasAVX2 ? X86::VPBROADCASTBrm : 0,
+        1);
   case X86::VMOVDQAYrm:
   case X86::VMOVDQUYrm:
-    if (ST->hasAVX2())
-      return ConvertToBroadcast(0, X86::VBROADCASTI128, X86::VPBROADCASTQYrm,
-                                X86::VPBROADCASTDYrm, X86::VPBROADCASTWYrm,
-                                X86::VPBROADCASTBYrm, 1);
-    return ConvertToBroadcast(0, X86::VBROADCASTF128, X86::VBROADCASTSDYrm,
-                              X86::VBROADCASTSSYrm, 0, 0, 1);
+    return ConvertToBroadcast(
+        0, HasAVX2 ? X86::VBROADCASTI128 : X86::VBROADCASTF128,
+        HasAVX2 ? X86::VPBROADCASTQYrm : X86::VBROADCASTSDYrm,
+        HasAVX2 ? X86::VPBROADCASTDYrm : X86::VBROADCASTSSYrm,
+        HasAVX2 ? X86::VPBROADCASTWYrm : 0, HasAVX2 ? X86::VPBROADCASTBYrm : 0,
+        1);
   case X86::VMOVDQA32Z128rm:
   case X86::VMOVDQA64Z128rm:
   case X86::VMOVDQU32Z128rm:


        


More information about the llvm-commits mailing list