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, Fix PR 31098] a*C == b*C is not foldded to a == b with --fast-math/floating point


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


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