platform/upstream/gcc.git
2 years ago[Ada] Reorder subprogram spec and bodies in alphabetical order
Etienne Servais [Thu, 30 Sep 2021 12:27:34 +0000 (14:27 +0200)]
[Ada] Reorder subprogram spec and bodies in alphabetical order

gcc/ada/

* sem_ch4.adb (Analyze_Membership_Op): Reorder subprogram spec
and bodies in alphabetical order.

2 years ago[Ada] Rewrite extended names in derived class-wide expressions
Piotr Trojanek [Thu, 30 Sep 2021 10:54:28 +0000 (12:54 +0200)]
[Ada] Rewrite extended names in derived class-wide expressions

gcc/ada/

* exp_util.adb (Build_Class_Wide_Expression): Replace entities
of both simple and extended names.

2 years ago[Ada] Import binder globals as constant
Ghjuvan Lacambre [Wed, 29 Sep 2021 13:48:49 +0000 (15:48 +0200)]
[Ada] Import binder globals as constant

gcc/ada/

* libgnarl/s-intman__android.adb, libgnarl/s-intman__lynxos.adb,
libgnarl/s-intman__posix.adb, libgnarl/s-intman__qnx.adb,
libgnarl/s-intman__solaris.adb, libgnarl/s-intman__susv3.adb,
libgnarl/s-taprob.adb, libgnarl/s-taprop__hpux-dce.adb,
libgnarl/s-taprop__linux.adb, libgnarl/s-taprop__mingw.adb,
libgnarl/s-taprop__posix.adb, libgnarl/s-taprop__qnx.adb,
libgnarl/s-taprop__solaris.adb, libgnarl/s-taprop__vxworks.adb,
libgnarl/s-taskin.adb, libgnarl/s-tasque.adb,
libgnarl/s-tpoben.adb, libgnat/a-calend.adb,
libgnat/a-excach.adb, libgnat/a-except.adb, libgnat/a-tags.adb,
libgnat/a-textio.adb, libgnat/a-witeio.adb,
libgnat/a-ztexio.adb, libgnat/g-binenv.adb,
libgnat/s-parame.adb, libgnat/s-parame__vxworks.adb,
libgnat/s-stratt.adb, libgnat/s-trasym__dwarf.adb: Mark imported
binder globals as constant.

2 years ago[Ada] Move rewriting of boxes in aggregates from resolution to expansion
Piotr Trojanek [Wed, 29 Sep 2021 17:51:33 +0000 (19:51 +0200)]
[Ada] Move rewriting of boxes in aggregates from resolution to expansion

gcc/ada/

* exp_aggr.adb (Initialize_Record_Component): Add assertion
about one of the parameters, so that illegal attempts to
initialize record components with Empty node are detected early
on.
(Build_Record_Aggr_Code): Handle boxes in aggregate component
associations just the components with no initialization in
Build_Record_Init_Proc.
* sem_aggr.adb (Resolve_Record_Aggregate): For components that
require simple initialization carry boxes from resolution to
expansion.
* sem_util.adb (Needs_Simple_Initialization): Remove redundant
paren.

2 years ago[Ada] Simplify initialization of concurrent components
Piotr Trojanek [Wed, 29 Sep 2021 14:10:23 +0000 (16:10 +0200)]
[Ada] Simplify initialization of concurrent components

gcc/ada/

* exp_ch3.adb (Build_Init_Statements): Simplify detection of
concurrent record types.

2 years ago[Ada] Simplify detection of delayed aggregates
Piotr Trojanek [Wed, 29 Sep 2021 10:18:36 +0000 (12:18 +0200)]
[Ada] Simplify detection of delayed aggregates

gcc/ada/

* exp_aggr.adb (Is_Delayed_Aggregate): Simplify.

2 years ago[Ada] Simplify detection of record components with default initialization
Piotr Trojanek [Wed, 29 Sep 2021 10:16:38 +0000 (12:16 +0200)]
[Ada] Simplify detection of record components with default initialization

gcc/ada/

* exp_aggr.adb (Has_Default_Init_Comps): Simplify.

2 years ago[Ada] Remove redundant guard against an empty component list
Piotr Trojanek [Wed, 29 Sep 2021 10:13:17 +0000 (12:13 +0200)]
[Ada] Remove redundant guard against an empty component list

gcc/ada/

* exp_aggr.adb (Component_OK_For_Backend): Remove redundant
guard.

2 years ago[Ada] RTEMS: use default stack checking emulation package
Patrick Bernardi [Tue, 28 Sep 2021 18:00:09 +0000 (14:00 -0400)]
[Ada] RTEMS: use default stack checking emulation package

gcc/ada/

* Makefile.rtl (RTEMS): Add s-stchop.o to
EXTRA_GNATRTL_NONTASKING_OBJS, remove s-stchop__rtems.adb.
* libgnat/s-stchop__rtems.adb: Removed.

2 years ago[Ada] Do not clear Analyzed flag in expand if already set by preanalysis
Marc Poulhiès [Mon, 20 Sep 2021 14:33:30 +0000 (16:33 +0200)]
[Ada] Do not clear Analyzed flag in expand if already set by preanalysis

gcc/ada/

* expander.adb (Expand): Skip clearing of Analyzed flag if
already set for N_Real_Literal.

2 years ago[Ada] Simplify code for checks within an initialization procedure
Piotr Trojanek [Mon, 27 Sep 2021 14:37:57 +0000 (16:37 +0200)]
[Ada] Simplify code for checks within an initialization procedure

gcc/ada/

* sem_util.adb (Compile_Time_Constraint_Error): Simplify getting
the type of the first formal parameter.

2 years ago[Ada] Fix crash on array component with Default_Value
Piotr Trojanek [Mon, 27 Sep 2021 14:15:39 +0000 (16:15 +0200)]
[Ada] Fix crash on array component with Default_Value

gcc/ada/

* exp_util.adb (Inside_Init_Proc): Simplify.
* sem_aggr.adb (Resolve_Record_Aggregate): Fix style.
* sem_util.adb (Compile_Time_Constraint_Error): Guard against
calling Corresponding_Concurrent_Type with an array type entity.

2 years ago[Ada] Size of time_t in newer verions of VxWorks7
Doug Rupp [Fri, 17 Sep 2021 20:18:29 +0000 (13:18 -0700)]
[Ada] Size of time_t in newer verions of VxWorks7

gcc/ada/

* libgnat/s-parame__ae653.ads (time_t_bits): Change to
Long_Long_Integer'Size.  Add some comments to explain.

2 years agoopts: Remove AUTODETECT_VALUE usage.
Martin Liska [Fri, 8 Oct 2021 08:00:45 +0000 (10:00 +0200)]
opts: Remove AUTODETECT_VALUE usage.

gcc/ChangeLog:

* common.opt: Remove Init(2) for some options.
* toplev.c (process_options): Do not use AUTODETECT_VALUE, but
use rather OPTION_SET_P.

2 years agoRemove usage of IRA_REGION_AUTODETECT
Martin Liska [Fri, 8 Oct 2021 07:51:19 +0000 (09:51 +0200)]
Remove usage of IRA_REGION_AUTODETECT

gcc/ChangeLog:

* common.opt: Remove usage of IRA_REGION_AUTODETECT.
* flag-types.h (enum ira_region): Likewise.
* toplev.c (process_options): Use OPTION_SET_P instead of
IRA_REGION_AUTODETECT.

2 years agolibgomp: Add tests for omp_atv_serialized and deprecate omp_atv_sequential.
Marcel Vollweiler [Mon, 11 Oct 2021 11:34:51 +0000 (04:34 -0700)]
libgomp: Add tests for omp_atv_serialized and deprecate omp_atv_sequential.

The variable omp_atv_sequential was replaced by omp_atv_serialized in OpenMP
5.1. This was already implemented by Jakub (C/C++, commit ea82325afec) and
Tobias (Fortran, commit fff15bad1ab).

This patch adds two tests to check if omp_atv_serialized is available (one test
for C/C++ and one for Fortran). Besides that omp_atv_sequential is marked as
deprecated in C/C++ and Fortran for OpenMP 5.1.

libgomp/ChangeLog:

* allocator.c (omp_init_allocator): Replace omp_atv_sequential with
omp_atv_serialized.
* omp.h.in: Add deprecated flag for omp_atv_sequential.
* omp_lib.f90.in: Add deprecated flag for omp_atv_sequential.
* testsuite/libgomp.c-c++-common/alloc-10.c: New test.
* testsuite/libgomp.fortran/alloc-12.f90: New test.

2 years agoopenmp: Add omp_set_num_teams, omp_get_max_teams, omp_[gs]et_teams_thread_limit
Jakub Jelinek [Mon, 11 Oct 2021 10:02:15 +0000 (12:02 +0200)]
openmp: Add omp_set_num_teams, omp_get_max_teams, omp_[gs]et_teams_thread_limit

OpenMP 5.1 adds env vars and functions to set and query new ICVs used
as fallback if thread_limit or num_teams clauses aren't specified on
teams construct.

The following patch implements those, though further work will be needed:
1) OpenMP 5.1 also changed the num_teams clause, so that it can specify
   both lower and upper limit for how many teams should be created and
   changed the meaning when only one expression is provided, instead of
   num_teams(expr) in 5.0 meaning num_teams(1:expr) in 5.1, it now means
   num_teams(expr:expr), i.e. while previously we could create 1 to expr
   teams, in 5.1 we have some low limit by default equal to the single
   expression provided and may not create fewer teams.
   For host teams (which we don't currently implement efficiently for
   NUMA hosts) we trivially satisfy it now by always honoring what the
   user asked for, but for the offloading teams I think we'll need to
   rethink the APIs; currently teams construct is just a call that returns
   and possibly lowers the number of teams; and whenever possible we try
   to evaluate num_teams/thread_limit already on the target construct
   and the GOMP_teams call just sets the number of teams to the minimum
   of provided and requested teams; for some cases e.g. where target
   is not combined with teams and num_teams expression calls some functions
   etc., we need to call those functions in the target region and so it is
   late to figure number of teams, but also hw could just limit what it
   is willing to create; in that case I'm afraid we need to run the target
   body multiple times and arrange for omp_get_team_num () returning the
   right values
2) we need to finally implement the NUMA handling for GOMP_teams_reg
3) I now realize I haven't added some testcase coverage, will do that
   incrementally
4) libgomp.texi needs updates for these new APIs, but also others like
   the allocator

2021-10-11  Jakub Jelinek  <jakub@redhat.com>

gcc/
* omp-low.c (omp_runtime_api_call): Handle omp_get_max_teams,
omp_[sg]et_teams_thread_limit and omp_set_num_teams.
libgomp/
* omp.h.in (omp_set_num_teams, omp_get_max_teams,
omp_set_teams_thread_limit, omp_get_teams_thread_limit): Declare.
* omp_lib.f90.in (omp_set_num_teams, omp_get_max_teams,
omp_set_teams_thread_limit, omp_get_teams_thread_limit): Declare.
* omp_lib.h.in (omp_set_num_teams, omp_get_max_teams,
omp_set_teams_thread_limit, omp_get_teams_thread_limit): Declare.
* libgomp.h (gomp_nteams_var, gomp_teams_thread_limit_var): Declare.
* libgomp.map (OMP_5.1): Export omp_get_max_teams{,_},
omp_get_teams_thread_limit{,_}, omp_set_num_teams{,_,_8_} and
omp_set_teams_thread_limit{,_,_8_}.
* icv.c (omp_set_num_teams, omp_get_max_teams,
omp_set_teams_thread_limit, omp_get_teams_thread_limit): New
functions.
* env.c (gomp_nteams_var, gomp_teams_thread_limit_var): Define.
(omp_display_env): Print OMP_NUM_TEAMS and OMP_TEAMS_THREAD_LIMIT.
(initialize_env): Handle OMP_NUM_TEAMS and OMP_TEAMS_THREAD_LIMIT env
vars.
* teams.c (GOMP_teams_reg): If thread_limit is not specified, use
gomp_teams_thread_limit_var as fallback if not zero.  If num_teams
is not specified, use gomp_nteams_var.
* fortran.c (omp_set_num_teams, omp_get_max_teams,
omp_set_teams_thread_limit, omp_get_teams_thread_limit): Add
ialias_redirect.
(omp_set_num_teams_, omp_set_num_teams_8_, omp_get_max_teams_,
omp_set_teams_thread_limit_, omp_set_teams_thread_limit_8_,
omp_get_teams_thread_limit_): New functions.

2 years agoIBM Z: Provide rawmemchr{qi,hi,si} expander
Stefan Schulze Frielinghaus [Mon, 11 Oct 2021 07:59:32 +0000 (09:59 +0200)]
IBM Z: Provide rawmemchr{qi,hi,si} expander

gcc/ChangeLog:

* config/s390/s390-protos.h (s390_rawmemchr): Add prototype.
* config/s390/s390.c (s390_rawmemchr): New function.
* config/s390/s390.md (rawmemchr<SINT:mode>): New expander.
* config/s390/vector.md (@vec_vfees<mode>): Basically a copy of
the pattern vfees<mode> from vx-builtins.md.
* config/s390/vx-builtins.md (*vfees<mode>): Remove.

gcc/testsuite/ChangeLog:

* gcc.target/s390/rawmemchr-1.c: New test.

2 years agoldist: Recognize strlen and rawmemchr like loops
Stefan Schulze Frielinghaus [Mon, 11 Oct 2021 07:59:13 +0000 (09:59 +0200)]
ldist: Recognize strlen and rawmemchr like loops

This patch adds support for recognizing loops which mimic the behaviour
of functions strlen and rawmemchr, and replaces those with internal
function calls in case a target provides them.  In contrast to the
standard strlen and rawmemchr functions, this patch also supports
different instances where the memory pointed to is interpreted as 8, 16,
and 32-bit sized, respectively.

gcc/ChangeLog:

* builtins.c (get_memory_rtx): Change to external linkage.
* builtins.h (get_memory_rtx): Add function prototype.
* doc/md.texi (rawmemchr<mode>): Document.
* internal-fn.c (expand_RAWMEMCHR): Define.
* internal-fn.def (RAWMEMCHR): Add.
* optabs.def (rawmemchr_optab): Add.
* tree-loop-distribution.c (find_single_drs): Change return code
behaviour by also returning true if no single store was found
but a single load.
(loop_distribution::classify_partition): Respect the new return
code behaviour of function find_single_drs.
(loop_distribution::execute): Call new function
transform_reduction_loop in order to replace rawmemchr or strlen
like loops by calls into builtins.
(generate_reduction_builtin_1): New function.
(generate_rawmemchr_builtin): New function.
(generate_strlen_builtin_1): New function.
(generate_strlen_builtin): New function.
(generate_strlen_builtin_using_rawmemchr): New function.
(reduction_var_overflows_first): New function.
(determine_reduction_stmt_1): New function.
(determine_reduction_stmt): New function.
(loop_distribution::transform_reduction_loop): New function.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/ldist-rawmemchr-1.c: New test.
* gcc.dg/tree-ssa/ldist-rawmemchr-2.c: New test.
* gcc.dg/tree-ssa/ldist-strlen-1.c: New test.
* gcc.dg/tree-ssa/ldist-strlen-2.c: New test.
* gcc.dg/tree-ssa/ldist-strlen-3.c: New test.

