This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR middle-end/14490
- From: Richard Earnshaw <rearnsha at gcc dot gnu dot org>
- To: Andrew Pinski <pinskia at physics dot uc dot edu>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 01 Jul 2005 11:42:49 +0100
- Subject: Re: [PATCH] Fix PR middle-end/14490
- References: <f5de2762e0ef737afe7f077f13f82602@physics.uc.edu>
On Thu, 2005-06-30 at 20:10, Andrew Pinski wrote:
+ /* Transform comparisons of the form X +- C1 CMP C2 to X CMP C2
+- C1. */
+ if ((TREE_CODE (arg0) == PLUS_EXPR || TREE_CODE (arg0) ==
MINUS_EXPR)
+ && ((TREE_CODE (TREE_OPERAND (arg0, 1)) == REAL_CST
+ && !HONOR_SNANS (TYPE_MODE (TREE_TYPE (arg0))))
+ || (TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST
+ && !TREE_OVERFLOW (TREE_OPERAND (arg0, 1))
+ && !TYPE_UNSIGNED (TREE_TYPE (arg1))
+ && !(flag_wrapv || flag_trapv)))
+ && (TREE_CODE (arg1) == REAL_CST
+ || (TREE_CODE (arg1) == INTEGER_CST
+ && !TREE_OVERFLOW (arg1))))
+ {
I think you need to be more conservative than this for REAL_CST.
Consider the case where CST1 and CST2 are the same (so the difference is
zero) and X is much smaller than CST1.
It should be safe if we allow reassociation of floating-point
expressions, but not otherwise. I forget precisely which flag enables
that these days (probably -funsafe-math-optimizations).
R.