Use broadcasts to optimize overall size when loading constant splat vectors (x86...
authorSanjay Patel <spatel@rotateright.com>
Mon, 22 Sep 2014 18:54:01 +0000 (18:54 +0000)
committerSanjay Patel <spatel@rotateright.com>
Mon, 22 Sep 2014 18:54:01 +0000 (18:54 +0000)
commit65398878478edb79c05bd1579ede5ae992a93080
treeaef55316de5d72506ee68a238ab1affeb769ce75
parent73c604b290b039be25e30c25ca1325d715a30c5b
Use broadcasts to optimize overall size when loading constant splat vectors (x86-64 with AVX or AVX2).

We generate broadcast instructions on CPUs with AVX2 to load some constant splat vectors.
This patch should preserve all existing behavior with regular optimization levels,
but also use splats whenever possible when optimizing for *size* on any CPU with AVX or AVX2.

The tradeoff is up to 5 extra instruction bytes for the broadcast instruction to save
at least 8 bytes (up to 31 bytes) of constant pool data.

Differential Revision: http://reviews.llvm.org/D5347

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218263 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86InstrSSE.td
test/CodeGen/X86/splat-for-size.ll [new file with mode: 0644]