Commit 039f4db9 by Segher Boessenkool Committed by Sandra Loosemore

nios2.c (nios2_simple_const_p): Returns false if the argument isn't a CONST_INT.

2017-02-24  Segher Boessenkool  <segher@kernel.crashing.org>
	    Sandra Loosemore  <sandra@codesourcery.com>

	gcc/
	* config/nios2/nios2.c (nios2_simple_const_p): Returns false if the
	argument isn't a CONST_INT.
	(nios2_alternate_compare_const): Assert op is a CONST_INT.
	(nios2_valid_compare_const_p): Assert op is a CONST_INT.
	(nios2_validate_compare): Bypass alternate compare logic if *op2
	is not a CONST_INT.
	(ldstwm_operation_p): Return false if first_base is not a REG or
	if first_offset is not a CONST_INT.


Co-Authored-By: Sandra Loosemore <sandra@codesourcery.com>

From-SVN: r245724
parent da3243b2
2017-02-24 Segher Boessenkool <segher@kernel.crashing.org> 2017-02-24 Segher Boessenkool <segher@kernel.crashing.org>
Sandra Loosemore <sandra@codesourcery.com>
* config/nios2/nios2.c (nios2_simple_const_p): Returns false if the
argument isn't a CONST_INT.
(nios2_alternate_compare_const): Assert op is a CONST_INT.
(nios2_valid_compare_const_p): Assert op is a CONST_INT.
(nios2_validate_compare): Bypass alternate compare logic if *op2
is not a CONST_INT.
(ldstwm_operation_p): Return false if first_base is not a REG or
if first_offset is not a CONST_INT.
2017-02-24 Segher Boessenkool <segher@kernel.crashing.org>
* config/cris/cris.md: Use correct operand in a define_peephole2. * config/cris/cris.md: Use correct operand in a define_peephole2.
......
...@@ -1416,6 +1416,8 @@ nios2_option_override (void) ...@@ -1416,6 +1416,8 @@ nios2_option_override (void)
static bool static bool
nios2_simple_const_p (const_rtx cst) nios2_simple_const_p (const_rtx cst)
{ {
if (!CONST_INT_P (cst))
return false;
HOST_WIDE_INT val = INTVAL (cst); HOST_WIDE_INT val = INTVAL (cst);
return SMALL_INT (val) || SMALL_INT_UNSIGNED (val) || UPPER16_INT (val); return SMALL_INT (val) || SMALL_INT_UNSIGNED (val) || UPPER16_INT (val);
} }
...@@ -1753,6 +1755,8 @@ nios2_alternate_compare_const (enum rtx_code code, rtx op, ...@@ -1753,6 +1755,8 @@ nios2_alternate_compare_const (enum rtx_code code, rtx op,
enum rtx_code *alt_code, rtx *alt_op, enum rtx_code *alt_code, rtx *alt_op,
machine_mode mode) machine_mode mode)
{ {
gcc_assert (CONST_INT_P (op));
HOST_WIDE_INT opval = INTVAL (op); HOST_WIDE_INT opval = INTVAL (op);
enum rtx_code scode = signed_condition (code); enum rtx_code scode = signed_condition (code);
bool dec_p = (scode == LT || scode == GE); bool dec_p = (scode == LT || scode == GE);
...@@ -1788,6 +1792,7 @@ nios2_alternate_compare_const (enum rtx_code code, rtx op, ...@@ -1788,6 +1792,7 @@ nios2_alternate_compare_const (enum rtx_code code, rtx op,
static bool static bool
nios2_valid_compare_const_p (enum rtx_code code, rtx op) nios2_valid_compare_const_p (enum rtx_code code, rtx op)
{ {
gcc_assert (CONST_INT_P (op));
switch (code) switch (code)
{ {
case EQ: case NE: case GE: case LT: case EQ: case NE: case GE: case LT:
...@@ -1846,7 +1851,7 @@ nios2_validate_compare (machine_mode mode, rtx *cmp, rtx *op1, rtx *op2) ...@@ -1846,7 +1851,7 @@ nios2_validate_compare (machine_mode mode, rtx *cmp, rtx *op1, rtx *op2)
if (GET_MODE_CLASS (mode) == MODE_FLOAT) if (GET_MODE_CLASS (mode) == MODE_FLOAT)
return nios2_validate_fpu_compare (mode, cmp, op1, op2, true); return nios2_validate_fpu_compare (mode, cmp, op1, op2, true);
if (!reg_or_0_operand (*op2, mode)) if (CONST_INT_P (*op2) && *op2 != const0_rtx)
{ {
/* Create alternate constant compare. */ /* Create alternate constant compare. */
nios2_alternate_compare_const (code, *op2, &alt_code, &alt_op2, mode); nios2_alternate_compare_const (code, *op2, &alt_code, &alt_op2, mode);
...@@ -1878,8 +1883,11 @@ nios2_validate_compare (machine_mode mode, rtx *cmp, rtx *op1, rtx *op2) ...@@ -1878,8 +1883,11 @@ nios2_validate_compare (machine_mode mode, rtx *cmp, rtx *op1, rtx *op2)
code = alt_code; code = alt_code;
*op2 = alt_op2; *op2 = alt_op2;
} }
*op2 = force_reg (SImode, *op2); *op2 = force_reg (mode, *op2);
} }
else if (!reg_or_0_operand (*op2, mode))
*op2 = force_reg (mode, *op2);
check_rebuild_cmp: check_rebuild_cmp:
if (code == GT || code == GTU || code == LE || code == LEU) if (code == GT || code == GTU || code == LE || code == LEU)
{ {
...@@ -4558,6 +4566,8 @@ ldstwm_operation_p (rtx op, bool load_p) ...@@ -4558,6 +4566,8 @@ ldstwm_operation_p (rtx op, bool load_p)
if (!split_mem_address (XEXP (mem, 0), if (!split_mem_address (XEXP (mem, 0),
&first_base, &first_offset)) &first_base, &first_offset))
return false; return false;
if (!REG_P (first_base) || !CONST_INT_P (first_offset))
return false;
base_reg = first_base; base_reg = first_base;
inc_p = INTVAL (first_offset) >= 0; inc_p = INTVAL (first_offset) >= 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment