Re: wide int patch #7: Replacement of INT_CST_LT and INT_CST_LT_UNSIGNED

2012-10-19 Thread Richard Biener
On Fri, Oct 19, 2012 at 2:12 PM, Kenneth Zadeck
 wrote:
>
> On 10/19/2012 07:58 AM, Richard Biener wrote:
>>
>> On Fri, Oct 19, 2012 at 1:49 PM, Kenneth Zadeck
>>  wrote:
>>>
>>> On 10/19/2012 07:13 AM, Richard Biener wrote:

 On Fri, Oct 19, 2012 at 12:59 PM, Kenneth Zadeck
  wrote:
>
> On 10/19/2012 04:22 AM, Richard Biener wrote:
>>
>> On Thu, Oct 18, 2012 at 7:32 PM, Kenneth Zadeck
>>  wrote:
>>>
>>> This patch replaces all instances of  INT_CST_LT and
>>> INT_CST_LT_UNSIGNED
>>> with
>>> the new functions tree_int_cst_lts_p and tree_int_cst_ltu_p.   With
>>> the
>>> new
>>> implementation of int_cst these functions will be too big to do
>>> inline.
>>
>> These new function names are extremely confusing given that we already
>> have tree_int_cst_lt which does the right thing based on the
>> signedness
>> of the INTEGER_CST trees.
>>
>> The whole point of the macros was to be inlined and you break that.
>> That
>> is,
>> for example
>>
>>   if (unsignedp && unsignedp0)
>>{
>> - min_gt = INT_CST_LT_UNSIGNED (primop1, minval);
>> - max_gt = INT_CST_LT_UNSIGNED (primop1, maxval);
>> - min_lt = INT_CST_LT_UNSIGNED (minval, primop1);
>> - max_lt = INT_CST_LT_UNSIGNED (maxval, primop1);
>> + min_gt = tree_int_cst_ltu_p (primop1, minval);
>> + max_gt = tree_int_cst_ltu_p (primop1, maxval);
>> + min_lt = tree_int_cst_ltu_p (minval, primop1);
>> + max_lt = tree_int_cst_ltu_p (maxval, primop1);
>>}
>>   else
>>{
>> - min_gt = INT_CST_LT (primop1, minval);
>> - max_gt = INT_CST_LT (primop1, maxval);
>> - min_lt = INT_CST_LT (minval, primop1);
>> - max_lt = INT_CST_LT (maxval, primop1);
>> + min_gt = tree_int_cst_lts_p (primop1, minval);
>> ...
>>
>> could have just been
>>
>>min_gt = tree_int_cst_lt (primop1, minval);
>> 
>>
>> without any sign check.
>>
>> So if you think you need to kill the inlined variants please use the
>> existing
>> tree_int_cst_lt instead.
>
> no, they could not have.   tree_int_cst_lt uses the signedness of the
> type
> to determine how to do the comparison.These two functions, as the
> macros
> they replace, force the comparison to be done independent of the
> signedness
> of the type.

 Well, looking at the surrounding code it's indeed non-obvious that this
 would
 be a 1:1 transform.  But then they should not compare _trees_ but
 instead
 compare double-ints (or wide-ints).

 That said, I still think having a tree_int_cst_lt[us]_p function is
 wrong.
 tree INTEGER_CSTs have a sign.  (apart from that opinion we have
 tree_int_cst_lt and you introduce tree_int_cst_ltu_p - consistent
 would be tree_int_cst_ltu).
>>>
>>> This reply applies just as much to this patch as patch 6.
>>> I morally agree with you 100%.But the code does not agree with you.
>>>
>>> On patch 6, there are about 450 places where we want to take the lower
>>> hwi
>>> worth of bits out of a int cst.Of those, only 5 places use the
>>> function
>>> that allows the signedness to be passed in.   The rest make the
>>> signedness
>>> decision based on the local code and completely ignore any information in
>>> the type.Of those 5 that do allow the signedness to be passed in,
>>> only
>>> three of them actually pass it in based on the signedness of the variable
>>> they are accessing.
>>>
>>> I am sure that a lot of these are wrong.  But i could not tell you which
>>> are
>>> and which are not.
>>> luckily, a lot of this will go away with the full wide-int code because i
>>> just do most of this math in the full precision so the issue never comes
>>> up.
>>> But after i am finished, there will still be a fair number of places that
>>> do
>>> this.   (luckily, a large number of them are pulling the number out and
>>> comparing it to the precision of something, so this is likely to be
>>> harmless
>>> no matter how the code is written).
>>>
>>> But to a large extent, you are shooting the messenger here, and not
>>> person
>>> who committed the crime.   I will be happy to add some comments to point
>>> the
>>> clients of these to the one that looks at the type.   In looking over the
>>> patch, the only obvious ones that could be changed are the ones in
>>> tree-ssa-uninit.c and the tree-vrp.c. The one in tree-vrp.c just looks
>>> like
>>> that the person writing the code did not know about tree_int_cst_lt and
>>> wrote the check out our himself.  (i will fix this in the tree-vrp patch
>>> that i am working on now. The one in tree-ssa-uniunit looks correct.
>>>
>>> But beyond that, the rest are in the front ends and so i think that this
>>> as

Re: wide int patch #7: Replacement of INT_CST_LT and INT_CST_LT_UNSIGNED

2012-10-19 Thread Kenneth Zadeck


On 10/19/2012 07:58 AM, Richard Biener wrote:

On Fri, Oct 19, 2012 at 1:49 PM, Kenneth Zadeck
 wrote:

On 10/19/2012 07:13 AM, Richard Biener wrote:

On Fri, Oct 19, 2012 at 12:59 PM, Kenneth Zadeck
 wrote:

On 10/19/2012 04:22 AM, Richard Biener wrote:

On Thu, Oct 18, 2012 at 7:32 PM, Kenneth Zadeck
 wrote:

This patch replaces all instances of  INT_CST_LT and
INT_CST_LT_UNSIGNED
with
the new functions tree_int_cst_lts_p and tree_int_cst_ltu_p.   With the
new
implementation of int_cst these functions will be too big to do inline.

These new function names are extremely confusing given that we already
have tree_int_cst_lt which does the right thing based on the signedness
of the INTEGER_CST trees.

The whole point of the macros was to be inlined and you break that.
That
is,
for example

  if (unsignedp && unsignedp0)
   {
- min_gt = INT_CST_LT_UNSIGNED (primop1, minval);
- max_gt = INT_CST_LT_UNSIGNED (primop1, maxval);
- min_lt = INT_CST_LT_UNSIGNED (minval, primop1);
- max_lt = INT_CST_LT_UNSIGNED (maxval, primop1);
+ min_gt = tree_int_cst_ltu_p (primop1, minval);
+ max_gt = tree_int_cst_ltu_p (primop1, maxval);
+ min_lt = tree_int_cst_ltu_p (minval, primop1);
+ max_lt = tree_int_cst_ltu_p (maxval, primop1);
   }
  else
   {
- min_gt = INT_CST_LT (primop1, minval);
- max_gt = INT_CST_LT (primop1, maxval);
- min_lt = INT_CST_LT (minval, primop1);
- max_lt = INT_CST_LT (maxval, primop1);
+ min_gt = tree_int_cst_lts_p (primop1, minval);
...

could have just been

   min_gt = tree_int_cst_lt (primop1, minval);


without any sign check.

So if you think you need to kill the inlined variants please use the
existing
tree_int_cst_lt instead.

no, they could not have.   tree_int_cst_lt uses the signedness of the
type
to determine how to do the comparison.These two functions, as the
macros
they replace, force the comparison to be done independent of the
signedness
of the type.

Well, looking at the surrounding code it's indeed non-obvious that this
would
be a 1:1 transform.  But then they should not compare _trees_ but instead
compare double-ints (or wide-ints).

That said, I still think having a tree_int_cst_lt[us]_p function is wrong.
tree INTEGER_CSTs have a sign.  (apart from that opinion we have
tree_int_cst_lt and you introduce tree_int_cst_ltu_p - consistent
would be tree_int_cst_ltu).

This reply applies just as much to this patch as patch 6.
I morally agree with you 100%.But the code does not agree with you.

On patch 6, there are about 450 places where we want to take the lower hwi
worth of bits out of a int cst.Of those, only 5 places use the function
that allows the signedness to be passed in.   The rest make the signedness
decision based on the local code and completely ignore any information in
the type.Of those 5 that do allow the signedness to be passed in, only
three of them actually pass it in based on the signedness of the variable
they are accessing.

I am sure that a lot of these are wrong.  But i could not tell you which are
and which are not.
luckily, a lot of this will go away with the full wide-int code because i
just do most of this math in the full precision so the issue never comes up.
But after i am finished, there will still be a fair number of places that do
this.   (luckily, a large number of them are pulling the number out and
comparing it to the precision of something, so this is likely to be harmless
no matter how the code is written).

But to a large extent, you are shooting the messenger here, and not person
who committed the crime.   I will be happy to add some comments to point the
clients of these to the one that looks at the type.   In looking over the
patch, the only obvious ones that could be changed are the ones in
tree-ssa-uninit.c and the tree-vrp.c. The one in tree-vrp.c just looks like
that the person writing the code did not know about tree_int_cst_lt and
wrote the check out our himself.  (i will fix this in the tree-vrp patch
that i am working on now. The one in tree-ssa-uniunit looks correct.

But beyond that, the rest are in the front ends and so i think that this as
good as you get out of me.

Well, if you transform bogus (by moral standards) code into other
bogus code the whole point of your patch is to exchange the names
of a set of macros / functions to another set of macros / functions.

I see no point in that then.

Leave broken code as-is.  The more often you touch broken code
and just mangle it in some way the harder it gets to get to the
point that would maybe reveal the real intent of the original code.

Sorry for the harsh words, but to take the example of
INT_CST_LT and INT_CST_LT_UNSIGNED -- those are remanents of
a world before double_ints existed.  All uses should have been
replaced by double_int usage by now; replacing them with something
tree-ish is the wrong way.  It might be 

Re: wide int patch #7: Replacement of INT_CST_LT and INT_CST_LT_UNSIGNED

2012-10-19 Thread Richard Biener
On Fri, Oct 19, 2012 at 1:49 PM, Kenneth Zadeck
 wrote:
>
> On 10/19/2012 07:13 AM, Richard Biener wrote:
>>
>> On Fri, Oct 19, 2012 at 12:59 PM, Kenneth Zadeck
>>  wrote:
>>>
>>> On 10/19/2012 04:22 AM, Richard Biener wrote:

 On Thu, Oct 18, 2012 at 7:32 PM, Kenneth Zadeck
  wrote:
>
> This patch replaces all instances of  INT_CST_LT and
> INT_CST_LT_UNSIGNED
> with
> the new functions tree_int_cst_lts_p and tree_int_cst_ltu_p.   With the
> new
> implementation of int_cst these functions will be too big to do inline.

 These new function names are extremely confusing given that we already
 have tree_int_cst_lt which does the right thing based on the signedness
 of the INTEGER_CST trees.

 The whole point of the macros was to be inlined and you break that.
 That
 is,
 for example

  if (unsignedp && unsignedp0)
   {
 - min_gt = INT_CST_LT_UNSIGNED (primop1, minval);
 - max_gt = INT_CST_LT_UNSIGNED (primop1, maxval);
 - min_lt = INT_CST_LT_UNSIGNED (minval, primop1);
 - max_lt = INT_CST_LT_UNSIGNED (maxval, primop1);
 + min_gt = tree_int_cst_ltu_p (primop1, minval);
 + max_gt = tree_int_cst_ltu_p (primop1, maxval);
 + min_lt = tree_int_cst_ltu_p (minval, primop1);
 + max_lt = tree_int_cst_ltu_p (maxval, primop1);
   }
  else
   {
 - min_gt = INT_CST_LT (primop1, minval);
 - max_gt = INT_CST_LT (primop1, maxval);
 - min_lt = INT_CST_LT (minval, primop1);
 - max_lt = INT_CST_LT (maxval, primop1);
 + min_gt = tree_int_cst_lts_p (primop1, minval);
 ...

 could have just been

   min_gt = tree_int_cst_lt (primop1, minval);
 

 without any sign check.

 So if you think you need to kill the inlined variants please use the
 existing
 tree_int_cst_lt instead.
>>>
>>> no, they could not have.   tree_int_cst_lt uses the signedness of the
>>> type
>>> to determine how to do the comparison.These two functions, as the
>>> macros
>>> they replace, force the comparison to be done independent of the
>>> signedness
>>> of the type.
>>
>> Well, looking at the surrounding code it's indeed non-obvious that this
>> would
>> be a 1:1 transform.  But then they should not compare _trees_ but instead
>> compare double-ints (or wide-ints).
>>
>> That said, I still think having a tree_int_cst_lt[us]_p function is wrong.
>> tree INTEGER_CSTs have a sign.  (apart from that opinion we have
>> tree_int_cst_lt and you introduce tree_int_cst_ltu_p - consistent
>> would be tree_int_cst_ltu).
>
> This reply applies just as much to this patch as patch 6.
> I morally agree with you 100%.But the code does not agree with you.
>
> On patch 6, there are about 450 places where we want to take the lower hwi
> worth of bits out of a int cst.Of those, only 5 places use the function
> that allows the signedness to be passed in.   The rest make the signedness
> decision based on the local code and completely ignore any information in
> the type.Of those 5 that do allow the signedness to be passed in, only
> three of them actually pass it in based on the signedness of the variable
> they are accessing.
>
> I am sure that a lot of these are wrong.  But i could not tell you which are
> and which are not.
> luckily, a lot of this will go away with the full wide-int code because i
> just do most of this math in the full precision so the issue never comes up.
> But after i am finished, there will still be a fair number of places that do
> this.   (luckily, a large number of them are pulling the number out and
> comparing it to the precision of something, so this is likely to be harmless
> no matter how the code is written).
>
> But to a large extent, you are shooting the messenger here, and not person
> who committed the crime.   I will be happy to add some comments to point the
> clients of these to the one that looks at the type.   In looking over the
> patch, the only obvious ones that could be changed are the ones in
> tree-ssa-uninit.c and the tree-vrp.c. The one in tree-vrp.c just looks like
> that the person writing the code did not know about tree_int_cst_lt and
> wrote the check out our himself.  (i will fix this in the tree-vrp patch
> that i am working on now. The one in tree-ssa-uniunit looks correct.
>
> But beyond that, the rest are in the front ends and so i think that this as
> good as you get out of me.

Well, if you transform bogus (by moral standards) code into other
bogus code the whole point of your patch is to exchange the names
of a set of macros / functions to another set of macros / functions.

I see no point in that then.

Leave broken code as-is.  The more often you touch broken code
and just mangle it in some way the harder it gets to get to the
point that would maybe re

Re: wide int patch #7: Replacement of INT_CST_LT and INT_CST_LT_UNSIGNED

2012-10-19 Thread Kenneth Zadeck


On 10/19/2012 07:13 AM, Richard Biener wrote:

On Fri, Oct 19, 2012 at 12:59 PM, Kenneth Zadeck
 wrote:

On 10/19/2012 04:22 AM, Richard Biener wrote:

On Thu, Oct 18, 2012 at 7:32 PM, Kenneth Zadeck
 wrote:

This patch replaces all instances of  INT_CST_LT and INT_CST_LT_UNSIGNED
with
the new functions tree_int_cst_lts_p and tree_int_cst_ltu_p.   With the
new
implementation of int_cst these functions will be too big to do inline.

These new function names are extremely confusing given that we already
have tree_int_cst_lt which does the right thing based on the signedness
of the INTEGER_CST trees.

The whole point of the macros was to be inlined and you break that.  That
is,
for example

 if (unsignedp && unsignedp0)
  {
- min_gt = INT_CST_LT_UNSIGNED (primop1, minval);
- max_gt = INT_CST_LT_UNSIGNED (primop1, maxval);
- min_lt = INT_CST_LT_UNSIGNED (minval, primop1);
- max_lt = INT_CST_LT_UNSIGNED (maxval, primop1);
+ min_gt = tree_int_cst_ltu_p (primop1, minval);
+ max_gt = tree_int_cst_ltu_p (primop1, maxval);
+ min_lt = tree_int_cst_ltu_p (minval, primop1);
+ max_lt = tree_int_cst_ltu_p (maxval, primop1);
  }
 else
  {
- min_gt = INT_CST_LT (primop1, minval);
- max_gt = INT_CST_LT (primop1, maxval);
- min_lt = INT_CST_LT (minval, primop1);
- max_lt = INT_CST_LT (maxval, primop1);
+ min_gt = tree_int_cst_lts_p (primop1, minval);
...

could have just been

  min_gt = tree_int_cst_lt (primop1, minval);


without any sign check.

So if you think you need to kill the inlined variants please use the
existing
tree_int_cst_lt instead.

no, they could not have.   tree_int_cst_lt uses the signedness of the type
to determine how to do the comparison.These two functions, as the macros
they replace, force the comparison to be done independent of the signedness
of the type.

Well, looking at the surrounding code it's indeed non-obvious that this would
be a 1:1 transform.  But then they should not compare _trees_ but instead
compare double-ints (or wide-ints).

That said, I still think having a tree_int_cst_lt[us]_p function is wrong.
tree INTEGER_CSTs have a sign.  (apart from that opinion we have
tree_int_cst_lt and you introduce tree_int_cst_ltu_p - consistent
would be tree_int_cst_ltu).

This reply applies just as much to this patch as patch 6.
I morally agree with you 100%.But the code does not agree with you.

On patch 6, there are about 450 places where we want to take the lower 
hwi worth of bits out of a int cst.Of those, only 5 places use the 
function that allows the signedness to be passed in.   The rest make the 
signedness decision based on the local code and completely ignore any 
information in the type.Of those 5 that do allow the signedness to 
be passed in, only three of them actually pass it in based on the 
signedness of the variable they are accessing.


I am sure that a lot of these are wrong.  But i could not tell you which 
are and which are not.
luckily, a lot of this will go away with the full wide-int code because 
i just do most of this math in the full precision so the issue never 
comes up.But after i am finished, there will still be a fair number 
of places that do this.   (luckily, a large number of them are pulling 
the number out and comparing it to the precision of something, so this 
is likely to be harmless no matter how the code is written).


But to a large extent, you are shooting the messenger here, and not 
person who committed the crime.   I will be happy to add some comments 
to point the clients of these to the one that looks at the type.   In 
looking over the patch, the only obvious ones that could be changed are 
the ones in tree-ssa-uninit.c and the tree-vrp.c. The one in tree-vrp.c 
just looks like that the person writing the code did not know about 
tree_int_cst_lt and wrote the check out our himself.  (i will fix this 
in the tree-vrp patch that i am working on now. The one in 
tree-ssa-uniunit looks correct.


But beyond that, the rest are in the front ends and so i think that this 
as good as you get out of me.


Kenny


I do not know why we need to do this.  I am just applying a plug compatible
replacement here. I did not write this code, but I do not think that i can
just do as you say here.

So use the double-int interface in the places you substituted your new
tree predicates.  Yes, you'll have to touch that again when converting to
wide-int - but if those places really want to ignore the sign of the tree
they should not use a tree interface.

Richard.


Kenny



Thanks,
Richard.


This is a small patch that has no prerequisites.

Tested on x86-64.

kenny






Re: wide int patch #7: Replacement of INT_CST_LT and INT_CST_LT_UNSIGNED

2012-10-19 Thread Richard Biener
On Fri, Oct 19, 2012 at 12:59 PM, Kenneth Zadeck
 wrote:
>
> On 10/19/2012 04:22 AM, Richard Biener wrote:
>>
>> On Thu, Oct 18, 2012 at 7:32 PM, Kenneth Zadeck
>>  wrote:
>>>
>>> This patch replaces all instances of  INT_CST_LT and INT_CST_LT_UNSIGNED
>>> with
>>> the new functions tree_int_cst_lts_p and tree_int_cst_ltu_p.   With the
>>> new
>>> implementation of int_cst these functions will be too big to do inline.
>>
>> These new function names are extremely confusing given that we already
>> have tree_int_cst_lt which does the right thing based on the signedness
>> of the INTEGER_CST trees.
>>
>> The whole point of the macros was to be inlined and you break that.  That
>> is,
>> for example
>>
>> if (unsignedp && unsignedp0)
>>  {
>> - min_gt = INT_CST_LT_UNSIGNED (primop1, minval);
>> - max_gt = INT_CST_LT_UNSIGNED (primop1, maxval);
>> - min_lt = INT_CST_LT_UNSIGNED (minval, primop1);
>> - max_lt = INT_CST_LT_UNSIGNED (maxval, primop1);
>> + min_gt = tree_int_cst_ltu_p (primop1, minval);
>> + max_gt = tree_int_cst_ltu_p (primop1, maxval);
>> + min_lt = tree_int_cst_ltu_p (minval, primop1);
>> + max_lt = tree_int_cst_ltu_p (maxval, primop1);
>>  }
>> else
>>  {
>> - min_gt = INT_CST_LT (primop1, minval);
>> - max_gt = INT_CST_LT (primop1, maxval);
>> - min_lt = INT_CST_LT (minval, primop1);
>> - max_lt = INT_CST_LT (maxval, primop1);
>> + min_gt = tree_int_cst_lts_p (primop1, minval);
>> ...
>>
>> could have just been
>>
>>  min_gt = tree_int_cst_lt (primop1, minval);
>> 
>>
>> without any sign check.
>>
>> So if you think you need to kill the inlined variants please use the
>> existing
>> tree_int_cst_lt instead.
>
> no, they could not have.   tree_int_cst_lt uses the signedness of the type
> to determine how to do the comparison.These two functions, as the macros
> they replace, force the comparison to be done independent of the signedness
> of the type.

Well, looking at the surrounding code it's indeed non-obvious that this would
be a 1:1 transform.  But then they should not compare _trees_ but instead
compare double-ints (or wide-ints).

That said, I still think having a tree_int_cst_lt[us]_p function is wrong.
tree INTEGER_CSTs have a sign.  (apart from that opinion we have
tree_int_cst_lt and you introduce tree_int_cst_ltu_p - consistent
would be tree_int_cst_ltu).

> I do not know why we need to do this.  I am just applying a plug compatible
> replacement here. I did not write this code, but I do not think that i can
> just do as you say here.

So use the double-int interface in the places you substituted your new
tree predicates.  Yes, you'll have to touch that again when converting to
wide-int - but if those places really want to ignore the sign of the tree
they should not use a tree interface.

Richard.

> Kenny
>
>
>> Thanks,
>> Richard.
>>
>>> This is a small patch that has no prerequisites.
>>>
>>> Tested on x86-64.
>>>
>>> kenny
>
>


Re: wide int patch #7: Replacement of INT_CST_LT and INT_CST_LT_UNSIGNED

2012-10-19 Thread Kenneth Zadeck


On 10/19/2012 04:22 AM, Richard Biener wrote:

On Thu, Oct 18, 2012 at 7:32 PM, Kenneth Zadeck
 wrote:

This patch replaces all instances of  INT_CST_LT and INT_CST_LT_UNSIGNED
with
the new functions tree_int_cst_lts_p and tree_int_cst_ltu_p.   With the new
implementation of int_cst these functions will be too big to do inline.

These new function names are extremely confusing given that we already
have tree_int_cst_lt which does the right thing based on the signedness
of the INTEGER_CST trees.

The whole point of the macros was to be inlined and you break that.  That is,
for example

if (unsignedp && unsignedp0)
 {
- min_gt = INT_CST_LT_UNSIGNED (primop1, minval);
- max_gt = INT_CST_LT_UNSIGNED (primop1, maxval);
- min_lt = INT_CST_LT_UNSIGNED (minval, primop1);
- max_lt = INT_CST_LT_UNSIGNED (maxval, primop1);
+ min_gt = tree_int_cst_ltu_p (primop1, minval);
+ max_gt = tree_int_cst_ltu_p (primop1, maxval);
+ min_lt = tree_int_cst_ltu_p (minval, primop1);
+ max_lt = tree_int_cst_ltu_p (maxval, primop1);
 }
else
 {
- min_gt = INT_CST_LT (primop1, minval);
- max_gt = INT_CST_LT (primop1, maxval);
- min_lt = INT_CST_LT (minval, primop1);
- max_lt = INT_CST_LT (maxval, primop1);
+ min_gt = tree_int_cst_lts_p (primop1, minval);
...

could have just been

 min_gt = tree_int_cst_lt (primop1, minval);


without any sign check.

So if you think you need to kill the inlined variants please use the existing
tree_int_cst_lt instead.
no, they could not have.   tree_int_cst_lt uses the signedness of the 
type to determine how to do the comparison.These two functions, as 
the macros they replace, force the comparison to be done independent of 
the signedness of the type.


I do not know why we need to do this.  I am just applying a plug 
compatible replacement here. I did not write this code, but I do not 
think that i can just do as you say here.


Kenny


Thanks,
Richard.


This is a small patch that has no prerequisites.

Tested on x86-64.

kenny




Re: wide int patch #7: Replacement of INT_CST_LT and INT_CST_LT_UNSIGNED

2012-10-19 Thread Richard Biener
On Thu, Oct 18, 2012 at 7:32 PM, Kenneth Zadeck
 wrote:
> This patch replaces all instances of  INT_CST_LT and INT_CST_LT_UNSIGNED
> with
> the new functions tree_int_cst_lts_p and tree_int_cst_ltu_p.   With the new
> implementation of int_cst these functions will be too big to do inline.

These new function names are extremely confusing given that we already
have tree_int_cst_lt which does the right thing based on the signedness
of the INTEGER_CST trees.

The whole point of the macros was to be inlined and you break that.  That is,
for example

   if (unsignedp && unsignedp0)
{
- min_gt = INT_CST_LT_UNSIGNED (primop1, minval);
- max_gt = INT_CST_LT_UNSIGNED (primop1, maxval);
- min_lt = INT_CST_LT_UNSIGNED (minval, primop1);
- max_lt = INT_CST_LT_UNSIGNED (maxval, primop1);
+ min_gt = tree_int_cst_ltu_p (primop1, minval);
+ max_gt = tree_int_cst_ltu_p (primop1, maxval);
+ min_lt = tree_int_cst_ltu_p (minval, primop1);
+ max_lt = tree_int_cst_ltu_p (maxval, primop1);
}
   else
{
- min_gt = INT_CST_LT (primop1, minval);
- max_gt = INT_CST_LT (primop1, maxval);
- min_lt = INT_CST_LT (minval, primop1);
- max_lt = INT_CST_LT (maxval, primop1);
+ min_gt = tree_int_cst_lts_p (primop1, minval);
...

could have just been

min_gt = tree_int_cst_lt (primop1, minval);


without any sign check.

So if you think you need to kill the inlined variants please use the existing
tree_int_cst_lt instead.

Thanks,
Richard.

> This is a small patch that has no prerequisites.
>
> Tested on x86-64.
>
> kenny


Re: wide int patch #7: Replacement of INT_CST_LT and INT_CST_LT_UNSIGNED

2012-10-18 Thread Kenneth Zadeck
This patch replaces all instances of  INT_CST_LT and INT_CST_LT_UNSIGNED 
with
the new functions tree_int_cst_lts_p and tree_int_cst_ltu_p.   With the 
new implementation of int_cst these functions will be too big to do inline.


This is a small patch that has no prerequisites.

Tested on x86-64.

kenny
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 930d5e5..5f235fb 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -3902,17 +3902,17 @@ shorten_compare (tree *op0_ptr, tree *op1_ptr, tree *restype_ptr,
 
   if (unsignedp && unsignedp0)
 	{
-	  min_gt = INT_CST_LT_UNSIGNED (primop1, minval);
-	  max_gt = INT_CST_LT_UNSIGNED (primop1, maxval);
-	  min_lt = INT_CST_LT_UNSIGNED (minval, primop1);
-	  max_lt = INT_CST_LT_UNSIGNED (maxval, primop1);
+	  min_gt = tree_int_cst_ltu_p (primop1, minval);
+	  max_gt = tree_int_cst_ltu_p (primop1, maxval);
+	  min_lt = tree_int_cst_ltu_p (minval, primop1);
+	  max_lt = tree_int_cst_ltu_p (maxval, primop1);
 	}
   else
 	{
-	  min_gt = INT_CST_LT (primop1, minval);
-	  max_gt = INT_CST_LT (primop1, maxval);
-	  min_lt = INT_CST_LT (minval, primop1);
-	  max_lt = INT_CST_LT (maxval, primop1);
+	  min_gt = tree_int_cst_lts_p (primop1, minval);
+	  max_gt = tree_int_cst_lts_p (primop1, maxval);
+	  min_lt = tree_int_cst_lts_p (minval, primop1);
+	  max_lt = tree_int_cst_lts_p (maxval, primop1);
 	}
 
   val = 0;
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index f888d32..2ee6eca 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -6317,8 +6317,8 @@ type_passed_as (tree type)
   else if (targetm.calls.promote_prototypes (type)
 	   && INTEGRAL_TYPE_P (type)
 	   && COMPLETE_TYPE_P (type)
-	   && INT_CST_LT_UNSIGNED (TYPE_SIZE (type),
-   TYPE_SIZE (integer_type_node)))
+	   && tree_int_cst_ltu_p (TYPE_SIZE (type),
+  TYPE_SIZE (integer_type_node)))
 type = integer_type_node;
 
   return type;
@@ -6358,8 +6358,8 @@ convert_for_arg_passing (tree type, tree val, tsubst_flags_t complain)
   else if (targetm.calls.promote_prototypes (type)
 	   && INTEGRAL_TYPE_P (type)
 	   && COMPLETE_TYPE_P (type)
-	   && INT_CST_LT_UNSIGNED (TYPE_SIZE (type),
-   TYPE_SIZE (integer_type_node)))
+	   && tree_int_cst_ltu_p (TYPE_SIZE (type),
+  TYPE_SIZE (integer_type_node)))
 val = cp_perform_integral_promotions (val, complain);
   if ((complain & tf_warning)
   && warn_suggest_attribute_format)
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index c62a33e..8183e85 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -3427,7 +3427,7 @@ walk_subobject_offsets (tree type,
 
   /* If this OFFSET is bigger than the MAX_OFFSET, then we should
  stop.  */
-  if (max_offset && INT_CST_LT (max_offset, offset))
+  if (max_offset && tree_int_cst_lts_p (max_offset, offset))
 return 0;
 
   if (type == error_mark_node)
@@ -3582,8 +3582,8 @@ walk_subobject_offsets (tree type,
   for (index = size_zero_node;
 	   /* G++ 3.2 had an off-by-one error here.  */
 	   (abi_version_at_least (2)
-	? !INT_CST_LT (TYPE_MAX_VALUE (domain), index)
-	: INT_CST_LT (index, TYPE_MAX_VALUE (domain)));
+	? !tree_int_cst_lts_p (TYPE_MAX_VALUE (domain), index)
+	: tree_int_cst_lts_p (index, TYPE_MAX_VALUE (domain)));
 	   index = size_binop (PLUS_EXPR, index, size_one_node))
 	{
 	  r = walk_subobject_offsets (TREE_TYPE (type),
@@ -3599,7 +3599,7 @@ walk_subobject_offsets (tree type,
 	  /* If this new OFFSET is bigger than the MAX_OFFSET, then
 	 there's no point in iterating through the remaining
 	 elements of the array.  */
-	  if (max_offset && INT_CST_LT (max_offset, offset))
+	  if (max_offset && tree_int_cst_lts_p (max_offset, offset))
 	break;
 	}
 }
@@ -5432,7 +5432,7 @@ end_of_class (tree t, int include_virtuals_p)
 	continue;
 
   offset = end_of_base (base_binfo);
-  if (INT_CST_LT_UNSIGNED (result, offset))
+  if (tree_int_cst_ltu_p (result, offset))
 	result = offset;
 }
 
@@ -5442,7 +5442,7 @@ end_of_class (tree t, int include_virtuals_p)
 	 VEC_iterate (tree, vbases, i, base_binfo); i++)
   {
 	offset = end_of_base (base_binfo);
-	if (INT_CST_LT_UNSIGNED (result, offset))
+	if (tree_int_cst_ltu_p (result, offset))
 	  result = offset;
   }
 
@@ -5522,7 +5522,7 @@ include_empty_classes (record_layout_info rli)
 		  CLASSTYPE_AS_BASE (rli->t) != NULL_TREE);
   rli_size = rli_size_unit_so_far (rli);
   if (TREE_CODE (rli_size) == INTEGER_CST
-  && INT_CST_LT_UNSIGNED (rli_size, eoc))
+  && tree_int_cst_ltu_p (rli_size, eoc))
 {
   if (!abi_version_at_least (2))
 	/* In version 1 of the ABI, the size of a class that ends with
@@ -5638,7 +5638,7 @@ layout_class_type (tree t, tree *virtuals_p)
 	 type, then there are some special rules for allocating
 	 it.  */
   if (DECL_C_BIT_FIELD (field)
-	  && INT_CST_LT (TYPE_SIZE (type), DECL_SIZE (field)))
+	  && tree_int_cst_lts_p (TYPE_SIZE (type), DECL_SIZE (field)))
 	{
 	  unsigned int itk;
 	  tree integer