public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* overflow check in extract_range_from_binary_1 useless?
@ 2018-06-08 10:38 Aldy Hernandez
  2018-06-13 11:42 ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: Aldy Hernandez @ 2018-06-08 10:38 UTC (permalink / raw)
  To: Richard Biener, GCC Mailing List; +Cc: Andrew MacLeod

Howdy.

Am I missing something or are these two sets identical?

> 	  /* Get the lower and upper bounds of the type.  */
> 	  if (TYPE_OVERFLOW_WRAPS (expr_type))
> 	    {
> 	      type_min = wi::min_value (prec, sgn);
> 	      type_max = wi::max_value (prec, sgn);
> 	    }
> 	  else
> 	    {
> 	      type_min = wi::to_wide (vrp_val_min (expr_type));
> 	      type_max = wi::to_wide (vrp_val_max (expr_type));
> 	    }

Isn't wi::to_wide(TYPE_MIN/MAX_VALUE) the same as wi::min/max_value, or 
is there some weird language (*cough ada*) subtlety I'm missing?

Confused.
Aldy

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: overflow check in extract_range_from_binary_1 useless?
  2018-06-08 10:38 overflow check in extract_range_from_binary_1 useless? Aldy Hernandez
@ 2018-06-13 11:42 ` Richard Biener
  2018-07-05 22:06   ` Jeff Law
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2018-06-13 11:42 UTC (permalink / raw)
  To: Aldy Hernandez; +Cc: GCC Development, Andrew MacLeod

On Fri, Jun 8, 2018 at 11:42 AM Aldy Hernandez <aldyh@redhat.com> wrote:
>
> Howdy.
>
> Am I missing something or are these two sets identical?
>
> >         /* Get the lower and upper bounds of the type.  */
> >         if (TYPE_OVERFLOW_WRAPS (expr_type))
> >           {
> >             type_min = wi::min_value (prec, sgn);
> >             type_max = wi::max_value (prec, sgn);
> >           }
> >         else
> >           {
> >             type_min = wi::to_wide (vrp_val_min (expr_type));
> >             type_max = wi::to_wide (vrp_val_max (expr_type));
> >           }
>
> Isn't wi::to_wide(TYPE_MIN/MAX_VALUE) the same as wi::min/max_value, or
> is there some weird language (*cough ada*) subtlety I'm missing?

It might have subtle differences for -fstrict-enums or other language specific
types where the legal value-range doesn't cover all of the types precision.

I think you can safely use the wi::max/min_value variant and IMHO
vrp_val_min/max should use wi::min/max_value as well (well, it returns
a tree so better not re-create that all the time).

Richard.

> Confused.
> Aldy

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: overflow check in extract_range_from_binary_1 useless?
  2018-06-13 11:42 ` Richard Biener
@ 2018-07-05 22:06   ` Jeff Law
  0 siblings, 0 replies; 3+ messages in thread
From: Jeff Law @ 2018-07-05 22:06 UTC (permalink / raw)
  To: Richard Biener, Aldy Hernandez; +Cc: GCC Development, Andrew MacLeod

On 06/13/2018 05:18 AM, Richard Biener wrote:
> On Fri, Jun 8, 2018 at 11:42 AM Aldy Hernandez <aldyh@redhat.com> wrote:
>>
>> Howdy.
>>
>> Am I missing something or are these two sets identical?
>>
>>>         /* Get the lower and upper bounds of the type.  */
>>>         if (TYPE_OVERFLOW_WRAPS (expr_type))
>>>           {
>>>             type_min = wi::min_value (prec, sgn);
>>>             type_max = wi::max_value (prec, sgn);
>>>           }
>>>         else
>>>           {
>>>             type_min = wi::to_wide (vrp_val_min (expr_type));
>>>             type_max = wi::to_wide (vrp_val_max (expr_type));
>>>           }
>>
>> Isn't wi::to_wide(TYPE_MIN/MAX_VALUE) the same as wi::min/max_value, or
>> is there some weird language (*cough ada*) subtlety I'm missing?
> 
> It might have subtle differences for -fstrict-enums or other language specific
> types where the legal value-range doesn't cover all of the types precision.
> 
> I think you can safely use the wi::max/min_value variant and IMHO
> vrp_val_min/max should use wi::min/max_value as well (well, it returns
> a tree so better not re-create that all the time).
Or even C++ perhaps where an enum object can take on values outside the
enum.

Jeff

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-07-05 22:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-08 10:38 overflow check in extract_range_from_binary_1 useless? Aldy Hernandez
2018-06-13 11:42 ` Richard Biener
2018-07-05 22:06   ` Jeff Law

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).