2 years agooptions: use cl_optimization_hash.
Martin Liska [Fri, 8 Oct 2021 07:40:16 +0000 (09:40 +0200)]
options: use cl_optimization_hash.

gcc/ChangeLog:

* tree.c (cl_option_hasher::hash): Use cl_optimization_hash
and remove legacy hashing code.

2 years ago[PR/target 100316] Allow constant address for __builtin___clear_cache.
Kito Cheng [Thu, 7 Oct 2021 08:17:13 +0000 (16:17 +0800)]
[PR/target 100316] Allow constant address for __builtin___clear_cache.

__builtin___clear_cache was able to accept constant address for the
argument, but it seems no longer accept recently, and it even not
accept constant address which is hold in variable when optimization is
enable:

```
void foo3(){
  void *yy = (void*)0x1000;
  __builtin___clear_cache(yy, yy);
}
```

So this patch make BEGIN and END accept VOIDmode, like cselib_lookup_mem did per
Jim Wilson's suggestion.

```
static cselib_val *
cselib_lookup_mem (rtx x, int create)
{
  ...
  addr_mode = GET_MODE (XEXP (x, 0));
  if (addr_mode == VOIDmode)
    addr_mode = Pmode;
```

Changes v2 -> v3:
- Use gcc_assert rather than error, maybe_emit_call_builtin___clear_cache is
internal use only, and we already checked the type in other place.

Changes v1 -> v2:
- Check is CONST_INT intead of cehck mode, no new testcase, since
  constant value with other type like CONST_DOUBLE will catched by
  front-end.
e.g.
Code:
```c
void foo(){
  __builtin___clear_cache(1.11, 0);
}
```
Error message:
```
clearcache-double.c: In function 'foo':
clearcache-double.c:2:27: error: incompatible type for argument 1 of '__builtin___clear_cache'
    2 |   __builtin___clear_cache(1.11, 0);
      |                           ^~~~
      |                           |
      |                           double
clearcache-double.c:2:27: note: expected 'void *' but argument is of type 'double'
```

gcc/ChangeLog:

PR target/100316
* builtins.c (maybe_emit_call_builtin___clear_cache): Allow
CONST_INT for BEGIN and END, and use gcc_assert rather than
error.

gcc/testsuite/ChangeLog:

PR target/100316
* gcc.c-torture/compile/pr100316.c: New.

2 years agoAdjust testcase for O2 vectorization enabling.
liuhongt [Mon, 11 Oct 2021 05:14:13 +0000 (13:14 +0800)]
Adjust testcase for O2 vectorization enabling.

gcc/testsuite/ChangeLog:

PR middle-end/102669
* gnat.dg/unroll1.adb: Add -fno-tree-vectorize.

2 years agoDaily bump.
GCC Administrator [Mon, 11 Oct 2021 00:16:24 +0000 (00:16 +0000)]
Daily bump.

2 years agoFortran: handle initialization of derived type parameter arrays from scalar
Harald Anlauf [Sun, 10 Oct 2021 18:11:43 +0000 (20:11 +0200)]
Fortran: handle initialization of derived type parameter arrays from scalar

gcc/fortran/ChangeLog:

PR fortran/99348
PR fortran/102521
* decl.c (add_init_expr_to_sym): Extend initialization of
parameter arrays from scalars to handle derived types.

gcc/testsuite/ChangeLog:

PR fortran/99348
PR fortran/102521
* gfortran.dg/parameter_array_init_8.f90: New test.

2 years agovar-tracking: Fix a wrong-debug issue caused by my r10-7665 var-tracking change ...
Jakub Jelinek [Sun, 10 Oct 2021 10:13:22 +0000 (12:13 +0200)]
var-tracking: Fix a wrong-debug issue caused by my r10-7665 var-tracking change [PR102441]

Since my r10-7665-g33c45e51b4914008064d9b77f2c1fc0eea1ad060 change, we get
wrong-debug on e.g. the following testcase at -O2 -g on x86_64-linux for the
x parameter:
void bar (int *r);
int
foo (int x)
{
  int r = 0;
  bar (&r);
  return r;
}
At the start of function, we have
        subq    $24, %rsp
        leaq    12(%rsp), %rdi
instructions.  The x parameter is passed in %rdi, but isn't used in the
function and so the leaq instruction overwrites %rdi without remembering
%rdi anywhere.  Before the r10-7665 change (which was trying to fix a large
(3% for 32-bit, 1% for 64-bit x86-64) debug info/loc growth introduced with
r10-7515), the leaq insn above resulted in a MO_VAL_SET micro-operation that
said that the value of sp + 12, a cselib_sp_derived_value_p, is stored into
the %rdi register.  The r10-7665 change added a change to add_stores that
added no micro-operation for the leaq store, with the rationale that the sp
based values can be and will be always computable some other more compact
and primarily more stable way (cfa based expression like DW_OP_fbreg, that
is the same in the whole function).  That is true.  But by throwing the
micro-operation on the floor, we miss another important part of the
MO_VAL_SET, in particular that the destination of the store, %rdi in this
case, now has a different value from what it had before, so the vt_*
dataflow code thinks that even after the leaq instruction %rdi still holds
the x argument value (and changes it to DW_OP_entry_value (%rdi) only in the
middle of the call to bar).  Previously and with the patches below,
the location for x changes already at the end of leaq instruction to
DW_OP_entry_value (%rdi).

My first attempt to fix this was instead of dropping the MO_VAL_SET add
a MO_CLOBBER operation:
--- gcc/var-tracking.c.jj       2021-05-04 21:02:24.196799586 +0200
+++ gcc/var-tracking.c  2021-09-24 19:23:16.420154828 +0200
@@ -6133,7 +6133,9 @@ add_stores (rtx loc, const_rtx expr, voi
     {
       if (preserve)
        preserve_value (v);
-      return;
+      mo.type = MO_CLOBBER;
+      mo.u.loc = loc;
+      goto log_and_return;
     }

   nloc = replace_expr_with_values (oloc);
so don't track that the value lives in the loc destination, but track
that the previous value doesn't live there anymore.  That failed bootstrap
miserably, the vt_* code isn't prepared to see MO_CLOBBER of a MEM that
isn't tracked (e.g. has MEM_EXPR on it that the var-tracking code wants
to track, i.e. track_p in add_stores).  On the other side, thinking about
it more, in the most common case where a cselib_sp_derived_value_p value
is stored into the sp register (and which is the reason why PR94495
testcase got larger), dropping the micro-operation on the floor is the
right thing, because we have that cselib_sp_derived_value_p tracking, any
reads from the sp hard register will be treated as
cselib_sp_derived_value_p.
Then I've tried 3 different patches described below and in the end
what is committed is patch2.
Additionally, I've gathered statistics from cc1plus by always reverting the
var-tracking.c change after finished bootstrap/regtest and rebuilding the
stage3 var-tracking.o and cc1plus, such that it would be comparable.
dwlocstat and .debug_{info,loclists} section sizes detailed below.
patch3 uses MO_VAL_SET (i.e. essentially reversion of the r10-7665
change) when destination is not a REG_P and !track_p, otherwise if
destination is sp drops the micro-operation on the floor (i.e. no change),
otherwise adds a MO_CLOBBER.
patch1 is similar, except it checks for destination not equal to sp and
!track_p, i.e. for !track_p REG_P destinations other than sp it will use
MO_VAL_SET rather than MO_CLOBBER.
Finally, patch2, the shortest patch, uses MO_VAL_SET whenever destination
is not sp and otherwise drops the micro-operation on the floor.
All the 3 patches don't affect the PR94495 testcase, all the changes
there were caused by stores of sp based values into %rsp.

While the patch2 (and patch1 which results in exactly the same sizes)
causes the largest debug loclists/info growth from the 3, it is still quite
minor (0.651% on 64-bit and 0.114% on 32-bit) compared
to the 1% and 3% PR94495 was trying to solve, and I actually think it is the
best thing to do.  Because, if we have say
  int q[10];
  int *p = &q[0];
or similar and we load the &q[0] sp based value into some hard register,
by noting in the debug info that p lives in some hard reg for some part
of the function and a user is trying to change the p var in the debugger,
if we say it lives in some register or memory, there is some chance that
the changing of the value could work successfully (of course, nothing
is guaranteed, we don't have tracking of where each var lives at which
moment for changing purposes (i.e. what register, memory or else you need
to change in order to change behavior of the code)), while if we just say
that p's location is DW_OP_fbreg 16 DW_OP_stack_value, that is a read-only
value one can just print but not change.  Now, for stores of variable
values into the sp register, I don't think we have such an issue, you don't
want debugger to change your stack pointer when user asks to change value
of some variable whose value lives in the stack pointer, that would pretty
much always result in misbehavior of the program.
So, my preference from these 3 is patch2 and that is being committed.

64-bit cc1plus
==============
vanilla
cov%    samples cumul
0..10   1064665/37%     1064665/37%
11..20  35972/1%        1100637/38%
21..30  47969/1%        1148606/40%
31..40  45787/1%        1194393/42%
41..50  57529/2%        1251922/44%
51..60  53974/1%        1305896/46%
61..70  112055/3%       1417951/50%
71..80  79420/2%        1497371/52%
81..90  126225/4%       1623596/57%
91..100 1206682/42%     2830278/100%
  [34] .debug_info       PROGBITS        0000000000000000 2f1c74c a44949f 00      0   0  1
  [38] .debug_loclists   PROGBITS        0000000000000000 ff5d046 506e947 00      0   0  1
patch1 (same as patch2)
cov%    samples cumul
0..10   1064685/37%     1064685/37%
11..20  36011/1%        1100696/38%
21..30  47975/1%        1148671/40%
31..40  45799/1%        1194470/42%
41..50  57566/2%        1252036/44%
51..60  54011/1%        1306047/46%
61..70  112068/3%       1418115/50%
71..80  79421/2%        1497536/52%
81..90  126171/4%       1623707/57%
91..100 1206571/42%     2830278/100%
  [34] .debug_info       PROGBITS        0000000000000000 2f1c74c a448f27 00      0   0  1
  [38] .debug_loclists   PROGBITS        0000000000000000 ff608bc 52070dd 00      0   0  1
patch3
cov%    samples cumul
0..10   1064698/37%     1064698/37%
11..20  36018/1%        1100716/38%
21..30  47977/1%        1148693/40%
31..40  45804/1%        1194497/42%
41..50  57562/2%        1252059/44%
51..60  54018/1%        1306077/46%
61..70  112071/3%       1418148/50%
71..80  79424/2%        1497572/52%
81..90  126172/4%       1623744/57%
91..100 1206534/42%     2830278/100%
  [34] .debug_info       PROGBITS        0000000000000000 2f1c74c a449548 00      0   0  1
  [38] .debug_loclists   PROGBITS        0000000000000000 ff5df39 507acd8 00      0   0  1
So, size of .debug_info+.debug_loclists grows for vanilla -> patch1 (or patch2) by
0.651% and for vanilla -> patch3 by 0.020%.

32-bit cc1plus
==============
vanilla
cov%    samples cumul
0..10   1061892/37%     1061892/37%
11..20  34002/1%        1095894/39%
21..30  43513/1%        1139407/40%
31..40  41667/1%        1181074/42%
41..50  59144/2%        1240218/44%
51..60  47009/1%        1287227/45%
61..70  105069/3%       1392296/49%
71..80  72990/2%        1465286/52%
81..90  125988/4%       1591274/56%
91..100 1208726/43%     2800000/100%
  [33] .debug_info       PROGBITS        00000000 351ab10 8b1c83d 00      0   0  1
  [37] .debug_loclists   PROGBITS        00000000 ebc816e 3fe44fd 00      0   0  1
patch1 (same as patch2)
cov%    samples cumul
0..10   1061999/37%     1061999/37%
11..20  34065/1%        1096064/39%
21..30  43557/1%        1139621/40%
31..40  41690/1%        1181311/42%
41..50  59191/2%        1240502/44%
51..60  47143/1%        1287645/45%
61..70  105045/3%       1392690/49%
71..80  73021/2%        1465711/52%
81..90  125885/4%       1591596/56%
91..100 1208404/43%     2800000/100%
  [33] .debug_info       PROGBITS        00000000 351ab10 8b1c597 00      0   0  1
  [37] .debug_loclists   PROGBITS        00000000 ebca915 401ffad 00      0   0  1
patch3
cov%    samples cumul
0..10   1062006/37%     1062006/37%
11..20  34073/1%        1096079/39%
21..30  43559/1%        1139638/40%
31..40  41693/1%        1181331/42%
41..50  59189/2%        1240520/44%
51..60  47142/1%        1287662/45%
61..70  105054/3%       1392716/49%
71..80  73027/2%        1465743/52%
81..90  125874/4%       1591617/56%
91..100 1208383/43%     2800000/100%
  [33] .debug_info       PROGBITS        00000000 351ab10 8b1c690 00      0   0  1
  [37] .debug_loclists   PROGBITS        00000000 ebca40a 4020a6e 00      0   0  1
So, size of .debug_info+.debug_loclists grows for vanilla -> patch1 (or patch2) by
0.114% and for vanilla -> patch3 by 0.116%.

2021-10-10  Jakub Jelinek  <jakub@redhat.com>

PR debug/102441
* var-tracking.c (add_stores): For cselib_sp_derived_value_p values
use MO_VAL_SET if loc is not sp.

2 years agotree-optimization: [PR102622]: wrong code due to signed one bit integer and "a?-1:0"
Andrew Pinski [Sun, 10 Oct 2021 01:28:59 +0000 (01:28 +0000)]
tree-optimization: [PR102622]: wrong code due to signed one bit integer and "a?-1:0"

So it turns out this is kinda of a latent bug but not really latent.
In GCC 9 and 10, phi-opt would transform a?-1:0 (even for signed 1-bit integer)
to -(type)a but the type is an one bit integer which means the negation is
undefined. GCC 11 fixed the problem by checking for a?pow2cst:0 transformation
before a?-1:0 transformation.

When I added the transformations to match.pd, I had swapped the order not paying
attention and I didn't expect anything of it. Because there was no testcase failing
due to this.
Anyways this fixes the problem on the trunk by swapping the order in match.pd and
adding a comment of why the order is this way.

I will try to come up with a patch for GCC 9 and 10 series later on which fixes
the problem there too.

Note I didn't include the original testcase which requires the vectorizer and AVX-512f
as I can't figure out the right dg options to restrict it to avx-512f but I did come up
with a testcase which shows the problem and even more shows the problem with the 9/10
series as mentioned.

OK? Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/102622

gcc/ChangeLog:

* match.pd: Swap the order of a?pow2cst:0 and a?-1:0 transformations.
Swap the order of a?0:pow2cst and a?0:-1 transformations.

gcc/testsuite/ChangeLog:

