From: Jakub Jelinek Date: Thu, 10 Dec 2015 10:14:38 +0000 (+0100) Subject: re PR middle-end/68785 (valgrind reports issues with folding on x86_64) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1ff0a84c3d3c0e8257a3837bf9f5d7f09f2f131e;p=gcc.git re PR middle-end/68785 (valgrind reports issues with folding on x86_64) 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index eac59176108..50e6e7a39a6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2015-12-10 Jakub Jelinek + + 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 PR ipa/68331 diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 6ff5e266d42..6f8ec6f90a6 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -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) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6141624b7b9..fd5fc3e5913 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-12-10 Jakub Jelinek + + PR tree-optimization/68785 + * gcc.dg/pr68785.c: New test. + 2015-12-10 Richard Biener PR ipa/68331 diff --git a/gcc/testsuite/gcc.dg/pr68785.c b/gcc/testsuite/gcc.dg/pr68785.c new file mode 100644 index 00000000000..f4257da4dd8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr68785.c @@ -0,0 +1,9 @@ +/* PR tree-optimization/68785 */ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +int +foo (void) +{ + return *(int *) ""; +} diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 2014ee7a7eb..3086f84f39e 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -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); } } }