riscv: Fix up riscv_rtx_costs for RTL checking (PR target/93333)

As mentioned in the PR, during combine rtx_costs can be called sometimes
even on RTL that has not been validated yet and so can contain even operands
that aren't valid in any instruction.

2020-01-21  Jakub Jelinek  <jakub@redhat.com>

	PR target/93333
	* config/riscv/riscv.c (riscv_rtx_costs) <case ZERO_EXTRACT>: Verify
	the last two operands are CONST_INT_P before using them as such.

	* gcc.c-torture/compile/pr93333.c: New test.
This commit is contained in:
Jakub Jelinek 2020-01-22 17:55:23 +01:00
parent 1abe8d45b7
commit 51faa475c9
4 changed files with 31 additions and 1 deletions

View File

@ -1,3 +1,12 @@
2020-01-22 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
2020-01-21 Jakub Jelinek <jakub@redhat.com>
PR target/93333
* config/riscv/riscv.c (riscv_rtx_costs) <case ZERO_EXTRACT>: Verify
the last two operands are CONST_INT_P before using them as such.
2020-01-22 Jakub Jelinek <jakub@redhat.com>
Backported from mainline

View File

@ -1612,7 +1612,10 @@ riscv_rtx_costs (rtx x, machine_mode mode, int outer_code, int opno ATTRIBUTE_UN
case ZERO_EXTRACT:
/* This is an SImode shift. */
if (outer_code == SET && (INTVAL (XEXP (x, 2)) > 0)
if (outer_code == SET
&& CONST_INT_P (XEXP (x, 1))
&& CONST_INT_P (XEXP (x, 2))
&& (INTVAL (XEXP (x, 2)) > 0)
&& (INTVAL (XEXP (x, 1)) + INTVAL (XEXP (x, 2)) == 32))
{
*total = COSTS_N_INSNS (SINGLE_SHIFT_COST);

View File

@ -1,3 +1,11 @@
2020-01-22 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
2020-01-21 Jakub Jelinek <jakub@redhat.com>
PR target/93333
* gcc.c-torture/compile/pr93333.c: New test.
2020-01-22 Jakub Jelinek <jakub@redhat.com>
Backported from mainline

View File

@ -0,0 +1,10 @@
/* PR target/93333 */
unsigned
foo (int b, int c, int d, unsigned long e, int x, int y, int g, int h,
unsigned i)
{
e >>= b;
i >>= e & 31;
return i & 1;
}