diff options
-rw-r--r-- | gcc/ipa-cp.cc | 10 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr120048.c | 12 |
2 files changed, 22 insertions, 0 deletions
diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc index f7e5aa9..b41148c 100644 --- a/gcc/ipa-cp.cc +++ b/gcc/ipa-cp.cc @@ -6362,6 +6362,11 @@ ipcp_store_vr_results (void) TYPE_PRECISION (type), TYPE_SIGN (type))); tmp.update_bitmask (bm); + // Reflecting the bitmask on the ranges can sometime + // produce an UNDEFINED value if the the bitmask update + // was previously deferred. See PR 120048. + if (tmp.undefined_p ()) + tmp.set_varying (type); ipa_vr vr (tmp); ts->m_vr->quick_push (vr); } @@ -6383,6 +6388,11 @@ ipcp_store_vr_results (void) TYPE_PRECISION (type), TYPE_SIGN (type))); tmp.update_bitmask (bm); + // Reflecting the bitmask on the ranges can sometime + // produce an UNDEFINED value if the the bitmask update + // was previously deferred. See PR 120048. + if (tmp.undefined_p ()) + tmp.set_varying (type); ipa_vr vr (tmp); ts->m_vr->quick_push (vr); } diff --git a/gcc/testsuite/gcc.dg/pr120048.c b/gcc/testsuite/gcc.dg/pr120048.c new file mode 100644 index 0000000..6bb34b0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr120048.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-vrp -fno-tree-fre" } */ + +int a, b, c; +static int d(short e) { return e || (a && e) ? 0 : a; } +static void f(int e) { + if (!e) { + d(0); + b = d(e); + } +} +int main() { f(c | 1); } |