[ast-optimizer-branch] PATCH to simplify array base

Jason Merrill jason@redhat.com
Fri Jun 7 23:04:00 GMT 2002


We haven't been simplifying array bases, but we should.  Given an
expression like k.d[2][3] where k.d is of type int[3][4], this will now
simplify to

  int (*t1)[3][4];
  int t2;
  t1 = &k.d;
  t2 = (*t1)[2][3];

This is still an extension from the published SIMPLE grammar, but I believe
this was omitted there because the McCAT version of ARRAY_REF takes a
POINTER_TYPE argument, whereas the gcc version takes an ARRAY_TYPE.  It
seems to me that it would make sense for gcc to support POINTER_TYPE
arguments as well, so that we can retain information about array indexing
off of pointers, but that can wait.

Booted and tested i686-pc-linux-gnu, applied ast-optimizer-branch.

2002-06-08  Jason Merrill  <jason@redhat.com>

	* tree-simple.c (is_simple_arraybase): New function.
	(is_simple_arrayref): Use it to check the array base again.
	* tree-simple.h: Add declaration.
	* c-simplify.c (simplify_array_ref): Do simplify the base.
	* expr.c (expand_expr): First make sure the type has a size.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/x-patch
Size: 6167 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20020607/edb3b4e8/attachment.bin>


More information about the Gcc-patches mailing list