]> gcc.gnu.org Git - gcc.git/log
gcc.git
3 years ago[Ada] Do not systematically suppress checks on atree.adb
Arnaud Charlet [Sun, 28 Feb 2021 13:24:59 +0000 (08:24 -0500)]
[Ada] Do not systematically suppress checks on atree.adb

gcc/ada/

* atree.adb: Do not suppress checks.

3 years ago[Ada] Removal of technical debt
Justin Squirek [Sun, 28 Feb 2021 02:57:32 +0000 (21:57 -0500)]
[Ada] Removal of technical debt

gcc/ada/

* exp_ch3.adb (Check_Missing_Others): Add comment.
(Build_Initialization_Call): Remove inaccurate accessibility
comment.
* sem_ch12.adb (Analyze_Generic_Subprogram_Declaration): Remove
test for Ada2012.
(Analyze_Package_Instantiation): Remove speculative comment.
(Inline_Instance_Body): Add comments for loops.
(Build_Subprogram_Renaming): Remove comment about fix being
partial and "ugly."
(Instantiate_Subprogram_Body): Remove comment referencing DEC
related internal issue.
(Subtypes_Match): Add comment and simplify anonymous access
test.
(Is_Global): Add test for when E is an expanded name, and
calculate the scope accordingly.
* sem_ch6.adb (Analyze_Function_Return): Update comment
regarding accessibility, and add check for
Warn_On_Ada_2012_Compatibility.
(Mask_Type_Refs): Add comments.
(Analyze_Subprogram_Declaration): Remove mysterious suppression
of elaboration checks.
* sem_ch7.adb (Preserve_Full_Attributes): Preserve Is_Atomic
value.
* sem_ch8.adb (Most_Descendant_Use_Clause): Remove comment.
(Note_Redundant_Use): Fix calls to Find_First_Use to be
Find_Most_Prev.
(Get_Object_Name): Modify error message to be more descriptive.
(Known_But_Visible): Remove mysterious special case for
GNAT_Mode.
(Find_First_Use): Removed.
(Find_Most_Prev): Renamed from Find_First_Use.
* sem_prag.adb (Check_Static_Constraint): Add comments to
routine.

3 years ago[Ada] Display Entity in debugging printouts
Bob Duff [Thu, 4 Mar 2021 21:27:05 +0000 (16:27 -0500)]
[Ada] Display Entity in debugging printouts

gcc/ada/

* treepr.adb (Print_Node): Display the Entity or Associated_Node
fields if appropriate.
* sinfo-utils.ads (F_Associated_Node, F_Entity): Remove. These
are no longer needed.

3 years ago[Ada] Apply aliasing checks only to names and not to objects as actuals
Piotr Trojanek [Mon, 1 Mar 2021 15:23:38 +0000 (16:23 +0100)]
[Ada] Apply aliasing checks only to names and not to objects as actuals

gcc/ada/

* checks.adb (Apply_Parameter_Aliasing_Checks): Replace calls to
Is_Object_Reference with calls to Is_Name_Reference; remove
asymmetric condition that only detected an aggregate as the
first actual (aggregate objects were just a special case of an
object reference that was not a name).

3 years ago[Ada] Fix varsize node name conflict
Bob Duff [Wed, 3 Mar 2021 21:12:54 +0000 (16:12 -0500)]
[Ada] Fix varsize node name conflict

gcc/ada/

* gen_il-gen.adb, gen_il-internals.ads: Generate field
enumeration literals with "F_" prefix.  Update all generated
references accordingly.
* atree.adb, einfo-utils.adb, sem_ch3.adb, sem_ch5.adb,
sem_ch6.adb, sem_ch8.adb, sinfo-cn.adb, sinfo-utils.adb,
sinfo-utils.ads, treepr.adb: Add "F_" prefix to all uses of the
field enumeration literals.

3 years ago[Ada] AI12-0411 Add "bool" to Interfaces.C
Arnaud Charlet [Wed, 3 Mar 2021 15:14:43 +0000 (10:14 -0500)]
[Ada] AI12-0411 Add "bool" to Interfaces.C

gcc/ada/

* libgnat/i-c.ads, libgnat/i-cexten.ads,
libgnat/i-cexten__128.ads: bool renamed C_bool.

3 years ago[Ada] Reject allocators in contexts restricted by SPARK
Piotr Trojanek [Wed, 3 Mar 2021 22:18:01 +0000 (23:18 +0100)]
[Ada] Reject allocators in contexts restricted by SPARK

gcc/ada/

* sem_ch4.adb (Analyze_Allocator): Reject allocators in
restricted contexts.

3 years agoFix spacing and typos in comments.
Andrew MacLeod [Thu, 17 Jun 2021 13:07:19 +0000 (09:07 -0400)]
Fix spacing and typos in comments.

* gimple-range-cache.cc: Comment cleanups.
* gimple-range-gori.cc: Comment cleanups.
* gimple-range.cc: Comment/spacing cleanups
* value-range.h: Comment cleanups.

3 years agolibstdc++: Non-triv-copyable extra args aren't simple [PR100940]
Patrick Palka [Thu, 17 Jun 2021 13:46:07 +0000 (09:46 -0400)]
libstdc++: Non-triv-copyable extra args aren't simple [PR100940]

This force-enables perfect forwarding call wrapper semantics whenever
the extra arguments of a partially applied range adaptor aren't all
trivially copyable, so as to avoid incurring unnecessary copies of
potentially expensive-to-copy objects (such as std::function objects)
when invoking the adaptor.

PR libstdc++/100940

libstdc++-v3/ChangeLog:

* include/std/ranges (__adaptor::_Partial): For the "simple"
forwarding partial specializations, also require that
the extra arguments are trivially copyable.
* testsuite/std/ranges/adaptors/100577.cc (test04): New test.

3 years agolibstdc++: Refine range adaptors' "simple extra args" mechanism [PR100940]
Patrick Palka [Thu, 17 Jun 2021 13:46:04 +0000 (09:46 -0400)]
libstdc++: Refine range adaptors' "simple extra args" mechanism [PR100940]

The _S_has_simple_extra_args mechanism is used to simplify forwarding
of range adaptor's extra arguments when perfect forwarding call wrapper
semantics isn't required for correctness, on a per-adaptor basis.
Both views::take and views::drop are flagged as such, but it turns out
perfect forwarding semantics are needed for these adaptors in some
contrived cases, e.g. when their extra argument is a move-only class
that's implicitly convertible to an integral type.

To fix this, we could just clear the flag for views::take/drop as with
views::split, but that'd come at the cost of acceptable diagnostics
for ill-formed uses of these adaptors (see PR100577).

This patch instead allows adaptors to parameterize their
_S_has_simple_extra_args flag according the types of the captured extra
arguments, so that we could conditionally disable perfect forwarding
semantics only when the types of the extra arguments permit it.  We
then use this finer-grained mechanism to safely disable perfect
forwarding semantics for views::take/drop when the extra argument is
integer-like, rather than incorrectly always disabling it.  Similarly,
for views::split, rather than always enabling perfect forwarding
semantics we now safely disable it when the extra argument is a scalar
or a view, and recover good diagnostics for these common cases.

PR libstdc++/100940

libstdc++-v3/ChangeLog:

* include/std/ranges (__adaptor::_RangeAdaptor): Document the
template form of _S_has_simple_extra_args.
(__adaptor::__adaptor_has_simple_extra_args): Add _Args template
parameter pack.  Try to treat _S_has_simple_extra_args as a
variable template parameterized by _Args.
(__adaptor::_Partial): Pass _Arg/_Args to the constraint
__adaptor_has_simple_extra_args.
(views::_Take::_S_has_simple_extra_args): Templatize according
to the type of the extra argument.
(views::_Drop::_S_has_simple_extra_args): Likewise.
(views::_Split::_S_has_simple_extra_args): Define.
* testsuite/std/ranges/adaptors/100577.cc (test01, test02):
Adjust after changes to _S_has_simple_extra_args mechanism.
(test03): Define.

3 years agolibgomp: Structure element mapping for OpenMP 5.0
Chung-Lin Tang [Thu, 17 Jun 2021 13:33:32 +0000 (21:33 +0800)]
libgomp: Structure element mapping for OpenMP 5.0

This patch implement OpenMP 5.0 requirements of incrementing/decrementing
the reference count of a mapped structure at most once (across all elements)
on a construct.

This is implemented by pulling in libgomp/hashtab.h and using htab_t as a
pointer set. Structure element list siblings also have pointers-to-refcounts
linked together, to naturally achieve uniform increment/decrement without
repeating.

There are still some questions on whether using such a htab_t based set is
faster/slower than using a sorted pointer array based implementation. This
is to be researched on later.

libgomp/ChangeLog:

* hashtab.h (htab_clear): New function with initialization code
factored out from...
(htab_create): ...here, adjust to use htab_clear function.

* libgomp.h (REFCOUNT_SPECIAL): New symbol to denote range of
special refcount values, add comments.
(REFCOUNT_INFINITY): Adjust definition to use REFCOUNT_SPECIAL.
(REFCOUNT_LINK): Likewise.
(REFCOUNT_STRUCTELEM): New special refcount range for structure
element siblings.
(REFCOUNT_STRUCTELEM_P): Macro for testing for structure element
sibling maps.
(REFCOUNT_STRUCTELEM_FLAG_FIRST): Flag to indicate first sibling.
(REFCOUNT_STRUCTELEM_FLAG_LAST):  Flag to indicate last sibling.
(REFCOUNT_STRUCTELEM_FIRST_P): Macro to test _FIRST flag.
(REFCOUNT_STRUCTELEM_LAST_P): Macro to test _LAST flag.
(struct splay_tree_key_s): Add structelem_refcount and
structelem_refcount_ptr fields into a union with dynamic_refcount.
Add comments.
(gomp_map_vars): Delete declaration.
(gomp_map_vars_async): Likewise.
(gomp_unmap_vars): Likewise.
(gomp_unmap_vars_async): Likewise.
(goacc_map_vars): New declaration.
(goacc_unmap_vars): Likewise.

* oacc-mem.c (acc_map_data): Adjust to use goacc_map_vars.
(goacc_enter_datum): Likewise.
(goacc_enter_data_internal): Likewise.
* oacc-parallel.c (GOACC_parallel_keyed): Adjust to use goacc_map_vars
and goacc_unmap_vars.
(GOACC_data_start): Adjust to use goacc_map_vars.
(GOACC_data_end): Adjust to use goacc_unmap_vars.

