platform/upstream/gcc.git
2 years agoMAINTAINERS: Add myself for write after approval
Cui,Lili [Thu, 30 Jun 2022 03:21:09 +0000 (11:21 +0800)]
MAINTAINERS: Add myself for write after approval

ChangeLog:

* MAINTAINERS (Write After Approval): Add myself.

2 years agotestsuite/102690: Only check warning for lp64 in Warray-bounds-16.C
Kito Cheng [Tue, 28 Jun 2022 10:43:42 +0000 (18:43 +0800)]
testsuite/102690: Only check warning for lp64 in Warray-bounds-16.C

That warning won't happen on ilp32 targets, seems like Andrew Pinski
already mention that[1] before.

Verified on riscv32-unknown-elf and riscv64-unknown-elf.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92879#c1

gcc/testsuite/ChangeLog:

PR testsuite/102690
* g++.dg/warn/Warray-bounds-16.C: XFAIL only on lp64 for the
warning.

2 years agoDon't use gori dependencies to optimize.
Andrew MacLeod [Wed, 29 Jun 2022 17:34:05 +0000 (13:34 -0400)]
Don't use gori dependencies to optimize.

  The routine fold_using_range::relation_fold_and_or needs to veriyf that both
operands of 2 stmts are the same, and uses GORIs dependency cache for this.
This cache cannot be counted on to reflect the current contents of a
stmt, expecially in the presence of an IL changing pass.  Instead, look at the
statement operands.

PR tree-optimization/106114
gcc/
* gimple-range-fold.cc (fold_using_range::relation_fold_and_or): Check
statement operands instead of GORI cache.
gcc/testsuite/
* gcc.dg/pr106114.c: New.

2 years agotarget: Fix asm generation for AVX builtins when using -masm=intel [PR106095]
Antoni Boucher [Sun, 26 Jun 2022 22:49:15 +0000 (18:49 -0400)]
target: Fix asm generation for AVX builtins when using -masm=intel [PR106095]

gcc/ChangeLog:
PR target/106095
* config/i386/sse.md: Fix asm generation.

gcc/testsuite/ChangeLog:
PR target/106095
* gcc.target/i386/pr106095.c: Add test using those AVX builtins.

2 years agoDaily bump.
GCC Administrator [Thu, 30 Jun 2022 00:16:46 +0000 (00:16 +0000)]
Daily bump.

2 years agolibgccjit: Fix bug where unary_op will return an integer type instead of the correct...
Antoni Boucher [Wed, 29 Jun 2022 23:56:56 +0000 (19:56 -0400)]
libgccjit: Fix bug where unary_op will return an integer type instead of the correct type

2022-06-29  Antoni Boucher  <bouanto@zoho.com>

gcc/jit/
PR jit/105812
* jit-playback.cc: Use the correct return type when folding in
as_truth_value.

gcc/testsuite/
PR jit/105812
* jit.dg/test-asm.cc: Add include missing to make the test pass.
* jit.dg/test-pr105812-bool-operations.c: New test.

2 years agocompiler: check repeated const expressions in new scope
Ian Lance Taylor [Wed, 29 Jun 2022 00:03:28 +0000 (17:03 -0700)]
compiler: check repeated const expressions in new scope

Test case is const8.go in https://go.dev/cl/414795.

Fixes golang/go#53585

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/414914

2 years agod: Fix error: aggregate value used where floating point was expected
Iain Buclaw [Wed, 29 Jun 2022 19:52:39 +0000 (21:52 +0200)]
d: Fix error: aggregate value used where floating point was expected

Casting from vector to static array is permitted, and the frontend
generates a reinterpret cast, but casting back the other way resulted in
an error.  This has been fixed to be properly handled in the code
generation pass of VectorExp, and the conversion for lvalue and rvalue
handling done in convert_expr and convert_for_rvalue respectively.

PR d/106139

gcc/d/ChangeLog:

* d-convert.cc (convert_expr): Handle casting from array to vector.
(convert_for_rvalue): Rewrite vector to array casts of the same
element type into a constructor.
(convert_for_assignment): Return calling convert_for_rvalue.
* expr.cc (ExprVisitor::visit (VectorExp *)): Handle generating a
vector expression from a static array.
* toir.cc (IRVisitor::visit (ReturnStatement *)): Call
convert_for_rvalue on return value.

gcc/testsuite/ChangeLog:

* gdc.dg/pr106139a.d: New test.
* gdc.dg/pr106139b.d: New test.
* gdc.dg/pr106139c.d: New test.
* gdc.dg/pr106139d.d: New test.

2 years agojit: avoid calloc() poisoning on musl [PR106102]
Sergei Trofimovich [Mon, 27 Jun 2022 22:42:44 +0000 (23:42 +0100)]
jit: avoid calloc() poisoning on musl [PR106102]

On musl <pthread.h> uses calloc() (via <sched.h>). jit/ includes
it directly and exposes use of poisoned calloc():

    /build/build/./prev-gcc/xg++ ... ../../gcc-13-20220626/gcc/jit/jit-playback.cc
    make[3]: *** [Makefile:1143: jit/libgccjit.o] Error 1
    make[3]: *** Waiting for unfinished jobs....
    In file included from /<<NIX>>/musl-1.2.3-dev/include/pthread.h:30,
                     from ../../gcc-13-20220626/gcc/jit/jit-playback.cc:44:
    /<<NIX>>/musl-1.2.3-dev/include/sched.h:84:7: error: attempt to use poisoned "calloc"
       84 | void *calloc(size_t, size_t);
          |       ^
    /<<NIX>>/musl-1.2.3-dev/include/sched.h:124:36: error: attempt to use poisoned "calloc"
      124 | #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n)))
          |                                    ^

The change moves <pthread.h> inclusion to "system.h" under new
INCLUDE_PTHREAD_H guard and uses this mechanism in libgccjit.

gcc/

PR c++/106102
* system.h: Introduce INCLUDE_PTHREAD_H macros to include <pthread.h>.

gcc/jit/

PR c++/106102
* jit-playback.cc: Include <pthread.h> via "system.h" to avoid calloc()
poisoning.
* jit-recording.cc: Ditto.
* libgccjit.cc: Ditto.

2 years agoFortran: improve error recovery for EXTENDS_TYPE_OF() [PR106121]
Harald Anlauf [Tue, 28 Jun 2022 20:29:28 +0000 (22:29 +0200)]
Fortran: improve error recovery for EXTENDS_TYPE_OF() [PR106121]

gcc/fortran/ChangeLog:

PR fortran/106121
* simplify.cc (gfc_simplify_extends_type_of): Do not attempt to
simplify when one of the arguments is a CLASS variable that was
not properly declared.

gcc/testsuite/ChangeLog:

PR fortran/106121
* gfortran.dg/extends_type_of_4.f90: New test.

Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
2 years agoc++: Rename macro location structs
Nathan Sidwell [Fri, 24 Jun 2022 12:17:24 +0000 (05:17 -0700)]
c++: Rename macro location structs

The macro location tables should really mention they are about
locations.  So rename them.  Also, add a missing free of the remapping
table, and remove some now-unneeded macro checking.

gcc/cp/
* module.cc (macro_info, macro_traits, macro_table,
macro_remap): Rename to ...
(macro_loc_info, macro_loc_traits, macro_loc_table,
macro_loc_remap): ... these.  Update all uses.
(module_state::write_prepare_maps): Remove unneeded macro checking.
(module_state::write_begin): Free macro_loc_remap.

2 years agod: Fix build on aarch64-suse-linux
Iain Buclaw [Wed, 29 Jun 2022 16:27:08 +0000 (18:27 +0200)]
d: Fix build on aarch64-suse-linux

