aoliva [Tue, 12 Dec 2017 02:15:00 +0000 (02:15 +0000)]
[SFN] boilerplate changes in preparation to introduce nonbind markers
This patch introduces a number of new macros and functions that will
be used to distinguish between different kinds of debug stmts, insns
and notes, namely, preexisting debug bind ones and to-be-introduced
nonbind markers.
In a seemingly mechanical way, it adjusts several uses of the macros
and functions, so that they refer to narrower categories when
appropriate.
These changes, by themselves, should not have any visible effect in
the compiler behavior, since the upcoming debug markers are never
created with this patch alone.
for gcc/ChangeLog
* gimple.h (enum gimple_debug_subcode): Add
GIMPLE_DEBUG_BEGIN_STMT.
(gimple_debug_begin_stmt_p): New.
(gimple_debug_nonbind_marker_p): New.
* tree.h (MAY_HAVE_DEBUG_MARKER_STMTS): New.
(MAY_HAVE_DEBUG_BIND_STMTS): Renamed from....
(MAY_HAVE_DEBUG_STMTS): ... this. Check both.
* insn-notes.def (BEGIN_STMT): New.
* rtl.h (MAY_HAVE_DEBUG_MARKER_INSNS): New.
(MAY_HAVE_DEBUG_BIND_INSNS): Renamed from....
(MAY_HAVE_DEBUG_INSNS): ... this. Check both.
(NOTE_MARKER_LOCATION, NOTE_MARKER_P): New.
(DEBUG_BIND_INSN_P, DEBUG_MARKER_INSN_P): New.
(INSN_DEBUG_MARKER_KIND): New.
(GEN_RTX_DEBUG_MARKER_BEGIN_STMT_PAT): New.
(INSN_VAR_LOCATION): Check for VAR_LOCATION.
(INSN_VAR_LOCATION_PTR): New.
* cfgexpand.c (expand_debug_locations): Handle debug bind insns
only.
(expand_gimple_basic_block): Likewise. Emit debug temps for TER
deps only if debug bind insns are enabled.
(pass_expand::execute): Avoid deep TER and expand
debug locations for debug bind insns only.
* cgraph.c (cgraph_edge::redirect_call_stmt_to_callee): Narrow
debug stmts special handling down to debug bind stmts.
* combine.c (try_combine): Narrow debug insns special handling
down to debug bind insns.
* cse.c (delete_trivially_dead_insns): Handle debug bindings.
Narrow debug insns preexisting special handling down to debug
bind insns.
* dce.c (rest_of_handle_ud_dce): Narrow debug insns special
handling down to debug bind insns.
* function.c (instantiate_virtual_regs): Skip debug markers,
adjust handling of debug binds.
* gimple-ssa-backprop.c (backprop::prepare_change): Try debug
temp insertion iff MAY_HAVE_DEBUG_BIND_STMTS.
* haifa-sched.c (schedule_insn): Narrow special handling of debug
insns to debug bind insns.
* ipa-param-manipulation.c (ipa_modify_call_arguments): Narrow
special handling of debug stmts to debug bind stmts.
* ipa-split.c (split_function): Likewise.
* ira.c (combine_and_move_insns): Adjust debug bind insns only.
* loop-unroll.c (apply_opt_in_copies): Adjust tests on bind
debug insns.
* reg-stack.c (convert_regs_1): Use DEBUG_BIND_INSN_P.
* regrename.c (build_def_use): Likewise.
* regcprop.c (copyprop_hardreg_forward_1): Likewise.
(pass_cprop_hardreg): Narrow special casing of debug insns to
debug bind insns.
* regstat.c (regstat_init_n_sets_and_refs): Likewise.
* reload1.c (reload): Likewise.
* sese.c (sese_insert_phis_for_liveouts): Narrow special
casing of debug stmts to debug bind stmts.
* shrink-wrap.c (move_insn_for_shrink_wrap): Likewise.
* ssa-iterators.h (num_imm_uses): Likewise.
* tree-cfg.c (gimple_merge_blocks): Narrow special casing of
debug stmts to debug bind stmts.
* tree-inline.c (tree_function_versioning): Narrow special casing
of debug stmts to debug bind stmts.
* tree-loop-distribution.c (generate_loops_for_partition):
Narrow special casing of debug stmts to debug bind stmts.
* tree-sra.c (analyze_access_subtree): Narrow special casing
of debug stmts to debug bind stmts.
* tree-ssa-dce.c (remove_dead_stmt): Narrow special casing of debug
stmts to debug bind stmts.
* tree-ssa-loop-ivopt.c (remove_unused_ivs): Narrow special
casing of debug stmts to debug bind stmts.
* tree-ssa-reassoc.c (reassoc_remove_stmt): Likewise.
* tree-ssa-tail-merge.c (tail_merge_optimize): Narrow special
casing of debug stmts to debug bind stmts.
* tree-ssa-threadedge.c (propagate_threaded_block_debug_info):
Likewise.
* tree-ssa.c (flush_pending_stmts): Narrow special casing of
debug stmts to debug bind stmts.
(gimple_replace_ssa_lhs): Likewise.
(insert_debug_temp_for_var_def): Likewise.
(insert_debug_temps_for_defs): Likewise.
(reset_debug_uses): Likewise.
* tree-ssanames.c (release_ssa_name_fn): Likewise.
* tree-vect-loop-manip.c (adjust_debug_stmts_now): Likewise.
(adjust_debug_stmts): Likewise.
(adjust_phi_and_debug_stmts): Likewise.
(vect_do_peeling): Likewise.
* tree-vect-loop.c (vect_transform_loop): Likewise.
* valtrack.c (propagate_for_debug): Use BIND_DEBUG_INSN_P.
* var-tracking.c (adjust_mems): Narrow special casing of debug
insns to debug bind insns.
(dv_onepart_p, dataflow_set_clar_at_call, use_type): Likewise.
(compute_bb_dataflow, vt_find_locations): Likewise.
(vt_expand_loc, emit_notes_for_changes): Likewise.
(vt_init_cfa_base): Likewise.
(vt_emit_notes): Likewise.
(vt_initialize): Likewise.
(vt_finalize): Likewise.
aoliva [Tue, 12 Dec 2017 02:14:39 +0000 (02:14 +0000)]
[SFN] adjust RTL insn-walking API
This patch removes unused RTL functions, introduces alternate ones for
use in a later SFN patch, and regroups other related functions so that
they appear in a more consistent order.
dmalcolm [Tue, 12 Dec 2017 01:31:30 +0000 (01:31 +0000)]
Expensive selftests: torture testing for fix-it boundary conditions (PR c/82050)
This patch adds selftest coverage for the fix for PR c/82050.
The selftest iterates over various "interesting" column and line-width
values to try to shake out bugs in the fix-it printing routines, a kind
of "torture" selftest.
Unfortunately this selftest is noticably slower than the other selftests;
adding it to diagnostic-show-locus.c led to:
-fself-test: 40218 pass(es) in 0.172000 seconds
slowing down to:
-fself-test: 97315 pass(es) in 6.109000 seconds
for an unoptimized build (e.g. when hacking with --disable-bootstrap).
Given that this affects the compile-edit-test cycle of the "gcc"
subdirectory, this felt like an unacceptable amount of overhead to add.
I attempted to optimize the test by reducing the amount of coverage, but
the test seems useful, and there seems to be a valid role for "torture"
selftests.
Hence this patch adds a:
gcc.dg/plugin/expensive_selftests_plugin.c
with the responsibility for running "expensive" selftests, and adds the
expensive test there. The patch moves a small amount of code from
selftest::run_tests into a helper class so that the plugin can print
a useful summary line (to reassure us that the tests are actually being
run).
With that, the compile-edit-test cycle of the "gcc" subdir is unaffected;
the plugin takes:
expensive_selftests_plugin: 26641 pass(es) in 3.127000 seconds
which seems reasonable within the much longer time taken by "make check"
(I optimized some of the overhead away, hence the reduction from 6 seconds
above down to 3 seconds).
gcc/ChangeLog:
PR c/82050
* selftest-run-tests.c (selftest::run_tests): Move start/finish code
to...
* selftest.c (selftest::test_runner::test_runner): New ctor.
(selftest::test_runner::~test_runner): New dtor.
* selftest.h (class selftest::test_runner): New class.
gcc/testsuite/ChangeLog:
PR c/82050
* gcc.dg/plugin/expensive-selftests-1.c: New file.
* gcc.dg/plugin/expensive_selftests_plugin.c: New file.
* gcc.dg/plugin/plugin.exp (plugin_test_list): Add the above.
aoliva [Mon, 11 Dec 2017 22:36:07 +0000 (22:36 +0000)]
[PR80693] drop value of parallel SETs dropped by combine
When combine drops a REG_UNUSED SET in a parallel, we have to clear
cached values, so that, even if the REGs remain used (e.g. because
they were referenced in the used SET_SRC), we will not use properties
of the dropped modified value as if they applied to the preserved
original one.
We fail to adjust REG_N_SETS.
for gcc/ChangeLog
PR rtl-optimization/80693
PR rtl-optimization/81019
PR rtl-optimization/81020
* combine.c (distribute_notes): Reset any REG_UNUSED REGs that
are not mentioned in i3. Place the REG_UNUSED note on i2,
possibly modified to REG_DEAD, if it did not originate in i3.
jakub [Mon, 11 Dec 2017 22:20:27 +0000 (22:20 +0000)]
* recog.c (store_data_bypass_p_1): New function.
(store_data_bypass_p): Handle USE in a PARALLEL like CLOBBER. Use
store_data_bypass_p_1 to avoid code duplication. Formatting fixes.
segher [Mon, 11 Dec 2017 21:23:08 +0000 (21:23 +0000)]
ifcvt: Call fixup_partitions (PR83361)
After converting a conditional branch to an unconditional trap to a
conditional trap, if the original trap is still reachable from another
path, it may be that it is in a hot basic block and only reachable from
cold blocks. Fix that up.
jakub [Mon, 11 Dec 2017 17:59:01 +0000 (17:59 +0000)]
* config/aarch64/aarch64.c (aarch64_print_operand): Don't start
output_operand_lossage first argument with capital letter.
(aarch64_override_options): Don't start error and sorry first argument
with capital letter.
PR fortran/53478
* gfortran.h (gfc_find_case_gsymbol): New prototype.
* symbol.c (gfc_find_case_gsymbol): New procedure, case
insensistive version of gfc_find_gsymbol.
* resolve.c (resolve_common_blocks): Use it.
Replace %s with %qs where needed.
jakub [Sat, 9 Dec 2017 11:43:31 +0000 (11:43 +0000)]
PR tree-optimization/83338
* tree-vect-stmts.c (vectorizable_operation): Handle POINTER_DIFF_EXPR
vectorization as MINUS_EXPR with a subsequent VIEW_CONVERT_EXPR from
vector of unsigned integers to vector of signed integers.
jamborm [Fri, 8 Dec 2017 12:11:02 +0000 (12:11 +0000)]
Prevent SRA from removing type changing assignment
2017-12-08 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/83141
* tree-sra.c (contains_vce_or_bfcref_p): Move up in the file, also
test for MEM_REFs implicitely changing types with padding. Remove
inline keyword.
(build_accesses_from_assign): Added contains_vce_or_bfcref_p checks.
segher [Fri, 8 Dec 2017 11:26:35 +0000 (11:26 +0000)]
combine: Fix PR83304
In PR83304 two insns are combined, where the I2 uses a register that
has a REG_DEAD note on an insn after I2 but before I3. In such a case
move_deaths should move that death note. But move_deaths only looks
at the reg_stat[regno].last_death insn, and that field can be zeroed
out (previously, use_crosses_set_p would prevent the combination in
this case).
If the last_death field is zero it means "unknown", not "no death", so
we have to find if there is a REG_DEAD note.
PR rtl-optimization/83304
* combine.c (move_deaths): If we do not know where a register died,
search for it.
rearnsha [Fri, 8 Dec 2017 11:19:20 +0000 (11:19 +0000)]
[arm] PR target/83206: Make native driver select fp-capable armv6 cores
A quirk in the historical naming of some ARMv6 products means that the
main CPU name implies the presence or otherwise of the floating point unit.
This causes problems when using -mfpu=auto with -mcpu=native: the driver is
picking a CPU that does not support a floating-point unit, even though
one may well exist.
This patch addresses this by selecting the FP-capable names so that FP
instructions will be generated if the other options suggest this is
permitted.
Note that a more complete fix is really needed here to look up the
FP/simd capabilities and append the appropriate capability extensions.
This will be the subject of some follow-up patches.
* config/arm/driver-arm.c (arm_cpu_table): Use fp-capable product names
for armv6 ARM CPU IDs.
rearnsha [Fri, 8 Dec 2017 11:14:09 +0000 (11:14 +0000)]
[arm] Don't strip off all architecture features from -march passed to assembler
When GCC invokes the assembler it generates a sanitized version of the
user-specified -march option to pass through, since the assembler does
not understand all the new FPU-related architectural options.
Unfortunately it goes too far and strips off all the architectural
extensions, including some that are unrelated to the -mfpu variant
selected.
Again, this doesn't really matter when compiling C code because the
compiler will override the command-line specified architecture with
directives in the assembly file itself, but when using the compiler
driver to invoke the assembler the only indiciation of the desired
architecture might come from the command line.
We fix this by adjusting the canonicalization pass to remove any
option that only specifies features that can be expressed by -mfpu
(any that go beyond that are already supported by the assembler). We
do have to take care to re-order the options, though as the assembler
expects feature options to be in a canonical order (unlike the
compiler, where ordering is handled left-to-right: there's only a
difference if there are negation options, but a canonicalized
architecture string shouldn't have any of those). We do this by
recording which options we need and then sorting the final list
alphabetically.
* common/config/arm/arm-common.c: Include <algorithm>.
(INCLUDE_VECTOR): Define.
(compare_opt_names): New function.
(arm_rewrite_selected_arch): Only strip out extensions that can be
expressed through -mfpu. Sort the remaining extensions
alphabetically.
rearnsha [Fri, 8 Dec 2017 10:55:01 +0000 (10:55 +0000)]
[arm] Generate a -mfpu= option for passing to the assembler
When gcc runs with the new -mfpu=auto option (either explicitly or
when that's the default behaviour) then this option is not passed
through to the assembler as we cannot rely on the assembler
understanding it (currently it doesn't understand it at all, but in
future that might change). That means that the assembler falls back
to its builtin default, which may not correspond to what the user
expected based on the command-line options they passed.
Normally that wouldn't matter because assembler files generated by the
compiler will contain explicit directives that set the FPU type
directly and override any internal defaults; but when the compiler
driver is used to invoke the assembler directly (because the source
file ends in .s or .S) then this might cause a problem if that assumes
the FPU matches the compiler.
To address this, this patch makes the driver construct a -mfpu= option
for the assembler in the same way as the compiler generates an
internal .fpu directive. As mentioned, this makes no difference if
the assembler file explicitly overrides the command line options, but
helps in the case where this is implicit.
* config/arm/arm.h (arm_asm_auto_mfpu): Declare.
(ASM_CPU_SPEC_FUNCTIONS): Add new rule asm_auto_mfpu.
(ASM_CPU_SPEC): Use it if -mfpu is set to auto.
* common/config/arm/arm-common.c (arm_asm_auto_mfpu): New function.
-- This line, and those below, will be ignored--
M gcc/ChangeLog
M gcc/common/config/arm/arm-common.c
M gcc/config/arm/arm.h
rguenth [Fri, 8 Dec 2017 08:06:31 +0000 (08:06 +0000)]
2017-12-08 Richard Biener <rguenther@suse.de>
PR tree-optimization/81303
* tree-vect-stmts.c (vect_is_simple_cond): For invariant
conditions try to create a comparison vector type matching
the data vector type.
(vectorizable_condition): Adjust.
* tree-vect-patterns.c (vect_recog_mask_conversion_pattern):
Leave invariant conditions alone in case we can vectorize those.
* gcc.target/i386/vectorize9.c: New testcase.
* gcc.target/i386/vectorize10.c: New testcase.
wilson [Fri, 8 Dec 2017 00:44:13 +0000 (00:44 +0000)]
Add srodata section support to riscv port.
2017-12-07 Andrew Waterman <andrew@sifive.com>
gcc/
* config/riscv/riscv.c (TARGET_ASM_SELECT_SECTION): New define.
(TARGET_HAVE_SRODATA_SECTION): New define.
(riscv_select_section): New function.
jakub [Thu, 7 Dec 2017 23:55:18 +0000 (23:55 +0000)]
PR tree-optimization/83075
* gcc.dg/tree-ssa/strncpy-2.c: Use size_t instead of unsigned, add
separate function with noipa attribute to also verify behavior when
optimizers don't know the sizes and aliasing, verify resulting sizes
and array content. Add -Wstringop-overflow to dg-options.
* gcc.dg/tree-ssa/strncat.c: Likewise.
thopre01 [Thu, 7 Dec 2017 21:48:35 +0000 (21:48 +0000)]
Improve fstack_protector effective target
Effective target fstack_protector fails to return an error for
newlib-based target (such as arm-none-eabi targets) which does not
support stack protector. This is due to the test being too simplist for
stack protection code to be generated by GCC: it does not contain a
local buffer and does not read unknown input.
This commit adds a small local buffer with a copy of the filename to
trigger stack protector code to be generated. The filename is used
instead of the full path so as to ensure the size will fit in the local
buffer.
2017-12-07 Thomas Preud'homme <thomas.preudhomme@arm.com>
gcc/testsuite/
* lib/target-supports.exp (check_effective_target_fstack_protector):
Copy filename in local buffer to trigger stack protection.
jsm28 [Thu, 7 Dec 2017 18:47:20 +0000 (18:47 +0000)]
Allow _Alignas in compound literals (C11 DR#444).
C11 DR#444 dealt with how C11 intended to allow alignment specifiers
on struct and union members, but failed to include that in the syntax.
The final resolution of that DR also allows alignment specifiers in
type names in compound literals (in order to apply an increased
alignment to the unnamed object created by the compound literal), but
not other cases of type names.
This patch implements allowing alignment specifiers in compound
literals and adds tests for the resolution of the DR (including that
they are allowed on struct and union members, which GCC already
implemented). Because the parser has to parse the parenthesized type
name of a compound literal before it can tell that it's a compound
literal (rather than, depending on the context, a cast expression or
sizeof (type-name) or _Alignof (type-name)), this means _Alignas
specifiers are allowed syntactically in those contexts and then an
error is given once it's known to be an invalid use (whereas _Alignas
specifiers are disallowed syntactically in other contexts where type
names can occur and a compound literal is not possible).
Bootstrapped with no regressions on x86_64-pc-linux-gnu.
gcc/c:
* c-decl.c (build_compound_literal): Add parameter alignas_align
and set alignment of decl if nonzero.
* c-parser.c (c_keyword_starts_typename): Allow RID_ALIGNAS.
(c_parser_declspecs): Allow RID_ALIGNAS to follow a type, like a
qualifier.
(c_parser_struct_declaration): Update syntax comment.
(c_parser_type_name): Add alignas_ok argument and pass it to
c_parser_declspecs.
(c_parser_cast_expression): Pass true to c_parser_type_name and
give error if a cast used an _Alignas specifier.
(c_parser_sizeof_expression): Pass true to c_parser_type_name and
give error if sizeof (type-name) used an _Alignas specifier.
(c_parser_alignof_expression): Pass true to c_parser_type_name and
give error if _Alignof (type-name) used an _Alignas specifier.
(c_parser_postfix_expression_after_paren_type): Check specified
alignment for a compound literal and pass it to
build_compound_literal.
* c-parser.h (c_parser_type_name): Update prototype.
* c-tree.h (build_compound_literal): Update prototype.
gcc/testsuite:
* gcc.dg/c11-align-7.c, gcc.dg/c11-align-8.c,
gcc.dg/c11-align-9.c, gcc.dg/gnu11-align-1.c: New tests.
* gcc.dg/c11-align-5.c (test): Update expected error for sizeof
case.
rsandifo [Thu, 7 Dec 2017 18:43:40 +0000 (18:43 +0000)]
[AArch64] Fix ICEs in aarch64_print_operand
Three related regression fixes:
- We can't use asserts like:
gcc_assert (GET_MODE_SIZE (mode) == 16);
in aarch64_print_operand because it could trigger for invalid user input.
- The output_operand_lossage in aarch64_print_address_internal:
output_operand_lossage ("invalid operand for '%%%c'", op);
wasn't right because "op" is an rtx_code enum rather than the
prefix character.
- aarch64_print_operand_address shouldn't call output_operand_lossage
(because it doesn't have a prefix code) but instead fall back to
output_addr_const.
2017-12-05 Richard Sandiford <richard.sandiford@linaro.org>
gcc/
* config/aarch64/aarch64.c (aarch64_print_address_internal): Return
a bool success value. Don't call output_operand_lossage here.
(aarch64_print_ldpstp_address): Return a bool success value.
(aarch64_print_operand_address): Call output_addr_const if
aarch64_print_address_internal fails.
(aarch64_print_operand): Don't assert that the mode is 16 bytes for
'y'; call output_operand_lossage instead. Call output_operand_lossage
if aarch64_print_ldpstp_address fails.
gcc/testsuite/
* gcc.target/aarch64/asm-2.c: New test.
* gcc.target/aarch64/asm-3.c: Likewise.
rsandifo [Thu, 7 Dec 2017 18:42:41 +0000 (18:42 +0000)]
Make more use of VECTOR_CST_ENCODED_ELT
This patch makes various bits of code operate directly on the new
VECTOR_CST encoding, instead of using VECTOR_CST_ELT on all elements
of the vector.
Previous patches handled operations that produce a new VECTOR_CST,
while this patch handles things like predicates. It also makes
print_node dump the encoding instead of the full vector that
the encoding represents.
2017-12-07 Richard Sandiford <richard.sandiford@linaro.org>
gcc/
* tree-vector-builder.h
(tree_vector_builder::binary_encoded_nelts): Declare.
* tree-vector-builder.c
(tree_vector_builder::binary_encoded_nelts): New function.
* fold-const.c (negate_expr_p): Likewise.
(operand_equal_p, fold_checksum_tree): Likewise.
* tree-loop-distribution.c (const_with_all_bytes_same): Likewise.
* tree.c (integer_zerop, integer_onep, integer_all_onesp, real_zerop)
(real_onep, real_minus_onep, add_expr, initializer_zerop): Likewise.
(uniform_vector_p): Likewise.
* varasm.c (const_hash_1, compare_constant): Likewise.
* tree-ssa-ccp.c: Include tree-vector-builder.h.
(valid_lattice_transition): Operate directly on the VECTOR_CST
encoding.
* ipa-icf.c: Include tree-vector-builder.h.
(sem_variable::equals): Operate directly on the VECTOR_CST encoding.
* print-tree.c (print_node): Print encoding of VECTOR_CSTs.
rsandifo [Thu, 7 Dec 2017 18:41:59 +0000 (18:41 +0000)]
Make gimple_build_vector take a tree_vector_builder
This patch changes gimple_build_vector so that it takes a
tree_vector_builder instead of a size and a vector of trees.
2017-12-07 Richard Sandiford <richard.sandiford@linaro.org>
gcc/
* vector-builder.h (vector_builder::derived): New const overload.
(vector_builder::elt): New function.
* tree-vector-builder.h (tree_vector_builder::type): New function.
(tree_vector_builder::apply_step): Declare.
* tree-vector-builder.c (tree_vector_builder::apply_step): New
function.
* gimple-fold.h (tree_vector_builder): Declare.
(gimple_build_vector): Take a tree_vector_builder instead of a
type and vector of elements.
* gimple-fold.c (gimple_build_vector): Likewise.
* tree-vect-loop.c (get_initial_def_for_reduction): Update call
accordingly.
(get_initial_defs_for_reduction): Likewise.
(vectorizable_induction): Likewise.
rsandifo [Thu, 7 Dec 2017 18:41:35 +0000 (18:41 +0000)]
Use tree_vector_builder::new_binary_operation for folding
This patch makes fold-const.c operate directly on the VECTOR_CST
encoding when folding an operation that has two VECTOR_CST inputs.
2017-12-07 Richard Sandiford <richard.sandiford@linaro.org>
gcc/
* tree-vector-builder.h
(tree_vector_builder::new_binary_operation): Declare.
* tree-vector-builder.c
(tree_vector_builder::new_binary_operation): New function.
* fold-const.c (fold_relational_const): Use it.
(const_binop): Likewise. Check that both input vectors have
the same number of elements, thus excluding things like WIDEN_SUM.
Check whether it is possible to operate directly on the encodings
of stepped inputs.
rsandifo [Thu, 7 Dec 2017 18:41:13 +0000 (18:41 +0000)]
Use tree_vector_builder::new_unary_operation for folding
This patch makes fold-const.c operate directly on the VECTOR_CST
encoding when folding an operation that has a single VECTOR_CST input.
2017-12-07 Richard Sandiford <richard.sandiford@linaro.org>
gcc/
* fold-const.c (fold_negate_expr_1): Use tree_vector_builder and
new_unary_operation, operating only on the encoded elements.
(const_unop): Likewise.
(exact_inverse): Likewise.
(distributes_over_addition_p): New function.
(const_binop): Use tree_vector_builder and new_unary_operation
for combinations of VECTOR_CST and INTEGER_CST. Operate only
on the encoded elements unless the encoding is strided and the
operation does not distribute over addition.
(fold_convert_const): Use tree_vector_builder and
new_unary_operation. Operate only on the encoded elements
for truncating integer conversions, or for non-stepped encodings.
rsandifo [Thu, 7 Dec 2017 18:40:50 +0000 (18:40 +0000)]
Use tree_vector_builder instead of build_vector
This patch switches most build_vector calls over to tree_vector_builder,
using explicit encodings where appropriate. Later patches handle
the remaining uses of build_vector.
2017-12-07 Richard Sandiford <richard.sandiford@linaro.org>
gcc/
* config/sparc/sparc.c: Include tree-vector-builder.h.
(sparc_fold_builtin): Use tree_vector_builder instead of build_vector.
* expmed.c: Include tree-vector-builder.h.
(make_tree): Use tree_vector_builder instead of build_vector.
* fold-const.c: Include tree-vector-builder.h.
(const_binop): Use tree_vector_builder instead of build_vector.
(const_unop): Likewise.
(native_interpret_vector): Likewise.
(fold_vec_perm): Likewise.
(fold_ternary_loc): Likewise.
* gimple-fold.c: Include tree-vector-builder.h.
(gimple_fold_stmt_to_constant_1): Use tree_vector_builder instead
of build_vector.
* tree-ssa-forwprop.c: Include tree-vector-builder.h.
(simplify_vector_constructor): Use tree_vector_builder instead
of build_vector.
* tree-vect-generic.c: Include tree-vector-builder.h.
(add_rshift): Use tree_vector_builder instead of build_vector.
(expand_vector_divmod): Likewise.
(optimize_vector_constructor): Likewise.
* tree-vect-loop.c: Include tree-vector-builder.h.
(vect_create_epilog_for_reduction): Use tree_vector_builder instead
of build_vector. Explicitly use a stepped encoding for
{ 1, 2, 3, ... }.
* tree-vect-slp.c: Include tree-vector-builder.h.
(vect_get_constant_vectors): Use tree_vector_builder instead
of build_vector.
(vect_transform_slp_perm_load): Likewise.
(vect_schedule_slp_instance): Likewise.
* tree-vect-stmts.c: Include tree-vector-builder.h.
(vectorizable_bswap): Use tree_vector_builder instead of build_vector.
(vect_gen_perm_mask_any): Likewise.
(vectorizable_call): Likewise. Explicitly use a stepped encoding.
* tree.c: (build_vector_from_ctor): Use tree_vector_builder instead
of build_vector.
(build_vector_from_val): Likewise. Explicitly use a duplicate
encoding.
rsandifo [Thu, 7 Dec 2017 18:40:28 +0000 (18:40 +0000)]
New VECTOR_CST layout
This patch uses a simple compression scheme to represent the contents
of a VECTOR_CST using its leading elements. There are three formats:
1) a repeating sequence of N values. This is encoded using the first
N elements.
2) a "foreground" sequence of N values inserted at the beginning of
a "background" repeating sequence of N values, such as:
{ 1, 2, 0, 0, 0, 0, ... }. This is encoded using the first 2*N
elements.
2) a "foreground" sequence of N values inserted at the beginning of
a "background" repeating sequence of N interleaved linear series,
such as: { 0, 0, 8, 10, 9, 11, 10, 12, ... }. This is encoded
using the first 3*N elements. In practice the foreground values
are often part of the same series as the background values,
such as: { 1, 11, 2, 12, 3, 13, ... }.
This reduces the amount of work involved in processing simple
vector constants and means that the encoding extends naturally
to variable-length vectors.
2017-12-07 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* doc/generic.texi (VECTOR_CST): Describe new representation of
vector constants.
* vector-builder.h: New file.
* tree-vector-builder.h: Likewise.
* tree-vector-builder.c: Likewise.
* Makefile.in (OBJS): Add tree-vector-builder.o.
* tree.def (VECTOR_CST): Update comment to refer to generic.texi.
* tree-core.h (tree_base): Add a vector_cst field to the u union.
(tree_vector): Change the number of elements to
vector_cst_encoded_nelts.
* tree.h (VECTOR_CST_NELTS): Redefine using TYPE_VECTOR_SUBPARTS.
(VECTOR_CST_ELTS): Delete.
(VECTOR_CST_ELT): Redefine using vector_cst_elt.
(VECTOR_CST_LOG2_NPATTERNS, VECTOR_CST_NPATTERNS): New macros.
(VECTOR_CST_NELTS_PER_PATTERN, VECTOR_CST_DUPLICATE_P): Likewise.
(VECTOR_CST_STEPPED_P, VECTOR_CST_ENCODED_ELTS): Likewise.
(VECTOR_CST_ENCODED_ELT): Likewise.
(vector_cst_encoded_nelts): New function.
(make_vector): Take the values of VECTOR_CST_LOG2_NPATTERNS and
VECTOR_CST_NELTS_PER_PATTERN as arguments.
(vector_cst_int_elt, vector_cst_elt): Declare.
* tree.c: Include tree-vector-builder.h.
(tree_code_size): Abort if passed VECTOR_CST.
(tree_size): Update for new VECTOR_CST layout.
(make_vector): Take the values of VECTOR_CST_LOG2_NPATTERNS and
VECTOR_CST_NELTS_PER_PATTERN as arguments.
(build_vector): Use tree_vector_builder.
(vector_cst_int_elt, vector_cst_elt): New functions.
(drop_tree_overflow): For VECTOR_CST, drop the TREE_OVERFLOW from the
encoded elements and then create the vector in the canonical form.
(check_vector_cst, check_vector_cst_duplicate, check_vector_cst_fill)
(check_vector_cst_stepped, test_vector_cst_patterns): New functions.
(tree_c_tests): Call test_vector_cst_patterns.
* lto-streamer-out.c (DFS::DFS_write_tree_body): Handle the new
VECTOR_CST fields.
(hash_tree): Likewise.
* tree-streamer-out.c (write_ts_vector_tree_pointers): Likewise.
(streamer_write_tree_header): Likewise.
* tree-streamer-in.c (lto_input_ts_vector_tree_pointers): Likewise.
(streamer_alloc_tree): Likewise. Update call to make_vector.
* fold-const.c (fold_ternary_loc): Avoid using VECTOR_CST_ELTS.
gcc/lto/
* lto.c (compare_tree_sccs_1): Compare the new VECTOR_CST flags.
amker [Thu, 7 Dec 2017 18:03:53 +0000 (18:03 +0000)]
PR tree-optimization/81303
* Makefile.in (gimple-loop-interchange.o): New object file.
* common.opt (floop-interchange): Reuse the option from graphite.
* doc/invoke.texi (-floop-interchange): Ditto. New document for
-floop-interchange and mention it for -O3.
* opts.c (default_options_table): Enable -floop-interchange at -O3.
* gimple-loop-interchange.cc: New file.
* params.def (PARAM_LOOP_INTERCHANGE_MAX_NUM_STMTS): New parameter.
(PARAM_LOOP_INTERCHANGE_STRIDE_RATIO): New parameter.
* passes.def (pass_linterchange): New pass.
* timevar.def (TV_LINTERCHANGE): New time var.
* tree-pass.h (make_pass_linterchange): New declaration.
* tree-ssa-loop-ivcanon.c (create_canonical_iv): Change to external
interchange. Record IV before/after increment in new parameters.
* tree-ssa-loop-ivopts.h (create_canonical_iv): New declaration.
* tree-vect-loop.c (vect_is_simple_reduction): Factor out reduction
path check into...
(check_reduction_path): ...New function here.
* tree-vectorizer.h (check_reduction_path): New declaration.
gcc/testsuite
* gcc.dg/tree-ssa/loop-interchange-1.c: New test.
* gcc.dg/tree-ssa/loop-interchange-1b.c: New test.
* gcc.dg/tree-ssa/loop-interchange-2.c: New test.
* gcc.dg/tree-ssa/loop-interchange-3.c: New test.
* gcc.dg/tree-ssa/loop-interchange-4.c: New test.
* gcc.dg/tree-ssa/loop-interchange-5.c: New test.
* gcc.dg/tree-ssa/loop-interchange-6.c: New test.
* gcc.dg/tree-ssa/loop-interchange-7.c: New test.
* gcc.dg/tree-ssa/loop-interchange-8.c: New test.
* gcc.dg/tree-ssa/loop-interchange-9.c: New test.
* gcc.dg/tree-ssa/loop-interchange-10.c: New test.
* gcc.dg/tree-ssa/loop-interchange-11.c: New test.
* gcc.dg/tree-ssa/loop-interchange-12.c: New test.
* gcc.dg/tree-ssa/loop-interchange-13.c: New test.
vmakarov [Thu, 7 Dec 2017 17:50:54 +0000 (17:50 +0000)]
2017-12-07 Vladimir Makarov <vmakarov@redhat.com>
PR target/83252
PR rtl-optimization/80818
* lra.c (add_regs_to_insn_regno_info): Make a hard reg in CLOBBER
always early clobbered.
* lra-lives.c (process_bb_lives): Check input hard regs for early
clobbered non-operand hard reg.
PR c/81544
* cp-tree.h (decls_match): Add default argument.
* decl.c (decls_match): Avoid calling into the target back end
and triggering an error.
* decl2.c (cplus_decl_attributes): Look up existing declaration and
pass it to decl_attributes.
* tree.c (cxx_attribute_table): Initialize new member of struct
attribute_spec.
gcc/fortran/ChangeLog:
PR c/81544
* f95-lang.c (gfc_attribute_table): Initialize new member of struct
attribute_spec.
gcc/lto/ChangeLog:
PR c/81544
* lto-lang.c (lto_attribute_table): Initialize new member of struct
attribute_spec.
gcc/ChangeLog:
PR c/81544
* attribs.c (empty_attribute_table): Initialize new member of
struct attribute_spec.
(decl_attributes): Add argument. Handle mutually exclusive
combinations of attributes.
(selftests::test_attribute_exclusions): New function.
(selftests::attribute_c_tests): Ditto.
* attribs.h (decl_attributes): Add default argument.
* selftest.h (attribute_c_tests): Declare.
* selftest-run-tests.c (selftest::run_tests): Call attribute_c_tests.
* tree-core.h (attribute_spec::exclusions, exclude): New type and
member.
* doc/extend.texi (Common Function Attributes): Update const and pure.
gcc/testsuite/ChangeLog:
PR c/81544
* c-c++-common/Wattributes-2.c: New test.
* c-c++-common/Wattributes.c: New test.
* c-c++-common/attributes-3.c: Adjust.
* gcc.dg/Wattributes-6.c: New test.
* gcc.dg/Wattributes-7.c: New test.
* gcc.dg/attr-noinline.c
* gcc.dg/pr44964.c: Same.
* gcc.dg/torture/pr42363.c: Same.
* gcc.dg/tree-ssa/ssa-ccp-2.c: Same.
rguenth [Thu, 7 Dec 2017 13:21:51 +0000 (13:21 +0000)]
2017-12-07 Richard Biener <rguenther@suse.de>
PR tree-optimization/83296
PR tree-optimization/67769
* tree-ssa-phiopt.c (conditional_replacement): Do not reset
flow sensitive info in an unrelated BB.
(value_replacement): Use reset_flow_sensitive_info.
(minmax_replacement): Reset flow sensitive info on the def
we move. Do not reset flow sensitive info in the whole BB
we move the stmt to.
(abs_replacement): Likewise.
* g++.dg/warn/Wstringop-overflow-1.C: New testcase.
segher [Thu, 7 Dec 2017 09:35:10 +0000 (09:35 +0000)]
rs6000: Don't use rs6000_cpu_attr directly
In some places in the code we currently use rs6000_cpu_attr, although
that is a cast from rs6000_tune. This patch changes things to be more
regular and clearer. Now rs6000_cpu_attr is not used any more, and
it is deleted.
dmalcolm [Wed, 6 Dec 2017 20:02:55 +0000 (20:02 +0000)]
C/C++: don't suggest implementation names as spelling fixes (PR c/83236)
gcc/c-family/ChangeLog:
PR c/83236
* c-common.c (selftest::c_family_tests): Call
selftest::c_spellcheck_cc_tests.
* c-common.h (selftest::c_spellcheck_cc_tests): New decl.
* c-spellcheck.cc: Include "selftest.h".
(name_reserved_for_implementation_p): New function.
(should_suggest_as_macro_p): New function.
(find_closest_macro_cpp_cb): Move the check for NT_MACRO to
should_suggest_as_macro_p and call it.
(selftest::test_name_reserved_for_implementation_p): New function.
(selftest::c_spellcheck_cc_tests): New function.
* c-spellcheck.h (name_reserved_for_implementation_p): New decl.
gcc/c/ChangeLog:
PR c/83236
* c-decl.c (lookup_name_fuzzy): Don't suggest names that are
reserved for use by the implementation.
gcc/cp/ChangeLog:
PR c/83236
* name-lookup.c (consider_binding_level): Don't suggest names that
are reserved for use by the implementation.
gcc/testsuite/ChangeLog:
PR c/83236
* c-c++-common/spellcheck-reserved.c: New test case.
gcc/c-family/ChangeLog:
* c-spellcheck.cc: New file, taken from macro-handling code in
spellcheck-tree.c.
* c-spellcheck.h: New file, taken from macro-handling code in
spellcheck-tree.h.
gcc/c/ChangeLog:
* c-decl.c: Include "c-family/c-spellcheck.h".
gcc/cp/ChangeLog:
* name-lookup.c: Include "c-family/c-spellcheck.h".
jakub [Wed, 6 Dec 2017 19:27:41 +0000 (19:27 +0000)]
PR tree-optimization/83293
* gimple-ssa-strength-reduction.c (insert_initializers): Use
GSI_NEW_STMT instead of GSI_SAME_STMT in gsi_insert_after that
might insert into empty bb.
jakub [Wed, 6 Dec 2017 19:22:06 +0000 (19:22 +0000)]
PR sanitizer/81281
* match.pd ((T)(P + A) - (T)P -> (T) A): Split into separate
simplify for plus with :c added, and pointer_plus without that.
((T)P - (T)(P + A) -> -(T) A): Likewise. If type is integral
with undefined overflow and the conversion is not widening,
perform negation in utype and only convert to type afterwards.
((T)(P + A) - (T)(P + B) -> (T)A - (T)B): Split into separate
simplify for plus with :c added, and pointer_plus without that.
If type is integral with undefined overflow and the conversion is
not widening, perform minus in utype and only convert to type
afterwards. Move the last pointer_diff_expr simplify into the
two outermost ifs.
* gcc.c-torture/execute/pr81281.c: New test.
* gcc.dg/pr81281-1.c: New test.
* gcc.dg/pr81281-2.c: New test.
* g++.dg/ubsan/pr81281.C: New test.
* g++.dg/ubsan/pr81281-aux.cc: New test.