public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/112941] during GIMPLE pass: bitintlower ICE: in handle_operand_addr, at gimple-lower-bitint.cc:2126 (gimple-lower-bitint.cc:2134) at -O with _BitInt()
Date: Wed, 20 Dec 2023 10:34:19 +0000	[thread overview]
Message-ID: <bug-112941-4-13F4HIA8hE@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-112941-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #7 from GCC 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:be9e8de628471399ee5abb1e6ba7738139256b67

commit r14-6742-gbe9e8de628471399ee5abb1e6ba7738139256b67
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Dec 20 11:32:52 2023 +0100

    lower-bitint: Fix up handling of nested casts in mergeable stmt handling
[PR112941]

    The following patch fixes 2 issues in handling of casts for mergeable
    stmts.
    The first hunk fixes the case when we have two nested casts (typically
    after optimization that is zero-extension of a sign-extension because
    everything else should have been folded into a single cast).  If
    the lowering of the outer cast needs to make the code conditional
    (e.g.
      for (...)
        {
          if (idx <= 32)
            {
              if (idx < 32)
                { ... handle_operand (idx); ... }
              else
                { ... handle_operand (32); ... }
            }
          ...
        }
    ) and the lowering of the inner one as well, right now it creates invalid
    SSA form, because even for the inner cast we need a PHI on the loop
    and the PHI argument from the latch edge is a SSA_NAME initialized in
    the conditionally executed bb.  The hunk fixes that by detecting such
    a case and adding further PHI nodes at the end of the ifs such that
    the right value propagates to the next loop iteration.  We can use
    0 arguments for the other edges because the inner operand handling
    is only done for the first set of iterations and then the other ifs take
    over.

    The rest fixes a case of again invalid SSA form, when for a sign extension
    we need to use the 0 or -1 value initialized by earlier iteration in
    a constant idx case, the code was using the value of the loop PHI argument
    from latch edge rather than result; that is correct for cases expanded
    in straight line code after the loop, but not inside of the loop for the
    cases of handle_cast conditionals, there we should use PHI result.  This
    is done in the second hunk and supported by the remaining hunks, where
    it clears m_bb to tell the code we aren't in the loop anymore.

    Note, this patch doesn't deal with similar problems during multiplication,
    division, floating casts etc. where we just emit a library call.  I'll
    need to make sure in that case we don't merge more than one cast per
    operand.

    2023-12-20  Jakub Jelinek  <jakub@redhat.com>

            PR tree-optimization/112941
            * gimple-lower-bitint.cc (bitint_large_huge::handle_cast): If
            save_cast_conditional, instead of adding assignment of t4 to
            m_data[save_data_cnt + 1] before m_gsi, add phi nodes such that
            t4 propagates to m_bb loop.  For constant idx, use
            m_data[save_data_cnt] rather than m_data[save_data_cnt + 1] if
inside
            of the m_bb loop.
            (bitint_large_huge::lower_mergeable_stmt): Clear m_bb when no
longer
            expanding inside of that loop.
            (bitint_large_huge::lower_comparison_stmt): Likewise.
            (bitint_large_huge::lower_addsub_overflow): Likewise.
            (bitint_large_huge::lower_mul_overflow): Likewise.
            (bitint_large_huge::lower_bit_query): Likewise.

            * gcc.dg/bitint-55.c: New test.

  parent reply	other threads:[~2023-12-20 10:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-09 14:26 [Bug tree-optimization/112941] New: " zsojka at seznam dot cz
2023-12-09 23:39 ` [Bug tree-optimization/112941] " pinskia at gcc dot gnu.org
2023-12-13 20:03 ` zsojka at seznam dot cz
2023-12-14 15:41 ` jakub at gcc dot gnu.org
2023-12-15 10:19 ` jakub at gcc dot gnu.org
2023-12-15 11:07 ` jakub at gcc dot gnu.org
2023-12-15 12:33 ` jakub at gcc dot gnu.org
2023-12-20 10:34 ` cvs-commit at gcc dot gnu.org [this message]
2023-12-20 13:20 ` jakub at gcc dot gnu.org
2023-12-20 14:42 ` jakub at gcc dot gnu.org
2023-12-21 10:14 ` cvs-commit at gcc dot gnu.org
2023-12-21 16:50 ` jakub at gcc dot gnu.org
2023-12-22 11:30 ` cvs-commit at gcc dot gnu.org
2024-01-03  9:17 ` jakub at gcc dot gnu.org
2024-01-20 17:11 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-112941-4-13F4HIA8hE@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).