[llvm-dev] array fill idioms

Bagel via llvm-dev llvm-dev at lists.llvm.org
Thu Nov 10 14:17:00 PST 2016

On 11/10/2016 04:07 PM, Ryan Taylor wrote:
> Like a list initializer, but will do partials/slices?

More than just an initializer, and yes it must do partials/slices.  More like
std:fill in C++;

> Are you just looking to create an intrinsic that will generate a jump to a lib
> routine? 

If all else fails, then call a library routine.  But if the number of elements
is "small" and suitably aligned, them perhaps several elements can be filled by
a simple load a constant and store.

> On Thu, Nov 10, 2016 at 5:02 PM, Bagel via llvm-dev <llvm-dev at lists.llvm.org
> <mailto:llvm-dev at lists.llvm.org>> wrote:
>     Yes, I know this works peachy keen for char arrays.  I'm looking at (which is
>     hard to express in C) something like
>     void foo () {
>        int bar[20] = { 42, 42, ..., 42 };
>     }
>     I don't want to do a memcopy of the 20 element constant array, and memset
>     doesn't work here.  I want an intrinsic that copys the scalar int constant 42
>     to each element of the int array.
>     bagel

More information about the llvm-dev mailing list