[Bug tree-optimization/102798] [9/10/11/12 Regression] wrong code with -O3 -fno-tree-pta by r9-2475
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102798 --- Comment #12 from CVS Commits --- The master branch has been updated by Richard Biener : https://gcc.gnu.org/g:a5b1b2a186d94b31a522395e9d02c9cec1b928cb commit r12-4466-ga5b1b2a186d94b31a522395e9d02c9cec1b928cb Author: Richard Biener Date: Mon Oct 18 09:10:43 2021 +0200 tree-optimization/102798 - avoid copying PTA info to old SSA names The vectorizer duplicates pointer-info to created pointer bases but it has to avoid changing points-to info on existing SSA names because there's now flow-sensitive info in there (pt->pt_null as set from VRP). 2021-10-18 Richard Biener PR tree-optimization/102798 * tree-vect-data-refs.c (vect_create_addr_base_for_vector_ref): Only copy points-to info to newly generated SSA names. * gcc.dg/pr102798.c: New testcase.
[Bug tree-optimization/102798] [9/10/11/12 Regression] wrong code with -O3 -fno-tree-pta by r9-2475
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102798 --- Comment #11 from Richard Biener --- The issue is that the vectorizer should only duplicate pointer-info to SSA names it created itself, not to _any_ existing ones.
[Bug tree-optimization/102798] [9/10/11/12 Regression] wrong code with -O3 -fno-tree-pta by r9-2475
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102798 Richard Biener changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org
[Bug tree-optimization/102798] [9/10/11/12 Regression] wrong code with -O3 -fno-tree-pta by r9-2475
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102798 H.J. Lu changed: What|Removed |Added Attachment #51618|0 |1 is obsolete|| --- Comment #10 from H.J. Lu --- Created attachment 51619 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51619=edit An updated patch
[Bug tree-optimization/102798] [9/10/11/12 Regression] wrong code with -O3 -fno-tree-pta by r9-2475
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102798 --- Comment #9 from H.J. Lu --- Created attachment 51618 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51618=edit A patch
[Bug tree-optimization/102798] [9/10/11/12 Regression] wrong code with -O3 -fno-tree-pta by r9-2475
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102798 --- Comment #8 from H.J. Lu --- Vectorizer has if (DR_PTR_INFO (dr) && TREE_CODE (addr_base) == SSA_NAME && !SSA_NAME_PTR_INFO (addr_base)) vect_duplicate_ssa_name_ptr_info (addr_base, dr_info); This fixes the crash. diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c index 1e13148190c..fca5aebfbdb 100644 --- a/gcc/tree-vect-data-refs.c +++ b/gcc/tree-vect-data-refs.c @@ -4785,7 +4785,8 @@ vect_create_addr_base_for_vector_ref (vec_info *vinfo, stmt_vec_info stmt_info, if (DR_PTR_INFO (dr) && TREE_CODE (addr_base) == SSA_NAME - && !SSA_NAME_PTR_INFO (addr_base)) + && !SSA_NAME_PTR_INFO (addr_base) + && TREE_CODE (SSA_NAME_VAR (addr_base)) != PARM_DECL) vect_duplicate_ssa_name_ptr_info (addr_base, dr_info); if (dump_enabled_p ())
[Bug tree-optimization/102798] [9/10/11/12 Regression] wrong code with -O3 -fno-tree-pta by r9-2475
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102798 H.J. Lu changed: What|Removed |Added CC||aldyh at gcc dot gnu.org --- Comment #7 from H.J. Lu --- Looks like a VRP bug. For: [local count: 168730857]: if (in_16(D) != 0B) goto ; [70.00%] else goto ; [30.00%] [local count: 118111600]: _1 = size_17(D) + 18446744073709551615; out_26 = out_18(D) + _1; goto ; [100.00%] VRP reports: in_16(D) : BACK visiting block 3 for in_16(D) 2->3 has cache, const unsigned char * VARYING, update. FWD visiting block 3 for in_16(D) starting range : UNDEFINED edge 2->3 :const unsigned char * [1B, +INF] Updating range to const unsigned char * [1B, +INF] Updating blocks : DONE visiting blocks for in_16(D)
[Bug tree-optimization/102798] [9/10/11/12 Regression] wrong code with -O3 -fno-tree-pta by r9-2475
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102798 --- Comment #6 from H.J. Lu --- A pointer is known to non-null only if we know where the pointer is pointing to. Since the null field is initialized to 0, we need to check both null and anything. This works on the test case: diff --git a/gcc/value-query.cc b/gcc/value-query.cc index ab133aab114..1e8e3b96ea7 100644 --- a/gcc/value-query.cc +++ b/gcc/value-query.cc @@ -302,7 +302,7 @@ get_ssa_name_ptr_info_nonnull (const_tree name) When PTA analysis is improved, pt.anything, pt.nonlocal and pt.escaped may also has to be considered before deciding that pointer cannot point to NULL. */ - return !pi->pt.null; + return !pi->pt.null && !pi->pt.anything; } // Update the global range for NAME into the SSA_RANGE_NAME_INFO and
[Bug tree-optimization/102798] [9/10/11/12 Regression] wrong code with -O3 -fno-tree-pta by r9-2475
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102798 Andrew Pinski changed: What|Removed |Added Summary|[9/10/11/12 Regression] |[9/10/11/12 Regression] |wrong code with -O3 |wrong code with -O3 |-fno-tree-pta -mavx512f by |-fno-tree-pta by r9-2475 |r9-2475 | --- Comment #5 from Andrew Pinski --- Here is a testcase which fails without -mavx512 typedef __SIZE_TYPE__ size_t; __attribute__((__noipa__)) void BUF_reverse (unsigned char *out, const unsigned char *in, size_t size) { size_t i; if (in) { out += size - 1; for (i = 0; i < size; i++) *out++ = *in++; } else { unsigned char *q; char c; q = out + size - 1; for (i = 0; i < size ; i++) { *out++ = 1; } } } int main (void) { unsigned char buf[40]; unsigned char buf1[40]; for (unsigned i = 0; i < sizeof (buf); i++) buf[i] = i; BUF_reverse (buf, 0, sizeof (buf)); for (unsigned i = 0; i < sizeof (buf); i++) if (buf[i] != 1) __builtin_abort (); return 0; }