]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
riscv: Fix up riscv_rtx_costs for RTL checking (PR target/93333)
authorJakub Jelinek <jakub@redhat.com>
Wed, 22 Jan 2020 16:55:23 +0000 (17:55 +0100)
committerJakub Jelinek <jakub@redhat.com>
Wed, 22 Jan 2020 19:12:57 +0000 (20:12 +0100)
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.

gcc/ChangeLog
gcc/config/riscv/riscv.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr93333.c [new file with mode: 0644]

index 2b0541ea1f0f7c280fccd22db815fefa45b139f7..6048a8fdc602898cd4edfefa815b81f860b86b78 100644 (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
index 92e7f312583721a5d4c3c5b01691cb2a8c347a0a..931662b31371796bb91b7992f7c7a0d861952339 100644 (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);
index 24c597b33c7fc99183501b6a26729f419d3caf52..1346e461c305912381e2bbcdce4dd0912b39d456 100644 (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
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr93333.c b/gcc/testsuite/gcc.c-torture/compile/pr93333.c
new file mode 100644 (file)
index 0000000..801959b
--- /dev/null
@@ -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;
+}