What is "splat" in BUILD_VECTOR?

Hi All,

First of all, I am not native English speaker. While reading BUILD_VECTOR related code, for example,
PPCTargetLowering::LowerBUILD_VECTOR, I see “splat” here and there. Could someone explain what
it is (does splat mean the same thing across the whole code base)? Besides, from my English dictionary,
I don’t know why we call such thing as “splat”… :stuck_out_tongue:

Regards,
chenwj

Splat means to take a single value and build a vector out of identical copies of that value. 4 → [4,4,4,4]

I’m not sure where the term came from.

I was wondering this myself.

Would it be possible (in the spirit of the other discussion) to put
a clean explanation of this into The LLVM Lexicon — LLVM 16.0.0git documentation ?
(That was where I first looked for an answer.)

Perry

AFAIK, the first use of “splat” in this vector instruction sense comes from PowerPC’s Altivec extension:
https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.1.0/com.ibm.zos.v2r1.cbcpx01/bif_vec_splat.htm

It’s possible there were other instruction sets that used the term before this, but that’s my first sighting of vector splat. Given that PPC was an early (first?) LLVM backend, it makes sense that the code here adopted that terminology. In x86 AVX, it’s called a “broadcast” instruction, but we still mostly use “splat”.

Splat is derived from “splatter”. For vector functionality, we’re visualizing a scalar object being thrown into a vector register and breaking into identical pieces for each element of the vector. Disregard conservation of mass, etc. :slight_smile:

Would it be possible (in the spirit of the other discussion) to put
a clean explanation of this into The LLVM Lexicon — LLVM 16.0.0git documentation ?
(That was where I first looked for an answer.)

​Done. https://reviews.llvm.org/D32964 waiting for review. ;-)​