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

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
OK, built a cross to x86_64-netbsd and I see we go from

Breakpoint 8, gimplify_addr_expr (expr_p=0x7ffff6cdec28, pre_p=0x7fffffffd8b0, 
    post_p=0x7fffffffcc40) at /space/rguenther/src/gcc/gcc/gimplify.c:6171
6171          ret = gimplify_expr (&TREE_OPERAND (expr, 0), pre_p, post_p,
(gdb) p debug_tree (expr)
 <addr_expr 0x7ffff6d050c0
    type <pointer_type 0x7ffff6ce23f0
        type <array_type 0x7ffff6ce2e70 type <record_type 0x7ffff6ce2c78 b>
            BLK
            align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff6ce2e70
            pointer_to_this <pointer_type 0x7ffff6ce23f0>>
        unsigned DI
        size <integer_cst 0x7ffff6bb7cd8 constant 64>
        unit-size <integer_cst 0x7ffff6bb7cf0 constant 8>
        align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff6ce23f0>

    arg:0 <var_decl 0x7ffff7fefbd0 f
        type <array_type 0x7ffff6ce2498 type <record_type 0x7ffff6ce2c78 b>
            sizes-gimplified BLK
            size <integer_cst 0x7ffff6bd53a8 constant 384>
            unit-size <integer_cst 0x7ffff6ce9d08 constant 48>
            align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff6ce2498 domain <integer_type 0x7ffff6ce2540>
            pointer_to_this <pointer_type 0x7ffff6ce25e8>>
        addressable used read BLK t.c:7:14 size <integer_cst 0x7ffff6bd53a8
384> unit-size <integer_cst 0x7ffff6ce9d08 48>
        align:64 warn_if_not_align:0 context <function_decl 0x7ffff6d03000 e>
        value-expr <indirect_ref 0x7ffff6d05160 type <array_type
0x7ffff6ce2498>
            nothrow arg:0 <var_decl 0x7ffff7fefc60 f.0>>>
    t.c:7:29 start: t.c:7:29 finish: t.c:7:29>

to

6178          prepare_gimple_addressable (&TREE_OPERAND (expr, 0), pre_p);
(gdb) p debug_tree (expr)
 <addr_expr 0x7ffff6d050c0
    type <pointer_type 0x7ffff6ce23f0
        type <array_type 0x7ffff6ce2e70 type <record_type 0x7ffff6ce2c78 b>
            BLK
            align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff6ce2e70
            pointer_to_this <pointer_type 0x7ffff6ce23f0>>
        unsigned DI
        size <integer_cst 0x7ffff6bb7cd8 constant 64>
        unit-size <integer_cst 0x7ffff6bb7cf0 constant 8>
        align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff6ce23f0>

    arg:0 <mem_ref 0x7ffff6cdec30
        type <array_type 0x7ffff6ce2498 type <record_type 0x7ffff6ce2c78 b>
            sizes-gimplified BLK
            size <integer_cst 0x7ffff6bd53a8 constant 384>
            unit-size <integer_cst 0x7ffff6ce9d08 constant 48>
            align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff6ce2498 domain <integer_type 0x7ffff6ce2540>
            pointer_to_this <pointer_type 0x7ffff6ce25e8>>
        nothrow
        arg:0 <var_decl 0x7ffff7fefc60 f.0 type <pointer_type 0x7ffff6ce25e8>
            used unsigned DI t.c:7:14 size <integer_cst 0x7ffff6bb7cd8 64>
unit-size <integer_cst 0x7ffff6bb7cf0 8>
            align:64 warn_if_not_align:0 context <function_decl 0x7ffff6d03000
e>>
        arg:1 <integer_cst 0x7ffff6ce9e28 constant 0>
        t.c:7:29 start: t.c:7:29 finish: t.c:7:29>
    t.c:7:29 start: t.c:7:29 finish: t.c:7:29>

via the DECL_VALUE_EXPR of 'f'.  Now we're basically the do_indirect_ref
case but via MEM_REF but we're only checking for INDIRECT_REF here.

The following fixes the cross compilation for me:

diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 787435c38cd..8cdfae26510 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -6181,7 +6181,9 @@ gimplify_addr_expr (tree *expr_p, gimple_seq *pre_p,
gimple_seq *post_p)

       /* For various reasons, the gimplification of the expression
         may have made a new INDIRECT_REF.  */
-      if (TREE_CODE (op0) == INDIRECT_REF)
+      if (TREE_CODE (op0) == INDIRECT_REF
+         || (TREE_CODE (op0) == MEM_REF
+             && integer_zerop (TREE_OPERAND (op0, 1))))
        goto do_indirect_ref;

       mark_addressable (TREE_OPERAND (expr, 0));

Reply via email to