On 10/27/2017 09:56 AM, Richard Sandiford wrote:
> Jeff Law <l...@redhat.com> writes:
>> On 10/23/2017 05:21 AM, Richard Sandiford wrote:
>>> This patch adds a way of treating certain kinds of CONST as unique,
>>> so that pointer equality is equivalent to value equality.  For now it
>>> is restricted to VEC_DUPLICATE and VEC_SERIES, although the code to
>>> generate them remains in the else arm of an "if (1)" until a later
>>> patch.
>>>
>>> This is needed so that (const (vec_duplicate xx)) can used as the
>>> CONSTxx_RTX of a variable-length vector.
>> You're brave :-)  I know we looked at making CONST_INTs behave in this
>> manner eons ago in an effort to reduce memory consumption and it was
>> just plain painful.   There may still be comments from that project
>> littering the source code.
>>
>> I do wonder if we might want to revisit this again as we have better
>> infrastructure in place.
> 
> For vectors it isn't so bad, since we already do the same thing
> for CONST_VECTOR.  Fortunately CONST_VECTOR and CONST always have
> a mode, so there's no awkward sharing between modes...
> 
>>> 2017-10-23  Richard Sandiford  <richard.sandif...@linaro.org>
>>>         Alan Hayward  <alan.hayw...@arm.com>
>>>         David Sherwood  <david.sherw...@arm.com>
>>>
>>> gcc/
>>>     * rtl.h (unique_const_p): New function.
>>>     (gen_rtx_CONST): Declare.
>>>     * emit-rtl.c (const_hasher): New struct.
>>>     (const_htab): New variable.
>>>     (init_emit_once): Initialize it.
>>>     (const_hasher::hash, const_hasher::equal): New functions.
>>>     (gen_rtx_CONST): New function.
>>>     (spare_vec_duplicate, spare_vec_series): New variables.
>>>     (gen_const_vec_duplicate_1): Add code for use (const (vec_duplicate)),
>>>     but disable it for now.
>>>     (gen_const_vec_series): Likewise (const (vec_series)).
>>>     * gengenrtl.c (special_rtx): Return true for CONST.
>>>     * rtl.c (shared_const_p): Return true if unique_const_p.
>> ISTM that you need an update the rtl.texi's structure sharing
>> assumptions section to describe the new rules around CONSTs.
> 
> Oops, yeah.  How about the attached?
OK.

> 
>> So what's the purpose of the sparc_vec_* stuff that you're going to use
>> in the future?  It looks like a single element cache to me.    Am I
>> missing something?
> 
> No, that's right.  When looking up the const for (vec_duplicate x), say,
> it's easier to create the vec_duplicate rtx first.  But if the lookup
> succeeds (and so we already have an rtx with that value), we keep the
> discarded vec_duplicate around so that we can reuse it for the next
> lookup.
OK.

Jeff

Reply via email to