public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-6137] tree-optimization/108819 - niter analysis ICE with unexpected constant
Date: Mon, 20 Feb 2023 07:44:33 +0000 (GMT)	[thread overview]
Message-ID: <20230220074433.0B4B83858D20@sourceware.org> (raw)

https://gcc.gnu.org/g:ca31bc3366c533a55bfd7f1b9f4959c0c9869a7b

commit r13-6137-gca31bc3366c533a55bfd7f1b9f4959c0c9869a7b
Author: Richard Biener <rguenther@suse.de>
Date:   Fri Feb 17 14:21:39 2023 +0100

    tree-optimization/108819 - niter analysis ICE with unexpected constant
    
    The following makes sure we do not ICE on unfolded stmts like
    _1 = 1 & 1.
    
            PR tree-optimization/108819
            * tree-ssa-loop-niter.cc (number_of_iterations_cltz): Check
            we have an SSA name as iv_2 as expected.

Diff:
---
 gcc/tree-ssa-loop-niter.cc | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/tree-ssa-loop-niter.cc b/gcc/tree-ssa-loop-niter.cc
index 581bf5d067b..1ce5e736ce3 100644
--- a/gcc/tree-ssa-loop-niter.cc
+++ b/gcc/tree-ssa-loop-niter.cc
@@ -2354,7 +2354,8 @@ number_of_iterations_cltz (loop_p loop, edge exit,
       gimple *and_stmt = SSA_NAME_DEF_STMT (gimple_cond_lhs (cond_stmt));
       if (!is_gimple_assign (and_stmt)
 	  || gimple_assign_rhs_code (and_stmt) != BIT_AND_EXPR
-	  || !integer_pow2p (gimple_assign_rhs2 (and_stmt)))
+	  || !integer_pow2p (gimple_assign_rhs2 (and_stmt))
+	  || TREE_CODE (gimple_assign_rhs1 (and_stmt)) != SSA_NAME)
 	return false;
 
       checked_bit = tree_log2 (gimple_assign_rhs2 (and_stmt));
@@ -2382,7 +2383,8 @@ number_of_iterations_cltz (loop_p loop, edge exit,
 	     precision.  */
 	  iv_2 = gimple_assign_rhs1 (test_value_stmt);
 	  tree rhs_type = TREE_TYPE (iv_2);
-	  if (TREE_CODE (rhs_type) != INTEGER_TYPE
+	  if (TREE_CODE (iv_2) != SSA_NAME
+	      || TREE_CODE (rhs_type) != INTEGER_TYPE
 	      || (TYPE_PRECISION (rhs_type)
 		  != TYPE_PRECISION (test_value_type)))
 	    return false;

                 reply	other threads:[~2023-02-20  7:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230220074433.0B4B83858D20@sourceware.org \
    --to=rguenth@gcc.gnu.org \
    --cc=gcc-cvs@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).