public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: gcc-patches@gcc.gnu.org
Cc: Segher Boessenkool <segher@kernel.crashing.org>,
	sandra@codesourcery.com,	bschmidt@redhat.com
Subject: [PATCH 4/6] nios2: Fixes for RTL checking
Date: Tue, 21 Feb 2017 14:49:00 -0000	[thread overview]
Message-ID: <e923a713bf55570f6f3c6235b23baecbbd3eeec0.1487685472.git.segher@kernel.crashing.org> (raw)
In-Reply-To: <cover.1487685472.git.segher@kernel.crashing.org>
In-Reply-To: <cover.1487685472.git.segher@kernel.crashing.org>

You cannot call REGNO on something that isn't a REG, and you cannot
call INTVAL on something that isn't a CONST_INT.

The way I fixed nios2_alternate_compare_const is admittedly a bit lame.


2017-02-21  Segher Boessenkool  <segher@kernel.crashing.org>

	* config/nios2/nios2.c (nios2_simple_const_p): Returns false if the
	argument isn't a CONST_INT.
	(nios2_alternate_compare_const): Set *alt_code and *alt_op to code
	and op if op is not a CONST_INT.
	(nios2_valid_compare_const_p): Return false if the argument isn't
	a CONST_INT.
	(ldstwm_operation_p): Return false if first_base is not a REG or
	if first_offset is not a CONST_INT.

---
 gcc/config/nios2/nios2.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/gcc/config/nios2/nios2.c b/gcc/config/nios2/nios2.c
index e1b0372..75eeee3 100644
--- a/gcc/config/nios2/nios2.c
+++ b/gcc/config/nios2/nios2.c
@@ -1416,6 +1416,8 @@ nios2_option_override (void)
 static bool
 nios2_simple_const_p (const_rtx cst)
 {
+  if (!CONST_INT_P (cst))
+    return false;
   HOST_WIDE_INT val = INTVAL (cst);
   return SMALL_INT (val) || SMALL_INT_UNSIGNED (val) || UPPER16_INT (val);
 }
@@ -1753,6 +1755,13 @@ nios2_alternate_compare_const (enum rtx_code code, rtx op,
 			       enum rtx_code *alt_code, rtx *alt_op,
 			       machine_mode mode)
 {
+  if (!CONST_INT_P (op))
+    {
+      *alt_code = code;
+      *alt_op = op;
+      return;
+    }
+
   HOST_WIDE_INT opval = INTVAL (op);
   enum rtx_code scode = signed_condition (code);
   bool dec_p = (scode == LT || scode == GE);
@@ -1788,6 +1797,9 @@ nios2_alternate_compare_const (enum rtx_code code, rtx op,
 static bool
 nios2_valid_compare_const_p (enum rtx_code code, rtx op)
 {
+  if (!CONST_INT_P (op))
+    return false;
+
   switch (code)
     {
     case EQ: case NE: case GE: case LT:
@@ -4558,6 +4570,8 @@ ldstwm_operation_p (rtx op, bool load_p)
 	  if (!split_mem_address (XEXP (mem, 0),
 				  &first_base, &first_offset))
 	    return false;
+	  if (!REG_P (first_base) || !CONST_INT_P (first_offset))
+	    return false;
 	  base_reg = first_base;
 	  inc_p = INTVAL (first_offset) >= 0;
 	}
-- 
1.9.3

  parent reply	other threads:[~2017-02-21 14:49 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-21 14:48 [PATCH 0/6] Fallout from " Segher Boessenkool
2017-02-21 14:48 ` [PATCH 2/6] cris: Fix for " Segher Boessenkool
2017-02-21 15:03   ` Hans-Peter Nilsson
2017-02-21 14:49 ` [PATCH 1/6] c6x: " Segher Boessenkool
2017-02-21 15:09   ` Bernd Schmidt
2017-02-21 14:49 ` Segher Boessenkool [this message]
2017-02-21 19:33   ` [PATCH 4/6] nios2: Fixes " Jeff Law
2017-02-21 19:53   ` Sandra Loosemore
2017-02-24 22:45     ` Sandra Loosemore
2017-02-21 14:49 ` [PATCH 6/6] sh: " Segher Boessenkool
2017-02-21 15:49   ` Oleg Endo
2017-02-21 16:32     ` Segher Boessenkool
2017-02-21 14:49 ` [PATCH 3/6] microblaze: " Segher Boessenkool
2017-02-21 19:28   ` Jeff Law
2017-02-21 20:11   ` Michael Eager
2017-02-21 20:33     ` Segher Boessenkool
2017-02-21 21:07       ` Michael Eager
2017-02-24 23:12         ` Segher Boessenkool
2017-02-21 20:19   ` Jakub Jelinek
2017-02-21 20:37     ` Michael Eager
2017-02-21 20:41       ` Jakub Jelinek
2017-02-21 21:23       ` Segher Boessenkool
2017-02-21 15:01 ` [PATCH 5/6] pa: " Segher Boessenkool
2017-02-21 19:12   ` Jeff Law
2017-02-21 15:16 ` [PATCH] arc: " Segher Boessenkool
2017-02-21 19:27   ` Jeff Law
2017-02-24 19:20   ` Claudiu Zissulescu

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=e923a713bf55570f6f3c6235b23baecbbd3eeec0.1487685472.git.segher@kernel.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=bschmidt@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=sandra@codesourcery.com \
    /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).