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]

Re: [PATCH] if-convert "y < 0 ? z : 0" into "(y >> C) & z"


> The idea comes from Andrew Pinki's
> posting "fold-const trick for gzip" from last December.  RTH
> suggested that this transformation should be performed in ifcvt.c
> instead of fold-const.c.

The fact is that that trick was actually an unsigned subtraction with
saturation:

x < 128 ? 0 : x - 128;
SAT_MINUS (x, 128)      in fold-const.c
-(x < 128) & (x - 128)     in the expander for unsigned SAT_MINUS
-((signed) x < 0) & (x - 128)   from RTL-level simplifications or in
expand_store_flag
(x >> 7) & (x - 128)      in the expander for less-than

This is equivalent (in cost) to (x >> 7) & x & 127 which Andrew suggested back
then.  I have a patch to implement SAT_PLUS_EXPR and SAT_MINUS_EXPR and create
them in fold-const.c, which I hope to submit in a couple of weeks (I want to
merge the jumbo rtxclass patch first).

Paolo



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