https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88587

--- Comment #11 from Richard Biener <rguenth at gcc dot gnu.org> ---
Yes, it depends on the supported ISAs.  In essential the issue is that
TYPE_MODE
depends on the (function) context it is used, that's even true for globals
(IIRC there are existing bugs with respect to that).

For your always-inline testcase we override the target attribute conflict
and run into the same issue that the inliner copying is remapping the decl
(but not for debug-decls!).

So for example

# DEBUG b => { 0, 0, 0, 0 }

has BLKmode decl but V4SImode type.

The issue here can possibly befixed (for debug insns) by fixing up the
(debug bind) decl during expansion.  Or having it fixed up (aka copied)
during inlining. Given that

(debug_insn 7 6 8 2 (var_location:BLK b (return:CC)) "t.c":2:61 -1
     (nil))

is going to be useless anyways (because of :BLK).

The following fixes the always-inline case but not the MV one:

Index: gcc/tree-inline.c
===================================================================
--- gcc/tree-inline.c   (revision 267930)
+++ gcc/tree-inline.c   (working copy)
@@ -5479,6 +5479,10 @@ copy_decl_for_dup_finish (copy_body_data
   if (CODE_CONTAINS_STRUCT (TREE_CODE (copy), TS_DECL_WRTL)
       && !TREE_STATIC (copy) && !DECL_EXTERNAL (copy))
     SET_DECL_RTL (copy, 0);
+  /* For vector typed decls make sure to update DECL_MODE according
+     to the new function context.  */
+  if (VECTOR_TYPE_P (TREE_TYPE (copy)))
+    SET_DECL_MODE (copy, TYPE_MODE (TREE_TYPE (copy)));

   /* These args would always appear unused, if not for this.  */
   TREE_USED (copy) = 1;


The following helps tracking down affected stmts:

Index: gcc/tree-cfg.c
===================================================================
--- gcc/tree-cfg.c      (revision 267930)
+++ gcc/tree-cfg.c      (working copy)
@@ -5108,6 +5108,17 @@ verify_node_sharing_1 (tree *tp, int *wa
 {
   hash_set<void *> *visited = (hash_set<void *> *) data;

+  if (DECL_P (*tp)
+      && VECTOR_TYPE_P (TREE_TYPE (*tp))
+      && DECL_MODE (*tp) != TYPE_MODE (TREE_TYPE (*tp)))
+    {
+      fprintf (stderr, "DECL_MODE %s vs TYPE_MODE %s [%s]: ",
+              mode_name[DECL_MODE (*tp)],
+              mode_name[TYPE_MODE (TREE_TYPE (*tp))],
+              mode_name[TYPE_MODE_RAW (TREE_TYPE (*tp))]);
+      print_generic_expr (stderr, *tp);
+      fprintf (stderr, "\n");
+    }
   if (tree_node_can_be_shared (*tp))
     {
       *walk_subtrees = false;

Reply via email to