[PATCH] Use broadcasts to optimize overall size when loading constant splat vectors (x86-64 with AVX or AVX2)

Demikhovsky, Elena elena.demikhovsky at intel.com
Tue Sep 16 01:25:12 PDT 2014


I just suggest to add this pattern to X86InstrSSE.td:

def : Pat<(v2i64 (X86VBroadcast (loadi64 addr:$src))),
          (v2i64 (EXTRACT_SUBREG (v4i64 (VBROADCASTSDYrm addr:$src)),sub_xmm)))>;

and remove this code:

+    if (VecSize == 128 && ScalarSize == 64) {
+      // This is only a size optimization - could be slightly slower in time.
+      if (OptForSize) {
+        if (ConstantSDNode *CI = dyn_cast<ConstantSDNode>(Ld)) {
+          C = CI->getConstantIntValue();
+          if (!Subtarget->hasAVX2()) {
+            // For an AVX CPU, fake an int splat with FP splat.
+            Opcode = X86ISD::MOVDDUP;
+            CVT = MVT::v2f64;
+            VT = MVT::v2f64;
+          }
+        } else if (ConstantFPSDNode *CF = dyn_cast<ConstantFPSDNode>(Ld)) {
+          C = CF->getConstantFPValue();
+          Opcode = X86ISD::MOVDDUP;
+        }
+      }

-  Elena


-----Original Message-----
From: Sanjay Patel [mailto:spatel at rotateright.com] 
Sent: Monday, September 15, 2014 19:23
To: spatel at rotateright.com; nrotem at apple.com; chandlerc at gmail.com; Andrea_DiBiagio at sn.scee.net; Demikhovsky, Elena
Cc: llvm-commits at cs.uiuc.edu
Subject: Re: [PATCH] Use broadcasts to optimize overall size when loading constant splat vectors (x86-64 with AVX or AVX2)

Hi Elena -

Thank you for the feedback. This function is already guarded against non-AVX CPUs. I've made that more explicit in the updated patch.

> You can take the broadcast to ymm as well.
> VBROADCASTSD ymm1,m64

This patch generates that - please see the testcases for expected output in both the AVX and AVX2 cases. Let me know if I missed something. I've tried to match the correct broadcast instruction with the vector element type in all cases, unless the ISA does not allow it.

http://reviews.llvm.org/D5347

Files:
  lib/Target/X86/X86ISelLowering.cpp
  test/CodeGen/X86/splat-for-size.ll
---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.




More information about the llvm-commits mailing list