Re: AVX - cast from YMM to XMM without overhead?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Marc Glisse <marc.glisse@xxxxxxxx> writes:

> On Sun, 24 Jun 2012, Dag Lem wrote:
> 
> > Marc Glisse <marc.glisse@xxxxxxxx> writes:
> >
> >> On Sun, 24 Jun 2012, Dag Lem wrote:
> >>

[...]

> > I guess you're right. Casting as in my naïve approach would also have
> > limited usefulness in that it would only be able to extract the lower
> > (and not the higher) bits of a vector register. However I can't help
> > thinking that some kind of intrinsic/operator/whatever to extract
> > vector register parts would be useful.
> 
> But they do exist. You even criticized one for generating a
> superfluous mov and reported a bug against one that mysteriously
> started generating vshufps ;-)

I should have been more specific; what I meant was a *portable*
intrinsic/operator/whatever, not AVX intrinsics.

[...]

> or *z=*(v2sf*)&d; if you really want pointers. I agree it isn't that
> pretty, but it could be worse...

Well, I guess you're right - it's not that bad, and certainly
portable. If only gcc could translate the casts to no-ops or single
instructions, instead of insisting on storing and reloading the
registers from memory.

[...]

> Although since I was the one who tried to fix it and I gave up, you
> may have to wait a bit for someone else to be motivated...

Don't give up! ;-)

> 
> I have to say, I am impressed by the code generated for this at -O3:
> 
> #include <x86intrin.h>
> __v2sf f(__v4sf x){
>    __v2sf d=*(__v2sf*)&x;
>    return d;
> }
> 
>  	movaps	%xmm0, -72(%rsp)
>  	movq	-72(%rsp), %rax
>  	movq	%rax, -80(%rsp)
>  	movlps	-80(%rsp), %xmm0

Yes, it is impressive. But could have been a no-op?

Again, thanks for your help and feedback. I'll just stick to pointer
casts, and hope that even better code will be generated some time in
the future.

-- 
Best regards,

Dag Lem



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux