public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/109258] New: [13 Regression] go.test/test/fixedbugs/bug207.go ICEs
@ 2023-03-23  5:52 pinskia at gcc dot gnu.org
  2023-03-23  5:52 ` [Bug middle-end/109258] " pinskia at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-03-23  5:52 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109258
           Summary: [13 Regression] go.test/test/fixedbugs/bug207.go ICEs
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code, testsuite-fail
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---
            Target: x86_64-linux-gnu

FAIL: go.test/test/fixedbugs/bug207.go,  -O2 -g  (internal compiler error: in
emit_move_insn, at expr.cc:4224)

Started after r13-6667-g1526ecd739f and at or before r13-6696-gcd394c542b7 .

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

* [Bug middle-end/109258] [13 Regression] go.test/test/fixedbugs/bug207.go ICEs
  2023-03-23  5:52 [Bug middle-end/109258] New: [13 Regression] go.test/test/fixedbugs/bug207.go ICEs pinskia at gcc dot gnu.org
@ 2023-03-23  5:52 ` pinskia at gcc dot gnu.org
  2023-03-23  9:01 ` rguenth at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-03-23  5:52 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.0

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

* [Bug middle-end/109258] [13 Regression] go.test/test/fixedbugs/bug207.go ICEs
  2023-03-23  5:52 [Bug middle-end/109258] New: [13 Regression] go.test/test/fixedbugs/bug207.go ICEs pinskia at gcc dot gnu.org
  2023-03-23  5:52 ` [Bug middle-end/109258] " pinskia at gcc dot gnu.org
@ 2023-03-23  9:01 ` rguenth at gcc dot gnu.org
  2023-03-23  9:35 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-03-23  9:01 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2023-03-23
     Ever confirmed|0                           |1
           Keywords|                            |needs-bisection

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed, I also saw this in recent testing.

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

* [Bug middle-end/109258] [13 Regression] go.test/test/fixedbugs/bug207.go ICEs
  2023-03-23  5:52 [Bug middle-end/109258] New: [13 Regression] go.test/test/fixedbugs/bug207.go ICEs pinskia at gcc dot gnu.org
  2023-03-23  5:52 ` [Bug middle-end/109258] " pinskia at gcc dot gnu.org
  2023-03-23  9:01 ` rguenth at gcc dot gnu.org
@ 2023-03-23  9:35 ` jakub at gcc dot gnu.org
  2023-03-23 10:06 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-03-23  9:35 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I can confirm a range between March 14th and 16th in my logs, but am not
prepared to bisect go.

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

* [Bug middle-end/109258] [13 Regression] go.test/test/fixedbugs/bug207.go ICEs
  2023-03-23  5:52 [Bug middle-end/109258] New: [13 Regression] go.test/test/fixedbugs/bug207.go ICEs pinskia at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-03-23  9:35 ` jakub at gcc dot gnu.org
@ 2023-03-23 10:06 ` jakub at gcc dot gnu.org
  2023-03-23 10:10 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-03-23 10:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I'm pretty sure it is r13-6690-g45641f3a99281bb0a4296 because that's where the
ICE is.

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

* [Bug middle-end/109258] [13 Regression] go.test/test/fixedbugs/bug207.go ICEs
  2023-03-23  5:52 [Bug middle-end/109258] New: [13 Regression] go.test/test/fixedbugs/bug207.go ICEs pinskia at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-03-23 10:06 ` jakub at gcc dot gnu.org
@ 2023-03-23 10:10 ` jakub at gcc dot gnu.org
  2023-03-23 10:21 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-03-23 10:10 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|needs-bisection             |

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
One possible fix is
2023-03-23  Jakub Jelinek  <jakub@redhat.com>

        PR middle-end/109258
        * builtins.cc (inline_expand_builtin_bytecmp): Return NULL_RTX early
        if target == const0_rtx.

--- gcc/builtins.cc.jj  2023-03-23 10:00:58.308100548 +0100
+++ gcc/builtins.cc     2023-03-23 11:05:38.308135309 +0100
@@ -7178,8 +7178,8 @@ inline_expand_builtin_bytecmp (tree exp,
   bool is_ncmp = (fcode == BUILT_IN_STRNCMP || fcode == BUILT_IN_MEMCMP);

   /* Do NOT apply this inlining expansion when optimizing for size or
-     optimization level below 2.  */
-  if (optimize < 2 || optimize_insn_for_size_p ())
+     optimization level below 2 or if unused *cmp hasn't been DCEd.  */
+  if (optimize < 2 || optimize_insn_for_size_p () || target == const0_rtx)
     return NULL_RTX;

   gcc_checking_assert (fcode == BUILT_IN_STRCMP

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

* [Bug middle-end/109258] [13 Regression] go.test/test/fixedbugs/bug207.go ICEs
  2023-03-23  5:52 [Bug middle-end/109258] New: [13 Regression] go.test/test/fixedbugs/bug207.go ICEs pinskia at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2023-03-23 10:10 ` jakub at gcc dot gnu.org
@ 2023-03-23 10:21 ` jakub at gcc dot gnu.org
  2023-03-23 10:21 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-03-23 10:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Or we could fix the go FE to make memcmp properly pure:
2023-03-23  Jakub Jelinek  <jakub@redhat.com>

        PR middle-end/109258
        * go-gcc.cc (Gcc_backend): Add new static data member builtin_pure.
        (Gcc_backend::Gcc_backend): Pass builtin_pure for BUILT_IN_MEMCMP.
        (Gcc_backend::define_builtin): Handle builtin_pure in flags.

--- gcc/go/go-gcc.cc.jj 2023-01-18 12:22:10.396234744 +0100
+++ gcc/go/go-gcc.cc    2023-03-23 11:16:08.958054518 +0100
@@ -543,6 +543,7 @@ private:
   static const int builtin_const = 1 << 0;
   static const int builtin_noreturn = 1 << 1;
   static const int builtin_novops = 1 << 2;
+  static const int builtin_pure = 1 << 3;

   void
   define_builtin(built_in_function bcode, const char* name, const char*
libname,
@@ -601,7 +602,7 @@ Gcc_backend::Gcc_backend()
                                                const_ptr_type_node,
                                                size_type_node,
                                                NULL_TREE),
-                      0);
+                      builtin_pure);

   // We use __builtin_memmove for copying data.
   this->define_builtin(BUILT_IN_MEMMOVE, "__builtin_memmove", "memmove",
@@ -3596,6 +3597,8 @@ Gcc_backend::define_builtin(built_in_fun
                                   libname, NULL_TREE);
   if ((flags & builtin_const) != 0)
     TREE_READONLY(decl) = 1;
+  if ((flags & builtin_pure) != 0)
+    DECL_PURE_P(decl) = 1;
   if ((flags & builtin_noreturn) != 0)
     TREE_THIS_VOLATILE(decl) = 1;
   if ((flags & builtin_novops) != 0)
@@ -3608,6 +3611,8 @@ Gcc_backend::define_builtin(built_in_fun
                                  NULL, NULL_TREE);
       if ((flags & builtin_const) != 0)
        TREE_READONLY(decl) = 1;
+      if ((flags & builtin_pure) != 0)
+       DECL_PURE_P(decl) = 1;
       if ((flags & builtin_noreturn) != 0)
        TREE_THIS_VOLATILE(decl) = 1;
       if ((flags & builtin_novops) != 0)

Or both.

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

* [Bug middle-end/109258] [13 Regression] go.test/test/fixedbugs/bug207.go ICEs
  2023-03-23  5:52 [Bug middle-end/109258] New: [13 Regression] go.test/test/fixedbugs/bug207.go ICEs pinskia at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2023-03-23 10:21 ` jakub at gcc dot gnu.org
@ 2023-03-23 10:21 ` jakub at gcc dot gnu.org
  2023-03-24  9:40 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-03-23 10:21 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

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

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

* [Bug middle-end/109258] [13 Regression] go.test/test/fixedbugs/bug207.go ICEs
  2023-03-23  5:52 [Bug middle-end/109258] New: [13 Regression] go.test/test/fixedbugs/bug207.go ICEs pinskia at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2023-03-23 10:21 ` jakub at gcc dot gnu.org
@ 2023-03-24  9:40 ` cvs-commit at gcc dot gnu.org
  2023-03-24 12:33 ` jakub at gcc dot gnu.org
  2023-03-24 22:02 ` cvs-commit at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-24  9:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:5450833e4f9993f81ac16cbbcf4e46881a519f85

commit r13-6847-g5450833e4f9993f81ac16cbbcf4e46881a519f85
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Mar 24 10:38:42 2023 +0100

    builtins: Fix up ICE in inline_string_cmp [PR109258]

    The PR109086 r13-6690 inline_string_cmp change to
          if (diff != result)
            emit_move_insn (result, diff);
    regressed
    FAIL: go.test/test/fixedbugs/bug207.go,  -O2 -g  (internal compiler error:
in emit_move_insn, at expr.cc:4224)
    The problem is the Go FE doesn't mark __builtin_memcmp as pure (I'll also
    send patch for that) and so result is const0_rtx when the call lost its lhs
    and the above move ICEs because moving something into const0_rtx is
