Make highest_pow2_factor be unsigned

Richard Kenner kenner@vlsi1.ultra.nyu.edu
Mon Apr 14 21:07:00 GMT 2003


This was discussed a long time ago on the GCC list.  It fixes an ICE on
the following:

     PROCEDURE P1 is

        function Ident_Int (X : Integer) return Integer is
        begin
           return X;
        end;

        SUBTYPE SM IS INTEGER RANGE 1..10;

        TYPE MY_ARR IS ARRAY (SM RANGE <>) OF INTEGER;

        TYPE CONS (D3 : INTEGER := 1) IS
           RECORD
              C1 : MY_ARR(D3..IDENT_INT(10));
           END RECORD;

        TYPE ARR IS ARRAY (1..5) OF CONS;

     BEGIN
        null;
     end;

Tested on i686-pc-linux-gnu.

2002-06-03  Olivier Hainque <hainque@act-europe.fr>

        * expr.c (highest_pow2_factor): Return unsigned.
        * expr.h (offset_address): Likewise.
        * emit-rtl.c (offset_address): POW2 argument now unsigned.
        
*** gcc/expr.c	11 Apr 2003 16:22:25 -0000	1.520
--- gcc/expr.c	11 Apr 2003 19:45:06 -0000
*************** static rtx store_field		PARAMS ((rtx, HO
*** 167,172 ****
  					 int));
  static rtx var_rtx		PARAMS ((tree));
! static HOST_WIDE_INT highest_pow2_factor PARAMS ((tree));
! static HOST_WIDE_INT highest_pow2_factor_for_type PARAMS ((tree, tree));
  static int is_aligning_offset	PARAMS ((tree, tree));
  static rtx expand_increment	PARAMS ((tree, int, int));
--- 167,175 ----
  					 int));
  static rtx var_rtx		PARAMS ((tree));
! 
! static unsigned HOST_WIDE_INT highest_pow2_factor PARAMS ((tree));
! static unsigned HOST_WIDE_INT highest_pow2_factor_for_type PARAMS ((tree,
! 								    tree));
! 
  static int is_aligning_offset	PARAMS ((tree, tree));
  static rtx expand_increment	PARAMS ((tree, int, int));
*************** check_max_integer_computation_mode (exp)
*** 6336,6344 ****
     This is used in updating alignment of MEMs in array references.  */
  
! static HOST_WIDE_INT
  highest_pow2_factor (exp)
       tree exp;
  {
!   HOST_WIDE_INT c0, c1;
  
    switch (TREE_CODE (exp))
--- 6339,6347 ----
     This is used in updating alignment of MEMs in array references.  */
  
! static unsigned HOST_WIDE_INT
  highest_pow2_factor (exp)
       tree exp;
  {
!   unsigned HOST_WIDE_INT c0, c1;
  
    switch (TREE_CODE (exp))
*************** highest_pow2_factor (exp)
*** 6406,6415 ****
     of the alignment of TYPE.  */
  
! static HOST_WIDE_INT
  highest_pow2_factor_for_type (type, exp)
       tree type;
       tree exp;
  {
!   HOST_WIDE_INT type_align, factor;
  
    factor = highest_pow2_factor (exp);
--- 6409,6418 ----
     of the alignment of TYPE.  */
  
! static unsigned HOST_WIDE_INT
  highest_pow2_factor_for_type (type, exp)
       tree type;
       tree exp;
  {
!   unsigned HOST_WIDE_INT type_align, factor;
  
    factor = highest_pow2_factor (exp);
*** gcc/emit-rtl.c	4 Apr 2003 22:44:02 -0000	1.318
--- gcc/emit-rtl.c	11 Apr 2003 19:43:57 -0000
*************** offset_address (memref, offset, pow2)
*** 2314,2318 ****
       rtx memref;
       rtx offset;
!      HOST_WIDE_INT pow2;
  {
    rtx new, addr = XEXP (memref, 0);
--- 2314,2318 ----
       rtx memref;
       rtx offset;
!      unsigned HOST_WIDE_INT pow2;
  {
    rtx new, addr = XEXP (memref, 0);
*************** offset_address (memref, offset, pow2)
*** 2342,2347 ****
    MEM_ATTRS (new)
      = get_mem_attrs (MEM_ALIAS_SET (memref), MEM_EXPR (memref), 0, 0,
! 		     MIN (MEM_ALIGN (memref),
! 			  (unsigned HOST_WIDE_INT) pow2 * BITS_PER_UNIT),
  		     GET_MODE (new));
    return new;
--- 2342,2346 ----
    MEM_ATTRS (new)
      = get_mem_attrs (MEM_ALIAS_SET (memref), MEM_EXPR (memref), 0, 0,
! 		     MIN (MEM_ALIGN (memref), pow2 * BITS_PER_UNIT),
  		     GET_MODE (new));
    return new;
*** gcc/expr.h	13 Mar 2003 16:05:23 -0000	1.131
--- gcc/expr.h	11 Apr 2003 19:44:02 -0000
***************
*** 643,647 ****
     adding OFFSET, an RTX, to it.  POW2 is the highest power of two factor
     known to be in OFFSET (possibly 1).  */
! extern rtx offset_address PARAMS ((rtx, rtx, HOST_WIDE_INT));
  
  /* Return a memory reference like MEMREF, but with its address changed to
--- 643,647 ----
     adding OFFSET, an RTX, to it.  POW2 is the highest power of two factor
     known to be in OFFSET (possibly 1).  */
! extern rtx offset_address PARAMS ((rtx, rtx, unsigned HOST_WIDE_INT));
  
  /* Return a memory reference like MEMREF, but with its address changed to



More information about the Gcc-patches mailing list