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/113705] [14 Regression] ICE in decompose, at wide-int.h:1049 on aarch64-linux-gnu since r14-8680-g2f14c0dbb78985
Date: Fri, 02 Feb 2024 10:26:57 +0000	[thread overview]
Message-ID: <bug-113705-4-ctBYJu0WCj@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-113705-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #10 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:a8f335ccb61bf6105192a4197ef2d84900614dc1

commit r14-8742-ga8f335ccb61bf6105192a4197ef2d84900614dc1
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Feb 2 11:25:13 2024 +0100

    tree-ssa-math-opts: Fix is_widening_mult_rhs_p - unbreak bootstrap
[PR113705]

    On Tue, Jan 30, 2024 at 07:33:10AM -0000, Roger Sayle wrote:
    +             wide_int bits = wide_int::from (tree_nonzero_bits (rhs),
    +                                             prec,
    +                                             TYPE_SIGN (TREE_TYPE (rhs)));
    ...
    > +               if (gimple_assign_rhs_code (stmt) == BIT_AND_EXPR
    > +                   && TREE_CODE (gimple_assign_rhs2 (stmt)) ==
INTEGER_CST
    > +                   && wi::to_wide (gimple_assign_rhs2 (stmt))
    > +                      == wi::mask (hprec, false, prec))

    This change broke bootstrap on aarch64-linux.
    The problem can be seen even on the reduced testcase.

    The IL on the unreduced testcase before widening_mul has:
      # val_583 = PHI <val_26(13), val_164(40)>
    ...
      pretmp_266 = MEM[(const struct wide_int_storage *)&D.160657].len;
      _264 = pretmp_266 & 65535;
    ...
      _176 = (sizetype) val_583;
      _439 = (sizetype) _264;
      _284 = _439 * 8;
      _115 = _176 + _284;
    where 583/266/264 have unsigned int type and 176/439/284/115 have sizetype.
    widening_mul first turns that into:
      # val_583 = PHI <val_26(13), val_164(40)>
    ...
      pretmp_266 = MEM[(const struct wide_int_storage *)&D.160657].len;
      _264 = pretmp_266 & 65535;
    ...
      _176 = (sizetype) val_583;
      _439 = (sizetype) _264;
      _284 = _264 w* 8;
      _115 = _176 + _284;
    and then is_widening_mult_rhs_p is called, with type sizetype (64-bit),
    rhs _264, hprec 32 and prec 64.  Now tree_nonzero_bits (rhs) is
    65535, so bits is 64-bit wide_int 65535, stmt is BIT_AND_EXPR,
    but we ICE on the
    wi::to_wide (gimple_assign_rhs2 (stmt)) == wi::mask (hprec, false, prec)
    comparison because wi::to_wide on gimple_assign_rhs2 (stmt) - unsigned int
    65535 gives 32-bit wide_int 65535, while wi::mask (hprec, false, prec)
    gives 64-bit wide_int 0xffffffff and comparison between different precision
    wide_ints is forbidden.

    The following patch fixes it the same way how bits is computed earlier,
    by calling wide_int::from on the wi::to_wide (gimple_assign_rhs2 (stmt)),
    so we compare 64-bit 65535 with 64-bit 0xffffffff.

    2024-02-02  Jakub Jelinek  <jakub@redhat.com>

            PR middle-end/113705
            * tree-ssa-math-opts.cc (is_widening_mult_rhs_p): Use wide_int_from
            around wi::to_wide in order to compare value in prec precision.

            * g++.dg/opt/pr113705.C: New test.

  parent reply	other threads:[~2024-02-02 10:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-01 14:07 [Bug middle-end/113705] New: [14 Regression] ICE in decompose, at wide-int.h:1049 on aarch64-linux-gnu doko at gcc dot gnu.org
2024-02-01 14:13 ` [Bug middle-end/113705] " doko at gcc dot gnu.org
2024-02-01 14:13 ` rguenth at gcc dot gnu.org
2024-02-01 15:35 ` acoplan at gcc dot gnu.org
2024-02-01 16:09 ` mpolacek at gcc dot gnu.org
2024-02-01 16:22 ` [Bug middle-end/113705] [14 Regression] ICE in decompose, at wide-int.h:1049 on aarch64-linux-gnu since r14-8680-g2f14c0dbb78985 acoplan at gcc dot gnu.org
2024-02-01 16:45 ` jakub at gcc dot gnu.org
2024-02-01 16:56 ` jakub at gcc dot gnu.org
2024-02-01 17:37 ` xry111 at gcc dot gnu.org
2024-02-01 18:08 ` jakub at gcc dot gnu.org
2024-02-01 18:29 ` xry111 at gcc dot gnu.org
2024-02-02  9:58 ` doko at gcc dot gnu.org
2024-02-02 10:26 ` cvs-commit at gcc dot gnu.org [this message]
2024-02-02 10:33 ` 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-113705-4-ctBYJu0WCj@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).