This is the mail archive of the gcc-patches@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]

[PATCH] if-convert one's complement abs


This patch optimizes the code pattern for the "one's complement abs" function:

 if (x < 0)
   y = ~x;

to y = ((signed)x>>(SIZE-1)) ^ x, where SIZE is the size of x's
storage type in bits.  This is similar to the  existing optimization
that converts  the abs function

if (x < 0)
  y = -x;

to (((signed) x >> (SIZE-1)) ^ x) - ((signed) x >> (SIZE-1)).

I've bootstrapped the compiler with these changes on x86_64-unknown-linux-gnu
 and ran the testsuite.


2009-09-24  Easwaran Raman <eraman@google.com>
* ifcvt.c (noce_try_abs): Recognize pattern and call
expand_one_cmpl_abs_nojump.
* optabs.c (expand_one_cmpl_abs_nojump): New function.
* optabs.h: Update declarations.
* testsuite/gcc.target/i386/ifcvt-onecmpl-abs-1.c: New file.
* testsuite/gcc.dg/ifcvt-onecmpl-abs-1.c: New file.

Attachment: ifcvtpatch.txt
Description: Text document


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