From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2049) id 85F8A3856270; Thu, 5 May 2022 12:04:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 85F8A3856270 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Matthew Malcomson To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ARM/heads/morello)] Avoid trans-capability MEM_REF relaxation in SLSR X-Act-Checkin: gcc X-Git-Author: Matthew Malcomson X-Git-Refname: refs/vendors/ARM/heads/morello X-Git-Oldrev: 9fe818be7c3594dc63d1945bd4cefa39b2ea417d X-Git-Newrev: 730d6010d4773bba7255a5cd845c9d48826c4074 Message-Id: <20220505120429.85F8A3856270@sourceware.org> Date: Thu, 5 May 2022 12:04:29 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 May 2022 12:04:29 -0000 https://gcc.gnu.org/g:730d6010d4773bba7255a5cd845c9d48826c4074 commit 730d6010d4773bba7255a5cd845c9d48826c4074 Author: Matthew Malcomson Date: Thu Mar 17 15:49:47 2022 +0000 Avoid trans-capability MEM_REF relaxation in SLSR There is an optimisation in SLSR that takes a COMPONENT_REF (or similar) whose base is a MEM_REF, and it splits that out into a MEM_REF using a different offset (pre-calculated using known constants). When performing this optimisation it uses the type of the offset for different things, and ends up changing the type of the MEM_REF base to the type of the offset. This is problematic, since if the base is a capability type and the offset is not this is throwing away the capability features. Here we just disable this optimisation if the two types are not compatible. Diff: --- gcc/gimple-ssa-strength-reduction.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gcc/gimple-ssa-strength-reduction.c b/gcc/gimple-ssa-strength-reduction.c index 3b7e1994abb..45f58df40df 100644 --- a/gcc/gimple-ssa-strength-reduction.c +++ b/gcc/gimple-ssa-strength-reduction.c @@ -993,6 +993,14 @@ restructure_reference (tree *pbase, tree *poffset, widest_int *pindex, t1 = TREE_OPERAND (base, 0); c1 = widest_int::from (mem_offset, SIGNED); type = TREE_TYPE (TREE_OPERAND (base, 1)); + /* MORELLO TODO HYBRID + * When splitting these MEM_REF's out we currently use the type of the + * offset rather than the type of the base pointer. If the base pointer and + * offset types differ in their capability nature then these types are not + * interchangeable. There is probably a way around this, but it's a simple + * and safe solution to avoid the optimisation in that case. */ + if (!types_compatible_p (type, TREE_TYPE (t1))) + return false; mult_op0 = TREE_OPERAND (offset, 0); c3 = wi::to_widest (TREE_OPERAND (offset, 1));