* target.c (hash_entry_type): New typedef.
(htab_alloc): New function hook for hashtab.h.
(htab_free): Likewise.
(htab_hash): Likewise.
(htab_eq): Likewise.
(hashtab.h): Add file include.
(gomp_increment_refcount): New function.
(gomp_decrement_refcount): Likewise.
(gomp_map_vars_existing): Add refcount_set parameter, adjust to use
gomp_increment_refcount.
(gomp_map_fields_existing): Add refcount_set parameter, adjust calls
to gomp_map_vars_existing.

(gomp_map_vars_internal): Add refcount_set parameter, add local openmp_p
variable to guard OpenMP specific paths, adjust calls to
gomp_map_vars_existing, add structure element sibling splay_tree_key
sequence creation code, adjust Fortran map case to avoid increment
under OpenMP.
(gomp_map_vars): Adjust to static, add refcount_set parameter, manage
local refcount_set if caller passed in NULL, adjust call to
gomp_map_vars_internal.
(gomp_map_vars_async): Adjust and rename into...
(goacc_map_vars): ...this new function, adjust call to
gomp_map_vars_internal.

(gomp_remove_splay_tree_key): New function with code factored out from
gomp_remove_var_internal.
(gomp_remove_var_internal): Add code to handle removing multiple
splay_tree_key sequence for structure elements, adjust code to use
gomp_remove_splay_tree_key for splay-tree key removal.
(gomp_unmap_vars_internal): Add refcount_set parameter, adjust to use
gomp_decrement_refcount.
(gomp_unmap_vars): Adjust to static, add refcount_set parameter, manage
local refcount_set if caller passed in NULL, adjust call to
gomp_unmap_vars_internal.
(gomp_unmap_vars_async): Adjust and rename into...
(goacc_unmap_vars): ...this new function, adjust call to
gomp_unmap_vars_internal.
(GOMP_target): Manage refcount_set and adjust calls to gomp_map_vars and
gomp_unmap_vars.
(GOMP_target_ext): Likewise.
(gomp_target_data_fallback): Adjust call to gomp_map_vars.
(GOMP_target_data): Likewise.
(GOMP_target_data_ext): Likewise.
(GOMP_target_end_data): Adjust call to gomp_unmap_vars.
(gomp_exit_data): Add refcount_set parameter, adjust to use
gomp_decrement_refcount, adjust to queue splay-tree keys for removal
after main loop.
(GOMP_target_enter_exit_data): Manage refcount_set and adjust calls to
gomp_map_vars and gomp_exit_data.
(gomp_target_task_fn): Likewise.

* testsuite/libgomp.c-c++-common/refcount-1.c: New testcase.
* testsuite/libgomp.c-c++-common/struct-elem-1.c: New testcase.
* testsuite/libgomp.c-c++-common/struct-elem-2.c: New testcase.
* testsuite/libgomp.c-c++-common/struct-elem-3.c: New testcase.
* testsuite/libgomp.c-c++-common/struct-elem-4.c: New testcase.
* testsuite/libgomp.c-c++-common/struct-elem-5.c: New testcase.

3 years agoAdd a target calls hook: TARGET_PUSH_ARGUMENT
H.J. Lu [Fri, 21 May 2021 18:56:55 +0000 (11:56 -0700)]
Add a target calls hook: TARGET_PUSH_ARGUMENT

1. Replace PUSH_ARGS with a target calls hook, TARGET_PUSH_ARGUMENT, which
takes an integer argument.  When it returns true, push instructions will
be used to pass outgoing arguments.  If the argument is nonzero, it is
the number of bytes to push and indicates the PUSH instruction usage is
optional so that the backend can decide if PUSH instructions should be
generated.  Otherwise, the argument is zero.
2. Implement x86 target hook which returns false when the number of bytes
to push is no less than 16 (8 for 32-bit targets) if vector load and store
can be used.
3. Remove target PUSH_ARGS definitions which return 0 as it is the same
as the default.
4. Define TARGET_PUSH_ARGUMENT of cr16 and m32c to always return true.

gcc/

PR target/100704
* calls.c (expand_call): Replace PUSH_ARGS with
targetm.calls.push_argument (0).
(emit_library_call_value_1): Likewise.
* defaults.h (PUSH_ARGS): Removed.
(PUSH_ARGS_REVERSED): Replace PUSH_ARGS with
targetm.calls.push_argument (0).
* expr.c (block_move_libcall_safe_for_call_parm): Likewise.
(emit_push_insn): Pass the number bytes to push to
targetm.calls.push_argument and pass 0 if ARGS_ADDR is 0.
* hooks.c (hook_bool_uint_true): New.
* hooks.h (hook_bool_uint_true): Likewise.
* rtlanal.c (nonzero_bits1): Replace PUSH_ARGS with
targetm.calls.push_argument (0).
* target.def (push_argument): Add a targetm.calls hook.
* targhooks.c (default_push_argument): New.
* targhooks.h (default_push_argument): Likewise.
* config/bpf/bpf.h (PUSH_ARGS): Removed.
* config/cr16/cr16.c (TARGET_PUSH_ARGUMENT): New.
* config/cr16/cr16.h (PUSH_ARGS): Removed.
* config/i386/i386.c (ix86_push_argument): New.
(TARGET_PUSH_ARGUMENT): Likewise.
* config/i386/i386.h (PUSH_ARGS): Removed.
* config/m32c/m32c.c (TARGET_PUSH_ARGUMENT): New.
* config/m32c/m32c.h (PUSH_ARGS): Removed.
* config/nios2/nios2.h (PUSH_ARGS): Likewise.
* config/pru/pru.h (PUSH_ARGS): Likewise.
* doc/tm.texi.in: Remove PUSH_ARGS documentation.  Add
TARGET_PUSH_ARGUMENT hook.
* doc/tm.texi: Regenerated.

gcc/testsuite/

PR target/100704
* gcc.target/i386/pr100704-1.c: New test.
* gcc.target/i386/pr100704-2.c: Likewise.
* gcc.target/i386/pr100704-3.c: Likewise.

3 years agoi386: Add variable vec_set for 64bit vectors [PR97194]
Uros Bizjak [Thu, 17 Jun 2021 13:19:12 +0000 (15:19 +0200)]
i386: Add variable vec_set for 64bit vectors [PR97194]

To generate sane code a SSE4.1 variable PBLENDV instruction is needed.

2021-06-17  Uroš Bizjak  <ubizjak@gmail.com>

gcc/
PR target/97194
* config/i386/i386-expand.c (expand_vector_set_var):
Handle V2FS mode remapping.  Pass TARGET_MMX_WITH_SSE to
ix86_expand_vector_init_duplicate.
(ix86_expand_vector_init_duplicate): Emit insv_1 for
QImode for !TARGET_PARTIAL_REG_STALL.
* config/i386/predicates.md (vec_setm_mmx_operand): New predicate.
* config/i386/mmx.md (vec_setv2sf): Use vec_setm_mmx_operand
as operand 2 predicate.  Call ix86_expand_vector_set_var
for non-constant index operand.
(vec_setv2si): Ditto.
(vec_setv4hi): Ditto.
(vec_setv8qi): ditto.

gcc/testsuite/

PR target/97194
* gcc.target/i386/sse4_1-vec-set-1.c: New test.
* gcc.target/i386/sse4_1-vec-set-2.c: ditto.

3 years agoCleanup clz and ctz code in range_of_builtin_call.
Aldy Hernandez [Thu, 13 May 2021 17:47:41 +0000 (13:47 -0400)]
Cleanup clz and ctz code in range_of_builtin_call.

These are various cleanups to the clz/ctz code.

First, ranges from range_of_expr are always numeric so we
should adjust.  Also, the checks for non-zero were assuming the argument
was unsigned, which in the PR's testcase is clearly not.  I've cleaned
this up, so that it works either way.

I've also removed the following annoying idiom:

-         int newmini = prec - 1 - wi::floor_log2 (r.upper_bound ());
-         if (newmini == prec)

This is really a check for r.upper_bound() == 0, as floor_log2(0)
returns -1.  It's confusing.

Tested on x86-64 Linux.

gcc/ChangeLog:

PR tree-optimization/100790
* gimple-range.cc (range_of_builtin_call): Cleanup clz and ctz
code.

gcc/testsuite/ChangeLog:

* gcc.dg/pr100790.c: New test.

3 years agodocs: Use -O1 as a canonical value for -O option
Martin Liska [Thu, 17 Jun 2021 09:48:59 +0000 (11:48 +0200)]
docs: Use -O1 as a canonical value for -O option

gcc/ChangeLog:

* doc/invoke.texi: Use consistently -O1 instead of -O.

3 years agogcov: update documentation entry about string format
Martin Liska [Thu, 17 Jun 2021 09:39:11 +0000 (11:39 +0200)]
gcov: update documentation entry about string format

gcc/ChangeLog:

* gcov-io.h: Update documentation entry about string format.

3 years agoIBM Z: Fix vector intrinsics vec_double and vec_floate
Marius Hillenbrand [Wed, 16 Jun 2021 16:26:48 +0000 (18:26 +0200)]
IBM Z: Fix vector intrinsics vec_double and vec_floate

Fix the mapping of vec_double and vec_floate to builtins.

gcc/ChangeLog:

PR target/100871
* config/s390/vecintrin.h (vec_doublee): Fix to use
  __builtin_s390_vflls.
(vec_floate): Fix to use __builtin_s390_vflrd.

gcc/testsuite/ChangeLog:

* gcc.target/s390/zvector/vec-doublee.c: New test.
* gcc.target/s390/zvector/vec-floate.c: New test.

3 years agoreturn auto_vec from more dominance functions
Trevor Saunders [Sat, 12 Jun 2021 23:36:38 +0000 (19:36 -0400)]
return auto_vec from more dominance functions

This ensures the vector gets cleaned up by the caller when appropriate.

Signed-off-by: Trevor Saunders <tbsaunde@tbsaunde.org>
gcc/ChangeLog:

* dominance.c (get_dominated_to_depth): Return auto_vec<basic_block>.
* dominance.h (get_dominated_to_depth): Likewise.
(get_all_dominated_blocks): Likewise.
* cfgcleanup.c (delete_unreachable_blocks): Adjust.
* gcse.c (hoist_code): Likewise.
* tree-cfg.c (remove_edge_and_dominated_blocks): Likewise.
* tree-parloops.c (oacc_entry_exit_ok): Likewise.
* tree-ssa-dce.c (eliminate_unnecessary_stmts): Likewise.
* tree-ssa-phiprop.c (pass_phiprop::execute): Likewise.

