From: Martin Liska Date: Thu, 15 Oct 2020 12:57:31 +0000 (+0200) Subject: IPA: compare VRP types. X-Git-Tag: releases/gcc-10.3.0~768 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92fedd32d8568f2336050b064da50b3c6441d029;p=thirdparty%2Fgcc.git IPA: compare VRP types. gcc/ChangeLog: PR ipa/97404 * ipa-prop.c (struct ipa_vr_ggc_hash_traits): Compare types of VRP as we can merge ranges of different types. gcc/testsuite/ChangeLog: PR ipa/97404 * gcc.c-torture/execute/pr97404.c: New test. (cherry picked from commit a86623902767122c71c7229150a8b8a79cbb3673) --- diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index 71ac0e104d24..0d9f0a8ab8d8 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -122,7 +122,8 @@ struct ipa_vr_ggc_hash_traits : public ggc_cache_remove static bool equal (const value_range *a, const value_range *b) { - return a->equal_p (*b); + return (a->equal_p (*b) + && types_compatible_p (a->type (), b->type ())); } static const bool empty_zero_p = true; static void diff --git a/gcc/testsuite/gcc.c-torture/execute/pr97404.c b/gcc/testsuite/gcc.c-torture/execute/pr97404.c new file mode 100644 index 000000000000..7e5ce231725e --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr97404.c @@ -0,0 +1,28 @@ +/* PR ipa/97404 */ +/* { dg-additional-options "-fno-inline" } */ + +char a, b; +long c; +short d, e; +long *f = &c; +int g; +char h(signed char i) { return 0; } +static short j(short i, int k) { return i < 0 ? 0 : i >> k; } +void l(void); +void m(void) +{ + e = j(d | 9766, 11); + *f = e; +} +void l(void) +{ + a = 5 | g; + b = h(a); +} +int main() +{ + m(); + if (c != 4) + __builtin_abort(); + return 0; +}