The variables being used to get the result out of TYPE_VECTOR_SUBPARTS
were being flagged by -Werror=maybe-uninitialized.  As they have already
been checked for being constant earlier, use `to_constant' instead.

gcc/d/ChangeLog:

* intrinsics.cc (build_shuffle_mask_type): Use to_constant when
getting the number of subparts from a vector type.
(expand_intrinsic_vec_shufflevector): Likewise.

2 years agonios2: Fix PIC function call slowness
Joseph Myers [Wed, 29 Jun 2022 15:55:41 +0000 (15:55 +0000)]
nios2: Fix PIC function call slowness

On Nios II, PIC function calls use R_NIOS2_CALL* relocations, which
may refer to a GOT entry that initially points to a PLT entry to
resolve the function on first call and that is then changed by the
dynamic linker to point directly to the function to be called so
subsequent calls do not go through the dynamic linker.  To quote the
ABI, "A global offset table (GOT) entry referenced using
R_NIOS2_GOT16, R_NIOS2_GOT_LO as well as R_NIOS2_GOT_HA must be
resolved at load time.  A GOT entry referenced only using
R_NIOS2_CALL16, R_NIOS2_CALL_LO as well as R_NIOS2_CALL_HA can
initially refer to a procedure linkage table (PLT) entry and then be
resolved lazily.".

However, GCC wrongly treats function addresses loaded from the GOT
with such relocations as constant.  If the address load is pulled out
of a loop, then every call in the loop looks up the function by name.
This shows up as very slow execution of many glibc testcases in glibc
2.35 and later (tests that call functions from shared libc many times
in a loop), where tests are now built as PIE by default.  Fix this
problem by using gen_rtx_MEM instead of gen_const_mem when loading
addresses for PIC function calls.

Tested with no regressions for cross to nios2-linux-gnu, where many
glibc tests pass that previously timed out.

* config/nios2/nios2.cc (nios2_load_pic_address): Use gen_rtx_MEM
not gen_const_mem for UNSPEC_PIC_CALL_SYM.

2 years agolibgfortran: Switch some more __float128 uses to _Float128
Jakub Jelinek [Wed, 29 Jun 2022 15:06:02 +0000 (17:06 +0200)]
libgfortran: Switch some more __float128 uses to _Float128

My patch apparently left some __float128 uses in libgfortran
that could use _Float128 instead, the following patch changes that.

2022-06-29  Jakub Jelinek  <jakub@redhat.com>

* mk-kinds-h.sh: Change __float128 to _Float128 in a comment.
* acinclude.m4 (LIBGFOR_CHECK_MATH_IEEE128): Use _Float128 instead of
__float128.
* libgfortran.h (isnan): Change __float128 to _Float128 in a comment.
(__acoshieee128, __acosieee128, __asinhieee128, __asinieee128,
__atan2ieee128, __atanhieee128, __atanieee128, __copysignieee128,
__coshieee128, __cosieee128, __erfcieee128, __erfieee128,
__expieee128, __fabsieee128, __fmaieee128, __fmodieee128, __jnieee128,
__log10ieee128, __logieee128, __powieee128, __sinhieee128,
__sinieee128, __sqrtieee128, __tanhieee128, __tanieee128,
__ynieee128, __strtoieee128): Use _Float128 instead of __float128.
* configure: Regenerated.

2 years agolibgfortran: Fix up LIBGFOR_CHECK_FLOAT128 [PR106137]
Jakub Jelinek [Wed, 29 Jun 2022 15:04:50 +0000 (17:04 +0200)]
libgfortran: Fix up LIBGFOR_CHECK_FLOAT128 [PR106137]

My recent gfortran + libgfortran patch apparently broke (some?) aarch64
builds.  While it is desirable to use just _Float128 rather than __float128,
we only want to use it (and e.g. define HAVE_FLOAT128) on targets where
_Float128 is supported and long double isn't IEEE quad precision.
Which is targets that support __float128 type which we have been testing
for before - _Float128 is supported on those targets and on targets where
long double is IEEE quad precision.

So, the following patch restores check for whether __float128 is supported
into the LIBGFOR_CHECK_FLOAT128 check which determines whether
HAVE_FLOAT128 is defined or whether to use libquadmath, so that e.g. on
aarch64 where long double is IEEE quad we don't do that.

2022-06-29  Jakub Jelinek  <jakub@redhat.com>

PR bootstrap/106137
* acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Adjust comment.
Also test for __float128.
(HAVE_FLOAT128): Adjust description.
* config.h.in: Regenerated.
* configure: Regenerated.

2 years agolibsanitizer: cherry-pick 791e0d1bc85d
Martin Liska [Wed, 29 Jun 2022 13:28:07 +0000 (15:28 +0200)]
libsanitizer: cherry-pick 791e0d1bc85d

791e0d1bc85d: [compiler-rt] Add NO_EXEC_STACK_DIRECTIVE on s390x

2 years agortl-optimization/106082 - preserve EH note for no non-local goto
Richard Biener [Tue, 28 Jun 2022 11:08:33 +0000 (13:08 +0200)]
rtl-optimization/106082 - preserve EH note for no non-local goto

The following makes sure we preserve EH notes on call insns that
indicate the call doesn't perform a non-local goto when distributing
notes after combining insns.

2022-06-28  Richard Biener  <rguenther@suse.de>

PR rtl-optimization/106082
* combine.cc (distribute_notes): Preserve notes when
they indicate a call doesn't perform a non-local goto.

2 years agotree-optimization/106112 - fix CSE from wider operation
Richard Biener [Tue, 28 Jun 2022 11:57:29 +0000 (13:57 +0200)]
tree-optimization/106112 - fix CSE from wider operation

The following fixes a mistake in looking up an extended operand
in the CSE of a truncated operation.

2022-06-28  Richard Biener  <rguenther@suse.de>

PR tree-optimization/106112
* tree-ssa-sccvn.cc (valueized_wider_op): Properly extend
a constant operand according to its type.

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

2 years agotestsuite/ix86: SSE2 is a prereq to _Float16 use
Jan Beulich [Wed, 29 Jun 2022 08:27:22 +0000 (10:27 +0200)]
testsuite/ix86: SSE2 is a prereq to _Float16 use

When enabling AVX512FP via attribute or pragma, the _Float16 type would
remain unavailable when at initialization time SSE2 wouldn't be seen as
available for use. While this may hint at a wider underlying issue (like
the feature, the type may want providing dynamically, albeit this may be
challenging in particular for functions returning _Float16 yet having
the attribute specified after their return type), for now simply make
SSE2 available when targeting ix86.

gcc/testsuite/

* gcc.target/i386/avx512fp16-reduce-op-2.c: Force SSE2 for i?86.
* gcc.target/i386/pr99464.c: Likewise.

2 years agotestsuite/ix86: prune MMX ABI warning
Jan Beulich [Wed, 29 Jun 2022 08:26:26 +0000 (10:26 +0200)]
testsuite/ix86: prune MMX ABI warning

So far on 32-bit hosts this test failed (for both C and C++) because of
the ABI change warning occurring without (explictly) enabling MMX.

gcc/testsuite/

* c-c++-common/torture/builtin-shufflevector-2.c: Prune ix86 MMX
ABI warning.

2 years agodocs: remove removed param from documentation
Martin Liska [Wed, 29 Jun 2022 08:08:05 +0000 (10:08 +0200)]
docs: remove removed param from documentation

gcc/ChangeLog:

* doc/invoke.texi: Remove removed evrp-mode.

2 years agoLoongArch: Remove undefined behavior from code [PR 106097]
Lulu Cheng [Mon, 27 Jun 2022 08:26:25 +0000 (16:26 +0800)]
LoongArch: Remove undefined behavior from code [PR 106097]

C++2017 and previous standard description:

The value of E1 << E2 is E1 left-shifted E2 bit positions;
vacated bits are zero-filled. If E1 has an unsigned type,
the value of the result is E1×2E2, reduced modulo one more
than the maximum value representable inthe result type.
Otherwise, if E1 has a signed type and non-negative value,
and E1×2E2 is representablein the corresponding unsigned
type of the result type, then that value, converted to the
result type, is the resulting value; otherwise, the behavior
is undefined.

The value of E1 >> E2 is E1 right-shifted E2 bit positions.
If E1 has an unsigned type or if E1 has a signed type and
a non-negative value, the value of the result is the integral
part of the quotient of E1/2E2. If E1 has a signed type and
a negative value, the resulting value is implementation-defined.

gcc/ChangeLog:

PR target/106097
* config/loongarch/loongarch.cc (loongarch_build_integer):
Remove undefined behavior from code.

2 years agod: Add SIMD intrinsics module and compiler built-ins.
Iain Buclaw [Tue, 28 Jun 2022 17:22:34 +0000 (19:22 +0200)]
d: Add SIMD intrinsics module and compiler built-ins.

Vectors in D are exposed by the use of the `__vector(T[N])' type, and
whilst most unary and binary operations work as you'd expect, there are
some operations that are not possible without doing the operation
unrolled, or calling some target-specific built-in, or with inline asm.

This introduces a new `gcc.simd' module that introduces the following.

 - Prefetching has been exposed by a convenient `prefetch' function in
   the library.

 - Loading and storing from an unaligned address have been exposed by
   `loadUnaligned' and `storeUnaligned' intrinsics.

 - Vector permutations have been exposed by `shuffle`, and
   `shufflevector' intrinsics.

 - Converting between two vectors with a different element type has been
   exposed by a `convertvector' intrinsic.

 - The ternary operator has been exposed with a `blendvector' intrinsic.

 - Comparison operators have been exposed by `equalMask',
   `notEqualMask', `greaterMask', and `greaterEqualMask' intrinsics.

 - Logic operators have been exposed by convenient `notMask',
   `andAndMask', and `orOrMask' functions in the library.

