aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorTamar Christina <tamar.christina@arm.com>2018-08-21 09:55:07 +0000
committerTamar Christina <tnfchris@gcc.gnu.org>2018-08-21 09:55:07 +0000
commitdaa9715842345da5b9c440a9fef1ed3bc916bc18 (patch)
tree12d634187fcdcecf0de83dafe2f8355dc44386b8 /gcc
parent25d4036370f11d5c32fed965c2d47e0958cbe64a (diff)
downloadgcc-daa9715842345da5b9c440a9fef1ed3bc916bc18.zip
gcc-daa9715842345da5b9c440a9fef1ed3bc916bc18.tar.gz
gcc-daa9715842345da5b9c440a9fef1ed3bc916bc18.tar.bz2
Fix DSE big-endian subreg crash on AArch64.
This patch fixes an ICE that would happen when extract_low_bits is called with modes for which you can't extract a valid subreg. e.g. taking a 32 bytes subreg from a 48 byte mode. The ICE happens because convert_modes which eventually calls simplify_gen_subreg does not expect the convertion to fail. The assert in gen_lowpart_general would then be hit. The patch changes it to validate the subreg before trying to convert the modes. If the subreg is not possible we return NULL_RTX and bail out early. gcc/ChangeLog: 2018-08-21 Tamar Christina <tamar.christina@arm.com> * expmed.c (extract_low_bits): Reject invalid subregs early. gcc/testsuite/ChangeLog: 2018-08-21 Tamar Christina <tamar.christina@arm.com> * gcc.target/aarch64/large_struct_copy.c: New test. From-SVN: r263696
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/expmed.c4
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.target/aarch64/large_struct_copy.c23
4 files changed, 35 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b4b7fe0..66ca10b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,7 @@
+2018-08-21 Tamar Christina <tamar.christina@arm.com>
+
+ * expmed.c (extract_low_bits): Reject invalid subregs early.
+
2018-08-21 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR middle-end/86121
diff --git a/gcc/expmed.c b/gcc/expmed.c
index be9f0ec..e281930 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -2392,6 +2392,10 @@ extract_low_bits (machine_mode mode, machine_mode src_mode, rtx src)
return NULL_RTX;
src = gen_lowpart (src_int_mode, src);
+ if (!validate_subreg (int_mode, src_int_mode, src,
+ subreg_lowpart_offset (int_mode, src_int_mode)))
+ return NULL_RTX;
+
src = convert_modes (int_mode, src_int_mode, src, true);
src = gen_lowpart (mode, src);
return src;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ccdaa1e..42117a6 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2018-08-21 Tamar Christina <tamar.christina@arm.com>
+
+ * gcc.target/aarch64/large_struct_copy.c: New test.
+
2018-08-21 Szabolcs Nagy <szabolcs.nagy@arm.com>
* g++.dg/torture/pr86763.C: Restrict to *-*-linux*.
diff --git a/gcc/testsuite/gcc.target/aarch64/large_struct_copy.c b/gcc/testsuite/gcc.target/aarch64/large_struct_copy.c
new file mode 100644
index 0000000..2b5e780
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/large_struct_copy.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+typedef unsigned __attribute__((mode(DI))) uint64_t;
+
+struct S0 {
+ uint64_t f1;
+ uint64_t f2;
+ uint64_t f3;
+ uint64_t f4;
+ uint64_t f5;
+} a;
+struct S2 {
+ uint64_t f0;
+ uint64_t f2;
+ struct S0 f3;
+};
+
+void fn1 () {
+ struct S2 b = {0, 1, 7, 4073709551611, 4, 8, 7};
+ a = b.f3;
+}
+