This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: operand swapping in get_expr_operands.
- From: Jeffrey A Law <law at redhat dot com>
- To: Andrew MacLeod <amacleod at redhat dot com>
- Cc: gcc mailing list <gcc at gcc dot gnu dot org>
- Date: Wed, 04 May 2005 09:07:26 -0600
- Subject: Re: operand swapping in get_expr_operands.
- References: <1115216925.6516.41.camel@pain>
- Reply-to: law at redhat dot com
On Wed, 2005-05-04 at 10:28 -0400, Andrew MacLeod wrote:
> Why is it we try to swap operands in get_expr_operands, where we are
> otherwise simply parsing not modifying?
>
> /* If it would be profitable to swap the operands, then do so to
> canonicalize the statement, enabling better optimization.
> By placing canonicalization of such expressions here we
> transparently keep statements in canonical form, even
> when the statement is modified. */
>
>
> Is this statement still true? and if so, who is counting on it? DOM?
> And does it need to be done in update_stmt? Its been a minor wart
> everytime I turn around that we are modifying the stmt when in the
> middle of building operands. I'm curious if we still need to do it here,
> now its making comparing operands more difficult.
Any code which is hashing expressions is probably dependent on this
to some extent.
> I believe it basically attempts to have the first operand of a pair be
> the lower ssa_name index... ie, so commutative or comparision pairs are
> sorted.
That's its primary purpose -- to ensure that SSA_NAMEs appear in a
predictable order within an expression.
An alternate approach would be to twiddle the hashing code -- that works
OK for commutative operands, but not necessarily for things like LT_EXPR
where putting things into canonical form involves changing the tree
code.
jeff