To be compatible with the LLVM D compiler's own SIMD intrinsic module,
there is also the addition of an `extractelement' and `insertelement'
convenience functions, and an alternative interface for calling the
`shufflevector' function.

The addition of these intrinsics lowers the boundary for users working
in SIMD to get the desired codegen they want out of the compiler.

Most of what is present here - apart from tests - is the adding of
machinery in the intrinsics suite of functions to do validation on
templated intrinsics.  Whilst these are still matched from the library
by their generic (untyped) signature, there is a still an assumption
that what has been instantiated and handed down to the code generator is
valid, because why would these definitions be found outside of the
in-tree D runtime library?  The majority of intrinsics are not
templates, so the test on the mangled signature string still guarantees
all types are as we expect them to be.  However there are still a small
handful of other templated intrinsics (core.bitop.{rol,ror},
core.math.toPrec, std.math.traits.isNaN, ...) that are currently
unchecked, so would benefit from being included into this built-in
checking function at some point in the future.

gcc/d/ChangeLog:

* intrinsics.cc: Include diagnostic.h, langhooks.h,
vec-perm-indices.h.
(maybe_set_intrinsic): Add cases for new simd intrinsics.
(warn_mismatched_return_type): New function.
(warn_mismatched_argument): New function.
(build_shuffle_mask_type): New function.
(maybe_warn_intrinsic_mismatch): New function.
(expand_intrinsic_vec_cond): New function.
(expand_intrinsic_vec_convert): New function.
(expand_intrinsic_vec_blend): New function.
(expand_intrinsic_vec_shuffle): New function.
(expand_intrinsic_vec_shufflevector): New function.
(expand_intrinsic_vec_load_unaligned): New function.
(expand_intrinsic_vec_store_unaligned): New function.
(maybe_expand_intrinsic): Check signature of intrinsic before handing
off to front-end lowering.  Add cases for new simd intrinsics.
* intrinsics.def (INTRINSIC_LOADUNALIGNED): Define intrinsic.
(INTRINSIC_STOREUNALIGNED): Define intrinsic.
(INTRINSIC_SHUFFLE): Define intrinsic.
(INTRINSIC_SHUFFLEVECTOR): Define intrinsic.
(INTRINSIC_CONVERTVECTOR): Define intrinsic.
(INTRINSIC_BLENDVECTOR): Define intrinsic.
(INTRINSIC_EQUALMASK): Define intrinsic.
(INTRINSIC_NOTEQUALMASK): Define intrinsic.
(INTRINSIC_GREATERMASK): Define intrinsic.
(INTRINSIC_GREATEREQUALMASK): Define intrinsic.

libphobos/ChangeLog:

* libdruntime/Makefile.am (DRUNTIME_DSOURCES): Add gcc/simd.d.
* libdruntime/Makefile.in: Regenerate.
* libdruntime/gcc/simd.d: New file.

gcc/testsuite/ChangeLog:

* gdc.dg/Wbuiltin_declaration_mismatch.d: Rename to...
* gdc.dg/Wbuiltin_declaration_mismatch1.d: ...this.
* gdc.dg/Wbuiltin_declaration_mismatch2.d: New test.
* gdc.dg/torture/simd_blendvector.d: New test.
* gdc.dg/torture/simd_cond.d: New test.
* gdc.dg/torture/simd_convertvector.d: New test.
* gdc.dg/torture/simd_load.d: New test.
* gdc.dg/torture/simd_logical.d: New test.
* gdc.dg/torture/simd_shuffle.d: New test.
* gdc.dg/torture/simd_shufflevector.d: New test.
* gdc.dg/torture/simd_store.d: New test.

2 years agoDaily bump.
GCC Administrator [Wed, 29 Jun 2022 00:17:00 +0000 (00:17 +0000)]
Daily bump.

2 years agolibcpp: Update ucnid.h to Unicode 14
Lewis Hyatt [Tue, 28 Jun 2022 21:33:37 +0000 (17:33 -0400)]
libcpp: Update ucnid.h to Unicode 14

This patch updates ucnid.h from Unicode 13 to Unicode 14.  Additionally, the
procedure detailed in contrib/unicode/README, which updates
generated_wcwidth.h, has been expanded with instructions for updating this
file as well, so that both may be done at the same time conveniently.  Two
additional Unicode data files which are needed to create ucnid.h are also
added to source control in contrib/unicode.

contrib/ChangeLog:

* unicode/README: Added instructions for updating ucnid.h.
* unicode/DerivedCoreProperties.txt: New file added to source
control from Unicode 14.0 release.
* unicode/DerivedNormalizationProps.txt: Likewise.

libcpp/ChangeLog:

* ucnid.h: Regenerated for Unicode 14.0.

2 years agocompiler: use package path with embedded builtin type
Ian Lance Taylor [Sun, 26 Jun 2022 05:09:16 +0000 (22:09 -0700)]
compiler: use package path with embedded builtin type

The test case is https://go.dev/cl/414235.

Fixes golang/go#52856

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/414294

2 years agolibgo: make runtime.Version return a meaningful string
Ian Lance Taylor [Tue, 28 Jun 2022 00:22:53 +0000 (17:22 -0700)]
libgo: make runtime.Version return a meaningful string

Fixes golang/go#51850

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/414734

2 years agod: Use create_tmp_var_raw and get_callee_fndecl
Iain Buclaw [Tue, 28 Jun 2022 16:49:27 +0000 (18:49 +0200)]
d: Use create_tmp_var_raw and get_callee_fndecl

A couple of small patterns that repeat are generating a temporary, and
getting a function out of a CALL_EXPR.  There are convenience functions
for these in the common parts of gcc, use them instead.

gcc/d/ChangeLog:

* d-codegen.cc: Include gimple-expr.h.
(force_target_expr): Use create_tmp_var_raw.
* decl.cc: Inlucde gimple-expr.h.
(build_local_temp): Use create_tmp_var_raw.
* intrinsics.cc (expand_intrinsic_rotate): Use get_callee_fndecl.
(maybe_expand_intrinsic): Likewise.

2 years agod: Add `@simd` and `@simd_clones` attributes to compiler and library
Iain Buclaw [Sat, 25 Jun 2022 13:06:43 +0000 (15:06 +0200)]
d: Add `@simd` and `@simd_clones` attributes to compiler and library

The `@simd` attribute is equivalent to `__attribute__((simd))`, and
`@simd_clones` is a convenience alias to allow specifying whether the
compiler should generated masked or non-masked simd clones.

gcc/d/ChangeLog:

* d-attribs.cc (handle_omp_declare_simd_attribute): New function.
(d_handle_simd_attribute): New function.
(d_langhook_common_attribute_table): Add 'omp declare simd' attribute.
(d_langhook_attribute_table): Add simd attribute.

libphobos/ChangeLog:

* libdruntime/gcc/attributes.d (simd): Define.

gcc/testsuite/ChangeLog:

* gdc.dg/attr_simd1.d: New test.
* gdc.dg/attr_simd2.d: New test.

2 years agocompiler: permit expressions of abstract bool to remain abstract
Ian Lance Taylor [Tue, 28 Jun 2022 05:17:51 +0000 (22:17 -0700)]
compiler: permit expressions of abstract bool to remain abstract

Test case is https://go.dev/cl/414755.

Fixes golang/go#51475

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/414735

2 years agotestsuite: Add new target check for no_alignment_constraints
Dimitar Dimitrov [Sun, 3 Apr 2022 19:27:12 +0000 (22:27 +0300)]
testsuite: Add new target check for no_alignment_constraints

A few testcases were marked for avr target, which has no alignment
requirements.  But those tests in fact should filter for any
target having __BIGGEST_ALIGNMENT__=1.

A new effective target check is introduced: no_alignment_constraints.
It checks whether __BIGGEST_ALIGNMENT__ is declared as 1.

This change fixes the testsuite cases for PRU target.

It was regression-tested on x86_64-pc-linux-gnu.

The following two existing macros were considered, but they check for
subtly different target behaviour:
 1. non_strict_align
    If true, non-aligned access is permitted. But it also allows
    variables to be naturally aligned, which is not true for
    no_alignment_constraints.

 2. default_packed
    Whether structures are packed by default is not necessarily
    the same as lacking constraints for non-aggregate types.
    For example, BIGGEST_FIELD_ALIGNMENT or ADJUST_FIELD_ALIGN
    could be defined for a target as something other than
    BIGGEST_ALIGNMENT.

gcc/ChangeLog:

* doc/sourcebuild.texi: Document new no_alignment_constraints
effective target check.

gcc/testsuite/ChangeLog:

* c-c++-common/Wcast-align.c: Silence warnings for targets with
no_alignment_constraints.
* gcc.dg/c11-align-4.c: Skip for no_alignment_constraints.
* gcc.dg/strlenopt-10.c: Replace checks for avr with checks for
any target with no_alignment_constraints.
* gcc.dg/strlenopt-11.c: Ditto.
* gcc.dg/strlenopt-13.c: Ditto.
* lib/target-supports.exp
(check_effective_target_no_alignment_constraints): New.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2 years agoRemove legacy EVRP code.
Aldy Hernandez [Mon, 27 Jun 2022 16:40:23 +0000 (18:40 +0200)]
Remove legacy EVRP code.

With DOM converted to ranger, there are no longer any uses of the EVRP
engine.  For that matter, we haven't used the legacy mode in quite a
while, so I think it's safe to remove any associated code.

There are some methods in vr_values which should now be private, but I
didn't bother changing them, as most of the vr_values class will be
removed when VRP1 is converted to ranger.

Tested on x86-64 Linux.

gcc/ChangeLog:

* Makefile.in: Remove gimple-ssa-evrp.o and gimple-ssa-evrp-analyze.o.
* flag-types.h (enum evrp_mode): Remove.
* params.opt: Remove --param=evrp-mode.
* tree-vrp.cc (make_pass_early_vrp): New.
(pass_vrp::execute): Call early VRP instance.
* gimple-ssa-evrp-analyze.cc: Removed.
* gimple-ssa-evrp-analyze.h: Removed.
* gimple-ssa-evrp.cc: Removed.

gcc/testsuite/ChangeLog:

* g++.dg/pr100774.C: Remove --param=evrp-mode.
* gcc.dg/pr100781.c: Same.

2 years agoAdd TFLAGS to gcc's GCC_FOR_TARGET
Alexandre Oliva [Tue, 28 Jun 2022 12:41:07 +0000 (09:41 -0300)]
Add TFLAGS to gcc's GCC_FOR_TARGET

When the GCC build runs GCC_FOR_TARGET, e.g. for selftests or for
dumping specs, it doesn't use TFLAGS in non-bootstrap scenarios.  This
patch arranges for TFLAGS to be passed from the top level down to gcc
in GCC_FOR_TARGET in this case.

Another issue related with TFLAGS fixed herein is that there's no easy
way to add a TFLAGS to GCC_FOR_TARGET when running "make gnatlib"
within the gcc directory.  Overriding all of GCC_FOR_TARGET is
somewhat cumbersome, so I'm adding TFLAGS support to gcc/Makefile.in,
getting it added to GCC_FOR_TARGET, as it would when passed down from
the top level.

for  ChangeLog

* Makefile.tpl (HOST_EXPORTS): Add TFLAGS to GCC_FOR_TARGET.
(EXTRA_GCC_FLAGS): Likewise.
* Makefile.in: Rebuilt.

for  gcc/ChangeLog

* Makefile.in (TFLAGS): New.
(GCC_FOR_TARGET): Add TFLAGS.
(FLAGS_TO_PASS): Pass TFLAGS down.

2 years agolibstdc++: Fix filesystem build for Windows
Jonathan Wakely [Tue, 28 Jun 2022 11:56:19 +0000 (12:56 +0100)]
libstdc++: Fix filesystem build for Windows

I only half remembered to use char_type instead of char for filesystem
paths, so that it works with wchar_t on Windows. This fixes the
bootstrap failure.

libstdc++-v3/ChangeLog:

* src/filesystem/dir-common.h (_Dir_base::_At_path):
Use char_type consistently for paths.

2 years agofortran, libgfortran: Avoid using libquadmath for glibc 2.26+
Jakub Jelinek [Tue, 28 Jun 2022 11:05:28 +0000 (13:05 +0200)]
fortran, libgfortran: Avoid using libquadmath for glibc 2.26+

As mentioned by Joseph in PR105101, glibc 2.26 or later has on x86
(both -m32/-m64), powerpc64le, ia64 and mips support for
*f128 math/complex APIs plus strtof128 and strfromf128, and these APIs allow
us to avoid libquadmath for Fortran purposes on these architectures,
replace *q math/complex APIs, strtof128 instead of strtoflt128 and,
while strfromf128 unfortunately isn't a perfect replacement to
quadmath_snprintf, it can be made to work.

The advantage of this is that when configured against such glibcs
(2.26 is now almost 5 years old), we can avoid linking against an extra shared
library and the math support in glibc is maintained better than libquadmath.

We need both a compiler change (so that for glibc 2.26+ it uses *f128 APIs
instead of *q) and library change.

The above mentioned problem with strfromf128 is that the strfrom* functions
are severely restricted versions of snprintf.  In libgfortran, we handle
!isfinite differently and just use snprintf/quadmath_snprintf for
%+-#.*{L,Q}{f,e} printing.
strfrom* doesn't allow +, -, # modifiers and it only supports .34 or
similar precision, not .* .  The L/Q etc. letters are omitted.
The + is there to force + sign at the start if it is positive.
Workaround in the patch is to add the + at the start manually for
!signbit (val).
The - (left alignment instead of right) I don't understand why we need it,
when minimum field width isn't specified (for strfrom* can't be specified),
no padding is ever added anywhere I believe.
The # is to force adding . - workaround is to search for first . or e or '\0'
character, if it is '\0', just append ., if it is e, insert . before e and
memmove the rest (which is just a few bytes, e, +/- and at most a few digits)
one byte later.
The .* case is handled by creating the format string for strfrom* by
snprintf into a temporary buffer.

As requested, this patch also switches from using __float128 type in
libgfortran to _Float128 which is equivalent on all arches that support
__float128.

The change is done in a backwards compatible change, when GCC is configured
against glibc 2.26 or newer, libgfortran.so.5 itself doesn't link against
-lquadmath nor uses any libquadmath APIs, libgfortran.a doesn't use any
libquadmath APIs either.  User programs and libraries when being linked
by gfortran driver are linked against -lgfortran and -lquadmath, but
the latter only in the --as-needed linker mode, which means it needs
to be around during linking and will be linked in if there are any
calls to math/complex functions with real(kind=16) or complex(kind=16)
in compilation units compiled by older versions of gcc, but if either
user code doesn't call those math/complex functions for the largest
supported kind, or the code is recompiled by gcc with this change in,
libquadmath won't be linked in.

2022-06-28  Jakub Jelinek  <jakub@redhat.com>

gcc/fortran/
* gfortran.h (gfc_real_info): Add use_iec_60559 bitfield.
* trans-types.h (gfc_real16_use_iec_60559): Declare.
* trans-types.cc (gfc_real16_use_iec_60559): Define.
(gfc_init_kinds): When building powerpc64le-linux libgfortran
on glibc 2.26 to 2.31, set gfc_real16_use_iec_60559 and
use_iec_60559.
(gfc_build_real_type): Set gfc_real16_use_iec_60559 and use_iec_60559
on glibc 2.26 or later.
* trans-intrinsic.cc (gfc_build_intrinsic_lib_fndecls): Adjust
comment.  Handle gfc_real16_use_iec_60559.
(gfc_get_intrinsic_lib_fndecl): Handle use_iec_60559.
libgfortran/
* configure.ac: Check for strtof128 and strfromf128.
Check for math and complex *f128 functions.  Set
have_iec_60559_libc_support to yes if *f128 support is around, for
--enable-libquadmath-support default to "default" rather than yes if
have_iec_60559_libc_support is yes.
* acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Test
_Float128/_Complex _Float128 rather than __float128 and
_Complex float __attribute__((mode(TC))).  If libquadmath support
is defaulted and have_iec_60559_libc_support is yes, define and subst
USE_IEC_60559.  Remove unused LIBGFOR_BUILD_QUAD conditional.
* Makefile.am (kinds.h): Pass @USE_IEC_60559@ as an extra
mk-kinds-h.sh argument.
* mk-kinds-h.sh: Accept 4th use_iec_60559 argument.  Use
_Float128/_Complex _Float128 types instead of __float128 and
_Complex float __attribute__((mode(TC))), and if use_iec_60559 is yes,
use f128 suffix instead of q and define GFC_REAL_16_USE_IEC_60559.
* kinds-override.h: Use _Float128/_Complex _Float128 types instead of
__float128 and _Complex float __attribute__((mode(TC))), if
USE_IEC_60559 is defined, use f128 suffixes instead of q and
define GFC_REAL_17_USE_IEC_60559.
* libgfortran.h: Don't include quadmath_weak.h if USE_IEC_60559 is
defined.
(GFC_REAL_16_INFINITY, GFC_REAL_16_QUIET_NAN): Define
for GFC_REAL_16_USE_IEC_60559 differently.
* caf/single.c (convert_type): Use _Float128/_Complex _Float128
instead of __float128 and _Complex float __attribute__((mode(TC))).
For HAVE_GFC_REAL_10 when HAVE_GFC_REAL_16 isn't defined use
_Complex long double instead of long double.
* ieee/issignaling_fallback.h (ieee854_float128_shape_type): Use
_Float128 instead of __float128.
(__issignalingf128): Change argument type to _Float128.
(issignaling): Use _Float128 instead of __float128 in _Generic.
* intrinsics/cshift0.c (cshift0): Use _Float128 instead of __float128
in a comment.  Fix a comment typo, logn double -> long double.
* intrinsics/erfc_scaled.c (_THRESH, _M_2_SQRTPI, _INF, _ERFC, _EXP):
Use different definitions if GFC_REAL_16_USE_IEC_60559.
(_THRESH, _M_2_SQRTPI): Use GFC_REAL_17_LITERAL macro.
(_ERFC, _EXP): Use different definitions if GFC_REAL_17_USE_IEC_60559.
* intrinsics/spread_generic.c (spread, spread_scalar): Use _Float128
instead of __float128 in a comment.  Fix a comment typo,
logn double -> long double.
* intrinsics/trigd.c (ENABLE_SIND, ENABLE_COSD, ENABLE_TAND): Handle
GFC_REAL_16_USE_IEC_60559.
* intrinsics/pack_generic.c (pack): Use _Float128 instead of
__float128 in a comment.  Fix a comment typo, logn double ->
long double.
* intrinsics/unpack_generic.c (unpack1, unpack0): Likewise.
* runtime/in_pack_generic.c (internal_pack): Likewise.
* runtime/in_unpack_generic.c (internal_unpack): Likewise.
* io/read.c (convert_real, convert_infnan): Handle
GFC_REAL_16_USE_IEC_60559 and GFC_REAL_17_USE_IEC_60559.
* io/transfer128.c (tmp1, tmp2): Don't define if libquadmath
isn't needed.
* io/write_float.def (gfor_strfromf128): New function.
(DTOA2Q, FDTOA2Q): Define differently if
GFC_REAL_16_USE_IEC_60559 or GFC_REAL_17_USE_IEC_60559.
* m4/mtype.m4: Use different suffix if GFC_REAL_16_USE_IEC_60559
or GFC_REAL_17_USE_IEC_60559.
* config.h.in: Regenerated.
* configure: Regenerated.
* Makefile.in: Regenerated.
* generated/bessel_r16.c: Regenerated.
* generated/bessel_r17.c: Regenerated.
* generated/norm2_r16.c: Regenerated.
* generated/norm2_r17.c: Regenerated.

2 years agoSpeedup loop splitting SSA update
Richard Biener [Tue, 28 Jun 2022 10:07:14 +0000 (12:07 +0200)]
Speedup loop splitting SSA update

Since we never process loops with inner loops that have been split
we can delay SSA update until after the pass is done with the whole
loop, avoiding the O(function-size) work associated with it.

2022-06-28  Richard Biener  <rguenther@suse.de>

* tree-ssa-loop-split.cc (fix_loop_bb_probability): Do not
call update_ssa.

2 years agoUse mark_block_for_update properly in insert_updated_phi_nodes_for
Richard Biener [Tue, 28 Jun 2022 10:03:22 +0000 (12:03 +0200)]
Use mark_block_for_update properly in insert_updated_phi_nodes_for

This makes sure to use mark_block_for_update when adding a block for
rewriting in insert_updated_phi_nodes_for as otherwise stmt flags are not
initialized.

2022-06-28  Richard Biener  <rguenther@suse.de>

* tree-into-ssa.cc (insert_updated_phi_nodes_for): Use
mark_block_for_update.
(update_ssa): Adjust.

2 years agolibstdc++: Improve directory iterator abstractions for openat
Jonathan Wakely [Mon, 27 Jun 2022 13:43:54 +0000 (14:43 +0100)]
libstdc++: Improve directory iterator abstractions for openat

Currently the _Dir::open_subdir function decides whether to construct a
_Dir_base with just a pathname, or a file descriptor and pathname. But
that means it is tiughtly coupled to the implementation of
_Dir_base::openat, which is what actually decides whether to use a file
descriptor or not. If the derived class passes a file descriptor and
filename, but the base class expects a full path and ignores the file
descriptor, then recursive_directory_iterator cannot recurse.

This change introduces a new type that provides the union of all the
information available to the derived class (the full pathname, as well
as a file descriptor for a directory and another pathname relative to
that directory). This allows the derived class to be agnostic to how the
base class will use that information.

libstdc++-v3/ChangeLog:

* src/c++17/fs_dir.cc (_Dir::dir_and_pathname):: Replace with
current() returning _At_path.
(_Dir::_Dir, _Dir::open_subdir, _Dir::do_unlink): Adjust.
* src/filesystem/dir-common.h (_Dir_base::_At_path): New class.
(_Dir_base::_Dir_Base, _Dir_base::openat): Use _At_path.
* src/filesystem/dir.cc (_Dir::dir_and_pathname): Replace with
current() returning _At_path.
(_Dir::_Dir, _Dir::open_subdir): Adjust.

2 years agolibstdc++: Do not optimize away storing pathname if it's needed
Jonathan Wakely [Tue, 28 Jun 2022 08:26:12 +0000 (09:26 +0100)]
libstdc++: Do not optimize away storing pathname if it's needed

libstdc++-v3/ChangeLog:

* src/c++17/fs_dir.cc (_Dir::_Dir) [!_GLIBCXX_HAVE_OPENAT]:
Always store pathname if we don't have openat or unlinkat,
because the full path is needed to open sub-directories and
remove entries.

2 years agoloongarch: exclude LARCH_PROLOGUE_TEMP from SIBCALL_REGS [PR 106096]
Xi Ruoyao [Tue, 28 Jun 2022 08:00:14 +0000 (16:00 +0800)]
loongarch: exclude LARCH_PROLOGUE_TEMP from SIBCALL_REGS [PR 106096]

The epilogue may clobber LARCH_PROLOGUE_TEMP ($r13/$t1), so it cannot be
used for sibcalls.

gcc/ChangeLog:

PR target/106096
* config/loongarch/loongarch.h (REG_CLASS_CONTENTS): Exclude
$r13 from SIBCALL_REGS.
* config/loongarch/loongarch.cc (loongarch_regno_to_class):
Change $r13 to JIRL_REGS.

gcc/testsuite/ChangeLog:

PR target/106096
* g++.target/loongarch/loongarch.exp: New test support file.
* g++.target/loongarch/pr106096.C: New test.

2 years agoAllow all types supported by ranger in loop-ch.
Aldy Hernandez [Mon, 27 Jun 2022 18:50:03 +0000 (20:50 +0200)]
Allow all types supported by ranger in loop-ch.

This converts the ranger use in loop-ch to allow any types allowed by
the ranger infrastructure.  Since the range of a GIMPLE_COND is always an
integer we can remove the check because the only temporary is already
an int_range.

gcc/ChangeLog:

* tree-ssa-loop-ch.cc (entry_loop_condition_is_static): Remove
irange::supports_p.

2 years agomiddle-end/106053 - fold_sign_changed_comparison and large bools
Richard Biener [Tue, 28 Jun 2022 08:50:34 +0000 (10:50 +0200)]
middle-end/106053 - fold_sign_changed_comparison and large bools

The following fixes a latent issue in the match.pd variant of
fold_sign_changed_comparison which replaces an unsigned integer
comparison with a signed boolean comparison of the same precision
despite the fact that we treat BOOLEAN_TYPEs as only having two
valid values.

2022-06-28  Richard Biener  <rguenther@suse.de>

PR middle-end/106053
* match.pd ((T)a == (T)b): Avoid folding away sign
changes in a comparison if we'd truncate to a boolean.

* gcc.target/i386/pr106053.c: New testcase.

2 years agolibgomp: fix typo in mold linker detection
Martin Liska [Tue, 28 Jun 2022 08:34:56 +0000 (10:34 +0200)]
libgomp: fix typo in mold linker detection

libgomp/ChangeLog:

* acinclude.m4: Fix typo in mold linker detection.
* Makefile.in: Regenerate.
* configure: Regenerate.

2 years agolibstdc++: testsuite: Guard use of C99 std::log2
Jonathan Wakely [Tue, 28 Jun 2022 08:17:06 +0000 (09:17 +0100)]
libstdc++: testsuite: Guard use of C99 std::log2

This prevents the test from failing if the only thing not supported is
the text printed to the log about the size of the floating-point type.

libstdc++-v3/ChangeLog:

* testsuite/20_util/from_chars/4.cc: Only use log2 if C99 math
functions are available.

2 years agoMAINTAINERS: Add myself for write after approval
konglin1 [Mon, 27 Jun 2022 09:28:10 +0000 (17:28 +0800)]
MAINTAINERS: Add myself for write after approval

ChangeLog:

* MAINTAINERS (Write After Approval): Add myself.

2 years agors6000: Simplify *rotl<mode>3_insert_4 by removing DImode
Kewen Lin [Tue, 28 Jun 2022 02:50:26 +0000 (21:50 -0500)]
rs6000: Simplify *rotl<mode>3_insert_4 by removing DImode

define_insn *rotl<mode>3_insert_4 use mode iterator GPR which
consists of SImode and conditional DImode, but the condition
of this define_insn requires the mode should be SImode.  By
further checking, it's found that the rldimi instruction can
not be used for this pattern since the required mask can not
be represented correctly.  We can have the fixed mask end 31
with rlwimi, but can not have the fixed mask end 63 with
rldimi as it has to be (63 - SH) always.

So this patch simplifies this define_insn to use SImode only.

gcc/ChangeLog:

* config/rs6000/rs6000.md (*rotl<mode>3_insert_4): Replace mode
iterator GPR with SImode, adjust the condition and output template,
rename to ...
(*rotlsi3_insert_4): ... this.

2 years agoDaily bump.
GCC Administrator [Tue, 28 Jun 2022 00:16:58 +0000 (00:16 +0000)]
Daily bump.

2 years agoc++: avoid <memory> poisoning on musl [PR106102]
Sergei Trofimovich [Mon, 27 Jun 2022 12:27:24 +0000 (13:27 +0100)]
c++: avoid <memory> poisoning on musl [PR106102]

On musl <pthread.h> uses calloc() (via <sched.h>). <memory> includes
it indirectly and exposes use of poisoned calloc() when module code
is built:

    /build/build/./prev-gcc/xg++ ... ../../gcc-13-20220626/gcc/cp/mapper-resolver.cc
        In file included from /<<NIX>>/musl-1.2.3-dev/include/pthread.h:30,
                 from /build/build/prev-x86_64-unknown-linux-musl/libstdc++-v3/include/x86_64-unknown-linux-musl/bits/gthr-default.h:35,
                 ....
                 from /build/build/prev-x86_64-unknown-linux-musl/libstdc++-v3/include/memory:77,
                 from ../../gcc-13-20220626/gcc/../libcody/cody.hh:24,
                 from ../../gcc-13-20220626/gcc/cp/../../c++tools/resolver.h:25,
                 from ../../gcc-13-20220626/gcc/cp/../../c++tools/resolver.cc:23,
                 from ../../gcc-13-20220626/gcc/cp/mapper-resolver.cc:32:
    /<<NIX>>/musl-1.2.3-dev/include/sched.h:84:7: error: attempt to use poisoned "calloc"
       84 | void *calloc(size_t, size_t);
          |       ^
    /<<NIX>>/musl-1.2.3-dev/include/sched.h:124:36: error: attempt to use poisoned "calloc"
      124 | #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n)))
          |                                    ^

gcc/cp/

PR c++/106102
* mapper-client.cc: Include <memory> via "system.h".
* mapper-resolver.cc: Ditto.
* module.cc: Ditto.

libcc1/

PR c++/106102
* libcc1plugin.cc: Include <memory> via "system.h".
* libcp1plugin.cc: Ditto.

2 years agoAdd 'final' and 'override' in various places
David Malcolm [Mon, 27 Jun 2022 21:00:34 +0000 (17:00 -0400)]
Add 'final' and 'override' in various places

gcc/cp/ChangeLog:
* cxx-pretty-print.h: Add "final" and "override" to various vfunc
implementations, removing redundant "virtual" as appropriate.
* module.cc: Likewise.

gcc/ChangeLog:
* genmatch.cc: Add "final" and "override" to various vfunc
implementations, removing redundant "virtual" as appropriate.
* gensupport.cc: Likewise.
* gimple-range-cache.h: Likewise.
* ipa-icf-gimple.h: Likewise.
* ipa-icf.h: Likewise.
* read-md.h: Likewise.
* read-rtl-function.cc: Likewise.
* tree-ssa-loop-ch.cc: Likewise.
* tree-ssa-sccvn.cc: Likewise.

gcc/lto/ChangeLog:
* lto-dump.cc: Add "final" and "override" to various vfunc
implementations, removing redundant "virtual" as appropriate.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoi386: add 'final' and 'override' to scalar_chain vfunc impls
David Malcolm [Mon, 27 Jun 2022 21:00:34 +0000 (17:00 -0400)]
i386: add 'final' and 'override' to scalar_chain vfunc impls

gcc/ChangeLog:
* config/i386/i386-features.h: Add "final" and "override" to
scalar_chain vfunc implementations as appropriate.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agotree-switch-conversion.h: use final/override for cluster vfunc impls
David Malcolm [Mon, 27 Jun 2022 21:00:33 +0000 (17:00 -0400)]
tree-switch-conversion.h: use final/override for cluster vfunc impls

gcc/ChangeLog:
* tree-switch-conversion.h: Add "final" and "override" to cluster
vfunc implementations as appropriate.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoexpr.cc: use final/override on op_by_pieces_d vfuncs
David Malcolm [Mon, 27 Jun 2022 21:00:33 +0000 (17:00 -0400)]
expr.cc: use final/override on op_by_pieces_d vfuncs

gcc/ChangeLog:
* expr.cc: Add "final" and "override" to op_by_pieces_d vfunc
implementations as appropriate.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoAdd 'final' and 'override' on dom_walker vfunc impls
David Malcolm [Mon, 27 Jun 2022 21:00:33 +0000 (17:00 -0400)]
Add 'final' and 'override' on dom_walker vfunc impls

gcc/ChangeLog:
* compare-elim.cc: Add "final" and "override" to dom_walker vfunc
implementations, removing redundant "virtual" as appropriate.
* gimple-ssa-strength-reduction.cc: Likewise.
* ipa-prop.cc: Likewise.
* rtl-ssa/blocks.cc: Likewise.
* tree-into-ssa.cc: Likewise.
* tree-ssa-dom.cc: Likewise.
* tree-ssa-math-opts.cc: Likewise.
* tree-ssa-phiopt.cc: Likewise.
* tree-ssa-propagate.cc: Likewise.
* tree-ssa-sccvn.cc: Likewise.
* tree-ssa-strlen.cc: Likewise.
* tree-ssa-uncprop.cc: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoAdd 'final' and 'override' to opt_pass vfunc impls
David Malcolm [Mon, 27 Jun 2022 21:00:33 +0000 (17:00 -0400)]
Add 'final' and 'override' to opt_pass vfunc impls

gcc/ChangeLog:
* adjust-alignment.cc: Add "final" and "override" to opt_pass
vfunc implementations, removing redundant "virtual" as
appropriate.
* asan.cc: Likewise.
* auto-inc-dec.cc: Likewise.
* auto-profile.cc: Likewise.
* bb-reorder.cc: Likewise.
* cfgcleanup.cc: Likewise.
* cfgexpand.cc: Likewise.
* cfgrtl.cc: Likewise.
* cgraphbuild.cc: Likewise.
* combine-stack-adj.cc: Likewise.
* combine.cc: Likewise.
* compare-elim.cc: Likewise.
* config/i386/i386-features.cc: Likewise.
* coroutine-passes.cc: Likewise.
* cprop.cc: Likewise.
* cse.cc: Likewise.
* dce.cc: Likewise.
* df-core.cc: Likewise.
* dse.cc: Likewise.
* dwarf2cfi.cc: Likewise.
* early-remat.cc: Likewise.
* except.cc: Likewise.
* final.cc: Likewise.
* function.cc: Likewise.
* fwprop.cc: Likewise.
* gcse.cc: Likewise.
* gimple-harden-conditionals.cc: Likewise.
* gimple-if-to-switch.cc: Likewise.
* gimple-isel.cc: Likewise.
* gimple-laddress.cc: Likewise.
* gimple-loop-interchange.cc: Likewise.
* gimple-loop-jam.cc: Likewise.
* gimple-loop-versioning.cc: Likewise.
* gimple-low.cc: Likewise.
* gimple-ssa-backprop.cc: Likewise.
* gimple-ssa-evrp.cc: Likewise.
* gimple-ssa-isolate-paths.cc: Likewise.
* gimple-ssa-nonnull-compare.cc: Likewise.
* gimple-ssa-split-paths.cc: Likewise.
* gimple-ssa-store-merging.cc: Likewise.
* gimple-ssa-strength-reduction.cc: Likewise.
* gimple-ssa-warn-access.cc: Likewise.
* gimple-ssa-warn-alloca.cc: Likewise.
* gimple-ssa-warn-restrict.cc: Likewise.
* gimple-warn-recursion.cc: Likewise.
* graphite.cc: Likewise.
* ifcvt.cc: Likewise.
* init-regs.cc: Likewise.
* ipa-comdats.cc: Likewise.
* ipa-cp.cc: Likewise.
* ipa-devirt.cc: Likewise.
* ipa-fnsummary.cc: Likewise.
* ipa-free-lang-data.cc: Likewise.
* ipa-icf.cc: Likewise.
* ipa-inline.cc: Likewise.
* ipa-modref.cc: Likewise.
* ipa-profile.cc: Likewise.
* ipa-pure-const.cc: Likewise.
* ipa-reference.cc: Likewise.
* ipa-split.cc: Likewise.
* ipa-sra.cc: Likewise.
* ipa-visibility.cc: Likewise.
* ipa.cc: Likewise.
* ira.cc: Likewise.
* jump.cc: Likewise.
* loop-init.cc: Likewise.
* lower-subreg.cc: Likewise.
* mode-switching.cc: Likewise.
* modulo-sched.cc: Likewise.
* multiple_target.cc: Likewise.
* omp-expand.cc: Likewise.
* omp-low.cc: Likewise.
* omp-oacc-kernels-decompose.cc: Likewise.
* omp-oacc-neuter-broadcast.cc: Likewise.
* omp-offload.cc: Likewise.
* omp-simd-clone.cc: Likewise.
* passes.cc: Likewise.
* postreload-gcse.cc: Likewise.
* postreload.cc: Likewise.
* predict.cc: Likewise.
* recog.cc: Likewise.
* ree.cc: Likewise.
* reg-stack.cc: Likewise.
* regcprop.cc: Likewise.
* reginfo.cc: Likewise.
* regrename.cc: Likewise.
* reorg.cc: Likewise.
* sancov.cc: Likewise.
* sanopt.cc: Likewise.
* sched-rgn.cc: Likewise.
* stack-ptr-mod.cc: Likewise.
* store-motion.cc: Likewise.
* tracer.cc: Likewise.
* trans-mem.cc: Likewise.
* tree-call-cdce.cc: Likewise.
* tree-cfg.cc: Likewise.
* tree-cfgcleanup.cc: Likewise.
* tree-complex.cc: Likewise.
* tree-eh.cc: Likewise.
* tree-emutls.cc: Likewise.
* tree-if-conv.cc: Likewise.
* tree-into-ssa.cc: Likewise.
* tree-loop-distribution.cc: Likewise.
* tree-nrv.cc: Likewise.
* tree-object-size.cc: Likewise.
* tree-parloops.cc: Likewise.
* tree-predcom.cc: Likewise.
* tree-profile.cc: Likewise.
* tree-sra.cc: Likewise.
* tree-ssa-ccp.cc: Likewise.
* tree-ssa-copy.cc: Likewise.
* tree-ssa-dce.cc: Likewise.
* tree-ssa-dom.cc: Likewise.
* tree-ssa-dse.cc: Likewise.
* tree-ssa-forwprop.cc: Likewise.
* tree-ssa-ifcombine.cc: Likewise.
* tree-ssa-loop-ch.cc: Likewise.
* tree-ssa-loop-im.cc: Likewise.
* tree-ssa-loop-ivcanon.cc: Likewise.
* tree-ssa-loop-prefetch.cc: Likewise.
* tree-ssa-loop-split.cc: Likewise.
* tree-ssa-loop-unswitch.cc: Likewise.
* tree-ssa-loop.cc: Likewise.
* tree-ssa-math-opts.cc: Likewise.
* tree-ssa-phiopt.cc: Likewise.
* tree-ssa-phiprop.cc: Likewise.
* tree-ssa-pre.cc: Likewise.
* tree-ssa-reassoc.cc: Likewise.
* tree-ssa-sccvn.cc: Likewise.
* tree-ssa-sink.cc: Likewise.
* tree-ssa-strlen.cc: Likewise.
* tree-ssa-structalias.cc: Likewise.
* tree-ssa-uncprop.cc: Likewise.
* tree-ssa-uninit.cc: Likewise.
* tree-ssanames.cc: Likewise.
* tree-stdarg.cc: Likewise.
* tree-switch-conversion.cc: Likewise.
* tree-tailcall.cc: Likewise.
* tree-vect-generic.cc: Likewise.
* tree-vectorizer.cc: Likewise.
* tree-vrp.cc: Likewise.
* tsan.cc: Likewise.
* ubsan.cc: Likewise.
* var-tracking.cc: Likewise.
* vtable-verify.cc: Likewise.
* web.cc: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agolibbacktrace: replace fgrep with grep in configure script
Ian Lance Taylor [Mon, 27 Jun 2022 19:57:23 +0000 (12:57 -0700)]
libbacktrace: replace fgrep with grep in configure script

Patch by Xi Ruoyao.

* configure.ac: Use grep instead of fgrep.
* configure, Makefile.in: Regenerate.

2 years agoc++: Add fixed test [PR89197]
Marek Polacek [Mon, 27 Jun 2022 18:52:58 +0000 (14:52 -0400)]
c++: Add fixed test [PR89197]

Fixed since bug 97899 was fixed.

PR c++/89197

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/initlist130.C: New test.

2 years agocompiler: don't use sink as parameter in method expression thunk
Ian Lance Taylor [Mon, 27 Jun 2022 04:52:35 +0000 (21:52 -0700)]
compiler: don't use sink as parameter in method expression thunk

Also fix a couple of cases where the error led to a later compiler crash.

Test case is https://go.dev/cl/414336.

Fixes golang/go#52871

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/414354

2 years agocompiler: always initialize mpfr in integer import
Ian Lance Taylor [Sat, 25 Jun 2022 00:18:15 +0000 (17:18 -0700)]
compiler: always initialize mpfr in integer import

Test case is https://go.dev/cl/413980.

Fixes golang/go#52862

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/413981

2 years agoamdgcn: test global constructors
Andrew Stubbs [Wed, 22 Jun 2022 13:42:06 +0000 (14:42 +0100)]
amdgcn: test global constructors

The tests are disabled for historical reasons only.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp (check_effective_target_global_constructor):
Remove amdgcn.

2 years agotestsuite: Fix up pr106070.c test [PR106070]
Jakub Jelinek [Mon, 27 Jun 2022 13:35:25 +0000 (15:35 +0200)]
testsuite: Fix up pr106070.c test [PR106070]

The test FAILs on 32-bit targets, because when unsigned long
is 32-bit, (unsigned long) -1 isn't 0xffffffffffffffff.
The options to fix this would be either using -1UL, or switch
to unsigned long long and using -1ULL, I chose the latter because
the test then FAILs in r13-1242 even on 32-bit targets.
And while at it, some deobfuscation and formatting tweaks.

2022-06-27  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/106070
* gcc.dg/torture/pr106070.c: Use unsigned long long instead of
unsigned long and -1ULL instead of 0xffffffffffffffff, deobcuscate
and improve formatting.

2 years agolibstdc++: testsuite: use cmath long double overloads
Alexandre Oliva [Mon, 27 Jun 2022 13:34:19 +0000 (10:34 -0300)]
libstdc++: testsuite: use cmath long double overloads

In case we need to supplement the C standard library with additional
definitions for float and long double, the declarations expected to be
in the C headers may not be there.  Rely on the cmath overloads
instead.

for  libstdc++-v3/ChangeLog

* testsuite/20_util/to_chars/long_double.cc: Use cmath
long double overloads for nexttoward and ldexp.

2 years agolibstdc++: testsuite: require cmath for exp simd
Alexandre Oliva [Mon, 27 Jun 2022 13:34:19 +0000 (10:34 -0300)]
libstdc++: testsuite: require cmath for exp simd

simd_math.h assumes declarations for many C99 functions to be present,
that libstdc++ doesn't add to target systems that don't have them in
the C library.

Add the C99 math requirement to tests for simd features, so that they
don't fail because of limitations of the target C library.

for  libstdc++-v3/ChangeLog

* testsuite/experimental/simd/standard_abi_usable.cc: Require
cmath support.
* testsuite/experimental/simd/standard_abi_usable_2.cc:
Likewise.

2 years agolibstdc++: testsuite: complex proj requirements
Alexandre Oliva [Mon, 27 Jun 2022 13:34:18 +0000 (10:34 -0300)]
libstdc++: testsuite: complex proj requirements

The template version of complex::proj returns its argument without
testing for infinities, and that's all we have when neither C99
complex nor C99 math functions are available, and it seems too hard to
do better without isinf and copysign.

I suppose just calling them and expecting users will supply
specializations as needed has been ruled out, and so has refraining
from defining it when it can't be implemented correctly.

It's pointless to run the proj.cc test under these circumstances, so
arrange for it to be skipped.  In an unusual way, after trying to
introduce dg-require tests for ccomplex-or-cmath, and found their
results to be misleading due to variations across -std=* versions.

for  libstdc++-v3/ChangeLog

* testsuite/26_numerics/complex/proj.cc: Skip test in the
circumstances in which the implementation of proj is known to
be broken.

2 years agotestsuite: pthread: call sched_yield for non-preemptive targets
Alexandre Oliva [Mon, 27 Jun 2022 13:34:17 +0000 (10:34 -0300)]
testsuite: pthread: call sched_yield for non-preemptive targets

Systems without preemptive multi-threading require sched_yield calls
to be placed at points in which a context switch might be needed to
enable the test to complete.

for  gcc/testsuite/ChangeLog

* gcc.dg/atomic/c11-atomic-exec-4.c: Call sched_yield.
* gcc.dg/atomic/c11-atomic-exec-5.c: Likewise.
* gcc.dg/atomic/pr80640-2.c: Likewise.
* gcc.dg/atomic/pr80640.c: Likewise.
* gcc.dg/atomic/pr81316.c: Likewise.
* gcc.dg/di-sync-multithread.c: Likewise.

2 years agolibstdc++: check for openat with dirfd in std::filesystem
Alexandre Oliva [Mon, 27 Jun 2022 13:34:16 +0000 (10:34 -0300)]
libstdc++: check for openat with dirfd in std::filesystem

In the recent patch to check for openat, I missed an occurrence of
dirfd in std::filesystem.

for  libstdc++-v3/ChangeLog

* src/c++17/fs_dir.cc (dir_and_pathname): Use dirfd if
_GLIBCXX_HAVE_OPENAT.

2 years agolibstdc++: testsuite: conditionalize another symlink test
Alexandre Oliva [Mon, 27 Jun 2022 13:34:15 +0000 (10:34 -0300)]
libstdc++: testsuite: conditionalize another symlink test

In the recent patch that introduced NO_SYMLINKS, I missed one of the
testcases that created symlinks.

for  libstdc++-v3/ChangeLog

* testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc
(test06): Don't create symlinks when NO_SYMLINKS is defined.

2 years agolibstdc++: xfail experimental/net tests on rtems
Alexandre Oliva [Mon, 27 Jun 2022 13:34:14 +0000 (10:34 -0300)]
libstdc++: xfail experimental/net tests on rtems

Some net/timer/waitable tests fail on rtems because poll() is not
available.

The above, as well as net/internet/resolver/ops tests and
net/timer/waitable/cons.cc, will fail early at runtime unless mkfifo
is enabled in the RTEMS configuration, because the io_context ctor
throws when pipe() fails.

However, even enabling pipes and adjusting the net_ts link command to
use --gc-sections for -lbsd as recommended, both
net/internet/resolver/ops still fail at runtime.

for  libstdc++-v3/ChangeLog

* testsuite/lib/dg-options.exp (add_options_for_net_ts):
Add -Wl,--gc-sections for RTEMS targets.
* testsuite/experimental/net/timer/waitable/dest.cc: Link-time
xfail on RTEMS.
* testsuite/experimental/net/timer/waitable/ops.cc: Likewise.
* testsuite/experimental/net/internet/resolver/ops/lookup.cc:
Execution-time xfail on RTEMS.
* testsuite/experimental/net/internet/resolver/ops/reverse.cc:
Likewise.

2 years agoamdgcn: remove obsolete assembler workarounds
Andrew Stubbs [Sat, 11 Jun 2022 23:16:24 +0000 (00:16 +0100)]
amdgcn: remove obsolete assembler workarounds

This nonsense is no longer required, now that the minimum supported
assembler version is LLVM 13.0.1.

gcc/ChangeLog:

* config/gcn/gcn.md (*movbi): Remove assembler bug workarounds.
(jump): Likewise.
(movdi_symbol_save_scc): Likewise.

2 years agolibstdc++: testsuite: Add missing <string> header
Jonathan Wakely [Fri, 24 Jun 2022 14:13:12 +0000 (15:13 +0100)]
libstdc++: testsuite: Add missing <string> header

libstdc++-v3/ChangeLog:

* testsuite/ext/mt_allocator/22309_thread.cc: Include <string>.

2 years agolibstdc++: testsuite: avoid predicable mkstemp
Joel Brobecker [Thu, 23 Jun 2022 12:12:12 +0000 (13:12 +0100)]
libstdc++: testsuite: avoid predicable mkstemp

We have noticed that, on RTEMS, a small number of testscases are
failing because two calls to this method return the same filename.
This happens for instance in 27_io/filesystem/operations/copy_file.cc
where it does:

  auto from = __gnu_test::nonexistent_path();
  auto to = __gnu_test::nonexistent_path();

We tracked this issue down to the fact that the implementation of
mkstemp on that system appears to use a very predictable algorithm
for chosing the name of the temporary file, where the same filename
appears to be tried in the same order, regardless of past calls.
So, as long as the file gets deleted after a call to mkstemp (something
we do here in our nonexistent_path method), the next call to mkstemps
ends up returning the same filename, causing the collision we se above.

This commit enhances the __gnu_test::nonexistent_path method to
introduce in the filename being returned a counter which gets
incremented at every call of this method.

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

* testsuite/util/testsuite_fs.h (__gnu_test::nonexistent_path):
Always include a counter in the filename returned.

2 years agolibstdc++: Make std::move_only_function never valueless in std::variant
Jonathan Wakely [Thu, 23 Jun 2022 17:42:55 +0000 (18:42 +0100)]
libstdc++: Make std::move_only_function never valueless in std::variant

This is not suitable to backport, as it affects the ABI of std::variant
and so isn't appropriate for a release branch.

libstdc++-v3/ChangeLog:

* include/bits/move_only_function.h (_Never_valueless_alt):
Define partial specialization for std::move_only_function.

2 years agolibstdc++: Simplify std::variant construction using variable templates
Jonathan Wakely [Thu, 23 Jun 2022 17:41:17 +0000 (18:41 +0100)]
libstdc++: Simplify std::variant construction using variable templates

libstdc++-v3/ChangeLog:

* include/std/variant (_Build_FUN::_S_fun): Define fallback case
as deleted.
(__accepted_index, _Extra_visit_slot_needed): Replace class
templates with variable templates.

2 years agolibstdc++: Simplify fs::path construction using variable template
Jonathan Wakely [Thu, 23 Jun 2022 17:39:50 +0000 (18:39 +0100)]
libstdc++: Simplify fs::path construction using variable template

libstdc++-v3/ChangeLog:

* include/bits/fs_path.h (__is_path_iter_src): Replace class
template with variable template.

2 years agolibstdc++: Invert relationship between std::is_clock and std::is_clock_v
Jonathan Wakely [Thu, 23 Jun 2022 17:17:30 +0000 (18:17 +0100)]
libstdc++: Invert relationship between std::is_clock and std::is_clock_v

This redefines std::is_clock in terms of std::is_clock_v, instead of the
other way around. This avoids instantiatng the class template for code
that only uses the variable template.

libstdc++-v3/ChangeLog:

* include/bits/chrono.h (is_clock_v): Define to false.
(is_clock_v<T>): Define partial specialization for true cases.
(is_clock): Define in terms of is_clock_v.

2 years ago[gdb/build] Fix gdbserver build with -fsanitize=thread
Tom de Vries [Mon, 27 Jun 2022 08:46:58 +0000 (10:46 +0200)]
[gdb/build] Fix gdbserver build with -fsanitize=thread

When building gdbserver with -fsanitize=thread (added to CFLAGS/CXXFLAGS) we
run into:
...
ld: ../libiberty/libiberty.a(safe-ctype.o): warning: relocation against \
  `__tsan_init' in read-only section `.text'
