From: Richard Biener Date: Fri, 16 Feb 2018 07:56:16 +0000 (+0000) Subject: re PR c/84190 (double arithmetic on x86 no longer rounds to nearest) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bd74f4d876ffa7090603bb5d317d7b6e52df43c0;p=gcc.git re PR c/84190 (double arithmetic on x86 no longer rounds to nearest) 2018-02-16 Richard Biener PR tree-optimization/84190 * tree-ssa.c (non_rewritable_mem_ref_base): Do not touch volatile accesses if the decl isn't volatile. * g++.dg/torture/pr84190.C: New testcase. From-SVN: r257721 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4062532e804..8ca7fba1714 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-02-16 Richard Biener + + PR tree-optimization/84190 + * tree-ssa.c (non_rewritable_mem_ref_base): Do not touch + volatile accesses if the decl isn't volatile. + 2018-02-15 Jason Merrill PR c++/84314 - ICE with templates and fastcall attribute. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 11da4b2caff..8c0e0f0d97d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-02-16 Richard Biener + + PR tree-optimization/84190 + * g++.dg/torture/pr84190.C: New testcase. + 2018-02-15 Martin Sebor * gcc.dg/lto/README (dg-lto-warning, dg-lto-message): Document new diff --git a/gcc/testsuite/g++.dg/torture/pr84190.C b/gcc/testsuite/g++.dg/torture/pr84190.C new file mode 100644 index 00000000000..a7bab944365 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr84190.C @@ -0,0 +1,20 @@ +// { dg-do compile } +// For slim LTO there's no optimized dump +// { dg-skip-if "" { *-*-* } { "-flto" } { "" } } +// { dg-additional-options "-fdump-tree-optimized" } + +typedef double T; +static int equalfn (volatile T* x, volatile T* y); +T gx, gy; +int main () +{ + T x = gx, y = gy; + return equalfn (&x, &y); +} +static int equalfn (volatile T* x, volatile T* y) +{ + return (*x == *y); +} + +// There should be exactly two volatile accesses (ignoring clobbers). +// { dg-final { scan-tree-dump-times " ={v} \[^\{\]" 2 "optimized" } } diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index ee311ce9758..949b951e1aa 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -1427,7 +1427,8 @@ non_rewritable_mem_ref_base (tree ref) if (! DECL_P (decl)) return NULL_TREE; if (! is_gimple_reg_type (TREE_TYPE (base)) - || VOID_TYPE_P (TREE_TYPE (base))) + || VOID_TYPE_P (TREE_TYPE (base)) + || TREE_THIS_VOLATILE (decl) != TREE_THIS_VOLATILE (base)) return decl; if ((TREE_CODE (TREE_TYPE (decl)) == VECTOR_TYPE || TREE_CODE (TREE_TYPE (decl)) == COMPLEX_TYPE)