public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/113602] New: ICE: in vn_reference_maybe_forwprop_address, at tree-ssa-sccvn.cc:1426 with invalid _BitInt() register asm with -O2 -fno-tree-loop-optimize
@ 2024-01-25 18:15 zsojka at seznam dot cz
  2024-01-25 22:25 ` [Bug tree-optimization/113602] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: zsojka at seznam dot cz @ 2024-01-25 18:15 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113602
           Summary: ICE: in vn_reference_maybe_forwprop_address, at
                    tree-ssa-sccvn.cc:1426 with invalid _BitInt() register
                    asm with -O2 -fno-tree-loop-optimize
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zsojka at seznam dot cz
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu
            Target: x86_64-pc-linux-gnu

Created attachment 57216
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57216&action=edit
reduced testcase (from gcc.dg/torture/pr60606-1.c)

Compiler output:
$ x86_64-pc-linux-gnu-gcc -O2 -fno-tree-loop-optimize testcase.c 
during GIMPLE pass: fre
testcase.c: In function 'f':
testcase.c:2:1: internal compiler error: in
vn_reference_maybe_forwprop_address, at tree-ssa-sccvn.cc:1426
    2 | f(void) {
      | ^
0x875c2c vn_reference_maybe_forwprop_address
        /repo/gcc-trunk/gcc/tree-ssa-sccvn.cc:1426
0x17176d8 valueize_refs_1
        /repo/gcc-trunk/gcc/tree-ssa-sccvn.cc:1718
0x171c008 valueize_shared_reference_ops_from_ref
        /repo/gcc-trunk/gcc/tree-ssa-sccvn.cc:1763
0x171c008 valueize_shared_reference_ops_from_ref
        /repo/gcc-trunk/gcc/tree-ssa-sccvn.cc:1757
0x171c008 vn_reference_lookup(tree_node*, tree_node*, vn_lookup_kind,
vn_reference_s**, bool, tree_node**, tree_node*, bool)
        /repo/gcc-trunk/gcc/tree-ssa-sccvn.cc:3963
0x1720437 visit_reference_op_load
        /repo/gcc-trunk/gcc/tree-ssa-sccvn.cc:5752
0x1720437 visit_stmt
        /repo/gcc-trunk/gcc/tree-ssa-sccvn.cc:6273
0x1720abb process_bb
        /repo/gcc-trunk/gcc/tree-ssa-sccvn.cc:8037
0x1722496 do_rpo_vn_1
        /repo/gcc-trunk/gcc/tree-ssa-sccvn.cc:8638
0x172400b execute
        /repo/gcc-trunk/gcc/tree-ssa-sccvn.cc:8799
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

$ x86_64-pc-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=/repo/gcc-trunk/binary-latest-amd64/bin/x86_64-pc-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-r14-8419-20240125172014-gc6c2a1d79eb-checking-yes-rtl-df-extra-nobootstrap-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++
--enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra
--disable-bootstrap --with-cloog --with-ppl --with-isl
--build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu
--target=x86_64-pc-linux-gnu --with-ld=/usr/bin/x86_64-pc-linux-gnu-ld
--with-as=/usr/bin/x86_64-pc-linux-gnu-as --disable-libstdcxx-pch
--prefix=/repo/gcc-trunk//binary-trunk-r14-8419-20240125172014-gc6c2a1d79eb-checking-yes-rtl-df-extra-nobootstrap-amd64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.0.1 20240125 (experimental) (GCC)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/113602] ICE: in vn_reference_maybe_forwprop_address, at tree-ssa-sccvn.cc:1426 with invalid _BitInt() register asm with -O2 -fno-tree-loop-optimize
  2024-01-25 18:15 [Bug tree-optimization/113602] New: ICE: in vn_reference_maybe_forwprop_address, at tree-ssa-sccvn.cc:1426 with invalid _BitInt() register asm with -O2 -fno-tree-loop-optimize zsojka at seznam dot cz
@ 2024-01-25 22:25 ` pinskia at gcc dot gnu.org
  2024-01-26  8:26 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-25 22:25 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-01-25

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/113602] ICE: in vn_reference_maybe_forwprop_address, at tree-ssa-sccvn.cc:1426 with invalid _BitInt() register asm with -O2 -fno-tree-loop-optimize
  2024-01-25 18:15 [Bug tree-optimization/113602] New: ICE: in vn_reference_maybe_forwprop_address, at tree-ssa-sccvn.cc:1426 with invalid _BitInt() register asm with -O2 -fno-tree-loop-optimize zsojka at seznam dot cz
  2024-01-25 22:25 ` [Bug tree-optimization/113602] " pinskia at gcc dot gnu.org
@ 2024-01-26  8:26 ` rguenth at gcc dot gnu.org
  2024-01-26 10:25 ` cvs-commit at gcc dot gnu.org
  2024-01-26 10:25 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-01-26  8:26 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
(gdb) p tem.last ()
$2 = (vn_reference_op_struct &) @0x7fffffffc820: {opcode = VAR_DECL, 
  clique = 0, base = 0, reverse = 0, align = 0, off = {coeffs = {-1}}, 
  type = <bitint_type 0x7ffff6bb9690>, op0 = <var_decl 0x7ffff6a19c60 r>, 
  op1 = <tree 0x0>, op2 = <tree 0x0>}
(gdb) p debug_vn_reference_ops (tem)
{array_ref<_4,0,1>,view_convert_expr,r}
(gdb) p debug_generic_expr (addr)
&VIEW_CONVERT_EXPR<unsigned long[8]>(r)[_4]

We're valueizing

MEM <vector(2) unsigned long> [(_BitInt(503) *)vectp.5_18]

trying to forward the vectp.5_18 def

vectp.5_18 = &VIEW_CONVERT_EXPR<unsigned long[8]>(r)[_4];

but we're not anticipating this shape of a non-invariant ADDR_EXPR.  We
do wrap all VAR_DECLs but DECL_HARD_REGISTER inside a MEM_REF but then
a DECL_HARD_REGISTER shouldn't be addressable so the IL is actually
invalid, generated by vectorization (but not diagnosed by IL checking).

I'm not sure to what extent we should try to paper over this though ...

The following works for me:

diff --git a/gcc/tree-data-ref.cc b/gcc/tree-data-ref.cc
index ae55bf6aa48..f37734b5340 100644
--- a/gcc/tree-data-ref.cc
+++ b/gcc/tree-data-ref.cc
@@ -1182,7 +1182,12 @@ dr_analyze_innermost (innermost_loop_behavior *drb, tree
ref,
       base = TREE_OPERAND (base, 0);
     }
   else
-    base = build_fold_addr_expr (base);
+    {
+      if (may_be_nonaddressable_p (base))
+       return opt_result::failure_at (stmt,
+                                      "failed: base not addressable.\n");
+      base = build_fold_addr_expr (base);
+    }

   if (in_loop)
     {

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/113602] ICE: in vn_reference_maybe_forwprop_address, at tree-ssa-sccvn.cc:1426 with invalid _BitInt() register asm with -O2 -fno-tree-loop-optimize
  2024-01-25 18:15 [Bug tree-optimization/113602] New: ICE: in vn_reference_maybe_forwprop_address, at tree-ssa-sccvn.cc:1426 with invalid _BitInt() register asm with -O2 -fno-tree-loop-optimize zsojka at seznam dot cz
  2024-01-25 22:25 ` [Bug tree-optimization/113602] " pinskia at gcc dot gnu.org
  2024-01-26  8:26 ` rguenth at gcc dot gnu.org
@ 2024-01-26 10:25 ` cvs-commit at gcc dot gnu.org
  2024-01-26 10:25 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-26 10:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:f9b143d239db775318a29e9ff63f232b9501a22a

