diff options
author | Martin Liska <mliska@suse.cz> | 2021-12-30 14:34:08 +0100 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2021-12-30 14:34:08 +0100 |
commit | 3710ef43346d9c666fa8175812806d20ebd4e380 (patch) | |
tree | a4921408674e35db5c07786bf949e9fc9bf8f096 /gcc | |
parent | 50c93d3fa3f1394dbe992e287a934e2a523b787c (diff) | |
parent | 73898bc006ee9bec1a5eed4bfdd4eb0b158b7838 (diff) | |
download | gcc-3710ef43346d9c666fa8175812806d20ebd4e380.zip gcc-3710ef43346d9c666fa8175812806d20ebd4e380.tar.gz gcc-3710ef43346d9c666fa8175812806d20ebd4e380.tar.bz2 |
Merge branch 'master' into devel/sphinx
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 59 | ||||
-rw-r--r-- | gcc/DATESTAMP | 2 | ||||
-rw-r--r-- | gcc/c-family/c-cppbuiltin.c | 6 | ||||
-rw-r--r-- | gcc/config/aarch64/aarch64-c.c | 2 | ||||
-rw-r--r-- | gcc/config/arm/arm-c.c | 2 | ||||
-rw-r--r-- | gcc/config/i386/i386-c.c | 4 | ||||
-rw-r--r-- | gcc/config/s390/s390-c.c | 2 | ||||
-rw-r--r-- | gcc/doc/cpp.texi | 2 | ||||
-rw-r--r-- | gcc/fortran/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/fortran/expr.c | 3 | ||||
-rw-r--r-- | gcc/fortran/match.c | 3 | ||||
-rw-r--r-- | gcc/fortran/primary.c | 1 | ||||
-rw-r--r-- | gcc/fortran/resolve.c | 9 | ||||
-rw-r--r-- | gcc/go/gofrontend/MERGE | 2 | ||||
-rw-r--r-- | gcc/go/gofrontend/types.cc | 15 | ||||
-rw-r--r-- | gcc/godump.c | 2 | ||||
-rw-r--r-- | gcc/loop-invariant.c | 17 | ||||
-rw-r--r-- | gcc/shrink-wrap.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 22 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp/pr103012.C | 18 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/opt/pr103742.C | 36 | ||||
-rw-r--r-- | gcc/testsuite/g++.target/i386/pr103012.C | 19 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/loop-invariant-2.c | 20 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr103860.c | 31 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/pr102332.f90 | 69 | ||||
-rw-r--r-- | gcc/testsuite/lib/prune.exp | 7 | ||||
-rw-r--r-- | gcc/tree-ssa-dce.c | 38 |
27 files changed, 387 insertions, 19 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3c37502..6e8901c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,62 @@ +2021-12-29 Ian Lance Taylor <iant@golang.org> + + PR go/103847 + * godump.c (go_force_record_alignment): Name the alignment + field "_". + +2021-12-29 Jakub Jelinek <jakub@redhat.com> + + PR debug/103742 + * tree-ssa-dce.c (make_forwarders_with_degenerate_phis): If any phi + argument is not CONSTANT_CLASS_P or SSA_NAME and any arguments are + equal, change second from hash value to lowest dest_idx from the + edges which have equal argument and resort to ensure -fcompare-debug + stability. + +2021-12-29 Martin Liska <mliska@suse.cz> + + * collect2.c (main): Add ld.mold. + * common.opt: Add -fuse-ld=mold. + * doc/invoke.texi: Document it. + * gcc.c (driver_handle_option): Handle -fuse-ld=mold. + * opts.c (common_handle_option): Likewise. + +2021-12-29 Uroš Bizjak <ubizjak@gmail.com> + + * config/i386/sse.md (vec_pack<floatprefix>_float_<mode>): + Perform gen_avx512dq_float<floatunssuffix>v2div2sf2 into a + pseudo and emit move insn into operands[0]. + (fix<fixunssuffix>_truncv2sfv2di2): Use lowpart_subreg + instead of simplify_gen_subreg. + (trunc<mode><pmov_dst_3_lower>2): Perform + gen_avx512vl_truncate<mode>v<ssescalarnum>qi2 into a + pseudo and emit move insn into operands[0]. + (trunc<mode><pmov_dst_4_lower>2): Perform + gen_avx512vl_truncate<mode>v<ssescalarnum>hi2 into a + pseudo and emit move insn into operands[0]. + (truncv2div2si2): Perform gen_avx512vl_truncatev2div2si2 into a + pseudo and emit move insn into operands[0]. + (truncv8div8qi2): Perform gen_avx512f_truncatev8div16qi2 into a + pseudo and emit move insn into operands[0]. + (<any_extend:insn>v8qiv8hi2): Use lowpart_subreg + instead of simplify_gen_subreg. + (<any_extend:insn>v8qiv8si2): Ditto. + (<any_extend:insn>v4qiv4si2): Ditto. + (<any_extend:insn>v4hiv4si2): Ditto. + (<any_extend:insn>v8qiv8di2): Ditto. + (<any_extend:insn>v4qiv4di2): Ditto. + (<any_extend:insn>v2qiv2di2): Ditto. + (<any_extend:insn>v4hiv4di2): Ditto. + (<any_extend:insn>v2hiv2di2): Ditto. + (<any_extend:insn>v2siv2di2): Ditto. + +2021-12-29 Xionghu Luo <luoxhu@linux.ibm.com> + + PR tree-optimization/103793 + * tree-ssa-loop-split.c (fix_loop_bb_probability): New function. + (split_loop): Use multiply to scale loop1's exit probability. + (do_split_loop_on_cond): Call fix_loop_bb_probability. + 2021-12-28 Jason Merrill <jason@redhat.com> PR c++/99968 diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index 252ebb2..86d9845 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20211229 +20211230 diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c index feb7e61..339dd2b 100644 --- a/gcc/c-family/c-cppbuiltin.c +++ b/gcc/c-family/c-cppbuiltin.c @@ -589,6 +589,10 @@ c_cpp_builtins_optimize_pragma (cpp_reader *pfile, tree prev_tree, if (flag_undef) return; + /* Make sure all of the builtins about to be declared have + BUILTINS_LOCATION has their location_t. */ + cpp_force_token_locations (parse_in, BUILTINS_LOCATION); + /* Other target-independent built-ins determined by command-line options. */ if (!prev->x_optimize_size && cur->x_optimize_size) @@ -653,6 +657,8 @@ c_cpp_builtins_optimize_pragma (cpp_reader *pfile, tree prev_tree, cpp_define_unused (pfile, "__ROUNDING_MATH__"); else if (prev->x_flag_rounding_math && !cur->x_flag_rounding_math) cpp_undef (pfile, "__ROUNDING_MATH__"); + + cpp_stop_forcing_token_locations (parse_in); } diff --git a/gcc/config/aarch64/aarch64-c.c b/gcc/config/aarch64/aarch64-c.c index 3af3e5c..a2fab4d 100644 --- a/gcc/config/aarch64/aarch64-c.c +++ b/gcc/config/aarch64/aarch64-c.c @@ -259,7 +259,9 @@ aarch64_pragma_target_parse (tree args, tree pop_target) unsigned char saved_warn_unused_macros = cpp_opts->warn_unused_macros; cpp_opts->warn_unused_macros = 0; + cpp_force_token_locations (parse_in, BUILTINS_LOCATION); aarch64_update_cpp_builtins (parse_in); + cpp_stop_forcing_token_locations (parse_in); cpp_opts->warn_unused_macros = saved_warn_unused_macros; diff --git a/gcc/config/arm/arm-c.c b/gcc/config/arm/arm-c.c index d1414f6..787eaf3 100644 --- a/gcc/config/arm/arm-c.c +++ b/gcc/config/arm/arm-c.c @@ -464,7 +464,9 @@ arm_pragma_target_parse (tree args, tree pop_target) acond_macro = get_identifier ("__ARM_FEATURE_LDREX"); C_CPP_HASHNODE (acond_macro)->flags |= NODE_CONDITIONAL; + cpp_force_token_locations (parse_in, BUILTINS_LOCATION); arm_cpu_builtins (parse_in); + cpp_stop_forcing_token_locations (parse_in); cpp_opts->warn_unused_macros = saved_warn_unused_macros; diff --git a/gcc/config/i386/i386-c.c b/gcc/config/i386/i386-c.c index cc64f85..144d452 100644 --- a/gcc/config/i386/i386-c.c +++ b/gcc/config/i386/i386-c.c @@ -702,12 +702,14 @@ ix86_pragma_target_parse (tree args, tree pop_target) cur_tune = prev_tune = PROCESSOR_max; /* Undef all of the macros for that are no longer current. */ + cpp_force_token_locations (parse_in, BUILTINS_LOCATION); ix86_target_macros_internal (prev_isa & diff_isa, prev_isa2 & diff_isa2, prev_arch, prev_tune, (enum fpmath_unit) prev_opt->x_ix86_fpmath, cpp_undef); + cpp_stop_forcing_token_locations (parse_in); /* For the definitions, ensure all newly defined macros are considered as used for -Wunused-macros. There is no point warning about the @@ -717,12 +719,14 @@ ix86_pragma_target_parse (tree args, tree pop_target) cpp_opts->warn_unused_macros = 0; /* Define all of the macros for new options that were just turned on. */ + cpp_force_token_locations (parse_in, BUILTINS_LOCATION); ix86_target_macros_internal (cur_isa & diff_isa, cur_isa2 & diff_isa2, cur_arch, cur_tune, (enum fpmath_unit) cur_opt->x_ix86_fpmath, cpp_define); + cpp_stop_forcing_token_locations (parse_in); cpp_opts->warn_unused_macros = saved_warn_unused_macros; diff --git a/gcc/config/s390/s390-c.c b/gcc/config/s390/s390-c.c index 4cce261..74601a0 100644 --- a/gcc/config/s390/s390-c.c +++ b/gcc/config/s390/s390-c.c @@ -457,7 +457,9 @@ s390_pragma_target_parse (tree args, tree pop_target) cpp_opts->warn_unused_macros = 0; /* Define all of the macros for new options that were just turned on. */ + cpp_force_token_locations (parse_in, BUILTINS_LOCATION); s390_cpu_cpp_builtins_internal (parse_in, cur_opt, prev_opt); + cpp_stop_forcing_token_locations (parse_in); cpp_opts->warn_unused_macros = saved_warn_unused_macros; } diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi index be05777..ae21eb9 100644 --- a/gcc/doc/cpp.texi +++ b/gcc/doc/cpp.texi @@ -4167,7 +4167,7 @@ IP2K, MMIX, MIPS Irix 3, ARM aout, and PowerPC targets for the AIX operating system. You can override the default with @option{-fdollars-in-identifiers} or -@option{fno-dollars-in-identifiers}. @xref{fdollars-in-identifiers}. +@option{-fno-dollars-in-identifiers}. @xref{fdollars-in-identifiers}. @item Non-empty sequences of whitespace characters. diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 65f52f3..c982afb 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,13 @@ +2021-12-29 Harald Anlauf <anlauf@gmx.de> + + PR fortran/102332 + * expr.c (gfc_get_variable_expr): Avoid NULL pointer dereferences + during handling of errors with invalid uses of CLASS variables. + * match.c (select_type_set_tmp): Likewise. + * primary.c (gfc_match_varspec): Likewise. + * resolve.c (resolve_variable): Likewise. + (resolve_select_type): Likewise. + 2021-12-28 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> PR fortran/103828 diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index b874607..c1258e0 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -5166,7 +5166,8 @@ gfc_get_variable_expr (gfc_symtree *var) if (var->n.sym->attr.flavor != FL_PROCEDURE && ((var->n.sym->as != NULL && var->n.sym->ts.type != BT_CLASS) - || (var->n.sym->ts.type == BT_CLASS && CLASS_DATA (var->n.sym) + || (var->n.sym->ts.type == BT_CLASS && var->n.sym->ts.u.derived + && CLASS_DATA (var->n.sym) && CLASS_DATA (var->n.sym)->as))) { e->rank = var->n.sym->ts.type == BT_CLASS diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index 617fb35..41faa53 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -6363,7 +6363,8 @@ select_type_set_tmp (gfc_typespec *ts) sym = tmp->n.sym; gfc_add_type (sym, ts, NULL); - if (selector->ts.type == BT_CLASS && selector->attr.class_ok) + if (selector->ts.type == BT_CLASS && selector->attr.class_ok + && selector->ts.u.derived && CLASS_DATA (selector)) { sym->attr.pointer = CLASS_DATA (selector)->attr.class_pointer; diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c index d873264..1f63028 100644 --- a/gcc/fortran/primary.c +++ b/gcc/fortran/primary.c @@ -2151,6 +2151,7 @@ gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag, && !(gfc_matching_procptr_assignment && sym->attr.flavor == FL_PROCEDURE)) || (sym->ts.type == BT_CLASS && sym->attr.class_ok + && sym->ts.u.derived && CLASS_DATA (sym) && (CLASS_DATA (sym)->attr.dimension || CLASS_DATA (sym)->attr.codimension))) { diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index bff1b35..591e818 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -5736,6 +5736,8 @@ resolve_variable (gfc_expr *e) can't be translated that way. */ if (sym->assoc && e->rank == 0 && e->ref && sym->ts.type == BT_CLASS && sym->assoc->target && sym->assoc->target->ts.type == BT_CLASS + && sym->assoc->target->ts.u.derived + && CLASS_DATA (sym->assoc->target) && CLASS_DATA (sym->assoc->target)->as) { gfc_ref *ref = e->ref; @@ -5799,7 +5801,8 @@ resolve_variable (gfc_expr *e) /* Like above, but for class types, where the checking whether an array ref is present is more complicated. Furthermore make sure not to add the full array ref to _vptr or _len refs. */ - if (sym->assoc && sym->ts.type == BT_CLASS + if (sym->assoc && sym->ts.type == BT_CLASS && sym->ts.u.derived + && CLASS_DATA (sym) && CLASS_DATA (sym)->attr.dimension && (e->ts.type != BT_DERIVED || !e->ts.u.derived->attr.vtype)) { @@ -9432,6 +9435,7 @@ resolve_select_type (gfc_code *code, gfc_namespace *old_ns) /* Check F03:C815. */ if ((c->ts.type == BT_DERIVED || c->ts.type == BT_CLASS) + && selector_type && !selector_type->attr.unlimited_polymorphic && !gfc_type_is_extensible (c->ts.u.derived)) { @@ -9442,7 +9446,8 @@ resolve_select_type (gfc_code *code, gfc_namespace *old_ns) } /* Check F03:C816. */ - if (c->ts.type != BT_UNKNOWN && !selector_type->attr.unlimited_polymorphic + if (c->ts.type != BT_UNKNOWN + && selector_type && !selector_type->attr.unlimited_polymorphic && ((c->ts.type != BT_DERIVED && c->ts.type != BT_CLASS) || !gfc_type_is_extension_of (selector_type, c->ts.u.derived))) { diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 05e47ec..2d04f4b 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -3e9f4ee16683883ccfb8661d99318c74bb7a4bef +d3be41f0a1fca20e241e1db62b4b0f5262caac55 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc index 0f66661..57c02a9 100644 --- a/gcc/go/gofrontend/types.cc +++ b/gcc/go/gofrontend/types.cc @@ -6454,9 +6454,18 @@ get_backend_struct_fields(Gogo* gogo, Struct_type* type, bool use_placeholder, ? p->type()->get_backend_placeholder(gogo) : p->type()->get_backend(gogo)); (*bfields)[i].location = p->location(); - lastsize = gogo->backend()->type_size((*bfields)[i].btype); - if (lastsize != 0) - saw_nonzero = true; + int64_t size = gogo->backend()->type_size((*bfields)[i].btype); + if (size != 0) + saw_nonzero = true; + + if (size > 0 || !Gogo::is_sink_name(p->field_name())) + lastsize = size; + else + { + // There is an unreferenceable field of zero size. This + // doesn't affect whether we may need zero padding, so leave + // lastsize unchanged. + } } go_assert(i == fields->size()); if (saw_nonzero && lastsize == 0 && !type->is_results_struct()) diff --git a/gcc/godump.c b/gcc/godump.c index a50aef1..f016989 100644 --- a/gcc/godump.c +++ b/gcc/godump.c @@ -651,7 +651,7 @@ go_force_record_alignment (struct obstack *ob, const char *type_string, unsigned int index, const char *error_string) { index = go_append_artificial_name (ob, index); - obstack_grow (ob, "_align ", 7); + obstack_grow (ob, "_ ", 2); if (type_string == NULL) obstack_grow (ob, error_string, strlen (error_string)); else diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c index be95155..d69a0c1 100644 --- a/gcc/loop-invariant.c +++ b/gcc/loop-invariant.c @@ -1183,9 +1183,21 @@ find_invariants_insn (rtx_insn *insn, bool always_reached, bool always_executed) call. */ static void -find_invariants_bb (basic_block bb, bool always_reached, bool always_executed) +find_invariants_bb (class loop *loop, basic_block bb, bool always_reached, + bool always_executed) { rtx_insn *insn; + basic_block preheader = loop_preheader_edge (loop)->src; + + /* Don't move insn of cold BB out of loop to preheader to reduce calculations + and register live range in hot loop with cold BB. */ + if (!always_executed && preheader->count > bb->count) + { + if (dump_file) + fprintf (dump_file, "Don't move invariant from bb: %d out of loop %d\n", + bb->index, loop->num); + return; + } FOR_BB_INSNS (bb, insn) { @@ -1214,8 +1226,7 @@ find_invariants_body (class loop *loop, basic_block *body, unsigned i; for (i = 0; i < loop->num_nodes; i++) - find_invariants_bb (body[i], - bitmap_bit_p (always_reached, i), + find_invariants_bb (loop, body[i], bitmap_bit_p (always_reached, i), bitmap_bit_p (always_executed, i)); } diff --git a/gcc/shrink-wrap.c b/gcc/shrink-wrap.c index 5e60f34..35149ec 100644 --- a/gcc/shrink-wrap.c +++ b/gcc/shrink-wrap.c @@ -781,7 +781,7 @@ try_shrink_wrapping (edge *entry_edge, rtx_insn *prologue_seq) unsigned max_grow_size = get_uncond_jump_length (); max_grow_size *= param_max_grow_copy_bb_insns; - while (!vec.is_empty () && pro != entry) + while (pro != entry) { while (pro != entry && !can_get_prologue (pro, prologue_clobbered)) { @@ -791,6 +791,9 @@ try_shrink_wrapping (edge *entry_edge, rtx_insn *prologue_seq) vec.quick_push (pro); } + if (vec.is_empty ()) + break; + basic_block bb = vec.pop (); if (!can_dup_for_shrink_wrapping (bb, pro, max_grow_size)) while (!dominated_by_p (CDI_DOMINATORS, bb, pro)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6c6a732..53346a8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,25 @@ +2021-12-29 Jakub Jelinek <jakub@redhat.com> + + PR debug/103742 + * g++.dg/opt/pr103742.C: New test. + +2021-12-29 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> + + PR testsuite/47334 + PR testsuite/103823 + * lib/prune.exp: Prune some warnings related to LTO and + visibility. + +2021-12-29 Harald Anlauf <anlauf@gmx.de> + + PR fortran/102332 + * gfortran.dg/pr102332.f90: New test. + +2021-12-29 Xionghu Luo <luoxhu@linux.ibm.com> + + PR tree-optimization/103793 + * gcc.dg/pr103793.c: New test. + 2021-12-28 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> PR fortran/103828 diff --git a/gcc/testsuite/g++.dg/cpp/pr103012.C b/gcc/testsuite/g++.dg/cpp/pr103012.C new file mode 100644 index 0000000..a172419 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp/pr103012.C @@ -0,0 +1,18 @@ +// PR c++/103012 +// { dg-do compile } + +int a = 1; +#pragma GCC optimize "Og" +#define A(a) a + +#define B(a) A(a)A(a) +#define C(a) B(a)B(a) +#define D(a) C(a)C(a) +#define E(a) D(a)D(a) +#define F(a) E(a)E(a) +#define G(a) F(a)F(a) +#define H(a) G(a)G(a) +#define I(a) H(a)H(a) +#define J(a) I(a)I(a) +#define K(a) J(a)J(a) +#define L(a) K(a)K(a) +int b = L(a) 1; diff --git a/gcc/testsuite/g++.dg/opt/pr103742.C b/gcc/testsuite/g++.dg/opt/pr103742.C new file mode 100644 index 0000000..6155d22 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr103742.C @@ -0,0 +1,36 @@ +// PR debug/103742 +// { dg-do compile { target c++17 } } +// { dg-options "-O2 -fnon-call-exceptions --param=early-inlining-insns=82 -fcompare-debug" } + +template <typename T> T max(T a, T b) { return a >= b ? a : b; } +template <typename T> T abs(T); +template <int T, int U> struct A { + long a; + A(A &x) { a = x.a; } + A(long); + A foo(A) { + if (abs(a) && a == a) + a = a ? U : T; + else + a += a; + return *this; + } + bool operator>=(A) { return a; } +}; +struct B {}; +struct C { + A<2147483647, 0> c; +}; +struct D { + A<2147483647, 0> d; + C e[]; +}; +struct E : D{} * f; +A<2147483647, 0> bar() { + A<2147483647, 0> g = g.foo(f->d); + return max(g, (A<2147483647, 0>)1); +} +E *h; +void baz() { + h->e[0].c = bar(); +} diff --git a/gcc/testsuite/g++.target/i386/pr103012.C b/gcc/testsuite/g++.target/i386/pr103012.C new file mode 100644 index 0000000..2c9a8cd --- /dev/null +++ b/gcc/testsuite/g++.target/i386/pr103012.C @@ -0,0 +1,19 @@ +// PR c++/103012 +// { dg-do compile } +// { dg-options "-mno-avx2" } + +int a = 1; +#pragma GCC target "avx2" +#define A(a) a + +#define B(a) A(a)A(a) +#define C(a) B(a)B(a) +#define D(a) C(a)C(a) +#define E(a) D(a)D(a) +#define F(a) E(a)E(a) +#define G(a) F(a)F(a) +#define H(a) G(a)G(a) +#define I(a) H(a)H(a) +#define J(a) I(a)I(a) +#define K(a) J(a)J(a) +#define L(a) K(a)K(a) +int b = L(a) 1; diff --git a/gcc/testsuite/gcc.dg/loop-invariant-2.c b/gcc/testsuite/gcc.dg/loop-invariant-2.c new file mode 100644 index 0000000..df3d845 --- /dev/null +++ b/gcc/testsuite/gcc.dg/loop-invariant-2.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-rtl-loop2_invariant" } */ + +volatile int x; +void +bar (int, char *, char *); +void +foo (int *a, int n, int k) +{ + int i; + + for (i = 0; i < n; i++) + { + if (__builtin_expect (x, 0)) + bar (k / 5, "one", "two"); + a[i] = k; + } +} + +/* { dg-final { scan-rtl-dump "Don't move invariant from bb: .*out of loop" "loop2_invariant" } } */ diff --git a/gcc/testsuite/gcc.dg/pr103860.c b/gcc/testsuite/gcc.dg/pr103860.c new file mode 100644 index 0000000..15eee55 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr103860.c @@ -0,0 +1,31 @@ +/* PR rtl-optimization/103860 */ +/* { dg-do run } */ +/* { dg-options "-O3" } */ +/* { dg-additional-options "-fPIC" { target fpic } } */ + +static int d, *e; +int f; + +__attribute__((noinline)) signed char +foo (signed char b, signed char c) +{ + return b + c; +} + +int +main () +{ + signed char l; + for (l = -1; l; l = foo (l, 1)) + { + while (d < 0) + ; + if (d > 0) + { + f = 0; + *e = 0; + } + } + d = 0; + return 0; +} diff --git a/gcc/testsuite/gfortran.dg/pr102332.f90 b/gcc/testsuite/gfortran.dg/pr102332.f90 new file mode 100644 index 0000000..f955709 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr102332.f90 @@ -0,0 +1,69 @@ +! { dg-do compile } +! PR fortran/102332 - ICE in select_type_set_tmp +! Contributed by G.Steinmetz + +program p + type t + real :: a, b + end type + class(t), allocatable :: x ! Valid + select type (y => x) + type is (t) + y%a = 0 + end select +end + +subroutine s0 (x) + type t + real :: a, b + end type + class(t) :: x ! Valid + select type (y => x) + type is (t) + y%a = 0 + end select +end + +subroutine s1 + type t + real :: a, b + end type + class(t) :: x ! { dg-error "must be dummy, allocatable or pointer" } + select type (y => x) + type is (t) + y%a = 0 + end select +end + +subroutine s3 + type t + real :: a, b + end type + class(t) :: x ! { dg-error "must be dummy, allocatable or pointer" } + select type (y => x) + class is (t) + y%a = 0 + end select +end + +subroutine s2 + type t + real :: a, b + end type + class(t) :: x ! { dg-error "must be dummy, allocatable or pointer" } + select type (y => x) + type default ! { dg-error "Expected" } + y%a = 0 + end select +end + +subroutine s4 + type t + real :: a, b + end type + class(t) :: x ! { dg-error "must be dummy, allocatable or pointer" } + select type (y => x) + class default + y%a = 0 + end select +end diff --git a/gcc/testsuite/lib/prune.exp b/gcc/testsuite/lib/prune.exp index 1314248..533e31d 100644 --- a/gcc/testsuite/lib/prune.exp +++ b/gcc/testsuite/lib/prune.exp @@ -96,6 +96,13 @@ proc prune_gcc_output { text } { # Ignore stabs obsoletion warnings regsub -all "(^|\n)\[^\n\]*\[Ww\]arning: STABS debugging information is obsolete and not supported anymore\[^\n\]*" $text "" text + # Ignore missing lto jobserver for tests that do more than 1 LTRANS unit + regsub -all "(^|\n)\[^\n\]*lto\[^\n\]*: warning: using serial compilation of \[^\n\]*" $text "" text + regsub -all "(^|\n)\[^\n\]*lto\[^\n\]*: note: see the \[^\n\]*'-flto' option documentation\[^\n\]* for more information" $text "" text + + # Many tests that use visibility will still pass on platforms that don't support it. + regsub -all "(^|\n)\[^\n\]*lto1: warning: visibility attribute not supported in this configuration; ignored\[^\n\]*" $text "" text + # If dg-enable-nn-line-numbers was provided, then obscure source-margin # line numbers by converting them to "NN" form. set text [maybe-handle-nn-line-numbers $text] diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c index 1f817b9..6a6da09 100644 --- a/gcc/tree-ssa-dce.c +++ b/gcc/tree-ssa-dce.c @@ -1671,6 +1671,7 @@ make_forwarders_with_degenerate_phis (function *fn) continue; gphi *phi = gsi.phi (); auto_vec<std::pair<edge, hashval_t>, 8> args; + bool need_resort = false; for (unsigned i = 0; i < gimple_phi_num_args (phi); ++i) { edge e = gimple_phi_arg_edge (phi, i); @@ -1682,12 +1683,42 @@ make_forwarders_with_degenerate_phis (function *fn) if (loops_state_satisfies_p (LOOP_CLOSED_SSA) && loop_exit_edge_p (e->src->loop_father, e)) continue; - args.safe_push (std::make_pair (e, iterative_hash_expr - (gimple_phi_arg_def (phi, i), 0))); + + tree arg = gimple_phi_arg_def (phi, i); + if (!CONSTANT_CLASS_P (arg) && TREE_CODE (arg) != SSA_NAME) + need_resort = true; + args.safe_push (std::make_pair (e, iterative_hash_expr (arg, 0))); } if (args.length () < 2) continue; args.qsort (sort_phi_args); + /* The above sorting can be different between -g and -g0, as e.g. decls + can have different uids (-g could have bigger gaps in between them). + So, only use that to determine which args are equal, then change + second from hash value to smallest dest_idx of the edges which have + equal argument and sort again. If all the phi arguments are + constants or SSA_NAME, there is no need for the second sort, the hash + values are stable in that case. */ + hashval_t hash = args[0].second; + args[0].second = args[0].first->dest_idx; + bool any_equal = false; + for (unsigned i = 1; i < args.length (); ++i) + if (hash == args[i].second + && operand_equal_p (PHI_ARG_DEF_FROM_EDGE (phi, args[i - 1].first), + PHI_ARG_DEF_FROM_EDGE (phi, args[i].first))) + { + args[i].second = args[i - 1].second; + any_equal = true; + } + else + { + hash = args[i].second; + args[i].second = args[i].first->dest_idx; + } + if (!any_equal) + continue; + if (need_resort) + args.qsort (sort_phi_args); /* From the candidates vector now verify true candidates for forwarders and create them. */ @@ -1697,8 +1728,7 @@ make_forwarders_with_degenerate_phis (function *fn) { unsigned i; for (i = start + 1; i < args.length (); ++i) - if (!operand_equal_p (PHI_ARG_DEF_FROM_EDGE (phi, args[start].first), - PHI_ARG_DEF_FROM_EDGE (phi, args[i].first))) + if (args[start].second != args[i].second) break; /* args[start]..args[i-1] are equal. */ if (start != i - 1) |