mirror of
https://github.com/gcc-mirror/gcc.git
synced 2024-11-21 13:40:47 +00:00
Don't call invert on VARYING.
When all cases go to one label and resul in a VARYING value, we can't invert that value to remove all values from the default case. Simply check for this case and set the default to UNDEFINED. PR tree-optimization/117398 gcc/ * gimple-range-edge.cc (gimple_outgoing_range::calc_switch_ranges): Check for VARYING and don't call invert () on it. gcc/testsuite/ * gcc.dg/pr117398.c: New.
This commit is contained in:
parent
8762bb1b00
commit
766075c47d
@ -159,8 +159,14 @@ gimple_outgoing_range::calc_switch_ranges (gswitch *sw)
|
|||||||
// Remove the case range from the default case.
|
// Remove the case range from the default case.
|
||||||
int_range_max def_range (type, low, high);
|
int_range_max def_range (type, low, high);
|
||||||
range_cast (def_range, type);
|
range_cast (def_range, type);
|
||||||
def_range.invert ();
|
// If all possible values are taken, set default_range to UNDEFINED.
|
||||||
default_range.intersect (def_range);
|
if (def_range.varying_p ())
|
||||||
|
default_range.set_undefined ();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
def_range.invert ();
|
||||||
|
default_range.intersect (def_range);
|
||||||
|
}
|
||||||
|
|
||||||
// Create/union this case with anything on else on the edge.
|
// Create/union this case with anything on else on the edge.
|
||||||
int_range_max case_range (type, low, high);
|
int_range_max case_range (type, low, high);
|
||||||
|
17
gcc/testsuite/gcc.dg/pr117398.c
Normal file
17
gcc/testsuite/gcc.dg/pr117398.c
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/* { dg-do compile } */
|
||||||
|
/* { dg-options "-O2" } */
|
||||||
|
|
||||||
|
int a;
|
||||||
|
void c(void);
|
||||||
|
int d(_Bool b) {
|
||||||
|
switch (b+0) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
c();
|
||||||
|
}
|
||||||
|
if (b)
|
||||||
|
return a;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user