3 years agomake get_domminated_by_region return a auto_vec
Trevor Saunders [Sat, 12 Jun 2021 18:18:05 +0000 (14:18 -0400)]
make get_domminated_by_region return a auto_vec

This makes it clear the caller owns the vector, and ensures it is cleaned up.

Signed-off-by: Trevor Saunders <tbsaunde@tbsaunde.org>
gcc/ChangeLog:

* dominance.c (get_dominated_by_region): Return auto_vec<basic_block>.
* dominance.h (get_dominated_by_region): Likewise.
* tree-cfg.c (gimple_duplicate_sese_region): Adjust.
(gimple_duplicate_sese_tail): Likewise.
(move_sese_region_to_fn): Likewise.

3 years agoreturn auto_vec from get_dominated_by
Trevor Saunders [Tue, 8 Jun 2021 03:36:15 +0000 (23:36 -0400)]
return auto_vec from get_dominated_by

Signed-off-by: Trevor Saunders <tbsaunde@tbsaunde.org>
gcc/ChangeLog:

* dominance.c (get_dominated_by): Return auto_vec<basic_block>.
* dominance.h (get_dominated_by): Likewise.
* auto-profile.c (afdo_find_equiv_class): Adjust.
* cfgloopmanip.c (duplicate_loop_to_header_edge): Likewise.
* loop-unroll.c (unroll_loop_runtime_iterations): Likewise.
* tree-cfg.c (test_linear_chain): Likewise.
(test_diamond): Likewise.

3 years agoreturn auto_vec from get_loop_hot_path
Trevor Saunders [Mon, 7 Jun 2021 00:13:38 +0000 (20:13 -0400)]
return auto_vec from get_loop_hot_path

This ensures callers take ownership of the returned vector.

Signed-off-by: Trevor Saunders <tbsaunde@tbsaunde.org>
gcc/ChangeLog:

* cfgloop.h (get_loop_hot_path): Return auto_vec<basic_block>.
* cfgloopanal.c (get_loop_hot_path): Likewise.
* tree-ssa-loop-ivcanon.c (tree_estimate_loop_size): Likewise.

3 years agoreturn auto_vec from cgraph_node::collect_callers
Trevor Saunders [Sun, 6 Jun 2021 20:30:29 +0000 (16:30 -0400)]
return auto_vec from cgraph_node::collect_callers

This ensures the callers of collect_callers () take ownership of the vector and
free it when appropriate.

Signed-off-by: Trevor Saunders <tbsaunde@tbsaunde.org>
gcc/ChangeLog:

* cgraph.c (cgraph_node::collect_callers): Return
auto_vec<cgraph_edge *>.
* cgraph.h (cgraph_node::collect_callers): Likewise.
* ipa-cp.c (create_specialized_node): Adjust.
(decide_about_value): Likewise.
(decide_whether_version_node): Likewise.
* ipa-sra.c (process_isra_node_results): Likewise.

3 years agoauto_vec copy/move improvements
Trevor Saunders [Mon, 7 Jun 2021 00:05:53 +0000 (20:05 -0400)]
auto_vec copy/move improvements

- Unfortunately using_auto_storage () needs to handle m_vec being null.
- Handle self move of an auto_vec to itself.
- Make sure auto_vec defines the classes move constructor and assignment
  operator, as well as ones taking vec<T>, so the compiler does not generate
them for us.  Per https://en.cppreference.com/w/cpp/language/move_constructor
the ones taking vec<T> do not count as the classes move constructor or
assignment operator, but we want them as well to assign a plain vec to a
auto_vec.
- Explicitly delete auto_vec's copy constructor and assignment operator.  This
  prevents unintentional expenssive coppies of the vector and makes it clear
when coppies are needed that that is what is intended.  When it is necessary to
copy a vector copy () can be used.

Signed-off-by: Trevor Saunders <tbsaunde@tbsaunde.org>
gcc/ChangeLog:

* vec.h (vl_ptr>::using_auto_storage): Handle null m_vec.
(auto_vec<T, 0>::auto_vec): Define move constructor, and delete copy
constructor.
(auto_vec<T, 0>::operator=): Define move assignment and delete copy
assignment.

3 years agoAdd debugging helpers for ranger.
Aldy Hernandez [Mon, 14 Jun 2021 09:39:33 +0000 (11:39 +0200)]
Add debugging helpers for ranger.

These are debugging aids for help in debugging ranger based passes.

gcc/ChangeLog:

* gimple-range.cc (debug_seed_ranger): New.
(dump_ranger): New.
(debug_ranger): New.

3 years agoVectorization of BB reductions
Richard Biener [Tue, 8 Jun 2021 13:10:45 +0000 (15:10 +0200)]
Vectorization of BB reductions

This adds a simple reduction vectorization capability to the
non-loop vectorizer.  Simple meaning it lacks any of the fancy
ways to generate the reduction epilogue but only supports
those we can handle via a direct internal function reducing
a vector to a scalar.  One of the main reasons is to avoid
massive refactoring at this point but also that more complex
epilogue operations are hardly profitable.

Mixed sign reductions are for now fend off and I'm not finally
settled with whether we want an explicit SLP node for the
reduction epilogue operation.  Handling mixed signs could be
done by multiplying with a { 1, -1, .. } vector.  Fend off
are also reductions with non-internal operands (constants
or register parameters for example).

Costing is done by accounting the original scalar participating
stmts for the scalar cost and log2 permutes and operations for
the vectorized epilogue.

--

SPEC CPU 2017 FP with rate workload measurements show (picked
fastest runs of three) regressions for 507.cactuBSSN_r (1.5%),
508.namd_r (2.5%), 511.povray_r (2.5%), 526.blender_r (0.5) and
527.cam4_r (2.5%) and improvements for 510.parest_r (5%) and
538.imagick_r (1.5%).  This is with -Ofast -march=znver2 on a Zen2.

Statistics on CPU 2017 shows that the overwhelming number of seeds
we find are reductions of two lanes (well - that's basically every
associative operation).  That means we put a quite high pressure
on the SLP discovery process this way.

In total we find 583218 seeds we put to SLP discovery out of which
66205 pass that and only 6185 of those make it through
code generation checks. 796 of those are discarded because the reduction
is part of a larger SLP instance.  4195 of the remaining
are deemed not profitable to vectorize and 1194 are finally
vectorized.  That's a poor 0.2% rate.

Of the 583218 seeds 486826 (83%) have two lanes, 60912 have three (10%),
28181 four (5%), 4808 five, 909 six and there are instances up to 120
lanes.

There's a set of 54086 candidate seeds we reject because
they contain a constant or invariant (not implemented yet) but still
have two or more lanes that could be put to SLP discovery.

2021-06-16  Richard Biener   <rguenther@suse.de>

PR tree-optimization/54400
* tree-vectorizer.h (enum slp_instance_kind): Add
slp_inst_kind_bb_reduc.
(reduction_fn_for_scalar_code): Declare.
* tree-vect-data-refs.c (vect_slp_analyze_instance_dependence):
Check SLP_INSTANCE_KIND instead of looking at the
representative.
(vect_slp_analyze_instance_alignment): Likewise.
* tree-vect-loop.c (reduction_fn_for_scalar_code): Export.
* tree-vect-slp.c (vect_slp_linearize_chain): Split out
chain linearization from vect_build_slp_tree_2 and generalize
for the use of BB reduction vectorization.
(vect_build_slp_tree_2): Adjust accordingly.
(vect_optimize_slp): Elide permutes at the root of BB reduction
instances.
(vectorizable_bb_reduc_epilogue): New function.
(vect_slp_prune_covered_roots): Likewise.
(vect_slp_analyze_operations): Use them.
(vect_slp_check_for_constructors): Recognize associatable
chains for BB reduction vectorization.
(vectorize_slp_instance_root_stmt): Generate code for the
BB reduction epilogue.

* gcc.dg/vect/bb-slp-pr54400.c: New testcase.

3 years agoAdd amacleod and aldyh as *vrp and ranger maintainers.
Aldy Hernandez [Thu, 17 Jun 2021 07:49:43 +0000 (09:49 +0200)]
Add amacleod and aldyh as *vrp and ranger maintainers.

ChangeLog:

* MAINTAINERS (Various Maintainers): Add Andrew and myself
as *vrp and ranger maintainers.

3 years ago[Ada] Use runtime from base compiler during stage1 (continued)
Arnaud Charlet [Wed, 16 Jun 2021 07:55:17 +0000 (03:55 -0400)]
[Ada] Use runtime from base compiler during stage1 (continued)

gcc/ada/

* gcc-interface/Make-lang.in: Use libgnat.so if libgnat.a cannot
be found.

3 years agoc++: Tweak PR101029 fix
Jason Merrill [Wed, 16 Jun 2021 21:42:15 +0000 (17:42 -0400)]
c++: Tweak PR101029 fix

The case of an initializer with side effects for a zero-length array seems
extremely unlikely, but we should still return the right type in that case.

PR c++/101029

gcc/cp/ChangeLog:

* init.c (build_vec_init): Preserve the type of base.

3 years agoDaily bump.
GCC Administrator [Thu, 17 Jun 2021 00:16:54 +0000 (00:16 +0000)]
Daily bump.

3 years agoAdd recomputation to outgoing_edge_range.
Andrew MacLeod [Wed, 16 Jun 2021 22:08:03 +0000 (18:08 -0400)]
Add recomputation to outgoing_edge_range.

The gori engine can calculate outgoing ranges for exported values.  This
change allows 1st degree recomputation.  If a name is not exported from a
block, but one of the ssa_names used directly in computing it is, then
we can recompute the ssa_name on the edge using the edge values for its
operands.

* gimple-range-gori.cc (gori_compute::has_edge_range_p): Check with
may_recompute_p.
(gori_compute::may_recompute_p): New.
(gori_compute::outgoing_edge_range_p): Perform recomputations.
* gimple-range-gori.h (class gori_compute): Add prototype.

3 years agoRange_on_edge in ranger_cache should return true for all ranges.
Andrew MacLeod [Wed, 16 Jun 2021 15:14:36 +0000 (11:14 -0400)]
Range_on_edge in ranger_cache should return true for all ranges.

Range_on_edge was implemented in the cache to always return a range, but
only returned true when the edge actally changed the range.
Return true with any range that can be calculated.

* gimple-range-cache.cc (ranger_cache::range_on_edge): Always return
true when a range can be calculated.
* gimple-range.cc (gimple_ranger::dump_bb): Check has_edge_range_p.

3 years agoCorrect documented option defaults.
Martin Sebor [Wed, 16 Jun 2021 22:49:56 +0000 (16:49 -0600)]
Correct documented option defaults.

