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]

improve multiple_of_p


A couple of months ago I changed round_up and round_down to 
use BIT_AND_EXPR instead of FLOOR_DIV_EXPR and CEIL_DIV_EXPR.

When the current result of round_up is passed to round_up
again, since multiple_of_p doesn't understand BIT_AND_EXPR
we get a second, unnecessary, set of operations.


r~


        * fold-const.c (multiple_of_p): Handle BIT_AND_EXPR when
        BOTTOM is a power of two.

Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.485
diff -c -p -d -r1.485 fold-const.c
*** fold-const.c	14 Dec 2004 17:59:36 -0000	1.485
--- fold-const.c	18 Dec 2004 19:02:34 -0000
*************** multiple_of_p (tree type, tree top, tree
*** 9541,9546 ****
--- 9541,9553 ----
  
    switch (TREE_CODE (top))
      {
+     case BIT_AND_EXPR:
+       /* Bitwise and provides a power of two multiple.  If the mask is
+ 	 a multiple of BOTTOM then TOP is a multiple of BOTTOM.  */
+       if (!integer_pow2p (bottom))
+ 	return 0;
+       /* FALLTHRU */
+ 
      case MULT_EXPR:
        return (multiple_of_p (type, TREE_OPERAND (top, 0), bottom)
  	      || multiple_of_p (type, TREE_OPERAND (top, 1), bottom));


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