This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] fold copysign(x, REAL_CST)
- From: Roger Sayle <roger at eyesopen dot com>
- To: Andrew Pinski <apinski at apple dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 20 Aug 2004 13:24:51 -0600 (MDT)
- Subject: Re: [PATCH] fold copysign(x, REAL_CST)
On Fri, 20 Aug 2004, Andrew Pinski wrote:
> I saw that we were not folding copysign(x,10) for some reason so I
> decided to implement it.
The "copysign(x,10.0)" case should already be handled by the test
for tree_expr_nonnegative_p which is true if for REAL_CST when the
constant is not negative. However, I agree that we should also be
handling the "copysign(x,-10.0)" case.
> + if (TREE_CODE (arg2) == REAL_CST && !TREE_CONSTANT_OVERFLOW (arg2))
I think you don't need to test for TREE_CONSTANT_OVERFLOW here. Joseph
will argue that it's just plain evil, but for floating point types
I suspect the middle-end does the correct thing without these bits.
> + if (in_gimple_form)
> + return NULL_TREE;
I'd like to believe that this isn't needed. One of my recent fixes
to tree-ssa-ccp.c was to adds checks to ensure that all calls to
fold_builtin whilst in_gimple verified that the results were still
gimple. It's far better to put these tests in the caller, such that
if ever tree-SSA has the ability to regimplify expressions, it can
still profit from these optimizations (by introducing a new temporary
between the ABS_EXPR and the NEGATE_EXPR).
Could you see if this patch still bootstraps and regression tests
without these two lines?
Many thanks for cleaning up the dead code and my mistake committing a
duplicate testcase, instead of two different testcases.
Roger
--