public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/108819] [12/13 Regression] ICE on valid code at -O1 with "-fno-tree-ccp -fno-tree-forwprop" on x86_64-linux-gnu: tree check: expected ssa_name, have integer_cst in number_of_iterations_cltz, at tree-ssa-loop-niter.cc:2394
Date: Fri, 17 Feb 2023 16:46:29 +0000	[thread overview]
Message-ID: <bug-108819-4-p7KUHLmzGu@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108819-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #3)
> --- a/gcc/tree-ssa-reassoc.cc
> +++ b/gcc/tree-ssa-reassoc.cc
> @@ -2950,6 +2950,9 @@ update_range_test (struct range_entry *range, struct
> range_entry *otherrange,
>      }
>    if (stmt == NULL)
>      gcc_checking_assert (tem == op);
> +  /* When range->exp is a constant, we can use it as-is.  */
> +  else if (is_gimple_min_invariant (tem))
> +    ;
>    /* In rare cases range->exp can be equal to lhs of stmt.
>       In that case we have to insert after the stmt rather then before
>       it.  If stmt is a PHI, insert it at the start of the basic block.  */

That would make things worse, not better (i.e. constants could appear more
often and we could trigger these problems more often), no?
forwprop/ccp etc. should optimize it later...

I wonder if we just can't do:
--- gcc/tree-ssa-reassoc.cc.jj  2023-02-16 10:41:11.000000000 +0100
+++ gcc/tree-ssa-reassoc.cc     2023-02-17 17:43:52.169452832 +0100
@@ -4687,6 +4687,8 @@ update_ops (tree var, enum tree_code cod
       gimple_set_uid (g, gimple_uid (stmt));
       gimple_set_visited (g, true);
       gsi_insert_before (&gsi, g, GSI_SAME_STMT);
+      gimple_stmt_iterator gsi2 = gsi_for_stmt (g);
+      fold_stmt_inplace (&gsi2);
     }
   return var;
 }
or if the in-place folding wouldn't be appropriate, at least fold it by hand if
both arguments are constants.  Though, there is also the case of commutative
ops and just the first one turned into constant etc.

  parent reply	other threads:[~2023-02-17 16:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-16 10:35 [Bug tree-optimization/108819] New: " zhendong.su at inf dot ethz.ch
2023-02-16 15:39 ` [Bug tree-optimization/108819] [13 Regression] " pinskia at gcc dot gnu.org
2023-02-16 19:34 ` [Bug tree-optimization/108819] [12/13 " pinskia at gcc dot gnu.org
2023-02-17  7:59 ` rguenth at gcc dot gnu.org
2023-02-17 13:20 ` rguenth at gcc dot gnu.org
2023-02-17 16:46 ` jakub at gcc dot gnu.org [this message]
2023-02-18 11:41 ` cvs-commit at gcc dot gnu.org
2023-02-18 11:42 ` [Bug tree-optimization/108819] [12 " jakub at gcc dot gnu.org
2023-02-20  7:44 ` cvs-commit at gcc dot gnu.org
2023-03-19  5:29 ` cvs-commit at gcc dot gnu.org
2023-03-20 10:26 ` 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-108819-4-p7KUHLmzGu@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).