public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/57009] New: Select best typed instruction for scalar bitwise operations
@ 2013-04-19 19:46 glisse at gcc dot gnu.org
  2021-12-06 23:52 ` [Bug target/57009] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: glisse at gcc dot gnu.org @ 2013-04-19 19:46 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57009

             Bug #: 57009
           Summary: Select best typed instruction for scalar bitwise
                    operations
    Classification: Unclassified
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: glisse@gcc.gnu.org
            Target: x86_64-linux-gnu


Hello,

I purposedly took almost the same title as PR 54716, because this is the same
issue, but for scalars. Consider this code:

union A { double d; unsigned long long i; };

bool f(double a, double b, double c){
  A x, y, z;
  x.d = a * a;
  y.d = b * b;
  z.i = x.i & y.i;
  return z.d < c;
}

which compiles to:

    mulsd    %xmm0, %xmm0
    mulsd    %xmm1, %xmm1
    movq    %xmm0, %rax
    movq    %xmm1, %rdx
    andq    %rdx, %rax
    movq    %rax, %xmm0
    ucomisd    %xmm0, %xmm2
    seta    %al

when using andpd would save 3 movq. Note that for vectors, we get nicer code
thanks to Jakub's patch:

    mulpd    %xmm1, %xmm1
    mulpd    %xmm0, %xmm0
    andpd    %xmm1, %xmm0
    cmpltpd    %xmm2, %xmm0

It would be nice to extend that code to scalars (including the case where one
of the arguments is a constant).

I hit this while experimenting for PR 56944.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug target/57009] Select best typed instruction for scalar bitwise operations
  2013-04-19 19:46 [Bug target/57009] New: Select best typed instruction for scalar bitwise operations glisse at gcc dot gnu.org
@ 2021-12-06 23:52 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-06 23:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57009

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Marc Glisse from comment #1) 
> union A { double d; unsigned long long i; };
> bool f(double x){
>   A a; a.d = x;
>   unsigned long long inf = 0x7ff0000000000000;
>   return (a.i & inf) != inf;
> }
> 
> (I use != and not < in the example above because gcc insists on creating a
> new constant inf-1 and replacing <inf with <=inf-1)

I think the above issue is the same issue as mentioned in PR 95740.

I have not looked into the original comments yet but I think there might be a
dup of it somewhere too.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-06 23:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-19 19:46 [Bug target/57009] New: Select best typed instruction for scalar bitwise operations glisse at gcc dot gnu.org
2021-12-06 23:52 ` [Bug target/57009] " pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).