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] Bunch of ivopts improvements patches


On Sun, 19 Dec 2004, Zdenek Dvorak wrote:
> 3) Makes fold ignore differences in signedness of operands when folding
>    X - X type expression to 0 (e.g. ((int) X + 3) - ((unsigned) X + 3) = 0).

Could you post an example of a piece of code that benefits from this
optimization?  This might be the most appropriate solution, or it might
just be papering over type safty problems, missing calls to fold or
ftrapv/fwrapv bugs in the loop optimizers.

For example, it might be appropriate to push fwrapv as a default so that
we can canonicalize (int)((unsigned)X + 3) as (int)X + 3, and likewise
(unsigned)((int)X + 3) as (unsigned)X + 3, which should also cure your
problem.

However, my first/second impression is that I like this change.  I was
a bit uncertain about the insertion of code on the critical path of a
frequently called and recursive function, but I think that's acceptable
given that its only a three or four instructions per function call, and
this change can potentially benefit many other constant folding
optimizations, such as "x & x", "x | x", "x == x", "x != x", etc...
where signedness is also not significant.

The alternative of having a new function unsigned_operand_equal_p or
similar, by comparison, would be inferior due to that large duplication
of code, even if the default behaviour for non-specialized tree nodes
is to call operand_equal_p.


However, unless your example can demonstrate a loop transformation
regression, I suspect this enhancement isn't suitable for 4.0.  I do
have some more suggestions, but I'd like to know whether this is a
possible 4.0 candidate, before requesting that you make changes.

Roger
--


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