public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/106630] [13 Regression] ICE: Segmentation fault signal terminated program cc1plus with -O2 since r13-1268-g8c99e307b20c50
Date: Tue, 16 Aug 2022 07:41:36 +0000	[thread overview]
Message-ID: <bug-106630-4-ppCALxbqJA@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106630-4@http.gcc.gnu.org/bugzilla/>

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
We are folding a POINTER_PLUS_EXPR of

(vector(8) short int *) &g + a_9 * 48

and

48

which first gets to (vector(8) short int *) &g + (a_9 * 48 + 48)

which gets

/* (A * C) +- (B * C) -> (A+-B) * C and (A * C) +- A -> A * (C+-1).
    Modeled after fold_plusminus_mult_expr.  */

applied producing (a_9 + 1) * 48

the fold code produces a (sizetype) cast around (unsigned long) which is
useless (but not in GENERIC) and then

/* Narrow integer multiplication by a zero_one_valued_p operand.
   Multiplication by [0,1] is guaranteed not to overflow.  */
(simplify
 (convert (mult@0 zero_one_valued_p@1 INTEGER_CST@2))
 (if (INTEGRAL_TYPE_P (type)
      && INTEGRAL_TYPE_P (TREE_TYPE (@0))
      && TYPE_PRECISION (type) <= TYPE_PRECISION (TREE_TYPE (@0)))
  (mult (convert @1) (convert @2))))

triggers but folding this multiplication via fold-const.cc extract_muldiv
hoists the conversion again:

          if (TREE_CODE (arg1) == INTEGER_CST
              && (tem = extract_muldiv (op0, arg1, code, NULL_TREE,
                                        &strict_overflow_p)) != 0)
            {
              if (strict_overflow_p)
                fold_overflow_warning (("assuming signed overflow does not "
                                        "occur when simplifying "
                                        "multiplication"),
                                       WARN_STRICT_OVERFLOW_MISC);
              return fold_convert_loc (loc, type, tem);

which triggers the endless loop.  The fix might be to change the above
pattern guard to TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (@0))
which would match what the comment says.

The comment about DOM + missing cprop remains of course.

I'm testing the above.

  parent reply	other threads:[~2022-08-16  7:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-15 17:28 [Bug tree-optimization/106630] New: [13 Regression] ICE: Segmentation fault signal terminated program cc1plus with -O2 vsevolod.livinskiy at gmail dot com
2022-08-15 17:33 ` [Bug tree-optimization/106630] " pinskia at gcc dot gnu.org
2022-08-15 17:45 ` mpolacek at gcc dot gnu.org
2022-08-15 19:27 ` [Bug tree-optimization/106630] [13 Regression] ICE: Segmentation fault signal terminated program cc1plus with -O2 since r13-1268-g8c99e307b20c50 aldyh at gcc dot gnu.org
2022-08-15 21:34 ` aldyh at gcc dot gnu.org
2022-08-15 21:39 ` pinskia at gcc dot gnu.org
2022-08-15 22:09 ` aldyh at gcc dot gnu.org
2022-08-16  7:41 ` rguenth at gcc dot gnu.org [this message]
2022-08-16  7:47 ` aldyh at gcc dot gnu.org
2022-08-16  7:54 ` rguenther at suse dot de
2022-08-16  9:20 ` cvs-commit at gcc dot gnu.org
2022-08-16  9:21 ` rguenth 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-106630-4-ppCALxbqJA@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).