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]

ia32: express_from enhancement


Probably goes along with the fold-const change to actually
be able to unify the givs in question.


r~


	* loop.c (express_from): Try harder to unify (* c N) and (* c M)
	where N and M are constant and N is an integer multiple of M.

Index: loop.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/loop.c,v
retrieving revision 1.171
diff -c -p -d -r1.171 loop.c
*** loop.c	1999/08/09 13:59:46	1.171
--- loop.c	1999/08/09 23:58:45
*************** express_from (g1, g2)
*** 6813,6818 ****
--- 6813,6842 ----
  
    add = express_from_1 (g1->add_val, g2->add_val, mult);
    if (add == NULL_RTX)
+     {
+       /* Failed.  If we've got a multiplication factor between G1 and G2,
+ 	 scale G1's addend and try again.  */
+       if (INTVAL (mult) > 1)
+ 	{
+ 	  rtx g1_add_val = g1->add_val;
+ 	  if (GET_CODE (g1_add_val) == MULT
+ 	      && GET_CODE (XEXP (g1_add_val, 1)) == CONST_INT)
+ 	    {
+ 	      HOST_WIDE_INT m;
+ 	      m = INTVAL (mult) * INTVAL (XEXP (g1_add_val, 1));
+ 	      g1_add_val = gen_rtx_MULT (GET_MODE (g1_add_val),
+ 					 XEXP (g1_add_val, 0), GEN_INT (m));
+ 	    }
+ 	  else
+ 	    {
+ 	      g1_add_val = gen_rtx_MULT (GET_MODE (g1_add_val), g1_add_val,
+ 					 mult);
+ 	    }
+ 
+ 	  add = express_from_1 (g1_add_val, g2->add_val, const1_rtx);
+ 	}
+     }
+   if (add == NULL_RTX)
      return NULL_RTX;
  
    /* Form simplified final result.  */


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