* gcc.c-torture/execute/bitfld-10.c: New test.

2 years agoDaily bump.
GCC Administrator [Sun, 10 Oct 2021 00:16:19 +0000 (00:16 +0000)]
Daily bump.

2 years agoFortran: accept both old and new-style relational operators in USE, ONLY
Harald Anlauf [Sat, 9 Oct 2021 19:16:32 +0000 (21:16 +0200)]
Fortran: accept both old and new-style relational operators in USE, ONLY

F2018:10.1.5.5.1(2) requires the same interpretation of old and new-style
relational operators.  As gfortran internally distinguishes between
these versions, we must match equivalent notations in
USE module, ONLY: OPERATOR(op)
statements when reading modules.

gcc/fortran/ChangeLog:

PR fortran/65454
* module.c (read_module): Handle old and new-style relational
operators when used in USE module, ONLY: OPERATOR(op).

gcc/testsuite/ChangeLog:

PR fortran/65454
* gfortran.dg/interface_operator_3.f90: New test.

2 years agotestsuite: Add missing comment for some dg-warning
Kewen Lin [Sat, 9 Oct 2021 09:17:07 +0000 (04:17 -0500)]
testsuite: Add missing comment for some dg-warning

This fixes the typos introduced by commit r12-4240.

The dg-warning format looks like:

{ dg-warning regexp
    [comment [{ target/xfail selector } [line] ]] }

Some dg-warnings such as:

{ dg-warning "\\\[-Wstringop-overflow"
    { target { i?86-*-* x86_64-*-* } } }

miss the comment field, it makes target selector not take effect.

For targets which are not { i?86-*-* x86_64-*-* }, this kind of cases
fail or pass unexpectedly.

gcc/testsuite/ChangeLog:

* c-c++-common/Wstringop-overflow-2.c: Add missing comment.
* gcc.dg/Warray-bounds-51.c: Likewise.
* gcc.dg/Warray-parameter-3.c: Likewise.
* gcc.dg/Wstringop-overflow-14.c: Likewise.
* gcc.dg/Wstringop-overflow-21.c: Likewise.
* gcc.dg/Wstringop-overflow-76.c: Likewise.

2 years agoAdjust more testcases for O2 vectorization enabling.
liuhongt [Sat, 9 Oct 2021 02:26:22 +0000 (10:26 +0800)]
Adjust more testcases for O2 vectorization enabling.

libgomp/ChangeLog:

* testsuite/libgomp.c++/scan-10.C: Add option -fvect-cost-model=cheap.
* testsuite/libgomp.c++/scan-11.C: Ditto.
* testsuite/libgomp.c++/scan-12.C: Ditto.
* testsuite/libgomp.c++/scan-13.C: Ditto.
* testsuite/libgomp.c++/scan-14.C: Ditto.
* testsuite/libgomp.c++/scan-15.C: Ditto.
* testsuite/libgomp.c++/scan-16.C: Ditto.
* testsuite/libgomp.c++/scan-9.C: Ditto.
* testsuite/libgomp.c-c++-common/lastprivate-conditional-7.c: Ditto.
* testsuite/libgomp.c-c++-common/lastprivate-conditional-8.c: Ditto.
* testsuite/libgomp.c/scan-11.c: Ditto.
* testsuite/libgomp.c/scan-12.c: Ditto.
* testsuite/libgomp.c/scan-13.c: Ditto.
* testsuite/libgomp.c/scan-14.c: Ditto.
* testsuite/libgomp.c/scan-15.c: Ditto.
* testsuite/libgomp.c/scan-16.c: Ditto.
* testsuite/libgomp.c/scan-17.c: Ditto.
* testsuite/libgomp.c/scan-18.c: Ditto.
* testsuite/libgomp.c/scan-19.c: Ditto.
* testsuite/libgomp.c/scan-20.c: Ditto.
* testsuite/libgomp.c/scan-21.c: Ditto.
* testsuite/libgomp.c/scan-22.c: Ditto.

gcc/testsuite/ChangeLog:

* g++.dg/tree-ssa/pr94403.C: Add -fno-tree-vectorize
* gcc.dg/optimize-bswapsi-5.c: Ditto.
* gcc.dg/optimize-bswapsi-6.c: Ditto.
* gcc.dg/Warray-bounds-51.c: Add additional option
-mtune=generic for target x86/i?86
* gcc.dg/Wstringop-overflow-14.c: Ditto.

2 years agoopenmp: Add support for OpenMP 5.1 structured-block-sequences
Jakub Jelinek [Sat, 9 Oct 2021 08:14:36 +0000 (10:14 +0200)]
openmp: Add support for OpenMP 5.1 structured-block-sequences

Related to this is the addition of structured-block-sequence in OpenMP 5.1,
which doesn't change anything for Fortran, but for C/C++ allows multiple
statements instead of just one possibly compound around the separating
directives (section and scan).

I've also made some updates to the OpenMP 5.1 support list in libgomp.texi.

2021-10-09  Jakub Jelinek  <jakub@redhat.com>

gcc/c/
* c-parser.c (c_parser_omp_structured_block_sequence): New function.
(c_parser_omp_scan_loop_body): Use it.
(c_parser_omp_sections_scope): Likewise.
gcc/cp/
* parser.c (cp_parser_omp_structured_block): Remove disallow_omp_attrs
argument.
(cp_parser_omp_structured_block_sequence): New function.
(cp_parser_omp_scan_loop_body): Use it.
(cp_parser_omp_sections_scope): Likewise.
gcc/testsuite/
* c-c++-common/gomp/sections1.c (foo): Don't expect errors on
multiple statements in between section directive(s).  Add testcases
for invalid no statements in between section directive(s).
* gcc.dg/gomp/sections-2.c (foo): Don't expect errors on
multiple statements in between section directive(s).
* g++.dg/gomp/sections-2.C (foo): Likewise.
* g++.dg/gomp/attrs-6.C (foo): Add testcases for multiple
statements in between section directive(s).
(bar): Add testcases for multiple statements in between scan
directive.
* g++.dg/gomp/attrs-7.C (bar): Adjust expected error recovery.
libgomp/
* libgomp.texi (OpenMP 5.1): Mention implemented support for
structured block sequences in C/C++.  Mention support for
unconstrained/reproducible modifiers on order clause.
Mention partial (C/C++ only) support of extentensions to atomics
construct.  Mention partial (C/C++ on clause only) support of
align/allocator modifiers on allocate clause.

2 years agoRefine movhfcc.
liuhongt [Fri, 8 Oct 2021 07:21:44 +0000 (15:21 +0800)]
Refine movhfcc.

For AVX512-FP16, HFmode only supports vcmpsh whose dest is mask
register, so for movhfcc, it's

vcmpsh op2, op1, %k1
vmovsh op1, op2{%k1}
mov op2, dest

gcc/ChangeLog:

PR target/102639
* config/i386/i386-expand.c (ix86_valid_mask_cmp_mode): Handle
HFmode.
(ix86_use_mask_cmp_p): Ditto.
(ix86_expand_sse_movcc): Ditto.
* config/i386/i386.md (setcc_hf_mask): New define_insn.
(movhf_mask): Ditto.
(UNSPEC_MOVCC_MASK): New unspec.
* config/i386/sse.md (UNSPEC_PCMP): Move to i386.md.

gcc/testsuite/ChangeLog:
* g++.target/i386/pr102639.C: New test.

2 years agoDaily bump.
GCC Administrator [Sat, 9 Oct 2021 00:16:26 +0000 (00:16 +0000)]
Daily bump.

2 years agolibstdc++: Remove unnecessary uses of _GLIBCXX_USE_WCHAR_T in testsuite [PR98725]
Jonathan Wakely [Fri, 8 Oct 2021 19:48:35 +0000 (20:48 +0100)]
libstdc++: Remove unnecessary uses of _GLIBCXX_USE_WCHAR_T in testsuite [PR98725]

Now that std::wstring and other specializations for wchar_t are defined
unconditionally, many checks for _GLIBCXX_USE_WCHAR_T in the testsuite
are unnecessary and can be removed. Tests for iostreams, locales, regex
and filesystem::path still need to be guarded by _GLIBCXX_USE_WCHAR_T
because those components depend on libc support in <wchar.h> and other
headers.

libstdc++-v3/ChangeLog:

PR libstdc++/98725
* testsuite/18_support/numeric_limits/lowest.cc: Remove use of
_GLIBCXX_USE_WCHAR_T.
* testsuite/18_support/numeric_limits/min_max.cc: Replace use of
_GLIBCXX_USE_WCHAR_T with checks for WCHAR_MIN and WCHAR_MAX.
* testsuite/20_util/from_chars/1_neg.cc: Remove use of
_GLIBCXX_USE_WCHAR_T.
* testsuite/20_util/function_objects/searchers.cc: Likewise. Use
char_traits<wchar_t>::length instead of wcslen.
* testsuite/20_util/hash/requirements/explicit_instantiation.cc:
Likewise.
* testsuite/20_util/is_arithmetic/value.cc: Likewise.
* testsuite/20_util/is_compound/value.cc: Likewise.
* testsuite/20_util/is_floating_point/value.cc: Likewise.
* testsuite/20_util/is_fundamental/value.cc: Likewise.
* testsuite/20_util/is_integral/value.cc: Likewise.
* testsuite/20_util/is_signed/value.cc: Likewise.
* testsuite/20_util/is_unsigned/value.cc: Likewise.
* testsuite/20_util/is_void/value.cc: Likewise.
* testsuite/20_util/make_signed/requirements/typedefs-1.cc:
Likewise.
* testsuite/20_util/make_signed/requirements/typedefs-2.cc:
Likewise.
* testsuite/20_util/make_signed/requirements/typedefs-3.cc:
Likewise.
* testsuite/20_util/make_signed/requirements/typedefs-4.cc:
Likewise.
* testsuite/20_util/make_unsigned/requirements/typedefs-1.cc:
Likewise.
* testsuite/20_util/make_unsigned/requirements/typedefs-2.cc:
Likewise.
* testsuite/20_util/make_unsigned/requirements/typedefs-3.cc:
Likewise.
* testsuite/20_util/to_chars/3.cc: Likewise.
* testsuite/20_util/type_identity/requirements/typedefs.cc:
Likewise.
* testsuite/21_strings/basic_string/hash/debug.cc: Likewise.
* testsuite/21_strings/basic_string/hash/hash.cc: Likewise.
* testsuite/21_strings/basic_string/literals/types-char8_t.cc:
Likewise.
* testsuite/21_strings/basic_string/literals/types.cc: Likewise.
* testsuite/21_strings/basic_string/literals/values-char8_t.cc:
Likewise.
* testsuite/21_strings/basic_string/literals/values.cc:
Likewise.
* testsuite/21_strings/basic_string/modifiers/64422.cc:
Likewise.
* testsuite/21_strings/basic_string/range_access/wchar_t/1.cc:
Likewise.
* testsuite/21_strings/basic_string/requirements/citerators.cc:
Likewise.
* testsuite/21_strings/basic_string/requirements/typedefs.cc:
Likewise.
* testsuite/21_strings/basic_string/types/pmr_typedefs.cc:
Likewise.
* testsuite/21_strings/basic_string_view/literals/types-char8_t.cc:
Likewise.
* testsuite/21_strings/basic_string_view/literals/types.cc:
Likewise.
* testsuite/21_strings/basic_string_view/literals/values-char8_t.cc:
Likewise.
* testsuite/21_strings/basic_string_view/literals/values.cc:
Likewise.
* testsuite/21_strings/basic_string_view/requirements/typedefs.cc:
Likewise.
* testsuite/21_strings/basic_string_view/typedefs.cc: Likewise.
* testsuite/21_strings/char_traits/requirements/constexpr_functions.cc:
Likewise.
* testsuite/21_strings/char_traits/requirements/constexpr_functions_c++17.cc:
Likewise.
* testsuite/21_strings/char_traits/requirements/constexpr_functions_c++20.cc:
Likewise.
* testsuite/22_locale/ctype/is/string/89728_neg.cc: Likewise.
* testsuite/25_algorithms/fill/4.cc: Likewise.
* testsuite/25_algorithms/fill_n/1.cc: Likewise.
* testsuite/experimental/functional/searchers.cc: Likewise. Use
char_traits<wchar_t>::length instead of wcslen.
* testsuite/experimental/polymorphic_allocator/pmr_typedefs_string.cc:
Likewise.
* testsuite/experimental/string_view/literals/types-char8_t.cc:
Likewise.
* testsuite/experimental/string_view/literals/types.cc:
Likewise.
* testsuite/experimental/string_view/literals/values-char8_t.cc:
Likewise.
* testsuite/experimental/string_view/literals/values.cc:
Likewise.
* testsuite/experimental/string_view/range_access/wchar_t/1.cc:
Likewise.
* testsuite/experimental/string_view/requirements/typedefs.cc:
Likewise.
* testsuite/experimental/string_view/typedefs.cc: Likewise.
* testsuite/ext/vstring/range_access.cc: Likewise.
* testsuite/std/concepts/concepts.lang/concept.arithmetic/integral.cc:
Likewise.
* testsuite/std/concepts/concepts.lang/concept.arithmetic/signed_integral.cc:
Likewise.
* testsuite/std/concepts/concepts.lang/concept.arithmetic/unsigned_integral.cc:
Likewise.
* testsuite/tr1/4_metaprogramming/is_arithmetic/value.cc:
Likewise.
* testsuite/tr1/4_metaprogramming/is_compound/value.cc:
Likewise.
* testsuite/tr1/4_metaprogramming/is_floating_point/value.cc:
Likewise.
* testsuite/tr1/4_metaprogramming/is_fundamental/value.cc:
Likewise.
* testsuite/tr1/4_metaprogramming/is_integral/value.cc:
Likewise.
* testsuite/tr1/4_metaprogramming/is_signed/value.cc: Likewise.
* testsuite/tr1/4_metaprogramming/is_unsigned/value.cc:
Likewise.
* testsuite/tr1/4_metaprogramming/is_void/value.cc: Likewise.
* testsuite/tr1/6_containers/hash/24799.cc: Likewise.

2 years agolibstdc++: Define deleted wchar_t overloads unconditionally [PR 98725]
Jonathan Wakely [Fri, 8 Oct 2021 13:26:09 +0000 (14:26 +0100)]
libstdc++: Define deleted wchar_t overloads unconditionally [PR 98725]

We don't need to have <wchar.h> support in order to delete overloads
for inserting wide characters into narrow streams.

libstdc++-v3/ChangeLog:

PR libstdc++/98725
* include/std/ostream (operator<<(basic_ostream<char, Tr>&, wchar_t))
(operator<<(basic_ostream<char, Tr>&, const wchar_t*)): Always
define as deleted. Do not check _GLIBCXX_USE_WCHAR_T.

2 years agolibstdc++: Define std::wstring_convert unconditionally [PR 98725]
Jonathan Wakely [Fri, 8 Oct 2021 13:25:42 +0000 (14:25 +0100)]
libstdc++: Define std::wstring_convert unconditionally [PR 98725]

