platform/upstream/gcc.git
3 years ago[Ada] Assert failure on complex code with private type and discriminant
Arnaud Charlet [Tue, 8 Dec 2020 17:14:08 +0000 (12:14 -0500)]
[Ada] Assert failure on complex code with private type and discriminant

gcc/ada/

* einfo.adb (Discriminant_Constraint): Refine assertion.

3 years ago[Ada] AI12-0397: Default_Initial_Condition expressions for derived types
Gary Dismukes [Mon, 7 Dec 2020 06:58:10 +0000 (01:58 -0500)]
[Ada] AI12-0397: Default_Initial_Condition expressions for derived types

gcc/ada/

* exp_util.adb (Add_Own_DIC): Suppress expansion of a DIC pragma
when the pragma occurs for an abstract type, since that could
lead to a call to an abstract function, and such DIC checks can
never be performed for abstract types in any case.
* sem_disp.adb (Check_Dispatching_Context): Suppress the check
for illegal calls to abstract subprograms when the call occurs
within a Default_Initial_Condition aspect and the call is passed
the current instance as an actual.
(Has_Controlling_Current_Instance_Actual): New function to test
a call to see if it has any actuals given by direct references
to a current instance of a type
* sem_res.adb (Resolve_Actuals): Issue an error for a call
within a DIC aspect to a nonprimitive subprogram with an actual
given by the name of the DIC type's current instance (which will
show up as a reference to the formal parameter of a DIC
procedure).

3 years ago[Ada] Crash on inherited component in type extension in generic unit.
Ed Schonberg [Tue, 8 Dec 2020 00:34:01 +0000 (19:34 -0500)]
[Ada] Crash on inherited component in type extension in generic unit.

gcc/ada/

* exp_ch3.adb (Expand_Record_Extension): Set Parent_Subtype on
the type extension when within a generic unit, even though
expansion is disabled, to allow for proper resolution of
selected components inherited from an ancestor.

3 years ago[Ada] Crash with declare expression used in a postcondition
Arnaud Charlet [Thu, 3 Dec 2020 15:06:47 +0000 (10:06 -0500)]
[Ada] Crash with declare expression used in a postcondition

gcc/ada/

* sem_aux.adb (Is_Limited_Type): Fix logic to check Is_Type
before assuming Ent is a typo.
* sem_ch4.adb (Analyze_Expression_With_Actions): Update
comments, minor reformatting.
* sem_res.adb (Resolve_Declare_Expression): Add protection
against no type.

3 years ago[Ada] Incorrect discriminant check on call to access to subprogram
Arnaud Charlet [Tue, 8 Dec 2020 13:16:45 +0000 (08:16 -0500)]
[Ada] Incorrect discriminant check on call to access to subprogram

gcc/ada/

* exp_ch6.adb: Fix typo in comment.
* sem_ch3.adb (Access_Subprogram_Declaration): Add missing call
to Create_Extra_Formals. Remove obsolete bootstrap check.
* sem_eval.adb (Eval_Selected_Component): Simplify a
selected_component on an aggregate.

3 years ago[Ada] Remove double initialization of interpretation tables
Piotr Trojanek [Mon, 7 Dec 2020 23:22:20 +0000 (00:22 +0100)]
[Ada] Remove double initialization of interpretation tables

gcc/ada/

* fmap.ads (Reset_Tables): Remove outdated references to
GNSA/ASIS.
* sem_eval.ads (Initialize): Likewise.
* sem_type.adb (Headers): Remove initialization at elaboration.
* sem_type.ads (Init_Interp_Tables): Remove outdated reference
to gnatf.
* stringt.ads (Initialize): Fix style in comment.

3 years ago[Ada] Update reference with description of type resolution
Piotr Trojanek [Mon, 7 Dec 2020 22:47:12 +0000 (23:47 +0100)]
[Ada] Update reference with description of type resolution

gcc/ada/

* sem_res.ads: Update reference in comment.
* sem_type.ads: Fix casing in a name of a unit.

3 years ago[Ada] Improve error message for ghost in predicate
Yannick Moy [Tue, 8 Dec 2020 08:23:09 +0000 (09:23 +0100)]
[Ada] Improve error message for ghost in predicate

gcc/ada/

* ghost.adb (Check_Ghost_Context): Add continuation message when
in predicate.

3 years ago[Ada] Couple of adjustments for the sake of static analyzers
Eric Botcazou [Mon, 7 Dec 2020 21:04:43 +0000 (22:04 +0100)]
[Ada] Couple of adjustments for the sake of static analyzers

gcc/ada/

* libgnat/s-valrea.adb (Integer_to_Real): Use a subtype of Num
for the component type of the table of powers of ten.
* libgnat/s-valuer.adb (Round_Extra): Add assertion on Base.

3 years ago[Ada] Extend compile-time evaluation in case statements to all objects
Piotr Trojanek [Mon, 7 Dec 2020 15:54:06 +0000 (16:54 +0100)]
[Ada] Extend compile-time evaluation in case statements to all objects

gcc/ada/

* sem_ch5.adb (Analyze_Case_Statement): Extend optimization to
all objects; fix typo in comment.

3 years ago[Ada] Cleanups related to entry barrier conditions
Piotr Trojanek [Mon, 7 Dec 2020 14:32:40 +0000 (15:32 +0100)]
[Ada] Cleanups related to entry barrier conditions

gcc/ada/

* exp_ch9.adb (Build_Barrier_Function): Refine type of a
protected type entity.
(Is_Pure_Barrier): Fix style.

3 years ago[Ada] Incorrect error with Default_Value on private/modular type
Bob Duff [Mon, 7 Dec 2020 13:16:34 +0000 (08:16 -0500)]
[Ada] Incorrect error with Default_Value on private/modular type

gcc/ada/

* exp_ch3.adb (Simple_Init_Defaulted_Type): Simplify the code,
and always use OK_Convert_To, rather than Unchecked_Convert_To
and Convert_To.

3 years ago[Ada] Remove unused subprograms
Arnaud Charlet [Mon, 7 Dec 2020 12:47:37 +0000 (07:47 -0500)]
[Ada] Remove unused subprograms

gcc/ada/

* sem_ch3.adb (Analyze_Object_Declaration): Remove dead code.
* ali.ads, ali.adb (Scan_ALI): Remove unused parameters.
Remove unused code related to Xref lines.
(Get_Typeref): Removed, no longer used.

3 years ago[Ada] Bad handling of 'Valid_Scalars and arrays
Arnaud Charlet [Wed, 2 Dec 2020 09:15:36 +0000 (04:15 -0500)]
[Ada] Bad handling of 'Valid_Scalars and arrays

gcc/ada/

* exp_attr.adb (Build_Array_VS_Func, Build_Record_VS_Func,
Expand_N_Attribute_Reference): Use Get_Fullest_View instead of
Validated_View.
(Build_Record_VS_Func): Adjust to keep using Validated_View.
(Expand_N_Attribute_Reference) [Valid]: Use
Small_Integer_Type_For to allow for more compile time
evaluations.
* sem_util.adb (Cannot_Raise_Constraint_Error): Add more precise
support for N_Indexed_Component and fix support for
N_Selected_Component which wasn't completely safe.
(List_Cannot_Raise_CE): New.
* libgnat/i-cobol.adb (Valid_Packed): Simplify test to address
new GNAT warning.

3 years ago[Ada] Fix the Sphinx configuration and port it to Python3
Arnaud Charlet [Wed, 7 Apr 2021 09:11:57 +0000 (05:11 -0400)]
[Ada] Fix the Sphinx configuration and port it to Python3

gcc/ada/

* .gitignore: New.
* doc/share/conf.py: Add Python 3 compatibility.
* doc/share/gnat.sty: Add missing file.

3 years ago[Ada] Hashed container Cursor type predefined equality non-conformance
Richard Wai [Mon, 15 Mar 2021 10:24:00 +0000 (06:24 -0400)]
[Ada] Hashed container Cursor type predefined equality non-conformance

gcc/ada/

* libgnat/a-cohase.ads (Cursor): Synchronize comments for the Cursor
type definition to be consistent with identical definitions in other
container packages. Add additional comments regarding the importance of
maintaining the "Position" component for predefined equality.
* libgnat/a-cohama.ads (Cursor): Likewise.
* libgnat/a-cihama.ads (Cursor): Likewise.
* libgnat/a-cohase.adb (Find, Insert): Ensure that Cursor objects
always have their "Position" component set to ensure predefined
equality works as required.
* libgnat/a-cohama.adb (Find, Insert): Likewise.
* libgnat/a-cihama.adb (Find, Insert): Likewise.

gcc/testsuite/

* gnat.dg/containers2.adb: New test.

3 years agoAvoid creating useless local bounds around calls
Eric Botcazou [Wed, 28 Apr 2021 08:21:59 +0000 (10:21 +0200)]
Avoid creating useless local bounds around calls

This prevents the compiler from creating useless local bounds around calls
that take a parameter of an unconstrained array type when the bounds already
exist somewhere else for the actual parameter.

gcc/ada/
* gcc-interface/decl.c (gnat_to_gnu_subprog_type): Do not demote a
const or pure function because of a parameter whose type is pointer
to function.
* gcc-interface/trans.c (Call_to_gnu): Do not put back a conversion
between an actual and a formal that are unconstrained array types.
(gnat_gimplify_expr) <CALL_EXPR>: New case.
* gcc-interface/utils2.c (build_binary_op): Do not use |= operator.
(gnat_stabilize_reference_1): Likewise.
(gnat_rewrite_reference): Likewise.
(build_unary_op): Do not clear existing TREE_CONSTANT on the result.
(gnat_build_constructor): Also accept the address of a constant
CONSTRUCTOR as constant element.

3 years agoGet rid of useless temporary for call to pure function
Eric Botcazou [Wed, 28 Apr 2021 07:58:21 +0000 (09:58 +0200)]
Get rid of useless temporary for call to pure function

This avoids creating a useless temporary for a call to a pure function with
good properties by using the RSO.

gcc/ada/
* gcc-interface/trans.c (is_array_of_scalar_type): New predicate.
(find_decls_r): New function.
(return_slot_opt_for_pure_call_p): New predicate.
(Call_to_gnu): Do not create a temporary for the return value if the
parent node is an aggregate.  If there is a target, try to apply the
return slot optimization to regular calls to pure functions returning
an array of scalar type.

3 years agoFix loss of optimization of array iteration due to inlining
Eric Botcazou [Wed, 28 Apr 2021 07:43:02 +0000 (09:43 +0200)]
Fix loss of optimization of array iteration due to inlining

This helps loop-invariant motion to hoist complicated offset computations.

gcc/ada/
* gcc-interface/trans.c (language_function): Add comment.
(loop_info_d): Add fndecl and invariants fields.
(find_loop_for): Test fndecl instead of the context of var.
(find_loop): New function.
(Regular_Loop_to_gnu): Fold back into...
(Loop_Statement_to_gnu): ...this.  Emit invariants on entry, if any.
(gnat_to_gnu) <N_Selected_Component>: Record nonconstant invariant
offset computations in loops when optimization is enabled.
* gcc-interface/utils2.c (gnat_invariant_expr): Handle BIT_AND_EXPR.
gcc/testsuite/
* gnat.dg/opt93.ads, gnat.dg/opt93.adb: New test.

3 years agolibstdc++: Fix various bugs in ranges_algo.h [PR100187, ...]
Patrick Palka [Wed, 28 Apr 2021 03:21:19 +0000 (23:21 -0400)]
libstdc++: Fix various bugs in ranges_algo.h [PR100187, ...]

This fixes some bugs with our ranges algorithms in uncommon situations,
such as when the return type of a predicate is a non-copyable class type
that's implicitly convertible to bool (PR100187), when a comparison
predicate isn't invocable as an rvalue (PR100237), and when the return
type of a projection function is non-copyable (PR100249).

This also fixes PR100287, which reports that we're moving __first twice
when constructing with it an empty subrange in ranges::partition.

libstdc++-v3/ChangeLog:

PR libstdc++/100187
PR libstdc++/100237
PR libstdc++/100249
PR libstdc++/100287
* include/bits/ranges_algo.h (__search_n_fn::operator()): Give
the __value_comp lambda an explicit bool return type.
(__is_permutation_fn::operator()): Give the __proj_scan local
variable auto&& return type.  Give the __comp_scan lambda an
explicit bool return type.
(__remove_fn::operator()): Give the __pred lambda an explicit
bool return type.
(__partition_fn::operator()): Don't std::move __first twice
when returning an empty subrange.
(__min_fn::operator()): Don't std::move __comp.
(__max_fn::operator()): Likewise.
(__minmax_fn::operator()): Likewise.

3 years agoDaily bump.
GCC Administrator [Wed, 28 Apr 2021 00:16:36 +0000 (00:16 +0000)]
Daily bump.

3 years agoaix: Alias -m64 to -maix64 and -m32 to -maix32.
David Edelsohn [Tue, 27 Apr 2021 20:09:07 +0000 (16:09 -0400)]
aix: Alias -m64 to -maix64 and -m32 to -maix32.

GCC on AIX historically has used -maix64 and -maix32 to switch to 64 bit mode
or 32 bit mode, unlike other ports that use -m64 and -m32.  The Alias()
directive for options cannot be used because aix64 is expected in multiple
parts of the compiler infrastructure and one cannot switch to -m64 due to
backward compatibility.

This patch defines DRIVER_SELF_SPECS to translate -m64 to -maix64 and
-m32 to -maix32 so that the command line option compatible with other
targets can be used while continuing to allow the historical options.

gcc/ChangeLog:

* config/rs6000/aix.h (SUBTARGET_DRIVER_SELF_SPECS): New.
* config/rs6000/aix64.opt (m64): New.
(m32): New.

3 years agoc++: -Wdeprecated-copy and using operator= [PR92145]
Jason Merrill [Fri, 23 Apr 2021 20:41:35 +0000 (16:41 -0400)]
c++: -Wdeprecated-copy and using operator= [PR92145]

For the purpose of [depr.impldec] "if the class has a user-declared copy
assignment operator", an operator= brought in from a base class with 'using'
may be a copy-assignment operator, but it isn't a copy-assignment operator
for the derived class.

gcc/cp/ChangeLog:

PR c++/92145
* class.c (classtype_has_depr_implicit_copy): Check DECL_CONTEXT
of operator=.

gcc/testsuite/ChangeLog:

PR c++/92145
* g++.dg/cpp0x/depr-copy3.C: New test.

3 years agoc++: Fix Bases(args...)... base initialization [PR88580]
Patrick Palka [Tue, 27 Apr 2021 18:18:25 +0000 (14:18 -0400)]
c++: Fix Bases(args...)... base initialization [PR88580]

When substituting into the arguments of a base initializer pack
expansion, tsubst_initializer_list uses a dummy EXPR_PACK_EXPANSION
in order to expand an initializer such as Bases(args)... into
Bases#{0}(args#{0}) and so on.  But when an argument inside the base
initializer is itself a pack expansion, as in Bases(args...)..., the
argument is already an EXPR_PACK_EXPANSION so we don't need to wrap it.
It's also independent from the outer expansion of Bases, so we need to
"multiplicatively" append the expansion of args... onto the argument
list of each expanded base.

gcc/cp/ChangeLog:

PR c++/88580
* pt.c (tsubst_initializer_list): Correctly handle the case
where an argument inside a base initializer pack expansion is
itself a pack expansion.

gcc/testsuite/ChangeLog:

PR c++/88580
* g++.dg/cpp0x/variadic182.C: New test.

3 years agolibstdc++: Fix up lambda in join_view::_Iterator::operator++ [PR100290]
Patrick Palka [Tue, 27 Apr 2021 18:07:46 +0000 (14:07 -0400)]
libstdc++: Fix up lambda in join_view::_Iterator::operator++ [PR100290]

Currently, the return type of this lambda is decltype(auto), so the
lambda ends up returning a copy of _M_parent->_M_inner rather than a
reference to it when _S_ref_glvalue is false.  This means _M_inner and
ranges::end(__inner_range) are respectively an iterator and sentinel for
different ranges, so comparing them is undefined.

libstdc++-v3/ChangeLog:

PR libstdc++/100290
* include/std/ranges (join_view::_Iterator::operator++): Correct
the return type of the lambda to avoid returning a copy of
_M_parent->_M_inner.
* testsuite/std/ranges/adaptors/join.cc (test10): New test.

3 years agoVAX: Accept ASHIFT in address expressions
Maciej W. Rozycki [Wed, 21 Apr 2021 21:33:25 +0000 (23:33 +0200)]
VAX: Accept ASHIFT in address expressions

Fix regressions:

FAIL: gcc.c-torture/execute/20090113-2.c   -O1  (internal compiler error)
FAIL: gcc.c-torture/execute/20090113-2.c   -O1  (test for excess errors)
FAIL: gcc.c-torture/execute/20090113-3.c   -O1  (internal compiler error)
FAIL: gcc.c-torture/execute/20090113-3.c   -O1  (test for excess errors)

triggering if LRA is used rather than old reload and caused by:

(plus:SI (plus:SI (mult:SI (reg:SI 30 [ _10 ])
            (const_int 4 [0x4]))
        (reg/f:SI 26 [ _6 ]))
    (const_int 12 [0xc]))

coming from:

(insn 58 57 59 10 (set (reg:SI 33 [ _13 ])
        (zero_extract:SI (mem:SI (plus:SI (plus:SI (mult:SI (reg:SI 30 [ _10 ])
                            (const_int 4 [0x4]))
                        (reg/f:SI 26 [ _6 ]))
                    (const_int 12 [0xc])) [4 _6->bits[_10]+0 S4 A32])
            (reg:QI 56)
            (reg:SI 53)))
".../gcc/testsuite/gcc.c-torture/execute/20090113-2.c":64:12 490 {*extzv_non_const}
     (expr_list:REG_DEAD (reg:QI 56)
        (expr_list:REG_DEAD (reg:SI 53)
            (expr_list:REG_DEAD (reg:SI 30 [ _10 ])
                (expr_list:REG_DEAD (reg/f:SI 26 [ _6 ])
                    (nil))))))

being converted into:

(plus:SI (plus:SI (ashift:SI (reg:SI 30 [ _10 ])
            (const_int 2 [0x2]))
        (reg/f:SI 26 [ _6 ]))
    (const_int 12 [0xc]))

which is an rtx the VAX backend currently does not recognize as a valid
machine address, although apparently it is only inside MEM rtx's that
indexed addressing is supposed to be canonicalized to a MULT rather than
ASHIFT form.  Handle the ASHIFT form too throughout the backend then.

The change appears to also improve code generation with old reload and
code size stats are as follows, collected from 18153 executables built
in `check-c' GCC testing:

              samples average  median
--------------------------------------
regressions        47  0.702%  0.521%
unchanged       17503  0.000%  0.000%
progressions      603 -0.920% -0.403%
--------------------------------------
total           18153 -0.029%  0.000%

with a small number of outliers (over 5% size change):

old     new     change  %change filename
----------------------------------------------------
1885    1645    -240   -12.7320 pr53505.exe
1331    1221    -110    -8.2644 pr89634.exe
1553    1473    -80     -5.1513 stdatomic-vm.exe
1413    1341    -72     -5.0955 pr45830.exe
1415    1343    -72     -5.0883 stdatomic-vm.exe
25765   24463   -1302   -5.0533 strlen-5.exe
25765   24463   -1302   -5.0533 strlen-5.exe
25765   24463   -1302   -5.0533 strlen-5.exe
1191    1131    -60     -5.0377 20050527-1.exe

(all changes on the expansion side are below 5%).

gcc/
* config/vax/vax.c (print_operand_address, vax_address_cost_1)
(index_term_p): Handle ASHIFT too.

3 years agoVAX: Fix ill-formed `jbb<ccss>i<mode>' insn operands
Maciej W. Rozycki [Wed, 21 Apr 2021 21:33:11 +0000 (23:33 +0200)]
VAX: Fix ill-formed `jbb<ccss>i<mode>' insn operands

The insn has extraneous operand #3 that is aliased in RTL to operand #0
with a constraint.  The operands specify a single-bit field in memory
that the machine instruction produced boths reads for the purpose of
determining whether to branch or not and either clears or sets according
to the machine operation selected with the `ccss' iterator.  The caller
of the insn is supposed to supply the same rtx for both operands.

This odd arrangement happens to work with old reload, but breaks with
libatomic if LRA is used instead:

.../libatomic/flag.c: In function 'atomic_flag_test_and_set':
.../libatomic/flag.c:36:1: error: unable to generate reloads for:
   36 | }
      | ^
(jump_insn 7 6 19 2 (unspec_volatile [
            (set (pc)
                (if_then_else (eq (zero_extract:SI (mem/v:QI (reg:SI 27) [-1  S1 A8])
                            (const_int 1 [0x1])
                            (const_int 0 [0]))
                        (const_int 1 [0x1]))
                    (label_ref:SI 25)
                    (pc)))
            (set (zero_extract:SI (mem/v:QI (reg:SI 28) [-1  S1 A8])
                    (const_int 1 [0x1])
                    (const_int 0 [0]))
                (const_int 1 [0x1]))
        ] 100) ".../libatomic/flag.c":35:10 669 {jbbssiqi}
     (nil)
 -> 25)
