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]

Q. init_rtl() may change CONST_DOUBLE




All

I've been trying to understand some code in the
routine init_rtl() in rtl.c which may change the
entries for CONST_DOUBLE in the rtx_length[]
and rtx_format[] arrays which were initialised from
the definition in rtl.def.

On my x86 the code in init_rtl() changes the
rtx_format[] entry from "e0ww" to "e0www" and
the corresponding rtx_length[] from 4 to 5.

This make sense for 96-bit doubles.

Now for the bit I don't understand.

gengenrtl.c generates genrtl.c based on the definitions
in rtl.def.  In particular it has generates a routine
gen_rtx_fmt_e0ww() which creates a CONST_DOUBLE
rtx.

The routine immed_real_const_1() in varasm.c has two
ways of generating a CONST_DOUBLE rtx it either
calls gen_rtx_CONST_DOUBLE() which calls
gen_rtx_fmt_e0ww() or it calls rtx_alloc(CONST_DOUBLE)

These two ways of generating a CONST_DOUBLE rtx
are obviously not equivalent when init_rtl() has done
its hacking.

The rest of the compiler appears not to care about the
difference even when comparing two CONST_DOUBLE's.

For example the routine exp_equiv_p() in cse.c uses the
rtx_length[] and rtx_format[] arrays when comparing
two CONST_DOUBLE rtx's. These arrays only correctly
describe CONST_DOUBLE's allocate via rtx_alloc()
this is a problem if one or both of the CONST_DOUBLE's
being compared were allocared via gen_rtx_CONST_DOUBLE().

Consider the following 3 possible combinations when
comparing CONST_DOUBLE rtx's using exp_equiv_p().

1. Comparing two e0www CONST_DOUBLE rtx's
====================================
The result is well defined.

2. Comparing two e0ww CONST_DOUBLE rtx's
===================================
The result is not well defined because the code is
accessing unallocated memory in both rtx's

3. Comparing a e0ww and a e0www CONST_DOUBLE
=======================================
The result is not well defined because the code is
accessing unallocated memory in one of the rtx's

Where e0ww  has been allocated via gen_rtx_CONST_DOUBLE()
and e0www has been allocated via rtx_alloc(CONST_DOUBLE).

Any comments ?

Graham  


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