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]

(partial) fix PR middle-end/20396


The attached patch fixes four known places where gen_lowpart* is currently used without checking
TRULY_NOOP_TRUNCATION, three in optabs.c by generating conversion (i.e. a
TRUNCATE), and one in loop.c by not combining movables with incompatible modes.


Bootstrapped and regression tested on i686-pc-linux.gnu.

As mentioned in the PR, a more thorough fix would entail changing gen_lowpart_common,
but that need would agreement of and co-operation with the MIPS maintainers. (There are
186 mentions of gen_lowpart in the gcc/gcc/*.c, so auditing them all and vetting all new
code is hardly feasible.)
2005-04-06  J"orn Rennecke <joern.rennecke@st.com>
            Richard Shann <rshann@superh.com>

	PR middle-end/20396:
	* loop.c (combine_movables): Take TRULY_NOOP_TRUNCATION into account.
	* optabs.c (expand_binop): Likewise.

Index: loop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop.c,v
retrieving revision 1.525
diff -p -r1.525 loop.c
*** loop.c	2 Apr 2005 16:53:38 -0000	1.525
--- loop.c	8 Apr 2005 17:06:28 -0000
*************** combine_movables (struct loop_movables *
*** 1890,1896 ****
  		    || (GET_MODE_CLASS (GET_MODE (m->set_dest)) == MODE_INT
  			&& GET_MODE_CLASS (GET_MODE (m1->set_dest)) == MODE_INT
  			&& (GET_MODE_BITSIZE (GET_MODE (m->set_dest))
! 			    >= GET_MODE_BITSIZE (GET_MODE (m1->set_dest)))))
  		   /* See if the source of M1 says it matches M.  */
  		   && ((REG_P (m1->set_src)
  			&& matched_regs[REGNO (m1->set_src)])
--- 1890,1899 ----
  		    || (GET_MODE_CLASS (GET_MODE (m->set_dest)) == MODE_INT
  			&& GET_MODE_CLASS (GET_MODE (m1->set_dest)) == MODE_INT
  			&& (GET_MODE_BITSIZE (GET_MODE (m->set_dest))
! 			    >= GET_MODE_BITSIZE (GET_MODE (m1->set_dest)))
! 			&& (TRULY_NOOP_TRUNCATION
! 			    (GET_MODE_BITSIZE (GET_MODE (m1->set_dest)),
! 			     GET_MODE_BITSIZE (GET_MODE (m->set_dest))))))
  		   /* See if the source of M1 says it matches M.  */
  		   && ((REG_P (m1->set_src)
  			&& matched_regs[REGNO (m1->set_src)])
Index: optabs.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/optabs.c,v
retrieving revision 1.268
diff -p -r1.268 optabs.c
*** optabs.c	24 Mar 2005 06:22:36 -0000	1.268
--- optabs.c	8 Apr 2005 17:06:28 -0000
*************** expand_binop (enum machine_mode mode, op
*** 1134,1140 ****
  
        if (temp != 0)
  	{
! 	  if (GET_MODE_CLASS (mode) == MODE_INT)
  	    return gen_lowpart (mode, temp);
  	  else
  	    return convert_to_mode (mode, temp, unsignedp);
--- 1134,1142 ----
  
        if (temp != 0)
  	{
! 	  if (GET_MODE_CLASS (mode) == MODE_INT
! 	      && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode),
!                                         GET_MODE_BITSIZE (GET_MODE (temp))))
  	    return gen_lowpart (mode, temp);
  	  else
  	    return convert_to_mode (mode, temp, unsignedp);
*************** expand_binop (enum machine_mode mode, op
*** 1181,1187 ****
  				 unsignedp, OPTAB_DIRECT);
  	    if (temp)
  	      {
! 		if (class != MODE_INT)
  		  {
  		    if (target == 0)
  		      target = gen_reg_rtx (mode);
--- 1183,1191 ----
  				 unsignedp, OPTAB_DIRECT);
  	    if (temp)
  	      {
! 		if (class != MODE_INT
!                     || !TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode),
!                                                GET_MODE_BITSIZE (wider_mode)))
  		  {
  		    if (target == 0)
  		      target = gen_reg_rtx (mode);
*************** expand_binop (enum machine_mode mode, op
*** 1709,1715 ****
  				   unsignedp, methods);
  	      if (temp)
  		{
! 		  if (class != MODE_INT)
  		    {
  		      if (target == 0)
  			target = gen_reg_rtx (mode);
--- 1713,1721 ----
  				   unsignedp, methods);
  	      if (temp)
  		{
! 		  if (class != MODE_INT
! 		      || !TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode),
! 						 GET_MODE_BITSIZE (wider_mode)))
  		    {
  		      if (target == 0)
  			target = gen_reg_rtx (mode);

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