help-rcs
[Top][All Lists]
Advanced

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

[Bug optimization/14504] Missed Bit Twiddling Optimization


From: kazu at cs dot umass dot edu
Subject: [Bug optimization/14504] Missed Bit Twiddling Optimization
Date: 11 Mar 2004 00:09:29 -0000

------- Additional Comments From kazu at cs dot umass dot edu  2004-03-11 00:09 
-------
I've got a patch.

/* There are four cases to handle modulo whether FLAG appears
   positively and ordering of operands TARGET and MASK in the
   expression.

   With my patch, gcc -O2 -fomit-frame-pointer -mregparm=3 generates
   the following assembly code.  */

typedef _Bool bool;

unsigned long
cond_mask_0 (bool flag, unsigned long mask, unsigned long target)
{
  return flag ? target | mask : target & ~mask;
#if 0
        movzbl  %al, %eax
        decl    %eax
        xorl    %eax, %ecx
        orl     %edx, %ecx
        xorl    %ecx, %eax
#endif
}

unsigned long
cond_mask_1 (bool flag, unsigned long mask, unsigned long target)
{
  return flag ? target | ~mask : target & mask;
#if 0
        movzbl  %al, %eax
        negl    %eax
        xorl    %eax, %ecx
        andl    %edx, %ecx
        xorl    %ecx, %eax
#endif
}

unsigned long
cond_mask_2 (bool flag, unsigned long mask, unsigned long target)
{
  return flag ? target & mask : target | ~mask;
#if 0
        movzbl  %al, %eax
        decl    %eax
        xorl    %eax, %ecx
        andl    %edx, %ecx
        xorl    %ecx, %eax
#endif
}

unsigned long
cond_mask_3 (bool flag, unsigned long mask, unsigned long target)
{
  return flag ? target & ~mask : target | mask;
#if 0
        movzbl  %al, %eax
        negl    %eax
        xorl    %eax, %ecx
        orl     %edx, %ecx
        xorl    %ecx, %eax
#endif
}


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kazu at cs dot umass dot edu
         AssignedTo|unassigned at gcc dot gnu   |kazu at cs dot umass dot edu
                   |dot org                     |
             Status|NEW                         |ASSIGNED


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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]