public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Richard Biener <richard.guenther@gmail.com>,
	Kenneth Zadeck <zadeck@naturalbridge.com>,
		Mike Stump <mikestump@comcast.net>,
	gcc-patches <gcc-patches@gcc.gnu.org>,
		Lawrence Crowl <crowl@google.com>,
	Ian Lance Taylor <iant@google.com>,
	rdsandiford@googlemail.com
Subject: Re: patch to fix constant math -5th patch, rtl
Date: Fri, 03 May 2013 12:53:00 -0000	[thread overview]
Message-ID: <CAFiYyc2P_+gf-_3G2Y8KwtdxK8E_mrDppQceR-kN+Y98Mw8Gtw@mail.gmail.com> (raw)
In-Reply-To: <87txmki6ho.fsf@sandifor-thinkpad.stglab.manchester.uk.ibm.com>

On Fri, May 3, 2013 at 2:37 PM, Richard Sandiford
<rdsandiford@googlemail.com> wrote:
> Richard Biener <richard.guenther@gmail.com> writes:
>>> See e.g. the hoops that cselib has to jump through:
>>>
>>> /* We need to pass down the mode of constants through the hash table
>>>    functions.  For that purpose, wrap them in a CONST of the appropriate
>>>    mode.  */
>>> static rtx
>>> wrap_constant (enum machine_mode mode, rtx x)
>>> {
>>>   if ((!CONST_SCALAR_INT_P (x)) && GET_CODE (x) != CONST_FIXED)
>>>     return x;
>>>   gcc_assert (mode != VOIDmode);
>>>   return gen_rtx_CONST (mode, x);
>>> }
>>>
>>> That is, cselib locally converts (const_int X) into (const:M (const_int X)),
>>> purely so that it doesn't lose track of the CONST_INT's mode.
>>> (const:M (const_int ...)) is invalid rtl elsewhere, but a necessary
>>> hack here all the same.
>>
>> Indeed ugly.  But I wonder why cselib needs to store constants in
>> hashtables at all ... they should be VALUEs themselves.  So the fix
>> for the above might not necessarily be to assign the CONST_INT
>> a mode (not that CONST_WIDE_INT would fix the above).
>
> I don't understand.  Do you mean that cselib values ought to have
> a field to say whether the value is constant or not, and if so, what
> constant that is?  That feels like just the same kind of hack as the above.
> The current idea of chaining all known equivalent rtxes in a list seems
> more natural than having a list of all known equivalent rtxes except
> CONST_INT and CONST_DOUBLE, which have to be stored separately instead.
> (Again, we have runtime constants like SYMBOL_REF, which store modes,
> and which would presumably still be in the normal rtx list.)
>
> CONST_WIDE_INT was never supposed to solve this problem.  I'm just giving
> it as an example to back up the argument that rtx constants do in fact
> have modes (although those modes are not stored in the rtx).  The code
> above is there to make sure that equivalence stays transitive.
> Without it we could have bogus equivalences like:
>
>   (A) (reg:DI X) == (const_int Y) == (reg:SI Z)
>
> even though it cannot be the case that:
>
>   (B) (reg:DI X) == (reg:SI Z)
>
> My point is that, semantically, (A) did not come from X and Z being
> equivalent to the "same" constant.  X was equivalent to (const_int:DI Y)
> and Z was equivalent to (const_int:SI Y).  (A) only came about because
> we happen to use the same rtx object to represent those two semantically-
> distinct constants.
>
> The idea isn't to make CONST_WIDE_INT get rid of the code above.
> The idea is to make sure that wide_int has a precision and so doesn't
> require code like the above to be written when dealing with wide_ints.
>
> In other words, I got the impression your argument was "the fact
> that CONST_INT and CONST_DOUBLE don't store a mode shows that
> wide_int shouldn't store a precision".  But the fact that CONST_INT
> and CONST_DOUBLE don't store a mode doesn't mean they don't _have_
> a mode.  You just have to keep track of that mode separately.
> And the same would apply to wide_int if we did the same thing there.
>
> What I was trying to argue was that storing the mode/precision
> separately is not always easy.  It's also much less robust,
> because getting the wrong mode or precision will only show up
> for certain values.  If the precision is stored in the wide_int,
> mismatches can be asserted for based on precision alone, regardless
> of the value.