The wchar_t type is defined unconditionally for C++, so there is no
reason for std::wstring_convert and std::wbuffer_convert to be disabled
when <wchar.h> is not usable. It should be possible to use those class
templates with char16_t and char32_t even if wchar_t conversions don't
work.

libstdc++-v3/ChangeLog:

PR libstdc++/98725
* include/bits/locale_conv.h (wstring_convert, wbuffer_convert):
Define unconditionally. Do not check _GLIBCXX_USE_WCHAR_T.

2 years agolibstdc++: Enable type traits for wchar_t unconditionally [PR98725]
Jonathan Wakely [Fri, 8 Oct 2021 13:52:07 +0000 (14:52 +0100)]
libstdc++: Enable type traits for wchar_t unconditionally [PR98725]

None of these traits depend on libc support for wchar_t, so they should
be defined unconditionally. The wchar_t type is always defined in C++.

libstdc++-v3/ChangeLog:

PR libstdc++/98725
* include/c_global/cstddef [!_GLIBCXX_USE_WCHAR_T]
(__byte_operand<wchar_t>): Define specialization.
* include/std/type_traits (__make_signed<wchar_t>)
(__make_unsigned<wchar_t>): Remove redundant check for
__WCHAR_TYPE__ being defined.
* include/tr1/type_traits [!_GLIBCXX_USE_WCHAR_T]
(__is_integral_helper<wchar_t>): Likewise.

2 years agolibstdc++: Enable vstring for wchar_t unconditionally [PR98725]
Jonathan Wakely [Fri, 8 Oct 2021 13:48:04 +0000 (14:48 +0100)]
libstdc++: Enable vstring for wchar_t unconditionally [PR98725]

None of these vstring specializations depend on libc support for
wchar_t, so can be enabled unconditionally now that char_traits<wchar_t>
is always available.

libstdc++-v3/ChangeLog:

PR libstdc++/98725
* include/ext/rc_string_base.h [!_GLIBCXX_USE_WCHAR_T]
(__rc_string_base<wchar_t>): Define member function.
* include/ext/vstring.h [!_GLIBCXX_USE_WCHAR_T]
(hash<__gnu_cxx::__wvstring>): Define specialization.
* include/ext/vstring_fwd.h [!_GLIBCXX_USE_WCHAR_T] (__wvstring)
(__wsso_string, __wrc_string): Declare typedefs.

2 years agolibstdc++: Always define typedefs and hash functions for wide strings [PR 98725]
Jonathan Wakely [Fri, 8 Oct 2021 13:24:18 +0000 (14:24 +0100)]
libstdc++: Always define typedefs and hash functions for wide strings [PR 98725]

The wstring and wstring_view typedefs should be enabled even if
<wchar.h> isn't supported, because char_traits<wchar_t> works
unconditionally. Similarly, the std::hash specializations for wide
strings do not depend on <wchar.h> support.

Although the primary template works OK for std::char_traits<wchar_t> in
the absence of <wchar.h> support, this patch still defines it as an
explicit specialization for compatibility with declarations that expect
it to be specialized. The explicit specialization just uses the same
__gnu_cxx::char_traits base class as the primary template.

libstdc++-v3/ChangeLog:

PR libstdc++/98725
* include/bits/char_traits.h (char_traits<wchar_t>): Define
explicit specialization unconditionally.
* include/bits/basic_string.h (hash<wstring>): Define
unconditionally. Do not check _GLIBCXX_USE_WCHAR_T.
* include/bits/stringfwd.h (wstring): Likewise.
* include/debug/string (wstring): Likewise.
* include/experimental/string_view (experimental::wstring_view)
(hash<experimental::wstring_view>): Likewise.
* include/std/string (pmr::wstring, hash<pmr::wstring>):
Likewise.
* include/std/string_view (wstring_view, hash<wstring_view>):
Likewise.

2 years agolibstdc++: Move test that depends on wchar_t I/O to wchar_t sub-directory
Jonathan Wakely [Fri, 8 Oct 2021 23:50:04 +0000 (00:50 +0100)]
libstdc++: Move test that depends on wchar_t I/O to wchar_t sub-directory

This fixes a FAIL when --disable-wchar_t is used.

libstdc++-v3/ChangeLog:

* testsuite/27_io/basic_filebuf/close/81256.cc: Moved to...
* testsuite/27_io/basic_filebuf/close/wchar_t/81256.cc: ...here.

2 years agolibstdc++: Add missing _GLIBCXX_USE_WCHAR_T checks in testsuite
Jonathan Wakely [Fri, 8 Oct 2021 20:04:26 +0000 (21:04 +0100)]
libstdc++: Add missing _GLIBCXX_USE_WCHAR_T checks in testsuite

These tests fail for a --disable-wchar_t build.

libstdc++-v3/ChangeLog:

* testsuite/22_locale/conversions/buffer/1.cc: Check
_GLIBCXX_USE_WCHAR_T.
* testsuite/22_locale/conversions/buffer/3.cc: Likewise. Add
test using char16_t.
* testsuite/22_locale/conversions/string/1.cc: Check
_GLIBCXX_USE_WCHAR_T.
* testsuite/27_io/filesystem/path/generic/generic_string.cc:
Likewise.
* testsuite/27_io/filesystem/path/modifiers/make_preferred.cc:
Likewise.
* testsuite/27_io/filesystem/path/native/alloc.cc: Likewise.
* testsuite/27_io/filesystem/path/native/string-char8_t.cc:
Likewise.
* testsuite/27_io/filesystem/path/native/string.cc: Likewise.
* testsuite/28_regex/algorithms/regex_match/extended/wstring_locale.cc:
Likewise.
* testsuite/experimental/filesystem/path/generic/generic_string.cc:
Likewise.
* testsuite/experimental/filesystem/path/native/alloc.cc:
Likewise.
* testsuite/experimental/filesystem/path/native/string-char8_t.cc:
Likewise.
* testsuite/experimental/filesystem/path/native/string.cc:
Likewise.

2 years agolibstdc++: Replace uses of _GLIBCXX_USE_INT128 in testsuite
Jonathan Wakely [Fri, 8 Oct 2021 19:41:24 +0000 (20:41 +0100)]
libstdc++: Replace uses of _GLIBCXX_USE_INT128 in testsuite

Since r12-435 the _GLIBCXX_USE_INT128 macro is never defined, so all
uses of it in the testsuite are wrong. The tests should be checking
__SIZEOF_INT128__ instead.

Also add some tests for an INT_3 type, which were missing.

libstdc++-v3/ChangeLog:

* testsuite/18_support/numeric_limits/40856.cc: Replace use of
_GLIBCXX_USE_INT128.
* testsuite/18_support/numeric_limits/dr559.cc: Likewise.
* testsuite/18_support/numeric_limits/lowest.cc: Likewise.
* testsuite/18_support/numeric_limits/max_digits10.cc: Likewise.
* testsuite/20_util/is_floating_point/value.cc: Likewise.
* testsuite/20_util/is_integral/value.cc: Likewise.
* testsuite/20_util/is_signed/value.cc: Likewise.
* testsuite/20_util/is_unsigned/value.cc: Likewise.
* testsuite/20_util/make_signed/requirements/typedefs-1.cc:
Likewise.
* testsuite/20_util/make_signed/requirements/typedefs-2.cc:
Likewise.
* testsuite/20_util/make_unsigned/requirements/typedefs-1.cc:
Likewise.
* testsuite/20_util/make_unsigned/requirements/typedefs-2.cc:
Likewise.
* testsuite/20_util/type_identity/requirements/typedefs.cc:
Likewise.
* testsuite/26_numerics/bit/bit.count/countl_one.cc: Likewise.
* testsuite/26_numerics/bit/bit.count/countl_zero.cc: Likewise.
* testsuite/26_numerics/bit/bit.count/countr_one.cc: Likewise.
* testsuite/26_numerics/bit/bit.count/countr_zero.cc: Likewise.
* testsuite/26_numerics/bit/bit.count/popcount.cc: Likewise.
* testsuite/26_numerics/bit/bit.pow.two/bit_ceil.cc: Likewise.
* testsuite/26_numerics/bit/bit.pow.two/bit_floor.cc: Likewise.
* testsuite/26_numerics/bit/bit.pow.two/bit_width.cc: Likewise.
* testsuite/26_numerics/bit/bit.pow.two/has_single_bit.cc:
Likewise.
* testsuite/26_numerics/bit/bit.rotate/rotl.cc: Likewise.

libstdc++-v3/ChangeLog:

* testsuite/26_numerics/bit/bit.rotate/rotr.cc:
* testsuite/util/testsuite_common_types.h:

2 years agolibstdc++: Access std::pair members without tuple-like helpers
Jonathan Wakely [Fri, 8 Oct 2021 12:41:19 +0000 (13:41 +0100)]
libstdc++: Access std::pair members without tuple-like helpers

This avoids the tuple-like API for std::pair in the unordered
containers, removing some overly generic code.

The _Select1st projection can figure out the member types of a std::pair
without using decltype(std::get<0>(...)).

We don't need _Select2nd because it's only needed in
_NodeBuilder::_S_build, and that can just access the .second member of
the pair directly. The return type of that function doesn't need to be
deduced by decltype, we can just expose the __node_type typedef of the
node generator.

libstdc++-v3/ChangeLog:

* include/bits/hashtable_policy.h (_Select1st): Replace use of
std::get.
(_Select2nd): Remove.
(_NodeBuilder::_S_build): Use _NodeGenerator::__node_type
typedef instead of deducing it. Remove unnecessary piecewise
construction.
(_ReuseOrAllocNode): Make __node_type public.
(_Map_base): Adjust partial specialization to be able to extract
the mapped_type without using tuple_element.
(_Map_base::at): Define inline
* testsuite/23_containers/unordered_map/requirements/53339.cc:
Remove XFAIL.
* testsuite/23_containers/unordered_multimap/requirements/53339.cc:
Likewise.

2 years agolibstdc++: Avoid instantiation of _Hash_node before it's needed
Jonathan Wakely [Fri, 8 Oct 2021 12:35:54 +0000 (13:35 +0100)]
libstdc++: Avoid instantiation of _Hash_node before it's needed

This is a step towards restoring support for incomplete types in
unordered containers (PR 53339).

We do not need to instantiate the node type to get its value_type
member, because we know that the value type is the first template
parameter. We can deduce that template argument using a custom trait and
a partial specialization for _Hash_node. If we wanted to support custom
hash node types we could still use typename _Tp::value_type in the
primary template of that trait, but that seems unnecessary.

The other change needed is to defer a static assert at class scope, so
that it is done when the types are complete. We must have a complete
type in the destructor, so we can do it there instead.

libstdc++-v3/ChangeLog:

* include/bits/hashtable.h: Move static assertion to destructor.
* include/bits/hashtable_policy.h: Deduce value type from node
type without instantiating it.

2 years agoFortran: Add diagnostic for F2018:C839 (TS29113:C535c)
Sandra Loosemore [Fri, 8 Oct 2021 21:29:12 +0000 (14:29 -0700)]
Fortran: Add diagnostic for F2018:C839 (TS29113:C535c)

2021-10-08 Sandra Loosemore  <sandra@codesourcery.com>

PR fortran/54753

gcc/fortran/
* interface.c (gfc_compare_actual_formal): Add diagnostic
for F2018:C839.  Refactor shared code and fix bugs with class
array info lookup, and extend similar diagnostic from PR94110
to also cover class types.

gcc/testsuite/
* gfortran.dg/c-interop/c535c-1.f90: Rewrite and expand.
* gfortran.dg/c-interop/c535c-2.f90: Remove xfails.
* gfortran.dg/c-interop/c535c-3.f90: Likewise.
* gfortran.dg/c-interop/c535c-4.f90: Likewise.
* gfortran.dg/PR94110.f90: Extend to cover class types.

2 years ago[PR102627] Use at least natural mode during splitting hard reg live range
Vladimir N. Makarov [Fri, 8 Oct 2021 14:16:09 +0000 (10:16 -0400)]
[PR102627] Use at least natural mode during splitting hard reg live range

In the PR test case SImode was used to split live range of cx on x86-64
because it was the biggest mode for this hard reg in the function.  But
all 64-bits of cx contain structure members.  We need always to use at least
natural mode of hard reg in splitting to fix this problem.

gcc/ChangeLog:

PR rtl-optimization/102627
* lra-constraints.c (split_reg): Use at least natural mode of hard reg.

gcc/testsuite/ChangeLog:

PR rtl-optimization/102627
* gcc.target/i386/pr102627.c: New test.

2 years agolibstdc++: Detect miscompilation of src/c++11/limits.cc
Jonathan Wakely [Fri, 8 Oct 2021 13:45:23 +0000 (14:45 +0100)]
libstdc++: Detect miscompilation of src/c++11/limits.cc

Add a #error directive to ensure that the definitions are not compiled
as C++17, which would prevent them being emitted.

libstdc++-v3/ChangeLog:

PR libstdc++/98725
* src/c++11/limits.cc: Fail if __cpp_inline_variables is
defined.

2 years agoGrow non_null_ref bitmap when num_ssa_names increases.
Aldy Hernandez [Fri, 8 Oct 2021 13:42:42 +0000 (15:42 +0200)]
Grow non_null_ref bitmap when num_ssa_names increases.

The strlen pass changes the IL as it works with the ranger.  This
causes the non_null_ref code to sometimes get asked questions about new
SSA names.

Tested on x86-64 Linux.

gcc/ChangeLog:

* gimple-range-cache.cc (non_null_ref::non_null_deref_p): Grow
bitmap if needed.

2 years agoImplement irange::debug()
Aldy Hernandez [Fri, 8 Oct 2021 13:42:01 +0000 (15:42 +0200)]
Implement irange::debug()

Tested on x86-64 Linux.

gcc/ChangeLog:

* value-range.cc (irange::debug): New.
* value-range.h (irange::debug): New.

2 years agolibstdc++: Reduce header dependencies of <algorithm> in C++20 [PR 92546]
Jonathan Wakely [Thu, 8 Apr 2021 09:01:08 +0000 (10:01 +0100)]
libstdc++: Reduce header dependencies of <algorithm> in C++20 [PR 92546]

The <bits/ranges_algobase.h> header doesn't need the stream and
streambuf iterators, so don't include the whole of <iterator>.

libstdc++-v3/ChangeLog:

PR libstdc++/92546
* include/bits/ranges_algobase.h: Replace <iterator> with a
subset of the headers it includes.

2 years agolibsanitizer: Add AM_CCASFLAGS to Makefile.am
H.J. Lu [Fri, 10 Sep 2021 13:13:59 +0000 (06:13 -0700)]
libsanitizer: Add AM_CCASFLAGS to Makefile.am