commit r14-8450-gf9b143d239db775318a29e9ff63f232b9501a22a
Author: Richard Biener <rguenther@suse.de>
Date:   Fri Jan 26 09:29:22 2024 +0100

    tree-optimization/113602 - datarefs of non-addressables

    We can end up creating ADDR_EXPRs of non-addressable entities during
    for example vectorization.  The following plugs this in data-ref
    analysis when that would create such invalid ADDR_EXPR as part of
    analyzing the ref structure.

            PR tree-optimization/113602
            * tree-data-ref.cc (dr_analyze_innermost): Fail when
            the base object isn't addressable.

            * gcc.dg/pr113602.c: New testcase.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/113602] ICE: in vn_reference_maybe_forwprop_address, at tree-ssa-sccvn.cc:1426 with invalid _BitInt() register asm with -O2 -fno-tree-loop-optimize
  2024-01-25 18:15 [Bug tree-optimization/113602] New: ICE: in vn_reference_maybe_forwprop_address, at tree-ssa-sccvn.cc:1426 with invalid _BitInt() register asm with -O2 -fno-tree-loop-optimize zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2024-01-26 10:25 ` cvs-commit at gcc dot gnu.org
@ 2024-01-26 10:25 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-01-26 10:25 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-01-26 10:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-25 18:15 [Bug tree-optimization/113602] New: ICE: in vn_reference_maybe_forwprop_address, at tree-ssa-sccvn.cc:1426 with invalid _BitInt() register asm with -O2 -fno-tree-loop-optimize zsojka at seznam dot cz
2024-01-25 22:25 ` [Bug tree-optimization/113602] " pinskia at gcc dot gnu.org
2024-01-26  8:26 ` rguenth at gcc dot gnu.org
2024-01-26 10:25 ` cvs-commit at gcc dot gnu.org
2024-01-26 10:25 ` rguenth at gcc dot gnu.org

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