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/112940] ICE: verify_ssa failed: definition in block 4 does not dominate use in block 8 at -O with _BitInt()
Date: Wed, 13 Dec 2023 10:47:03 +0000	[thread overview]
Message-ID: <bug-112940-4-Nq3C5nPpoX@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-112940-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #3 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:07efd5668537892e1c07264455bfd96f1a99a130

commit r14-6487-g07efd5668537892e1c07264455bfd96f1a99a130
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Dec 13 11:36:27 2023 +0100

    lower-bitint: Fix lowering of non-_BitInt to _BitInt cast merged with some
wider cast [PR112940]

    The following testcase ICEs, because a PHI argument from latch edge
    uses a SSA_NAME set only in a conditionally executed block inside of the
    loop.
    This happens when we have some outer cast which lowers its operand several
    times, under some condition with variable index, under different condition
    with some constant index, otherwise something else, and then there is
    an inner cast from non-_BitInt integer (or small/middle one).  Such cast
    in certain conditions is emitted by initializing some SSA_NAMEs in the
    initialization statements before loops (say for casts from <= limb size
    precision by computing a SSA_NAME for the first limb and then extension
    of it for the later limbs) and uses the prepare_data_in_out function
    to create a PHI node.  Such function is passed the value (constant or
    SSA_NAME) to use in the PHI argument from the pre-header edge, but for
    the latch edge it always created a new SSA_NAME and then caller emitted
    in the following 3 spots an extra assignment to set that SSA_NAME to
    whatever value we want from the latch edge.  In all these 3 cases
    the argument from the latch edge is known already before the loop though,
    either constant or SSA_NAME computed in pre-header as well.
    But the need to emit an assignment combined with the handle_operand done
    in a conditional basic block results in the SSA verification failure.

    The following patch fixes it by extending the prpare_data_in_out method,
    so that when the latch edge argument is known before (constant or computed
    in pre-header), we can just use it directly and avoid the extra assignment
    that would normally be hopefully optimized away later to what we now emit
    directly.

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

            PR tree-optimization/112940
            * gimple-lower-bitint.cc (struct bitint_large_huge): Add another
            argument to prepare_data_in_out method defaulted to NULL_TREE.
            (bitint_large_huge::handle_operand): Pass another argument to
            prepare_data_in_out instead of emitting an assignment to set it.
            (bitint_large_huge::prepare_data_in_out): Add VAL_OUT argument.
            If non-NULL, use it as PHI argument instead of creating a new
            SSA_NAME.
            (bitint_large_huge::handle_cast): Pass rext as another argument
            to 2 prepare_data_in_out calls instead of emitting assignments
            to set them.

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

  parent reply	other threads:[~2023-12-13 10:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-09 14:22 [Bug tree-optimization/112940] New: " zsojka at seznam dot cz
2023-12-09 23:36 ` [Bug tree-optimization/112940] " pinskia at gcc dot gnu.org
2023-12-12 17:58 ` jakub at gcc dot gnu.org
2023-12-13 10:47 ` cvs-commit at gcc dot gnu.org [this message]
2023-12-13 11:10 ` jakub 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-112940-4-Nq3C5nPpoX@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).