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 middle-end/111369] [14 Regression] ICE in handle_cast, gimple-lower-bitint.cc:1486 with -Os
Date: Wed, 04 Oct 2023 07:32:50 +0000	[thread overview]
Message-ID: <bug-111369-4-QSqlMcHcHj@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-111369-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 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:64eeec25f11e31bed844ef0a95ef0f9661c3ab37

commit r14-4392-g64eeec25f11e31bed844ef0a95ef0f9661c3ab37
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Oct 4 09:30:15 2023 +0200

    match.pd: Avoid other build_nonstandard_integer_type calls [PR111369]

    In the light of the PR111668 patch which shows that
    build_nonstandard_integer_type is needed (at least for some signed prec > 1
    BOOLEAN_TYPEs if we use e.g. negation), I've reworked this patch and
handled
    the last problematic build_nonstandard_integer_type call in there as well.

    In the x == cstN ? cst4 : cst3 optimization it uses
    build_nonstandard_integer_type solely for BOOLEAN_TYPEs (I really don't see
    why ENUMERAL_TYPEs would be a problem, we treat them in GIMPLE as uselessly
    convertible to same precision/sign INTEGER_TYPEs), for INTEGER_TYPEs it is
    really a no-op (might return a different type, but always INTEGER_TYPE
    with same TYPE_PRECISION same TYPE_UNSIGNED) and for BITINT_TYPE with
larger
    precisions really harmful (we shouldn't create large precision
    INTEGER_TYPEs).

    The a?~t:t optimization just omits the negation of a in type for 1-bit
    precision types or any BOOLEAN_TYPEs.  I think that is correct, because
    for both signed and unsigned 1-bit precision type, cast to type of a bool
    value yields already 0, -1 or 0, 1 values and for 1-bit precision negation
    of that is still 0, -1 or 0, 1 (except for invoking sometimes UB).
    And for signed larger precision BOOLEAN_TYPEs I think it is correct as
well,
    cast of [0, 1] to type yields 0, -1 and those can be xored with 0 or -1
    to yield the proper result, any other values would be UB.

    This fixes PR111369, where one of the bitint*.c tests FAILs with
    GCC_TEST_RUN_EXPENSIVE=1.

    2023-10-04  Jakub Jelinek  <jakub@redhat.com>

            PR middle-end/111369
            * match.pd (x == cstN ? cst4 : cst3): Use
            build_nonstandard_integer_type only if type1 is BOOLEAN_TYPE.
            Fix comment typo.  Formatting fix.
            (a?~t:t -> (-(a))^t): Always convert to type rather
            than using build_nonstandard_integer_type.  Perform negation
            only if type has precision > 1 and is not signed BOOLEAN_TYPE.

  parent reply	other threads:[~2023-10-04  7:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-11 13:14 [Bug middle-end/111369] New: " fkastl at suse dot cz
2023-09-11 13:16 ` [Bug middle-end/111369] " jakub at gcc dot gnu.org
2023-09-11 13:17 ` [Bug middle-end/111369] [14 Regression] " jakub at gcc dot gnu.org
2023-10-04  7:32 ` cvs-commit at gcc dot gnu.org [this message]
2023-10-04  7:34 ` 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-111369-4-QSqlMcHcHj@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).