This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, Fix PR 31098] a*C == b*C is not foldded to a == b with --fast-math/floating point
- From: "Kaveh R. GHAZI" <ghazi at caip dot rutgers dot edu>
- To: Pranav Bhandarkar <pranav dot bhandarkar at celunite dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 8 Oct 2007 02:37:14 -0400 (EDT)
- Subject: Re: [PATCH, Fix PR 31098] a*C == b*C is not foldded to a == b with --fast-math/floating point
- References: <470900FD.1090105@celunite.com>
On Sun, 7 Oct 2007, Pranav Bhandarkar wrote:
> Hi,
> Could somebody please review this patch which is a proposed fix for PR
> 31098.
>
> 2007-10-07 Pranav Bhandarkar <pranav.bhandarkar@celunite.com>
>
> * fold-const.c (fold_comparison): fold (a OP c) CMP (b OP c) -> a
> CMP b, iff c is not zero
> * testsuite/pr31098.c: New
> + /* (a OP c) CMP (b OP c) -> a CMP b, iff c is not zero */
> + if (fast_math_flags_set_p () && (TREE_CODE (arg0) == TREE_CODE (arg1))
Do we really need all "fast math" flags set to enable this opt? E.g.
surely we don't care about !flag_signed_zeros since you disable the code
when "c" is zero. Perhaps other sub-bits of "fast math" can also be
ignored for this purpose.
Also I would suggest a few more testcases (not necessarily more test
files, you can put them all in the same file). E.g. try testing various
different permutations of changing CMP or OP. Or how about (a OP c) CMP
(c OP b) when OP is commutative? I believe the exprs are canonicalized at
this point so adding a testcase for one side reversed should just work.
Thanks,
--Kaveh
--
Kaveh R. Ghazi ghazi@caip.rutgers.edu