[PATCH] reorganize simplify_const_relational_operation

Paolo Bonzini bonzini@gnu.org
Tue Sep 4 19:31:00 GMT 2007


This patch reorganizes simplify_const_relational_operation to perform
logically related simplifications in the same "if" stanza, and to
return as soon as possible to avoid cascading many "else if"s.

In doing this, I noticed that the bounds-checking simplifications can
be easily made more powerful.  In particular, the bounds can be improved
over the result of get_mode_bounds using either nonzero_bits or
num_sign_bit_copies.  This subsumes and generalizes the optimization
on (GE (POPCOUNT A) 0) and (LT (POPCOUNT A) 0).  I put this in the
same patch because it untangles ABS simplifications from the others
in the last "else".

This removes the need for doing some of these optimizations in CSE,
and enables further RTL-level simplifications.  For example, this

   int f(int x)
   {
     return (f & 255) <= 256;
   }

is optimized by VRP but not with -fno-tree-vrp.  With this patch,
the same optimization is performed at RTL-level too (by CSE).  I
have not performed an assembly-output comparison, but I can do it
if somebody is interested.

Bootstrapped/regtested i686-pc-linux-gnu, all languages except
Ada.  Ok?

Paolo
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cse-simplify-relop.patch
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070904/5804073f/attachment.ksh>


More information about the Gcc-patches mailing list