public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: <apinski@marvell.com>
To: <gcc-patches@gcc.gnu.org>
Cc: Andrew Pinski <apinski@marvell.com>
Subject: [PATCH 2/2] Add assert for type on tree_nonzero_bits
Date: Wed, 2 Nov 2022 14:46:35 -0700	[thread overview]
Message-ID: <1667425595-2654-3-git-send-email-apinski@marvell.com> (raw)
In-Reply-To: <1667425595-2654-1-git-send-email-apinski@marvell.com>

From: Andrew Pinski <apinski@marvell.com>

Right now anyone could call tree_nonzero_bits with
either complex or vector types and this will return
the wrong thing. So just assert that nobody calls
it with this.

OK? Bootstrapped and tested with no regressions on x86_64-linux-gnu.

gcc/ChangeLog:

	* fold-const.cc (tree_nonzero_bits): Add
	assert.
---
 gcc/fold-const.cc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc
index 7e1ea58518b..3ccac9b28df 100644
--- a/gcc/fold-const.cc
+++ b/gcc/fold-const.cc
@@ -16567,6 +16567,9 @@ c_getstr (tree str)
 wide_int
 tree_nonzero_bits (const_tree t)
 {
+  gcc_assert (TREE_CODE (TREE_TYPE (t)) != VECTOR_TYPE
+	      && TREE_CODE (TREE_TYPE (t)) != COMPLEX_TYPE);
+
   switch (TREE_CODE (t))
     {
     case INTEGER_CST:
-- 
2.17.1


  parent reply	other threads:[~2022-11-02 21:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-02 21:46 [PATCH 0/2] tree_nonzero_bits vs vector and complex types apinski
2022-11-02 21:46 ` [PATCH 1/2] Fix PR 105532: match.pd patterns calling tree_nonzero_bits with vector types apinski
2022-11-05 11:44   ` Richard Biener
2022-12-20 13:45     ` Richard Biener
2022-11-02 21:46 ` apinski [this message]
2022-11-05 11:47   ` [PATCH 2/2] Add assert for type on tree_nonzero_bits Richard Biener

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=1667425595-2654-3-git-send-email-apinski@marvell.com \
    --to=apinski@marvell.com \
    --cc=gcc-patches@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).