This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fold X/C1 < C2 also for EXACT_DIV_EXPR
- From: "Falk Hueffner" <falk at debian dot org>
- To: gcc-patches at gcc dot gnu dot org
- Cc: "AlViro" <viro at parcelfarce dot linux dot theplanet dot co dot uk>
- Date: Sun, 09 Jan 2005 18:06:47 +0100
- Subject: [PATCH] Fold X/C1 < C2 also for EXACT_DIV_EXPR
- Organization: http://freemail.web.de/
Hi,
Roger's patch to fold e.g. x/3 < 5 as x < 15
(http://gcc.gnu.org/ml/gcc-patches/2004-05/msg00063.html) also works
for EXACT_DIV_EXPR, simply because everything that works with
TRUNC_DIV_EXPR also works with EXACT_DIV_EXPR. This helps for
pointer subtraction (see e.g.
http://linux.bkbits.net:8080/linux-2.5/cset@1.2247).
Bootstrapped and tested on alphaev68-linux.
2005-01-08 Falk Hueffner <falk@debian.org>
* fold-const.c (fold): Also handle EXACT_DIV_EXPR when folding
X/C1 cmpop C2.
Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.491
diff -u -p -r1.491 fold-const.c
--- fold-const.c 7 Jan 2005 09:08:01 -0000 1.491
+++ fold-const.c 8 Jan 2005 14:05:04 -0000
@@ -8965,7 +8965,8 @@ fold (tree expr)
/* We can fold X/C1 op C2 where C1 and C2 are integer constants
into a single range test. */
- if (TREE_CODE (arg0) == TRUNC_DIV_EXPR
+ if ((TREE_CODE (arg0) == TRUNC_DIV_EXPR
+ || TREE_CODE (arg0) == EXACT_DIV_EXPR)
&& TREE_CODE (arg1) == INTEGER_CST
&& TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST
&& !integer_zerop (TREE_OPERAND (arg0, 1))