obviously
    invalid.
    I think it is better not to rely on all FEs having these *cmp functions
    pure anD DCE being performed.  The following patch just punts from the
    inline expansion in that case, so we just emit normal library call.

    2023-03-24  Jakub Jelinek  <jakub@redhat.com>

            PR middle-end/109258
            * builtins.cc (inline_expand_builtin_bytecmp): Return NULL_RTX
early
            if target == const0_rtx.

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

* [Bug middle-end/109258] [13 Regression] go.test/test/fixedbugs/bug207.go ICEs
  2023-03-23  5:52 [Bug middle-end/109258] New: [13 Regression] go.test/test/fixedbugs/bug207.go ICEs pinskia at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2023-03-24  9:40 ` cvs-commit at gcc dot gnu.org
@ 2023-03-24 12:33 ` jakub at gcc dot gnu.org
  2023-03-24 22:02 ` cvs-commit at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-03-24 12:33 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

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

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed now (though still would like to fix the Go FE too).

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

* [Bug middle-end/109258] [13 Regression] go.test/test/fixedbugs/bug207.go ICEs
  2023-03-23  5:52 [Bug middle-end/109258] New: [13 Regression] go.test/test/fixedbugs/bug207.go ICEs pinskia at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2023-03-24 12:33 ` jakub at gcc dot gnu.org
@ 2023-03-24 22:02 ` cvs-commit at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-24 22:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:0849a188d539d78101a32deea63db4cb39fb55ac

commit r13-6858-g0849a188d539d78101a32deea63db4cb39fb55ac
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Mar 24 23:02:08 2023 +0100

    go: Fix up go.test/test/fixedbugs/bug207.go failure [PR109258]

    The PR109086 r13-6690 inline_string_cmp change to
          if (diff != result)
            emit_move_insn (result, diff);
    regressed
    FAIL: go.test/test/fixedbugs/bug207.go,  -O2 -g  (internal compiler error:
in emit_move_insn, at expr.cc:4224)
    The problem is the Go FE doesn't mark __builtin_memcmp as pure as other
FEs,
    so we ended up with
      __builtin_memcmp (whatever, whateverelse, somesize);
    in the IL before expansion and the expansion ICEd on it.
    As the builtin calls a library function which is pure or is inline expanded
    as such, not marking it pure is an unnecessary pessimization from the FE
    side, keeping such dead calls in the IL if they aren't needed will not help
    anything.

    The following patch fixes that.  Initially I've added just DECL_PURE_P to
    it, but that unfortunately broke bootstrap, for __builtin_memcmp there is
    also __builtin_memcmp_eq registered by the middle-end code if not
registered
    earlier and that one is registered with the usual flags (pure, nothrow,
    leaf), so if __builtin_memcmp from FE was just pure, it would appear in the
    IL as that it can raise exceptions and when folded into __builtin_memcmp_eq
    all of sudden it couldn't and we'd ICE in verification.

    I think tons of functions should have builtin_nothrow as well, but changing
    that wasn't necessary for this fix.

    2023-03-24  Jakub Jelinek  <jakub@redhat.com>

            PR middle-end/109258
            * go-gcc.cc (Gcc_backend): Add new static data members builtin_pure
            and builtin_nothrow.
            (Gcc_backend::Gcc_backend): Pass builtin_pure | builtin_nothrow for
            BUILT_IN_MEMCMP.
            (Gcc_backend::define_builtin): Handle builtin_pure and
builtin_nothrow
            in flags.

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

end of thread, other threads:[~2023-03-24 22:02 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-23  5:52 [Bug middle-end/109258] New: [13 Regression] go.test/test/fixedbugs/bug207.go ICEs pinskia at gcc dot gnu.org
2023-03-23  5:52 ` [Bug middle-end/109258] " pinskia at gcc dot gnu.org
2023-03-23  9:01 ` rguenth at gcc dot gnu.org
2023-03-23  9:35 ` jakub at gcc dot gnu.org
2023-03-23 10:06 ` jakub at gcc dot gnu.org
2023-03-23 10:10 ` jakub at gcc dot gnu.org
2023-03-23 10:21 ` jakub at gcc dot gnu.org
2023-03-23 10:21 ` jakub at gcc dot gnu.org
2023-03-24  9:40 ` cvs-commit at gcc dot gnu.org
2023-03-24 12:33 ` jakub at gcc dot gnu.org
2023-03-24 22:02 ` cvs-commit 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).