I was just arguing that pointing out facts in the RTL land doesn't
necessarily influence wide-int which is purely separate.  So if you
argue that having a mode in RTL constants would be soo nice and
thus that is why you want a precision in wide-int then I don't follow
that argument.  If you want a mode in RTL constants then get a mode
in RTL constants!

This would make it immediately obvious where to get the precision
for wide-ints - something you do not address at all (and as you don't
I sort of cannot believe the 'it would be so nice to have a mode on RTL
constants').

That said, if modes on RTL constants were so useful then why not
have them on CONST_WIDE_INT at least?  Please.  Only sticking
them to wide-int in form of a precision is completely backward to me
(and I still think the core wide-int shouldn't have a precision, and if
you really want a wide-int-with-precision simply derive from wide-int).

>> Ok, so please then make all CONST_INTs and CONST_DOUBLEs have
>> a mode!
>
> I'm saying that CONST_INT and CONST_DOUBLE already have a mode, but that
> mode is not stored in the rtx.  So if you're saying "make all CONST_INTs
> and CONST_DOUBLEs _store_ a mode", then yeah, I'd like to :-)  But I see
> Kenny's patch as a prerequisite for that, because it consolidates the
> CONST_INT and CONST_DOUBLE code so that the choice of rtx code is
> less special.  Lots more work is needed after that.

If there were a separate patch consolidating the paths I'd be all for
doing that.
I don't see a reason that this cannot be done even with the current
code using double-ints.

> Although TBH, the huge pushback that Kenny has got from this patch
> puts me off ever trying that change.

Well.  The patch does so much together and is so large that makes
it basically unreviewable (or very hard to review at least).

> But storing the mode in the rtx is orthogonal to what Kenny is doing.
> The mode of each rtx constant is already available in the places
> that Kenny is changing, because we already do the work to keep track
> of the mode separately.  Being able to get the mode directly from the
> rtx would be simpler and IMO better, but the semantics are the same
> either way.

Well, you showed examples where it is impossible to get at the mode.

> Kenny's patch is not designed to "fix" the CONST_INT representation
> (although the patch does make it easier to "fix" the representation
> in future).  Kenny's patch is about representing and handling constants
> that we can't at the moment.

No, it is about much more.

> The argument isn't whether CONST_WIDE_INT repeats "mistakes" made for
> CONST_INT and CONST_DOUBLE; I hope we agree that CONST_WIDE_INT should
> behave like the other two, whatever that is.  The argument is about
> whether we copy the "mistake" into the wide_int class.

I don't see how CONST_WIDE_INT is in any way related to wide_int other
than that you use wide_int to operate on the constants encoded in
CONST_WIDE_INT.  As you have a mode available at the point you
create a wide_int from a CONST_WIDE_INT you can very easily just
use that modes precision to specify the precision of an operation
(or zero/sign-extend the result).  That's what happens hidden in the
wide-int implementation currently, but in the awkward way that allows
precision mismatches and leads to odd things like having a wide-int
1 constant with a precision.

> Storing a precision in wide_int in no way requires CONST_WIDE_INT
> to store a mode.  They are separate choices.

Yes.  And I obviously would have chosed to store a mode in CONST_WIDE_INT
and no precision in wide_int.  And I cannot see a good reason to
do it the way you did it ;)

>> The solution is not to have a CONST_WIDE_INT (again with VOIDmode
>> and no precision in the RTX object(!)) and only have wide_int have a
>> precision.
>
> Why is having a VOIDmode CONST_WIDE_INT any worse than having
> a VOIDmode CONST_INT or CONST_DOUBLE?  In all three cases the mode
> is being obtained/inferred from the same external source.

Well, we're arguing in circles - the argument that VOIDmode CONST_INT/DOUBLE
are bad is yours.  And if that's not bad I can't see why it is bad for wide-int
to not have a mode (or precision).