commit 9069eb28d45baaa8baf5e3790b03b0e2cc5b49b3
Author: Igor Tsimbalist <igor.v.tsimbalist@intel.com>
Date:   Fri Nov 17 22:34:50 2017 +0100

    Enable building libsanitizer with Intel CET

    libsanitizer/
            * acinclude.m4: Add enable.m4 and cet.m4.
            * Makefile.in: Regenerate.
            * asan/Makefile.am: Update AM_CXXFLAGS.
            * asan/Makefile.in: Regenerate.
            * configure: Likewise.
            * configure.ac: Set CET_FLAGS. Update EXTRA_CFLAGS,
            EXTRA_CXXFLAGS, EXTRA_ASFLAGS.
            * interception/Makefile.am: Update AM_CXXFLAGS.
            * interception/Makefile.in: Regenerate.
            * libbacktrace/Makefile.am: Update AM_CFLAGS, AM_CXXFLAGS.
            * libbacktrace/Makefile.in: Regenerate.
            * lsan/Makefile.am: Update AM_CXXFLAGS.
            * lsan/Makefile.in: Regenerate.
            * sanitizer_common/Makefile.am: Update AM_CXXFLAGS,
            AM_CCASFLAGS.
            * sanitizer_common/sanitizer_linux_x86_64.S: Include cet.h.
            Add _CET_ENDBR macro.
            * sanitizer_common/Makefile.in: Regenerate.
            * tsan/Makefile.am: Update AM_CXXFLAGS.
            * tsan/Makefile.in: Regenerate.
            * tsan/tsan_rtl_amd64.S Include cet.h. Add _CET_ENDBR macro.
            * ubsan/Makefile.am: Update AM_CXXFLAGS.
            * ubsan/Makefile.in: Regenerate.

failed to add EXTRA_ASFLAGS to AM_CCASFLAGS in all Makefile.am.  As
the result, CET aren't enabled in all assembly codes.

Add AM_CCASFLAGS to Makefile.am to compile assembly codes with $CET_FLAGS.

PR sanitizer/102632
* asan/Makefile.am (AM_CCASFLAGS): New.  Set to $(EXTRA_ASFLAGS).
* hwasan/Makefile.am (AM_CCASFLAGS): Likewise.
* interception/Makefile.am (AM_CCASFLAGS): Likewise.
* lsan/Makefile.am (AM_CCASFLAGS): Likewise.
* tsan/Makefile.am (AM_CCASFLAGS): Likewise.
* ubsan/Makefile.am (AM_CCASFLAGS): Likewise.
* asan/Makefile.in: Regenerate.
* hwasan/Makefile.in: Likewise.
* interception/Makefile.in: Likewise.
* lsan/Makefile.in: Likewise.
* tsan/Makefile.in: Likewise.
* ubsan/Makefile.in: Likewise.

2 years agoloop: Fix profile updates after unrolling [PR102385]
Richard Sandiford [Mon, 4 Oct 2021 22:55:43 +0000 (23:55 +0100)]
loop: Fix profile updates after unrolling [PR102385]

In g:62acc72a957b5614 I'd stopped the unroller from using
an epilogue loop in cases where the iteration count was
known to be a multiple of the unroll factor.  The epilogue
and non-epilogue cases still shared this (preexisting) code
to update the edge frequencies:

  basic_block exit_bb = single_pred (loop->latch);
  new_exit = find_edge (exit_bb, rest);
  new_exit->probability = profile_probability::always ()
                               .apply_scale (1, new_est_niter + 1);
  [etc]

But of course (in hindsight) that only makes sense for the
epilogue case, where we've already moved the main loop's exit edge
to be a sibling of the latch edge.  For the non-epilogue case,
the exit edge stays (and needs to stay) in its original position.

I don't really understand what the code is trying to do for
the epilogue case.  It has:

      /* Ensure that the frequencies in the loop match the new estimated
 number of iterations, and change the probability of the new
 exit edge.  */

      profile_count freq_h = loop->header->count;
      profile_count freq_e = (loop_preheader_edge (loop))->count ();
      if (freq_h.nonzero_p ())
{
          ...
  scale_loop_frequencies (loop, freq_e.probability_in (freq_h));
}

Here, freq_e.probability_in (freq_h) is freq_e / freq_h, so for the
header block, this has the effect of:

  new header count = freq_h * (freq_e / freq_h)

i.e. we say that the header executes exactly as often as the
preheader edge, which would only make sense if the loop never
iterates.  Also, after setting the probability of the nonexit edge
(correctly) to new_est_niter / (new_est_niter + 1), the code does:

    scale_bbs_frequencies (&loop->latch, 1, prob);

for this new probability.  I think that only makes sense if the
nonexit edge was previously unconditional (100%).  But the code
carefully preserved the probability of the original exit edge
when creating the new one.

All I'm trying to do here though is fix the mess I created
and get the probabilities right for the non-epilogue case.
Things are simpler there since we don't have to worry about
loop versioning.  Hopefully the comments explain the approach.

The function's current interface implies that it can cope with
multiple exit edges and that the function only needs the iteration
count relative to one of those edges in order to work correctly.
In practice that's not the case: it assumes there is exactly one
exit edge and all current callers also ensure that the exit test
dominates the latch.  I think the function is easier to follow
if we remove the implied generality.

gcc/
PR tree-optimization/102385
* predict.h (change_edge_frequency): Declare.
* predict.c (change_edge_frequency): New function.
* tree-ssa-loop-manip.h (tree_transform_and_unroll_loop): Remove
edge argument.
(tree_unroll_loop): Likewise.
* gimple-loop-jam.c (tree_loop_unroll_and_jam): Update accordingly.
* tree-predcom.c (pcom_worker::tree_predictive_commoning_loop):
Likewise.
* tree-ssa-loop-prefetch.c (loop_prefetch_arrays): Likewise.
* tree-ssa-loop-manip.c (tree_unroll_loop): Likewise.
(tree_transform_and_unroll_loop): Likewise.  Use single_dom_exit
to retrieve the exit edges.  Make all the old profile update code
conditional on !single_loop_p -- the case it was written for --
and use a different approach for the single-loop case.

gcc/testsuite/
* gcc.dg/pr102385.c: New test.

2 years agoopts: include missing header files.
Martin Liska [Fri, 8 Oct 2021 11:45:18 +0000 (13:45 +0200)]
opts: include missing header files.

gcc/objc/ChangeLog:

* objc-next-runtime-abi-01.c: Add missing include.
* objc-next-runtime-abi-02.c: Likewise.

2 years agoCome up with OPTION_SET_P macro.
Martin Liska [Fri, 8 Oct 2021 07:48:58 +0000 (09:48 +0200)]
Come up with OPTION_SET_P macro.

gcc/ada/ChangeLog:

* gcc-interface/misc.c (gnat_post_options): Use new macro
OPTION_SET_P.
(gnat_init_gcc_eh): Likewise.
(gnat_init_gcc_fp): Likewise.

gcc/c-family/ChangeLog:

* c-opts.c (c_common_post_options): Use new macro
OPTION_SET_P.

gcc/ChangeLog:

* config/alpha/alpha.c (alpha_option_override): Use new macro
OPTION_SET_P.
* config/arc/arc.c (arc_override_options): Likewise.
* config/arm/arm.c (arm_option_override): Likewise.
* config/bfin/bfin.c (bfin_load_pic_reg): Likewise.
* config/c6x/c6x.c (c6x_option_override): Likewise.
* config/csky/csky.c: Likewise.
* config/darwin.c (darwin_override_options): Likewise.
* config/frv/frv.c (frv_option_override): Likewise.
* config/i386/djgpp.h: Likewise.
* config/i386/i386.c (ix86_stack_protect_guard): Likewise.
(ix86_max_noce_ifcvt_seq_cost): Likewise.
* config/ia64/ia64.c (ia64_option_override): Likewise.
(ia64_override_options_after_change): Likewise.
* config/m32c/m32c.c (m32c_option_override): Likewise.
* config/m32r/m32r.c (m32r_init): Likewise.
* config/m68k/m68k.c (m68k_option_override): Likewise.
* config/microblaze/microblaze.c (microblaze_option_override): Likewise.
* config/mips/mips.c (mips_option_override): Likewise.
* config/nios2/nios2.c (nios2_option_override): Likewise.
* config/nvptx/nvptx.c (nvptx_option_override): Likewise.
* config/pa/pa.c (pa_option_override): Likewise.
* config/riscv/riscv.c (riscv_option_override): Likewise.
* config/rs6000/aix71.h: Likewise.
* config/rs6000/aix72.h: Likewise.
* config/rs6000/aix73.h: Likewise.
* config/rs6000/rs6000.c (darwin_rs6000_override_options): Likewise.
(rs6000_override_options_after_change): Likewise.
(rs6000_linux64_override_options): Likewise.
(glibc_supports_ieee_128bit): Likewise.
(rs6000_option_override_internal): Likewise.
(rs6000_file_start): Likewise.
(rs6000_darwin_file_start): Likewise.
* config/rs6000/rtems.h: Likewise.
* config/rs6000/sysv4.h: Likewise.
* config/rs6000/vxworks.h (SUB3TARGET_OVERRIDE_OPTIONS): Likewise.
* config/s390/s390.c (s390_option_override): Likewise.
* config/sh/linux.h: Likewise.
* config/sh/netbsd-elf.h (while): Likewise.
* config/sh/sh.c (sh_option_override): Likewise.
* config/sol2.c (solaris_override_options): Likewise.
* config/sparc/sparc.c (sparc_option_override): Likewise.
* config/tilegx/tilegx.c (tilegx_option_override): Likewise.
* config/visium/visium.c (visium_option_override): Likewise.
* config/vxworks.c (vxworks_override_options): Likewise.
* lto-opts.c (lto_write_options): Likewise.
* omp-expand.c (expand_omp_simd): Likewise.
* omp-general.c (omp_max_vf): Likewise.
* omp-offload.c (oacc_xform_loop): Likewise.
* opts.h (OPTION_SET_P): Likewise.
* targhooks.c (default_max_noce_ifcvt_seq_cost): Likewise.
* toplev.c (process_options): Likewise.
* tree-predcom.c: Likewise.
* tree-sra.c (analyze_all_variable_accesses): Likewise.

gcc/cp/ChangeLog:

* constexpr.c (maybe_warn_about_constant_value): Use new macro
OPTION_SET_P.
* decl.c (redeclaration_error_message): Likewise.
(cxx_init_decl_processing): Likewise.

gcc/d/ChangeLog:

* d-lang.cc (d_post_options): Use new macro
OPTION_SET_P.

gcc/fortran/ChangeLog:

* options.c (gfc_post_options): Use new macro
OPTION_SET_P.

gcc/objc/ChangeLog:

* objc-next-runtime-abi-01.c: Use new macro
OPTION_SET_P.
* objc-next-runtime-abi-02.c (objc_next_runtime_abi_02_init): Likewise.

2 years agolibstdc++: Restore debug checks in uniform container erasure functions
Jonathan Wakely [Thu, 7 Oct 2021 19:33:45 +0000 (20:33 +0100)]
libstdc++: Restore debug checks in uniform container erasure functions

This partially reverts commit 561078480ffb5adb68577276c6b23e4ee7b39272.

If we avoid all debug mode checks when erasing elements then we fail to
invalidate safe iterators to the removed elements. This reverts the
recent changes in r12-4083 and r12-4233, restoring the debug checking.

libstdc++-v3/ChangeLog:

* include/experimental/deque (erase, erase_if): Revert changes
to avoid debug mode overhead.
* include/experimental/map (erase, erase_if): Likewise.
* include/experimental/set (erase, erase_if): Likewise.
* include/experimental/unordered_map (erase, erase_if):
Likewise.
* include/experimental/unordered_set (erase, erase_if):
Likewise.
* include/experimental/vector (erase, erase_if): Likewise.
* include/std/deque (erase, erase_if): Likewise.
* include/std/map (erase, erase_if): Likewise.
* include/std/set (erase, erase_if): Likewise.
* include/std/unordered_map (erase, erase_if): Likewise.
* include/std/unordered_set (erase, erase_if): Likewise.
* include/std/vector (erase, erase_if): Likewise.

2 years agolibstdc++: Implement ostream insertion for chrono::duration
Jonathan Wakely [Thu, 7 Oct 2021 18:58:07 +0000 (19:58 +0100)]
libstdc++: Implement ostream insertion for chrono::duration

This is a missing piece of the C++20 <chrono> header.

It would be good to move the code into the compiled library, so that we
don't need <sstream> in <chrono>. It could also use spanstream in C++20,
to avoid memory allocations. That can be changed at a later date.

libstdc++-v3/ChangeLog:

* include/std/chrono (__detail::__units_suffix_misc): New
helper function.
(__detail::__units_suffix): Likewise.
(chrono::operator<<(basic_ostream&, const duration&)): Define.
* testsuite/20_util/duration/io.cc: New test.

2 years agoopenmp: Fix up declare target handling for vars with DECL_LOCAL_DECL_ALIAS [PR102640]
Jakub Jelinek [Fri, 8 Oct 2021 08:58:56 +0000 (10:58 +0200)]
openmp: Fix up declare target handling for vars with DECL_LOCAL_DECL_ALIAS [PR102640]

The introduction of DECL_LOCAL_DECL_ALIAS and push_local_extern_decl_alias
in r11-3699-g4e62aca0e0520e4ed2532f2d8153581190621c1a broke the following
testcase.  The following patch fixes it by treating similarly not just
the variable to or link clause is put on, but also its DECL_LOCAL_DECL_ALIAS
if any.  If it hasn't been created yet, when it is created it will copy
attributes and therefore should get it for free, and as it is an extern,
nothing more than attributes is needed for it.

2021-10-08  Jakub Jelinek  <jakub@redhat.com>

PR c++/102640
gcc/cp/
* parser.c (handle_omp_declare_target_clause): New function.
(cp_parser_omp_declare_target): Use it.
gcc/testsuite/
* c-c++-common/gomp/pr102640.c: New test.

2 years agoTweak new test cases for -march=cascadelake strangeness.
Roger Sayle [Fri, 8 Oct 2021 08:33:38 +0000 (09:33 +0100)]
Tweak new test cases for -march=cascadelake strangeness.

As reported by Sunil's tester, -march=cascadelake triggers some SUBREG
non-determinacy in the generated assembler for my new tests.  Fixed
by updating the regular expressions to match either the zero or sign
extended forms.  I'm testing a backend patch that may help with the
underlying cause of these differences.

2021-10-08  Roger Sayle  <roger@nextmovesoftware.com>

gcc/testsuite/ChangeLog
* gcc.target/i386/sse2-mmx-paddsb-2.c: Test for -128 or 128.
* gcc.target/i386/sse2-mmx-paddusb-2.c: Test for -1 or 255.
* gcc.target/i386/sse2-mmx-psubsb-2.c: Test for -128 or 128.

2 years agolibgcc: use .init_stack for constructors if available
Ian Lance Taylor [Fri, 8 Oct 2021 03:22:25 +0000 (20:22 -0700)]
libgcc: use .init_stack for constructors if available

* config/i386/morestack.S: Use .init_array for constructor if
available.
* config/rs6000/morestack.S: Likewise.
* config/s390/morestack.S: Likewise.

