Handle setting of 1-bit anti-ranges uniformly.
PR tree-optimization/99296 * value-range.cc (irange::irange_set_1bit_anti_range): New. (irange::irange_set_anti_range): Call irange_set_1bit_anti_range * value-range.h (irange::irange_set_1bit_anti_range): New.
This commit is contained in:
parent
441e1980ce
commit
88081d38bd
7
gcc/testsuite/gcc.dg/pr99296.c
Normal file
7
gcc/testsuite/gcc.dg/pr99296.c
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// { dg-do compile }
|
||||||
|
// { dg-options "-O2 -fno-tree-bit-ccp" }
|
||||||
|
|
||||||
|
struct {
|
||||||
|
signed a : 1;
|
||||||
|
} b, c;
|
||||||
|
void d() { b.a |= c.a |= 0 != 2; }
|
@ -184,12 +184,43 @@ irange::irange_set (tree min, tree max)
|
|||||||
verify_range ();
|
verify_range ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
irange::irange_set_1bit_anti_range (tree min, tree max)
|
||||||
|
{
|
||||||
|
tree type = TREE_TYPE (min);
|
||||||
|
gcc_checking_assert (TYPE_PRECISION (type) == 1);
|
||||||
|
|
||||||
|
if (operand_equal_p (min, max))
|
||||||
|
{
|
||||||
|
// Since these are 1-bit quantities, they can only be [MIN,MIN]
|
||||||
|
// or [MAX,MAX].
|
||||||
|
if (vrp_val_is_min (min))
|
||||||
|
min = max = vrp_val_max (type);
|
||||||
|
else
|
||||||
|
min = max = vrp_val_min (type);
|
||||||
|
set (min, max);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// The only alternative is [MIN,MAX], which is the empty range.
|
||||||
|
set_undefined ();
|
||||||
|
}
|
||||||
|
if (flag_checking)
|
||||||
|
verify_range ();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
irange::irange_set_anti_range (tree min, tree max)
|
irange::irange_set_anti_range (tree min, tree max)
|
||||||
{
|
{
|
||||||
gcc_checking_assert (!POLY_INT_CST_P (min));
|
gcc_checking_assert (!POLY_INT_CST_P (min));
|
||||||
gcc_checking_assert (!POLY_INT_CST_P (max));
|
gcc_checking_assert (!POLY_INT_CST_P (max));
|
||||||
|
|
||||||
|
if (TYPE_PRECISION (TREE_TYPE (min)) == 1)
|
||||||
|
{
|
||||||
|
irange_set_1bit_anti_range (min, max);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// set an anti-range
|
// set an anti-range
|
||||||
tree type = TREE_TYPE (min);
|
tree type = TREE_TYPE (min);
|
||||||
signop sign = TYPE_SIGN (type);
|
signop sign = TYPE_SIGN (type);
|
||||||
|
@ -127,6 +127,8 @@ protected:
|
|||||||
void copy_legacy_to_multi_range (const irange &);
|
void copy_legacy_to_multi_range (const irange &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void irange_set_1bit_anti_range (tree, tree);
|
||||||
|
|
||||||
unsigned char m_num_ranges;
|
unsigned char m_num_ranges;
|
||||||
unsigned char m_max_ranges;
|
unsigned char m_max_ranges;
|
||||||
ENUM_BITFIELD(value_range_kind) m_kind : 8;
|
ENUM_BITFIELD(value_range_kind) m_kind : 8;
|
||||||
|
Loading…
Reference in New Issue
Block a user