re PR middle-end/68785 (valgrind reports issues with folding on x86_64)
authorJakub Jelinek <jakub@redhat.com>
Thu, 10 Dec 2015 10:14:38 +0000 (11:14 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 10 Dec 2015 10:14:38 +0000 (11:14 +0100)
PR tree-optimization/68785
* gimple-fold.c (fold_ctor_reference): Pass return value from
native_encode_expr to native_interpret_expr.
* tree-ssa-sccvn.c (fully_constant_vn_reference_p): Likewise.

* gcc.dg/pr68785.c: New test.

From-SVN: r231499

gcc/ChangeLog
gcc/gimple-fold.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr68785.c [new file with mode: 0644]
gcc/tree-ssa-sccvn.c

index eac591761082ae63d5532090761f08c65d507eae..50e6e7a39a6130b4adb9977d88154956c3f0f793 100644 (file)
@@ -1,3 +1,10 @@
+2015-12-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/68785
+       * gimple-fold.c (fold_ctor_reference): Pass return value from
+       native_encode_expr to native_interpret_expr.
+       * tree-ssa-sccvn.c (fully_constant_vn_reference_p): Likewise.
+
 2015-12-10  Richard Biener  <rguenther@suse.de>
 
        PR ipa/68331
index 6ff5e266d420a94b80cf1db12d45784b3fc26214..6f8ec6f90a626d1fb9d70de3e6e76de3a2fe823f 100644 (file)
@@ -5495,9 +5495,10 @@ fold_ctor_reference (tree type, tree ctor, unsigned HOST_WIDE_INT offset,
       && size <= MAX_BITSIZE_MODE_ANY_MODE)
     {
       unsigned char buf[MAX_BITSIZE_MODE_ANY_MODE / BITS_PER_UNIT];
-      if (native_encode_expr (ctor, buf, size / BITS_PER_UNIT,
-                             offset / BITS_PER_UNIT) > 0)
-       return native_interpret_expr (type, buf, size / BITS_PER_UNIT);
+      int len = native_encode_expr (ctor, buf, size / BITS_PER_UNIT,
+                                   offset / BITS_PER_UNIT);
+      if (len > 0)
+       return native_interpret_expr (type, buf, len);
     }
   if (TREE_CODE (ctor) == CONSTRUCTOR)
     {
index 6141624b7b9006c761682a6d28a2dbd8a24db7ec..fd5fc3e5913e7d327aa287b17907d2c3882e3df8 100644 (file)
@@ -1,3 +1,8 @@
+2015-12-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/68785
+       * gcc.dg/pr68785.c: New test.
+
 2015-12-10  Richard Biener  <rguenther@suse.de>
 
        PR ipa/68331
diff --git a/gcc/testsuite/gcc.dg/pr68785.c b/gcc/testsuite/gcc.dg/pr68785.c
new file mode 100644 (file)
index 0000000..f4257da
--- /dev/null
@@ -0,0 +1,9 @@
+/* PR tree-optimization/68785 */
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+
+int
+foo (void)
+{
+  return *(int *) "";
+}
index 2014ee7a7ebf11748b99e010c034b33fa879fbb1..3086f84f39e7edd2ab0f687e8533391adfa211ae 100644 (file)
@@ -1370,8 +1370,9 @@ fully_constant_vn_reference_p (vn_reference_t ref)
          else
            {
              unsigned char buf[MAX_BITSIZE_MODE_ANY_MODE / BITS_PER_UNIT];
-             if (native_encode_expr (ctor, buf, size, off) > 0)
-               return native_interpret_expr (ref->type, buf, size);
+             int len = native_encode_expr (ctor, buf, size, off);
+             if (len > 0)
+               return native_interpret_expr (ref->type, buf, len);
            }
        }
     }