From: Richard Biener Date: Wed, 10 Jul 2019 13:24:32 +0000 (+0000) Subject: gimple-parser.c (c_parser_gimple_postfix_expression): Support _Literal (int *) &x... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8389386c6d55d57afc3ae01f71546ac4468f7926;p=gcc.git gimple-parser.c (c_parser_gimple_postfix_expression): Support _Literal (int *) &x for address literals. 2019-07-10 Richard Biener c/ * gimple-parser.c (c_parser_gimple_postfix_expression): Support _Literal (int *) &x for address literals. * tree-ssa-sccvn.c (vn_reference_lookup_3): Look at valueized LHS whenever possible. * gcc.dg/torture/ssa-fre-5.c: New testcase. * gcc.dg/torture/ssa-fre-6.c: Likewise. * gcc.dg/torture/ssa-fre-7.c: Likewise. From-SVN: r273354 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2f986338393..ac390d65ae7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2019-07-10 Richard Biener + + * tree-ssa-sccvn.c (vn_reference_lookup_3): Look at valueized + LHS whenever possible. + 2019-07-09 Jan Hubicka * tree-ssa-alias.c (nonoverlapping_component_refs_p_1): Break out diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 29836ff9595..bb0573e5401 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2019-07-10 Richard Biener + + * gimple-parser.c (c_parser_gimple_postfix_expression): Support + _Literal (int *) &x for address literals. + 2019-07-09 Martin Sebor PR c++/61339 diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c index 9a65394a020..a0ea7215984 100644 --- a/gcc/c/gimple-parser.c +++ b/gcc/c/gimple-parser.c @@ -1606,8 +1606,10 @@ c_parser_gimple_postfix_expression (gimple_parser &parser) tree val = c_parser_gimple_postfix_expression (parser).value; if (! val || val == error_mark_node - || ! CONSTANT_CLASS_P (val) - || (addr_p && TREE_CODE (val) != STRING_CST)) + || (!CONSTANT_CLASS_P (val) + && !(addr_p + && (TREE_CODE (val) == STRING_CST + || DECL_P (val))))) { c_parser_error (parser, "invalid _Literal"); return expr; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a953397db93..840d9c1f251 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2019-07-10 Richard Biener + + * gcc.dg/torture/ssa-fre-5.c: New testcase. + * gcc.dg/torture/ssa-fre-6.c: Likewise. + * gcc.dg/torture/ssa-fre-7.c: Likewise. + 2019-07-10 Ed Schonberg * gnat.dg/modular5.adb: New testcase. diff --git a/gcc/testsuite/gcc.dg/torture/ssa-fre-5.c b/gcc/testsuite/gcc.dg/torture/ssa-fre-5.c new file mode 100644 index 00000000000..5ee9d64204c --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/ssa-fre-5.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */ +/* { dg-additional-options "-fgimple -fdump-tree-fre1" } */ + +typedef int v4si __attribute__((vector_size(16))); + +int __GIMPLE (ssa,startwith("fre")) +foo () +{ + int * p; + int i; + int x[4]; + long unsigned int _1; + long unsigned int _2; + int _7; + + __BB(2): + i_3 = 0; + _1 = (long unsigned int) i_3; + _2 = _1 * 4ul; + p_4 = _Literal (int *) &x + _2; + __MEM ((v4si *)p_4) = _Literal (v4si) { 1, 2, 3, 4 }; + _7 = x[0]; + return _7; +} + +/* { dg-final { scan-tree-dump "return 1;" "fre1" } } */ diff --git a/gcc/testsuite/gcc.dg/torture/ssa-fre-6.c b/gcc/testsuite/gcc.dg/torture/ssa-fre-6.c new file mode 100644 index 00000000000..ecdd8f64e95 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/ssa-fre-6.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */ +/* { dg-additional-options "-fgimple -fdump-tree-fre1" } */ + +typedef int v4si __attribute__((vector_size(16))); + +int __GIMPLE (ssa,startwith("fre")) +foo () +{ + int * p; + int i; + int x[4]; + long unsigned int _1; + long unsigned int _2; + int _7; + + __BB(2): + i_3 = 0; + _1 = (long unsigned int) i_3; + _2 = _1 * 4ul; + p_4 = _Literal (int *) &x + _2; + __MEM ((v4si *)p_4) = _Literal (v4si) {}; + _7 = x[0]; + return _7; +} + +/* { dg-final { scan-tree-dump "return 0;" "fre1" } } */ diff --git a/gcc/testsuite/gcc.dg/torture/ssa-fre-7.c b/gcc/testsuite/gcc.dg/torture/ssa-fre-7.c new file mode 100644 index 00000000000..07f3c9dc567 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/ssa-fre-7.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */ +/* { dg-additional-options "-fgimple -fdump-tree-fre1" } */ + +typedef int v4si __attribute__((vector_size(16))); + +int __GIMPLE (ssa,startwith("fre")) +foo (int c) +{ + int * p; + int i; + int x[4]; + long unsigned int _1; + long unsigned int _2; + int _7; + v4si _6; + + __BB(2): + i_3 = 0; + _1 = (long unsigned int) i_3; + _2 = _1 * 4ul; + p_4 = _Literal (int *) &x + _2; + _6 = _Literal (v4si) { c_5(D), c_5(D), c_5(D), c_5(D) }; + __MEM ((v4si *)p_4) = _6; + _7 = x[0]; + return _7; +} + +/* { dg-final { scan-tree-dump "return c_5\\(D\\);" "fre1" } } */ diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 9186f15e39b..777cf58e43b 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -2488,12 +2488,22 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, && gimple_assign_rhs_code (def_stmt) == CONSTRUCTOR && CONSTRUCTOR_NELTS (gimple_assign_rhs1 (def_stmt)) == 0) { + tree lhs = gimple_assign_lhs (def_stmt); tree base2; poly_int64 offset2, size2, maxsize2; HOST_WIDE_INT offset2i, size2i; bool reverse; - base2 = get_ref_base_and_extent (gimple_assign_lhs (def_stmt), - &offset2, &size2, &maxsize2, &reverse); + if (lhs_ref_ok) + { + base2 = ao_ref_base (&lhs_ref); + offset2 = lhs_ref.offset; + size2 = lhs_ref.size; + maxsize2 = lhs_ref.max_size; + reverse = reverse_storage_order_for_component_p (lhs); + } + else + base2 = get_ref_base_and_extent (lhs, + &offset2, &size2, &maxsize2, &reverse); if (known_size_p (maxsize2) && known_eq (maxsize2, size2) && adjust_offsets_for_equal_base_address (base, &offset, @@ -2541,12 +2551,22 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, || (TREE_CODE (gimple_assign_rhs1 (def_stmt)) == SSA_NAME && is_gimple_min_invariant (SSA_VAL (gimple_assign_rhs1 (def_stmt)))))) { + tree lhs = gimple_assign_lhs (def_stmt); tree base2; poly_int64 offset2, size2, maxsize2; HOST_WIDE_INT offset2i, size2i; bool reverse; - base2 = get_ref_base_and_extent (gimple_assign_lhs (def_stmt), - &offset2, &size2, &maxsize2, &reverse); + if (lhs_ref_ok) + { + base2 = ao_ref_base (&lhs_ref); + offset2 = lhs_ref.offset; + size2 = lhs_ref.size; + maxsize2 = lhs_ref.max_size; + reverse = reverse_storage_order_for_component_p (lhs); + } + else + base2 = get_ref_base_and_extent (lhs, + &offset2, &size2, &maxsize2, &reverse); if (base2 && !reverse && known_eq (maxsize2, size2) @@ -2627,12 +2647,21 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, downstream, not so much for actually doing the insertion. */ && data->partial_defs.is_empty ()) { + tree lhs = gimple_assign_lhs (def_stmt); tree base2; poly_int64 offset2, size2, maxsize2; bool reverse; - base2 = get_ref_base_and_extent (gimple_assign_lhs (def_stmt), - &offset2, &size2, &maxsize2, - &reverse); + if (lhs_ref_ok) + { + base2 = ao_ref_base (&lhs_ref); + offset2 = lhs_ref.offset; + size2 = lhs_ref.size; + maxsize2 = lhs_ref.max_size; + reverse = reverse_storage_order_for_component_p (lhs); + } + else + base2 = get_ref_base_and_extent (lhs, + &offset2, &size2, &maxsize2, &reverse); tree def_rhs = gimple_assign_rhs1 (def_stmt); if (!reverse && known_size_p (maxsize2)