gcc/ChangeLog:

* doc/invoke.texi (-Wmismatched-dealloc, -Wmismatched-new-delete):
Correct documented defaults.

3 years agoc++: static memfn from non-dependent base [PR101078]
Jason Merrill [Wed, 16 Jun 2021 20:09:59 +0000 (16:09 -0400)]
c++: static memfn from non-dependent base [PR101078]

After my patch for PR91706, or before that with the qualified call,
tsubst_baselink returned a BASELINK with BASELINK_BINFO indicating a base of
a still-dependent derived class.  We need to look up the relevant base binfo
in the substituted class.

PR c++/101078
PR c++/91706

gcc/cp/ChangeLog:

* pt.c (tsubst_baselink): Update binfos in non-dependent case.

gcc/testsuite/ChangeLog:

* g++.dg/template/access39.C: New test.

3 years agoFortran - ICE in gfc_check_do_variable, at fortran/parse.c:4446
Harald Anlauf [Wed, 16 Jun 2021 20:04:22 +0000 (22:04 +0200)]
Fortran - ICE in gfc_check_do_variable, at fortran/parse.c:4446

Avoid NULL pointer dereferences during error recovery.

gcc/fortran/ChangeLog:

PR fortran/95501
PR fortran/95502
* expr.c (gfc_check_pointer_assign): Avoid NULL pointer
dereference.
* match.c (gfc_match_pointer_assignment): Likewise.
* parse.c (gfc_check_do_variable): Avoid comparison with NULL
symtree.

gcc/testsuite/ChangeLog:

PR fortran/95501
PR fortran/95502
* gfortran.dg/pr95502.f90: New test.

3 years agoRevert "Fortran - ICE in gfc_check_do_variable, at fortran/parse.c:4446"
Harald Anlauf [Wed, 16 Jun 2021 20:00:52 +0000 (22:00 +0200)]
Revert "Fortran - ICE in gfc_check_do_variable, at fortran/parse.c:4446"

This reverts commit 72e3d92178b44a3722519ec68e72e307443bda70.

3 years agoFortran - ICE in gfc_check_do_variable, at fortran/parse.c:4446
Harald Anlauf [Wed, 16 Jun 2021 19:54:16 +0000 (21:54 +0200)]
Fortran - ICE in gfc_check_do_variable, at fortran/parse.c:4446

Avoid NULL pointer dereferences during error recovery.

gcc/fortran/ChangeLog:

PR fortran/95501
PR fortran/95502
* expr.c (gfc_check_pointer_assign): Avoid NULL pointer
dereference.
* match.c (gfc_match_pointer_assignment): Likewise.
* parse.c (gfc_check_do_variable): Avoid comparison with NULL
symtree.

gcc/testsuite/ChangeLog:

PR fortran/95501
PR fortran/95502
* gfortran.dg/pr95502.f90: New test.

3 years agoAvoid loading an undefined value in the ranger_cache constructor.
Andrew MacLeod [Wed, 16 Jun 2021 17:01:21 +0000 (13:01 -0400)]
Avoid loading an undefined value in the ranger_cache constructor.

Enable_new_values takes a boolean, returning the old value.  The constructor
for ranger_cache initialized the m_new_value_p field by calling this routine
and ignorng the result.  This potentially loads the old value uninitialized.

* gimple-range-cache.cc (ranger_cache::ranger_cache): Initialize
m_new_value_p directly.

3 years agolibcpp: location comparison within macro [PR100796]
Jason Merrill [Mon, 14 Jun 2021 21:37:43 +0000 (17:37 -0400)]
libcpp: location comparison within macro [PR100796]

The patch for 96391 changed linemap_compare_locations to give up on
comparing locations from macro expansions if we don't have column
information.  But in this testcase, the BOILERPLATE macro is multiple lines
long, so we do want to compare locations within the macro.  So this patch
moves the LINE_MAP_MAX_LOCATION_WITH_COLS check inside the block, to use it
for failing gracefully.

PR c++/100796
PR preprocessor/96391

libcpp/ChangeLog:

* line-map.c (linemap_compare_locations): Only use comparison with
LINE_MAP_MAX_LOCATION_WITH_COLS to avoid abort.

gcc/testsuite/ChangeLog:

* g++.dg/plugin/location-overflow-test-pr100796.c: New test.
* g++.dg/plugin/plugin.exp: Run it.

3 years agoii386: Add missing two element 64bit vector permutations [PR89021]
Uros Bizjak [Wed, 16 Jun 2021 14:07:01 +0000 (16:07 +0200)]
ii386: Add missing two element 64bit vector permutations [PR89021]

In addition to V8QI permutations, several other missing permutations are
added for 64bit vector modes for TARGET_SSSE3 and TARGET_SSE4_1 targets.

2021-06-16  Uroš Bizjak  <ubizjak@gmail.com>

gcc/
PR target/89021
* config/i386/i386-expand.c (expand_vec_perm_2perm_pblendv):
Handle 64bit modes for TARGET_SSE4_1.
(expand_vec_perm_pshufb2): Handle 64bit modes for TARGET_SSSE3.
(expand_vec_perm_even_odd_pack): Handle V4HI mode.
(expand_vec_perm_even_odd_1) <case E_V4HImode>: Expand via
expand_vec_perm_pshufb2 for TARGET_SSSE3 and via
expand_vec_perm_even_odd_pack for TARGET_SSE4_1.
* config/i386/mmx.md (mmx_packusdw): New insn pattern.

3 years agolibstdc++: Use named struct for __decay_copy
Jonathan Wakely [Wed, 16 Jun 2021 11:47:32 +0000 (12:47 +0100)]
libstdc++: Use named struct for __decay_copy

In r12-1486-gcb326a6442f09cb36b05ce556fc91e10bfeb0cf6 I changed
__decay_copy to be a function object of unnamed class type. This causes
problems when importing the library headers:

error: conflicting global module declaration 'constexpr const std::ranges::__cust_access::<unnamed struct> std::ranges::__cust_access::__decay_copy'

The fix is to use a named struct instead of an anonymous one.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/iterator_concepts.h (__decay_copy): Name type.

3 years agolibstdc++: Revert final/non-addressable changes to ranges CPOs
Jonathan Wakely [Wed, 16 Jun 2021 11:34:52 +0000 (12:34 +0100)]
libstdc++: Revert final/non-addressable changes to ranges CPOs

In r12-1489-g8b93548778a487f31f21e0c6afe7e0bde9711fc4 I made the
[range.access] CPO types final and non-addressable. Tim Song pointed out
this is wrong. Only the [range.iter.ops] functions should be final and
non-addressable. Revert the changes to the [range.access] objects.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/ranges_base.h (ranges::begin, ranges::end)
(ranges::cbegin, ranges::cend, ranges::rbeing, ranges::rend)
(ranges::crbegin, ranges::crend, ranges::size, ranges::ssize)
(ranges::empty, ranges::data, ranges::cdata): Remove final
keywords and deleted operator& overloads.
* testsuite/24_iterators/customization_points/iter_move.cc: Use
new is_customization_point_object function.
* testsuite/24_iterators/customization_points/iter_swap.cc:
Likewise.
* testsuite/std/concepts/concepts.lang/concept.swappable/swap.cc:
Likewise.
* testsuite/std/ranges/access/begin.cc: Likewise.
* testsuite/std/ranges/access/cbegin.cc: Likewise.
* testsuite/std/ranges/access/cdata.cc: Likewise.
* testsuite/std/ranges/access/cend.cc: Likewise.
* testsuite/std/ranges/access/crbegin.cc: Likewise.
* testsuite/std/ranges/access/crend.cc: Likewise.
* testsuite/std/ranges/access/data.cc: Likewise.
* testsuite/std/ranges/access/empty.cc: Likewise.
* testsuite/std/ranges/access/end.cc: Likewise.
* testsuite/std/ranges/access/rbegin.cc: Likewise.
* testsuite/std/ranges/access/rend.cc: Likewise.
* testsuite/std/ranges/access/size.cc: Likewise.
* testsuite/std/ranges/access/ssize.cc: Likewise.
* testsuite/util/testsuite_iterators.h
(is_customization_point_object): New function.

3 years agoaarch64: Model zero-high-half semantics of ADDHN/SUBHN instructions
Jonathan Wright [Mon, 14 Jun 2021 15:18:44 +0000 (16:18 +0100)]
aarch64: Model zero-high-half semantics of ADDHN/SUBHN instructions

Model the zero-high-half semantics of the narrowing arithmetic Neon
instructions in the aarch64_<sur><addsub>hn<mode> RTL pattern.
Modeling these semantics allows for better RTL combinations while
also removing some register allocation issues as the compiler now
knows that the operation is totally destructive.

Add new tests to narrow_zero_high_half.c to verify the benefit of
this change.

gcc/ChangeLog:

2021-06-14  Jonathan Wright  <jonathan.wright@arm.com>

* config/aarch64/aarch64-simd.md (aarch64_<sur><addsub>hn<mode>):
Change to an expander that emits the correct instruction
depending on endianness.
(aarch64_<sur><addsub>hn<mode>_insn_le): Define.
(aarch64_<sur><addsub>hn<mode>_insn_be): Define.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/narrow_zero_high_half.c: Add new tests.

3 years agoaarch64: Model zero-high-half semantics of [SU]QXTN instructions
Jonathan Wright [Mon, 14 Jun 2021 14:09:18 +0000 (15:09 +0100)]
aarch64: Model zero-high-half semantics of [SU]QXTN instructions

Split the aarch64_<su>qmovn<mode> pattern into separate scalar and
vector variants. Further split the vector RTL  pattern into big/
little endian variants that model the zero-high-half semantics of the
underlying instruction. Modeling these semantics allows for better
RTL combinations while also removing some register allocation issues
as the compiler now knows that the operation is totally destructive.

Add new tests to narrow_zero_high_half.c to verify the benefit of
this change.

gcc/ChangeLog:

2021-06-14  Jonathan Wright  <jonathan.wright@arm.com>

* config/aarch64/aarch64-simd-builtins.def: Split generator
for aarch64_<su>qmovn builtins into scalar and vector
variants.
* config/aarch64/aarch64-simd.md (aarch64_<su>qmovn<mode>_insn_le):
Define.
(aarch64_<su>qmovn<mode>_insn_be): Define.
(aarch64_<su>qmovn<mode>): Split into scalar and vector
variants. Change vector variant to an expander that emits the
correct instruction depending on endianness.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/narrow_zero_high_half.c: Add new tests.

