Hi! The ipa vr hash table apparently intentionally doesn't differentiate between value ranges with different types, all that matters are the values of min and max, so before using it ipa_vr_operation_and_type_effects needs to be called to convert the value_range to the right type. Most of the spots do that correctly, but the second hunk fixes a spot that called it but ignored the newly computed value_range and used the non-converted one anyway.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2019-12-10 Jakub Jelinek <ja...@redhat.com> PR ipa/92883 * ipa-cp.c (propagate_vr_across_jump_function): Pass jvr rather than *jfunc->m_vr to intersect. Formatting fix. * gcc.dg/ipa/pr92883.c: New test. --- gcc/ipa-cp.c.jj 2019-12-06 00:40:40.000000000 +0100 +++ gcc/ipa-cp.c 2019-12-10 11:57:10.354999085 +0100 @@ -2369,12 +2369,10 @@ propagate_vr_across_jump_function (cgrap value_range vr; if (TREE_CODE_CLASS (operation) == tcc_unary) - { - ipa_vr_operation_and_type_effects (&vr, - &src_lats->m_value_range.m_vr, - operation, param_type, - operand_type); - } + ipa_vr_operation_and_type_effects (&vr, + &src_lats->m_value_range.m_vr, + operation, param_type, + operand_type); /* A crude way to prevent unbounded number of value range updates in SCC components. We should allow limited number of updates within SCC, too. */ @@ -2400,7 +2398,7 @@ propagate_vr_across_jump_function (cgrap NOP_EXPR, param_type, jfunc->m_vr->type ())) - vr.intersect (*jfunc->m_vr); + vr.intersect (jvr); } return dest_lat->meet_with (&vr); } --- gcc/testsuite/gcc.dg/ipa/pr92883.c.jj 2019-12-10 12:45:49.260640164 +0100 +++ gcc/testsuite/gcc.dg/ipa/pr92883.c 2019-12-10 12:45:07.490278603 +0100 @@ -0,0 +1,14 @@ +/* PR ipa/92883 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int a, b, c, d; +unsigned e; +void baz (void *, int); +void grault (int, unsigned long); +int foo (unsigned g) { return a / g; } +void bar (void *g) { if (b) baz (g, 5); } +static void quux (int, unsigned long); +static void qux (unsigned long g) { if (g) { d = foo (-1); quux (e, (d & 2) + g); } } +static void quux (int g, unsigned long m) { (void) g; grault (c, m); bar (""); } +void corge () { qux (e); } Jakub