[PATCH] improve C++ code by changing fold-const.c

Roger Sayle roger@eyesopen.com
Tue May 18 03:31:00 GMT 2004

On Sun, 16 May 2004, Andrew Pinski wrote:
> I found that my cast pass was too complicated and replicated too much in
> which was in fold already.  The only thing fold did not handle that my
> cast pass did was changing the type of an ADDR_EXPR.

Could you explain a bit more about why this is needed?  At the moment,
I believe that it's always the case that the type of an ADDR_EXPR node
is a pointer type to the type of it's operand.  Your patch changes this
to make ADDR_EXPR a form of conversion operator.

Which parts of tree-ssa have problems with "NOP_EXPR (type, ADDR_EXPR
...)" that they don't have with just ADDR_EXPR and a mismatched type?

I've read through both PR14032 and PR14720 and whilst they motivate
why this is a serious problem, they provide no indication of why
treating ADDR_EXPR as a conversion operator is a suitable fix.  I'm
not convinced that this isn't just papering over a missing STRIP_NOPS.

For example, would it be reasonable to instead fold this as:

	NOP_EXPR (T1, ADDR_EXPR (T2, X)) =>

i.e. push the conversion operation inside the ADDR_EXPR.  Where T1
and T2 are pointer types to compatible types T3 and T4 respectively
and X has type T4.


More information about the Gcc-patches mailing list