re PR tree-optimization/84417 (internal compiler error: verify_gimple failed)
authorRichard Biener <rguenther@suse.de>
Fri, 16 Feb 2018 12:01:23 +0000 (12:01 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 16 Feb 2018 12:01:23 +0000 (12:01 +0000)
2018-02-16  Richard Biener  <rguenther@suse.de>

PR tree-optimization/84417
* tree-ssa.c (non_rewritable_mem_ref_base): Properly constrain
the MEM_REF offset when conversion to BIT_FIELD_REF is desired.
(non_rewritable_lvalue_p): Likewise, use poly-ints.

* gcc.dg/torture/pr84417.c: New testcase.

From-SVN: r257731

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

index 9e7b575b38a70d3828ddc978ae6628de44e28419..c43637aac5e6d2a343fc341e92373ca76c4bacff 100644 (file)
@@ -1,3 +1,10 @@
+2018-02-16  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/84417
+       * tree-ssa.c (non_rewritable_mem_ref_base): Properly constrain
+       the MEM_REF offset when conversion to BIT_FIELD_REF is desired.
+       (non_rewritable_lvalue_p): Likewise, use poly-ints.
+
 2018-02-16  Martin Liska  <mliska@suse.cz>
 
        PR sanitizer/84307
index 2ead408c90a6e632c1c7e1b9902540d5186703f9..2d98e2e80249c0f6e58440b4672004431f229dc4 100644 (file)
@@ -1,3 +1,8 @@
+2018-02-16  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/84417
+       * gcc.dg/torture/pr84417.c: New testcase.
+
 2018-02-16  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/84272
diff --git a/gcc/testsuite/gcc.dg/torture/pr84417.c b/gcc/testsuite/gcc.dg/torture/pr84417.c
new file mode 100644 (file)
index 0000000..9c2b023
--- /dev/null
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target int32plus } */
+
+void fn1()
+{
+  __attribute__((__vector_size__(sizeof(double)))) double x;
+  double *a = (double *)&x;
+  *a + *(a + 8446744073709551615LL);
+}
index 949b951e1aaa98ccda0f769fde392a6809d70bcc..d197f99bdd231e0e7a1eab12b158920150596834 100644 (file)
@@ -1434,6 +1434,7 @@ non_rewritable_mem_ref_base (tree ref)
           || TREE_CODE (TREE_TYPE (decl)) == COMPLEX_TYPE)
          && useless_type_conversion_p (TREE_TYPE (base),
                                        TREE_TYPE (TREE_TYPE (decl)))
+         && known_ge (mem_ref_offset (base), 0)
          && known_gt (wi::to_poly_offset (TYPE_SIZE_UNIT (TREE_TYPE (decl))),
                       mem_ref_offset (base))
          && multiple_of_p (sizetype, TREE_OPERAND (base, 1),
@@ -1516,11 +1517,11 @@ non_rewritable_lvalue_p (tree lhs)
          && TYPE_MODE (TREE_TYPE (decl)) != BLKmode
          && operand_equal_p (TYPE_SIZE_UNIT (TREE_TYPE (lhs)),
                              TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (decl))), 0)
-         && tree_fits_uhwi_p (TREE_OPERAND (lhs, 1))
-         && tree_int_cst_lt (TREE_OPERAND (lhs, 1),
-                             TYPE_SIZE_UNIT (TREE_TYPE (decl)))
-         && (tree_to_uhwi (TREE_OPERAND (lhs, 1))
-             % tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (lhs)))) == 0)
+         && known_ge (mem_ref_offset (lhs), 0)
+         && 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))))
        return false;
     }