If a jump always falls through but that cannot be optimised away, like
is the case with the PowerPC bdnz insn if its jump target is the same as
the fallthrough, sched gets confused if it schedules some instructions
from before that jump instruction to behind it: it splits the
fallthrough branch, but the jump target isn't updated, and things fall
apart as in the PR. This patch fixes it.
The second patch fragment makes -fsched-verbose=N work for N>=4; the
currently scheduled fragment can now contain a label. Everything else
seems to work fine with that.
PR target/72749
* cfgrtl.c (rtl_split_edge): Also patch jump insns that jump to the
fallthrough.
* haifa-sched.c (dump_insn_stream): Don't crash if there is a label
in the currently scheduled RTL fragment.
From-SVN: r244477
As shown in the PR, ifcvt will happily make invalid insns when given the
chance. This patch teaches it some manners.
PR rtl-optimization/78751
* ifcvt.c (find_cond_trap): If we generated a non-existing insn,
give up.
From-SVN: r244476
PR tree-optimization/79090
* tree-ssa-dse.c (valid_ao_ref_for_dse): Reject zero length and
variable length stores.
(compute_trims): Delete dead assignment to *trim_tail.
(dse_dom_walker::dse_optimize_stmt): Optimize mem* calls with
zero length.
From-SVN: r244472
PR rtl-optimization/78626
PR rtl-optimization/78727
* cprop.c (one_cprop_pass): Collect unconditional traps in the middle
of a block, and split such blocks after everything else is finished.
PR rtl-optimization/78626
PR rtl-optimization/78727
* gcc.dg/torture/pr78626.c: New test.
* gcc.dg/torture/pr78727.c: New test.
From-SVN: r244467
Rather than using unspecs in doloop insns to stop combine creating
these insns, use legitimate_combined_insn.
PR target/72749
* combine.c (recog_for_combine_1): Set INSN_CODE before calling
target legitimate_combined_insn.
* config/rs6000/rs6000.c (TARGET_LEGITIMATE_COMBINED_INSN): Define.
(rs6000_legitimate_combined_insn): New function.
* config/rs6000/rs6000.md (UNSPEC_DOLOOP): Delete, and remove
all uses.
(ctr<mode>_internal3): Rename from *ctr<mode>_internal5.
(ctr<mode>_internal4): Rename from *ctr<mode>_internal6.
(ctr<mode>_internal1, ctr<mode>_internal2): Remove '*' from name.
From-SVN: r244465
PR tree-optimization/33562
PR tree-optimization/61912
PR tree-optimization/77485
* tree-ssa-dse.c (delete_dead_call): Accept gsi rather than
a statement.
(delete_dead_assignment): Likewise.
(dse_dom_walker::dse_optimize_stmt): Pass in the gsi rather than
statement to delete_dead_call and delete_dead_assignment.
From-SVN: r244461
This is a start of implementing type aliases (`type T1 = T2`) in the
Go frontend. This is incomplete, in that the reflection information
is not updated for an embedded type alias. It is also not well
tested. Finally, the change to the language has not been approved.
This should be regarded as preliminary work for experimental use.
Update golang/go#18130.
Reviewed-on: https://go-review.googlesource.com/35120
From-SVN: r244460
Compiler changes:
* Change map assignment to use mapassign and assign value directly.
* Change string iteration to use decoderune, faster for ASCII strings.
* Change makeslice to take int, and use makeslice64 for larger values.
* Add new noverflow field to hmap struct used for maps.
Unresolved problems, to be fixed later:
* Commented out test in go/types/sizes_test.go that doesn't compile.
* Commented out reflect.TestStructOf test for padding after zero-sized field.
Reviewed-on: https://go-review.googlesource.com/35231
gotools/:
Updates for Go 1.8rc1.
* Makefile.am (go_cmd_go_files): Add bug.go.
(s-zdefaultcc): Write defaultPkgConfig.
* Makefile.in: Rebuild.
From-SVN: r244456
gcc/ChangeLog:
PR c/78304
* substring-locations.c (format_warning_va): Strengthen case 1 so
that both endpoints of the substring must be within the format
range for just the substring to be printed.
gcc/testsuite/ChangeLog:
PR c/78304
* gcc.dg/format/diagnostic-ranges.c (test_macro): Undef INT_FMT.
(test_macro_2): New test.
(test_macro_3): New test.
(test_macro_4): New test.
(test_non_contiguous_strings): Convert line number to line offset.
* gcc.dg/format/pr78304-2.c: New test case.
* gcc.dg/format/pr78304.c: New test case.
From-SVN: r244453
* config/i386/i386.opt (msgx): Use ix86_isa_flags2 variable.
* config/i386/i386.c (ix86_target_string): Add missing options
to isa_opts and reorder options by implied ISAs. Rename isa_opts2 to
isa2_opts, ix86_flag_opts to flag2_opts, ix86_target_other to
flags_other and ix86_target_other to flags2_other. Display unknown
isa2 options.
(ix86_valid_target_attribute_inner_p): Add missing options and
reorder options by implied ISAs, as in ix86_target_string.
testsuite/ChangeLog:
* gcc.target/i386/funcspec-56.inc: Add missing options and
reorder options by implied ISAs, as in ix86_target_string.
From-SVN: r244452
In order to handle large character lengths on (L)LP64 targets, switch
the GFortran character length from an int to a size_t.
This is an ABI change, as procedures with character arguments take
hidden arguments with the character length.
I also changed the _size member in vtables from int to size_t, as
there were some cases where character lengths and sizes were
apparently mixed up and caused regressions otherwise. Although I
haven't tested, this might enable very large derived types as well.
Also, as there are some places in the frontend were negative character
lengths are used as special flag values, in the frontend the character
length is handled as a signed variable of the same size as a size_t,
although in the runtime library it really is size_t.
I haven't changed the character length variables for the co-array
intrinsics, as this is something that may need to be synchronized with
OpenCoarrays.
This is v4 of the patch. v3 was applied but had to reverted due to
breaking bootstrap. The fix is in resolve.c:resolve_charlen, where
it's necessary to check that an expression is constant before using
mpz_sgn.
Overview of v3 of the patch: All the issues pointed out by FX's review
of v2 have been fixed. In particular, there are now new functions
gfc_mpz_get_hwi and gfc_mpz_set_hwi, similar to the GMP functions
mpz_get_si and mpz_set_si, except that they get/set a HOST_WIDE_INT
instead of a long value. Similarly, gfc_get_int_expr now takes a
HOST_WIDE_INT instead of a long, gfc_extract_long is replaced by
gfc_extract_hwi. Also, the preliminary work to handle
gfc_charlen_type_node being unsigned has been removed.
Regtested on x86_64-pc-linux-gnu and i686-pc-linux-gnu.
frontend:
2017-01-13 Janne Blomqvist <jb@gcc.gnu.org>
PR fortran/78534
PR fortran/66310
* class.c (gfc_find_derived_vtab): Use gfc_size_kind instead of
hardcoded kind.
(find_intrinsic_vtab): Likewise.
* expr.c (gfc_get_character_expr): Length parameter of type
gfc_charlen_t.
(gfc_get_int_expr): Value argument of type HOST_WIDE_INT.
(gfc_extract_hwi): New function.
(simplify_const_ref): Make string_len of type gfc_charlen_t.
(gfc_simplify_expr): Use HOST_WIDE_INT for substring refs.
* gfortran.h (gfc_mpz_get_hwi): New prototype.
(gfc_mpz_set_hwi): Likewise.
(gfc_charlen_t): New typedef.
(gfc_expr): Use gfc_charlen_t for character lengths.
(gfc_size_kind): New extern variable.
(gfc_extract_hwi): New prototype.
(gfc_get_character_expr): Use gfc_charlen_t for character length.
(gfc_get_int_expr): Use HOST_WIDE_INT type for value argument.
* iresolve.c (gfc_resolve_repeat): Pass string length directly without
temporary, use gfc_charlen_int_kind.
* match.c (select_intrinsic_set_tmp): Use HOST_WIDE_INT for charlen.
* misc.c (gfc_mpz_get_hwi): New function.
(gfc_mpz_set_hwi): New function.
* module.c (atom_int): Change type from int to HOST_WIDE_INT.
(parse_integer): Don't complain about large integers.
(write_atom): Use HOST_WIDE_INT for integers.
(mio_integer): Handle integer type mismatch.
(mio_hwi): New function.
(mio_intrinsic_op): Use HOST_WIDE_INT.
(mio_array_ref): Likewise.
(mio_expr): Likewise.
* resolve.c (resolve_select_type): Use HOST_WIDE_INT for charlen,
use snprintf.
(resolve_substring_charlen): Use gfc_charlen_int_kind.
(resolve_charlen): Use mpz_sgn to determine sign.
* simplify.c (gfc_simplify_repeat): Use HOST_WIDE_INT/gfc_charlen_t
instead of long.
* target-memory.c (size_character): Length argument of type
gfc_charlen_t.
(gfc_encode_character): Likewise.
(gfc_interpret_character): Use gfc_charlen_t.
* target-memory.h (gfc_encode_character): Modify prototype.
* trans-array.c (get_array_ctor_var_strlen): Use
gfc_conv_mpz_to_tree_type.
* trans-const.c (gfc_conv_mpz_to_tree_type): New function.
* trans-const.h (gfc_conv_mpz_to_tree_type): New prototype.
* trans-expr.c (gfc_class_len_or_zero_get): Build const of type
gfc_charlen_type_node.
(gfc_conv_intrinsic_to_class): Use gfc_charlen_int_kind instead of
4, fold_convert to correct type.
(gfc_conv_class_to_class): Build const of type size_type_node for
size.
(gfc_copy_class_to_class): Likewise.
(gfc_conv_string_length): Use same type in expression.
(gfc_conv_substring): Likewise, use HOST_WIDE_INT for charlen.
(gfc_conv_string_tmp): Make sure len is of the right type.
(gfc_conv_concat_op): Use same type in expression.
(gfc_conv_procedure_call): Likewise.
(alloc_scalar_allocatable_for_subcomponent_assignment):
fold_convert to right type.
(gfc_trans_subcomponent_assign): Likewise.
(trans_class_vptr_len_assignment): Build const of correct type.
(gfc_trans_pointer_assignment): Likewise.
(alloc_scalar_allocatable_for_assignment): fold_convert to right
type in expr.
(trans_class_assignment): Build const of correct type.
* trans-intrinsic.c (gfc_conv_associated): Likewise.
(gfc_conv_intrinsic_repeat): Do calculation in sizetype.
* trans-io.c (gfc_build_io_library_fndecls): Use
gfc_charlen_type_node for character lengths.
* trans-stmt.c (gfc_trans_label_assign): Build const of
gfc_charlen_type_node.
(gfc_trans_character_select): Likewise.
(gfc_trans_allocate): Likewise, don't typecast strlen result.
(gfc_trans_deallocate): Don't typecast strlen result.
* trans-types.c (gfc_size_kind): New variable.
(gfc_init_types): Determine gfc_charlen_int_kind and gfc_size_kind
from size_type_node.
testsuite:
2017-01-13 Janne Blomqvist <jb@gcc.gnu.org>
PR fortran/78534
PR fortran/66310
* gfortran.dg/repeat_4.f90: Use integers of kind C_SIZE_T.
* gfortran.dg/repeat_7.f90: New test for PR 66310.
* gfortran.dg/scan_2.f90: Handle potential cast in assignment.
* gfortran.dg/string_1.f90: Limit to ilp32 targets.
* gfortran.dg/string_1_lp64.f90: New test.
* gfortran.dg/string_3.f90: Limit to ilp32 targets.
* gfortran.dg/string_3_lp64.f90: New test.
libgfortran:
2017-01-13 Janne Blomqvist <jb@gcc.gnu.org>
PR fortran/78534
* intrinsics/args.c (getarg_i4): Use gfc_charlen_type.
(get_command_argument_i4): Likewise.
(get_command_i4): Likewise.
* intrinsics/chmod.c (chmod_internal): Likewise.
* intrinsics/env.c (get_environment_variable_i4): Likewise.
* intrinsics/extends_type_of.c (struct vtype): Use size_t for size
member.
* intrinsics/gerror.c (gerror): Use gfc_charlen_type.
* intrinsics/getlog.c (getlog): Likewise.
* intrinsics/hostnm.c (hostnm_0): Likewise.
* intrinsics/string_intrinsics_inc.c (string_len_trim): Rework to
work if gfc_charlen_type is unsigned.
(string_scan): Likewise.
* io/transfer.c (transfer_character): Modify prototype.
(transfer_character_write): Likewise.
(transfer_character_wide): Likewise.
(transfer_character_wide_write): Likewise.
(transfer_array): Typecast to avoid signed-unsigned comparison.
* io/unit.c (is_trim_ok): Use gfc_charlen_type.
* io/write.c (namelist_write): Likewise.
* libgfortran.h (gfc_charlen_type): Change typedef to size_t.
From-SVN: r244448
A big source of cache misses when compiling a recent version of
gimple-match.ii was the call to cv_cache.empty () in clear_cv_cache.
The problem was that at one early point the hash table had grown
to 8191 entries (128k on LP64 hosts). It then stayed at that size
for the rest of the compilation, even though subsequent uses needed
only a small number of entries (usually fewer than ten). We would
still clear the whole 128k each time clear_cv_cache was called.
empty() already looks for cases where the hash table is very big
and cuts it down. At the moment it fires when the table is 1M
in size and reduces it to the next selected prime above 1K (so
almost 2K in practice). One fix would have been to lower the
threshold, but that didn't feel like the right approach. Reducing
the current limit of 1M by a factor of 8 would be pretty significant
on its own, but I think this cv_cache behaviour would have been a
problem even with 64k or 32k tables.
I think the existing check is really for cases in which even a
well-populated table would need to be shrunk rather than cleared.
Here the problem isn't that the table is excessively big in
absolute terms, more that one outlier has made the table much
too big for the general case.
traverse() already shrinks the table if it's "too empty",
which is taken to be if:
no. elements * 8 < capacity && capacity > 32
So an alternative would be to apply the same test (and the same choice
of shrunken size) to empty_slow too. The patch below does this.
It gives a 2.5% improvement in gimple-match.ii compile time at -O0 -g
and doesn't seem to adversely affect any other tests I've tried.
Of course, there's a theoretical risk of a table alternating between
one large element count and one small element count. If there was a
factor of eight difference between the two, we could shrink the table
on seeing each small element count, then grow it again when adding the
large number of elements. That seems pretty unlikely in practice
though.
Also, empty_slow() does involve a traversal if some form of manual
gc is needed on active elements, so trying to recover from an outlier
should have even more benefit there. (cv_cache uses automatic gc and so
the traversal gets optimised away.)
The calculation of the existing 1M threshold was assuming that each
entry was pointer-sized. This patch makes it use the actual size of the
entry instead.
Tested on aarch64-linux-gnu and x86_64-linux-gnu.
gcc/
* hash-table.h (hash_table::too_empty_p): New function.
(hash_table::expand): Use it.
(hash_table::traverse): Likewise.
(hash_table::empty_slot): Use sizeof (value_type) instead of
sizeof (PTR) to convert bytes to elements. Shrink the table
if the current size is excessive for the current number of
elements.
From-SVN: r244447
record_reg_classes is often the hottest function when generating
unoptimised output. It seems typical for over 60% of the instructions
it handles to be moves, and of course moves tend to be the instructions
with the longest constraint strings.
Maybe we should avoid using move constraints to set costs in unoptimised
output and instead use the "natural" class for the mode being moved.
That's too invasive for stage 3 though.
However, seeing so many moves means that we see many "failing"
alternatives, usually because of '*' or because of hard registers
in function call sequences. The frequency of alternatives that are
detected as failures after the first operand tends again to be more
than 60%. Previously we would continue to process the other operands
of the alternative regardless. This patch instead adds a short-cut.
As well as avoiding unnecessary work, it means that the alt_fail
variable can be jump-threaded away.
Tested on aach64-linux-gnu and x86_64-linux-gnu. It reduces compile
time by about 1% on some tests with "-g -O0".
gcc/
* ira-costs.c (record_reg_classes): Break from the inner loop
early once alt_fail is known to be true. Update outer loop
handling accordingly.
From-SVN: r244446
* tree-ssa-dse.c (decrement_count): New function.
(increment_start_addr, maybe_trim_memstar_call): Likewise.
(dse_dom_walker::optimize_stmt): Call maybe_trim_memstar_call directly
when we know the partially dead statement is a mem* function.
* gcc.dg/tree-ssa/ssa-dse-25.c: New test.
From-SVN: r244444
PR tree-optimization/33562
PR tree-optimization/61912
PR tree-optimization/77485
* doc/invoke.texi: Document new dse-max-object-size param.
* params.def (PARM_DSE_MAX_OBJECT_SIZE): New PARAM.
* tree-ssa-dse.c: Include params.h.
(dse_store_status): New enum.
(initialize_ao_ref_for_dse): New, partially extracted from
dse_optimize_stmt.
(valid_ao_ref_for_dse, normalize_ref): New.
(setup_live_bytes_from_ref, compute_trims): Likewise.
(clear_bytes_written_by, maybe_trim_complex_store): Likewise.
(maybe_trim_partially_dead_store): Likewise.
(maybe_trim_complex_store): Likewise.
(dse_classify_store): Renamed from dse_possibly_dead_store_p.
Track what bytes live from the original store. Return tri-state
for dead, partially dead or live.
(dse_dom_walker): Add constructor, destructor and new private members.
(delete_dead_call, delete_dead_assignment): New extracted from
dse_optimize_stmt.
(dse_optimize_stmt): Make a member of dse_dom_walker.
Use initialize_ao_ref_for_dse.
PR tree-optimization/33562
PR tree-optimization/61912
PR tree-optimization/77485
* gcc.dg/tree-ssa/complex-4.c: Remove xfail.
* gcc.dg/tree-ssa/complex-5.c: Likewise.
* gcc.dg/tree-ssa/ssa-dse-9.c: Likewise.
* gcc.dg/tree-ssa/ssa-dse-18.c: New test.
* gcc.dg/tree-ssa/ssa-dse-19.c: Likewise.
* gcc.dg/tree-ssa/ssa-dse-20.c: Likewise.
* gcc.dg/tree-ssa/ssa-dse-21.c: Likewise.
From-SVN: r244442
PR libstdc++/78389
* include/bits/list.tcc (merge(list&&)):
Adjust list sizes if the comparator throws.
(merge(list&&, _StrictWeakOrdering)): Likewise.
(sort()): Splice elements back from the scratch buffers
if the comparator throws.
(sort(_StrictWeakOrdering)): Likewise.
* testsuite/23_containers/list/operations/78389.cc: New.
From-SVN: r244439
2017-01-13 Martin Liska <mliska@suse.cz>
PR ipa/79043
* function.c (set_cfun): Add new argument force.
* function.h (set_cfun): Likewise.
* ipa-inline-transform.c (inline_call): Use the function when
strict alising from is dropped for function we inline to.
2017-01-13 Martin Liska <mliska@suse.cz>
PR ipa/79043
* gcc.c-torture/execute/pr79043.c: New test.
From-SVN: r244435
2017-01-13 Ed Schonberg <schonberg@adacore.com>
* einfo.ads: minor grammar fixes in comment of Normalized_Position_Max.
* scil_ll.adb: Minor style fix in comment.
* sem_ch8.adb (Analyze_Expanded_Name): Perform dimension analysis
even if entity is already set, because the node may be renalyzed
after inlining transformations.
2017-01-13 Javier Miranda <miranda@adacore.com>
* sem_res.adb (Resolve_Call): Do not establish a transient scope
for a call to inlinable expression function (since the call will
be replaced by its returned object).
* exp_ch6.ads (Is_Inlinable_Expression_Function): New subprogram.
* exp_ch6.adb (Expression_Of_Expression_Function): New subprogram.
(Expand_Call): For inlinable expression function call replace the
call by its returned object.
(Is_Inlinable_Expression_Function): New subprogram.
From-SVN: r244425
2017-01-13 Gary Dismukes <dismukes@adacore.com>
* checks.adb: Minor typo fix and reformatting.
2017-01-13 Javier Miranda <miranda@adacore.com>
* contracts.adb (Contract_Only_Subprograms): Remove formal.
(Copy_Original_Specification): Removed.
(Skip_Contract_Only_Subprogram): Move here checks previously
located in the caller of this routine (to leave the code more clean).
(Build_Contract_Only_Subprogram): Code cleanup.
* scil_ll.ads, scil_ll.adb (Get_Contract_Only_Body_Name): Removed.
(Get_Contract_Only_Missing_Body_Name): Removed.
From-SVN: r244424
2017-01-13 Javier Miranda <miranda@adacore.com>
* sem_ch6.adb (Cloned_Expression): New subprogram.
(Freeze_Expr_Types): Complete previous patch since the expression
of an expression-function may have iterators and loops with
defining identifiers which, as part of the preanalysis of the
expression, may be left decorated with itypes that will not be
available in the tree passed to the backend.
2017-01-13 Ed Schonberg <schonberg@adacore.com>
* checks.adb (Apply_Type_Conversion_Checks): Optimize a type
conversion to Integer of an expression that is an attribute
reference 'Pos on an enumeration type.
2017-01-13 Bob Duff <duff@adacore.com>
* atree.ads: Minor comment fix.
From-SVN: r244423
2017-01-13 Hristian Kirtchev <kirtchev@adacore.com>
* sem_ch6.adb (Analyze_Subprogram_Body_Helper):
Ensure that the input body is a subprogram body before trying to
determine whether it denoted an expression function. Note that
subprogram body stubs cannot denote expression functions.
From-SVN: r244421