This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: fix builtins/fputs.c
- From: Roger Sayle <roger at eyesopen dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 9 Jul 2004 21:37:28 -0600 (MDT)
- Subject: Re: fix builtins/fputs.c
On Fri, 9 Jul 2004, Richard Henderson wrote:
> This patch
>
> 2004-07-04 Roger Sayle <roger@eyesopen.com>
>
> * tree-ssa-ccp.c (set_rhs): Change function to return a bool.
> Ensure the replacement rhs is valid gimple before performing
> the substitution. Return false if these sanity checks fail.
>
> caused this test to begin failing on Alpha, because
>
> fputs (x, f)
> =>
> (int) fwrite (x, 1, 1, f)
>
> We did not strip the nop on Alpha because fwrite returns a long,
> and STRIP_NOP preserves mode conversions.
Thanks for fixing this.
I've been wondering whether this should be split out into an even
more aggressive function, something like "ignore_tree_value (tree)"?
This could be used both here, and within "fold" when converting an
expression to VOID_TYPE, and within omit_one_operand/COMPOUND_EXPR
when we evaluate an expression purely for its side-effects, etc.
Currently, the middle-end's fold_convert just wraps a CONVERT_EXPR
around the expression when casting it to void(!), but clearly not only
can we strip type conversions, but also non-trapping, non-side-effecting
unary and binary operators.
For example, (void)((int)foo() + 3) is really just (void)foo().
Expressions without side-effects could be reduced enitrely to just
integer_zero_node.
This would be a useful functionality to complement tree-ssa's implicit
"cast-to-void" (a.k.a. ignore result) semantics for non-MODIFY_EXPR
statements.
Thoughts?
Roger
--