Drop tree overflow in irange setter.

Drop meaningless overflow that may creep into the IL.

gcc/ChangeLog:

	PR tree-optimization/103207
	* value-range.cc (irange::set): Drop overflow.

gcc/testsuite/ChangeLog:

	* gcc.dg/pr103207.c: New test.
This commit is contained in:
Aldy Hernandez 2021-11-13 12:16:40 +01:00
parent 82ec4cb3c4
commit 6c29c9d6a7
2 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,15 @@
// { dg-do compile }
// { dg-options "-O2 --param case-values-threshold=1 -w" }
int f (int i)
{
switch (i) {
case 2147483647:
return 1;
case 9223372036854775807L:
return 2;
case (2147483647*4)%4:
return 4;
}
return 0;
}

View File

@ -270,6 +270,14 @@ irange::irange_set_anti_range (tree min, tree max)
void
irange::set (tree min, tree max, value_range_kind kind)
{
if (kind != VR_UNDEFINED)
{
if (TREE_OVERFLOW_P (min))
min = drop_tree_overflow (min);
if (TREE_OVERFLOW_P (max))
max = drop_tree_overflow (max);
}
if (!legacy_mode_p ())
{
if (kind == VR_RANGE)