3 years agoaarch64: Model zero-high-half semantics of SQXTUN instruction in RTL
Jonathan Wright [Mon, 14 Jun 2021 12:16:35 +0000 (13:16 +0100)]
aarch64: Model zero-high-half semantics of SQXTUN instruction in RTL

Split the aarch64_sqmovun<mode> pattern into separate scalar and
vector variants. Further split the vector pattern into big/little
endian variants that model the zero-high-half semantics of the
underlying instruction. Modeling these semantics allows for better
RTL combinations while also removing some register allocation issues
as the compiler now knows that the operation is totally destructive.

Add new tests to narrow_zero_high_half.c to verify the benefit of
this change.

gcc/ChangeLog:

2021-06-14  Jonathan Wright  <jonathan.wright@arm.com>

* config/aarch64/aarch64-simd-builtins.def: Split generator
for aarch64_sqmovun builtins into scalar and vector variants.
* config/aarch64/aarch64-simd.md (aarch64_sqmovun<mode>):
Split into scalar and vector variants. Change vector variant
to an expander that emits the correct instruction depending
on endianness.
(aarch64_sqmovun<mode>_insn_le): Define.
(aarch64_sqmovun<mode>_insn_be): Define.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/narrow_zero_high_half.c: Add new tests.

3 years agoaarch64: Model zero-high-half semantics of XTN instruction in RTL
Jonathan Wright [Fri, 11 Jun 2021 14:48:51 +0000 (15:48 +0100)]
aarch64: Model zero-high-half semantics of XTN instruction in RTL

Modeling the zero-high-half semantics of the XTN narrowing
instruction in RTL indicates to the compiler that this is a totally
destructive operation. This enables more RTL simplifications and also
prevents some register allocation issues.

Add new tests to narrow_zero_high_half.c to verify the benefit of
this change.

gcc/ChangeLog:

2021-06-11  Jonathan Wright  <jonathan.wright@arm.com>

* config/aarch64/aarch64-simd.md (aarch64_xtn<mode>_insn_le):
Define - modeling zero-high-half semantics.
(aarch64_xtn<mode>): Change to an expander that emits the
appropriate instruction depending on endianness.
(aarch64_xtn<mode>_insn_be): Define - modeling zero-high-half
semantics.
(aarch64_xtn2<mode>_le): Rename to...
(aarch64_xtn2<mode>_insn_le): This.
(aarch64_xtn2<mode>_be): Rename to...
(aarch64_xtn2<mode>_insn_be): This.
(vec_pack_trunc_<mode>): Emit truncation instruction instead
of aarch64_xtn.
* config/aarch64/iterators.md (Vnarrowd): Add Vnarrowd mode
attribute iterator.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/narrow_zero_high_half.c: Add new tests.

3 years agotestsuite: aarch64: Add zero-high-half tests for narrowing shifts
Jonathan Wright [Tue, 15 Jun 2021 14:03:09 +0000 (15:03 +0100)]
testsuite: aarch64: Add zero-high-half tests for narrowing shifts

Add tests to verify that Neon narrowing-shift instructions clear the
top half of the result vector. It is sufficient to show that a
subsequent combine with a zero-vector is optimized away - leaving
just the narrowing-shift instruction.

gcc/testsuite/ChangeLog:

2021-06-15  Jonathan Wright  <jonathan.wright@arm.com>

* gcc.target/aarch64/narrow_zero_high_half.c: New test.

3 years agotree-sra: Do not refresh readonly decls (PR 100453)
Martin Jambor [Wed, 16 Jun 2021 11:18:46 +0000 (13:18 +0200)]
tree-sra: Do not refresh readonly decls (PR 100453)

When SRA transforms an assignment where the RHS is an aggregate decl
that it creates replacements for, the (least efficient) fallback
method of dealing with them is to store all the replacements back into
the original decl and then let the original assignment takes its
course.

That of course should not need to be done for TREE_READONLY bases
which cannot change contents.  The SRA code handled this situation
only for DECL_IN_CONSTANT_POOL const decls, this patch modifies the
check so that it tests for TREE_READONLY and I also looked at all
other callers of generate_subtree_copies and added checks to another
one dealing with the same exact situation and one which deals with it
in a non-assignment context.

gcc/ChangeLog:

2021-06-11  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/100453
* tree-sra.c (create_access): Disqualify any const candidates
which are written to.
(sra_modify_expr): Do not store sub-replacements back to a const base.
(handle_unscalarized_data_in_subtree): Likewise.
(sra_modify_assign): Likewise.  Earlier, use TREE_READONLy test
instead of constant_decl_p.

gcc/testsuite/ChangeLog:

2021-06-10  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/100453
* gcc.dg/tree-ssa/pr100453.c: New test.

3 years agotestsuite: Use noipa attribute instead of noinline, noclone
Jakub Jelinek [Wed, 16 Jun 2021 11:10:48 +0000 (13:10 +0200)]
testsuite: Use noipa attribute instead of noinline, noclone

I've noticed this test now on various arches sometimes FAILs, sometimes
PASSes (the line 12 test in particular).

The problem is that a = 0; initialization in the caller no longer happens
before the f(&a) call as what the argument points to is only used in
debug info.

Making the function noipa forces the caller to initialize it and still
tests what the test wants to test, namely that we don't consider *p as
valid location for the c variable at line 18 (after it has been overwritten
with *p = 1;).

2021-06-16  Jakub Jelinek  <jakub@redhat.com>

* gcc.dg/guality/pr49888.c (f): Use noipa attribute instead of
noinline, noclone.

3 years agostor-layout: Create DECL_BIT_FIELD_REPRESENTATIVE even for bitfields in unions [PR101062]
Jakub Jelinek [Wed, 16 Jun 2021 10:17:55 +0000 (12:17 +0200)]
stor-layout: Create DECL_BIT_FIELD_REPRESENTATIVE even for bitfields in unions [PR101062]

The following testcase is miscompiled on x86_64-linux, the bitfield store
is implemented as a RMW 64-bit operation at d+24 when the d variable has
size of only 28 bytes and scheduling moves in between the R and W part
a store to a different variable that happens to be right after the d
variable.

The reason for this is that we weren't creating
DECL_BIT_FIELD_REPRESENTATIVEs for bitfields in unions.

The following patch does create them, but treats all such bitfields as if
they were in a structure where the particular bitfield is the only field.

2021-06-16  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/101062
* stor-layout.c (finish_bitfield_representative): For fields in unions
assume nextf is always NULL.
(finish_bitfield_layout): Compute bit field representatives also in
unions, but handle it as if each bitfield was the only field in the
aggregate.

* gcc.dg/pr101062.c: New test.

3 years agotree-optimization/101088 - fix SM invalidation issue
Richard Biener [Wed, 16 Jun 2021 07:49:18 +0000 (09:49 +0200)]
tree-optimization/101088 - fix SM invalidation issue

When we face a sm_ord vs sm_unord for the same ref during
store sequence merging we assert that the ref is already marked
unsupported.  But it can be that it will only be marked so
during the ongoing merging so instead of asserting mark it here.

Also apply some optimization to not waste resources to search
for already unsupported refs.

2021-06-16  Richard Biener  <rguenther@suse.de>

PR tree-optimization/101088
* tree-ssa-loop-im.c (sm_seq_valid_bb): Only look for
supported refs on edges.  Do not assert same ref but
different kind stores are unsuported but mark them so.
(hoist_memory_references): Only look for supported refs
on exits.

* gcc.dg/torture/pr101088.c: New testcase.

3 years ago[PATCH] PR rtl-optimization/46235: Improved use of bt for bit tests on x86_64.
Roger Sayle [Wed, 16 Jun 2021 08:56:09 +0000 (09:56 +0100)]
[PATCH] PR rtl-optimization/46235: Improved use of bt for bit tests on x86_64.

