This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/42588] New: unnecessary move through x87 stack/local frame for union


from
http://embed.cs.utah.edu/embarrassing/dec_09/harvest/gcc-head_llvm-gcc-head/

union __anonunion___u_19
{
  double __d;
  int __i[2];
};
extern __attribute__ ((__nothrow__))
     int __signbit (double __x) __attribute__ ((__const__));
     extern __attribute__ ((__nothrow__))
     int __signbit (double __x) __attribute__ ((__const__));
     extern int __signbit (double __x)
{
  union __anonunion___u_19 __u;

  {
    __u.__d = __x;
    return (__u.__i[1] < 0);
  }
}

/* Checksum = AEFB9790 */

generates with -O2 -m32 -fomit-frame-pointer

 subl    $12, %esp
        fldl    16(%esp)
        fstpl   (%esp)
        movl    4(%esp), %eax
        addl    $12, %esp
        shrl    $31, %eax
        ret

the move through the x87 stack and the local frame is totally unnecessary;
the shr could be just done on the input stack value

in comparison llvm generates the much neater:

   0:   0f b7 44 24 0c          movzwl 0xc(%esp),%eax
   5:   c1 e8 0f                shr    $0xf,%eax
   8:   c3                      ret


-- 
           Summary: unnecessary move through x87 stack/local frame for union
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: andi-gcc at firstfloor dot org
  GCC host triplet: x86_64-linux
GCC target triplet: x86_64-linux -m32


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]