public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-8275] expansion: Fix ICEs with BLKmode VIEW_CONVERT_EXPR around non-BLKmode VAR_DECLs
@ 2024-01-19  8:36 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2024-01-19  8:36 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:56778b69ce558bb7e3ab7c561ee4ee48ac20263b

commit r14-8275-g56778b69ce558bb7e3ab7c561ee4ee48ac20263b
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Jan 19 09:31:42 2024 +0100

    expansion: Fix ICEs with BLKmode VIEW_CONVERT_EXPR around non-BLKmode VAR_DECLs
    
    On aarch64 the backend decides to use non-BLKmode for some arrays
    like unsigned long[4] - OImode in that case, but the corresponding
    BITINT_TYPEs have BLKmode (like structures containing that many limb
    elements).
    This later causes ICEs durring expansion when expanding VIEW_CONVERT_EXPR
    from non-BLKmode VAR_DECL to BLKmode BITINT_TYPE.
    
    The following fix contains two parts, the discover_nonconstant_array_refs_r
    is make sure we force such variables into memory and the expand_expr_real_1
    change makes sure we don't try to extract a bitfield or something similar
    which doesn't really work for BLKmode - as op0 is a MEM, all we need is
    the op0 = adjust_address (op0, mode, 0); at the end to change the MEM's mode
    to BLKmode.
    
    2024-01-19  Jakub Jelinek  <jakub@redhat.com>
                Richard Biener  <rguenther@suse.de>
    
            * cfgexpand.cc (discover_nonconstant_array_refs_r): Force non-BLKmode
            VAR_DECLs referenced in BLKmode VIEW_CONVERT_EXPRs into memory.
            * expr.cc (expand_expr_real_1) <case VIEW_CONVERT_EXPR>: Do nothing
            but adjust_address also for BLKmode mode and MEM op0.

Diff:
---
 gcc/cfgexpand.cc | 8 ++++++--
 gcc/expr.cc      | 4 ++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/gcc/cfgexpand.cc b/gcc/cfgexpand.cc
index 9ce01181ebc..767982a63a9 100644
--- a/gcc/cfgexpand.cc
+++ b/gcc/cfgexpand.cc
@@ -6380,11 +6380,15 @@ discover_nonconstant_array_refs_r (tree * tp, int *walk_subtrees,
   /* References of size POLY_INT_CST to a fixed-size object must go
      through memory.  It's more efficient to force that here than
      to create temporary slots on the fly.
-     RTL expansion expectes TARGET_MEM_REF to always address actual memory.  */
+     RTL expansion expectes TARGET_MEM_REF to always address actual memory.
+     Also, force to stack non-BLKmode vars accessed through VIEW_CONVERT_EXPR
+     to BLKmode type.  */
   else if (TREE_CODE (t) == TARGET_MEM_REF
 	   || (TREE_CODE (t) == MEM_REF
 	       && TYPE_SIZE (TREE_TYPE (t))
-	       && POLY_INT_CST_P (TYPE_SIZE (TREE_TYPE (t)))))
+	       && POLY_INT_CST_P (TYPE_SIZE (TREE_TYPE (t))))
+	   || (TREE_CODE (t) == VIEW_CONVERT_EXPR
+	       && TYPE_MODE (TREE_TYPE (t)) == BLKmode))
     {
       tree base = get_base_address (t);
       if (base
diff --git a/gcc/expr.cc b/gcc/expr.cc
index 34f5ff90a9f..3396edff1c9 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc
@@ -12389,6 +12389,10 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode,
       /* If the input and output modes are both the same, we are done.  */
       if (mode == GET_MODE (op0))
 	;
+      /* Similarly if the output mode is BLKmode and input is a MEM,
+	 adjust_address done below is all we need.  */
+      else if (mode == BLKmode && MEM_P (op0))
+	;
       /* If neither mode is BLKmode, and both modes are the same size
 	 then we can use gen_lowpart.  */
       else if (mode != BLKmode

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

only message in thread, other threads:[~2024-01-19  8:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-19  8:36 [gcc r14-8275] expansion: Fix ICEs with BLKmode VIEW_CONVERT_EXPR around non-BLKmode VAR_DECLs Jakub Jelinek

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).