[llvm-dev] One element vectors versus scalars

Martin J. O'Riordan via llvm-dev
Tue, 10 Nov 2015 12:53:56 -0000

Thanks Hal.  In our case the ABI issue doesn't arise, but I'll have to
think about the legalization to see if maybe we could write our type definitions
better.

	MartinO

-----Original Message-----
From: Hal Finkel [mailto:hfinkel at anl.gov]
Sent: 10 November 2015 12:34

----- Original Message -----
> From: "Martin J. O'Riordan via llvm-dev" <llvm-dev at
lists.llvm.org>
>
> I am curious as to why LLVM has explicit support for 1 element
> vectors, for example ‘ v1i32 ’. Are there some contexts where handling
> a value as a 1 element vector can yield better code quality than the
> corresponding scalar ‘ i32 ’?

Hi Martin,

No, but I see two reasons we support 1-element vectors:

 1. Having 1-element vectors makes a lot of the SDAG legalization code simpler,
allowing us to separate the code that splits vector types from the code that
transforms 1-element vectors into scalars.

 2. On some platforms, there are ABI differences between the two types. (e.g.
i128 and <1 x i128> are passed in different registers across function-call
boundaries).

 -Hal