------- Comment #2 from tmartsum at gmail dot com  2010-09-12 15:01 -------
With Subtraction the situation is very similar:

struct Skew1 // Even
{
  unsigned long long data;
  unsigned long unused;
};

struct Skew2 // Odd
{
  unsigned long unused;
  unsigned long long data;
};

struct ULongLongLong
{
  union
  {
    unsigned long m_data[3];
    Skew1 m_rep1;
    Skew2 m_rep2;
  };
  ULongLongLong()
  {
    m_data[0]=0;
    m_data[1]=0;
    m_data[2]=0;
  }
  void print() {  std::cout << m_data[0] << "," << m_data[1] << "," <<
m_data[2] << "\n";}
//  void addtest(const ULongLongLong &b); // operator += 
  void subtest(const ULongLongLong &b); // operator -=   
};

It gives the following code:

.globl _ZN13ULongLongLong7subtestERKS_
        .type   _ZN13ULongLongLong7subtestERKS_, @function
_ZN13ULongLongLong7subtestERKS_:
.LFB965:
        .cfi_startproc
        .cfi_personality 0x0,__gxx_personality_v0
        pushl   %ebp
        .cfi_def_cfa_offset 8
        movl    %esp, %ebp
        .cfi_offset 5, -8
        .cfi_def_cfa_register 5
        movl    12(%ebp), %edx
        movl    8(%ebp), %eax
        pushl   %ebx
        xorl    %ebx, %ebx
        .cfi_offset 3, -12
        movl    (%edx), %ecx
        subl    %ecx, (%eax)
        sbbl    %ebx, 4(%eax)
        xorl    %ebx, %ebx
        movl    4(%edx), %ecx
        subl    %ecx, 4(%eax)
        sbbl    %ebx, 8(%eax)
        movl    8(%edx), %edx
        subl    %edx, 8(%eax)
        popl    %ebx
        popl    %ebp
        ret
        .cfi_endproc

This could be optimized (just like the addition).


-- 


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

Reply via email to