From 5ba25b2ef179aec8ba4c47612fbc5c388f41cb36 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 16 Mar 2020 09:02:21 +0100 Subject: [PATCH] tree-inline: Fix a -fcompare-debug issue in the inliner [PR94167] The following testcase fails with -fcompare-debug. The problem is that bar is marked as address_taken only with -g and not without. I've tracked it down to insert_init_stmt calling gimple_regimplify_operands even on DEBUG_STMTs. That function will just insert normal stmts before the DEBUG_STMT if the DEBUG_STMT operand isn't gimple val or invariant. While DCE will turn those statements into debug temporaries, it can cause differences in SSA_NAMEs and more importantly, the ipa references are generated from those before the DCE happens. On the testcase, the DEBUG_STMT value is (int)bar. We could generate DEBUG_STMTs with debug temporaries instead, but I fail to see the reason to do that, DEBUG_STMTs allow other expressions and all we want to ensure is that the expressions aren't too large (arbitrarily complex), but during inlining/function versioning I don't see why something would queue a DEBUG_STMT with arbitrarily complex expressions in there. 2020-03-16 Jakub Jelinek PR tree-optimization/94166 * tree-ssa-reassoc.c (sort_by_mach_mode): Use SSA_NAME_VERSION as secondary comparison key. * gcc.dg/pr94166.c: New test. --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr94166.c | 24 ++++++++++++++++++++++++ gcc/tree-ssa-reassoc.c | 7 +++++-- 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr94166.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 53c9622afa2..8709f0c7f53 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2020-03-16 Jakub Jelinek + + PR tree-optimization/94166 + * tree-ssa-reassoc.c (sort_by_mach_mode): Use SSA_NAME_VERSION + as secondary comparison key. + 2020-03-16 Bin Cheng PR tree-optimization/94125 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ab0406656d2..d52cd1effa3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-03-16 Jakub Jelinek + + PR tree-optimization/94166 + * gcc.dg/pr94166.c: New test. + 2020-03-16 Bin Cheng PR tree-optimization/94125 diff --git a/gcc/testsuite/gcc.dg/pr94166.c b/gcc/testsuite/gcc.dg/pr94166.c new file mode 100644 index 00000000000..71917c4a2ec --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr94166.c @@ -0,0 +1,24 @@ +/* PR tree-optimization/94166 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug" } */ + +typedef int __m128i __attribute__((__may_alias__, __vector_size__(4 * sizeof (int)))); +unsigned int b[512]; + +void +foo (unsigned int *x, __m128i *y) +{ +#define A(n) __m128i v##n = y[n]; +#define B(n) A(n##0) A(n##1) A(n##2) A(n##3) A(n##4) A(n##5) A(n##6) A(n##7) \ + A(n##8) A(n##9) A(n##a) A(n##b) A(n##c) A(n##d) A(n##e) A(n##f) +#define C(n) B(n##0) B(n##1) B(n##2) B(n##3) B(n##4) B(n##5) B(n##6) B(n##7) + C(0x) +#undef A +#define A(n) *(__m128i *) &b[4 * n] = v##n; + C(0x) +#undef A +#define A(n) + b[4 * n] + b[4 * n + 1] + b[4 * n + 2] + b[4 * n + 3] + *x = *x + C(0x) + ; +} diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index 359ccaee68d..79871a8c659 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -1793,8 +1793,11 @@ sort_by_mach_mode (const void *p_i, const void *p_j) return 1; else if (mode1 < mode2) return -1; - else - return 0; + if (SSA_NAME_VERSION (tr1) < SSA_NAME_VERSION (tr2)) + return -1; + else if (SSA_NAME_VERSION (tr1) > SSA_NAME_VERSION (tr2)) + return 1; + return 0; } /* Cleanup hash map for VECTOR information. */ -- 2.30.2