This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] if-convert "y < 0 ? z : 0" into "(y >> C) & z"
- From: "Paolo Bonzini" <bonzini at gnu dot org>
- To: <gcc-patches at gcc dot gnu dot org>,"Roger Sayle" <roger at eyesopen dot com>
- Date: Sun, 29 Feb 2004 14:27:36 +0100
- Subject: 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