This patch tackles PR46235 to improve the code generated for bit tests
on x86_64 by making more use of the bt instruction.  Currently, GCC emits
bt instructions when followed by condition jumps (thanks to Uros' splitters).
This patch adds splitters in i386.md, to catch the cases where bt is followed
by a conditional move (as in the original report), or by a setc/setnc (as in
comment 5 of the Bugzilla PR).

With this patch, the function in the original PR
int foo(int a, int x, int y) {
    if (a & (1 << x))
       return a;
   return 1;
}

which with -O2 on mainline generates:
foo: movl    %edi, %eax
        movl    %esi, %ecx
        sarl    %cl, %eax
        testb   $1, %al
        movl    $1, %eax
        cmovne  %edi, %eax
        ret

now generates:
foo: btl     %esi, %edi
        movl    $1, %eax
        cmovc   %edi, %eax
        ret

Likewise, IsBitSet1 and IsBitSet2 (from comment 5)
bool IsBitSet1(unsigned char byte, int index) {
    return (byte & (1<<index)) != 0;
}
bool IsBitSet2(unsigned char byte, int index) {
    return (byte >> index) & 1;
}

Before:
        movzbl  %dil, %eax
        movl    %esi, %ecx
        sarl    %cl, %eax
        andl    $1, %eax
        ret

After:
        movzbl  %dil, %edi
        btl     %esi, %edi
        setc    %al
        ret

According to Agner Fog, SAR/SHR r,cl takes 2 cycles on skylake,
where BT r,r takes only one, so the performance improvements on
recent hardware may be more significant than implied by just
the reduced number of instructions.  I've avoided transforming cases
(such as btsi_setcsi) where using bt sequences may not be a clear
win (over sarq/andl).

2010-06-15  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
PR rtl-optimization/46235
* config/i386/i386.md: New define_split for bt followed by cmov.
(*bt<mode>_setcqi): New define_insn_and_split for bt followed by setc.
(*bt<mode>_setncqi): New define_insn_and_split for bt then setnc.
(*bt<mode>_setnc<mode>): New define_insn_and_split for bt followed
by setnc with zero extension.

gcc/testsuite/ChangeLog
PR rtl-optimization/46235
* gcc.target/i386/bt-5.c: New test.
* gcc.target/i386/bt-6.c: New test.
* gcc.target/i386/bt-7.c: New test.

3 years agolibffi: Fix up x86_64 classify_argument
Jakub Jelinek [Wed, 16 Jun 2021 08:45:27 +0000 (10:45 +0200)]
libffi: Fix up x86_64 classify_argument

As the following testcase shows, libffi didn't handle properly
classify_arguments of structures at byte offsets not divisible by
UNITS_PER_WORD.  The following patch adjusts it to match what
config/i386/ classify_argument does for that and also ports the
PR38781 fix there (the second chunk).

This has been committed to upstream libffi already:
https://github.com/libffi/libffi/commit/5651bea284ad0822eafe768e3443c2f4d7da2c8f

2021-06-16  Jakub Jelinek  <jakub@redhat.com>

* src/x86/ffi64.c (classify_argument): For FFI_TYPE_STRUCT set words
to number of words needed for type->size + byte_offset bytes rather
than just type->size bytes.  Compute pos before the loop and check
total size of the structure.
* testsuite/libffi.call/nested_struct12.c: New test.

3 years ago[Ada] Fix Is_Volatile_Function for functions declared in protected bodies
Piotr Trojanek [Wed, 3 Mar 2021 20:19:39 +0000 (21:19 +0100)]
[Ada] Fix Is_Volatile_Function for functions declared in protected bodies

gcc/ada/

* sem_util.adb (Is_Volatile_Function): Follow the exact wording
of SPARK (regarding volatile functions) and Ada (regarding
protected functions).

3 years ago[Ada] Ignore volatile restrictions in preanalysis
Piotr Trojanek [Wed, 3 Mar 2021 19:15:56 +0000 (20:15 +0100)]
[Ada] Ignore volatile restrictions in preanalysis

gcc/ada/

* sem_util.adb (Is_OK_Volatile_Context): All references to
volatile objects are legal in preanalysis.
(Within_Volatile_Function): Previously it was wrongly called on
Empty entities; now it is only called on E_Return_Statement,
which allow the body to be greatly simplified.

3 years ago[Ada] Do not generate an Itype_Reference node for slices in GNATprove mode
Yannick Moy [Wed, 3 Mar 2021 13:54:09 +0000 (14:54 +0100)]
[Ada] Do not generate an Itype_Reference node for slices in GNATprove mode

gcc/ada/

* sem_res.adb (Set_Slice_Subtype): Revert special-case
introduced previously, which is not needed as Itypes created for
slices are precisely always used.

3 years ago[Ada] Fix floating-point exponentiation with Integer'First exponent
Eric Botcazou [Wed, 3 Mar 2021 19:15:42 +0000 (20:15 +0100)]
[Ada] Fix floating-point exponentiation with Integer'First exponent

gcc/ada/

* urealp.adb (Scale): Change first paramter to Uint and adjust.
(Equivalent_Decimal_Exponent): Pass U.Den directly to Scale.
* libgnat/s-exponr.adb (Negative): Rename to...
(Safe_Negative): ...this and change its lower bound.
(Exponr): Adjust to above renaming and deal with Integer'First.

3 years ago[Ada] Fix detection of volatile expressions in restricted contexts
Piotr Trojanek [Mon, 1 Mar 2021 15:39:31 +0000 (16:39 +0100)]
[Ada] Fix detection of volatile expressions in restricted contexts

gcc/ada/

* sem_res.adb (Flag_Effectively_Volatile_Objects): Detect also
allocators within restricted contexts and not just entity names.
(Resolve_Actuals): Remove duplicated code for detecting
restricted contexts; it is now exclusively done in
Is_OK_Volatile_Context.
(Resolve_Entity_Name): Adapt to new parameter of
Is_OK_Volatile_Context.
* sem_util.ads, sem_util.adb (Is_OK_Volatile_Context): Adapt to
handle contexts both inside and outside of subprogram call
actual parameters.
(Within_Subprogram_Call): Remove; now handled by
Is_OK_Volatile_Context itself and its parameter.

3 years ago[Ada] Cleanup repeated calls in Sloc_Range
Piotr Trojanek [Wed, 3 Mar 2021 10:45:41 +0000 (11:45 +0100)]
[Ada] Cleanup repeated calls in Sloc_Range

gcc/ada/

* sinput.adb (Sloc_Range): Refactor several repeated calls to
Sloc and two comparisons with No_Location.

3 years ago[Ada] Fix aliasing check for actual parameters passed by reference
Piotr Trojanek [Mon, 1 Mar 2021 13:01:25 +0000 (14:01 +0100)]
[Ada] Fix aliasing check for actual parameters passed by reference

gcc/ada/

* checks.adb (Apply_Scalar_Range_Check): Fix handling of check depending
on the parameter passing mechanism.  Grammar adjustment ("has"
=> "have").
(Parameter_Passing_Mechanism_Specified): Add a hyphen in a comment.

3 years ago[Ada] Remove unused initialization with New_List
Piotr Trojanek [Sun, 28 Feb 2021 23:03:47 +0000 (00:03 +0100)]
[Ada] Remove unused initialization with New_List

gcc/ada/

* exp_ch3.adb (Build_Slice_Assignment): Remove unused
initialization.

3 years ago[Ada] Fix typos in all occurrences of "occuring" in GNAT
Piotr Trojanek [Tue, 2 Mar 2021 08:58:20 +0000 (09:58 +0100)]
[Ada] Fix typos in all occurrences of "occuring" in GNAT

gcc/ada/

* restrict.adb, sem_attr.adb, types.ads: Fix typos in
"occuring"; refill comment as necessary.

3 years ago[Ada] Adapt Is_Actual_Parameter to also work for entry parameters
Piotr Trojanek [Tue, 2 Mar 2021 14:37:36 +0000 (15:37 +0100)]
[Ada] Adapt Is_Actual_Parameter to also work for entry parameters

gcc/ada/

* sem_util.ads (Is_Actual_Parameter): Update comment.
* sem_util.adb (Is_Actual_Parameter): Also detect entry parameters.

3 years ago[Ada] Wrong reference to System.Tasking in expanded code
Arnaud Charlet [Sun, 28 Feb 2021 13:25:42 +0000 (08:25 -0500)]
[Ada] Wrong reference to System.Tasking in expanded code

gcc/ada/

* rtsfind.ads, libgnarl/s-taskin.ads, exp_ch3.adb, exp_ch4.adb,
exp_ch6.adb, exp_ch9.adb, sem_ch6.adb: Move master related
entities to the expander directly.

3 years ago[Ada] Cleanup related to volatile objects in restricted contexts
Piotr Trojanek [Mon, 1 Mar 2021 15:36:08 +0000 (16:36 +0100)]
[Ada] Cleanup related to volatile objects in restricted contexts

gcc/ada/

* sem_res.adb (Is_Assignment_Or_Object_Expression): Whitespace
cleanup.
(Is_Attribute_Expression): Prevent AST climbing from going to
the root of the compilation unit.

3 years ago[Ada] Include info about containers in GNAT RM Implementation Advice section
Steve Baird [Mon, 1 Mar 2021 22:39:17 +0000 (14:39 -0800)]
[Ada] Include info about containers in GNAT RM Implementation Advice section

gcc/ada/

* doc/gnat_rm/implementation_advice.rst: Add a section for RM
A.18 .
* gnat_rm.texi: Regenerate.

3 years ago[Ada] Mixing of positional and named entries allowed in enum rep
Justin Squirek [Sat, 27 Feb 2021 19:16:32 +0000 (14:16 -0500)]
[Ada] Mixing of positional and named entries allowed in enum rep

gcc/ada/

* sem_ch13.adb (Analyze_Enumeration_Representation_Clause): Add
check for the mixing of entries.

3 years ago[Ada] Non-static Interrupt_Priority allowed with restriction Static_Priorities
Justin Squirek [Sun, 28 Feb 2021 00:09:48 +0000 (19:09 -0500)]
[Ada] Non-static Interrupt_Priority allowed with restriction Static_Priorities

gcc/ada/

* sem_ch13.adb (Make_Aitem_Pragma): Check for static expressions
in Priority aspect arguments for restriction Static_Priorities.

3 years ago[Ada] Spurious accessibility error on "for of" loop parameter
Justin Squirek [Sat, 27 Feb 2021 19:30:09 +0000 (14:30 -0500)]
[Ada] Spurious accessibility error on "for of" loop parameter

gcc/ada/

* sem_util.adb (Accessibility_Level): Take into account
renamings of loop parameters.

3 years ago[Ada] Fix ALI source location for dominance markers
Matthieu Eyraud [Tue, 23 Feb 2021 07:54:30 +0000 (08:54 +0100)]
[Ada] Fix ALI source location for dominance markers

gcc/ada/

* par_sco.adb (Set_Statement_Entry): Change sloc for dominance
marker.
(Traverse_One): Fix typo.
(Output_Header): Fix comment.

3 years ago[Ada] Don't look for aliases for generic subprograms
Richard Kenner [Sun, 28 Feb 2021 16:00:33 +0000 (11:00 -0500)]
[Ada] Don't look for aliases for generic subprograms

gcc/ada/

* exp_unst.adb (Register_Subprogram): Don't look for aliases for
subprograms that are generic.  Reorder tests for efficiency.

3 years ago[Ada] Make Incomplete_Or_Partial_View independent of the context
Eric Botcazou [Wed, 24 Feb 2021 11:29:10 +0000 (12:29 +0100)]
[Ada] Make Incomplete_Or_Partial_View independent of the context

gcc/ada/

* sem_util.adb (Incomplete_Or_Partial_View): Retrieve the scope of
the parameter and use it to find its incomplete view, if any.

3 years ago[Ada] Do not perform useless work in Check_No_Parts_Violations
Eric Botcazou [Tue, 23 Feb 2021 11:50:25 +0000 (12:50 +0100)]
[Ada] Do not perform useless work in Check_No_Parts_Violations

gcc/ada/

* freeze.adb (Check_No_Parts_Violations): Return earlier if the
type is elementary or does not come from source.

3 years ago[Ada] Fix missing array bounds checking
Bob Duff [Tue, 23 Feb 2021 20:50:21 +0000 (15:50 -0500)]
[Ada] Fix missing array bounds checking

gcc/ada/

* ghost.adb: Add another special case where full analysis is
needed. This bug is due to quirks in the way
Mark_And_Set_Ghost_Assignment works (it happens very early,
before name resolution is done).

3 years ago[Ada] Use more straightforward implementation for Current_Entity_In_Scope
Eric Botcazou [Sun, 21 Feb 2021 17:27:25 +0000 (18:27 +0100)]
[Ada] Use more straightforward implementation for Current_Entity_In_Scope

gcc/ada/

* sem_util.adb (Current_Entity_In_Scope): Reimplement.

3 years ago[Ada] Remove extra parens around a function call
Piotr Trojanek [Fri, 19 Feb 2021 12:05:34 +0000 (13:05 +0100)]
[Ada] Remove extra parens around a function call

gcc/ada/

* sem_ch8.adb (End_Scope): Remove extra parens.

3 years ago[Ada] ACATS 4.1R-c611a04: Class-wide preconditions in dispatching calls
Javier Miranda [Thu, 18 Feb 2021 18:47:10 +0000 (13:47 -0500)]
[Ada] ACATS 4.1R-c611a04: Class-wide preconditions in dispatching calls

gcc/ada/

* exp_disp.adb (Build_Class_Wide_Check): Ensure that evaluation
of actuals is side effects free (since the check duplicates
actuals).

3 years ago[Ada] Implementation of AI12-0152: legality rules for Raise_Expression
Ed Schonberg [Thu, 18 Feb 2021 16:09:36 +0000 (11:09 -0500)]
[Ada] Implementation of AI12-0152: legality rules for Raise_Expression

gcc/ada/

* sem_res.adb (Resolve_Raise_Expression): Apply Ada_2020 rules
concerning the need for parentheses around Raise_Expressions in
various contexts.

3 years ago[Ada] Reorder code for validity checks of unchecked conversions
Piotr Trojanek [Wed, 17 Feb 2021 22:32:25 +0000 (23:32 +0100)]
[Ada] Reorder code for validity checks of unchecked conversions

gcc/ada/

* sem_ch13.adb (Validate_Unchecked_Conversion): Move detection
of generic types before switching to their private views; fix
style in using AND THEN.

3 years ago[Ada] Raise expressions and unconstrained components
Arnaud Charlet [Wed, 17 Feb 2021 11:29:03 +0000 (06:29 -0500)]
[Ada] Raise expressions and unconstrained components

gcc/ada/

* sem_ch3.adb (Analyze_Component_Declaration): Do not special
case raise expressions.

gcc/testsuite/

* gnat.dg/limited4.adb: Disable illegal code.

3 years ago[Ada] Clarify the documentation of -gnaty0 style check option
Sergey Rybin [Wed, 17 Feb 2021 13:31:08 +0000 (16:31 +0300)]
[Ada] Clarify the documentation of -gnaty0 style check option

gcc/ada/

* doc/gnat_ugn/building_executable_programs_with_gnat.rst:
Instead of referring to the formatting of the Ada examples in
Ada RM add use the list of checks that are actually performed.
* gnat_ugn.texi: Regenerate.

3 years ago[Ada] Small cleanup in C header files
Eric Botcazou [Wed, 17 Feb 2021 08:00:19 +0000 (09:00 +0100)]
[Ada] Small cleanup in C header files

gcc/ada/

* initialize.c: Do not include vxWorks.h and fcntl.h from here.
(__gnat_initialize) [__MINGW32__]: Remove #ifdef and attribute
(__gnat_initialize) [init_float]: Delete.
(__gnat_initialize) [VxWorks]: Likewise.
(__gnat_initialize) [PA-RISC HP-UX 10]: Likewise.
* runtime.h: Add comment about vxWorks.h include.

3 years ago[Ada] Small cleanup in System.Exceptions
Eric Botcazou [Wed, 17 Feb 2021 07:55:15 +0000 (08:55 +0100)]
[Ada] Small cleanup in System.Exceptions

gcc/ada/

* libgnat/s-except.ads (ZCX_By_Default): Delete.
(Require_Body): Likewise.
* libgnat/s-except.adb: Replace body with pragma No_Body.

3 years agotree-optimization/101083 - fix ICE with SLP reassoc
Richard Biener [Wed, 16 Jun 2021 06:56:21 +0000 (08:56 +0200)]
tree-optimization/101083 - fix ICE with SLP reassoc

This makes us pass down the vector type for the two-operand
SLP node build rather than picking that from operand one which,
when constant or external, could be NULL.

2021-06-16  Richard Biener  <rguenther@suse.de>

PR tree-optimization/101083
* tree-vect-slp.c (vect_slp_build_two_operator_nodes): Get
vectype as argument.
(vect_build_slp_tree_2): Adjust.

* gcc.dg/vect/pr97832-4.c: New testcase.

3 years agoDaily bump.
GCC Administrator [Wed, 16 Jun 2021 00:17:05 +0000 (00:17 +0000)]
Daily bump.

3 years agoanalyzer: fix bitfield endianness issues [PR99212,PR101082]
David Malcolm [Tue, 15 Jun 2021 21:53:34 +0000 (17:53 -0400)]
analyzer: fix bitfield endianness issues [PR99212,PR101082]

Looks like my patch for PR analyzer/99212 implicitly assumed
little-endian, which the following patch fixes.

Fixes bitfields-1.c on:
- armeb-none-linux-gnueabihf
- cris-elf
- powerpc64-darwin
- s390-linux-gnu

gcc/analyzer/ChangeLog:
PR analyzer/99212
PR analyzer/101082
* engine.cc: Include "target.h".
(impl_run_checkers): Log BITS_BIG_ENDIAN, BYTES_BIG_ENDIAN, and
WORDS_BIG_ENDIAN.
* region-model-manager.cc
(region_model_manager::maybe_fold_binop): Move support for masking
via ARG0 & CST into...
(region_model_manager::maybe_undo_optimize_bit_field_compare):
...this new function.  Flatten by converting from nested
conditionals to a series of early return statements to reject
failures.  Reject if type is not unsigned_char_type_node.
Handle BYTES_BIG_ENDIAN when determining which bits are bound
in the binding_map.
* region-model.h
(region_model_manager::maybe_undo_optimize_bit_field_compare):
New decl.
* store.cc (bit_range::dump): New function.
* store.h (bit_range::dump): New decl.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
3 years agoConsider size_t mangling as unsigned int and long [PR100876].
Martin Sebor [Tue, 15 Jun 2021 18:42:06 +0000 (12:42 -0600)]
Consider size_t mangling as unsigned int and long [PR100876].

gcc/ChangeLog:

PR middle-end/100876
* builtins.c: (gimple_call_return_array): Account for size_t
mangling as either unsigned int or unsigned long

3 years agolibstdc++: Make ranges CPOs final and not addressable
Jonathan Wakely [Tue, 15 Jun 2021 16:54:53 +0000 (17:54 +0100)]
libstdc++: Make ranges CPOs final and not addressable

This restricts the API of the CPOs and other function objects so they
cannot be misused by deriving from them or taking their addresses.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/ranges_base.h (ranges::begin, ranges::end)
(ranges::cbegin, ranges::cend, ranges::rbeing, ranges::rend)
(ranges::crbegin, ranges::crend, ranges::size, ranges::ssize)
(ranges::empty, ranges::data, ranges::cdata): Make types final.
Add deleted operator& overloads.
(ranges::advance, ranges::distance, ranges::next, ranges::prev):
Likewise.
* testsuite/std/ranges/headers/ranges/synopsis.cc: Replace
ill-formed & expressions with using-declarations. Add checks for
other function objects.

3 years agolibstdc++: Add noexcept specifiers to some range adaptors
Jonathan Wakely [Tue, 15 Jun 2021 15:36:12 +0000 (16:36 +0100)]
libstdc++: Add noexcept specifiers to some range adaptors

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/ranges_util.h (view_interface): Add noexcept to
empty, operator bool, data and size members.
(subrange): Add noexcept to constructors.
* include/std/ranges (single_view, ref_view): Add noexcept to
constructors.
(views::single, views::all): Add noexcept.
* testsuite/std/ranges/adaptors/all.cc: Check noexcept.
* testsuite/std/ranges/single_view.cc: Likewise.

3 years agolibstdc++: Remove precondition checks from ranges::subrange
Jonathan Wakely [Tue, 15 Jun 2021 14:07:25 +0000 (15:07 +0100)]
libstdc++: Remove precondition checks from ranges::subrange

The assertion in the subrange constructor causes semantic changes,
because the call to ranges::distance performs additional operations that
are not part of the constructor's specification. That will fail to
compile if the iterator is move-only, because the argument to
ranges::distance is passed by value. It will modify the subrange if the
iterator is not a forward iterator, because incrementing the copy also
affects the _M_begin member. Those problems could be prevented by using
if-constexpr to only do the assertion for copyable forward iterators,
but the call to ranges::distance can also prevent the constructor being
usable in constant expressions. If the member initializers are usable in
constant expressions, but iterator increments of equality comparisons
are not, then the checks done by __glibcxx_assert might
make constant evaluation fail.

This change removes the assertion. Additionally, a new typedef is
introduced to simplify the declarations using __make_unsigned_like_t on
the iterator's difference type.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/ranges_util.h (subrange): Add __size_type typedef
and use it to simplify declarations.
(subrange(i, s, n)): Remove assertion.
* testsuite/std/ranges/subrange/constexpr.cc: New test.

3 years agolibstdc++: Use function object for __decay_copy helper
Jonathan Wakely [Tue, 15 Jun 2021 13:39:02 +0000 (14:39 +0100)]
libstdc++: Use function object for __decay_copy helper

By changing __cust_access::__decay_copy from a function template to a
function object we avoid ADL. That means it's fine to call it
unqualified (the compiler won't waste time doing ADL in associated
namespaces, and won't try to complete associated types).

This also makes some other minor simplications to other concepts for the
[range.access] CPOs.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/iterator_concepts.h (__cust_access::__decay_copy):
Replace with function object.
(__cust_access::__member_begin, ___cust_access::_adl_begin): Use
__decay_copy unqualified.
* include/bits/ranges_base.h (__member_end, __adl_end):
Likewise. Use __range_iter_t for type of ranges::begin.
(__member_rend): Use correct value category for rbegin argument.
(__member_data): Use __decay_copy unqualified.
(__begin_data): Use __range_iter_t for type of ranges::begin.

3 years agoMinor improvement to compare elimination
Jeff Law [Tue, 15 Jun 2021 16:42:42 +0000 (12:42 -0400)]
Minor improvement to compare elimination

gcc/
* compare-elim.c (try_eliminate_compare): Run DCE to clean things
up before eliminating comparisons.

3 years agorange-ops: (nonzero | X) is nonzero
Aldy Hernandez [Mon, 14 Jun 2021 10:51:48 +0000 (12:51 +0200)]
range-ops: (nonzero | X) is nonzero

For bitwise or, nonzero|X is always nonzero.  Make sure we don't drop to
varying in this case.

gcc/ChangeLog:

* range-op.cc (operator_bitwise_or::wi_fold): Make sure
nonzero|X is nonzero.
(range_op_bitwise_and_tests): Add tests for above.

3 years agoFix for vcmpequt builtin
Carl Love [Thu, 10 Jun 2021 22:36:25 +0000 (17:36 -0500)]
Fix for vcmpequt builtin

The vcmpequt builtin define eqvv1ti3 points to the eqv define instruction
for the eqv instruction.  The vcmpequt builtin define should point to the
vector_eqv1ti instruction definition for the vcmpequq instruction.

2021-06-15  Carl Love  <cel@us.ibm.com>

gcc/ChangeLog
PR target/101022
* config/rs6000/rs6000-builtin.def (VCMPEQUT): Fix the ICODE for the
enum definition.
(VRLQ, VSLQ, VSRQ, VSRAQ): Remove unused BU_P10_OVERLOAD_2
definitions.

3 years agoFortran/OpenMP: Extend defaultmap clause for OpenMP 5 [PR92568]
Tobias Burnus [Tue, 15 Jun 2021 14:06:38 +0000 (16:06 +0200)]
Fortran/OpenMP: Extend defaultmap clause for OpenMP 5 [PR92568]

PR fortran/92568

gcc/fortran/ChangeLog:

* dump-parse-tree.c (show_omp_clauses): Update for defaultmap.
* f95-lang.c (LANG_HOOKS_OMP_ALLOCATABLE_P,
LANG_HOOKS_OMP_SCALAR_TARGET_P): New.
* gfortran.h (enum gfc_omp_defaultmap,
enum gfc_omp_defaultmap_category): New.
* openmp.c (gfc_match_omp_clauses): Update defaultmap matching.
* trans-decl.c (gfc_finish_decl_attrs): Set GFC_DECL_SCALAR_TARGET.
* trans-openmp.c (gfc_omp_allocatable_p, gfc_omp_scalar_target_p): New.
(gfc_omp_scalar_p): Take 'ptr_alloc_ok' argument.
(gfc_trans_omp_clauses, gfc_split_omp_clauses): Update for
defaultmap changes.
* trans.h (gfc_omp_scalar_p): Update prototype.
(gfc_omp_allocatable_p, gfc_omp_scalar_target_p): New.
(struct lang_decl): Add scalar_target.
(GFC_DECL_SCALAR_TARGET, GFC_DECL_GET_SCALAR_TARGET): New.

gcc/ChangeLog:

* gimplify.c (enum gimplify_defaultmap_kind): Add GDMK_SCALAR_TARGET.
(struct gimplify_omp_ctx): Extend defaultmap array by one.
(new_omp_context): Init defaultmap[GDMK_SCALAR_TARGET].
(omp_notice_variable): Update type classification for Fortran.
(gimplify_scan_omp_clauses): Update calls for new argument; handle
GDMK_SCALAR_TARGET; for Fortran, GDMK_POINTER avoid GOVD_MAP_0LEN_ARRAY.
* langhooks-def.h (lhd_omp_scalar_p): Add 'ptr_ok' argument.
* langhooks.c (lhd_omp_scalar_p): Likewise.
(LANG_HOOKS_OMP_ALLOCATABLE_P, LANG_HOOKS_OMP_SCALAR_TARGET_P): New.
(LANG_HOOKS_DECLS): Add them.
* langhooks.h (struct lang_hooks_for_decls): Add new hooks, update
omp_scalar_p pointer type to include the new bool argument.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/defaultmap-8.f90: New test.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/pr99928-1.f90: Uncomment 'defaultmap(none)'.
* gfortran.dg/gomp/pr99928-2.f90: Uncomment 'defaultmap(none)'.
* gfortran.dg/gomp/pr99928-3.f90: Uncomment 'defaultmap(none)'.
* gfortran.dg/gomp/pr99928-4.f90: Uncomment 'defaultmap(none)'.
* gfortran.dg/gomp/pr99928-5.f90: Uncomment 'defaultmap(none)'.
* gfortran.dg/gomp/pr99928-6.f90: Uncomment 'defaultmap(none)'.
* gfortran.dg/gomp/pr99928-8.f90: Uncomment 'defaultmap(none)'.
* gfortran.dg/gomp/defaultmap-1.f90: New test.
* gfortran.dg/gomp/defaultmap-2.f90: New test.
* gfortran.dg/gomp/defaultmap-3.f90: New test.
* gfortran.dg/gomp/defaultmap-4.f90: New test.
* gfortran.dg/gomp/defaultmap-5.f90: New test.
* gfortran.dg/gomp/defaultmap-6.f90: New test.
* gfortran.dg/gomp/defaultmap-7.f90: New test.

3 years agoanalyzer: track dynamic extents of regions
David Malcolm [Tue, 15 Jun 2021 13:31:26 +0000 (09:31 -0400)]
analyzer: track dynamic extents of regions

This patch extends region_model to add tracking of the sizes of
dynamically-allocated regions, both on the heap (via malloc etc) and
stack (via alloca).  It adds enough purging of this state to avoid
blowing up any existing analyzer test cases.

The state can be queried via a new "__analyzer_dump_capacity" for use
in DejaGnu tests but other than that doesn't do anything - I have
various followup experiments that make use of this.

gcc/analyzer/ChangeLog:
* engine.cc (exploded_node::on_stmt): Handle __analyzer_dump_capacity.
(exploded_node::on_stmt): Drop m_sm_changes from on_stmt_flags.
(state_change_requires_new_enode_p): New function...
(exploded_graph::process_node): Call it, rather than querying
flags.m_sm_changes, so that dynamic-extent differences can also
trigger the splitting of nodes.
* exploded-graph.h (struct on_stmt_flags): Drop field m_sm_changes.
* program-state.cc (program_state::detect_leaks): Purge dead
heap-allocated regions from dynamic extents.
(selftest::test_program_state_1): Fix type of "size_in_bytes".
(selftest::test_program_state_merging): Likewise.
* region-model-impl-calls.cc
(region_model::impl_call_analyzer_dump_capacity): New.
(region_model::impl_call_free): Remove dynamic extents from the
freed region.
* region-model-reachability.h
(reachable_regions::begin_mutable_base_regs): New.
(reachable_regions::end_mutable_base_regs): New.
* region-model.cc: Include "tree-object-size.h".
(region_model::region_model): Support new field m_dynamic_extents.
(region_model::operator=): Likewise.
(region_model::operator==): Likewise.
(region_model::dump_to_pp): Dump sizes of dynamic regions.
(region_model::handle_unrecognized_call): Purge dynamic extents
from any regions that have escaped mutably:.
(region_model::get_capacity): New function.
(region_model::add_constraint): Unset dynamic extents when a
heap-allocated region's address is NULL.
(region_model::unbind_region_and_descendents): Purge dynamic
extents of unbound regions.
(region_model::can_merge_with_p): Call
m_dynamic_extents.can_merge_with_p.
(region_model::create_region_for_heap_alloc): Assert that
size_in_bytes's type is compatible with size_type_node.  Update
for renaming of record_dynamic_extents to set_dynamic_extents.
(region_model::create_region_for_alloca): Likewise.
(region_model::record_dynamic_extents): Rename to...
(region_model::set_dynamic_extents): ...this.  Assert that
size_in_bytes's type is compatible with size_type_node.  Add it
to the m_dynamic_extents map.
(region_model::get_dynamic_extents): New.
(region_model::unset_dynamic_extents): New.
(selftest::test_state_merging): Fix type of "size".
(selftest::test_malloc_constraints): Likewise.
(selftest::test_malloc): Verify dynamic extents.
(selftest::test_alloca): Likewise.
* region-model.h (region_to_value_map::is_empty): New.
(region_model::dynamic_extents_t): New typedef.
(region_model::impl_call_analyzer_dump_capacity): New decl.
(region_model::get_dynamic_extents): New function.
(region_model::get_dynamic_extents): New decl.
(region_model::set_dynamic_extents): New decl.
(region_model::unset_dynamic_extents): New decl.
(region_model::get_capacity): New decl.
(region_model::record_dynamic_extents): Rename to set_dynamic_extents.
(region_model::m_dynamic_extents): New field.

gcc/ChangeLog:
* doc/analyzer.texi
(Special Functions for Debugging the Analyzer): Add
__analyzer_dump_capacity.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/analyzer-decls.h (__analyzer_dump_capacity): New decl.
* gcc.dg/analyzer/capacity-1.c: New test.
* gcc.dg/analyzer/capacity-2.c: New test.
* gcc.dg/analyzer/capacity-3.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
3 years agoanalyzer: add class region_to_value_map
David Malcolm [Tue, 15 Jun 2021 13:30:18 +0000 (09:30 -0400)]
analyzer: add class region_to_value_map

Add a class for associating symbolic values with regions, for use
initially for recording the sizes of dynamically-allocated regions,
though this also could potentially be used for e.g. tracking strlen()
values.

gcc/analyzer/ChangeLog:
* region-model.cc (region_to_value_map::operator=): New.
(region_to_value_map::operator==): New.
(region_to_value_map::dump_to_pp): New.
(region_to_value_map::dump): New.
(region_to_value_map::can_merge_with_p): New.
* region-model.h (class region_to_value_map): New class.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
3 years agoanalyzer testsuite: add explode-2a.c [PR101068]
David Malcolm [Tue, 15 Jun 2021 13:29:23 +0000 (09:29 -0400)]
analyzer testsuite: add explode-2a.c [PR101068]

Due to a bug (PR analyzer/101068), the analyzer only explores a limited
subset of the possible paths through gcc.dg/analyzer/explode-2.c,
and this artifically helps stop this testcase from exploding.
I intend to fix this at some point, but for now, this patch adds a
revised test case which captures the effective CFG due to the bug, so
that we explicitly have test coverage for that CFG.

gcc/testsuite/ChangeLog:
PR analyzer/101068
* gcc.dg/analyzer/explode-2a.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
3 years ago[Ada] Avoid unhelpful dead code warnings
Steve Baird [Sat, 13 Feb 2021 00:34:04 +0000 (16:34 -0800)]
[Ada] Avoid unhelpful dead code warnings

gcc/ada/

* exp_util.adb (Kill_Dead_Code): Generalize the existing
handling of if statements to handle case statements similarly.

3 years ago[Ada] Remove couple of obsolete declarations
Eric Botcazou [Tue, 16 Feb 2021 17:20:40 +0000 (18:20 +0100)]
[Ada] Remove couple of obsolete declarations

gcc/ada/

* raise.h (_gnat_builtin_longjmp): Delete.
(set_gnat_exit_status): Likewise.

3 years ago[Ada] Enable removal of side-effects in component declarations
Piotr Trojanek [Tue, 16 Feb 2021 13:58:46 +0000 (14:58 +0100)]
[Ada] Enable removal of side-effects in component declarations

gcc/ada/

* exp_util.adb (Possible_Side_Effect_In_SPARK): Handle component
declaration just like full type and subtype declarations.

This page took 0.117801 seconds and 5 git commands to generate.