This is the mail archive of the gcc@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]

Re: PR 6212


On Mon, May 06, 2002 at 05:01:40PM -0700, Mark Mitchell wrote:
> Kenner, you're going to have to come up with a better patch.
> 
> Yesterday would be a good time.

I think the following will do the job.  It adds the alignment
based on the type of the dereference, not based on the form of
the index.

Bar one, the other uses of highest_pow2_factor are simple field
offsets, and so do not need adjustment.  The one other remaining
talks about the size of some BLKmode thingy.  Dunno what's going
on there, but it's for sure better to guess low than high when
talking about alignment.

I'm in the process of testing both patches on Alpha and MIPS.


r~


Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expr.c,v
retrieving revision 1.423.2.18
diff -c -p -d -r1.423.2.18 expr.c
*** expr.c	16 Apr 2002 06:03:36 -0000	1.423.2.18
--- expr.c	6 May 2002 23:12:44 -0000
*************** static rtx store_field		PARAMS ((rtx, HO
*** 147,152 ****
--- 147,153 ----
  					 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));
  static void do_jump_by_parts_greater PARAMS ((tree, int, rtx, rtx));
*************** expand_assignment (to, from, want_value,
*** 3707,3713 ****
  	    }
  
  	  to_rtx = offset_address (to_rtx, offset_rtx,
! 				   highest_pow2_factor (offset));
  	}
  
        if (GET_CODE (to_rtx) == MEM)
--- 3708,3715 ----
  	    }
  
  	  to_rtx = offset_address (to_rtx, offset_rtx,
! 				   highest_pow2_factor_for_type (TREE_TYPE (to),
! 								 offset));
  	}
  
        if (GET_CODE (to_rtx) == MEM)
*************** highest_pow2_factor (exp)
*** 5908,5913 ****
--- 5910,5930 ----
      }
  
    return 1;
+ }
+ 
+ /* Similar, except that it is known that the expression must be a multiple
+    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);
+   type_align = TYPE_ALIGN (type) / BITS_PER_UNIT;
+   return MAX (factor, type_align);
  }
  
  /* Return an object on the placeholder list that matches EXP, a


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