Richard.

> Richard

  reply	other threads:[~2013-05-03 12:53 UTC|newest]

Thread overview: 217+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-03 17:17 patch to fix Kenneth Zadeck
2012-10-03 20:47 ` Marc Glisse
2012-10-03 22:05   ` Kenneth Zadeck
2012-10-04 13:17     ` Marc Glisse
2012-10-04 15:19       ` Kenneth Zadeck
2012-10-04 16:55         ` Marc Glisse
2012-10-04 21:06     ` Marc Glisse
2012-10-04 23:02       ` Kenneth Zadeck
2012-10-05  7:05         ` Marc Glisse
2012-10-03 22:55   ` Mike Stump
2012-10-04 12:48 ` Richard Guenther
2012-10-04 13:55   ` patch to fix constant math Kenneth Zadeck
2012-10-04 16:58     ` Richard Guenther
2012-10-04 18:08       ` Kenneth Zadeck
2012-10-04 19:27         ` Richard Sandiford
2012-10-05  9:27           ` Richard Guenther
2012-10-05  9:29             ` Richard Guenther
2012-10-05  9:56             ` Richard Sandiford
2012-10-05 10:34               ` Richard Guenther
2012-10-05 11:24                 ` Richard Sandiford
2012-10-05 11:42                   ` Richard Guenther
2012-10-05 12:26                     ` Richard Sandiford
2012-10-05 12:39                       ` Richard Guenther
2012-10-05 13:11                         ` Richard Sandiford
2012-10-05 13:18                           ` Richard Sandiford
2012-10-05 13:53                             ` Richard Guenther
2012-10-05 14:15                               ` Richard Sandiford
2012-10-05 14:36                                 ` Richard Guenther
2012-10-05 14:41                                   ` Kenneth Zadeck
2012-10-05 14:53                                     ` Richard Sandiford
2012-10-05 13:49                         ` Richard Guenther
2012-10-05 16:34                           ` Kenneth Zadeck
2012-10-05 17:29                             ` Richard Sandiford
2012-10-05 17:53                               ` Kenneth Zadeck
2012-10-05 22:12                               ` patch to fix constant math - first small patch Kenneth Zadeck
2012-10-05 22:48                                 ` patch to fix constant math - second " Kenneth Zadeck
2012-10-06 15:55                                   ` patch to fix constant math - third " Kenneth Zadeck
2012-10-08  9:08                                     ` Richard Guenther
2012-10-08 11:37                                     ` Kenneth Zadeck
2012-10-08 12:11                                       ` Richard Guenther
2012-10-08 19:43                                       ` Richard Sandiford
2012-10-09 15:10                                         ` patch to fix constant math - 4th patch - the wide-int class Kenneth Zadeck
2012-10-23 14:33                                           ` Richard Biener
2012-10-23 16:25                                             ` Kenneth Zadeck
2012-10-23 18:52                                               ` Lawrence Crowl
2012-10-23 19:27                                                 ` Kenneth Zadeck
2012-10-23 20:51                                                   ` Lawrence Crowl
2012-10-23 21:34                                                     ` Kenneth Zadeck
2012-10-24 10:10                                               ` Richard Biener
2012-10-24 17:30                                                 ` Mike Stump
2012-10-25 10:55                                                   ` Richard Biener
2012-10-25 10:59                                                     ` Kenneth Zadeck
2012-10-25 12:12                                                       ` Richard Biener
2012-10-31 11:01                                                         ` Richard Sandiford
2012-10-31 12:01                                                           ` Richard Biener
2012-10-31 12:12                                                             ` Richard Sandiford
2012-10-31 12:14                                                               ` Richard Biener
2012-10-31 12:23                                                                 ` Richard Sandiford
2012-10-31 12:50                                                                   ` Richard Biener
2012-10-31 13:50                                                                     ` Richard Sandiford
2012-10-31 13:56                                                                       ` Richard Biener
2012-10-31 14:26                                                                         ` Kenneth Zadeck
2012-10-31 19:45                                                                         ` Mike Stump
2012-10-31 15:52                                                                       ` Kenneth Zadeck
2012-10-31 14:39                                                                     ` Kenneth Zadeck
2012-10-31 19:22                                                                     ` Mike Stump
2012-10-31 13:54                                                                 ` Kenneth Zadeck
2012-10-31 14:07                                                                   ` Richard Biener
2012-10-31 14:25                                                                     ` Kenneth Zadeck
2012-10-31 14:25                                                                       ` Richard Biener
2012-10-31 14:30                                                                         ` Kenneth Zadeck
2012-11-01 22:13                                                                         ` patch to fix constant math - 8th patch - tree-vrp.c Kenneth Zadeck
2012-11-01 22:28                                                                           ` Marc Glisse
2012-11-01 22:35                                                                             ` Kenneth Zadeck
2012-11-01 22:33                                                                           ` patch to fix constant math - 4th patch - wide-int.[ch] refresh Kenneth Zadeck
2012-11-01 22:36                                                                             ` Kenneth Zadeck
2012-11-30 16:46                                                                         ` patch to fix constant math - 4th patch - the wide-int class Kenneth Zadeck
2012-11-30 17:00                                                                           ` patch to fix constant math - 5th patch - the rtl level changes Kenneth Zadeck
2012-11-30 18:13                                                                             ` patch to add storage classes to wide int Kenneth Zadeck
2012-11-30 19:05                                                                               ` Kenneth Zadeck
2012-12-01  9:28                                                                               ` Richard Sandiford
2012-12-01 13:43                                                                                 ` Kenneth Zadeck
2013-02-27  1:59                                                                         ` patch to fix constant math - 4th patch - the wide-int class - patch ping for the next stage 1 Kenneth Zadeck
2013-03-27 14:54                                                                           ` Richard Biener
2013-04-04  8:08                                                                             ` Kenneth Zadeck
2013-04-02 15:40                                                                           ` Richard Biener
2013-04-02 19:23                                                                             ` Kenneth Zadeck
2013-04-03 10:44                                                                               ` Richard Biener
2013-04-03 13:36                                                                                 ` Kenneth Zadeck
2013-04-03 14:46                                                                                   ` Richard Biener
2013-04-03 19:18                                                                                     ` Kenneth Zadeck
2013-04-04 11:45                                                                                       ` Richard Biener
2013-04-08  5:28                                                                                         ` Comments on the suggestion to use infinite precision math for wide int Kenneth Zadeck
2013-04-08 10:32                                                                                           ` Florian Weimer
2013-04-08 13:58                                                                                             ` Kenneth Zadeck
2013-04-08 14:00                                                                                               ` Robert Dewar
2013-04-08 14:12                                                                                                 ` Kenneth Zadeck
2013-04-08 14:41                                                                                                   ` Robert Dewar
2013-04-08 15:10                                                                                                     ` Kenneth Zadeck
2013-04-08 17:18                                                                                                       ` Robert Dewar
2013-04-08 17:22                                                                                                         ` Kenneth Zadeck
2013-04-08 19:14                                                                                                           ` Robert Dewar
2013-04-08 23:48                                                                                                             ` Lawrence Crowl
2013-04-09  1:22                                                                                                               ` Robert Dewar
2013-04-09  1:56                                                                                                                 ` Kenneth Zadeck
2013-04-09  2:10                                                                                                                   ` Robert Dewar
2013-04-09  7:06                                                                                                                     ` Mike Stump
2013-04-09  8:20                                                                                                                       ` Robert Dewar
2013-04-09  8:22                                                                                                                         ` Kenneth Zadeck
2013-04-09  8:24                                                                                                                           ` Robert Dewar
2013-04-09 12:42                                                                                                                             ` Florian Weimer
2013-04-09 15:06                                                                                                                               ` Robert Dewar
2013-04-09 16:16                                                                                                                                 ` Florian Weimer
2013-04-08 13:12                                                                                           ` Richard Biener
2013-04-08 13:32                                                                                             ` Kenneth Zadeck
2013-04-08 13:44                                                                                               ` Robert Dewar
2013-04-08 14:26                                                                                                 ` Kenneth Zadeck
2013-04-08 14:35                                                                                                   ` Robert Dewar
2013-04-08 19:06                                                                                               ` Richard Biener
2013-04-08 22:34                                                                                               ` Lawrence Crowl
2013-04-09  9:47                                                                                                 ` Richard Biener
     [not found]                                                                                                   ` <CAGqM8fZ7NxiMnC6PTA8v6w_E6ZJ5HbjhJXzh-HAOJqaSx+7rnw@mail.gmail.com>
2013-04-10  9:44                                                                                                     ` Richard Biener
2013-04-10 17:43                                                                                                       ` Mike Stump
2013-04-10 17:53                                                                                                         ` Kenneth Zadeck
2013-04-08 23:46                                                                                             ` Lawrence Crowl
2013-04-22 21:39                                                                                         ` patch to fix constant math - 4th patch - the wide-int class - patch ping for the next stage 1 Richard Sandiford
2013-04-23  0:35                                                                                           ` Richard Biener
2013-04-23  6:47                                                                                             ` Richard Sandiford
2013-04-05 15:05                                                                             ` Kenneth Zadeck
2013-04-08 13:06                                                                               ` Richard Biener
2013-04-17  0:49                                                                                 ` Kenneth Zadeck
2013-04-17  3:41                                                                                   ` patch to fix constant math -5th patch, rtl Kenneth Zadeck
2013-04-24 13:25                                                                                     ` Richard Biener
2013-04-24 13:37                                                                                       ` Richard Sandiford
2013-04-24 14:18                                                                                         ` Richard Biener
2013-04-24 14:34                                                                                           ` Richard Sandiford
2013-04-24 14:37                                                                                             ` Richard Biener
2013-04-24 14:53                                                                                               ` Richard Sandiford
2013-04-24 15:07                                                                                                 ` Richard Biener
2013-04-24 15:13                                                                                                   ` Kenneth Zadeck
2013-04-24 15:45                                                                                                   ` Richard Sandiford
2013-04-24 16:51                                                                                                     ` Richard Biener
2013-04-24 18:24                                                                                                       ` Richard Sandiford
2013-05-03 11:28                                                                                                         ` Richard Biener
2013-05-03 12:38                                                                                                           ` Richard Sandiford
2013-05-03 12:53                                                                                                             ` Richard Biener [this message]
2013-05-03 13:50                                                                                                               ` Richard Sandiford
2013-05-03 14:27                                                                                                               ` Kenneth Zadeck
2013-04-25  8:38                                                                                                       ` Kenneth Zadeck
2013-05-03 11:34                                                                                                         ` Richard Biener
2013-05-03 11:50                                                                                                           ` Kenneth Zadeck
2013-05-03 12:12                                                                                                             ` Richard Biener
2013-05-03 12:31                                                                                                               ` Kenneth Zadeck
2013-05-03 12:40                                                                                                                 ` Richard Biener
2013-05-03 14:09                                                                                                                   ` Kenneth Zadeck
2013-05-03 12:48                                                                                                                 ` Richard Sandiford
2013-05-03 13:06                                                                                                                   ` Richard Biener
2013-05-03 13:23                                                                                                                     ` Richard Sandiford
2013-05-03 15:32                                                                                                                       ` Kenneth Zadeck
2013-04-24 14:57                                                                                           ` Kenneth Zadeck
2013-04-24 15:49                                                                                             ` Richard Biener
2013-04-24 17:11                                                                                               ` Richard Sandiford
2013-05-03 11:19                                                                                                 ` Richard Biener
2013-05-03 12:46                                                                                                   ` Kenneth Zadeck
2013-05-03 13:02                                                                                                     ` Richard Biener
2013-05-03 14:34                                                                                                       ` Kenneth Zadeck
2013-05-02 17:22                                                                                       ` Kenneth Zadeck
2013-04-17  7:34                                                                                   ` patch to fix constant math - builtins.c - the first of the tree level patches for wide-int Kenneth Zadeck
2013-05-02 17:53                                                                                     ` Kenneth Zadeck
2013-04-17 15:01                                                                                   ` patch to fix constant math - 4th patch - the wide-int class - patch ping for the next stage 1 Kenneth Zadeck
2013-04-19 15:35                                                                                   ` Richard Biener
2013-04-22  7:15                                                                                     ` Kenneth Zadeck
2013-04-22 15:21                                                                                       ` Richard Biener
2013-04-23  8:11                                                                                         ` Kenneth Zadeck
2013-04-22 18:53                                                                                     ` Kenneth Zadeck
2013-04-22 19:17                                                                                       ` richard, i accidently pushed send rather than save, the previous email was not finished, just ignore it Kenneth Zadeck
2013-05-02 17:21                                                                                     ` patch to fix constant math - 4th patch - the wide-int class - patch ping for the next stage 1 Kenneth Zadeck
2012-10-31 20:07                                                                     ` patch to fix constant math - 4th patch - the wide-int class Mike Stump
2012-10-23 18:10                                             ` Lawrence Crowl
2012-10-09 18:51                                         ` patch to fix constant math - patch 5 - the rest of the rtl stuff Kenneth Zadeck
2012-10-19 16:52                                           ` Richard Sandiford
2012-11-09 13:22                                         ` patch to fix constant math - third small patch Kenneth Zadeck
2012-10-08  9:07                                   ` patch to fix constant math - second " Richard Guenther
2012-11-08 18:14                                     ` Kenneth Zadeck
2012-11-26 15:31                                       ` Richard Biener
2013-02-27  0:28                                   ` patch to fix constant math - second small patch -patch ping for next stage 1 Kenneth Zadeck
2013-03-27 14:18                                     ` Richard Biener
2013-03-27 14:23                                       ` Kenneth Zadeck
2013-03-27 15:07                                         ` Richard Biener
2013-03-28 14:47                                           ` Kenneth Zadeck
2012-10-06  0:14                                 ` patch to fix constant math - first small patch Joseph S. Myers
2012-10-08 19:25                                   ` Kenneth Zadeck
2012-11-08 17:37                                   ` Kenneth Zadeck
2013-02-27  0:23                                   ` patch to fix constant math - first small patch - patch ping for the next stage 1 Kenneth Zadeck
2013-03-27 14:13                                     ` Richard Biener
2013-03-28 15:06                                       ` Kenneth Zadeck
2013-03-31 17:51                                       ` Kenneth Zadeck
2013-04-02  9:45                                         ` Richard Biener
2013-04-02 14:34                                           ` Kenneth Zadeck
2013-04-02 15:29                                             ` Richard Biener
2013-04-02 22:43                                               ` Kenneth Zadeck
2013-04-03 10:48                                                 ` Richard Biener
2013-04-03 12:21                                                   ` Kenneth Zadeck
2013-04-03 13:38                                                     ` Richard Biener
2013-04-04  3:13                                                       ` Kenneth Zadeck
2012-10-07 12:47                             ` patch to fix constant math Richard Guenther
2012-10-07 13:11                               ` Kenneth Zadeck
2012-10-07 13:19                                 ` Richard Guenther
2012-10-07 14:58                                   ` Kenneth Zadeck
2012-10-08  9:27                                     ` Richard Guenther
2012-10-08 15:01                                       ` Nathan Froyd
2012-10-08 15:11                                         ` Robert Dewar
2012-10-08 19:55                                           ` Richard Sandiford
2012-10-09  7:09                                             ` Richard Guenther
2012-10-08 16:18                                         ` Richard Guenther
2012-10-05 13:11                     ` Kenneth Zadeck
2012-10-04 15:39   ` patch to fix Kenneth Zadeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFiYyc2P_+gf-_3G2Y8KwtdxK8E_mrDppQceR-kN+Y98Mw8Gtw@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=crowl@google.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=iant@google.com \
    --cc=mikestump@comcast.net \
    --cc=rdsandiford@googlemail.com \
    --cc=zadeck@naturalbridge.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).