PR tree-optimization/94574 - aarch64: ICE during GIMPLE pass:ccp
authorYang Yang <yangyang305@huawei.com>
Tue, 14 Apr 2020 19:42:23 +0000 (19:42 +0000)
committerRichard Biener <rguenther@suse.de>
Tue, 14 Apr 2020 14:02:31 +0000 (16:02 +0200)
In this PR the testcase ICEs because a BIT_INSERT_EXPR whose replaced bits are
not fully inside the container is generated. A size check is added to avoid
this kind of ICE.

gcc/ChangeLog:

PR tree-optimization/94574
* tree-ssa.c (non_rewritable_lvalue_p): Add size check when analyzing
whether a vector-insert is rewritable using a BIT_INSERT_EXPR.

gcc/testsuite/ChangeLog:

PR tree-optimization/94574
* gcc.dg/pr94574.c: New test.

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr94574.c [new file with mode: 0644]
gcc/tree-ssa.c

index 343b52c051246442517e4658c87850c12f963f6e..441dcab490d4e7e8e3f528752b08b233336480f0 100644 (file)
@@ -1,3 +1,9 @@
+2020-04-14  Yang Yang <yangyang305@huawei.com>
+
+       PR tree-optimization/94574
+       * tree-ssa.c (non_rewritable_lvalue_p): Add size check when analyzing
+       whether a vector-insert is rewritable using a BIT_INSERT_EXPR.
+
 2020-04-14  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR target/94561
index e7a82389fc6afd004218ec8ebc3bb24db4f0ab44..051dcb15f482b3239bf3d5617f8a2f7dbba13462 100644 (file)
@@ -1,3 +1,8 @@
+2020-04-14  Yang Yang <yangyang305@huawei.com>
+
+       PR tree-optimization/94574
+       * gcc.dg/pr94574.c: New test.
+
 2020-04-14  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR target/94561
diff --git a/gcc/testsuite/gcc.dg/pr94574.c b/gcc/testsuite/gcc.dg/pr94574.c
new file mode 100644 (file)
index 0000000..0d18bd8
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -w -Wno-psabi" } */
+
+typedef unsigned int v4si __attribute__((vector_size(16)));
+typedef unsigned int v2si __attribute__((vector_size(8)));
+
+/* The aliasing is somewhat dubious here, but it must compile.  */
+
+v2si
+foo (v4si v)
+{
+  v2si res;
+  *(v4si *) &res = v;
+  return res;
+}
index 344f32d69cf2a722d85b32d4ee870420f82f41fc..4f4ab2b8992ae4bb258c763bb2a5442ea074d93b 100644 (file)
@@ -1543,7 +1543,9 @@ non_rewritable_lvalue_p (tree lhs)
          && known_gt (wi::to_poly_offset (TYPE_SIZE_UNIT (TREE_TYPE (decl))),
                       mem_ref_offset (lhs))
          && multiple_of_p (sizetype, TREE_OPERAND (lhs, 1),
-                           TYPE_SIZE_UNIT (TREE_TYPE (lhs))))
+                           TYPE_SIZE_UNIT (TREE_TYPE (lhs)))
+         && known_ge (wi::to_poly_offset (TYPE_SIZE (TREE_TYPE (decl))),
+                      wi::to_poly_offset (TYPE_SIZE (TREE_TYPE (lhs)))))
        {
          poly_uint64 lhs_bits, nelts;
          if (poly_int_tree_p (TYPE_SIZE (TREE_TYPE (lhs)), &lhs_bits)