This is the mail archive of the 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]

[PATCH] Fold X/C1 < C2 also for EXACT_DIV_EXPR


Roger's patch to fold e.g. x/3 < 5 as x < 15
( 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.

Bootstrapped and tested on alphaev68-linux.

2005-01-08  Falk Hueffner  <>

	* 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
 	  && !integer_zerop (TREE_OPERAND (arg0, 1))

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