2 years agoSimplify (_Float16) ceil ((double) x) to .CEIL (x) when available.
liuhongt [Fri, 24 Sep 2021 11:17:42 +0000 (19:17 +0800)]
Simplify (_Float16) ceil ((double) x) to .CEIL (x) when available.

gcc/ChangeLog:

PR target/102464
* config/i386/i386.c (ix86_optab_supported_p):
Return true for HFmode.
* match.pd: Simplify (_Float16) ceil ((double) x) to
__builtin_ceilf16 (a) when a is _Float16 type and
direct_internal_fn_supported_p.

gcc/testsuite/ChangeLog:

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

2 years agoSupport reduc_{plus,smax,smin,umax,min}_scal_v4hi.
liuhongt [Tue, 28 Sep 2021 04:55:10 +0000 (12:55 +0800)]
Support reduc_{plus,smax,smin,umax,min}_scal_v4hi.

gcc/ChangeLog:

PR target/102494
* config/i386/i386-expand.c (emit_reduc_half): Hanlde V4HImode.
* config/i386/mmx.md (reduc_plus_scal_v4hi): New.
(reduc_<code>_scal_v4hi): New.

gcc/testsuite/ChangeLog:

* gcc.target/i386/mmx-reduce-op-1.c: New test.
* gcc.target/i386/mmx-reduce-op-2.c: New test.

2 years agoEnable auto-vectorization at O2 with very-cheap cost model.
liuhongt [Mon, 6 Sep 2021 05:48:49 +0000 (13:48 +0800)]
Enable auto-vectorization at O2 with very-cheap cost model.

gcc/ChangeLog:

* common.opt (ftree-vectorize): Add Var(flag_tree_vectorize).
* doc/invoke.texi (Options That Control Optimization): Update
documents.
* opts.c (default_options_table): Enable auto-vectorization at
O2 with very-cheap cost model.
(finish_options): Use cheap cost model for
explicit -ftree{,-loop}-vectorize.

gcc/testsuite/ChangeLog:

* c-c++-common/Wstringop-overflow-2.c: Adjust testcase.
* g++.dg/tree-ssa/pr81408.C: Ditto.
* g++.dg/warn/Wuninitialized-13.C: Ditto.
* gcc.dg/Warray-bounds-51.c: Ditto.
* gcc.dg/Warray-parameter-3.c: Ditto.
* gcc.dg/Wstringop-overflow-14.c: Ditto.
* gcc.dg/Wstringop-overflow-21.c: Ditto.
* gcc.dg/Wstringop-overflow-68.c: Ditto.
* gcc.dg/Wstringop-overflow-76.c: Ditto.
* gcc.dg/gomp/pr46032-2.c: Ditto.
* gcc.dg/gomp/pr46032-3.c: Ditto.
* gcc.dg/gomp/simd-2.c: Ditto.
* gcc.dg/gomp/simd-3.c: Ditto.
* gcc.dg/graphite/fuse-1.c: Ditto.
* gcc.dg/pr67089-6.c: Ditto.
* gcc.dg/pr82929-2.c: Ditto.
* gcc.dg/pr82929.c: Ditto.
* gcc.dg/store_merging_1.c: Ditto.
* gcc.dg/store_merging_11.c: Ditto.
* gcc.dg/store_merging_13.c: Ditto.
* gcc.dg/store_merging_15.c: Ditto.
* gcc.dg/store_merging_16.c: Ditto.
* gcc.dg/store_merging_19.c: Ditto.
* gcc.dg/store_merging_24.c: Ditto.
* gcc.dg/store_merging_25.c: Ditto.
* gcc.dg/store_merging_28.c: Ditto.
* gcc.dg/store_merging_30.c: Ditto.
* gcc.dg/store_merging_5.c: Ditto.
* gcc.dg/store_merging_7.c: Ditto.
* gcc.dg/store_merging_8.c: Ditto.
* gcc.dg/strlenopt-85.c: Ditto.
* gcc.dg/tree-ssa/dump-6.c: Ditto.
* gcc.dg/tree-ssa/pr19210-1.c: Ditto.
* gcc.dg/tree-ssa/pr47059.c: Ditto.
* gcc.dg/tree-ssa/pr86017.c: Ditto.
* gcc.dg/tree-ssa/pr91482.c: Ditto.
* gcc.dg/tree-ssa/predcom-1.c: Ditto.
* gcc.dg/tree-ssa/predcom-dse-3.c: Ditto.
* gcc.dg/tree-ssa/prefetch-3.c: Ditto.
* gcc.dg/tree-ssa/prefetch-6.c: Ditto.
* gcc.dg/tree-ssa/prefetch-8.c: Ditto.
* gcc.dg/tree-ssa/prefetch-9.c: Ditto.
* gcc.dg/tree-ssa/ssa-dse-18.c: Ditto.
* gcc.dg/tree-ssa/ssa-dse-19.c: Ditto.
* gcc.dg/uninit-40.c: Ditto.
* gcc.dg/unroll-7.c: Ditto.
* gcc.misc-tests/help.exp: Ditto.
* gcc.target/i386/avx512vpopcntdqvl-vpopcntd-1.c: Ditto.
* gcc.target/i386/pr34012.c: Ditto.
* gcc.target/i386/pr49781-1.c: Ditto.
* gcc.target/i386/pr95798-1.c: Ditto.
* gcc.target/i386/pr95798-2.c: Ditto.
* gfortran.dg/pr77498.f: Ditto.

2 years agoDaily bump.
GCC Administrator [Fri, 8 Oct 2021 00:16:28 +0000 (00:16 +0000)]
Daily bump.

2 years agoc++: NTTP with array/function type after substitution [PR61355]
Patrick Palka [Thu, 7 Oct 2021 20:39:16 +0000 (16:39 -0400)]
c++: NTTP with array/function type after substitution [PR61355]

We're performing the [temp.param]/10 adjustment at parse time but not
also at substitution time.

PR c++/61355

gcc/cp/ChangeLog:

* pt.c (convert_template_argument): Perform array/function to
pointer conversion on the substituted type of an NTTP.

gcc/testsuite/ChangeLog:

* g++.old-deja/g++.pt/nontype5.C: Adjust.
* g++.dg/template/param6.C: New test.

2 years agolibstdc++: Move C++14 <chrono> components to new <bits/chrono.h> header
Jonathan Wakely [Thu, 7 Oct 2021 13:51:18 +0000 (14:51 +0100)]
libstdc++: Move C++14 <chrono> components to new <bits/chrono.h> header

This moves the "classic" contents of <chrono> to a new header, so that
<future>, <thread> etc. can get use durations and clocks without
calendar types, time zones, and chrono I/O.

libstdc++-v3/ChangeLog:

* include/Makefile.am: Add new header.
* include/Makefile.in: Regenerate.
* include/std/chrono (duration, time_point, system_clock)
(steady_clock, high_resolution_clock, chrono_literals, sys_time)
(file_clock, file_time): Move to ...
* include/bits/chrono.h: New file.
* include/bits/atomic_futex.h: Include new header instead of
<chrono>.
* include/bits/atomic_timed_wait.h: Likewise.
* include/bits/fs_fwd.h: Likewise.
* include/bits/semaphore_base.h: Likewise.
* include/bits/this_thread_sleep.h: Likewise.
* include/bits/unique_lock.h: Likewise.
* include/experimental/bits/fs_fwd.h: Likewise.
* include/experimental/chrono: Likewise.
* include/experimental/io_context: Likewise.
* include/experimental/netfwd: Likewise.
* include/experimental/timer: Likewise.
* include/std/condition_variable: Likewise.
* include/std/mutex: Likewise.
* include/std/shared_mutex: Likewise.

2 years agoctfc: Free CTF container elements in ctfc_delete_container ()
Indu Bhagat [Thu, 7 Oct 2021 19:24:33 +0000 (12:24 -0700)]
ctfc: Free CTF container elements in ctfc_delete_container ()

Free up the memory held by hash tables containing CTF types and CTF variables
at the earliest.  This can be done in ctfc_delete_container () as CTF debug
informtion has already been emitted.

gcc/ChangeLog:

* ctfc.c (ctfc_delete_container): Free hash table contents.

2 years agoctf: Do not warn for CTF not supported for GNU GIMPLE
Indu Bhagat [Thu, 7 Oct 2021 19:09:14 +0000 (12:09 -0700)]
ctf: Do not warn for CTF not supported for GNU GIMPLE

CTF is supported for C only.  Currently, a warning is emitted if the -gctf
command line option is specified for a non-C frontend.  This warning is also
used by the GCC testsuite framework - it skips adding -gctf to the list of
debug flags for automated testing, if CTF is not supported for the frontend.

The following warning, however, is not useful in case of LTO:

"lto1: note: CTF debug info requested, but not supported for â€˜GNU GIMPLE’
frontend"

This patch disables the generation of the above warning for GNU GIMPLE.

gcc/ChangeLog:

* toplev.c (process_options): Do not warn for GNU GIMPLE.

2 years agolibstdc++: Avoid use of hardware interference non-constant [PR102377]
Jonathan Wakely [Thu, 7 Oct 2021 17:28:04 +0000 (18:28 +0100)]
libstdc++: Avoid use of hardware interference non-constant [PR102377]

libstdc++-v3/ChangeLog:

PR libstdc++/102377
* include/bits/atomic_wait.h (__waiter_pool_base:_S_align):
Hardcode to 64 instead of using non-constant constant.

2 years agolibstdc++: Avoid debug checks in uniform container erasure functions
Jonathan Wakely [Thu, 7 Oct 2021 13:40:26 +0000 (14:40 +0100)]
libstdc++: Avoid debug checks in uniform container erasure functions

In commit r12-4083 I tried to make the std::erase and std::erase_if
function avoid the unnecessary overhead of safe iterators. It didn't
work, for two reasons. Firstly, for the RB tree containers the
__niter_base function is a no-op (because the iterators aren't
random access) so the safe iterators were still used. Secondly, for the
cases where __niter_base did remove the safe iterator layer, there was
still unnecessary overhead to create a new safe iterator and link it to
the container.

This solves the problem by simply binding a reference to the non-debug
version of the conainer. For normal mode this is a no-op, and for debug
mode it binds a reference to the debug container's base class. That
means the rest of the function operates directly on the non-debug
container, and avoids all checking.

For std::basic_string there's no need to unwrap anything, because we use
std::basic_string directly in debug mode anyway.

libstdc++-v3/ChangeLog:

* include/bits/erase_if.h (__erase_nodes_if): Remove redundant
__niter_base calls.
* include/std/string (erase, erase_if): Likewise.
* include/std/deque (erase, erase_if): Access non-debug
container directly.
* include/std/map (erase, erase_if): Likewise.
* include/std/set (erase, erase_if): Likewise.
* include/std/unordered_map (erase, erase_if): Likewise.
* include/std/unordered_set (erase, erase_if): Likewise.
* include/std/vector (erase, erase_if): Likewise.
* include/experimental/deque (erase, erase_if): Likewise.
* include/experimental/map (erase, erase_if): Likewise.
* include/experimental/set (erase, erase_if): Likewise.
* include/experimental/unordered_map (erase, erase_if):
Likewise.
* include/experimental/unordered_set (erase, erase_if):
Likewise.
* include/experimental/vector (erase, erase_if): Likewise.

2 years agotree-object-size: Drop unused pdecl and poff arguments
Siddhesh Poyarekar [Thu, 7 Oct 2021 14:14:00 +0000 (19:44 +0530)]
tree-object-size: Drop unused pdecl and poff arguments

The pdecl and poff arguments were added to allow their use in
compute_objsize in builtins.c.  That use has been gone for a while now
since compute_objsize does its own size estimation, so drop these
arguments to simplify code.

gcc/ChangeLog:

* tree-object-size.c (addr_object_size,
compute_builtin_object_size): Drop PDECL and POFF arguments.
(addr_object_size): Adjust calls.
* tree-object-size.h (compute_builtin_object_size): Drop PDECL
and POFF arguments.

Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
2 years agoIntroduce smul_highpart and umul_highpart RTX for high-part multiplications
Roger Sayle [Thu, 7 Oct 2021 14:42:09 +0000 (15:42 +0100)]
Introduce smul_highpart and umul_highpart RTX for high-part multiplications

This patch introduces new RTX codes to allow the RTL passes and
backends to consistently represent high-part multiplications.
Currently, the RTL used by different backends for expanding
smul<mode>3_highpart and umul<mode>3_highpart varies greatly,
with many but not all choosing to express this something like:

(define_insn "smuldi3_highpart"
  [(set (match_operand:DI 0 "nvptx_register_operand" "=R")
       (truncate:DI
        (lshiftrt:TI
         (mult:TI (sign_extend:TI
                   (match_operand:DI 1 "nvptx_register_operand" "R"))
                  (sign_extend:TI
                   (match_operand:DI 2 "nvptx_register_operand" "R")))
         (const_int 64))))]
  ""
  "%.\\tmul.hi.s64\\t%0, %1, %2;")

One complication with using this "widening multiplication" representation
is that it requires an intermediate in a wider mode, making it difficult
or impossible to encode a high-part multiplication of the widest supported
integer mode.  A second is that it can interfere with optimization; for
example simplify-rtx.c contains the comment:

   case TRUNCATE:
      /* Don't optimize (lshiftrt (mult ...)) as it would interfere
         with the umulXi3_highpart patterns.  */

Hopefully these problems are solved (or reduced) by introducing a
new canonical form for high-part multiplications in RTL passes.
This also simplifies insn patterns when one operand is constant.

Whilst implementing some constant folding simplifications and
compile-time evaluation of these new RTX codes, I noticed that
this functionality could also be added for the existing saturating
arithmetic RTX codes.  Then likewise when documenting these new RTX
codes, I also took the opportunity to silence the @xref warnings in
invoke.texi.

2021-10-07  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* rtl.def (SMUL_HIGHPART, UMUL_HIGHPART): New RTX codes for
representing signed and unsigned high-part multiplication resp.
* simplify-rtx.c (simplify_binary_operation_1) [SMUL_HIGHPART,
UMUL_HIGHPART]: Simplify high-part multiplications by zero.
[SS_PLUS, US_PLUS, SS_MINUS, US_MINUS, SS_MULT, US_MULT,
SS_DIV, US_DIV]: Similar simplifications for saturating
arithmetic.
(simplify_const_binary_operation) [SS_PLUS, US_PLUS, SS_MINUS,
US_MINUS, SS_MULT, US_MULT, SMUL_HIGHPART, UMUL_HIGHPART]:
Implement compile-time evaluation for constant operands.

* dwarf2out.c (mem_loc_descriptor): Skip SMUL_HIGHPART and
UMUL_HIGHPART.
* doc/rtl.texi (smul_highpart, umul_highpart): Document RTX codes.
* doc/md.texi (smul@var{m}3_highpart, umul@var{m3}_highpart):
Mention the new smul_highpart and umul_highpart RTX codes.
* doc/invoke.texi: Silence @xref "compilation" warnings.