ld: ../libiberty/libiberty.a(safe-ctype.o): relocation R_X86_64_PC32 \
  against symbol `__tsan_init' can not be used when making a shared object; \
  recompile with -fPIC
ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make[1]: *** [libinproctrace.so] Error 1
...
which looks similar to what is described in commit 78e49486944 ("[gdb/build]
Fix gdbserver build with -fsanitize=address").

The gdbserver component builds a shared library libinproctrace.so, which uses
libiberty and therefore requires the pic variant.  The gdbserver Makefile is
setup to use this variant, if available, but it's not there.

Fix this by listing gdbserver in the toplevel configure alongside libcc1, as a
component that needs the libiberty pic variant, setting:
...
extra_host_libiberty_configure_flags=--enable-shared
...

Tested on x86_64-linux.

ChangeLog:

2022-06-27  Tom de Vries  <tdevries@suse.de>

* configure.ac: Build libiberty pic variant for gdbserver.
* configure: Regenerate.

2 years agolto-plugin: make claim_file_handler thread-safe
Martin Liska [Mon, 16 May 2022 12:18:41 +0000 (14:18 +0200)]
lto-plugin: make claim_file_handler thread-safe

lto-plugin/ChangeLog:

* lto-plugin.c (plugin_lock): New lock.
(claim_file_handler): Use mutex for critical section.
(onload): Initialize mutex.
* configure.ac: Check for pthread.h.
* configure: Regenerate.
* config.h.in: Regenerate.

2 years agoImplement __imag__ of float _Complex using shufps on x86_64.
Roger Sayle [Mon, 27 Jun 2022 06:47:40 +0000 (07:47 +0100)]
Implement __imag__ of float _Complex using shufps on x86_64.

This patch is a follow-up improvement to my recent patch for
PR rtl-optimization/7061.  That patch added the test case
gcc.target/i386/pr7061-2.c:

float im(float _Complex a) { return __imag__ a; }

For which GCC on x86_64 currently generates:

        movq    %xmm0, %rax
        shrq    $32, %rax
        movd    %eax, %xmm0
        ret

but with this patch we now generate (the same as LLVM):

        shufps  $85, %xmm0, %xmm0
        ret

This is achieved by providing a define_insn_and_split that allows
truncated lshiftrt:DI by 32 to be performed on either SSE or general
regs, where if the register allocator prefers to use SSE, we split
to a shufps_v4si, or if not, we use a regular shrq.

2022-06-27  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
PR rtl-optimization/7061
* config/i386/i386.md (*highpartdisi2): New define_insn_and_split.

gcc/testsuite/ChangeLog
PR rtl-optimization/7061
* gcc.target/i386/pr7061-2.c: Update to look for shufps.

2 years ago[PATCH] PR tree-optimization/94026: Simplify (X>>8)&6 != 0 as X&1536 != 0.
Roger Sayle [Mon, 27 Jun 2022 06:44:49 +0000 (07:44 +0100)]
[PATCH] PR tree-optimization/94026: Simplify (X>>8)&6 != 0 as X&1536 != 0.

This patch implements the missed optimization described in PR 94026,
where a the shift can be eliminated from the sequence of a shift,
followed by a bit-wise AND followed by an equality/inequality test.
Specifically, ((X << C1) & C2) cmp C3 into (X & (C2 >> C1)) cmp (C3 >> C1)
and likewise ((X >> C1) & C2) cmp C3 into (X & (C2 << C1)) cmp (C3 << C1)
where cmp is == or !=, and C1, C2 and C3 are integer constants.
The example in the subject line is taken from the hot function
self_atari from the Go program Leela (in SPEC CPU 2017).

2022-06-27  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
PR tree-optimization/94026
* match.pd (((X << C1) & C2) eq/ne C3): New simplification.
(((X >> C1) & C2) eq/ne C3): Likewise.

gcc/testsuite/ChangeLog
PR tree-optimization/94026
* gcc.dg/pr94026.c: New test case.

2 years agoEmit asmname if set for decl with -fdump-statistics-asmname.
Prathamesh Kulkarni [Mon, 27 Jun 2022 06:25:45 +0000 (11:55 +0530)]
Emit asmname if set for decl with -fdump-statistics-asmname.

gcc/ChangeLog:

* statistics.cc: Include tree.h.
(get_function_name): New function.
(statistics_fini_pass_2): Call get_function_name instead of
current_function_name.
(statistics_counter_event): Call get_function_name instead of
function_name.
(statistics_histogram_event): Likewise.

2 years agoxtensa: Optimize integer constant addition that is between -32896 and 32639
Takayuki 'January June' Suwa [Sun, 26 Jun 2022 13:28:30 +0000 (22:28 +0900)]
xtensa: Optimize integer constant addition that is between -32896 and 32639

Such constants are often subject to the constant synthesis:

    int test(int a) {
      return a - 31999;
    }

    test:
movi a3, 1
addmi a3, a3, -0x7d00
add a2, a2, a3
ret

This patch optimizes such case as follows:

    test:
addi a2, a2, 1
addmi a2, a2, -0x7d00
ret

gcc/ChangeLog:

* config/xtensa/xtensa.md:
Suppress unnecessary emitting nop insn in the split patterns for
integer/FP constant synthesis, and add new peephole2 pattern that
folds such synthesized additions.

2 years agoDaily bump.
GCC Administrator [Mon, 27 Jun 2022 00:16:20 +0000 (00:16 +0000)]
Daily bump.

2 years agoFortran: fix simplification of INDEX(str1,str2) [PR105691]
Harald Anlauf [Tue, 21 Jun 2022 21:20:18 +0000 (23:20 +0200)]
Fortran: fix simplification of INDEX(str1,str2) [PR105691]

gcc/fortran/ChangeLog:

PR fortran/105691
* simplify.cc (gfc_simplify_index): Replace old simplification
code by the equivalent of the runtime library implementation.  Use
HOST_WIDE_INT instead of int for string index, length variables.

gcc/testsuite/ChangeLog:

PR fortran/105691
* gfortran.dg/index_6.f90: New test.

2 years agoFortran: handle explicit-shape specs with constant bounds [PR105954]
Harald Anlauf [Mon, 20 Jun 2022 18:59:55 +0000 (20:59 +0200)]
Fortran: handle explicit-shape specs with constant bounds [PR105954]

gcc/fortran/ChangeLog:

PR fortran/105954
* decl.cc (variable_decl): Adjust upper bounds for explicit-shape
specs with constant bound expressions to ensure non-negative
extents.

gcc/testsuite/ChangeLog:

PR fortran/105954
* gfortran.dg/pr105954.f90: New test.

2 years ago[PATCH] testsuite: constraint some of fp tests to hard_float
Vineet Gupta [Sun, 26 Jun 2022 19:03:52 +0000 (15:03 -0400)]
[PATCH] testsuite: constraint some of fp tests to hard_float

These tests validate fp conversions with various rounding modes which
would not work on soft-float ABIs.

On -march=rv64imac/-mabi=lp64 this reduces 5 unique failures (overall 35
due to multi flag combination builds)

gcc/testsuite/Changelog:
* gcc.dg/torture/fp-double-convert-float-1.c: Add
dg-require-effective-target hard_float.
* gcc.dg/torture/fp-int-convert-timode-3.c: Ditto.
* gcc.dg/torture/fp-int-convert-timode-4.c: Ditto.
* gcc.dg/torture/fp-uint64-convert-double-1.c: Ditto.
* gcc.dg/torture/fp-uint64-convert-double-2.c: Ditto.

2 years agoMake it easier to rebuild configure files.
Simon Marchi [Sun, 26 Jun 2022 18:43:33 +0000 (14:43 -0400)]
Make it easier to rebuild configure files.

Add

  AC_CONFIG_MACRO_DIRS([../config])

So that just running:

  $ autoreconf -vf

... does the right thing (no need to specify -I ../config).

Note: I don't have access to the gcc repo, so if this patch is approved,
can somebody push it there on my behalf?  I can push it to binutils-gdb.

libiberty/ChangeLog:

* configure.ac: Add AC_CONFIG_MACRO_DIRS call.
* configure: Re-generate.

2 years agolibcpp: Update cpp_wcwidth() to Unicode 14.0.0
Lewis Hyatt [Sun, 26 Jun 2022 18:13:26 +0000 (14:13 -0400)]
libcpp: Update cpp_wcwidth() to Unicode 14.0.0

The procedure detailed in contrib/unicode/README was followed with nothing
notable coming up. The glibc scripts did not require any update, so the
only change was retrieving new versions of the Unicode data files and
rerunning gen_wcwidth.py.

contrib/ChangeLog:

* unicode/EastAsianWidth.txt: Update to Unicode 14.0.0.
* unicode/PropList.txt: Likewise.
* unicode/README: Likewise.
* unicode/UnicodeData.txt: Likewise.

libcpp/ChangeLog:

* generated_cpp_wcwidth.h: Generated from updated Unicode data files.

2 years agotestsuite: Adjust btf-bitfields-1.c for default_packed
Dimitar Dimitrov [Fri, 22 Apr 2022 17:27:22 +0000 (20:27 +0300)]
testsuite: Adjust btf-bitfields-1.c for default_packed

If target packs structures by default, the bitfield offset which the
test validates must be adjusted to not include padding.

gcc/testsuite/ChangeLog:

* gcc.dg/debug/btf/btf-bitfields-1.c: Adjust the checked offsets
for targets which pack structures by default.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2 years agoXFAIL a test in g++.dg/warn/Wstringop-overflow-4.C
Aldy Hernandez [Sun, 26 Jun 2022 15:30:18 +0000 (17:30 +0200)]
XFAIL a test in g++.dg/warn/Wstringop-overflow-4.C

As per the explanation in the test, and in the DOM conversion to
ranger patch, this is a known regression.  I had mentioned I would
XFAIL this test, but forgot to do so.  There is an analysis in the
test itself as to what is going on.

Tested on x86-64 Linux.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wstringop-overflow-4.C: XFAIL a test.

2 years agoconfigure, Darwin: Correct a pasto in host-shared processing.
Iain Sandoe [Sun, 26 Jun 2022 08:24:28 +0000 (09:24 +0100)]
configure, Darwin: Correct a pasto in host-shared processing.

We do, of course, mean $host not $target in this case.  Corrected thus.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
ChangeLog:

* configure: Regenerate.
* configure.ac: Correct use of $host.

2 years agoDaily bump.
GCC Administrator [Sun, 26 Jun 2022 00:16:33 +0000 (00:16 +0000)]
Daily bump.

2 years agoConvert DOM to use Ranger rather than EVRP
Aldy Hernandez [Sat, 25 Jun 2022 22:58:02 +0000 (18:58 -0400)]
Convert DOM to use Ranger rather than EVRP

[Jeff, this is the same patch I sent you last week with minor tweaks
to the commit message.]

[Despite the verbosity of the message, this is actually a pretty
straightforward patch.  It should've gone in last cycle, but there
was a nagging regression I couldn't get to until after stage1
had closed.]

There are 3 uses of EVRP in DOM that must be converted.
Unfortunately, they need to be converted in one go, so further
splitting of this patch would be problematic.

There's nothing here earth shattering.  It's all pretty obvious in
retrospect, but I've added a short description of each use to aid in
reviewing:

* Convert evrp use in cprop to ranger.

  This is easy, as cprop in DOM was converted to the ranger API last
  cycle, so this is just a matter of using a ranger instead of an
  evrp_range_analyzer.

* Convert evrp use in threader to ranger.

  The idea here is to use the hybrid approach we used for the initial
  VRP threader conversion last cycle.  The DOM threader will continue
  using the forward threader infrastructure while continuing to query
  DOM data structures, and only if the conditional does not relsolve,
  using the ranger.  This gives us the best of both worlds, and is a
  proven approach.

  Furthermore, as frange and prange come live in the next cycle, we
  can move away from the forward threader altogether, and just add
  another backward threader.  This will not only remove the last use
  of the forward threader, but will allow us to remove at least 1 or 2
  threader instances.

* Convert conditional folding to use the method used by the ranger and
  evrp.  Previously DOM was calling into the guts of
  simplify_using_ranges::vrp_visit_cond_stmt.  The blessed way now is
  using fold_cond() which rewrites the conditional and edges
  automatically.

  When legacy is removed, simplify_using_ranges will be further
  cleaned up, and there will only be one entry point into simplifying
  a statement.

* DOM was setting global ranges determined from unreachable edges as a
  side-effect of using the evrp engine.  We must handle these cases
  before nuking evrp, and DOM seems like a good fit.  I've just moved
  the snippet to DOM, but it could live anywhere else we do a DOM
  walk.

  For the record, this is the case *vrp handled:

<bb C>:
...
if (c_5(D) != 5)
goto <bb N>;
else
goto <bb M>;
<bb N>:
__builtin_unreachable ();
<bb M>:

  If M dominates all uses of c_5, we can set the global range of c_5
  to [5,5].

I have tested on x86-64, pcc64le, and aarch64 Linux.

I also ran threading benchmarks as well as performance benchmarks.

DOM threads 1.56% more paths which ultimately yields a miniscule total
increase of 0.03%.

The conversion to ranger brings a 7.87% performance drop in DOM, which
is a wash in overall compilation.  This is in line with other
replacements of legacy evrp with ranger.  We handle a lot more cases.
It's not free .

There is a a regression on Wstringop-overflow-4.C which I'm planning
on XFAILing.  It's another variant of the usual middle-end false
positives: having no ranges produces no warnings, but slightly refined
ranges, or worse-- isolating specific problematic cases in the
threader causes flare-ups.

As an aside, as Richi has suggested, I think we should discuss
restricting the threader's ability to thread highly unlikely paths.
These cause no end of pain for middle-end warnings.  However,
I don't know if this would conflict with path isolation for
things like null dereferencing.  ISTR you were interested in this.

BTW, I think the Wstringop-overflow-4.C test is problematic and I've
attached my analysis.  Basically the regression is caused by a bad
interaction with the rounding/alignment that placement new has inlined
into the IL.  This happens for int16_r[] which the test is testing.
Ranger can glean some range info, which causes DOM threading to
isolate a path which causes a warning.

OK for trunk?

gcc/ChangeLog:

* tree-ssa-dom.cc (dom_jt_state): Pass ranger to constructor
instead of evrp.
(dom_jt_state::push): Remove m_evrp.
(dom_jt_state::pop): Same.
(dom_jt_state::record_ranges_from_stmt): Remove.
(dom_jt_state::register_equiv): Remove updating of evrp ranges.
(class dom_jt_simplifier): Pass ranger to constructor.
Inherit from hybrid_jt_simplifier.
(dom_jt_simplifier::simplify): Convert to ranger.
(pass_dominator::execute): Same.
(all_uses_feed_or_dominated_by_stmt): New.
(dom_opt_dom_walker::set_global_ranges_from_unreachable_edges): New.
(dom_opt_dom_walker::before_dom_children): Call
set_global_ranges_from_unreachable_edges.
Do not call record_ranges_from_stmt.
(dom_opt_dom_walker::after_dom_children): Remove evrp use.
(cprop_operand): Use int_range<> instead of value_range.
(dom_opt_dom_walker::fold_cond): New.
(dom_opt_dom_walker::optimize_stmt): Pass ranger to
cprop_into_stmt.
Use fold_cond() instead of vrp_visit_cond_stmt().
* tree-ssa-threadedge.cc (jt_state::register_equivs_stmt): Do not
pass state to simplifier.
* vr-values.h (class vr_values): Make fold_cond public.

gcc/testsuite/ChangeLog:

* gcc.dg/sancov/cmp0.c: Adjust for conversion to ranger.
* gcc.dg/tree-ssa/ssa-dom-branch-1.c: Same.
* gcc.dg/tree-ssa/ssa-dom-thread-7.c: Same.
* gcc.dg/vect/bb-slp-pr81635-2.c: Same.
* gcc.dg/vect/bb-slp-pr81635-4.c: Same.
* g++.dg/warn/Wstringop-overflow-4.C: Likewise.
* gcc.target/mips/data-sym-multi-pool.c: Likewise.
* gcc.target/mips/mips.exp: Likewise.

2 years agoRemove long deprecated tilegx and tilepro ports
Jeff Law [Sat, 25 Jun 2022 16:36:55 +0000 (12:36 -0400)]
Remove long deprecated tilegx and tilepro ports

/
* MAINTAINERS: Remove tilegx and tilepro entries.
* configure.ac: Remove tilegx and tilepro stanzas.
* configure: Rebuilt.

contrib/
* config-list.mk: Remove tilegx and tilepro entries.
* gcc_update: Remove tilegx and tilepro entries.

gcc/
* common/config/tilegx/tilegx-common.cc: Removed.
* common/config/tilepro/tilepro-common.cc: Removed.
* config.gcc: Remove tilegx and tilepro entries.
* config/tilegx/constraints.md: Removed.
* config/tilegx/feedback.h: Removed.
* config/tilegx/linux.h: Removed.
* config/tilegx/mul-tables.cc: Removed.
* config/tilegx/predicates.md: Removed.
* config/tilegx/sync.md: Removed.
* config/tilegx/t-tilegx: Removed.
* config/tilegx/tilegx-builtins.h: Removed.
* config/tilegx/tilegx-c.cc: Removed.
* config/tilegx/tilegx-generic.md: Removed.
* config/tilegx/tilegx-modes.def: Removed.
* config/tilegx/tilegx-multiply.h: Removed.
* config/tilegx/tilegx-opts.h: Removed.
* config/tilegx/tilegx-protos.h: Removed.
* config/tilegx/tilegx.cc: Removed.
* config/tilegx/tilegx.h: Removed.
* config/tilegx/tilegx.md: Removed.
* config/tilegx/tilegx.opt: Removed.
* config/tilepro/constraints.md: Removed.
* config/tilepro/feedback.h: Removed.
* config/tilepro/gen-mul-tables.cc: Removed.
* config/tilepro/linux.h: Removed.
* config/tilepro/mul-tables.cc: Removed.
* config/tilepro/predicates.md: Removed.
* config/tilepro/t-tilepro: Removed.
* config/tilepro/tilepro-builtins.h: Removed.
* config/tilepro/tilepro-c.cc: Removed.
* config/tilepro/tilepro-generic.md: Removed.
* config/tilepro/tilepro-modes.def: Removed.
* config/tilepro/tilepro-multiply.h: Removed.
* config/tilepro/tilepro-protos.h: Removed.
* config/tilepro/tilepro.cc: Removed.
* config/tilepro/tilepro.h: Removed.
* config/tilepro/tilepro.md: Removed.
* config/tilepro/tilepro.opt: Removed.
* configure.ac: Remove tilegx and tilepro entries.
* configure: Rebuilt.
* doc/extend.texi: Remove tilegx and tilepro entries.
* doc/install.texi: Remove tilegx and tilepro entries.
* doc/invoke.texi: Remove tilegx and tilepro entries.
* doc/md.texi: Remove tilegx and tilepro entries.

gcc/testsuite/
* gcc.dg/lower-subreg-1.c: Remove tilegx and tilepro entries.
* gcc.misc-tests/linkage.exp: Remove tilegx and
tilepro entries.

libgcc/
* config.host: Removed tilegx and tilepro entries.
* config/tilegx/sfp-machine.h: Removed.
* config/tilegx/sfp-machine32.h: Removed.
* config/tilegx/sfp-machine64.h: Removed.
* config/tilegx/t-crtstuff: Removed.
* config/tilegx/t-softfp: Removed.
* config/tilegx/t-tilegx: Removed.
* config/tilepro/atomic.c: Removed.
* config/tilepro/atomic.h: Removed.
* config/tilepro/linux-unwind.h: Removed.
* config/tilepro/sfp-machine.h: Removed.
* config/tilepro/softdivide.c: Removed.
* config/tilepro/softmpy.S: Removed.
* config/tilepro/t-crtstuff: Removed.
* config/tilepro/t-tilepro: Removed.

2 years agotestsuite, Darwin: Fix darwin-comm-1.c error messages for Darwin <= 10.
Iain Sandoe [Sat, 25 Jun 2022 08:58:35 +0000 (09:58 +0100)]
testsuite, Darwin: Fix darwin-comm-1.c error messages for Darwin <= 10.

When amending the allowed alignment size to accommodate the larger values
permitted by newer tools, we retained the object file limit of 2^15 for
Darwin versions <= 10, since that is what the native tools expect there.

This triggers a different diagnostic path with a distinct error message,
which is checked in the revised test here.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/testsuite/ChangeLog:

* gcc.dg/darwin-comm-1.c: Check for the correct error message for
Darwin <= 10.

2 years agoIterating cprop_hardreg... Third time's a charm.
Roger Sayle [Sat, 25 Jun 2022 08:35:45 +0000 (09:35 +0100)]
Iterating cprop_hardreg... Third time's a charm.

This middle-end patch proposes the "hard register constant propagation"
pass be performed up to three times on each basic block (up from the
current two times) if the second pass successfully made changes.

The motivation for three passes is to handle the "swap idiom" (i.e.
t = x; x = y; y = t;" sequences) that get generated by register allocation
(reload).

Consider the x86_64 test case for __int128 addition recently discussed
on gcc-patches.  With that proposed patch, the input to the cprop_hardreg
pass looks like:

movq %rdi, %r8
movq %rsi, %rdi
movq %r8, %rsi
        movq    %rdx, %rax
        movq    %rcx, %rdx
        addq    %rsi %rax
        adcq    %rdi, %rdx
        ret

where the first three instructions effectively swap %rsi and %rdi.

On the first pass of cprop_hardreg, we notice that the third insn,
%rsi := %r8, is redundant and can eliminated/propagated to produce:

        movq    %rdi, %r8
        movq    %rsi, %rdi
        movq    %rdx, %rax
        movq    %rcx, %rdx
        addq    %r8 %rax
        adcq    %rdi, %rdx
        ret

Because a successful propagation was found, cprop_hardreg then runs
a second pass/sweep on affected basic blocks (using worklist), and
on this second pass notices that the second instruction, %rdi := %rsi,
may now be propagated (%rsi was killed in the before the first transform),
and after a second pass, we now end up with:

        movq    %rdi, %r8
        movq    %rdx, %rax
        movq    %rcx, %rdx
        addq    %r8, %rax
        adcq    %rsi, %rdx
        ret

which is the current behaviour on mainline.  However, a third and final
pass would now notice that the first insn, "%r8 := %rdi" is also now
eliminable, and a third iteration would produce optimal code:

        movq    %rdx, %rax
        movq    %rcx, %rdx
        addq    %rdi, %rax
        adcq    %rsi, %rdx
        ret

The patch below creates two worklists, and alternates between them on
sucessive passes, populating NEXT with the basic block id's of blocks
that were updated during the current pass over the CURR worklist.
It should be noted that this a regression fix; GCC 4.8 generated
optimal code with two moves (whereas GCC 12 required 5 moves, up
from GCC 11's 4 moves).

2022-06-25  Roger Sayle  <roger@nextmovesoftware.com>
    Richard Biener  <rguenther@suse.de>

gcc/ChangeLog
* regcprop.cc (pass_cprop_hardreg::execute): Perform a third
iteration over each basic block that was updated by the second
iteration.

2 years agointl: stop using fgrep for exgettext
Xi Ruoyao [Fri, 24 Jun 2022 06:27:18 +0000 (14:27 +0800)]
intl: stop using fgrep for exgettext

fgrep has been deprecated in favor of grep -F for a long time, and the
next grep release (3.8 or 4.0) will print a warning of fgrep is used.
And, the fgrep command in exgettext is no longer useful after we
migrated from SVN to Git.  Remove the fgrep command so we won't see the
warning.

gcc/po/ChangeLog:

* exgettext: Remove unneeded fgrep command.

2 years agoDaily bump.
GCC Administrator [Sat, 25 Jun 2022 00:16:23 +0000 (00:16 +0000)]
Daily bump.

2 years agoc++: Include -Woverloaded-virtual in -Wall [PR87729]
Jason Merrill [Fri, 24 Jun 2022 18:40:12 +0000 (14:40 -0400)]
c++: Include -Woverloaded-virtual in -Wall [PR87729]

This seems like a good warning to have in -Wall, as requested.  But as
pointed out in PR20423, some users want a warning only when a derived
function doesn't override any base function.  So let's put that lesser
version in -Wall (and -Woverloaded-virtual=1) while leaving the semantics
for the existing option the same.

PR c++/87729
PR c++/20423

gcc/c-family/ChangeLog:

* c.opt (Woverloaded-virtual): Add levels, include in -Wall.

gcc/ChangeLog:

* doc/invoke.texi: Document changes.

gcc/cp/ChangeLog:

* class.cc (warn_hidden): Handle -Woverloaded-virtual=1.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Woverloaded-virt1.C: New test.
* g++.dg/warn/Woverloaded-virt2.C: New test.

2 years agotestsuite: Skip btf-bitfields-1.c if int is less than 32-bits
Dimitar Dimitrov [Thu, 9 Jun 2022 17:27:32 +0000 (20:27 +0300)]
testsuite: Skip btf-bitfields-1.c if int is less than 32-bits

This test spuriously fails on AVR with:
   error: width of 'bitfield_c' exceeds its type

8-bit and 16-bit microcontrollers do not seem to be the target audience
for BTF file format.  So the least intrusive fix is to simply skip the
test for them.

gcc/testsuite/ChangeLog:

* gcc.dg/debug/btf/btf-bitfields-1.c: Skip if int is less than
32-bits.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2 years agoFortran: fix checking of arguments to UNPACK when MASK is a variable [PR105813]
Harald Anlauf [Fri, 24 Jun 2022 20:21:39 +0000 (22:21 +0200)]
Fortran: fix checking of arguments to UNPACK when MASK is a variable [PR105813]

gcc/fortran/ChangeLog:

PR fortran/105813
* check.cc (gfc_check_unpack): Try to simplify MASK argument to
UNPACK so that checking of the VECTOR argument can work when MASK
is a variable.

gcc/testsuite/ChangeLog:

PR fortran/105813
* gfortran.dg/unpack_vector_1.f90: New test.

2 years agotestsuite: Handle default_packed for gcc.dg/builtin-object-size-20.c
Dimitar Dimitrov [Fri, 13 May 2022 19:46:59 +0000 (22:46 +0300)]
testsuite: Handle default_packed for gcc.dg/builtin-object-size-20.c

The gcc.dg/builtin-object-size-20.c test case assumes that the target
inserts padding between structure members.  Obviously it fails for
targets which pack structures by default.

Split the cases into two tests, so that the ones requiring structure
padding can be skipped for default_packed targets.

gcc/testsuite/ChangeLog:

* gcc.dg/builtin-object-size-20.c: Remove cases which
work on default_packed targets.
* gcc.dg/builtin-object-size-22.c: New test with the cases
removed above.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>