From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1461) id BC9F63858439; Mon, 24 Oct 2022 16:19:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BC9F63858439 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666628401; bh=IvW8dzVt/9vPaKmlSmanHOE7PZ5yp5BLbU6CCZ1R77Y=; h=From:To:Subject:Date:From; b=PJC4ZxjS7y+8ZncxFPAXjpI5MiTnnKr6pT6F5IdX3okxOZqg+1VDXq8DyqN8KmhOK OPvgMeHCBW+nbb8Jimb8MslDJJpRpd9ymulWYz2l9V2hMogh+MU39s4xO+YnDgiGVX /5KHMDw734ziZuGlZPJ/oDip252vagKxwqaq57O8= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Andrew Stubbs To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/omp/gcc-12] vect: WORKAROUND vectorizer bug X-Act-Checkin: gcc X-Git-Author: Andrew Stubbs X-Git-Refname: refs/heads/devel/omp/gcc-12 X-Git-Oldrev: 0889dd6912c8550e113d8b5417fd65291316209c X-Git-Newrev: 2a0dc45c854448ec4628dab5c6c08999a5cf3fe5 Message-Id: <20221024162001.BC9F63858439@sourceware.org> Date: Mon, 24 Oct 2022 16:19:59 +0000 (GMT) List-Id: https://gcc.gnu.org/g:2a0dc45c854448ec4628dab5c6c08999a5cf3fe5 commit 2a0dc45c854448ec4628dab5c6c08999a5cf3fe5 Author: Andrew Stubbs Date: Fri Oct 21 14:19:31 2022 +0100 vect: WORKAROUND vectorizer bug This patch disables vectorization of memory accesses to non-default address spaces where the pointer size is different to the usual pointer size. This condition typically occurs in OpenACC programs on amdgcn, where LDS memory is used for broadcasting gang-private variables between threads. In particular, see libgomp.oacc-c-c++-common/private-variables.c The problem is that the address space information is dropped from the various types in the middle-end and eventually it triggers an ICE trying to do an address conversion. That ICE can be avoided by defining POINTERS_EXTEND_UNSIGNED, but that just produces wrong RTL code later on. A correct solution would ensure that all the vectypes have the correct address spaces, but I don't have time for that right now. gcc/ChangeLog: * tree-vect-data-refs.cc (vect_analyze_data_refs): Workaround an address-space bug. Diff: --- gcc/ChangeLog.omp | 5 +++++ gcc/tree-vect-data-refs.cc | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp index d7b693ac830..68d5eea01a7 100644 --- a/gcc/ChangeLog.omp +++ b/gcc/ChangeLog.omp @@ -1,3 +1,8 @@ +2022-10-24 Andrew Stubbs + + * tree-vect-data-refs.cc (vect_analyze_data_refs): Workaround an + address-space bug. + 2022-10-24 Andrew Stubbs * config/gcn/gcn.cc (gcn_init_cumulative_args): Disallow gfx908. diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc index 09223baf718..70b671ed94a 100644 --- a/gcc/tree-vect-data-refs.cc +++ b/gcc/tree-vect-data-refs.cc @@ -4598,7 +4598,21 @@ vect_analyze_data_refs (vec_info *vinfo, poly_uint64 *min_vf, bool *fatal) /* Set vectype for STMT. */ scalar_type = TREE_TYPE (DR_REF (dr)); tree vectype = get_vectype_for_scalar_type (vinfo, scalar_type); - if (!vectype) + + /* FIXME: If the object is in an address-space in which the pointer size + is different to the default address space then vectorizing here will + lead to an ICE down the road because the address space information + gets lost. This work-around fixes the problem until we have a proper + solution. */ + tree base_object = DR_REF (dr); + tree op = (TREE_CODE (base_object) == COMPONENT_REF + || TREE_CODE (base_object) == ARRAY_REF + ? TREE_OPERAND (base_object, 0) : base_object); + addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (op)); + bool addr_space_bug = (!ADDR_SPACE_GENERIC_P (as) + && targetm.addr_space.pointer_mode (as) != Pmode); + + if (!vectype || addr_space_bug) { if (dump_enabled_p ()) {