This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Improved SAVE_EXPR handling in operand_equal_p
- From: Roger Sayle <roger at eyesopen dot com>
- To: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Cc: rth at redhat dot com, <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 9 Sep 2003 07:36:54 -0600 (MDT)
- Subject: Re: [PATCH] Improved SAVE_EXPR handling in operand_equal_p
On Mon, 8 Sep 2003, Kaveh R. Ghazi wrote:
> > From: Roger Sayle <firstname.lastname@example.org>
> > Kaveh, is it possible to only enable the "cabs(z) != cabs(z)" tests
> > at optimization levels -O2 and above? Sorry for the inconvenience.
> I'll do that if you can please explain to me why this works with
> optimization and not without it. (And why we can rely on that being
> the case.)
Certainly. Because of the use of SAVE_EXPR to prevent re-evaluation
the tree-level constant folders and RTL expanders are unable to
determine that save_expr(x*x) is the same as save_expr(x*x). Instead,
the duplication is discovered at the RTL level during CSE or the
local_cprop passes of GCSE. The x*x is a common subexpression of
both so one expression can be replaced by the other. This is enough
to simplify the comparison, when ends up comparing the same pseudo.
The issue is that CSE is only run when "(optimize > 0)" and similarly
for GCSE. So if we don't run the passes that recognize equivalent
expressions within a basic block, we never notice that link_error_cabs
As you correctly point out CSE is enabled at -O1 (which fixes the
testcase), so checking for __OPTIMIZE__ is sufficient. Sorry for
the confusion by mentioning -O2.
I hope this helps explain things.