From: Jakub Jelinek Date: Tue, 21 Jan 2020 20:43:03 +0000 (+0100) Subject: riscv: Fix up riscv_rtx_costs for RTL checking (PR target/93333) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bd0a3e244d94ad4a5e41f01ebf285f0861cb4a03;p=gcc.git 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 PR target/93333 * config/riscv/riscv.c (riscv_rtx_costs) : Verify the last two operands are CONST_INT_P before using them as such. * gcc.c-torture/compile/pr93333.c: New test. --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e2f3d0db2cd..e7ae5bbefa1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +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-21 Richard Sandiford * config/aarch64/aarch64-sve-builtins.def: Use get_typenode_from_name diff --git a/gcc/config/riscv/riscv.c b/gcc/config/riscv/riscv.c index 573024074e3..e0205c66f26 100644 --- a/gcc/config/riscv/riscv.c +++ b/gcc/config/riscv/riscv.c @@ -1642,7 +1642,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 b164f3156c7..e8561cca412 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-01-21 Jakub Jelinek + + PR target/93333 + * gcc.c-torture/compile/pr93333.c: New test. + 2020-01-21 Sandra Loosemore * g++.dg/coroutines/torture/mid-suspend-destruction-0.C: Generalize 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; +}