public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ARM/heads/morello)] Avoid trans-capability MEM_REF relaxation in SLSR
@ 2022-05-05 12:04 Matthew Malcomson
  0 siblings, 0 replies; only message in thread
From: Matthew Malcomson @ 2022-05-05 12:04 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:730d6010d4773bba7255a5cd845c9d48826c4074

commit 730d6010d4773bba7255a5cd845c9d48826c4074
Author: Matthew Malcomson <matthew.malcomson@arm.com>
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));


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-05 12:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-05 12:04 [gcc(refs/vendors/ARM/heads/morello)] Avoid trans-capability MEM_REF relaxation in SLSR Matthew Malcomson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).