[PATCH] x86: Define _mm*_undefined_*
Richard Biener
richard.guenther@gmail.com
Tue Mar 18 15:17:00 GMT 2014
On Tue, Mar 18, 2014 at 4:09 PM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Tue, Mar 18, 2014 at 4:03 PM, Ulrich Drepper <drepper@gmail.com> wrote:
>> On Tue, Mar 18, 2014 at 7:13 AM, Richard Biener
>> <richard.guenther@gmail.com> wrote:
>>> extern __inline __m512
>>> __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
>>> _mm512_undefined_ps (void)
>>> {
>>> __m512 __Y = __Y;
>>> return __Y;
>>> }
>>
>>
>> This provokes no warnings (as you wrote) and it doesn't clobber flags,
>> but it doesn't avoid loading. The code below creates a pxor for the
>> parameter. That's what I think compiler support should help to get
>> rid of. If the compiler has some magic to recognize -1 masks then
>> this will help in some situations but it seems to be a specific
>> implementation for the intrinsics while I've been looking at generic
>> solution.
>>
>>
>> typedef double __m128d __attribute__ ((__vector_size__ (16), __may_alias__));
>>
>> void g(__m128d);
>>
>> extern __inline __m128d
>> __attribute__((__gnu_inline__, __always_inline__, __artificial__, const))
>> _mm_undefined_pd(void) {
>> __m128d v = v;
>> return v;
>> }
>>
>> void
>> f()
>> {
>> g(_mm_undefined_pd());
>> }
>
> The load from zero is caused by the init-regs pass. To quote:
>
> /* Check all of the uses of pseudo variables. If any use that is MUST
> uninitialized, add a store of 0 immediately before it. For
> subregs, this makes combine happy. For full word regs, this makes
> other optimizations, like the register allocator and the reg-stack
> happy as well as papers over some problems on the arm and other
> processors where certain isa constraints cannot be handled by gcc.
> These are of the form where two operands to an insn my not be the
> same. The ra will only make them the same if they do not
> interfere, and this can only happen if one is not initialized.
>
> There is also the unfortunate consequence that this may mask some
> buggy programs where people forget to initialize stack variable.
> Any programmer with half a brain would look at the uninitialized
> variable warnings. */
>
> You can disable it with -fdisable-rtl-init-regs. Not sure if the above
> comment today is just overly cautious ... maybe we should have a
> target hook that controls its execution.
Btw, without this zeroing (where zero is also "undefined") this may
be an information leak and thus possibly a security issue? That is,
how is _mm_undefined_pd () specified?
Richard.
> Richard.
More information about the Gcc-patches
mailing list