gcc/testsuite/ChangeLog
* gcc.target/i386/sse2-mmx-paddsb-2.c: New test case.
* gcc.target/i386/sse2-mmx-paddusb-2.c: New test case.
* gcc.target/i386/sse2-mmx-psubsb-2.c: New test case.
* gcc.target/i386/sse2-mmx-psubusb-2.c: New test case.

2 years agoipa: Fix ICE when speculating calls from inlined functions (PR 102388)
Martin Jambor [Thu, 7 Oct 2021 14:21:19 +0000 (16:21 +0200)]
ipa: Fix ICE when speculating calls from inlined functions (PR 102388)

The code handling various cases which lead to call graph edge
duplication (in order to update reference descriptions used to track
and remove no-longer needed references) has missed one important case.

When edge duplication is an effect of creating a speculative edge for
an indirect edge which carries a constant jump function which had been
created from a pass-through function when the edge caller has was
inlined into one of its callers, the reference description attached to
the function describes an edge higher up in the "inlined" clone tree
and so even the new speculative edge will.  Therefore we should not
try to duplicate the reference description itself but rather just bump
the refcount of the existing one.

gcc/ChangeLog:

2021-09-22  Martin Jambor  <mjambor@suse.cz>

PR ipa/102388
* ipa-prop.c (ipa_edge_args_sum_t::duplicate): Also handle the
case when the source reference description corresponds to a
referance taken in a function src->caller is inlined to.

2 years agoc++: variadic ttp constraint subsumption [PR99904]
Patrick Palka [Thu, 7 Oct 2021 14:02:54 +0000 (10:02 -0400)]
c++: variadic ttp constraint subsumption [PR99904]

Here we're crashing when level-lowering the variadic constraint C<Ts...>
on the template template parameter TT because tsubst_pack_expansion expects
processing_template_decl to be set during a partial substitution.

PR c++/99904

gcc/cp/ChangeLog:

* pt.c (is_compatible_template_arg): Set processing_template_decl
around tsubst_constraint_info.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-ttp4.C: New test.

2 years agoc++: Do not warn about lifetime of std::initializer_list<T>& [PR102482]
Jonathan Wakely [Wed, 29 Sep 2021 20:19:49 +0000 (21:19 +0100)]
c++: Do not warn about lifetime of std::initializer_list<T>& [PR102482]

An initializer-list constructor taking a non-const lvalue cannot be
called with a temporary, so the array's lifetime probably doesn't end
with the full expression. -Winit-list-lifetime should not warn for that
case.

PR c++/102482

gcc/cp/ChangeLog:

* init.c (maybe_warn_list_ctor): Do not warn for a reference to
a non-const std::initializer_list.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Winit-list5.C: New test.

2 years agoFix access node merging
Jan Hubicka [Thu, 7 Oct 2021 13:26:01 +0000 (15:26 +0200)]
Fix access node merging

gcc/ChangeLog:

2021-10-07  Jan Hubicka  <hubicka@ucw.cz>

PR ipa/102581
* ipa-modref-tree.h (modref_access_node::contains_p): Handle offsets
better.
(modref_access_node::try_merge_with): Add sanity check that there
are no redundant entries in the list.

gcc/testsuite/ChangeLog:

2021-10-07  Jan Hubicka  <hubicka@ucw.cz>

* g++.dg/torture/pr102581.C: New test.

2 years agoc++: Add testcase for C++23 P2316R2 - consistent character literal encoding [PR102615]
Jakub Jelinek [Thu, 7 Oct 2021 13:16:13 +0000 (15:16 +0200)]
c++: Add testcase for C++23 P2316R2 - consistent character literal encoding [PR102615]

I believe we need no changes to the compiler for P2316R2, seems we treat
character literals the same between preprocessor and C++ expressions,
here is a testcase that should verify it.

Note, seems the internal charset for GCC can be either UTF-8 or UTF-EBCDIC,
but I bet it is very hard (at least for me) to actually test the latter.
I'd guess one needs all system headers to be in EBCDIC and the gcc sources too.
But looking around the source, I'm a little bit worried about the UTF-EBCDIC
case.
One is:
 #if  '\n' == 0x0A && ' ' == 0x20 && '0' == 0x30 \
    && 'A' == 0x41 && 'a' == 0x61 && '!' == 0x21
 #  define HOST_CHARSET HOST_CHARSET_ASCII
 #else
 # if '\n' == 0x15 && ' ' == 0x40 && '0' == 0xF0 \
    && 'A' == 0xC1 && 'a' == 0x81 && '!' == 0x5A
 #  define HOST_CHARSET HOST_CHARSET_EBCDIC
 # else
 #  define HOST_CHARSET HOST_CHARSET_UNKNOWN
 # endif
 #endif
in include/safe-ctype.h, does that mean we only support EBCDIC if -funsigned-char
and otherwise fail to build gcc?  Because with -fsigned-char, '0' is -0x10
rather than 0xF0, 'A' is -0x3F rather than 0xC1 and 'a' is -0x7F rather than
0x81.
And another thing, if HOST_CHARSET == HOST_CHARSET_EBCDIC, how does the libcpp/lex.c
static const cppchar_t utf8_signifier = 0xC0;
...
      if (*buffer->cur >= utf8_signifier)
        {
          if (_cpp_valid_utf8 (pfile, &buffer->cur, buffer->rlimit, 1 + !first,
                               state, &s))
            return true;
        }
work?  Because in UTF-EBCDIC, >= 0xC0 isn't the right test for start of
multi-byte character, it is more complicated and seems _cpp_valid_utf8
assumes UTF-8 as the host charset.

2021-10-07  Jakub Jelinek  <jakub@redhat.com>

PR c++/102615
* g++.dg/cpp23/charlit-encoding1.C: New testcase for C++23 P2316R2.

2 years agotree-optimization/102608 - avoid CSEing .DEFERRED_INIT
Richard Biener [Thu, 7 Oct 2021 12:24:03 +0000 (14:24 +0200)]
tree-optimization/102608 - avoid CSEing .DEFERRED_INIT

This makes VN not CSE .DEFERRED_INIT which confuses uninit
analysis which reports the wrong decl when facing copies
of not initialized data.

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

PR tree-optimization/102608
* tree-ssa-sccvn.c (visit_stmt): Drop .DEFERRED_INIT to
varying.

2 years agoMAINTAINERS: Add myself to DCO section
Siddhesh Poyarekar [Thu, 7 Oct 2021 12:19:00 +0000 (17:49 +0530)]
MAINTAINERS: Add myself to DCO section

Also updated my email address to the one I actually use for gcc, which
unfortunately is not the same as the one I use for glibc.  Oh well...

ChangeLog:

* MAINTAINERS: Add myself to DCO section and update email
address.

2 years agobuild: Fix --enable-gather-detailed-mem-stats
Martin Liska [Thu, 7 Oct 2021 10:29:15 +0000 (12:29 +0200)]
build: Fix --enable-gather-detailed-mem-stats

gcc/c-family/ChangeLog:

* c-common.c (parse_optimize_options): Make
save_opt_decoded_options a pointer type.

gcc/ChangeLog:

* toplev.c (toplev::main): Make
save_opt_decoded_options a pointer type
* toplev.h: Likewise.

2 years agoamdgcn: Fix assembler version incompatibility
Andrew Stubbs [Thu, 30 Sep 2021 16:50:33 +0000 (17:50 +0100)]
amdgcn: Fix assembler version incompatibility

This is another case of the global_load instruction format changing in LLVM
(because they fixed a bug).  The configure test is already in place to detect
what is needed.

gcc/ChangeLog:

* config/gcn/gcn-valu.md (gather<mode>_insn_2offsets<exec>): Apply
HAVE_GCN_ASM_GLOBAL_LOAD_FIXED.
(scatter<mode>_insn_2offsets<exec_scatter>): Likewise.

2 years agoamdgcn: Implement -msram-ecc=any
Andrew Stubbs [Tue, 28 Sep 2021 15:26:09 +0000 (16:26 +0100)]
amdgcn: Implement -msram-ecc=any

The option was already there, but just an alias for -msram-ecc=on.  Now that
LLVM13 supports HSACOv4 and the new ELF flags I can implement the option
properly.

The "any" option is the default in order to ensure that library files work
whichever way the user wants, which means we won't need multilibs to support
the different SRAM ECC hardware configurations.

gcc/ChangeLog:

* config/gcn/gcn-hsa.h (SRAMOPT): Include the whole option string.
Adjust for new -msram-ecc=any behaviour.
(ASM_SPEC): Adjust -mxnack and -msram-ecc usage.
* config/gcn/gcn.c (output_file_start): Implement -msram-ecc=any.
* config/gcn/mkoffload.c (EF_AMDGPU_XNACK): Rename to ...
(EF_AMDGPU_XNACK_V3): ... this.
(EF_AMDGPU_SRAM_ECC): Rename to ...
(EF_AMDGPU_SRAM_ECC_V3): ... this.
(EF_AMDGPU_FEATURE_XNACK_V4): New.
(EF_AMDGPU_FEATURE_XNACK_UNSUPPORTED_V4): New.
(EF_AMDGPU_FEATURE_XNACK_ANY_V4): New.
(EF_AMDGPU_FEATURE_XNACK_OFF_V4): New.
(EF_AMDGPU_FEATURE_XNACK_ON_V4): New.
(EF_AMDGPU_FEATURE_SRAMECC_V4): New.
(EF_AMDGPU_FEATURE_SRAMECC_UNSUPPORTED_V4): New.
(EF_AMDGPU_FEATURE_SRAMECC_ANY_V4): New.
(EF_AMDGPU_FEATURE_SRAMECC_OFF_V4): New.
(EF_AMDGPU_FEATURE_SRAMECC_ON_V4): New.
(SET_XNACK_ON): New.
(SET_XNACK_OFF): New.
(TEST_XNACK): New.
(SET_SRAM_ECC_ON): New.
(SET_SRAM_ECC_ANY): New.
(SET_SRAM_ECC_OFF): New.
(TEST_SRAM_ECC_ANY): New.
(TEST_SRAM_ECC_ON): New.
(main): Implement HSACOv4 and -msram-ecc=any.

2 years agoamdgcn: Support LLVM 13 assembler syntax
Andrew Stubbs [Fri, 24 Sep 2021 10:37:37 +0000 (11:37 +0100)]
amdgcn: Support LLVM 13 assembler syntax

