[gcc/devel/ranger] explow: Fix ICE caused by plus_constant [PR94002]
Aldy Hernandez
aldyh@gcc.gnu.org
Wed Jun 17 19:23:21 GMT 2020
https://gcc.gnu.org/g:0ab503d34f2a8c22262ceefea6c882ae2ff75230
commit 0ab503d34f2a8c22262ceefea6c882ae2ff75230
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Mar 3 10:42:34 2020 +0100
explow: Fix ICE caused by plus_constant [PR94002]
The following testcase ICEs in cross to riscv64-linux. The problem is
that we have a DImode integral constant (that doesn't fit into SImode),
which is pushed into a constant pool and later access just the first half of
it using a MEM. When plus_constant is called on such a MEM, if the constant
has mode, we verify the mode, but if it doesn't, we don't and ICE later on
when we think the CONST_INT is a valid SImode constant.
2020-03-03 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/94002
* explow.c (plus_constant): Punt if cst has VOIDmode and
get_pool_mode is different from mode.
* gcc.dg/pr94002.c: New test.
Diff:
---
gcc/ChangeLog | 6 ++++++
gcc/explow.c | 3 +++
gcc/testsuite/ChangeLog | 3 +++
gcc/testsuite/gcc.dg/pr94002.c | 13 +++++++++++++
4 files changed, 25 insertions(+)
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ef5c7a170b4..124a06a960a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2020-03-03 Jakub Jelinek <jakub@redhat.com>
+
+ PR rtl-optimization/94002
+ * explow.c (plus_constant): Punt if cst has VOIDmode and
+ get_pool_mode is different from mode.
+
2020-03-03 Claudiu Zissulescu <claziss@synopsys.com>
* config/arc/arc.c (leigitimate_small_data_address_p): Check if an
diff --git a/gcc/explow.c b/gcc/explow.c
index 77f0c07bbba..b838f035870 100644
--- a/gcc/explow.c
+++ b/gcc/explow.c
@@ -128,6 +128,9 @@ plus_constant (machine_mode mode, rtx x, poly_int64 c, bool inplace)
cst = gen_lowpart (mode, cst);
gcc_assert (cst);
}
+ else if (GET_MODE (cst) == VOIDmode
+ && get_pool_mode (XEXP (x, 0)) != mode)
+ break;
if (GET_MODE (cst) == VOIDmode || GET_MODE (cst) == mode)
{
tem = plus_constant (mode, cst, c);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2e316a3f744..c4aa9102460 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2020-03-03 Jakub Jelinek <jakub@redhat.com>
+ PR rtl-optimization/94002
+ * gcc.dg/pr94002.c: New test.
+
PR tree-optimization/93927
* gcc.c-torture/compile/pr93927-1.c: New test.
* gcc.c-torture/compile/pr93927-2.c: New test.
diff --git a/gcc/testsuite/gcc.dg/pr94002.c b/gcc/testsuite/gcc.dg/pr94002.c
new file mode 100644
index 00000000000..05a02f3f15b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr94002.c
@@ -0,0 +1,13 @@
+/* PR rtl-optimization/94002 */
+/* { dg-do compile } */
+/* { dg-options "-O1 -fno-tree-dce -fno-tree-reassoc" } */
+/* { dg-additional-options "-fPIC" { target fpic } } */
+
+unsigned a, b;
+
+void
+foo (void)
+{
+ __builtin_sub_overflow (b, 44852956282LL, &a);
+ a += ~b;
+}
More information about the Gcc-cvs
mailing list