during RTL pass: reload
.../libatomic/flag.c:36:1: internal compiler error: in curr_insn_transform, at lra-constraints.c:4098
0x1112c587 _fatal_insn(char const*, rtx_def const*, char const*, int, char const*)
.../gcc/rtl-error.c:108
0x10ee6563 curr_insn_transform
.../gcc/lra-constraints.c:4098
0x10eeaf87 lra_constraints(bool)
.../gcc/lra-constraints.c:5133
0x10ec97e3 lra(_IO_FILE*)
.../gcc/lra.c:2336
0x10e4633f do_reload
.../gcc/ira.c:5827
0x10e46b27 execute
.../gcc/ira.c:6013
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Switch to using `match_dup' as expected then for a machine instruction
that in its encoding only has one actual operand in for the single-bit
field.

gcc/
* config/vax/builtins.md (jbb<ccss>i<mode>): Remove operand #3.
(sync_lock_test_and_set<mode>): Adjust accordingly.
(sync_lock_release<mode>): Likewise.

3 years agoVAX: Remove dead `adjacent_operands_p' function
Maciej W. Rozycki [Wed, 21 Apr 2021 21:33:02 +0000 (23:33 +0200)]
VAX: Remove dead `adjacent_operands_p' function

This function has never been used and it is unclear what its intended
purpose was.

gcc/
* config/vax/vax-protos.h (adjacent_operands_p): Remove
prototype.
* config/vax/vax.c (adjacent_operands_p): Remove.

3 years agoifcvt: Fall through to NCE if getting the CE condition failed
Maciej W. Rozycki [Thu, 3 Dec 2020 11:35:06 +0000 (11:35 +0000)]
ifcvt: Fall through to NCE if getting the CE condition failed

If getting the condition for conditional execution has failed then fall
through and try the non-conditional execution approach instead rather
than giving up with dead code elimination altogether, for a better code
structure if nothing else.

The case may well now be that whenever `cond_exec_get_condition' fails
`noce_get_condition' will as well, however in that case no change in
semantics will result.  If they ever diverge, then someone will have to
chase this place.

gcc/
* ifcvt.c (dead_or_predicable) [!IFCVT_MODIFY_TESTS]: Fall
through to the non-conditional execution case if getting the
condition for conditional execution has failed.

3 years agoFix handling of VEC_COND_EXPR trap tests [PR100284]
Richard Sandiford [Tue, 27 Apr 2021 17:30:36 +0000 (18:30 +0100)]
Fix handling of VEC_COND_EXPR trap tests [PR100284]

Now that VEC_COND_EXPR has normal unnested operands,
operation_could_trap_p can treat it like any other expression.

This fixes many testsuite ICEs for SVE, but it turns out that none
of the tests in gcc.target/aarch64/sve were affected.  Anyone testing
on non-SVE aarch64 therefore wouldn't have seen it.

gcc/
PR middle-end/100284
* gimple.c (gimple_could_trap_p_1): Remove VEC_COND_EXPR test.
* tree-eh.c (operation_could_trap_p): Handle VEC_COND_EXPR rather
than asserting on it.

gcc/testsuite/
PR middle-end/100284
* gcc.target/aarch64/sve/pr81003.c: New test.

3 years agoRemove malformed dg-warning directives.
Martin Sebor [Tue, 27 Apr 2021 17:00:53 +0000 (11:00 -0600)]
Remove malformed dg-warning directives.

gcc/testsuite/ChangeLog:
PR testsuite/100272
* g++.dg/ext/flexary13.C: Remove malformed directives.

3 years agopowerpc: fix bootstrap.
David Edelsohn [Tue, 27 Apr 2021 16:59:59 +0000 (16:59 +0000)]
powerpc: fix bootstrap.

gcc/ChangeLog:

* config/rs6000/rs6000.c (rs6000_aix_precompute_tls_p): Protect
with TARGET_AIX_OS.

3 years agoaix: TLS precompute register parameters (PR 94177)
David Edelsohn [Sun, 11 Apr 2021 23:41:26 +0000 (19:41 -0400)]
aix: TLS precompute register parameters (PR 94177)

AIX uses a compiler-managed TOC for global data, including TLS symbols.
The GCC TOC implementation manages the TOC entries through the constant pool.

TLS symbols sometimes require a function call to obtain the TLS base
pointer.  The arguments to the TLS call can conflict with arguments to
a normal function call if the TLS symbol is an argument in the normal call.
GCC specifically checks for this situation and precomputes the TLS
arguments, but the mechanism to check for this requirement utilizes
legitimate_constant_p().  The necessary result of legitimate_constant_p()
for correct TOC behavior and for correct TLS argument behavior is in
conflict.

This patch adds a new target hook precompute_tls_p() to decide if an
argument should be precomputed regardless of the result from
legitmate_constant_p().

gcc/ChangeLog:

PR target/94177
* calls.c (precompute_register_parameters): Additionally test
targetm.precompute_tls_p to pre-compute argument.
* config/rs6000/aix.h (TARGET_PRECOMPUTE_TLS_P): Define.
* config/rs6000/rs6000.c (rs6000_aix_precompute_tls_p): New.
* target.def (precompute_tls_p): New.
* doc/tm.texi.in (TARGET_PRECOMPUTE_TLS_P): Add hook documentation.
* doc/tm.texi: Regenerated.

3 years agoaarch64: Fix up last commit [PR100200]
Jakub Jelinek [Tue, 27 Apr 2021 15:50:53 +0000 (17:50 +0200)]
aarch64: Fix up last commit [PR100200]

Pedantically signed vs. unsigned mismatches in va_arg are only well defined
if the value can be represented in both signed and unsigned integer types.

2021-04-27  Jakub Jelinek  <jakub@redhat.com>

PR target/100200
* config/aarch64/aarch64.c (aarch64_print_operand): Cast -UINTVAL
back to HOST_WIDE_INT.

3 years agoFix target/100106 ICE in gen_movdi
Bernd Edlinger [Wed, 21 Apr 2021 12:13:04 +0000 (14:13 +0200)]
Fix target/100106 ICE in gen_movdi

As the test case shows, the outer mode may have a higher alignment
requirement than the inner mode here.

2021-04-27  Bernd Edlinger  <bernd.edlinger@hotmail.de>

PR target/100106
* simplify-rtx.c (simplify_context::simplify_subreg): Check the
memory alignment for the outer mode.

* gcc.c-torture/compile/pr100106.c: New testcase.

3 years agoop_by_pieces_d::run: Change a while loop to a do-while loop
H.J. Lu [Mon, 26 Apr 2021 22:36:18 +0000 (15:36 -0700)]
op_by_pieces_d::run: Change a while loop to a do-while loop

Change a while loop in op_by_pieces_d::run to a do-while loop to prepare
for offset adjusted operation for the remaining bytes on the last piece
operation of a memory region.

PR middle-end/90773
* expr.c (op_by_pieces_d::get_usable_mode): New member function.
(op_by_pieces_d::run): Cange a while loop to a do-while loop.

3 years agoarm: Fix ICEs with compare-and-swap and -march=armv8-m.base [PR99977]
Alex Coplan [Tue, 27 Apr 2021 13:56:15 +0000 (14:56 +0100)]
arm: Fix ICEs with compare-and-swap and -march=armv8-m.base [PR99977]

The PR shows two ICEs with __sync_bool_compare_and_swap and
-mcpu=cortex-m23 (equivalently, -march=armv8-m.base): one in LRA and one
later on, after the CAS insn is split.

The LRA ICE occurs because the
@atomic_compare_and_swap<CCSI:arch><SIDI:mode>_1 pattern attempts to tie
two output operands together (operands 0 and 1 in the third
alternative). LRA can't handle this, since it doesn't make sense for an
insn to assign to the same operand twice.

The later (post-splitting) ICE occurs because the expansion of the
cbranchsi4_scratch insn doesn't quite go according to plan. As it
stands, arm_split_compare_and_swap calls gen_cbranchsi4_scratch,
attempting to pass a register (neg_bval) to use as a scratch register.
However, since the RTL template has a match_scratch here,
gen_cbranchsi4_scratch ignores this argument and produces a scratch rtx.
Since this is all happening after RA, this is doomed to fail (and we get
an ICE about the insn not matching its constraints).

It seems that the motivation for the choice of constraints in the
atomic_compare_and_swap pattern comes from an attempt to satisfy the
constraints of the cbranchsi4_scratch insn. This insn requires the
scratch register to be the same as the input register in the case that
we use a larger negative immediate (one that satisfies J, but not L).

Of course, as noted above, LRA refuses to assign two output operands to
the same register, so this was never going to work.

The solution I'm proposing here is to collapse the alternatives to the
CAS insn (allowing the two output register operands to be matched to
different registers) and to ensure that the constraints for
cbranchsi4_scratch are met in arm_split_compare_and_swap. We do this by
inserting a move to ensure the source and destination registers match if
necessary (i.e. in the case of large negative immediates).

Another notable change here is that we only do:

  emit_move_insn (neg_bval, const1_rtx);

for non-negative immediates. This is because the ADDS instruction used in
the negative case suffices to leave a suitable value in neg_bval: if the
operands compare equal, we don't take the branch (so neg_bval will be
set by the load exclusive). Otherwise, the ADDS will leave a nonzero
value in neg_bval, which will correctly signal that the CAS has failed
when it is later negated.

gcc/ChangeLog:

PR target/99977
* config/arm/arm.c (arm_split_compare_and_swap): Fix up codegen
with negative immediates: ensure we expand cbranchsi4_scratch
correctly and ensure we satisfy its constraints.
* config/arm/sync.md
(@atomic_compare_and_swap<CCSI:arch><NARROW:mode>_1): Don't
attempt to tie two output operands together with constraints;
collapse two alternatives.
(@atomic_compare_and_swap<CCSI:arch><SIDI:mode>_1): Likewise.
* config/arm/thumb1.md (cbranchsi4_neg_late): New.

gcc/testsuite/ChangeLog:

PR target/99977
* gcc.target/arm/pr99977.c: New test.

3 years agoaarch64: Fix UB in the compiler [PR100200]
Jakub Jelinek [Tue, 27 Apr 2021 13:46:16 +0000 (15:46 +0200)]
aarch64: Fix UB in the compiler [PR100200]

The following patch fixes UBs in the compiler when negativing
a CONST_INT containing HOST_WIDE_INT_MIN.  I've changed the spots where
there wasn't an obvious earlier condition check or predicate that
would fail for such CONST_INTs.

2021-04-27  Jakub Jelinek  <jakub@redhat.com>

PR target/100200
* config/aarch64/predicates.md (aarch64_sub_immediate,
aarch64_plus_immediate): Use -UINTVAL instead of -INTVAL.
* config/aarch64/aarch64.md (casesi, rotl<mode>3): Likewise.
* config/aarch64/aarch64.c (aarch64_print_operand,
aarch64_split_atomic_op, aarch64_expand_subvti): Likewise.

3 years agoveclower: Fix up vec_shl matching of VEC_PERM_EXPR [PR100239]
Jakub Jelinek [Tue, 27 Apr 2021 13:42:47 +0000 (15:42 +0200)]
veclower: Fix up vec_shl matching of VEC_PERM_EXPR [PR100239]

The following testcase ICEs at -O0, because lower_vec_perm sees the
  _1 = { 0, 0, 0, 0, 0, 0, 0, 0 };
  _2 = VEC_COND_EXPR <_1, { -1, -1, -1, -1, -1, -1, -1, -1 }, { 0, 0, 0, 0, 0, 0, 0, 0 }>;
  _3 = { 6, 0, 0, 0, 0, 0, 0, 0 };
  _4 = VEC_PERM_EXPR <{ 0, 0, 0, 0, 0, 0, 0, 0 }, _2, _3>;
and as the ISA is SSE2, there is no support for the particular permutation
nor for variable mask permutation.  But, the code to match vec_shl matches
it, because the permutation has the first operand a zero vector and the
mask picks all elements randomly from that vector.
So, in the end that isn't a vec_shl, but the permutation could be in theory
optimized into the first argument.  As we keep it as is, it will fail
during expansion though, because that for vec_shl correctly requires that
it actually is a shift:
      unsigned firstidx = 0;
      for (unsigned int i = 0; i < nelt; i++)
        {
          if (known_eq (sel[i], nelt))
            {
              if (i == 0 || firstidx)
                return NULL_RTX;
              firstidx = i;
            }
          else if (firstidx
                   ? maybe_ne (sel[i], nelt + i - firstidx)
                   : maybe_ge (sel[i], nelt))
            return NULL_RTX;
        }

      if (firstidx == 0)
        return NULL_RTX;
      first = firstidx;
The if (firstidx == 0) return NULL; is what is missing a counterpart
on the lower_vec_perm side.
As with optimize != 0 we fold it in other spots, I think it is not needed
to optimize this cornercase in lower_vec_perm (which would mean we'd need
to recurse on the newly created _4 = { 0, 0, 0, 0, 0, 0, 0, 0 };
whether it is supported or not).

2021-04-27  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/100239
* tree-vect-generic.c (lower_vec_perm): Don't accept constant
permutations with all indices from the first zero element as vec_shl.

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

3 years agoRevert "libstdc++: Add workaround for ia32 floating atomics miscompilations [PR100184]"
Jakub Jelinek [Tue, 27 Apr 2021 13:29:26 +0000 (15:29 +0200)]
Revert "libstdc++: Add workaround for ia32 floating atomics miscompilations [PR100184]"

This reverts commit 0f4588141fcbe4e0f1fa12776b47200870f6c621.

3 years agocfgcleanup: Fix -fcompare-debug issue in outgoing_edges_match [PR100254]
Jakub Jelinek [Tue, 27 Apr 2021 13:26:24 +0000 (15:26 +0200)]
cfgcleanup: Fix -fcompare-debug issue in outgoing_edges_match [PR100254]

The following testcase fails with -fcompare-debug.  The problem is that
outgoing_edges_match behaves differently between -g0 and -g, if
some load/store with REG_EH_REGION is followed by DEBUG_INSNs, the
REG_EH_REGION check is not done, while when there are no DEBUG_INSNs, it is
done.

We already compute last1 and last2 as BB_END (bb{1,2}) with skipped debug
insns and notes, so this patch just uses those.

2021-04-27  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/100254
* cfgcleanup.c (outgoing_edges_match): Check REG_EH_REGION on
last1 and last2 insns rather than BB_END (bb1) and BB_END (bb2) insns.

* g++.dg/opt/pr100254.C: New test.

3 years agotree-optimization/99912 - schedule another TODO_remove_unused_locals
Richard Biener [Tue, 27 Apr 2021 12:27:40 +0000 (14:27 +0200)]
tree-optimization/99912 - schedule another TODO_remove_unused_locals

This makes sure to remove unused locals and prune CLOBBERs after
the first scalar cleanup phase after IPA optimizations.  On the
testcase in the PR this results in 8000 CLOBBERs removed which
in turn unleashes more DSE which otherwise hits its walking limit
of 256 too early on this testcase.

2021-04-27  Richard Biener  <rguenther@suse.de>

PR tree-optimization/99912
* passes.def: Add comment about new TODO_remove_unused_locals.
* tree-stdarg.c (pass_data_stdarg): Run TODO_remove_unused_locals
at start.

3 years agotree-optimization/99912 - schedule DSE before SRA
Richard Biener [Wed, 7 Apr 2021 10:09:44 +0000 (12:09 +0200)]
tree-optimization/99912 - schedule DSE before SRA

For the testcase in the PR the main SRA pass is unable to do some
important scalarizations because dead stores of addresses make
the candiate variables disqualified.  The following patch adds
another DSE pass before SRA forming a DCE/DSE pair and moves the
DSE pass that is currently closely after SRA up to after the
next DCE pass, forming another DCE/DSE pair now residing after PRE.

2021-04-07  Richard Biener  <rguenther@suse.de>

PR tree-optimization/99912
* passes.def (pass_all_optimizations): Add pass_dse before
the first pass_dce, move the first pass_dse before the
pass_dce following pass_pre.

* gcc.dg/tree-ssa/ldist-33.c: Disable PRE and LIM.
* gcc.dg/tree-ssa/pr96789.c: Adjust dump file scanned.
* gcc.dg/tree-ssa/ssa-dse-28.c: Likewise.
* gcc.dg/tree-ssa/ssa-dse-29.c: Likewise.

3 years agolibstdc++: Minor refactoring in <experimental/internet>
Jonathan Wakely [Tue, 27 Apr 2021 12:43:23 +0000 (13:43 +0100)]
libstdc++: Minor refactoring in <experimental/internet>

libstdc++-v3/ChangeLog:

* include/experimental/internet (address_v6::bytes_type): Adjust
formatting.
(basic_endpoint): Define _M_is_v6() to put all checks for
AF_INET6 in one place.
(basic_endpoint::resize): Simplify.
(operator==(const tcp&, const tcp&)): Add constexpr and noexcept.
(operator!=(const tcp&, const tcp&)): Likewise.
(operator==(const udp&, const udp&)): Likewise.
(operator!=(const udp&, const udp&)): Likewise.
* testsuite/experimental/net/internet/tcp.cc: New test.
* testsuite/experimental/net/internet/udp.cc: New test.

3 years agolibstdc++: Better preprocessor conditions in net::ip [PR 100286]
Jonathan Wakely [Tue, 27 Apr 2021 12:06:43 +0000 (13:06 +0100)]
libstdc++: Better preprocessor conditions in net::ip [PR 100286]

This improves the use of preprocessor conditionas to enable/disable
members of namespace net::ip according to what is supported by the
target. This fixes PR 100286 by ensuring that the to_string member
functions are always defined for the address_v4 and address_v6 classes.
On the other hand, the IP protocol classes and internet socket option
classes aren't useful at all if the corresponding constants (such as
IPPROTO_TCP or IPV6_MULTICAST_HOPS) aren't define. So those types are
not defined at all if they can't be used.

The net/internet/socket/opt.cc test uses __has_include to check whether
or not to expect the types to be available.

libstdc++-v3/ChangeLog:

PR libstdc++/100286
* include/experimental/internet (resolver_errc, resolver_category())
(make_error_code, make_error_condition): Define unconditionally,
only make enumerators and use of gai_strerror depend on the
availability of <netdb.h>.
(address_v4::to_string): Use correct constant for string length.
(address_v4::to_string, address_v6::to_string): Define
unconditionally, throw if unsupported.
(make_address_v4, make_address_v6): Define unconditionally.
Return an error if unsupported.
(tcp, udp, v6_only, unicast::hops, multicast::*): Define
conditionally,
* testsuite/experimental/net/internet/socket/opt.cc: Check for
<netinet/in.h> and <netinet/tcp.h> before using types from
namespace net::ip.

3 years agolibstdc++: Define net::socket_base::message_flags operators as friends [PR 100285]
Jonathan Wakely [Tue, 27 Apr 2021 10:07:47 +0000 (11:07 +0100)]
libstdc++: Define net::socket_base::message_flags operators as friends [PR 100285]

The overloaded operators for socket_base::message_flags should only be
defined when the message_flags type itself is defined. Rather than
duplicate the preprocessor conditional, this moves the operators into
the same scope as the type, defining them as hidden friends.

As well as fixing the bug, this has all the usual advantages of hidden
friends (they are not visible to normal name lookup for unrelated
types).

For consistency, do the same for the resolver_base::flags bitmask
operators too.

libstdc++-v3/ChangeLog:

PR libstdc++/100285
* include/experimental/internet (resolver_base::flags):
Define overloaded operators as hidden friends.
* include/experimental/socket (socket_base::message_flags):
Likewise.

3 years agomatch.pd: Add some __builtin_ctz (x) cmp cst simplifications [PR95527]
Jakub Jelinek [Tue, 27 Apr 2021 12:47:54 +0000 (14:47 +0200)]
match.pd: Add some __builtin_ctz (x) cmp cst simplifications [PR95527]

This patch adds some ctz simplifications (e.g. ctz (x) >= 3 can be done by
testing if the low 3 bits are zero, etc.).

In addition, I've noticed that in the CLZ case, the
 #ifdef CLZ_DEFINED_VALUE_AT_ZERO don't really work as intended, they
are evaluated during genmatch and the macro is not defined then
(but, because of the missing tm.h includes it isn't defined in
gimple-match.c or generic-match.c either).  And when tm.h is included,
defaults.h is included which defines a fallback version of that macro.

For GCC 12, I wonder if it wouldn't be better to say in addition to __builtin_c[lt]z*
is always UB at zero that it would be undefined for .C[LT]Z ifn too if it
has just one operand and use a second operand to be the constant we expect
at zero.

2021-04-27  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/95527
* generic-match-head.c: Include tm.h.
* gimple-match-head.c: Include tm.h.
* match.pd (CLZ == INTEGER_CST): Don't use
#ifdef CLZ_DEFINED_VALUE_AT_ZERO, only test CLZ_DEFINED_VALUE_AT_ZERO
if clz == CFN_CLZ.  Add missing val declaration.
(CTZ cmp CST): New simplifications.

* gcc.dg/tree-ssa/pr95527-2.c: New test.

3 years agoexpand: Expand x / y * y as x - x % y if the latter is cheaper [PR96696]
Jakub Jelinek [Tue, 27 Apr 2021 12:45:45 +0000 (14:45 +0200)]
expand: Expand x / y * y as x - x % y if the latter is cheaper [PR96696]

The following patch tests both x / y * y and x - x % y expansion for the
former GIMPLE code and chooses the cheaper of those sequences.

2021-04-27  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/96696
* expr.c (expand_expr_divmod): New function.
(expand_expr_real_2) <case TRUNC_DIV_EXPR>: Use it for truncations and
divisions.  Formatting fixes.
<case MULT_EXPR>: Optimize x / y * y as x - x % y if the latter is
cheaper.

* gcc.target/i386/pr96696.c: New test.

3 years agoipa-sra: Release dead LHS SSA_NAME when removing it (PR 99951)
Martin Jambor [Tue, 27 Apr 2021 11:46:10 +0000 (13:46 +0200)]
ipa-sra: Release dead LHS SSA_NAME when removing it (PR 99951)

When IPA-SRA removes an SSA_NAME from a LHS of a call statement
because it is not necessary, it does not release it.  This patch fixes
that.

gcc/ChangeLog:

2021-04-08  Martin Jambor  <mjambor@suse.cz>

PR ipa/99951
* ipa-param-manipulation.c (ipa_param_adjustments::modify_call):
If removing a call statement LHS SSA name, release it.

3 years agoarm: fix UB when compiling thumb2 with PIC [PR100236]
Richard Earnshaw [Tue, 27 Apr 2021 11:25:30 +0000 (12:25 +0100)]
arm: fix UB when compiling thumb2 with PIC [PR100236]

arm_compute_save_core_reg_mask contains UB in that the saved PIC
register number is used to create a bit mask. However, for some target
options this register is undefined and we end up with a shift of ~0.

On native compilations this is benign since the shift will still be
large enough to move the bit outside of the range of the mask, but if
cross compiling from a system that truncates out-of-range shifts to
zero (or worse, raises a trap for such values) we'll get potentially
wrong code (or a fault).

gcc:
PR target/100236
* config/arm/arm.c (THUMB2_WORK_REGS): Check PIC_OFFSET_TABLE_REGNUM
is valid before including it in the mask.

3 years agoaarch64: Handle SVE attributes in comp_type_attributes [PR100270]
Richard Sandiford [Tue, 27 Apr 2021 11:18:03 +0000 (12:18 +0100)]
aarch64: Handle SVE attributes in comp_type_attributes [PR100270]

Even though "SVE type" and "SVE sizeless type" are marked as
affecting type identity, the middle end doesn't truly believe
it unless we also handle them in comp_type_attributes.

gcc/
PR target/100270
* config/aarch64/aarch64.c (aarch64_comp_type_attributes): Handle
SVE attributes.

gcc/testsuite/
PR target/100270
* gcc.target/aarch64/sve/acle/general-c/pr100270_1.c: New test.
* gcc.target/aarch64/sve/acle/general-c/sizeless-2.c: Change
expected error message when subtracting pointers to different
vector types.  Expect warnings when mixing them elsewhere.
* gcc.target/aarch64/sve/acle/general/attributes_7.c: Remove
XFAILs.  Tweak error messages for some cases.

3 years agoaarch64: Add +nosve to two tests
Richard Sandiford [Tue, 27 Apr 2021 11:18:02 +0000 (12:18 +0100)]
aarch64: Add +nosve to two tests

Adding +nosve is more robust than checking for command-line arguments,
since SVE can be enabled by default or indirectly via other options.

gcc/testsuite/
* gcc.target/aarch64/simd/ssra.c: Use +nosve
* gcc.target/aarch64/simd/usra.c: Likewise.

3 years agotree-optimization/100051 - disambiguate access size vs decl
Richard Biener [Tue, 13 Apr 2021 08:12:03 +0000 (10:12 +0200)]
tree-optimization/100051 - disambiguate access size vs decl

This adds disambiguation of the access size vs. the decl size
in the pointer based vs. decl based disambiguator.  We have
a TBAA based check like this already but that's fend off when
seeing alias-sets of zero or when -fno-strict-aliasing is in
effect.  Also the perceived dynamic type could be smaller than
the actual access.

2021-04-13  Richard Biener  <rguenther@suse.de>

PR tree-optimization/100051
* tree-ssa-alias.c (indirect_ref_may_alias_decl_p): Add
disambiguator based on access size vs. decl size.

* gcc.dg/tree-ssa/ssa-fre-92.c: New testcase.

3 years agotestsuite/100272 - undo PRE disabling for gcc.dg/tree-ssa/predcom-1.c
Richard Biener [Tue, 27 Apr 2021 09:02:03 +0000 (11:02 +0200)]
testsuite/100272 - undo PRE disabling for gcc.dg/tree-ssa/predcom-1.c

This re-enables PRE and fixes the malformed dg directive pointed
out in the PR.  It all works as desired and I forgot why I
disabled this in the past.

2021-04-27  Richard Biener  <rguenther@suse.de>

PR testsuite/100272
* gcc.dg/tree-ssa/predcom-1.c: Re-enable PRE and fix
malformed dg directive.

3 years agoUpdate gennews for GCC 10 and GCC 11.
Jakub Jelinek [Tue, 27 Apr 2021 09:01:25 +0000 (11:01 +0200)]
Update gennews for GCC 10 and GCC 11.

2021-04-27  Jakub Jelinek  <jakub@redhat.com>

* gennews (files): Add files for GCC 10 and GCC 11.

3 years agotestsuite/100272 - fix some malformed dg directives
Richard Biener [Tue, 27 Apr 2021 08:45:32 +0000 (10:45 +0200)]
testsuite/100272 - fix some malformed dg directives

The bug points out several malformed dg directives, the following
fixes the obvious ones where the testcases keep working after the
change.

2021-04-27  Richard Biener  <rguenther@suse.de>

PR testsuite/100272
* g++.dg/diagnostic/ptrtomem1.C: Fix dg directives.
* g++.dg/ipa/pr45572-2.C: Likewise.
* g++.dg/template/spec26.C: Likewise.
* gcc.dg/pr20126.c: Likewise.
* gcc.dg/tree-ssa/pr20739.c: Likewise.

3 years agotree-optimization/100278 - handle mismatched code in TBAA adjust of PRE
Richard Biener [Tue, 27 Apr 2021 07:41:38 +0000 (09:41 +0200)]
tree-optimization/100278 - handle mismatched code in TBAA adjust of PRE

PRE has code to adjust TBAA behavior for refs that expects the base
operation code to match.  The testcase shows a case where we have
a VAR_DECL vs. a MEM_REF so add code to give up in such cases.

2021-04-27  Richard Biener  <rguenther@suse.de>

PR tree-optimization/100278
* tree-ssa-pre.c (compute_avail): Give up when we cannot
adjust TBAA beacuse of mismatching bases.

* gcc.dg/tree-ssa/pr100278.c: New testcase.

3 years agoi386: Improve [QH]Imode rotates with masked shift count [PR99405]
Jakub Jelinek [Tue, 27 Apr 2021 08:17:45 +0000 (10:17 +0200)]
i386: Improve [QH]Imode rotates with masked shift count [PR99405]

The following testcase shows that while we nicely optimize away the
useless and? of shift count before rotation for [SD]Imode rotates,
we don't do that for [QH]Imode.

The following patch optimizes that by using the right iterator on those
4 patterns.

2021-04-27  Jakub Jelinek  <jakub@redhat.com>

PR target/99405
* config/i386/i386.md (*<insn><mode>3_mask, *<insn><mode>3_mask_1):
For any_rotate define_insn_split and following splitters, use
SWI iterator instead of SWI48.

* gcc.target/i386/pr99405.c: New test.

3 years agotree-optimization/99776 - relax condition on vector ctor element extract
Richard Biener [Fri, 26 Mar 2021 08:50:03 +0000 (09:50 +0100)]
tree-optimization/99776 - relax condition on vector ctor element extract

This relaxes the condition for the match.pd pattern doing vector ctor
element extracts to not require type identity but only size equality.
Since we vectorize pointer data as unsigned integer data such mismatches
have to be tolerated to optimize scalar code uses of vector results.

2021-03-26  Richard Biener  <rguenther@suse.de>

PR tree-optimization/99776
* match.pd (bit_field_ref (ctor)): Relax element extract
type compatibility checks.

* gcc.dg/tree-ssa/ssa-fre-91.c: New testcase.

3 years agoSynchronize Rocket Lake's processor_names and processor_cost_table with processor_type
Cui,Lili [Sat, 24 Apr 2021 03:52:17 +0000 (11:52 +0800)]
Synchronize Rocket Lake's processor_names and processor_cost_table with processor_type

gcc/ChangeLog

* common/config/i386/i386-common.c (processor_names):
Sync processor_names with processor_type.
* config/i386/i386-options.c (processor_cost_table):
Sync processor_cost_table with processor_type.

3 years agoDaily bump.
GCC Administrator [Tue, 27 Apr 2021 00:16:30 +0000 (00:16 +0000)]
Daily bump.

3 years agoc++: constexpr pointer indirection with negative offset [PR100209]
Patrick Palka [Mon, 26 Apr 2021 21:30:39 +0000 (17:30 -0400)]
c++: constexpr pointer indirection with negative offset [PR100209]

During constexpr evaluation, a base-to-derived conversion may yield an
expression like (Derived*)(&D.2217.D.2106 p+ -4) where D.2217 is the
derived object and D.2106 is the base.  But cxx_fold_indirect_ref
doesn't know how to resolve an INDIRECT_REF thereof to just D.2217,
because it doesn't handle POINTER_PLUS_EXPR of a COMPONENT_REF with
negative offset well: when the offset N is positive, it knows that
'&x p+ N' is equivalent to '&x.f p+ (N - bytepos(f))', but it doesn't
know about the reverse transformation, that '&x.f p+ N' is equivalent
to '&x p+ (N + bytepos(f))' when N is negative, which is important for
resolving such base-to-derived conversions and for accessing subobjects
backwards.  This patch teaches cxx_fold_indirect_ref this reverse
transformation.

gcc/cp/ChangeLog:

PR c++/100209
* constexpr.c (cxx_fold_indirect_ref): Try to canonicalize the
object/offset pair for a POINTER_PLUS_EXPR of a COMPONENT_REF
with a negative offset into one whose offset is nonnegative
before calling cxx_fold_indirect_ref_1.

gcc/testsuite/ChangeLog:

PR c++/100209
* g++.dg/cpp1y/constexpr-base1.C: New test.
* g++.dg/cpp1y/constexpr-ptrsub1.C: New test.

3 years agoOpenACC: Fix pattern in dg-bogus in Fortran testcases again
Tobias Burnus [Mon, 26 Apr 2021 20:59:21 +0000 (22:59 +0200)]
OpenACC: Fix pattern in dg-bogus in Fortran testcases again

It turned out that a compiler built without offloading support
and one with can produce slightly different diagnostic.

Offloading support implies ENABLE_OFFLOAD which implies that
g->have_offload is set when offloading is actually needed.
In cgraphunit.c, the latter causes flag_generate_offload = 1,
which in turn affects tree.c's free_lang_data.

The result is that the front-end specific diagnostic gets reset
('tree_diagnostics_defaults (global_dc)'), which affects in this
case 'Warning' vs. 'warning' via the Fortran frontend.

Result: 'Warning:' vs. 'warning:'.
Side note: Other FE also override the diagnostic, leading to
similar differences, e.g. the C++ FE outputs mangled function
names differently, cf. patch thread.

libgomp/ChangeLog:

* testsuite/libgomp.oacc-fortran/par-reduction-2-1.f:
Use [Ww]arning in dg-bogus as FE diagnostic and default
diagnostic differ and the result depends on ENABLE_OFFLOAD.
* testsuite/libgomp.oacc-fortran/par-reduction-2-2.f: Likewise.
* testsuite/libgomp.oacc-fortran/parallel-dims.f90: Likewise.
* testsuite/libgomp.oacc-fortran/parallel-reduction.f90: Likewise.

gcc/testsuite/ChangeLog:

* gfortran.dg/goacc/classify-serial.f95:
Use [Ww]arning in dg-bogus as FE diagnostic and default
diagnostic differ and the result depends on ENABLE_OFFLOAD.
* gfortran.dg/goacc/kernels-decompose-2.f95: Likewise.
* gfortran.dg/goacc/routine-module-mod-1.f90: Likewise.

3 years agoHandle anti-ranges of MIN,MAX uniformly.
Aldy Hernandez [Mon, 26 Apr 2021 17:24:09 +0000 (19:24 +0200)]
Handle anti-ranges of MIN,MAX uniformly.

The -fstrict-enums comment in the VR_ANTI_RANGE handling code is out
of date, as out-of-range ranges have already been handled by this
time.  I've removed it.

Furthermore, optimizing ~[MIN,MAX] as VARYING instead of UNDEFINED is
an old idiom.  I've been wanting to change it for a while, but have
only remembered late in the release cycle when it was too risky.

What I've chosen to do in this case is fall through to the code that
normalizes the range.  This will correctly turn ~[MIN,MAX] into
UNDEFINED, yet leaving things alone in the case of -fstrict-enums
where [MIN,MAX] may not necessarily include the entire range of the
underlying precision.  For example, if the domain of a strict enum is
[3,5] setting a VR_ANTI_RANGE of ~[3,5] should not cause neither
VR_UNDEFINED nor VR_VARYING, but just plain ~[3,5].

This is similar to what we do for -fstrict-enums when we set a range
of [3,5].  We leave it as a VR_RANGE, instead of upgrading it to
VR_VARYING.

gcc/ChangeLog:

* value-range.cc (irange::irange_set_1bit_anti_range): Add assert.
(irange::set): Call irange_set_1bit_anti_range for handling all
1-bit ranges.  Fall through on ~[MIN,MAX].

3 years agolibstdc++: Fix internet socket option classes
Jonathan Wakely [Mon, 26 Apr 2021 20:16:21 +0000 (21:16 +0100)]
libstdc++: Fix internet socket option classes

Similar to the previous commit, this fixes various problems with the
socket options classes in the <internet> header:

- The constructors were not noexcept.
- The __sockopt_base<T>::value() member function was present
  unconditionally (so was defined for socket_base::linger which is
  incorrect).
- The __socket_crtp<C, T>::operator=(T) assignment operator was not
  noexcept, and was hidden in the derived classes.
- The MulticastSocketOptions incorrectly used a union, incorrectly
  defined resize and const data() member functions, and their
  constructors were unimplemented.

Also, where appropriate:

- Use class instead of struct for the socket option types.
- Define the _S_level and _S_name constants as private.
- Declare the __socket_crtp base as a friend.

libstdc++-v3/ChangeLog:

* include/experimental/internet (tcp::no_delay, v6_only)
(unicast::hops, multicast::hops, multicast::enable_loopback):
Change access of base class and static data members. Add
using-declaration for __socket_crtp::operator=(_Tp).
(multicast::__mcastopt): New type.
(multicast::join_group, multicast::leave_group): Derive from
__mcastopt for common implementation.
* include/experimental/socket: Add comment.
* testsuite/experimental/net/internet/socket/opt.cc: New test.
* testsuite/experimental/net/socket/socket_base.cc: Check for
protected constructor/destructor of socket_base. Check for
explicit constructors of socket option classes.

3 years agolibstdc++: Fix socket option classes
Jonathan Wakely [Mon, 26 Apr 2021 20:16:21 +0000 (21:16 +0100)]
libstdc++: Fix socket option classes

This fixes some flaws in the socket option types defined in
net::socket_base:

- The constructors were not noexcept.
- The __sockopt_base<T>::value() member function was present
  unconditionally (so was defined for socket_base::linger which is
  incorrect).
- The __socket_crtp<C, T>::operator=(T) assignment operator was not
  noexcept, and was hidden in the derived classes.

Also:

- Use class instead of struct for the socket option types.
- Define the _S_level and _S_name constants as private.
- Declare the __socket_crtp base as a friend.

libstdc++-v3/ChangeLog:

* include/experimental/bits/net.h (__socket_base): Add
bool template parameter to allow BooleanSocketOption and
IntegerSocketOption to have different __socket_base<int>
base classes.
(__socket_base<bool>): Adjust base class.
(__socket_base<int>): Add partial specialization.
(__socket_crtp::operator=(_Tp)): Add noexcept-specifier.
* include/experimental/socket (socket_base::broadcast)
(socket_base::debug, socket_base::do_not_route)
(socket_base::keep_alive, socket_base::linger)
(socket_base::out_of_band_inline)
(socket_base::receive_buffer_size)
(socket_base::receive_low_watermark)
(socket_base::reuse_address, socket_base::send_buffer_size)
(socket_base::send_low_watermark): Add using-declaration for
__socket_crtp::operator=(_Tp).
* testsuite/experimental/net/socket/socket_base.cc: Check
properties of socket option types.

3 years agolibstdc++: Simplify definition of net::ip::resolver_base constants
Jonathan Wakely [Mon, 26 Apr 2021 20:16:20 +0000 (21:16 +0100)]
libstdc++: Simplify definition of net::ip::resolver_base constants

libstdc++-v3/ChangeLog:

* include/experimental/internet (resolver_base::flags): Remove
enumerators. Initialize constants directly with desired values.
Make all operators constexpr and noexcept.
* testsuite/experimental/net/internet/resolver/base.cc: Use
__gnu_test::test_bitmask_values for bitmask type. Check
construction and destruction is protected.

3 years agoOpenACC: Fix pattern in dg-bogus in Fortran testcases
Tobias Burnus [Mon, 26 Apr 2021 19:57:31 +0000 (21:57 +0200)]
OpenACC: Fix pattern in dg-bogus in Fortran testcases

libgomp/ChangeLog:

* testsuite/libgomp.oacc-fortran/par-reduction-2-1.f:
Correct spelling in dg-bogus to match -Wopenacc-parallelism.
* testsuite/libgomp.oacc-fortran/par-reduction-2-2.f: Likewise.
* testsuite/libgomp.oacc-fortran/parallel-dims.f90: Likewise.
* testsuite/libgomp.oacc-fortran/parallel-reduction.f90: Likewise.

gcc/testsuite/ChangeLog:

* gfortran.dg/goacc/classify-serial.f95:
Correct spelling in dg-bogus to match -Wopenacc-parallelism.
* gfortran.dg/goacc/kernels-decompose-2.f95: Likewise.
* gfortran.dg/goacc/routine-module-mod-1.f90: Likewise.

3 years agoCache irange::num_pairs() for non-legacy code.
Aldy Hernandez [Sat, 17 Apr 2021 15:44:37 +0000 (17:44 +0200)]
Cache irange::num_pairs() for non-legacy code.

This does for num_pairs() what my previous patch did for VR_UNDEFINED
and VR_VARYING.

Note that VR_ANTI_RANGE for legacy is always set to 2 ranges.  There
is only one way of representing a range, so a range that can be
represented as a VR_RANGE will never have a kind of VR_ANTI_RANGE.
Also legacy symbolics can also use VR_ANTI_RANGE, but no one will ever
ask for the bounds of such range, so m_num_ranges is irrelevant.

gcc/ChangeLog:

* value-range.cc (irange::legacy_num_pairs): Remove.
(irange::invert): Change gcc_assert to gcc_checking_assert.
* value-range.h (irange::num_pairs): Adjust for a cached
num_pairs().  Also, rename all gcc_assert's to
gcc_checking_assert's.

3 years agoKeep VR_UNDEFINED and VR_VARYING in sync (speeds up evrp by 8.47%).
Aldy Hernandez [Fri, 16 Apr 2021 16:40:44 +0000 (18:40 +0200)]
Keep VR_UNDEFINED and VR_VARYING in sync (speeds up evrp by 8.47%).

Currently multi-ranges calculate the undefined and varying bits on the
fly, whereas legacy uses the m_kind field.  Since we will always have
space in the irange class for a kind field, might as well keep it in
sync as ranges are created, thus speeding up lookups.

This patch, along with an upcoming ones for num_pairs(), speeds up EVRP
by 8.47%, VRP proper by 1.84% and overall compilation by 0.24%.

FWIW, since evrp is such a fast pass, and is hard to measure clock-wise,
we've been using callgrind to estimate improvements.  This has coincided
more or less with -ftime-report numbers (albeit having to run -ftime-report
half a dozen times and use the average).

gcc/ChangeLog:

* value-range.cc (irange::operator=): Set m_kind.
(irange::copy_to_legacy): Handle varying and undefined sources
as a legacy copy since they can be easily copied.
(irange::irange_set): Set m_kind.
(irange::irange_set_anti_range): Same.
(irange::set): Rename normalize_min_max to normalize_kind.
(irange::verify_range): Adjust for multi-ranges having the
m_kind field set.
(irange::irange_union): Set m_kind.
(irange::irange_intersect): Same.
(irange::invert): Same.
* value-range.h (irange::kind): Always return m_kind.
(irange::varying_p): Rename to...
(irange::varying_comptaible_p): ...this.
(irange::undefined_p): Only look at m_kind.
(irange::irange): Always set VR_UNDEFINED if applicable.
(irange::set_undefined): Always set VR_UNDEFINED.
(irange::set_varying): Always set m_kind to VR_VARYING.
(irange::normalize_min_max): Rename to...
(irange::normalize_kind): ...this.

3 years agoRemove irange::varying_p checks from symbolic_p and constant_p.
Aldy Hernandez [Sat, 17 Apr 2021 12:26:33 +0000 (14:26 +0200)]
Remove irange::varying_p checks from symbolic_p and constant_p.

As of a few releases ago, varying_p() ranges are also constant_p.
Consequently, there is no need to check varying_p from either
symbolic_p or constant_p.

I have adjusted a few users of constant_p that were depending on
constant_p returning false for varying_p.  In these cases, I have
placed the varying_p check before the constant_p check to avoid
the more expensive constant_p check when possible.

gcc/ChangeLog:

* gimple-ssa-evrp-analyze.c (evrp_range_analyzer::set_ssa_range_info):
Adjust for constant_p including varying_p.
* tree-vrp.c (vrp_prop::finalize): Same.
(determine_value_range): Same.
* vr-values.c (vr_values::range_of_expr): Same.
* value-range.cc (irange::symbolic_p): Do not check varying_p.
(irange::constant_p): Same.

3 years agoReplace !irange::undefined_p checks with num_ranges > 0 for readability.
Aldy Hernandez [Sat, 17 Apr 2021 12:24:15 +0000 (14:24 +0200)]
Replace !irange::undefined_p checks with num_ranges > 0 for readability.

A few of the undefined_p checks in the irange code are really checking if
there are sub-ranges.  It just so happens that undefined_p is
implemented with num_ranges > 0, so it was a shorthand used throughout.
This shorthand was making the code unreadable.

gcc/ChangeLog:

* value-range.cc (irange::legacy_lower_bound): Replace
  !undefined_p check with num_ranges > 0.
(irange::legacy_upper_bound): Same.
* value-range.h (irange::type): Same.
(irange::lower_bound): Same.
(irange::upper_bound): Same.

3 years agotree-optimization/99956 - improve loop interchange
Richard Biener [Wed, 7 Apr 2021 12:53:40 +0000 (14:53 +0200)]
tree-optimization/99956 - improve loop interchange

When we apply store motion and DSE manually to the bwaves kernel
in gfortran.dg/pr81303.f loop interchange no longer happens because
the perfect nest considered covers outer loops we cannot analyze
strides for.  The following compensates for this by shrinking the
nest in this analysis which was already possible but on a too coarse
granularity.  It shares the shrinked nest with the rest of the DRs
so the complexity overhead should be negligible.

2021-04-07  Richard Biener  <rguenther@suse.de>

PR tree-optimization/99956
* gimple-loop-interchange.cc (compute_access_stride):
Try instantiating the access in a shallower loop nest
if instantiating failed.
(compute_access_strides): Pass adjustable loop_nest
to compute_access_stride.

* gfortran.dg/pr99956.f: New testcase.

3 years agolibstdc++: Add missing headers for errno and std::terminate
Jonathan Wakely [Mon, 26 Apr 2021 11:28:37 +0000 (12:28 +0100)]
libstdc++: Add missing headers for errno and std::terminate

libstdc++-v3/ChangeLog:

* include/bits/semaphore_base.h: Include <exception> and <errno.h>.

3 years agotestsuite/arm: Add arm_cmse_hw effective target
Christophe Lyon [Mon, 26 Apr 2021 11:23:41 +0000 (11:23 +0000)]
testsuite/arm: Add arm_cmse_hw effective target

Some of the CMSE tests have 'dg-do run', but qemu-arm does not support
the privileged instructions involved; one has to use qemu-system-arm
for this, which in turn requires modifications to the default
newlib/libgloss startup code to enable the FPU as the FP status
registers need to be saved when using CMSE code.

This patch introduces arm_cmse_hw, similar to arm_neon_hw, to detect
whether the execution engine supports the CMSE instructions. If not,
we set dg-do-what-default to assemble instead of run. We thus remove
all the 'dg-do run' directives from CMSE tests, to rely on
dg-do-what-default instead.

Note that cmse-16.c used to pass with dg-do run under qemu-arm,
because the property being tested is not available (qemu-arm does not
model secure vs non-secure memory). The patch removes dg-do from it
too, since it is relevant only with an adequate simulator.

Before the patch, bitfield-[123].c and struct-1.c fail at execution
under qemu-arm. With the patch, execution is skipped.

The same tests pass under qemu-system-arm both with and without the
patch.

This avoids failures when testing with
-mthumb/-mfloat-abi=hard/-march=armv8-m.main+fp+dsp under qemu-arm for
cortex-m33.

I'm also running tests with qemu-system-arm for cortex-m33, but I run
only cmse.exp with a patched newlib in this case: I use qemu-arm for
all combinations except that one because it's faster and supports
semihosting.

I do not have a setup to check this with actual hardware or another
simulator.

2021-04-26  Christophe Lyon  <christophe.lyon@linaro.org>

gcc/
* doc/sourcebuild.texi (arm_cmse_hw): Document.

gcc/testsuite/
* gcc.target/arm/cmse/bitfield-1.c: Remove dg-do.
* gcc.target/arm/cmse/bitfield-2.c: Likewise.
* gcc.target/arm/cmse/bitfield-3.c: Likewise.
* gcc.target/arm/cmse/cmse-16.c: Likewise.
* gcc.target/arm/cmse/struct-1.c: Likewise.
* gcc.target/arm/cmse/cmse.exp: Set dg-do-what-default depending
on arm_cmse_hw.
* lib/target-supports.exp (check_effective_target_arm_cmse_hw):
New.

3 years agoaarch64: Handle V4BF V8BF modes in vwcore attribute
Kyrylo Tkachov [Mon, 26 Apr 2021 11:01:33 +0000 (12:01 +0100)]
aarch64: Handle V4BF V8BF modes in vwcore attribute

While playing with other unrelated changes I hit an assemble-failure bug where
a pattern (one of the get_lane ones) that was using V4BF, V8BF as part of a
mode iterator and outputting registers with the vwcore attribute,
but there is no vwcore mapping for V4BF and V8BF.

This patch fixes that in the obvious way by adding the missing mappings

Bootstrapped and tested on aarch64-none-linux-gnu.

gcc/ChangeLog:

* config/aarch64/iterators.md (vwcore): Handle V4BF, V8BF.

3 years agoAdd XFAIL for gcc.dg/pr84877.c on the SPARC
Eric Botcazou [Mon, 26 Apr 2021 10:55:24 +0000 (12:55 +0200)]
Add XFAIL for gcc.dg/pr84877.c on the SPARC

The maximum supported alignment is 64-bit on 32-bit mode.

gcc/testsuite/
* gcc.dg/pr84877.c: XFAIL on SPARC as well.

3 years agolibstdc++: Add missing 'inline' specifiers to net::ip functions [PR 100259]
Jonathan Wakely [Mon, 26 Apr 2021 10:37:38 +0000 (11:37 +0100)]
libstdc++: Add missing 'inline' specifiers to net::ip functions [PR 100259]

libstdc++-v3/ChangeLog:

PR libstdc++/100259
* include/experimental/internet (net::ip::make_error_code)
(net::ip::make_error_condition, net::ip::make_network_v4)
(net::ip::operator==(const udp&, const udp&)): Add 'inline'.

3 years agoAdd '-Wopenacc-parallelism'
Thomas Schwinge [Fri, 23 Apr 2021 10:23:51 +0000 (12:23 +0200)]
Add '-Wopenacc-parallelism'

... to diagnose potentially suboptimal choices regarding OpenACC parallelism.

Not enabled by default: too noisy ("*potentially* suboptimal choices"); see
XFAILed 'dg-bogus'es.

gcc/c-family/
* c.opt (Wopenacc-parallelism): New.
gcc/fortran/
* lang.opt (Wopenacc-parallelism): New.
gcc/
* omp-offload.c (oacc_validate_dims): Implement
'-Wopenacc-parallelism'.
* doc/invoke.texi (-Wopenacc-parallelism): Document.
gcc/testsuite/
* c-c++-common/goacc/diag-parallelism-1.c: New.
* c-c++-common/goacc/acc-icf.c: Specify '-Wopenacc-parallelism',
and match diagnostics, as appropriate.
* c-c++-common/goacc/classify-kernels-unparallelized.c: Likewise.
* c-c++-common/goacc/classify-kernels.c: Likewise.
* c-c++-common/goacc/classify-parallel.c: Likewise.
* c-c++-common/goacc/classify-routine.c: Likewise.
* c-c++-common/goacc/classify-serial.c: Likewise.
* c-c++-common/goacc/kernels-decompose-1.c: Likewise.
* c-c++-common/goacc/kernels-decompose-2.c: Likewise.
* c-c++-common/goacc/parallel-dims-1.c: Likewise.
* c-c++-common/goacc/parallel-reduction.c: Likewise.
* c-c++-common/goacc/pr70688.c: Likewise.
* c-c++-common/goacc/routine-1.c: Likewise.
* c-c++-common/goacc/routine-level-of-parallelism-2.c: Likewise.
* c-c++-common/goacc/uninit-dim-clause.c: Likewise.
* gfortran.dg/goacc/classify-kernels-unparallelized.f95: Likewise.
* gfortran.dg/goacc/classify-kernels.f95: Likewise.
* gfortran.dg/goacc/classify-parallel.f95: Likewise.
* gfortran.dg/goacc/classify-routine.f95: Likewise.
* gfortran.dg/goacc/classify-serial.f95: Likewise.
* gfortran.dg/goacc/kernels-decompose-1.f95: Likewise.
* gfortran.dg/goacc/kernels-decompose-2.f95: Likewise.
* gfortran.dg/goacc/parallel-tree.f95: Likewise.
* gfortran.dg/goacc/routine-4.f90: Likewise.
* gfortran.dg/goacc/routine-level-of-parallelism-1.f90: Likewise.
* gfortran.dg/goacc/routine-module-mod-1.f90: Likewise.
* gfortran.dg/goacc/routine-multiple-directives-1.f90: Likewise.
* gfortran.dg/goacc/uninit-dim-clause.f95: Likewise.
libgomp/
* testsuite/libgomp.oacc-c-c++-common/firstprivate-1.c: Specify
'-Wopenacc-parallelism', and match diagnostics, as appropriate.
* testsuite/libgomp.oacc-c-c++-common/loop-auto-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/loop-red-w-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/loop-red-w-2.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/loop-w-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/mode-transitions.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/par-reduction-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/par-reduction-2.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/parallel-dims.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/parallel-reduction.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/pr85381-3.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/private-variables.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/reduction-5.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/reduction-7.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/routine-g-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/routine-w-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/routine-wv-2.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/static-variable-1.c:
Likewise.
* testsuite/libgomp.oacc-fortran/optional-private.f90: Likewise.
* testsuite/libgomp.oacc-fortran/par-reduction-2-1.f: Likewise.
* testsuite/libgomp.oacc-fortran/par-reduction-2-2.f: Likewise.
* testsuite/libgomp.oacc-fortran/parallel-dims.f90: Likewise.
* testsuite/libgomp.oacc-fortran/parallel-reduction.f90: Likewise.
* testsuite/libgomp.oacc-fortran/pr84028.f90: Likewise.
* testsuite/libgomp.oacc-fortran/private-variables.f90: Likewise.
* testsuite/libgomp.oacc-fortran/reduction-1.f90: Likewise.
* testsuite/libgomp.oacc-fortran/reduction-5.f90: Likewise.
* testsuite/libgomp.oacc-fortran/reduction-6.f90: Likewise.
* testsuite/libgomp.oacc-fortran/routine-7.f90: Likewise.

Co-Authored-By: Nathan Sidwell <nathan@codesourcery.com>
Co-Authored-By: Tom de Vries <vries@codesourcery.com>
Co-Authored-By: Julian Brown <julian@codesourcery.com>
Co-Authored-By: Kwok Cheung Yeung <kcy@codesourcery.com>
3 years ago[OpenACC] Don't compile libgomp testcases with '-w'
Thomas Schwinge [Fri, 16 Apr 2021 14:08:19 +0000 (16:08 +0200)]
[OpenACC] Don't compile libgomp testcases with '-w'

We'd like to actually catch compiler diagnostics (and currently there aren't
any).

libgomp/
* testsuite/libgomp.oacc-c-c++-common/par-reduction-1.c: Don't
compile with '-w'.
* testsuite/libgomp.oacc-c-c++-common/par-reduction-2.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/parallel-reduction.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/reduction-5.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/reduction-6.c: Likewise.
* testsuite/libgomp.oacc-fortran/parallel-reduction.f90: Likewise.
* testsuite/libgomp.oacc-fortran/reduction-1.f90: Likewise.
* testsuite/libgomp.oacc-fortran/reduction-5.f90: Likewise.
* testsuite/libgomp.oacc-fortran/reduction-6.f90: Likewise.
* testsuite/libgomp.oacc-fortran/reduction-7.f90: Likewise.

3 years agoMove gimplify_buildN API local to only remaining user
Richard Biener [Thu, 15 Apr 2021 11:03:21 +0000 (13:03 +0200)]
Move gimplify_buildN API local to only remaining user

This moves the legacy gimplify_buildN API to tree-vect-generic.c,
its only user and elides the gimplification step, making it a wrapper
around gimple_build, adjusting tree_vec_extract for this.

I've noticed that vector CTOR expansion doesn't deal with unfolded
{} and thus this makes it more resilent.  I've also adjusted the
match.pd vector CTOR extraction code to make sure it doesn't
produce a CTOR when folding would make it a vector constant.

2021-04-15  Richard Biener  <rguenther@suse.de>

* tree-cfg.h (gimplify_build1): Remove.
(gimplify_build2): Likewise.
(gimplify_build3): Likewise.
* tree-cfg.c (gimplify_build1): Move to tree-vect-generic.c.
(gimplify_build2): Likewise.
(gimplify_build3): Likewise.
* tree-vect-generic.c (gimplify_build1): Move from tree-cfg.c.
Modernize.
(gimplify_build2): Likewise.
(gimplify_build3): Likewise.
(tree_vec_extract): Use resimplify with following SSA edges.
(expand_vector_parallel): Avoid passing NULL size/bitpos
to tree_vec_extract.
* expr.c (store_constructor): Deal with zero-element CTORs.
* match.pd (bit_field_ref <vector CTOR>): Make sure to
produce vector constants when possible.

3 years agoRemove gimplify_buildN API use from complex lowering
Richard Biener [Thu, 15 Apr 2021 09:52:16 +0000 (11:52 +0200)]
Remove gimplify_buildN API use from complex lowering

This removes the legacy gimplify_buildN API use from complex lowering.

2021-04-15  Richard Biener  <rguenther@suse.de>

* tree-complex.c: Include gimple-fold.h.
(expand_complex_addition): Use gimple_build.
(expand_complex_multiplication_components): Likewise.
(expand_complex_multiplication): Likewise.
(expand_complex_div_straight): Likewise.
(expand_complex_div_wide): Likewise.
(expand_complex_division): Likewise.
(expand_complex_conjugate): Likewise.
(expand_complex_comparison): Likewise.

3 years agoRemove gimplify_buildN API use from phiopt
Richard Biener [Thu, 15 Apr 2021 09:06:09 +0000 (11:06 +0200)]
Remove gimplify_buildN API use from phiopt

This removes use of the legacy gimplify_buildN API from phiopt.

2021-04-15  Richard Biener  <rguenther@suse.de>

* tree-ssa-phiopt.c (two_value_replacement): Remove use
of legacy gimplify_buildN API.

3 years agotree-optimization/99473 - more cselim
Richard Biener [Tue, 9 Mar 2021 08:29:29 +0000 (09:29 +0100)]
tree-optimization/99473 - more cselim

This fixes the pre-condition on cselim to include all references
and decls when they end up as auto-var.

Bootstrapped/tested on x86_64-linux

2021-03-09  Richard Biener  <rguenther@suse.de>

PR tree-optimization/99473
* tree-ssa-phiopt.c (cond_store_replacement): Handle all
stores.

* gcc.dg/tree-ssa/pr99473-1.c: New testcase.

3 years agoSimplify {gimplify_and_,}update_call_from_tree API
Richard Biener [Wed, 14 Apr 2021 11:40:58 +0000 (13:40 +0200)]
Simplify {gimplify_and_,}update_call_from_tree API

This removes update_call_from_tree in favor of
gimplify_and_update_call_from_tree, removing some code duplication
and simplifying the API use.  Some users of update_call_from_tree
have been transitioned to replace_call_with_value and the API
and its dependences have been moved to gimple-fold.h.

This shaves off another user of valid_gimple_rhs_p which is now
only used from within gimple-fold.c and thus moved and made private.

2021-04-14  Richard Biener  <rguenther@suse.de>

* tree-ssa-propagate.h (valid_gimple_rhs_p): Remove.
(update_gimple_call): Likewise.
(update_call_from_tree): Likewise.
* tree-ssa-propagate.c (valid_gimple_rhs_p): Remove.
(valid_gimple_call_p): Likewise.
(move_ssa_defining_stmt_for_defs): Likewise.
(finish_update_gimple_call): Likewise.
(update_gimple_call): Likewise.
(update_call_from_tree): Likewise.
(propagate_tree_value_into_stmt): Use replace_call_with_value.
* gimple-fold.h (update_gimple_call): Declare.
* gimple-fold.c (valid_gimple_rhs_p): Move here from
tree-ssa-propagate.c.
(update_gimple_call): Likewise.
(valid_gimple_call_p): Likewise.
(finish_update_gimple_call): Likewise, and simplify.
(gimplify_and_update_call_from_tree): Implement
update_call_from_tree functionality, avoid excessive
push/pop_gimplify_context.
(gimple_fold_builtin): Use only gimplify_and_update_call_from_tree.
(gimple_fold_call): Likewise.
* gimple-ssa-sprintf.c (try_substitute_return_value): Likewise.
* tree-ssa-ccp.c (ccp_folder::fold_stmt): Likewise.
(pass_fold_builtins::execute): Likewise.
(optimize_stack_restore): Use replace_call_with_value.
* tree-cfg.c (fold_loop_internal_call): Likewise.
* tree-ssa-dce.c (maybe_optimize_arith_overflow): Use
only gimplify_and_update_call_from_tree.
* tree-ssa-strlen.c (handle_builtin_strlen): Likewise.
(handle_builtin_strchr): Likewise.
* tsan.c: Include gimple-fold.h instead of tree-ssa-propagate.h.

* config/rs6000/rs6000-call.c (rs6000_gimple_fold_builtin):
Use replace_call_with_value.

3 years agovmsdbgout: Remove useless register keywords
Jakub Jelinek [Mon, 26 Apr 2021 07:59:15 +0000 (09:59 +0200)]
vmsdbgout: Remove useless register keywords

register keyword was removed in C++17, and in vmsdbgout.c it served no
useful purpose.

2021-04-26  Jakub Jelinek  <jakub@redhat.com>

PR debug/100255
* vmsdbgout.c (ASM_OUTPUT_DEBUG_STRING, vmsdbgout_begin_block,
vmsdbgout_end_block, lookup_filename, vmsdbgout_source_line): Remove
register keywords.

3 years agoDaily bump.
GCC Administrator [Mon, 26 Apr 2021 00:16:26 +0000 (00:16 +0000)]
Daily bump.

3 years agoAdd folding and remove expanders for x86 *pcmp{et,gt}* builtins [PR target/98911]
liuhongt [Tue, 23 Feb 2021 03:17:40 +0000 (11:17 +0800)]
Add folding and remove expanders for x86 *pcmp{et,gt}* builtins [PR target/98911]

gcc/ChangeLog:

PR target/98911
* config/i386/i386-builtin.def (BDESC): Change the icode of
the following builtins to CODE_FOR_nothing.
* config/i386/i386.c (ix86_gimple_fold_builtin): Fold
IX86_BUILTIN_PCMPEQB128, IX86_BUILTIN_PCMPEQW128,
IX86_BUILTIN_PCMPEQD128, IX86_BUILTIN_PCMPEQQ,
IX86_BUILTIN_PCMPEQB256, IX86_BUILTIN_PCMPEQW256,
IX86_BUILTIN_PCMPEQD256, IX86_BUILTIN_PCMPEQQ256,
IX86_BUILTIN_PCMPGTB128, IX86_BUILTIN_PCMPGTW128,
IX86_BUILTIN_PCMPGTD128, IX86_BUILTIN_PCMPGTQ,
IX86_BUILTIN_PCMPGTB256, IX86_BUILTIN_PCMPGTW256,
IX86_BUILTIN_PCMPGTD256, IX86_BUILTIN_PCMPGTQ256.
* config/i386/sse.md (avx2_eq<mode>3): Deleted.
(sse2_eq<mode>3): Ditto.
(sse4_1_eqv2di3): Ditto.
(sse2_gt<mode>3): Rename to ..
(*sse2_gt<mode>3): .. this.

gcc/testsuite/ChangeLog:

PR target/98911
* gcc.target/i386/pr98911.c: New test.
* gcc.target/i386/funcspec-8.c: Replace __builtin_ia32_pcmpgtq
with __builtin_ia32_pcmpistrm128 since it has been folded.

3 years agoDaily bump.
GCC Administrator [Sun, 25 Apr 2021 00:16:26 +0000 (00:16 +0000)]
Daily bump.

3 years agoanalyzer: fix ICE on NULL change.m_expr [PR100244]
David Malcolm [Sat, 24 Apr 2021 23:49:31 +0000 (19:49 -0400)]
analyzer: fix ICE on NULL change.m_expr [PR100244]

PR analyzer/100244 reports an ICE on a -Wanalyzer-free-of-non-heap
due to a case where free_of_non_heap::describe_state_change can be
passed a NULL change.m_expr for a suitably complicated symbolic value.

Bulletproof it by checking for change.m_expr being NULL before
dereferencing it.

gcc/analyzer/ChangeLog:
PR analyzer/100244
* sm-malloc.cc (free_of_non_heap::describe_state_change):
Bulletproof against change.m_expr being NULL.

gcc/testsuite/ChangeLog:
PR analyzer/100244
* g++.dg/analyzer/pr100244.C: New test.

3 years agoPR fortran/100154 - ICE in gfc_conv_procedure_call, at fortran/trans-expr.c:6131
Harald Anlauf [Sat, 24 Apr 2021 18:51:41 +0000 (20:51 +0200)]
PR fortran/100154 - ICE in gfc_conv_procedure_call, at fortran/trans-expr.c:6131

Add appropriate static checks for the character and status arguments to
the GNU Fortran intrinsic extensions fget[c], fput[c].  Extend variable
check to allow a function reference having a data pointer result.

gcc/fortran/ChangeLog:

PR fortran/100154
* check.c (variable_check): Allow function reference having a data
pointer result.
(arg_strlen_is_zero): New function.
(gfc_check_fgetputc_sub): Add static check of character and status
arguments.
(gfc_check_fgetput_sub): Likewise.
* intrinsic.c (add_subroutines): Fix argument name for the
character argument to intrinsic subroutines fget[c], fput[c].

gcc/testsuite/ChangeLog:

PR fortran/100154
* gfortran.dg/pr100154.f90: New test.

3 years agoFortran - allow target of pointer from evaluation of function-reference
Harald Anlauf [Sat, 24 Apr 2021 18:38:06 +0000 (20:38 +0200)]
Fortran - allow target of pointer from evaluation of function-reference

Fortran allows the target of a pointer from the evaluation of a
function-reference in a variable definition context (e.g. F2018:R902).

gcc/fortran/ChangeLog:

PR fortran/100218
* expr.c (gfc_check_vardef_context): Extend check to allow pointer
from a function reference.

gcc/testsuite/ChangeLog:

PR fortran/100218
* gfortran.dg/ptr-func-4.f90: New test.

3 years agoRevert "Darwin : Adjust darwin_binds_local_p for PIC code [PR100152]."
Iain Sandoe [Sat, 24 Apr 2021 18:28:25 +0000 (19:28 +0100)]
Revert "Darwin : Adjust darwin_binds_local_p for PIC code [PR100152]."

Unfortunately, although this is required to fix the PR, and is
notionally correct, it regresses some of the sanitizer and IPA
tests.  Reverting until this can be analysed.

This reverts commit b6600392bf71c4a9785f8f49948b611425896830.

3 years agotestuite: fix libtdc++ libatomic flags
David Edelsohn [Fri, 23 Apr 2021 21:45:10 +0000 (17:45 -0400)]
testuite: fix libtdc++ libatomic flags

Some ports require libatomic for atomic operations, at least for some
data types and widths.  The libstdc++ testsuite previously was updated
to link against libatomic, but the search path was hard-coded to
something that is not always correct, and the shared library search
path was not set.

The search path was hard-coded to the expected location of the
libatomic build directory relative to the libstdc++ testsuite
directory, but if one uses parallelism when invoking the libstdc++
testsuite, the tests are run in the "normalXX" sub-directories, for
which the hard-coded search path is incorrect. The path also is
incorrect for alternative multilib and tool options.

This patch adopts the logic from gcc/testsuite/lib/atomic-dg.exp to
search for the library and adds the logic to the libstdc++ testsuite
libatomic seatch path code.  Previously the libstdc++ testsuite atomic
tests failed depending on the build configuration and if a build of
libatomic was installed in the default search path.

Bootstrapped on powerpc-ibm-aix7.2.3.0.

libstdc++-v3/ChangeLog:

* testsuite/lib/dg-options.exp (atomic_link_flags): New.
(add_options_for_libatomic): Use atomic_link_flags.

3 years agoDarwin : Adjust darwin_binds_local_p for PIC code [PR100152].
Iain Sandoe [Sat, 24 Apr 2021 12:34:49 +0000 (13:34 +0100)]
Darwin : Adjust darwin_binds_local_p for PIC code [PR100152].

Darwin's dynamic linker supports interposition and lazy symbol binding.
If we are generating PIC code and a symbol is public, then it could
potentially be indirected via a lazy-resolver stub; we cannot tell at
compile-time if this will be done (since the indirection can be the
result of adding a -flat-namespace option at link-time).  Here we are
conservative and assume that any such symbol cannot bind locally.
The default implementation for binds_local_p handles undefined, weak and
common symbols which are always indirected (for mdynamic-no-pic also).

gcc/ChangeLog:

PR target/100152
* config/darwin.c (darwin_binds_local_p): Assume that any
public symbol might be interposed for PIC code. Update function
header comment to reflect current Darwin capability.

3 years agoAdjust guality xfails for aarch64*-*-*
Richard Sandiford [Sat, 24 Apr 2021 08:35:16 +0000 (09:35 +0100)]
Adjust guality xfails for aarch64*-*-*

This patch gives clean guality.exp test results for aarch64-linux-gnu
with modern (top-of-tree) gdb.

For people using older gdbs, it will trade one set of noisy results for
another set.  I still think it's better to have the xfails based on
one “clean” and “modern” run rather than have FAILs and XPASSes for
all runs.

It's hard to tell which of these results are aarch64-specific and
which aren't.  If other target maintainers want to do something similar,
and are prepared to assume the same gdb version, then it should become
clearer over time which ones are target-specific and which aren't.

There are no new skips here, so changes in test results will still
show up as XPASSes.

I've not analysed the failures or filed PRs for them.  In some
ways the guality directory itself seems like the best place to
start looking for xfails, if someone's interested in working
in this area.

gcc/testsuite/
* gcc.dg/guality/example.c: Update aarch64*-*-* xfails.
* gcc.dg/guality/guality.c: Likewise.
* gcc.dg/guality/inline-params.c: Likewise.
* gcc.dg/guality/loop-1.c: Likewise.
* gcc.dg/guality/pr36728-1.c: Likewise.
* gcc.dg/guality/pr36728-2.c: Likewise.
* gcc.dg/guality/pr36728-3.c: Likewise.
* gcc.dg/guality/pr41447-1.c: Likewise.
* gcc.dg/guality/pr54200.c:  Likewise.
* gcc.dg/guality/pr54519-1.c: Likewise.
* gcc.dg/guality/pr54519-2.c: Likewise.
* gcc.dg/guality/pr54519-3.c: Likewise.
* gcc.dg/guality/pr54519-4.c: Likewise.
* gcc.dg/guality/pr54519-5.c: Likewise.
* gcc.dg/guality/pr54519-6.c: Likewise.
* gcc.dg/guality/pr54693-2.c: Likewise.
* gcc.dg/guality/pr56154-1.c: Likewise.
* gcc.dg/guality/pr59776.c: Likewise.
* gcc.dg/guality/pr68860-1.c: Likewise.
* gcc.dg/guality/pr68860-2.c: Likewise.
* gcc.dg/guality/pr90074.c: Likewise.
* gcc.dg/guality/pr90716.c: Likewise.
* gcc.dg/guality/sra-1.c: Likewise.

3 years agoAdd dg-final option-based target selectors
Richard Sandiford [Sat, 24 Apr 2021 08:35:16 +0000 (09:35 +0100)]
Add dg-final option-based target selectors

This patch adds target selectors of the form:

  { any-opts "opt1" ... "optn" }
  { no-opts "opt1" ... "optn" }

for skipping or xfailing tests based on compiler options.  It only
works for dg-final selectors.

The patch then uses no-opts to exclude -O0 and (sometimes) -Og from
some guality.exp xfails.  AFAICT (based on gcc-testresults) these
tests pass for those options for all targets.

gcc/
* doc/sourcebuild.texi: Document no-opts and any-opts target
selectors.

gcc/testsuite/
* lib/target-supports-dg.exp (selector_expression): Handle any-opts
and no-opts.
* gcc.dg/guality/pr41353-1.c: Exclude -O0 from xfail.
* gcc.dg/guality/pr59776.c: Likewise.
* gcc.dg/guality/pr54970.c: Likewise -O0 and -Og.

3 years agoc++: do_class_deduction and dependent init [PR93383]
Patrick Palka [Sat, 24 Apr 2021 04:14:29 +0000 (00:14 -0400)]
c++: do_class_deduction and dependent init [PR93383]

Here we're crashing during CTAD with a dependent initializer (performed
from convert_template_argument) because one of the initializer's
elements has an empty TREE_TYPE, which ends up making resolve_args
unhappy.

Besides the case where we're initializing one template placeholder
from another, which is already specifically handled earlier in
do_class_deduction, it seems we can't in general correctly resolve a
template placeholder using a dependent initializer, so this patch makes
the function just punt until instantiation time instead.

gcc/cp/ChangeLog:

PR c++/89565
PR c++/93383
PR c++/95291
PR c++/99200
PR c++/99683
* pt.c (do_class_deduction): Punt if the initializer is
type-dependent.

gcc/testsuite/ChangeLog:

PR c++/89565
PR c++/93383
PR c++/95291
PR c++/99200
PR c++/99683
* g++.dg/cpp2a/nontype-class39.C: Remove dg-ice directive.
* g++.dg/cpp2a/nontype-class45.C: New test.
* g++.dg/cpp2a/nontype-class46.C: New test.
* g++.dg/cpp2a/nontype-class47.C: New test.
* g++.dg/cpp2a/nontype-class48.C: New test.

3 years agoc++: Hard error with tentative parse and CTAD [PR87709]
Patrick Palka [Sat, 24 Apr 2021 04:01:42 +0000 (00:01 -0400)]
c++: Hard error with tentative parse and CTAD [PR87709]

When parsing e.g. the operand of sizeof, where both types and
expressions are accepted, if during the tentative type parse we
encounter an unexpected template placeholder, we must simulate
an error rather than issue a real error because the expression
parse can still succeed.

gcc/cp/ChangeLog:

PR c++/87709
* parser.c (cp_parser_type_id_1): If we see a template
placeholder, first try simulating an error before issuing
a real error.

gcc/testsuite/ChangeLog:

PR c++/87709
* g++.dg/cpp1z/class-deduction86.C: New test.

3 years agoDaily bump.
GCC Administrator [Sat, 24 Apr 2021 00:16:37 +0000 (00:16 +0000)]
Daily bump.