]> gcc.gnu.org Git - gcc.git/commitdiff
Avoid trans-capability MEM_REF relaxation in SLSR
authorMatthew Malcomson <matthew.malcomson@arm.com>
Thu, 17 Mar 2022 15:49:47 +0000 (15:49 +0000)
committerMatthew Malcomson <matthew.malcomson@arm.com>
Thu, 5 May 2022 11:56:24 +0000 (12:56 +0100)
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.

gcc/gimple-ssa-strength-reduction.c

index 3b7e1994abb87a6198c553f253ec5a252ff6a148..45f58df40df69d6fb5365ed3b42a8a08a2ccedf5 100644 (file)
@@ -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));
This page took 0.062353 seconds and 5 git commands to generate.