This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [ast-optimizer-branch]: Your change to c-pretty-print.c is broken.
Hi,
I was thinking a little about how to disambiguate things.
What about defining an ADDRESS_CST and use it instead of INTEGER_CST
when dealing with memory offsets?
(Pro64 compiler defines 2 types A4 and A8 (32 and 64 bit address integers)
for allowing more aggressive optimizations).
Another thing that would be of interest for array dependence analysis
is to transform lhs memory accesses into exact array accesses
(for ex.: A[4] = ...; instead of pointer arithmetic A + 4*sizeof(...) = ...;)
Sebastian.
On Mon, Jun 17, 2002 at 11:57:57AM -0400, Frank Ch. Eigler wrote:
> Hi -
>
> Here is a new patch for this problem. Some experiments tell me
> that there is no simple way to correctly map from INTEGER_CST
> nodes to a proper literal. This new patch therefore punts on
> the problem. The included comment block gives a little more of
> the sob story. What do you think?
>
>
> 2002-06-17 Frank Ch. Eigler <fche@redhat.com>
>
> * c-pretty-print.c (dump_c_node): Print pointer-type
> integer constants as raw numbers with a "B" (bytes) suffix.
>
> Index: c-pretty-print.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/Attic/c-pretty-print.c,v
> retrieving revision 1.1.2.20
> diff -u -r1.1.2.20 c-pretty-print.c
> --- c-pretty-print.c 15 Jun 2002 13:08:59 -0000 1.1.2.20
> +++ c-pretty-print.c 17 Jun 2002 15:51:56 -0000
> @@ -354,10 +356,32 @@
>
> case INTEGER_CST:
> if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE)
> - /* In the case of a pointer, divide by the size of the pointed-to type. */
> - output_decimal (buffer,
> - TREE_INT_CST_LOW (node) * BITS_PER_UNIT /
> - (TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node)))));
> + {
> + /* In the case of a pointer, one may want to divide by the
> + size of the pointed-to type. Unfortunately, this not
> + straightforward. The C front-end maps expressions
> +
> + (int *) 5
> + int *p; (p + 5)
> +
> + in such a way that the two INTEGER_CST nodes for "5" have
> + different values but identical types. In the latter
> + case, the 5 is multipled by sizeof (int) in c-common.c
> + (pointer_int_sum) to convert it to a byte address, and
> + yet the type of the node is left unchanged. Argh. What
> + is consistent though is that the number value corresponds
> + to bytes (UNITS) offset.
> +
> + NB: Neither of the following divisors can be trivially
> + used to recover the original literal:
> +
> + TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
> + TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node)))
> + */
> +
> + output_decimal (buffer, TREE_INT_CST_LOW (node));
> + output_add_string (buffer, "B"); /* pseudo-unit */
> + }
> else
> output_decimal (buffer, TREE_INT_CST_LOW (node));
> break;
>
>
> - FChE