public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/111369] New: ICE in handle_cast, gimple-lower-bitint.cc:1486 with -Os
@ 2023-09-11 13:14 fkastl at suse dot cz
  2023-09-11 13:16 ` [Bug middle-end/111369] " jakub at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: fkastl at suse dot cz @ 2023-09-11 13:14 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111369
           Summary: ICE in handle_cast, gimple-lower-bitint.cc:1486 with
                    -Os
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fkastl at suse dot cz
                CC: jakub at redhat dot com, mjambor at suse dot cz
  Target Milestone: ---
              Host: x86_64-linux
            Target: x86_64-linux

Compiling gcc/testsuite/gcc.dg/torture/bitint-42.c with -Os produces this
error:

../gcc/gcc/testsuite/gcc.dg/torture/bitint-42.c: In function ‘main’:
../gcc/gcc/testsuite/gcc.dg/torture/bitint-42.c:50:1: internal compiler error:
in handle_cast, at gimple-lower-bitint.cc:1486
   50 | main ()
      | ^~~~
0x8cfc31 handle_cast
        ../../gcc/gcc/gimple-lower-bitint.cc:1486
0x1daafe8 handle_operand
        ../../gcc/gcc/gimple-lower-bitint.cc:791
0x1db31f0 lower_mergeable_stmt
        ../../gcc/gcc/gimple-lower-bitint.cc:2386
0x1db4c5d lower_stmt
        ../../gcc/gcc/gimple-lower-bitint.cc:4687
0x1db68fd gimple_lower_bitint
        ../../gcc/gcc/gimple-lower-bitint.cc:5767
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.

An assert fails at the line 1486:

1478   else if (TREE_CODE (lhs_type) == BITINT_TYPE    
1479            && bitint_precision_kind (lhs_type) >= bitint_prec_large
1480            && INTEGRAL_TYPE_P (rhs_type))
1481     {
1482       /* Add support for 3 or more limbs filled in from normal integral
1483          type if this assert fails.  If no target chooses limb mode
smaller
1484          than half of largest supported normal integral type, this will
not
1485          be needed.  */
1486       gcc_assert (TYPE_PRECISION (rhs_type) <= 2 * limb_prec);
1487       tree r1 = NULL_TREE, r2 = NULL_TREE, rext = NULL_TREE;
1488       if (m_first)   
1489         {

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

* [Bug middle-end/111369] ICE in handle_cast, gimple-lower-bitint.cc:1486 with -Os
  2023-09-11 13:14 [Bug middle-end/111369] New: ICE in handle_cast, gimple-lower-bitint.cc:1486 with -Os fkastl at suse dot cz
@ 2023-09-11 13:16 ` jakub at gcc dot gnu.org
  2023-09-11 13:17 ` [Bug middle-end/111369] [14 Regression] " jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-09-11 13:16 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
This is:
https://gcc.gnu.org/pipermail/gcc-patches/2023-September/629277.html

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

* [Bug middle-end/111369] [14 Regression] ICE in handle_cast, gimple-lower-bitint.cc:1486 with -Os
  2023-09-11 13:14 [Bug middle-end/111369] New: ICE in handle_cast, gimple-lower-bitint.cc:1486 with -Os 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 ` jakub at gcc dot gnu.org
  2023-10-04  7:32 ` cvs-commit at gcc dot gnu.org
  2023-10-04  7:34 ` jakub at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-09-11 13:17 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1
   Target Milestone|---                         |14.0
            Summary|ICE in handle_cast,         |[14 Regression] ICE in
                   |gimple-lower-bitint.cc:1486 |handle_cast,
                   |with -Os                    |gimple-lower-bitint.cc:1486
                   |                            |with -Os

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

* [Bug middle-end/111369] [14 Regression] ICE in handle_cast, gimple-lower-bitint.cc:1486 with -Os
  2023-09-11 13:14 [Bug middle-end/111369] New: ICE in handle_cast, gimple-lower-bitint.cc:1486 with -Os 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
  2023-10-04  7:34 ` jakub at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-10-04  7:32 UTC (permalink / raw)
  To: gcc-bugs

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.

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

* [Bug middle-end/111369] [14 Regression] ICE in handle_cast, gimple-lower-bitint.cc:1486 with -Os
  2023-09-11 13:14 [Bug middle-end/111369] New: ICE in handle_cast, gimple-lower-bitint.cc:1486 with -Os fkastl at suse dot cz
                   ` (2 preceding siblings ...)
  2023-10-04  7:32 ` cvs-commit at gcc dot gnu.org
@ 2023-10-04  7:34 ` jakub at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-10-04  7:34 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Should be fixed now.

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

end of thread, other threads:[~2023-10-04  7:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-11 13:14 [Bug middle-end/111369] New: ICE in handle_cast, gimple-lower-bitint.cc:1486 with -Os 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
2023-10-04  7:34 ` jakub 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).