diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2b0541ea1f0..6048a8fdc60 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2020-01-22 Jakub Jelinek + + Backported from mainline + 2020-01-21 Jakub Jelinek + + PR target/93333 + * config/riscv/riscv.c (riscv_rtx_costs) : Verify + the last two operands are CONST_INT_P before using them as such. + 2020-01-22 Jakub Jelinek Backported from mainline diff --git a/gcc/config/riscv/riscv.c b/gcc/config/riscv/riscv.c index 92e7f312583..931662b3137 100644 --- a/gcc/config/riscv/riscv.c +++ b/gcc/config/riscv/riscv.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 24c597b33c7..1346e461c30 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2020-01-22 Jakub Jelinek + + Backported from mainline + 2020-01-21 Jakub Jelinek + + PR target/93333 + * gcc.c-torture/compile/pr93333.c: New test. + 2020-01-22 Jakub Jelinek Backported from mainline diff --git a/gcc/testsuite/gcc.c-torture/compile/pr93333.c b/gcc/testsuite/gcc.c-torture/compile/pr93333.c new file mode 100644 index 00000000000..801959bea75 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr93333.c @@ -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; +}