[PATCH 4/6] nios2: Fixes for RTL checking
Segher Boessenkool
segher@kernel.crashing.org
Tue Feb 21 14:49:00 GMT 2017
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
More information about the Gcc-patches
mailing list