The LLVM devs have changed the assembler architecture attribute names on both
CLI and in the ".amdgcn_target" directive, and changed the attribute syntax
inside the directive, without keeping any backwards compatibility. :-(

This patch improves our configure tests to detect what dialect to use, what
attributes are valid, and adjusts the specs to match.

gcc/ChangeLog:

* config.in: Regenerate.
* config/gcn/gcn-hsa.h (X_FIJI): New macro.
(X_900): New macro.
(X_906): New macro.
(X_908): New macro.
(A_FIJI): Rename to ...
(S_FIJI): ... this.
(A_900): Rename to ...
(S_900): ... this.
(A_906): Rename to ...
(S_906): ... this.
(A_908): Rename to ...
(S_908): ... this.
(SRAMOPT): New macro.
(ASM_SPEC): Adjust xnack option usage.
* config/gcn/gcn.c (output_file_start): Adjust amdgcn_target usage.
* configure: Regenerate.
* configure.ac: Detect LLVM assembler dialect.

2 years agoProperly parse invariant &MEM addresses in the GIMPLE FE
Richard Biener [Wed, 6 Oct 2021 09:02:38 +0000 (11:02 +0200)]
Properly parse invariant &MEM addresses in the GIMPLE FE

Currently the frontend rejects those addresses as not lvalues
because the C frontend doens't expect MEM_REF or TARGET_MEM_REF
to appear (but they would be valid lvalues there).  The following
fixes that by amending lvalue_p.

The change also makes the dumping of the source of the testcase
valid for the GIMPLE FE by not eliding the '&' when dumping
string literals.

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

gcc/c/
* c-typeck.c (lvalue_p): Also allow MEM_REF and TARGET_MEM_REF.

gcc/
* tree-pretty-print.c (dump_generic_node): Do not elide
printing '&' when dumping with -gimple.

gcc/testsuite/
* gcc.dg/gimplefe-47.c: New testcase.

2 years agoDaily bump.
GCC Administrator [Thu, 7 Oct 2021 00:16:24 +0000 (00:16 +0000)]
Daily bump.

2 years agoc++: One more spaceship test.
Jason Merrill [Wed, 6 Oct 2021 21:12:02 +0000 (17:12 -0400)]
c++: One more spaceship test.

Jakub suggested adding a variant where we actually try to call the
implicitly deleted operator.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/spaceship-synth8a.C: New test.

2 years agolibsanitizer: Update LOCAL_PATCHES
H.J. Lu [Wed, 6 Oct 2021 20:11:34 +0000 (13:11 -0700)]
libsanitizer: Update LOCAL_PATCHES

* LOCAL_PATCHES: Update to the corresponding revision.

2 years agolibsanitizer: Apply local patches
H.J. Lu [Tue, 20 Jul 2021 17:46:51 +0000 (10:46 -0700)]
libsanitizer: Apply local patches

2 years agolibsanitizer: Merge with upstream
H.J. Lu [Wed, 6 Oct 2021 17:24:24 +0000 (10:24 -0700)]
libsanitizer: Merge with upstream

Merged revision: fdf4c035225de52f596899931b1f6100e5e3e928

2 years agolibstdc++: Implement std::move_only_function for C++23 (P0288R9)
Jonathan Wakely [Wed, 6 Oct 2021 12:28:57 +0000 (13:28 +0100)]
libstdc++: Implement std::move_only_function for C++23 (P0288R9)

libstdc++-v3/ChangeLog:

* include/Makefile.am: Add new headers.
* include/Makefile.in: Regenerate.
* include/std/functional: Include <bits/move_only_function.h>.
* include/std/version (__cpp_lib_move_only_function): Define.
* include/bits/mofunc_impl.h: New file.
* include/bits/move_only_function.h: New file.
* testsuite/20_util/move_only_function/call.cc: New test.
* testsuite/20_util/move_only_function/cons.cc: New test.
* testsuite/20_util/move_only_function/move.cc: New test.
* testsuite/20_util/move_only_function/version.cc: New test.

2 years agoAdd range intersect with 2 wide-ints.
Andrew MacLeod [Mon, 4 Oct 2021 19:30:44 +0000 (15:30 -0400)]
Add range intersect with 2 wide-ints.

Add a more efficent intersect using a lower/upper bound single pair of
wide_ints.

* gimple-range-cache.cc (non_null_ref::adjust_range): Call new
intersect routine.
* gimple-range-fold.cc (adjust_pointer_diff_expr): Ditto.
(adjust_imagpart_expr): Ditto.
* value-range.cc (irange::irange_intersect): Call new routine if
RHS is a single pair.
(irange::intersect): New wide_int version.
* value-range.h (class irange): New prototype.

2 years agoIntroduce a param-switch-limit for EVRP.
Andrew MacLeod [Wed, 29 Sep 2021 21:25:50 +0000 (17:25 -0400)]
Introduce a param-switch-limit for EVRP.

Very large switches cause a lot of range calculations with multiple subranges
to happen.  This can cause quadratic or even exponetial time increases in
large testcases.  This patch introduces a param variable to limit
the size of switches EVRP will process.

* gimple-range-edge.cc (gimple_outgoing_range::gimple_outgoing_range):
Add parameter to limit size when recognizing switches.
(gimple_outgoing_range::edge_range_p): Check size limit.
* gimple-range-edge.h (gimple_outgoing_range): Add size field.
* gimple-range-gori.cc (gori_map::calculate_gori): Ignore switches
that exceed the size limit.
(gori_compute::gori_compute): Add initializer.
* params.opt (evrp-switch-limit): New.
* doc/invoke.texi: Update docs.

2 years agoUse TYPE_MIN/MAX_VALUE in set_varying when possible.
Andrew MacLeod [Tue, 28 Sep 2021 17:11:22 +0000 (13:11 -0400)]
Use TYPE_MIN/MAX_VALUE in set_varying when possible.

We currently create new trees every time... which is very wasteful and time
consuming. Instead, just use the TYPE_MIN/MAX_VALUE.

* value-range.h (irange::set_varying): Use TYPE_MIN_VALUE and
TYPE_MAX_VALUE instead of creating new trees when possible.

2 years agoRanger: More efficient zero/nonzero check.
Andrew MacLeod [Mon, 27 Sep 2021 22:53:54 +0000 (18:53 -0400)]
Ranger: More efficient zero/nonzero check.

A recent change introduced a frequent check for zero and non-zero which has
caused a lot of extra temporary trees to be created.  Make the check more
efficent as it is always a pointer and thus unsigned.

* gimple-range-cache.cc (non_null_ref::adjust_range): Check for
zero and non-zero more efficently.

2 years agoMore consistently dump GIMPLE FE consumable stmts
Richard Biener [Tue, 5 Oct 2021 12:49:42 +0000 (14:49 +0200)]
More consistently dump GIMPLE FE consumable stmts

The following makes more stmts consumable with the GIMPLE FE
when dumping with -gimple.  In particular addresses in GIMPLE
operand position require wrapping with _Literal.

The TDF_ flag space is now exhausted and I've removed overlaps
and re-ordered things as to how it is supposed to work and
made it uint32_t and prepared the operator overloads for an
easy migration to uint64_t once required.

2021-10-05  Richard Biener  <rguenther@suse.de>

PR c/102605
* dumpfile.h (TDF_GIMPLE_VAL): New.
(dump_flag): Re-order and adjust TDF_* flags.  Make
the enum uint32_t.  Use std::underlying_type in the
operator overloads.
(optgroup_flag): Likewise for the operator overloads.
* tree-pretty-print.c (dump_generic_node): Wrap ADDR_EXPR
in _Literal if TDF_GIMPLE_VAL.
* gimple-pretty-print.c (dump_gimple_assign): Add
TDF_GIMPLE_VAL to flags when dumping operands where only
is_gimple_val are allowed.
(dump_gimple_cond): Likewise.

2 years agoopenmp: Optimize for OpenMP atomics 2x__builtin_clear_padding+__builtin_memcmp if...
Jakub Jelinek [Wed, 6 Oct 2021 08:40:12 +0000 (10:40 +0200)]
openmp: Optimize for OpenMP atomics 2x__builtin_clear_padding+__builtin_memcmp if possible

For the few long double types that do have padding bits, e.g. on x86
the clear_type_padding_in_mask computed mask is
ff ff ff ff ff ff ff ff ff ff 00 00 for 32-bit and
ff ff ff ff ff ff ff ff ff ff 00 00 00 00 00 00 for 64-bit.
Instead of doing __builtin_clear_padding on both operands that will clear the
last 2 or 6 bytes and then memcmp on the whole 12/16 bytes, we can just
memcmp 10 bytes.  The code also handles if the padding would be at the start
or both at the start and end, but everything on byte boundaries only and
non-padding bits being contiguous.
This works around a tree-ssa-dse.c bug (but we need to fix it anyway,
as libstdc++ won't do this and as it can deal with arbitrary types, it even
can't do that generally).

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

PR tree-optimization/102571
* c-omp.c (c_finish_omp_atomic): Optimize the case where type has
padding, but the non-padding bits are contiguous set of bytes
by adjusting the memcmp call arguments instead of emitting
__builtin_clear_padding and then comparing all the type's bytes.

2 years agoc++: Implement C++23 P2242R3 - Non-literal variables (and labels and gotos) in conste...
Jakub Jelinek [Wed, 6 Oct 2021 08:28:31 +0000 (10:28 +0200)]
c++: Implement C++23 P2242R3 - Non-literal variables (and labels and gotos) in constexpr functions [PR102612]

The following patch implements C++23 P2242R3 - Non-literal variables
(and labels and gotos) in constexpr functions.
I think it is mostly straightforward, don't diagnose certain
statements/declarations just because of their presence in
constexpr/consteval functions, but (except for the non-literal type
var declarations which ought to be caught by e.g. constructor or
destructor call during evaluation not being constexpr and for
labels which are now always allowed) diagnose it during constexpr
evaluation.

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

PR c++/102612
gcc/c-family/
* c-cppbuiltin.c (c_cpp_builtins): For -std=c++23 predefine
__cpp_constexpr to 202110L rather than 201907L.
gcc/cp/
* parser.c (cp_parser_jump_statement): Implement C++23 P2242R3.
Allow goto expressions in constexpr function bodies for C++23.
Adjust error message for older standards to mention it.
* decl.c (start_decl): Allow static and thread_local declarations
in constexpr function bodies for C++23.  Adjust error message for
older standards to mention it.
* constexpr.c (ensure_literal_type_for_constexpr_object): Allow
declarations of variables with non-literal type in constexpr function
bodies for C++23.  Adjust error message for older standards to mention
it.
(cxx_eval_constant_expression) <case DECL_EXPR>: Diagnose declarations
of initialization of static or thread_local vars.
(cxx_eval_constant_expression) <case GOTO_EXPR>: Diagnose goto
statements for C++23.
(potential_constant_expression_1) <case DECL_EXPR>: Swap the
CP_DECL_THREAD_LOCAL_P and TREE_STATIC checks.
(potential_constant_expression_1) <case LABEL_EXPR>: Allow labels for
C++23.  Adjust error message for older standards to mention it.
gcc/testsuite/
* g++.dg/cpp23/feat-cxx2b.C: Expect __cpp_constexpr 202110L rather
than 201907L.
* g++.dg/cpp23/constexpr-nonlit1.C: New test.
* g++.dg/cpp23/constexpr-nonlit2.C: New test.
* g++.dg/cpp23/constexpr-nonlit3.C: New test.
* g++.dg/cpp23/constexpr-nonlit4.C: New test.
* g++.dg/cpp23/constexpr-nonlit5.C: New test.
* g++.dg/cpp23/constexpr-nonlit6.C: New test.
* g++.dg/diagnostic/constexpr1.C: Only expect some diagnostics for
c++20_down.
* g++.dg/cpp1y/constexpr-label.C: Likewise.
* g++.dg/cpp1y/constexpr-neg1.C: Likewise.
* g++.dg/cpp2a/constexpr-try5.C: Likewise.  Adjust some expected
wording.
* g++.dg/cpp2a/constexpr-dtor3.C: Likewise.
* g++.dg/cpp2a/consteval3.C: Likewise.  Add effective target c++20
and remove dg-options.

2 years agolibcpp: Implement C++23 P2334R1 - #elifdef/#elifndef
Jakub Jelinek [Wed, 6 Oct 2021 08:13:51 +0000 (10:13 +0200)]
libcpp: Implement C++23 P2334R1 - #elifdef/#elifndef

This patch implements C++23 P2334R1, which is easy because Joseph has done
all the hard work for C2X already.
Unlike the C N2645 paper, the C++ P2334R1 contains one important addition
(but not in the normative text):
"While this is a new preprocessor feature and cannot be treated as a defect
report, implementations that support older versions of the standard are
encouraged to implement this feature in the older language modes as well
as C++23."
so there are different variants how to implement it.
One is ignoring that sentence and only implementing it
for -std=c++23/-std=gnu++23 like it is only implemented for -std=c2x.
Another option would be to implement it also in the older GNU modes but
not in the C/CXX modes (but it would be strange if we did that just for
C++ and not for C).
Yet another option is to enable it unconditionally.
And yet another option would be to enable it unconditionally but emit
a warning (or pedwarn) when it is seen.
Note, when it is enabled for the older language modes, as Joseph wrote
in the c11-elifdef-1.c testcase, it can result e.g. in rejecting previously
valid code:
 #define A
 #undef B
 #if 0
 #elifdef A
 #error "#elifdef A applied"
 #endif
 #if 0
 #elifndef B
 #error "#elifndef B applied"
 #endif
Note, seems clang went the enable it unconditionally in all standard
versions of both C and C++, no warnings or anything whatsoever, so
essentially treated it as a DR that changed behavior of e.g. the above code.
After feedback, this option enables #elifdef/#elifndef for -std=c2x
and -std=c++2{b,3} and enables it also for -std=gnu*, but for GNU modes
older than C2X or C++23 if -pedantic it emits a pedwarn on the directives
that either would be rejected in the corresponding -std=c* modes, e.g.
  #if 1
  #elifdef A // pedwarn if -pedantic
  #endif
or when the directives would be silently accepted, but when they are
recognized it changes behavior, so e.g.
  #define A
  #if 0
  #elifdef A // pedwarn if -pedantic
  #define M 1
  #endif
It won't pedwarn if the directives would be silently ignored and wouldn't
change anything, like:
  #define A
  #if 0
  #elifndef A
  #define M 1
  #endif
or
  #undef B
  #if 0
  #elifdef B
  #define M 1
  #endif

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

libcpp/
* init.c (lang_defaults): Implement P2334R1, enable elifdef for
-std=c++23 and -std=gnu++23.
* directives.c (_cpp_handle_directive): Support elifdef/elifndef if
either CPP_OPTION (pfile, elifdef) or !CPP_OPTION (pfile, std).
(do_elif): For older non-std modes if pedantic pedwarn about
#elifdef/#elifndef directives that change behavior.
gcc/testsuite/
* gcc.dg/cpp/gnu11-elifdef-1.c: New test.
* gcc.dg/cpp/gnu11-elifdef-2.c: New test.
* gcc.dg/cpp/gnu11-elifdef-3.c: New test.
* gcc.dg/cpp/gnu11-elifdef-4.c: New test.
* g++.dg/cpp/elifdef-1.C: New test.
* g++.dg/cpp/elifdef-2.C: New test.
* g++.dg/cpp/elifdef-3.C: New test.
* g++.dg/cpp/elifdef-4.C: New test.
* g++.dg/cpp/elifdef-5.C: New test.
* g++.dg/cpp/elifdef-6.C: New test.
* g++.dg/cpp/elifdef-7.C: New test.

2 years agoFortran: Fix deprecate warning with parameter
Tobias Burnus [Wed, 6 Oct 2021 06:47:40 +0000 (08:47 +0200)]
Fortran: Fix deprecate warning with parameter

Only warn with !GCC$ ATTRIBUTES DEPRECATED if
deprecated PARMETERS are actually used.

gcc/fortran/ChangeLog:

* resolve.c (resolve_values): Only show
deprecated warning if attr.referenced.

gcc/testsuite/ChangeLog:

* gfortran.dg/attr_deprecated-2.f90: New test.

2 years ago[gimple-isel] Remove redundant if condition.
prathamesh.kulkarni [Wed, 6 Oct 2021 05:51:13 +0000 (11:21 +0530)]
[gimple-isel] Remove redundant if condition.

gcc/ChangeLog:
* gimple-isel.cc (gimple_expand_vec_cond_expr): Remove redundant if
condition.

2 years agoc++: defaulted <=> with bitfields [PR102490]
Jakub Jelinek [Fri, 1 Oct 2021 15:07:17 +0000 (17:07 +0200)]
c++: defaulted <=> with bitfields [PR102490]

The testcases in the patch are either miscompiled or ICE with checking,
because the defaulted operator== is synthesized too early (but only if
constexpr), when the corresponding class type is still incomplete type.  The
problem is that at that point the bitfield FIELD_DECLs still have as
TREE_TYPE their underlying type rather than integral type with their
precision and when layout_class_type is called for the class soon after
that, it changes those types but the COMPONENT_REFs type stay the way that
they were during the operator== synthesize_method type and the middle-end is
then upset by the mismatch of types.  As what exact type will be given isn't
just a one liner but quite long code especially for over-sized bitfields, I
think it is best to just not synthesize the comparison operators so early
and call defaulted_late_check for them once again as soon as the class is
complete.

This is also a problem for virtual operator<=>, where we need to compare the
noexcept-specifier to validate the override before the class is complete.
Rather than try to defer that comparison, maybe_instantiate_noexcept now
calls maybe_synthesize_method, which calls build_comparison_op in
non-defining mode if the class isn't complete yet.  In that situation we
also might not have base fields yet, so we look in the binfo for the bases.

Co-authored-by: Jason Merrill <jason@redhat.com>
2021-10-01  Jakub Jelinek  <jakub@redhat.com>

PR c++/98712
PR c++/102490
* cp-tree.h (maybe_synthesize_method): Declare.
* method.c (genericize_spaceship): Use
LOOKUP_NORMAL | LOOKUP_NONVIRTUAL | LOOKUP_DEFAULTED instead of
LOOKUP_NORMAL for flags.
(comp_info): Remove defining member.  Add complain, code, retcat.
(comp_info::comp_info): Adjust.
(do_one_comp): Split out from build_comparison_op.   Use
LOOKUP_NORMAL | LOOKUP_NONVIRTUAL | LOOKUP_DEFAULTED instead of
LOOKUP_NORMAL for flags.
(build_comparison_op): Add defining argument. Adjust comp_info
construction.  Use defining instead of info.defining.  Assert that
if defining, ctype is a complete type.  Walk base binfos.
(synthesize_method, maybe_explain_implicit_delete,
explain_implicit_non_constexpr): Adjust build_comparison_op callers.
(maybe_synthesize_method): New function.
* class.c (check_bases_and_members): Don't call defaulted_late_check
for sfk_comparison.
(finish_struct_1): Call it here instead after class has been
completed.
* pt.c (maybe_instantiate_noexcept): Call maybe_synthesize_method
instead of synthesize_method.

* g++.dg/cpp2a/spaceship-synth8.C (std::strong_ordering): Provide
more complete definition.
(std::strong_ordering::less, std::strong_ordering::equal,
std::strong_ordering::greater): Define.
* g++.dg/cpp2a/spaceship-synth12.C: New test.
* g++.dg/cpp2a/spaceship-synth13.C: New test.
* g++.dg/cpp2a/spaceship-synth14.C: New test.
* g++.dg/cpp2a/spaceship-eq11.C: New test.
* g++.dg/cpp2a/spaceship-eq12.C: New test.
* g++.dg/cpp2a/spaceship-eq13.C: New test.