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]

another use for simplify_gen_subreg


Hi,
this patch adds another use for simplify_subreg to integrate.c
It also teaches simplify_subreg to deal with complex types represented as CONCAT,
as this is needed for gen_lowpart and some other places too.

Honza
Thu May 17 21:01:37 CEST 2001  Jan Hubicka  <jh@suse.cz>
	* integrate.c (copy_rtx_and_substitute): Use simplify_gen_subreg.
	(simplify_subreg): Handle complex types represented as CONCAT.

Index: integrate.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/integrate.c,v
retrieving revision 1.143
diff -c -3 -p -r1.143 integrate.c
*** integrate.c	2001/05/05 16:55:48	1.143
--- integrate.c	2001/05/17 19:00:25
*************** copy_rtx_and_substitute (orig, map, for_
*** 1902,1936 ****
  
      case SUBREG:
        copy = copy_rtx_and_substitute (SUBREG_REG (orig), map, for_lhs);
!       /* SUBREG is ordinary, but don't make nested SUBREGs.  */
!       if (GET_CODE (copy) == SUBREG)
! 	{
! 	  int final_offset = SUBREG_BYTE (orig) + SUBREG_BYTE (copy);
! 
! 	  /* When working with SUBREGs the rule is that the byte
! 	     offset must be a multiple of the SUBREG's mode.  */
! 	  final_offset = (final_offset / GET_MODE_SIZE (GET_MODE (orig)));
! 	  final_offset = (final_offset * GET_MODE_SIZE (GET_MODE (orig)));
! 	  return gen_rtx_SUBREG (GET_MODE (orig), SUBREG_REG (copy),
! 				 final_offset);
! 	}
!       else if (GET_CODE (copy) == CONCAT)
! 	{
! 	  rtx retval = subreg_realpart_p (orig) ? XEXP (copy, 0) : XEXP (copy, 1);
! 	  int final_offset;
! 
! 	  if (GET_MODE (retval) == GET_MODE (orig))
! 	    return retval;
! 	  
! 	  final_offset = SUBREG_BYTE (orig) %
! 	  		 GET_MODE_UNIT_SIZE (GET_MODE (SUBREG_REG (orig)));
! 	  final_offset = (final_offset / GET_MODE_SIZE (GET_MODE (orig)));
! 	  final_offset = (final_offset * GET_MODE_SIZE (GET_MODE (orig)));
! 	  return gen_rtx_SUBREG (GET_MODE (orig), retval, final_offset);
! 	}
!       else
! 	return gen_rtx_SUBREG (GET_MODE (orig), copy,
! 			       SUBREG_BYTE (orig));
  
      case ADDRESSOF:
        copy = gen_rtx_ADDRESSOF (mode,
--- 1902,1910 ----
  
      case SUBREG:
        copy = copy_rtx_and_substitute (SUBREG_REG (orig), map, for_lhs);
!       return (simplify_gen_subreg (GET_MODE (orig), copy,
! 				   GET_MODE (SUBREG_REG (orig)),
! 				   SUBREG_BYTE (orig));
  
      case ADDRESSOF:
        copy = gen_rtx_ADDRESSOF (mode,
Index: simplify-rtx.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/simplify-rtx.c,v
retrieving revision 1.52
diff -c -3 -p -r1.52 simplify-rtx.c
*** simplify-rtx.c	2001/05/17 18:46:58	1.52
--- simplify-rtx.c	2001/05/17 19:00:26
*************** simplify_subreg (outermode, op, innermod
*** 2388,2393 ****
--- 2388,2407 ----
        MEM_COPY_ATTRIBUTES (new, op);
        return new;
      }
+ 
+   /* Handle complex values represented as CONCAT
+      of real and imaginary part.  */
+   if (GET_CODE (op) == CONCAT)
+     {
+       int is_realpart = byte < GET_MODE_UNIT_SIZE (innermode);
+       rtx part = is_realpart ? XEXP (op, 0) : XEXP (op, 1);
+       int final_offset;
+ 
+       final_offset = SUBREG_BYTE (op) %
+ 		     GET_MODE_UNIT_SIZE (innermode);
+       return simplify_subreg (outermode, part, innermode, final_offset);
+     }
+ 
    return NULL_RTX;
  }
  /* Make a SUBREG operation or equivalent if it folds.  */


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