platform/upstream/gcc.git
2 years agoanalyzer: fix hashing of bit_range_region::key_t [PR104452]
David Malcolm [Tue, 8 Feb 2022 21:37:08 +0000 (16:37 -0500)]
analyzer: fix hashing of bit_range_region::key_t [PR104452]

gcc/analyzer/ChangeLog:
PR analyzer/104452
* region-model.cc (selftest::test_bit_range_regions): New.
(selftest::analyzer_region_model_cc_tests): Call it.
* region.h (bit_range_region::key_t::hash): Fix hashing of m_bits
to avoid using uninitialized data.

gcc/testsuite/ChangeLog:
PR analyzer/104452
* gcc.dg/analyzer/pr104452.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoc++: cleanup constant-init'd members [PR96876]
Jason Merrill [Fri, 4 Feb 2022 23:25:51 +0000 (18:25 -0500)]
c++: cleanup constant-init'd members [PR96876]

This is a case missed by my recent fixes to aggregate initialization and
exception cleanup for PR94041 et al: we also need to clean up members with
constant initialization if initialization of a later member throws.

It also occurs to me that we needn't bother building the cleanups if
-fno-exceptions; build_vec_init already doesn't.

PR c++/96876

gcc/cp/ChangeLog:

* typeck2.cc (split_nonconstant_init_1): Push cleanups for
preceding members with constant initialization.
(maybe_push_temp_cleanup): Do nothing if -fno-exceptions.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/aggr-base11.C: New test.
* g++.dg/eh/aggregate2.C: New test.

2 years agoDaily bump.
GCC Administrator [Wed, 9 Feb 2022 00:16:24 +0000 (00:16 +0000)]
Daily bump.

2 years agolibstdc++: Simplify resource management in directory iterators
Jonathan Wakely [Tue, 8 Feb 2022 15:57:58 +0000 (15:57 +0000)]
libstdc++: Simplify resource management in directory iterators

This replaces the _Dir constructor that takes ownership of an existing
DIR* resource with one that takes a _Dir_base rvalue instead. This means
a raw DIR* is never passed around, but is always owned by a _Dir_base
object.

libstdc++-v3/ChangeLog:

* src/c++17/fs_dir.cc (_Dir(DIR*, const path&)): Change first
parameter to _Dir_base&&.
* src/filesystem/dir-common.h (_Dir_base(DIR*)): Remove.
* src/filesystem/dir.cc (_Dir(DIR*, const path&)): Change first
parameter to _Dir_base&&.

2 years agoifcvt: Fix PR104153 and PR104198.
Robin Dapp [Tue, 8 Feb 2022 15:11:20 +0000 (16:11 +0100)]
ifcvt: Fix PR104153 and PR104198.

This is a bugfix for r12-6747-gaa8cfe785953a0 which caused an ICE
on or1k (PR104153) and broke SPARC bootstrap (PR104198).

cond_exec_get_condition () returns the jump condition directly and we
now pass it to the backend.  The or1k backend modified the condition
in-place (other backends do that as well) but this modification is not
reverted when the sequence in question is discarded.  Therefore we copy
the RTX instead of using it directly.

The SPARC problem is due to the SPARC backend recreating the initial
condition when being passed a CC comparison.  This causes the sequence
to read from an already overwritten condition operand.  Generally, this
could also happen on other targets.  The workaround is to always first
emit to a temporary.  In a second run of noce_convert_multiple_sets_1
we know which sequences actually require the comparison and will use no
temporaries if all sequences after the current one do not require it.

PR rtl-optimization/104198
PR rtl-optimization/104153

gcc/ChangeLog:

* ifcvt.cc (noce_convert_multiple_sets_1): Copy rtx instead of
using it directly.  Rework comparison handling and always
perform a second pass.

gcc/testsuite/ChangeLog:

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

2 years agoc++: Don't emit repeated -Wshadow warnings for templates/ctors [PR104379]
Jakub Jelinek [Tue, 8 Feb 2022 19:17:55 +0000 (20:17 +0100)]
c++: Don't emit repeated -Wshadow warnings for templates/ctors [PR104379]

The following patch suppresses extraneous -Wshadow warnings.
On the testcase without the patch we emit 14 -Wshadow warnings,
with the patch just 4.  It is enough to warn once e.g. during parsing of the
template or the abstract ctor, while previously we'd warn also on the clones
of the ctors and on instantiation.
In GCC 8 and earlier we didn't warn because check_local_shadow did
  /* Inline decls shadow nothing.  */
  if (DECL_FROM_INLINE (decl))
    return;

2022-02-08  Jakub Jelinek  <jakub@redhat.com>

PR c++/104379
* name-lookup.cc (check_local_shadow): When diagnosing shadowing
of a member or global declaration, add warning suppression for
the decl and don't warn again on it.

* g++.dg/warn/Wshadow-18.C: New test.

2 years agoc++: Remove superflous assert [PR104403]
Jakub Jelinek [Tue, 8 Feb 2022 19:15:42 +0000 (20:15 +0100)]
c++: Remove superflous assert [PR104403]

I've added the assert because start_decl diagnoses such vars for C++20 and
earlier:
  if (current_function_decl && VAR_P (decl)
      && DECL_DECLARED_CONSTEXPR_P (current_function_decl)
      && cxx_dialect < cxx23)
but as can be seen, we cam trigger the assert in older standards e.g. during
non-manifestly constant evaluation.  Rather than refining the assert that
DECL_EXPRs for such vars don't appear for C++20 and older if they are inside
of functions declared constexpr this patch just removes the assert, the
code rejects encountering those vars in constant expressions anyway.

2022-02-08  Jakub Jelinek  <jakub@redhat.com>

PR c++/104403
* constexpr.cc (cxx_eval_constant_expression): Don't assert DECL_EXPRs
of TREE_STATIC vars may only appear in -std=c++23.

* g++.dg/cpp0x/lambda/lambda-104403.C: New test.

2 years agors6000: Fix up vspltis_shifted [PR102140]
Jakub Jelinek [Tue, 8 Feb 2022 19:14:30 +0000 (20:14 +0100)]
rs6000: Fix up vspltis_shifted [PR102140]

The following testcase ICEs, because
(const_vector:V4SI [
                (const_int 0 [0]) repeated x3
                (const_int -2147483648 [0xffffffff80000000])
            ])
is recognized as valid easy_vector_constant in between split1 pass and
end of RA.
The problem is that such constants need to be split, and the only
splitter for that is:
(define_split
  [(set (match_operand:VM 0 "altivec_register_operand")
        (match_operand:VM 1 "easy_vector_constant_vsldoi"))]
  "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode) && can_create_pseudo_p ()"
There is only a single splitting pass before RA, so after that finishes,
if something gets matched in between that and end of RA (after that
can_create_pseudo_p () would be no longer true), it will never be
successfully split and we ICE at final.cc time or earlier.

The i386 backend (and a few others) already use
(cfun->curr_properties & PROP_rtl_split_insns)
as a test for split1 pass finished, so that some insns that should be split
during split1 and shouldn't be matched afterwards are properly guarded.

So, the following patch does that for vspltis_shifted too.

2022-02-08  Jakub Jelinek  <jakub@redhat.com>

PR target/102140
* config/rs6000/rs6000.cc (vspltis_shifted): Return false also if
split1 pass has finished already.

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

2 years agors6000: Add support for vmsumcud and vec_msumc
Bill Schmidt [Tue, 8 Feb 2022 16:36:14 +0000 (10:36 -0600)]
rs6000: Add support for vmsumcud and vec_msumc

2022-02-08  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
* config/rs6000/rs6000-builtins.def (VMSUMCUD): New.
* config/rs6000/rs6000-overload.def (VEC_MSUMC): New.
* config/rs6000/vsx.md (UNSPEC_VMSUMCUD): New constant.
(vmsumcud): New define_insn.

gcc/testsuite/
* gcc.target/powerpc/vec-msumc.c: New test.

2 years agoc++: Add testcase for already fixed PR [PR104425]
Patrick Palka [Tue, 8 Feb 2022 14:47:34 +0000 (09:47 -0500)]
c++: Add testcase for already fixed PR [PR104425]

Fixed by r12-1829.

PR c++/104425

gcc/testsuite/ChangeLog:

* g++.dg/template/partial-specialization10.C: New test.

2 years ago[nvptx] Unbreak build, add PTX_ISA_SM70
Tom de Vries [Tue, 8 Feb 2022 14:35:37 +0000 (15:35 +0100)]
[nvptx] Unbreak build, add PTX_ISA_SM70

With the commit "[nvptx] Choose -mptx default based on -misa" I introduced a
use of PTX_ISA_SM70, without adding it first.

Add it, as well as the corresponding TARGET_SM70.

Build for x86_64 with nvptx accelerator.

gcc/ChangeLog:

2022-02-08  Tom de Vries  <tdevries@suse.de>

* config/nvptx/nvptx-opts.h (enum ptx_isa): Add PTX_ISA_SM70.
* config/nvptx/nvptx.h (TARGET_SM70): Define.

2 years agos390: Increase costs for load on condition and change movqicc expander.
Robin Dapp [Tue, 8 Feb 2022 13:56:29 +0000 (14:56 +0100)]
s390: Increase costs for load on condition and change movqicc expander.

This patch changes the costs for a load on condition from 5 to 6 in
order to ensure that we only if-convert two and not three or more SETS like

if (cond)
{
  a = b;
  c = d;
  e = f;
}

In the movqicc expander we emit a paradoxical subreg directly that
combine would otherwise try to create by using a non-optimal sequence
(which would be too expensive).

Also, fix two oversights in ifcvt testcases.

gcc/ChangeLog:

* config/s390/s390.cc (s390_rtx_costs): Increase costs for load
on condition.
* config/s390/s390.md: Use paradoxical subreg.

gcc/testsuite/ChangeLog:

* gcc.target/s390/ifcvt-two-insns-int.c: Fix array size.
* gcc.target/s390/ifcvt-two-insns-long.c: Dito.

2 years agocombine: Check for paradoxical subreg.
Robin Dapp [Tue, 8 Feb 2022 13:39:16 +0000 (14:39 +0100)]
combine: Check for paradoxical subreg.

This adds a check for a paradoxical subreg in reg_subword_p ()
in order to prevent an ICE on s390 in try_combine () triggered
by the movqicc expander.

gcc/ChangeLog:

* combine.cc (reg_subword_p): Check for paradoxical subreg.

2 years agolibstdc++: Add comment to acinclude.m4
Jonathan Wakely [Tue, 8 Feb 2022 13:41:33 +0000 (13:41 +0000)]
libstdc++: Add comment to acinclude.m4

libstdc++-v3/ChangeLog:

* acinclude.m4 (GLIBCXX_ENABLE_LOCK_POLICY): Add comment about
checking for CAS on correct word size.

2 years agoc++: deducing only from noexcept-spec [PR80951]
Patrick Palka [Tue, 8 Feb 2022 14:11:31 +0000 (09:11 -0500)]
c++: deducing only from noexcept-spec [PR80951]

The "fail-fast" predicate uses_deducible_template_parms used by
unify_one_argument is neglecting to look inside the noexcept-spec of a
function type.  This causes deduction to spuriously fail whenever the
noexcept-spec is the only part of the type which contains a deducible
template parameter.

PR c++/80951

gcc/cp/ChangeLog:

* pt.cc (uses_deducible_template_parms): Consider the
noexcept-spec of a function type.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/noexcept-type25.C: New test.

2 years agoc++: satisfaction value of type const bool [PR104410]
Patrick Palka [Tue, 8 Feb 2022 14:11:29 +0000 (09:11 -0500)]
c++: satisfaction value of type const bool [PR104410]

Here constant evaluation of the atomic constraint use_func_v<T>
sensibly yields an INTEGER_CST of type const bool, but the assert in
satisfaction_value expects unqualified bool.  So let's just relax the
assert to accept cv-qualified bool.

PR c++/104410

gcc/cp/ChangeLog:

* constraint.cc (satisfaction_value): Relax assert to accept
cv-qualified bool.

gcc/testsuite/ChangeLog:

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

2 years agoc++: lambda in pack expansion using pack in constraint [PR103706]
Patrick Palka [Tue, 8 Feb 2022 13:46:32 +0000 (08:46 -0500)]
c++: lambda in pack expansion using pack in constraint [PR103706]

Here when expanding the pack expansion pattern containing a constrained
lambda, the template argument for each Ts is an ARGUMENT_PACK_SELECT,
which we store inside the lambda's LAMBDA_EXPR_REGEN_INFO.  Then during
satisfaction of the lambda's constraint C<Ts> the satisfaction cache
uses this argument as part of the key to the corresponding sat_entry, but
iterative_hash_template_arg and template_args_equal deliberately don't
handle ARGUMENT_PACK_SELECT.

Since it's wrong to preserve ARGUMENT_PACK_SELECT inside a hash table
due to its instability (as documented in iterative_hash_template_arg),
this patch helps make sure the satisfaction cache doesn't see such trees
by resolving ARGUMENT_PACK_SELECT arguments before adding them to
LAMBDA_EXPR_REGEN_INFO.

PR c++/103706

gcc/cp/ChangeLog:

* pt.cc (preserve_args): New function.
(tsubst_lambda_expr): Use it when setting LAMBDA_EXPR_REGEN_INFO.

gcc/testsuite/ChangeLog:

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

2 years agoc++: constrained auto in lambda using outer tparms [PR103706]
Patrick Palka [Tue, 8 Feb 2022 13:46:13 +0000 (08:46 -0500)]
c++: constrained auto in lambda using outer tparms [PR103706]

Here we're crashing during satisfaction of the lambda's placeholder type
constraints because the constraints depend on the template arguments
from the enclosing scope, which aren't part of the lambda's DECL_TI_ARGS.

This patch fixes this by making do_auto_deduction consider the
"regenerating" template arguments of a lambda for satisfaction,
mirroring what's done in satisfy_declaration_constraints.

PR c++/103706

gcc/cp/ChangeLog:

* constraint.cc (satisfy_declaration_constraints): Use
lambda_regenerating_args instead.
* cp-tree.h (lambda_regenerating_args): Declare.
* pt.cc (lambda_regenerating_args): Define, split out from
satisfy_declaration_constraints.
(do_auto_deduction): Use lambda_regenerating_args to obtain the
full set of outer template arguments for satisfaction when
inside a lambda.

gcc/testsuite/ChangeLog:

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

2 years agolibstdc++: Adjust Filesystem TS test for Windows
Jonathan Wakely [Tue, 8 Feb 2022 12:45:46 +0000 (12:45 +0000)]
libstdc++: Adjust Filesystem TS test for Windows

The Filesystem TS isn't really supported for Windows, but the FAIL for
this test is just because it doesn't match what happens on Windows.

libstdc++-v3/ChangeLog:

* testsuite/experimental/filesystem/operations/create_directories.cc:
Adjust expected results for Windows.

2 years agolibstdc++: Fix filesystem::remove_all for Windows [PR104161]
Jonathan Wakely [Mon, 7 Feb 2022 23:36:47 +0000 (23:36 +0000)]
libstdc++: Fix filesystem::remove_all for Windows [PR104161]

The recursive_directory_iterator::__erase member was failing for
Windows, because the entry._M_type value is always file_type::none
(because _Dir_base::advance doesn't populate it for Windows) and
top.unlink uses fs::remove which sets an error using the
system_category. That meant that ec.value() was a Windows error code and
not an errno value, so the comparisons to EPERM and EISDIR failed.
Instead of depending on a specific Windows error code for attempting to
remove a directory, just use directory_entry::refresh() to query the
type first. This doesn't avoid the TOCTTOU races with directory
symlinks, but we can't avoid them on Windows without openat and
unlinkat, and creating symlinks requires admin privs on Windows anyway.

This also fixes the fs::remove_all(const path&) overload, which was
supposed to use the same logic as the other overload, but I forgot to
change it before my previous commit.

libstdc++-v3/ChangeLog:

PR libstdc++/104161
* src/c++17/fs_dir.cc (fs::recursive_directory_iterator::__erase):
[i_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Refresh entry._M_type member,
instead of checking for errno values indicating a directory.
* src/c++17/fs_ops.cc (fs::remove_all(const path&)): Use similar
logic to non-throwing overload.
(fs::remove_all(const path&, error_code&)): Add comments.
* src/filesystem/ops-common.h: Likewise.

2 years ago[nvptx] Choose -mptx default based on -misa
Tom de Vries [Fri, 4 Feb 2022 07:53:52 +0000 (08:53 +0100)]
[nvptx] Choose -mptx default based on -misa

While testing with driver version 390.147 I ran into the problem that it
doesn't support ptx isa version 6.3 (the new default), only 6.1.

Furthermore, using the -mptx option is a bit user-unfriendly.

Say we want to compile for sm_80.  We can use -misa=sm_80 to specify that, but
then run into errors because the default ptx version is 6.3, which doesn't
support sm_80 yet.

Address both these issues by:
- picking a default -mptx based on the active -misa, and
- ensuring that the default -mptx is at least 6.0 (instead
  of 6.3).

Also add an error in case of incompatible options like
"-misa=sm_80 -mptx=6.3":
...
cc1: error: PTX version (-mptx) needs to be at least 7.0 to support \
  selected -misa (sm_80)
...

Tested on x86_64-linux with nvptx accelerator.

gcc/ChangeLog:

2022-02-08  Tom de Vries  <tdevries@suse.de>

PR target/104283
* config/nvptx/nvptx-opts.h (enum ptx_version): Add PTX_VERSION_3_0
and PTX_VERSION_4_2.
* config/nvptx/nvptx.cc (first_ptx_version_supporting_sm)
(default_ptx_version_option, ptx_version_to_string)
(sm_version_to_string, handle_ptx_version_option): New function.
(nvptx_option_override): Call handle_ptx_version_option.
(nvptx_file_start): Use ptx_version_to_string and sm_version_to_string.
* config/nvptx/nvptx.md (define_insn "nvptx_shuffle<mode>")
(define_insn "nvptx_vote_ballot"): Use TARGET_PTX_6_0.
* config/nvptx/nvptx.opt (mptx): Remove 'Init'.

2 years agoRISC-V/testsuite: Run target testing over all the usual optimization levels
Maciej W. Rozycki [Tue, 8 Feb 2022 12:14:59 +0000 (12:14 +0000)]
RISC-V/testsuite: Run target testing over all the usual optimization levels

Use `gcc-dg-runtest' test driver rather than `dg-runtest' to run the
RISC-V testsuite as several targets already do.  Adjust test options
across individual test cases accordingly where required.

As some tests want to be run at `-Og', add a suitable optimization
variant via ADDITIONAL_TORTURE_OPTIONS, and include the moderately
recent `-Oz' variant as well.

gcc/testsuite/
* gcc.target/riscv/riscv.exp: Use `gcc-dg-runtest' rather than
`dg-runtest'.  Add `-Og -g' and `-Oz' variants via
ADDITIONAL_TORTURE_OPTIONS.
* gcc.target/riscv/arch-1.c: Adjust test options accordingly.
* gcc.target/riscv/arch-10.c: Likewise.
* gcc.target/riscv/arch-11.c: Likewise.
* gcc.target/riscv/arch-12.c: Likewise.
* gcc.target/riscv/arch-2.c: Likewise.
* gcc.target/riscv/arch-3.c: Likewise.
* gcc.target/riscv/arch-4.c: Likewise.
* gcc.target/riscv/arch-5.c: Likewise.
* gcc.target/riscv/arch-6.c: Likewise.
* gcc.target/riscv/arch-7.c: Likewise.
* gcc.target/riscv/arch-8.c: Likewise.
* gcc.target/riscv/arch-9.c: Likewise.
* gcc.target/riscv/attribute-1.c: Likewise.
* gcc.target/riscv/attribute-10.c: Likewise.
* gcc.target/riscv/attribute-11.c: Likewise.
* gcc.target/riscv/attribute-12.c: Likewise.
* gcc.target/riscv/attribute-13.c: Likewise.
* gcc.target/riscv/attribute-14.c: Likewise.
* gcc.target/riscv/attribute-15.c: Likewise.
* gcc.target/riscv/attribute-16.c: Likewise.
* gcc.target/riscv/attribute-17.c: Likewise.
* gcc.target/riscv/attribute-2.c: Likewise.
* gcc.target/riscv/attribute-3.c: Likewise.
* gcc.target/riscv/attribute-4.c: Likewise.
* gcc.target/riscv/attribute-5.c: Likewise.
* gcc.target/riscv/attribute-7.c: Likewise.
* gcc.target/riscv/attribute-8.c: Likewise.
* gcc.target/riscv/attribute-9.c: Likewise.
* gcc.target/riscv/interrupt-1.c: Likewise.
* gcc.target/riscv/interrupt-2.c: Likewise.
* gcc.target/riscv/interrupt-3.c: Likewise.
* gcc.target/riscv/interrupt-4.c: Likewise.
* gcc.target/riscv/interrupt-conflict-mode.c: Likewise.
* gcc.target/riscv/interrupt-debug.c: Likewise.
* gcc.target/riscv/interrupt-mmode.c: Likewise.
* gcc.target/riscv/interrupt-smode.c: Likewise.
* gcc.target/riscv/interrupt-umode.c: Likewise.
* gcc.target/riscv/li.c: Likewise.
* gcc.target/riscv/load-immediate.c: Likewise.
* gcc.target/riscv/losum-overflow.c: Likewise.
* gcc.target/riscv/mcpu-6.c: Likewise.
* gcc.target/riscv/mcpu-7.c: Likewise.
* gcc.target/riscv/pr102957.c: Likewise.
* gcc.target/riscv/pr103302.c: Likewise.
* gcc.target/riscv/pr104140.c: Likewise.
* gcc.target/riscv/pr84660.c: Likewise.
* gcc.target/riscv/pr93202.c: Likewise.
* gcc.target/riscv/pr93304.c: Likewise.
* gcc.target/riscv/pr95252.c: Likewise.
* gcc.target/riscv/pr95683.c: Likewise.
* gcc.target/riscv/pr98777.c: Likewise.
* gcc.target/riscv/pr99702.c: Likewise.
* gcc.target/riscv/predef-1.c: Likewise.
* gcc.target/riscv/predef-10.c: Likewise.
* gcc.target/riscv/predef-11.c: Likewise.
* gcc.target/riscv/predef-12.c: Likewise.
* gcc.target/riscv/predef-13.c: Likewise.
* gcc.target/riscv/predef-14.c: Likewise.
* gcc.target/riscv/predef-15.c: Likewise.
* gcc.target/riscv/predef-16.c: Likewise.
* gcc.target/riscv/predef-2.c: Likewise.
* gcc.target/riscv/predef-3.c: Likewise.
* gcc.target/riscv/predef-4.c: Likewise.
* gcc.target/riscv/predef-5.c: Likewise.
* gcc.target/riscv/predef-6.c: Likewise.
* gcc.target/riscv/predef-7.c: Likewise.
* gcc.target/riscv/predef-8.c: Likewise.
* gcc.target/riscv/promote-type-for-libcall.c: Likewise.
* gcc.target/riscv/save-restore-1.c: Likewise.
* gcc.target/riscv/save-restore-2.c: Likewise.
* gcc.target/riscv/save-restore-3.c: Likewise.
* gcc.target/riscv/save-restore-4.c: Likewise.
* gcc.target/riscv/save-restore-6.c: Likewise.
* gcc.target/riscv/save-restore-7.c: Likewise.
* gcc.target/riscv/save-restore-8.c: Likewise.
* gcc.target/riscv/save-restore-9.c: Likewise.
* gcc.target/riscv/shift-and-1.c: Likewise.
* gcc.target/riscv/shift-and-2.c: Likewise.
* gcc.target/riscv/shift-shift-1.c: Likewise.
* gcc.target/riscv/shift-shift-2.c: Likewise.
* gcc.target/riscv/shift-shift-3.c: Likewise.
* gcc.target/riscv/shift-shift-4.c: Likewise.
* gcc.target/riscv/shift-shift-5.c: Likewise.
* gcc.target/riscv/shorten-memrefs-1.c: Likewise.
* gcc.target/riscv/shorten-memrefs-2.c: Likewise.
* gcc.target/riscv/shorten-memrefs-3.c: Likewise.
* gcc.target/riscv/shorten-memrefs-4.c: Likewise.
* gcc.target/riscv/shorten-memrefs-5.c: Likewise.
* gcc.target/riscv/shorten-memrefs-6.c: Likewise.
* gcc.target/riscv/shorten-memrefs-7.c: Likewise.
* gcc.target/riscv/shorten-memrefs-8.c: Likewise.
* gcc.target/riscv/switch-qi.c: Likewise.
* gcc.target/riscv/switch-si.c: Likewise.
* gcc.target/riscv/weak-1.c: Likewise.
* gcc.target/riscv/zba-adduw.c: Likewise.
* gcc.target/riscv/zba-shNadd-01.c: Likewise.
* gcc.target/riscv/zba-shNadd-02.c: Likewise.
* gcc.target/riscv/zba-shNadd-03.c: Likewise.
* gcc.target/riscv/zba-slliuw.c: Likewise.
* gcc.target/riscv/zba-zextw.c: Likewise.
* gcc.target/riscv/zbb-andn-orn-xnor-01.c: Likewise.
* gcc.target/riscv/zbb-andn-orn-xnor-02.c: Likewise.
* gcc.target/riscv/zbb-li-rotr.c: Likewise.
* gcc.target/riscv/zbb-min-max.c: Likewise.
* gcc.target/riscv/zbb-rol-ror-01.c: Likewise.
* gcc.target/riscv/zbb-rol-ror-02.c: Likewise.
* gcc.target/riscv/zbb-rol-ror-03.c: Likewise.
* gcc.target/riscv/zbbw.c: Likewise.
* gcc.target/riscv/zbs-bclr.c: Likewise.
* gcc.target/riscv/zbs-bext.c: Likewise.
* gcc.target/riscv/zbs-binv.c: Likewise.
* gcc.target/riscv/zbs-bset.c: Likewise.
* gcc.target/riscv/zero-extend-1.c: Likewise.
* gcc.target/riscv/zero-extend-2.c: Likewise.
* gcc.target/riscv/zero-extend-3.c: Likewise.
* gcc.target/riscv/zero-extend-4.c: Likewise.
* gcc.target/riscv/zero-extend-5.c: Likewise.

2 years agodoc: RISC-V: Document the `-misa-spec=' option
Maciej W. Rozycki [Tue, 8 Feb 2022 12:14:58 +0000 (12:14 +0000)]
doc: RISC-V: Document the `-misa-spec=' option

We have recently updated the default for the `-misa-spec=' option, yet
we still have not documented it nor its `--with-isa-spec=' counterpart
in the GCC manuals.  Fix that.

gcc/
* doc/install.texi (Configuration): Document `--with-isa-spec='
RISC-V option.
* doc/invoke.texi (Option Summary): List `-misa-spec=' RISC-V
option.
(RISC-V Options): Document it.

2 years agoRISC-V: Add target machine headers as a dependency for riscv-sr.o
Maciej W. Rozycki [Tue, 8 Feb 2022 12:14:58 +0000 (12:14 +0000)]
RISC-V: Add target machine headers as a dependency for riscv-sr.o

Make riscv-sr.o depend on target machine headers, removing spurious test
failures:

FAIL: gcc.target/riscv/save-restore-3.c scan-assembler-not call[ \t]*t0,__riscv_save_0
FAIL: gcc.target/riscv/save-restore-3.c scan-assembler-not tail[ \t]*__riscv_restore_0
FAIL: gcc.target/riscv/save-restore-3.c scan-assembler tail[ \t]*foo
FAIL: gcc.target/riscv/save-restore-6.c scan-assembler-not call[ \t]*t0,__riscv_save_0
FAIL: gcc.target/riscv/save-restore-6.c scan-assembler-not tail[ \t]*__riscv_restore_0
FAIL: gcc.target/riscv/save-restore-6.c scan-assembler tail[ \t]*other_func

if the definitions of UNSPECs are locally changed and GCC rebuilt from a
dirty tree.

gcc/
* config/riscv/t-riscv (riscv-sr.o): Add $(TM_H) dependency.

2 years ago[nvptx] Fix 'main (int argc)' compilation
Tom de Vries [Mon, 7 Feb 2022 13:50:13 +0000 (14:50 +0100)]
[nvptx] Fix 'main (int argc)' compilation

On nvptx, with test-case sso-12.c I run into:
...
spawn nvptx-none-run ./sso-12.exe^M
error: Prototype doesn't match for 'main' in 'input file 1 at offset 1796', \
  first defined in 'input file 1 at offset 1796'^M
nvptx-run: cuLinkAddData failed: device kernel image is invalid \
  (CUDA_ERROR_INVALID_SOURCE, 300)^M
FAIL: gcc.dg/sso-12.c execution test
...

The problem is that the test case uses 'main (int)' prototype, while __main
uses:
...
extern int main (int, void **);
...

There's code in write_fn_proto_1 to handle 'main (void)' as if
'main (int, void **)' was specified, but that's not active for 'main (int)'.

Fix this in write_fn_proto_1 by handling 'main (int)' as if
'main (int, void **)' was specified.

Tested on nvptx.

gcc/ChangeLog:

2022-02-07  Tom de Vries  <tdevries@suse.de>

* config/nvptx/nvptx.cc (write_fn_proto_1): Handle 'main (int)'.

2 years ago[testsuite] Require c99_runtime to run builtin-sprintf.c
Tom de Vries [Mon, 7 Feb 2022 13:45:12 +0000 (14:45 +0100)]
[testsuite] Require c99_runtime to run builtin-sprintf.c

On nvptx, I run into an execution failure in test-case
gcc.dg/tree-ssa/builtin-sprintf.c because the test-case uses the 'hh'
modifier.

The port uses newlib, which does by default not support that modifier.
There's a configure option --enable-newlib-io-c99-formats to enable this
support, but that requires alloca support, which nvptx doesn't have.

Fix this by requiring c99_runtime for running the test-case.

Tested on nvptx.

gcc/testsuite/ChangeLog:

2022-02-07  Tom de Vries  <tdevries@suse.de>

* gcc.dg/tree-ssa/builtin-sprintf.c: Require c99_runtime for
dg-do run.

2 years ago[nvptx] Fix .local atomic regressions
Tom de Vries [Thu, 3 Feb 2022 13:00:02 +0000 (14:00 +0100)]
[nvptx] Fix .local atomic regressions

In PR target/104364, two problems were reported:
- in muniform-simt mode, an atom.cas insn is no longer executed in the
  "master lane" only.
- in msoft-stack mode, an __atomic_compare_exchange_n on stack memory is
  translated assuming it accesses local memory, while that's not the case.

Fix these by:
- ensuring that all insns with atomic attribute are also predicable, such
  that the validate_change in nvptx_reorg_uniform_simt will succeed, and
  asserting that it does, and
- guarding the local atomics implementation with a new function
  nvptx_mem_local_p that correctly handles msoft-stack.

Tested on x86_64 with nvptx accelerator.

gcc/ChangeLog:

2022-02-04  Tom de Vries  <tdevries@suse.de>

PR target/104364
* config/nvptx/nvptx-protos.h (nvptx_mem_local_p): Declare.
* config/nvptx/nvptx.cc (nvptx_reorg_uniform_simt): Assert that
change is validated.
(nvptx_mem_local_p): New function.
* config/nvptx/nvptx.md: Use nvptx_mem_local_p.
(define_c_enum "unspecv"): Add UNSPECV_CAS_LOCAL.
(define_insn "atomic_compare_and_swap<mode>_1_local"): New
non-atomic, non-predicable define_insn, factored out of ...
(define_insn "atomic_compare_and_swap<mode>_1"): ... here.
Make predicable again.
(define_expand "atomic_compare_and_swap<mode>"): Use
atomic_compare_and_swap<mode>_1_local.

gcc/testsuite/ChangeLog:

2022-02-04  Tom de Vries  <tdevries@suse.de>

PR target/104364
* gcc.target/nvptx/softstack-2.c: New test.
* gcc.target/nvptx/uniform-simt-1.c: New test.

2 years agolibgomp: Fix segfault with posthumous orphan tasks [PR104385]
Jakub Jelinek [Tue, 8 Feb 2022 08:30:17 +0000 (09:30 +0100)]
libgomp: Fix segfault with posthumous orphan tasks [PR104385]

The following patch fixes crashes with posthumous orphan tasks.
When a parent task finishes, gomp_clear_parent clears the parent
pointers of its children tasks present in the parent->children_queue.
But children that are still waiting for dependencies aren't in that
queue yet, they will be added there only when the sibling they are
waiting for exits.  Unfortunately we were adding those tasks into
the queues with the original task->parent which then causes crashes
because that task is gone and freed.  The following patch fixes that
by clearing the parent field when we schedule such task for running
by adding it into the queues and we know that the sibling task which
is about to finish has NULL parent.

2022-02-08  Jakub Jelinek  <jakub@redhat.com>

PR libgomp/104385
* task.c (gomp_task_run_post_handle_dependers): If parent is NULL,
clear task->parent.
* testsuite/libgomp.c/pr104385.c: New test.

2 years agoMAINTAINERS: Remove Hartmut Penner as s390 maintainer
Ulrich Weigand [Tue, 8 Feb 2022 08:21:07 +0000 (09:21 +0100)]
MAINTAINERS: Remove Hartmut Penner as s390 maintainer

Hartmut is no longer with IBM and has not worked on GCC for a
long time; he asked to be removed from MAINTAINERS.

ChangeLog:

* MAINTAINERS: Remove Hartmut Penner as s390 maintainer.

2 years agoDon't propagate for a more expensive reg-reg move.
liuhongt [Mon, 24 Jan 2022 10:17:47 +0000 (18:17 +0800)]
Don't propagate for a more expensive reg-reg move.

For i386, it enables optimization like:

        vmovd   %xmm0, %edx
-       vmovd   %xmm0, %eax
+       movl    %edx, %eax

gcc/ChangeLog:

PR rtl-optimization/104059
* regcprop.cc (copyprop_hardreg_forward_1): Don't propagate
for a more expensive reg-reg move.

gcc/testsuite/ChangeLog:

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

2 years agoDaily bump.
GCC Administrator [Tue, 8 Feb 2022 00:16:24 +0000 (00:16 +0000)]
Daily bump.

2 years agoanalyzer: fix ICE on realloc of non-heap [PR104417]
David Malcolm [Mon, 7 Feb 2022 19:00:55 +0000 (14:00 -0500)]
analyzer: fix ICE on realloc of non-heap [PR104417]

gcc/analyzer/ChangeLog:
PR analyzer/104417
* sm-taint.cc (tainted_allocation_size::tainted_allocation_size):
Remove overzealous assertion.
(tainted_allocation_size::emit): Likewise.
(region_model::check_dynamic_size_for_taint): Likewise.

gcc/testsuite/ChangeLog:
PR analyzer/104417
* gcc.dg/analyzer/pr104417.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoanalyzer: fixes to memcpy [PR103872]
David Malcolm [Thu, 3 Feb 2022 21:21:27 +0000 (16:21 -0500)]
analyzer: fixes to memcpy [PR103872]

PR analyzer/103872 reports a failure of gcc.dg/analyzer/pr103526.c on
riscv64-unknown-elf-gcc.  The issue is that I wrote the test on x86_64
where a memcpy in the test is optimized to a write to a read/write pair,
whereas due to alignment differences the analyzer can see it as a
memcpy call, revealing problems with the analyzer's implementation
of memcpy.

This patch reimplements region_model::impl_call_memcpy in terms of a
get_store_value followed by a set_value, fixing the issue.

gcc/analyzer/ChangeLog:
PR analyzer/103872
* region-model-impl-calls.cc (region_model::impl_call_memcpy):
Reimplement in terms of a get_store_value followed by a set_value.

gcc/testsuite/ChangeLog:
PR analyzer/103872
* gcc.dg/analyzer/memcpy-1.c: Add alternate versions of test cases
in which the calls to memcpy are hidden from the optimizer.  Add
further test cases.
* gcc.dg/analyzer/taint-size-1.c: Add test coverage for memcpy
with tainted size.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agotestsuite: avoid analyzer asm failures on non-Linux
David Malcolm [Wed, 19 Jan 2022 19:06:25 +0000 (14:06 -0500)]
testsuite: avoid analyzer asm failures on non-Linux

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/asm-x86-1.c: Use dg-do "compile" rather than
"assemble".
* gcc.dg/analyzer/asm-x86-lp64-1.c: Likewise.
* gcc.dg/analyzer/asm-x86-lp64-2.c: Likewise.
* gcc.dg/analyzer/torture/asm-x86-linux-array_index_mask_nospec.c:
Likewise.
* gcc.dg/analyzer/torture/asm-x86-linux-cpuid-paravirt-1.c:
Likewise, and restrict to x86_64-pc-linux-gnu.
* gcc.dg/analyzer/torture/asm-x86-linux-cpuid-paravirt-2.c: Likewise.
* gcc.dg/analyzer/torture/asm-x86-linux-cpuid.c: Use dg-do
"compile" rather than "assemble".
* gcc.dg/analyzer/torture/asm-x86-linux-rdmsr-paravirt.c:
Likewise, and restrict to x86_64-pc-linux-gnu.
* gcc.dg/analyzer/torture/asm-x86-linux-rdmsr.c: Use dg-do
"compile" rather than "assemble".
* gcc.dg/analyzer/torture/asm-x86-linux-wfx_get_ps_timeout-full.c:
Likewise.
* gcc.dg/analyzer/torture/asm-x86-linux-wfx_get_ps_timeout-reduced.c:
Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agotestsuite: Fix up testsuite/gcc.c-torture/execute/builtins/lib/chk.c for powerpc...
Jakub Jelinek [Mon, 7 Feb 2022 16:39:11 +0000 (17:39 +0100)]
testsuite: Fix up testsuite/gcc.c-torture/execute/builtins/lib/chk.c for powerpc [PR104380]

> > The following testcase FAILs when configured with
> > --with-long-double-format=ieee .  Only happens in the -std=c* modes, not the
> > GNU modes; while the glibc headers have __asm redirects of
> > vsnprintf and __vsnprinf_chk to __vsnprintfieee128 and
> > __vsnprintf_chkieee128, the vsnprintf fortification extern inline gnu_inline
> > always_inline wrapper calls __builtin_vsnprintf_chk and we actually emit
> > a call to __vsnprinf_chk (i.e. with IBM extended long double) instead of
> > __vsnprintf_chkieee128.
> >
> > rs6000_mangle_decl_assembler_name already had cases for *printf and *scanf,
> > so this just adds another case for *printf_chk.  *scanf_chk doesn't exist.
> > __ prefixing isn't done because *printf_chk already starts with __.

Unfortunately, while I've tested the testcase also with -mabi=ieeelongdouble
by hand, the full bootstrap/regtest was on GCCFarm where glibc is too old
to test with --with-long-double-format=ieee.
I've done full bootstrap/regtest with that option during the weekend and
the patch regressed:
FAIL: gcc.c-torture/execute/builtins/snprintf-chk.c execution,  -O1
FAIL: gcc.c-torture/execute/builtins/snprintf-chk.c execution,  -O2
FAIL: gcc.c-torture/execute/builtins/snprintf-chk.c execution,  -O2 -flto -fno-use-linker-plugin -flto-partition=none
FAIL: gcc.c-torture/execute/builtins/snprintf-chk.c execution,  -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects
FAIL: gcc.c-torture/execute/builtins/snprintf-chk.c execution,  -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions
FAIL: gcc.c-torture/execute/builtins/snprintf-chk.c execution,  -O3 -g
FAIL: gcc.c-torture/execute/builtins/snprintf-chk.c execution,  -Og -g
FAIL: gcc.c-torture/execute/builtins/snprintf-chk.c execution,  -Os
FAIL: gcc.c-torture/execute/builtins/sprintf-chk.c execution,  -O1
FAIL: gcc.c-torture/execute/builtins/sprintf-chk.c execution,  -O2
FAIL: gcc.c-torture/execute/builtins/sprintf-chk.c execution,  -O2 -flto -fno-use-linker-plugin -flto-partition=none
FAIL: gcc.c-torture/execute/builtins/sprintf-chk.c execution,  -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects
FAIL: gcc.c-torture/execute/builtins/sprintf-chk.c execution,  -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions
FAIL: gcc.c-torture/execute/builtins/sprintf-chk.c execution,  -O3 -g
FAIL: gcc.c-torture/execute/builtins/sprintf-chk.c execution,  -Og -g
FAIL: gcc.c-torture/execute/builtins/sprintf-chk.c execution,  -Os
FAIL: gcc.c-torture/execute/builtins/vsnprintf-chk.c execution,  -O1
FAIL: gcc.c-torture/execute/builtins/vsnprintf-chk.c execution,  -O2
FAIL: gcc.c-torture/execute/builtins/vsnprintf-chk.c execution,  -O2 -flto -fno-use-linker-plugin -flto-partition=none
FAIL: gcc.c-torture/execute/builtins/vsnprintf-chk.c execution,  -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects
FAIL: gcc.c-torture/execute/builtins/vsnprintf-chk.c execution,  -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions
FAIL: gcc.c-torture/execute/builtins/vsnprintf-chk.c execution,  -O3 -g
FAIL: gcc.c-torture/execute/builtins/vsnprintf-chk.c execution,  -Og -g
FAIL: gcc.c-torture/execute/builtins/vsnprintf-chk.c execution,  -Os
FAIL: gcc.c-torture/execute/builtins/vsprintf-chk.c execution,  -O1
FAIL: gcc.c-torture/execute/builtins/vsprintf-chk.c execution,  -O2
FAIL: gcc.c-torture/execute/builtins/vsprintf-chk.c execution,  -O2 -flto -fno-use-linker-plugin -flto-partition=none
FAIL: gcc.c-torture/execute/builtins/vsprintf-chk.c execution,  -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects
FAIL: gcc.c-torture/execute/builtins/vsprintf-chk.c execution,  -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions
FAIL: gcc.c-torture/execute/builtins/vsprintf-chk.c execution,  -O3 -g
FAIL: gcc.c-torture/execute/builtins/vsprintf-chk.c execution,  -Og -g
FAIL: gcc.c-torture/execute/builtins/vsprintf-chk.c execution,  -Os

The problem is that the execute/builtins/ testsuite wants to override some
of the library functions and with the change we (correctly) call
__*printf_chkieee128 and so lib/chk.c is no longer called but the glibc
APIs are.

2022-02-07  Jakub Jelinek  <jakub@redhat.com>

PR target/104380
* gcc.c-torture/execute/builtins/lib/chk.c (__sprintf_chkieee128,
__vsprintf_chkieee128, __snprintf_chkieee128,
__vsnprintf_chkieee128): New aliases to non-ieee128 suffixed functions
for powerpc -mabi=ieeelongdouble.

2 years agoAArch32: correct usdot-product RTL patterns.
Tamar Christina [Mon, 7 Feb 2022 12:55:12 +0000 (12:55 +0000)]
AArch32: correct usdot-product RTL patterns.

There was a bug in the ACLE specication for dot product which has now
been fixed[1].  This means some intrinsics were missing and are added by this
patch.

Bootstrapped and regtested on arm-none-linux-gnueabihf and no issues.

Ok for master?

[1] https://github.com/ARM-software/acle/releases/tag/r2021Q3

gcc/ChangeLog:

* config/arm/arm_neon.h (vusdotq_s32, vusdot_laneq_s32,
vusdotq_laneq_s32, vsudot_laneq_s32, vsudotq_laneq_s32): New
* config/arm/arm_neon_builtins.def (usdot): Add V16QI.
(usdot_laneq, sudot_laneq): New.
* config/arm/neon.md (neon_<sup>dot_laneq<vsi2qi>): New.
(neon_<sup>dot_lane<vsi2qi>): Remote unneeded code.

gcc/testsuite/ChangeLog:

* gcc.target/arm/simd/vdot-2-1.c: Add new tests.
* gcc.target/arm/simd/vdot-2-2.c: Likewise and fix output.

2 years agoAArch32: correct dot-product RTL patterns.
Tamar Christina [Mon, 7 Feb 2022 12:54:42 +0000 (12:54 +0000)]
AArch32: correct dot-product RTL patterns.

The previous fix for this problem was wrong due to a subtle difference between
where NEON expects the RMW values and where intrinsics expects them.

The insn pattern is modeled after the intrinsics and so needs an expand for
the vectorizer optab to switch the RTL.

However operand[3] is not expected to be written to so the current pattern is
bogus.

Instead we use the expand to shuffle around the RTL.

The vectorizer expects operands[3] and operands[0] to be
the same but the aarch64 intrinsics expanders expect operands[0] and
operands[1] to be the same.

This also fixes some issues with big-endian, each dot product performs 4 8-byte
multiplications.  However compared to AArch64 we don't enter lanes in GCC
lane indexed in AArch32 aside from loads/stores.  This means no lane remappings
are done in arm-builtins.c and so none should be done at the instruction side.

There are some other instructions that need inspections as I think there are
more incorrect ones.

Third there was a bug in the ACLE specication for dot product which has now been
fixed[1].  This means some intrinsics were missing and are added by this patch.

Bootstrapped and regtested on arm-none-linux-gnueabihf and no issues.

Ok for master? and active branches after some stew?

[1] https://github.com/ARM-software/acle/releases/tag/r2021Q3

gcc/ChangeLog:

* config/arm/arm_neon.h (vdot_laneq_u32, vdotq_laneq_u32,
vdot_laneq_s32, vdotq_laneq_s32): New.
* config/arm/arm_neon_builtins.def (sdot_laneq, udot_laneq): New.
* config/arm/neon.md (neon_<sup>dot<vsi2qi>): New.
(<sup>dot_prod<vsi2qi>): Re-order rtl.
(neon_<sup>dot_lane<vsi2qi>): Fix rtl order and endiannes.
(neon_<sup>dot_laneq<vsi2qi>): New.

gcc/testsuite/ChangeLog:

* gcc.target/arm/simd/vdot-compile.c: Add new cases.
* gcc.target/arm/simd/vdot-exec.c: Likewise.

2 years agoCheck always_inline flag in s390_can_inline_p [PR104327]
Andreas Krebbel [Sun, 6 Feb 2022 08:07:41 +0000 (09:07 +0100)]
Check always_inline flag in s390_can_inline_p [PR104327]

MASK_MVCLE is set for -Os but not for other optimization levels. In
general it should not make much sense to inline across calls where the
flag is different but we have to allow it for always_inline.

The patch also rearranges the hook implementation a bit based on the
recommendations from Jakub und Martin in the PR.

Bootstrapped and regression tested on s390x with various arch flags.
Will commit after giving a few days for comments.

gcc/ChangeLog:

PR target/104327
* config/s390/s390.cc (s390_can_inline_p): Accept a few more flags
if always_inline is set. Don't inline when tune differs without
always_inline.

gcc/testsuite/ChangeLog:

PR target/104327
* gcc.c-torture/compile/pr104327.c: New test.

2 years agomiddle-end/104402 - split out _Complex compares from COND_EXPRs
Richard Biener [Mon, 7 Feb 2022 08:31:07 +0000 (09:31 +0100)]
middle-end/104402 - split out _Complex compares from COND_EXPRs

This makes sure we always have a _Complex compare split to a
different stmt for the compare operand in a COND_EXPR on GIMPLE.
Complex lowering doesn't handle this and the change is something
we want for all kind of compares at some point.

2022-02-07  Richard Biener  <rguenther@suse.de>

PR middle-end/104402
* gimple-expr.cc (is_gimple_condexpr): _Complex typed
compares are not valid.
* tree-cfg.cc (verify_gimple_assign_ternary): For COND_EXPR
check is_gimple_condexpr.

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

2 years agors6000: Move the hunk affecting VSX/ALTIVEC ahead [PR103627]
Kewen Lin [Mon, 7 Feb 2022 03:30:02 +0000 (21:30 -0600)]
rs6000: Move the hunk affecting VSX/ALTIVEC ahead [PR103627]

The modified hunk can update VSX and ALTIVEC flag, we have some codes
to check/warn for some flags related to VSX and ALTIVEC sitting where
the hunk is proprosed to be moved to.  Without this adjustment, the
VSX and ALTIVEC update is too late, it can cause the incompatibility
and result in unexpected behaviors, the associated test case is one
typical case.

Since we already have the code which sets TARGET_FLOAT128_TYPE and lays
after the moved place, and OPTION_MASK_FLOAT128_KEYWORD will rely on
TARGET_FLOAT128_TYPE, so it just simply remove them.

gcc/ChangeLog:

PR target/103627
* config/rs6000/rs6000.cc (rs6000_option_override_internal): Move the
hunk affecting VSX and ALTIVEC to appropriate place.

gcc/testsuite/ChangeLog:

PR target/103627
* gcc.target/powerpc/pr103627-3.c: New test.

2 years agors6000: Disable MMA if no VSX support [PR103627]
Kewen Lin [Mon, 7 Feb 2022 03:29:32 +0000 (21:29 -0600)]
rs6000: Disable MMA if no VSX support [PR103627]

As PR103627 shows, there is an unexpected case where !TARGET_VSX
and TARGET_MMA co-exist.  As ISA3.1 claims, SIMD is a requirement
for MMA.  By looking into the ICE, I noticed that the current
MMA implementation depends on vector pairs load/store which use
VSX register, but we don't have a separated option to control
Power10 vector support and Segher pointed out "-mpower9-vector is
a workaround that should go away" and more explanations in [1].
So this patch makes MMA require VSX instead.

[1] https://gcc.gnu.org/pipermail/gcc-patches/2022-January/589303.html

gcc/ChangeLog:

PR target/103627
* config/rs6000/rs6000.cc (rs6000_option_override_internal): Disable
MMA if !TARGET_VSX.

gcc/testsuite/ChangeLog:

PR target/103627
* gcc.target/powerpc/pr103627-1.c: New test.
* gcc.target/powerpc/pr103627-2.c: New test.

2 years agoDaily bump.
GCC Administrator [Mon, 7 Feb 2022 00:16:17 +0000 (00:16 +0000)]
Daily bump.

2 years agoc++: dependent noexcept-spec on defaulted comparison op [PR96242]
Patrick Palka [Sun, 6 Feb 2022 15:47:48 +0000 (10:47 -0500)]
c++: dependent noexcept-spec on defaulted comparison op [PR96242]

Here we're failing to instantiate the defaulted comparison op's
explicit dependent noexcept-spec.  The problem is ultimately that
mark_used relies on maybe_instantiate_noexcept to synthesize a defaulted
comparison op, but the relevant DECL_MAYBE_DELETED fn handling in m_i_n
is intended for such functions whose noexcept-spec wasn't explicitly
provided (and is therefore determined via synthesis), so m_i_n just
exits early afterwards, without considering that the synthesized fn may
have an explicit noexcept-spec that needs instantiating.

This patch fixes this issue by making mark_used directly synthesize a
DECL_MAYBE_DELETED fn before calling maybe_instantiate_noexcept.  And
in turn, we can properly restrict the DECL_MAYBE_DELETED fn synthesis
in m_i_n to only those without an explicit noexcept-spec.

PR c++/96242

gcc/cp/ChangeLog:

* decl2.cc (mark_used): Directly synthesize a DECL_MAYBE_DELETED
fn by calling maybe_synthesize_method instead of relying on
maybe_instantiate_noexcept.  Move call to m_i_n after the
DECL_DELETED_FN handling.
* pt.cc (maybe_instantiate_noexcept): Restrict DECL_MAYBE_DELETED
fn synthesis to only those with an implicit noexcept-spec, and
return !DECL_DELETED_FN instead of !DECL_MAYBE_DELETED afterwards.

gcc/testsuite/ChangeLog:

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

2 years agoc++: Further address_compare fixes [PR89074]
Jakub Jelinek [Sun, 6 Feb 2022 10:16:29 +0000 (11:16 +0100)]
c++: Further address_compare fixes [PR89074]

This patch introduces folding_cxx_constexpr, folding_initializer is used
for both C and C++ initializer/constant expression folding and enables more
optimizations over what we do normally at runtime, while folding_cxx_constexpr
is used only during C++ constant expression folding and disables some optimizations.

The patch improves STRING_CST vs. STRING_CST folding, for folding_initializer
FUNCTION_DECL vs. FUNCTION_DECL folding, disables some optimizations like
is_global_var != is_global_var or STRING_CST vs. DECL_P for folding_cxx_constexpr
etc.

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

PR c++/89074
PR c++/104033
* fold-const.h (folding_initializer): Adjust comment.
(folding_cxx_constexpr): Declare.
* fold-const.cc (folding_initializer): Adjust comment.
(folding_cxx_constexpr): New variable.
(address_compare): Restrict the decl vs. STRING_CST
or vice versa or STRING_CST vs. STRING_CST or
is_global_var != is_global_var optimizations to !folding_cxx_constexpr.
Punt for FUNCTION_DECLs with non-zero offsets.  If folding_initializer,
assume non-aliased functions have non-zero size and have different
addresses.  For folding_cxx_constexpr, punt on comparisons of start
of some object and end of another one, regardless whether it is a decl
or string literal.  Also punt for folding_cxx_constexpr on
STRING_CST vs. STRING_CST comparisons if the two literals could be
overlapping.

* constexpr.cc (cxx_eval_binary_expression): Temporarily set
folding_cxx_constexpr.

* g++.dg/cpp1y/constexpr-89074-3.C: New test.

2 years agoDaily bump.
GCC Administrator [Sun, 6 Feb 2022 00:16:21 +0000 (00:16 +0000)]
Daily bump.

2 years agoFix expected output for s390 tests
Jeff Law [Sat, 5 Feb 2022 17:17:56 +0000 (12:17 -0500)]
Fix expected output for s390 tests

Recent changes in diagnostic outputs have been triggering failures on the s390
testsuite.  In particular, capitalization changed in one diagnostic and the
range representation changed in another.  This patch makes the obvious updates
to the s390 testsuite.

gcc/testsuite
* gcc.target/s390/20150826-1.c: Update expected output.
* gcc.target/s390/zvector/imm-range-error-1.c: Likewise.

2 years agomatch.pd: Fix x * 0.0 -> 0.0 folding [PR104389]
Jakub Jelinek [Sat, 5 Feb 2022 09:52:19 +0000 (10:52 +0100)]
match.pd: Fix x * 0.0 -> 0.0 folding [PR104389]

The recent PR95115 change to punt in const_binop on folding operation
with non-NaN operands into NaN if flag_trapping_math broke the following
testcase, because the x * 0.0 simplification punts just if
x maybe a NaN (because NaN * 0.0 is NaN not 0.0) or if one of the operands
could be negative zero.  But Inf * 0.0 or -Inf * 0.0 is also NaN, not
0.0, so when NaNs are honored we need to punt for possible infinities too.

2022-02-05  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/104389
* match.pd (x * 0 -> 0): Punt if x maybe infinite and NaNs are
honored.

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

2 years agoRISC-V: Fix detection of zifencei support for binutils
Kito Cheng [Sat, 5 Feb 2022 09:24:46 +0000 (17:24 +0800)]
RISC-V: Fix detection of zifencei support for binutils

- binutils will complain version info is not found if default ISA spec
  is 2.2 for binutils.

Error: cannot find default versions of the ISA extension `zifencei'

gcc/ChangeLog:

* configure.ac: Fix detection for zifencei support.
* configure: Regenerate.

2 years agoRISC-V: Always pass -misa-spec to assembler [PR104219]
Kito Cheng [Tue, 25 Jan 2022 12:44:04 +0000 (20:44 +0800)]
RISC-V: Always pass -misa-spec to assembler [PR104219]

Add -misa-spec to OPTION_DEFAULT_SPECS to make sure -misa-spec will
always pass that into assembler, that prevent GCC and binutils using
different way to interpret the ISA string.

gcc/ChangeLog:

PR target/104219
* config.gcc (riscv*-*-*): Normalize the with_isa_spec value.
(all_defaults): Add isa_spec.
* config/riscv/riscv.h (OPTION_DEFAULT_SPECS): Add isa_spec.

2 years agoc++: assignment, aggregate, array [PR104300]
Jason Merrill [Wed, 2 Feb 2022 23:36:41 +0000 (18:36 -0500)]
c++: assignment, aggregate, array [PR104300]

The PR92385 fix meant that we see more VEC_INIT_EXPR outside of INIT_EXPR;
in such cases, we need to wrap them in TARGET_EXPR.  I previously fixed
that in build_array_copy; we also need it in process_init_constructor.
After fixing that, I needed to adjust a few places to recognize the
VEC_INIT_EXPR even inside a TARGET_EXPR.  And prevent cp_fully_fold_init
from lowering VEC_INIT_EXPR too soon.  And handle COMPOUND_EXPR inside
TARGET_EXPR better.

PR c++/104300
PR c++/92385

gcc/cp/ChangeLog:

* cp-tree.h (get_vec_init_expr): New.
(target_expr_needs_replace): New.
* cp-gimplify.cc (cp_gimplify_init_expr): Use it.
(struct cp_fold_data): New.
(cp_fold_r): Only genericize inits at end of fn.
(cp_fold_function): Here.
(cp_fully_fold_init): Not here.
* init.cc (build_vec_init): Use get_vec_init_expr.
* tree.cc (build_vec_init_expr): Likewise.
* typeck2.cc (split_nonconstant_init_1): Likewise.
(process_init_constructor): Wrap VEC_INIT_EXPR in
TARGET_EXPR.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/initlist-array14.C: New test.

2 years agoc++: add comment
Jason Merrill [Thu, 3 Feb 2022 21:23:24 +0000 (16:23 -0500)]
c++: add comment

gcc/cp/ChangeLog:

* pt.cc (iterative_hash_template_arg): Add comment.

2 years agocompiler: accept "any" as an alias for "interface{}"
Ian Lance Taylor [Tue, 1 Feb 2022 22:44:20 +0000 (14:44 -0800)]
compiler: accept "any" as an alias for "interface{}"

For golang/go#33232

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

2 years agoDaily bump.
GCC Administrator [Sat, 5 Feb 2022 00:16:31 +0000 (00:16 +0000)]
Daily bump.

2 years agolibstdc++: Fix std::filesystem build failure for Windows
Jonathan Wakely [Fri, 4 Feb 2022 23:54:17 +0000 (23:54 +0000)]
libstdc++: Fix std::filesystem build failure for Windows

The std::filesystem code needs to use posix::DIR not ::DIR, as that is
an alias for _WDIR on Windows.

libstdc++-v3/ChangeLog:

* src/filesystem/dir-common.h (_Dir_base::openat): Change return
type to use portable posix::DIR alias.

2 years agolibstdc++: Allow Clang to use <stdatomic.h> before C++23
Jonathan Wakely [Fri, 4 Feb 2022 19:42:19 +0000 (19:42 +0000)]
libstdc++: Allow Clang to use <stdatomic.h> before C++23

There is code that only expects to be compiled with clang++ and uses its
<stdatomic.h>, which works because Clang supports the _Atomic specifier
in C++. The addition  of <stdatomic.h> to libstdc++ broke this code, as
now it finds the C++ header instead, which is empty for any standard
mode before C++23.

This change allows that code to keep working as before, by forwarding to
clang's <stdatomic.h>.

libstdc++-v3/ChangeLog:

* include/c_compatibility/stdatomic.h [__clang__]: Use
#include_next <stdatomic.h>.

2 years agolibstdc++: Remove un-implementable noexcept from Filesystem TS operations
Jonathan Wakely [Fri, 4 Feb 2022 15:23:31 +0000 (15:23 +0000)]
libstdc++: Remove un-implementable noexcept from Filesystem TS operations

LWG 3014 removed these incorrect noexcept specifications from the C++17
std::filesystem operations. They are also incorrect on the experimental
TS versions and should be removed from them too.

libstdc++-v3/ChangeLog:

* include/experimental/bits/fs_ops.h (fs::copy_file): Remove
noexcept.
(fs::create_directories): Likewise.
(fs::remove_all): Likewise.
* src/filesystem/ops.cc (fs::copy_file): Remove noexcept.
(fs::create_directories): Likewise.
(fs::remove_all): Likewise.

2 years agolibstdc++: Fix filesystem::remove_all races [PR104161]
Jonathan Wakely [Tue, 1 Feb 2022 22:04:46 +0000 (22:04 +0000)]
libstdc++: Fix filesystem::remove_all races [PR104161]

This fixes the remaining filesystem::remove_all race condition by using
POSIX openat to recurse into sub-directories and using POSIX unlinkat to
remove files. This avoids the remaining race where the directory being
removed is replaced with a symlink after the directory has been opened,
so that the filesystem::remove("subdir/file") resolves to "target/file"
instead, because "subdir" has been removed and replaced with a symlink.
The previous patch only fixed the case where the directory was replaced
with a symlink before we tried to open it, but it still used the full
(potentially compromised) path as an argument to filesystem::remove.

The first part of the fix is to use openat when recursing into a
sub-directory with recursive_directory_iterator. This means that opening
"dir/subdir" uses the file descriptor for "dir", and so is sure to open
"dir/subdir" and not "symlink/subdir". (The previous patch to use
O_NOFOLLOW already ensured we won't open "dir/symlink/" here.)

The second part of the fix is to use unlinkat for the remove_all
operation. Previously we used a directory_iterator to get the name of
each file in a directory and then used filesystem::remove(iter->path())
on that name. This meant that any checks (e.g. O_NOFOLLOW) done by the
iterator could be invalidated before the remove operation on that
pathname. The directory iterator contains an open DIR stream, which we
can use to obtain a file descriptor to pass to unlinkat. This ensures
that the file being deleted really is contained within the directory
we're iterating over, rather than using a pathname that could resolve to
some other file.

The filesystem::remove_all function previously used a (non-recursive)
filesystem::directory_iterator for each directory, and called itself
recursively for sub-directories. The new implementation uses a single
filesystem::recursive_directory_iterator object, and calls a new __erase
member function on that iterator. That new __erase member function does
the actual work of removing a file (or a directory after its contents
have been iterated over and removed) using unlinkat. That means we don't
need to expose the DIR stream or its file descriptor to the remove_all
function, it's still encapuslated by the iterator class.

It would be possible to add a __rewind member to directory iterators
too, to call rewinddir after each modification to the directory. That
would make it more likely for filesystem::remove_all to successfully
remove everything even if files are being written to the directory tree
while removing it. It's unclear if that is actually prefereable, or if
it's better to fail and report an error at the first opportunity.

The necessary APIs (openat, unlinkat, fdopendir, dirfd) are defined in
POSIX.1-2008, and in Glibc since 2.10. But if the target doesn't provide
them, the original code (with race conditions) is still used.

This also reduces the number of small memory allocations needed for
std::filesystem::remove_all, because we do not store the full path to
every directory entry that is iterated over. The new filename_only
option means we only store the filename in the directory entry, as that
is all we need in order to use openat or unlinkat.

Finally, rather than duplicating everything for the Filesystem TS, the
std::experimental::filesystem::remove_all implementation now just calls
std::filesystem::remove_all to do the work.

libstdc++-v3/ChangeLog:

PR libstdc++/104161
* acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS): Check for dirfd
and unlinkat.
* config.h.in: Regenerate.
* configure: Regenerate.
* include/bits/fs_dir.h (recursive_directory_iterator): Declare
remove_all overloads as friends.
(recursive_directory_iterator::__erase): Declare new member
function.
* include/bits/fs_fwd.h (remove, remove_all): Declare.
* src/c++17/fs_dir.cc (_Dir): Add filename_only parameter to
constructor. Pass file descriptor argument to base constructor.
(_Dir::dir_and_pathname, _Dir::open_subdir, _Dir::do_unlink)
(_Dir::unlink, _Dir::rmdir): Define new member functions.
(directory_iterator): Pass filename_only argument to _Dir
constructor.
(recursive_directory_iterator::_Dir_stack): Adjust constructor
parameters to take a _Dir rvalue instead of creating one.
(_Dir_stack::orig): Add data member for storing original path.
(_Dir_stack::report_error): Define new member function.
(__directory_iterator_nofollow): Move here from dir-common.h and
fix value to be a power of two.
(__directory_iterator_filename_only): Define new constant.
(recursive_directory_iterator): Construct _Dir object and move
into _M_dirs stack. Pass skip_permission_denied argument to first
advance call.
(recursive_directory_iterator::increment): Use _Dir::open_subdir.
(recursive_directory_iterator::__erase): Define new member
function.
* src/c++17/fs_ops.cc (ErrorReporter, do_remove_all): Remove.
(fs::remove_all): Use new recursive_directory_iterator::__erase
member function.
* src/filesystem/dir-common.h (_Dir_base): Add int parameter to
constructor and use openat to implement nofollow semantics.
(_Dir_base::fdcwd, _Dir_base::set_close_on_exec, _Dir_base::openat):
Define new member functions.
(__directory_iterator_nofollow): Move to fs_dir.cc.
* src/filesystem/dir.cc (_Dir): Pass file descriptor argument to
base constructor.
(_Dir::dir_and_pathname, _Dir::open_subdir): Define new member
functions.
(recursive_directory_iterator::_Dir_stack): Adjust constructor
parameters to take a _Dir rvalue instead of creating one.
(recursive_directory_iterator): Check for new nofollow option.
Construct _Dir object and move into _M_dirs stack. Pass
skip_permission_denied argument to first advance call.
(recursive_directory_iterator::increment): Use _Dir::open_subdir.
* src/filesystem/ops.cc (fs::remove_all): Use C++17 remove_all.

2 years agors6000: More factoring of overload processing
Bill Schmidt [Thu, 3 Feb 2022 02:55:36 +0000 (20:55 -0600)]
rs6000: More factoring of overload processing

This patch continues the refactoring started with r12-6014.  I had previously
noted that the resolve_vec* routines can be further simplified by processing
the argument list earlier, so that all routines can use the arrays of arguments
and types.  I found that this was useful for some of the routines, but not for
all of them.

For several of the special-cased overloads, we don't specify all of the
possible type combinations in rs6000-overload.def, because the types don't
matter for the expansion we do.  For these, we can't use generic error message
handling when the number of arguments is incorrect, because the result is
misleading error messages that indicate argument types are wrong.

So this patch goes halfway and improves the factoring on the remaining special
cases, but leaves vec_splats, vec_promote, vec_extract, vec_insert, and
vec_step alone.

2022-02-02  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
* config/rs6000/rs6000-c.cc (resolve_vec_mul): Accept args and types
parameters instead of arglist and nargs.  Simplify accordingly.  Remove
unnecessary test for argument count mismatch.
(resolve_vec_cmpne): Likewise.
(resolve_vec_adde_sube): Likewise.
(resolve_vec_addec_subec): Likewise.
(altivec_resolve_overloaded_builtin): Move overload special handling
after the gathering of arguments into args[] and types[] and the test
for correct number of arguments.  Don't perform the test for correct
number of arguments for certain special cases.  Call the other special
cases with args and types instead of arglist and nargs.

2 years agors6000: Clean up ISA 3.1 documentation [PR100808]
Bill Schmidt [Fri, 4 Feb 2022 19:26:44 +0000 (13:26 -0600)]
rs6000: Clean up ISA 3.1 documentation [PR100808]

Due to a pasto error in the documentation, vec_replace_unaligned was
implemented with the same function prototypes as vec_replace_elt.  It was
intended that vec_replace_unaligned always specify output vectors as having
type vector unsigned char, to emphasize that elements are potentially
misaligned by this built-in function.  This patch corrects the
misimplementation.

2022-02-04  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
PR target/100808
* doc/extend.texi (Basic PowerPC Built-in Functions Available on ISA
3.1): Provide consistent type names.  Remove unnecessary semicolons.
Fix bad line breaks.

2 years agors6000: Fix up -D_FORTIFY_SOURCE* with -mabi=ieeelongdouble [PR104380]
Jakub Jelinek [Fri, 4 Feb 2022 17:30:59 +0000 (18:30 +0100)]
rs6000: Fix up -D_FORTIFY_SOURCE* with -mabi=ieeelongdouble [PR104380]

The following testcase FAILs when configured with
--with-long-double-format=ieee .  Only happens in the -std=c* modes, not the
GNU modes; while the glibc headers have __asm redirects of
vsnprintf and __vsnprinf_chk to __vsnprintfieee128 and
__vsnprintf_chkieee128, the vsnprintf fortification extern inline gnu_inline
always_inline wrapper calls __builtin_vsnprintf_chk and we actually emit
a call to __vsnprinf_chk (i.e. with IBM extended long double) instead of
__vsnprintf_chkieee128.

rs6000_mangle_decl_assembler_name already had cases for *printf and *scanf,
so this just adds another case for *printf_chk.  *scanf_chk doesn't exist.
__ prefixing isn't done because *printf_chk already starts with __.

2022-02-04  Jakub Jelinek  <jakub@redhat.com>

PR target/104380
* config/rs6000/rs6000.cc (rs6000_mangle_decl_assembler_name): Also
adjust mangling of __builtin*printf_chk.

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

2 years agoAdd optmization testcase for incorrect optimization in Ada
Eric Botcazou [Fri, 4 Feb 2022 16:41:55 +0000 (17:41 +0100)]
Add optmization testcase for incorrect optimization in Ada

gcc/testsuite/
PR tree-optimization/104356
* gnat.dg/opt97.adb: New test.

2 years agolibgomp.fortran/allocate-1.f90: Fix minor cleanup
Tobias Burnus [Fri, 4 Feb 2022 16:31:21 +0000 (17:31 +0100)]
libgomp.fortran/allocate-1.f90: Fix minor cleanup

libgomp/ChangeLog:
* testsuite/libgomp.fortran/allocate-1.f90: Remove spurious
STOP of previous commit.

2 years agodoc: Update references to "C++2a" in cpp.texi
Jonathan Wakely [Fri, 4 Feb 2022 13:23:25 +0000 (13:23 +0000)]
doc: Update references to "C++2a" in cpp.texi

gcc/ChangeLog:

* doc/cpp.texi (Variadic Macros): Replace C++2a with C++20.

2 years agolibstdc++: Add suggestion to std::uncaught_exception() warning
Jonathan Wakely [Thu, 3 Feb 2022 13:17:05 +0000 (13:17 +0000)]
libstdc++: Add suggestion to std::uncaught_exception() warning

We should use the SUGGEST macro for std::uncaught_exception()
deprecation warnings.

libstdc++-v3/ChangeLog:

* include/bits/allocator.h: Qualify std::allocator_traits in
deprecated warnings.
* libsupc++/exception (uncaught_exception): Add suggestion to
deprecated warning.

2 years agotestsuite: -mbig/-mlittle only is valid for powerpc-linux.
David Edelsohn [Fri, 4 Feb 2022 15:08:58 +0000 (10:08 -0500)]
testsuite: -mbig/-mlittle only is valid for powerpc-linux.

A recent change to some powerpc tests added explicit -mbig and -mlittle
options, but those options are not valid outside of powerpc-linux.

This patch updates the testcase options to enable -mbig when valid
and to only use -mlittle for powerpc-linux.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/builtins-1.c: Limit -mbig.
* gcc.target/powerpc/vsu/vec-cntlz-lsbb-0.c: Limit -mbig.
* gcc.target/powerpc/vsu/vec-cntlz-lsbb-1.c: Limit -mbig.
* gcc.target/powerpc/vsu/vec-cntlz-lsbb-2.c: Remove target selector.
* gcc.target/powerpc/vsu/vec-cntlz-lsbb-3.c: Only powerpc*-linux.
* gcc.target/powerpc/vsu/vec-cntlz-lsbb-4.c: Only powerpc*-linux*.
* gcc.target/powerpc/vsu/vec-cnttz-lsbb-0.c: Limit -mbig.
* gcc.target/powerpc/vsu/vec-cnttz-lsbb-1.c: Limit -mbig.
* gcc.target/powerpc/vsu/vec-cnttz-lsbb-2.c: Remove target selector.
* gcc.target/powerpc/vsu/vec-cnttz-lsbb-3.c: Only powerpc*-linux*.
* gcc.target/powerpc/vsu/vec-cnttz-lsbb-4.c: Only powerpc*-linux*.

2 years agolibgomp.fortran/allocate-1.f90: Minor cleanup
Tobias Burnus [Fri, 4 Feb 2022 13:51:01 +0000 (14:51 +0100)]
libgomp.fortran/allocate-1.f90: Minor cleanup

libgomp/ChangeLog:
* testsuite/libgomp.fortran/allocate-1.c (is_64bit_aligned): Renamed
from is_64bit_aligned_.
* testsuite/libgomp.fortran/allocate-1.f90: Fix interface decl
and use it, more implicit none, remove unused argument.

2 years agotree-optimization/100499 - niter analysis and multiple_of_p
Richard Biener [Wed, 26 Jan 2022 08:35:57 +0000 (09:35 +0100)]
tree-optimization/100499 - niter analysis and multiple_of_p

niter analysis uses multiple_of_p which currently assumes
operations like MULT_EXPR do not wrap.  We've got to rely on this
for optimizing size expressions like those in DECL_SIZE and those
generally use unsigned arithmetic with no indication that they
are not expected to wrap.  To preserve that the following adds
a parameter to multiple_of_p, defaulted to true, indicating that
the TOP expression is not expected to wrap for outer computations
in TYPE.  This mostly follows a patch proposed by Bin last year
with the conversion behavior added.

Applying to all users the new effect is that upon type conversions
in the TOP expression the behavior will switch to honor
TYPE_OVERFLOW_UNDEFINED for the converted sub-expressions.

The patch also changes the occurance in niter analysis that we
know is problematic and we have testcases for to pass false
to multiple_of_p.  The patch also contains a change to the
PR72817 fix from Bin to avoid regressing gcc.dg/tree-ssa/loop-42.c.

The intent for stage1 is to introduce a size_multiple_of_p and
internalize the added parameter so all multiple_of_p users will
honor TYPE_OVERFLOW_UNDEFINED and users dealing with size expressions
need to be switched to size_multiple_of_p.

2022-01-26  Richard Biener  <rguenther@suse.de>

PR tree-optimization/100499
* fold-const.h (multiple_of_p): Add nowrap parameter, defaulted
to true.
* fold-const.cc (multiple_of_p): Likewise.  Honor it for
MULT_EXPR, PLUS_EXPR and MINUS_EXPR and pass it along,
switching to false for conversions.
* tree-ssa-loop-niter.cc (number_of_iterations_ne): Do not
claim the outermost expression does not wrap when calling
multiple_of_p.  Refactor the check done to check the
original IV, avoiding a bias that might wrap.

* gcc.dg/torture/pr100499-1.c: New testcase.
* gcc.dg/torture/pr100499-2.c: Likewise.
* gcc.dg/torture/pr100499-3.c: Likewise.

Co-authored-by: Bin Cheng <bin.cheng@linux.alibaba.com>
2 years agofixincludes: Update pwd.
Martin Liska [Fri, 4 Feb 2022 09:24:51 +0000 (10:24 +0100)]
fixincludes: Update pwd.

fixincludes/ChangeLog:

* fixinc.in: Use cd OLDDIR instead of cd .. .

2 years agoAdjust LSHIFT_EXPR handling of multiple_of_p
Richard Biener [Mon, 24 Jan 2022 14:26:46 +0000 (15:26 +0100)]
Adjust LSHIFT_EXPR handling of multiple_of_p

This removes the odd check of size_type_node when handling left-shifts
as multiplications of 1 << N and instead uses the type as specified.
It also moves left-shift handling next to multiplications where it
semantically belongs.

2022-01-24  Richard Biener  <rguenther@suse.de>

* fold-const.cc (multiple_of_p): Re-write and move LSHIFT_EXPR
handling.

2 years agoEmpty the base_types vector before (re)populating it
Eric Botcazou [Fri, 4 Feb 2022 11:07:46 +0000 (12:07 +0100)]
Empty the base_types vector before (re)populating it

Otherwise Bad Things happen when it is populated several times.

gcc/
PR debug/104366
* dwarf2out.cc (dwarf2out_finish): Empty base_types.
(dwarf2out_early_finish): Likewise.

2 years agoDisable new 1/X optimization with -fnon-call-exceptions
Eric Botcazou [Fri, 4 Feb 2022 11:03:49 +0000 (12:03 +0100)]
Disable new 1/X optimization with -fnon-call-exceptions

The trapping behavior of the operation needs to be preserved when the
-fnon-call-exceptions switch is in effect.  This also adds the same
guards to similar optimizations.

gcc/
PR tree-optimization/104356
* match.pd (X / bool_range_Y is X): Add guard.
(X / X is one): Likewise.
(X / abs (X) is X < 0 ? -1 : 1): Likewise.
(X / -X is -1): Likewise.
(1 / X -> X == 1): Likewise.

2 years agotree-optimization/103641 - improve vect_synth_mult_by_constant
Richard Biener [Fri, 4 Feb 2022 08:26:57 +0000 (09:26 +0100)]
tree-optimization/103641 - improve vect_synth_mult_by_constant

The following happens to improve compile-time of the PR103641
testcase on aarch64 significantly.  I did not investigate the
effect on the generated code but at least in theory
choose_mult_variant should do a better job when we tell it
the actual mode we are going to use for the operations it
synthesizes.

2022-02-04  Richard Biener  <rguenther@suse.de>

PR tree-optimization/103641
* tree-vect-patterns.cc (vect_synth_mult_by_constant):
Pass the vector mode to choose_mult_variant.

2 years ago[PATCH] PR rtl-optimization/101885: Prevent combine from clobbering flags
Roger Sayle [Fri, 4 Feb 2022 09:32:21 +0000 (09:32 +0000)]
[PATCH] PR rtl-optimization/101885: Prevent combine from clobbering flags

This patch addresses PR rtl-optimization/101885 which is a P2 wrong code
regression.  In combine, if the resulting fused instruction is a parallel
of two sets which fails to be recognized by the backend, combine tries to
emit these as two sequential set instructions (known as split_i2i3).
As each set is recognized the backend may add any necessary "clobbers".
The code currently checks that any clobbers added to the first "set"
don't interfere with the second set, but doesn't currently handle the
case that clobbers added to the second set may interfere/kill the
destination of the first set (which must be live at this point).
The solution is to cut'n'paste the "clobber" logic from just a few
lines earlier, suitably adjusted for the second instruction.

One minor nit that may confuse a reviewer is that at this point in
the code we've lost track of which set was first and which was second
(combine chooses dynamically, and the recog processes that adds the
clobbers may have obfuscated the original SET_DEST) so the actual test
below is to confirm that any newly added clobbers (on the second set
instruction) don't overlap either set0's or set1's destination.

2022-02-04  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
PR rtl-optimization/101885
* combine.cc (try_combine): When splitting a parallel into two
sequential sets, check not only that the first doesn't clobber
the second but also that the second doesn't clobber the first.

gcc/testsuite/ChangeLog
PR rtl-optimization/101885
* gcc.dg/pr101885.c: New test case.

2 years agoaarch64: Add test for PR104092
Richard Sandiford [Fri, 4 Feb 2022 08:08:59 +0000 (08:08 +0000)]
aarch64: Add test for PR104092

gcc/testsuite/
PR middle-end/104092
* gcc.target/aarch64/sve/acle/general/pr104092.c: New test.

2 years agoAdd CLOBBER_EOL to mark storage end-of-life clobbers
Richard Biener [Wed, 2 Feb 2022 13:24:39 +0000 (14:24 +0100)]
Add CLOBBER_EOL to mark storage end-of-life clobbers

This adds a flag to CONSTRUCTOR nodes indicating that for
clobbers this marks the end-of-life of storage as opposed to
just ending the lifetime of the object that occupied it.
The dangling pointer diagnostics uses CLOBBERs but is confused
by those emitted by the C++ frontend for example which emits
them for the second purpose at the start of CTORs.  The issue
is also appearant for aarch64 in PR104092.

Distinguishing the two cases is also necessary for the PR90348 fix.

Since I'm going to add another flag I added an enum clobber_flags
and a defaulted argument to build_clobber plus a convenient way to
query the enum from the CTOR tree and specify it for gimple_clobber_p.
Since 'CLOBBER' is already taken and I needed a name for the unspecified
clobber we have now I used 'CLOBBER_UNDEF'.

2022-02-03  Richard Biener  <rguenther@suse.de>

PR middle-end/90348
PR middle-end/104092
gcc/
* tree-core.h (clobber_kind): New enum.
(tree_base::u::bits::address_space): Document use in CONSTRUCTORs.
* tree.h (CLOBBER_KIND): Add.
(build_clobber): Add clobber kind argument, defaulted to
CLOBBER_UNDEF.
* tree.cc (build_clobber): Likewise.
* gimple.h (gimple_clobber_p): New overload with specified kind.
* tree-streamer-in.cc (streamer_read_tree_bitfields): Stream
CLOBBER_KIND.
* tree-streamer-out.cc (streamer_write_tree_bitfields):
Likewise.
* tree-pretty-print.cc (dump_generic_node): Mark EOL CLOBBERs.
* gimplify.cc (gimplify_bind_expr): Build storage end-of-life clobbers
with CLOBBER_EOL.
(gimplify_target_expr): Likewise.
* tree-inline.cc (expand_call_inline): Likewise.
* tree-ssa-ccp.cc (insert_clobber_before_stack_restore): Likewise.
* gimple-ssa-warn-access.cc (pass_waccess::check_stmt): Only treat
CLOBBER_EOL clobbers as ending lifetime of storage.

gcc/lto/
* lto-common.cc (compare_tree_sccs_1): Compare CLOBBER_KIND.

gcc/testsuite/
* gcc.dg/pr87052.c: Adjust.

2 years agoUse auto_vec for pointer_query cache for auto cleanup.
Martin Sebor [Fri, 4 Feb 2022 02:44:44 +0000 (19:44 -0700)]
Use auto_vec for pointer_query cache for auto cleanup.

gcc/Changelog:

* pointer-query.h (pointer_query::cache_type): Use auto_vec for auto
cleanup.

2 years agoDaily bump.
GCC Administrator [Fri, 4 Feb 2022 00:16:24 +0000 (00:16 +0000)]
Daily bump.

2 years agoc++: dependence of member noexcept-spec [PR104079]
Patrick Palka [Thu, 3 Feb 2022 23:54:23 +0000 (18:54 -0500)]
c++: dependence of member noexcept-spec [PR104079]

Here a stale TYPE_DEPENDENT_P/_P_VALID value for f's function type
after replacing the type's DEFERRED_NOEXCEPT with the parsed dependent
noexcept-spec causes us to try to instantiate g's noexcept-spec ahead
of time (since it in turn appears non-dependent), leading to an ICE.

This patch fixes this by clearing TYPE_DEPENDENT_P_VALID in
fixup_deferred_exception_variants appropriately (as in
build_cp_fntype_variant).

That turns out to fix the testcase for C++17 but not for C++11/14,
because it's not until C++17 that a noexcept-spec is part of (and
therefore affects dependence of) the function type.  Since dependence of
NOEXCEPT_EXPR is defined in terms of instantiation dependence, the most
appropriate fix for earlier dialects seems to be to make instantiation
dependence consider dependence of a noexcept-spec.

PR c++/104079

gcc/cp/ChangeLog:

* pt.cc (value_dependent_noexcept_spec_p): New predicate split
out from ...
(dependent_type_p_r): ... here.
(instantiation_dependent_r): Use value_dependent_noexcept_spec_p
to consider dependence of a noexcept-spec before C++17.
* tree.cc (fixup_deferred_exception_variants): Clear
TYPE_DEPENDENT_P_VALID.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/noexcept74.C: New test.
* g++.dg/cpp0x/noexcept74a.C: New test.

2 years agoanalyzer: fixes to realloc-handling [PR104369]
David Malcolm [Wed, 2 Feb 2022 21:39:12 +0000 (16:39 -0500)]
analyzer: fixes to realloc-handling [PR104369]

This patch fixes various issues with how -fanalyzer handles "realloc"
seen when debugging PR analyzer/104369.

Previously it wasn't correctly copying over the contents of the old
buffer for the success-with-move case, leading to false
-Wanalyzer-use-of-uninitialized-value diagnostics.

I also noticed that -fanalyzer failed to properly handle "realloc" for
cases where the ptr's region had unknown dynamic extents, and an ICE
for the case where a tainted value is used as a realloc size argument.

This patch fixes these issues, including the false uninit diagnostics
seen in PR analyzer/104369.

gcc/analyzer/ChangeLog:
PR analyzer/104369
* engine.cc (exploded_graph::process_node): Use the node for any
diagnostics, avoiding ICE if a bifurcation update adds a
saved_diagnostic, such as for a tainted realloc size.
* region-model-impl-calls.cc
(region_model::impl_call_realloc::success_no_move::update_model):
Require the old pointer to be non-NULL to be able successfully
grow in place.  Use model->deref_rvalue rather than maybe_get_region
to support the old pointer being symbolic.
(region_model::impl_call_realloc::success_with_move::update_model):
Likewise.  Add a constraint that the new pointer != the old pointer.
Use a sized_region when setting the value of the new region.
Handle the case where we don't know the dynamic size of the old
region by marking the new region as unknown.
* sm-taint.cc (tainted_allocation_size::tainted_allocation_size):
Update assertion to also allow for MEMSPACE_UNKNOWN.
(tainted_allocation_size::emit): Likewise.
(region_model::check_dynamic_size_for_taint): Likewise.

gcc/testsuite/ChangeLog:
PR analyzer/104369
* gcc.dg/analyzer/pr104369-1.c: New test.
* gcc.dg/analyzer/pr104369-2.c: New test.
* gcc.dg/analyzer/realloc-3.c: New test.
* gcc.dg/analyzer/realloc-4.c: New test.
* gcc.dg/analyzer/taint-realloc.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoanalyzer: fix zero-fill of calloc
David Malcolm [Thu, 3 Feb 2022 16:15:48 +0000 (11:15 -0500)]
analyzer: fix zero-fill of calloc

It turned out that the analyzer wasn't treating calloc regions
as zero-filled, due to binding_cluster::fill_region getting an
unknown value for the byte_size_size_sval, and thus
get_or_create_repeated_svalue returning an unknown_svalue, which
was then used to fill the region.

Fixed thusly.

gcc/analyzer/ChangeLog:
* region-model-impl-calls.cc (region_model::impl_call_calloc): Use
a sized_region when calling zero_fill_region.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/calloc-1.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoAdjust warn_access pass placement [PR104260].
Martin Sebor [Thu, 3 Feb 2022 21:51:46 +0000 (14:51 -0700)]
Adjust warn_access pass placement [PR104260].

Resolves:
PR middle-end/104260 - Misplaced waccess3 pass

gcc/ChangeLog:

PR middle-end/104260
* passes.def (pass_warn_access): Adjust pass placement.

2 years agoi386: Do not use %ecx DRAP for functions that use __builtin_eh_return [PR104362]
Uros Bizjak [Thu, 3 Feb 2022 21:24:21 +0000 (22:24 +0100)]
i386: Do not use %ecx DRAP for functions that use __builtin_eh_return [PR104362]

%ecx can't be used for both DRAP register and eh_return.  Adjust find_drap_reg
to choose %edi for functions that uses __builtin_eh_return to avoid the assert
in ix86_expand_epilogue that enforces this rule.

2022-02-03  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

PR target/104362
* config/i386/i386.cc (find_drap_reg): For 32bit targets
return DI_REG if function uses __builtin_eh_return.

gcc/testsuite/ChangeLog:

PR target/104362
* gcc.target/i386/pr104362.c: New test.

2 years agoEnable pointer_query caching in -Wrestrict.
Martin Sebor [Thu, 3 Feb 2022 20:59:39 +0000 (13:59 -0700)]
Enable pointer_query caching in -Wrestrict.

gcc/ChangeLog:

* gimple-ssa-warn-restrict.cc (class pass_wrestrict): Outline ctor.
(pass_wrestrict::m_ptr_qry): New member.
(wrestrict_walk): Rename...
(pass_wrestrict::check_block): ...to this.
(pass_wrestrict::execute): Set up and tear down pointer_query and
ranger.
(builtin_memref::builtin_memref): Change ctor argument.  Simplify.
(builtin_access::builtin_access): Same.
(builtin_access::m_ptr_qry): New member.
(check_call): Rename...
(pass_wrestrict::check_call): ...to this.
(check_bounds_or_overlap): Change argument.
* gimple-ssa-warn-restrict.h (check_bounds_or_overlap): Same.

2 years agoEnable pointer_query caching in -Warray-bounds.
Martin Sebor [Thu, 3 Feb 2022 20:58:28 +0000 (13:58 -0700)]
Enable pointer_query caching in -Warray-bounds.

gcc/ChangeLog:

* gimple-array-bounds.cc (array_bounds_checker::array_bounds_checker):
Define ctor.
(array_bounds_checker::get_value_range): Use new member.
(array_bounds_checker::check_mem_ref): Same.
* gimple-array-bounds.h (array_bounds_checker::array_bounds_checker):
Outline ctor.
(array_bounds_checker::m_ptr_query): New member.

2 years agoMake pointer_query cache a private member.
Martin Sebor [Thu, 3 Feb 2022 20:56:50 +0000 (13:56 -0700)]
Make pointer_query cache a private member.

gcc/ChangeLog:

* gimple-ssa-warn-access.cc (pass_waccess::pass_waccess): Remove
pointer_query cache.
* pointer-query.cc (pointer_query::pointer_query): Remove cache
argument.  Zero-initialize new cache member.
(pointer_query::get_ref): Replace cache pointer with direct access.
(pointer_query::put_ref): Same.
(pointer_query::flush_cache): Same.
(pointer_query::dump): Same.
* pointer-query.h (class pointer_query): Remove cache argument from
ctor.  Change cache pointer to cache subobject member.
* tree-ssa-strlen.cc: Remove pointer_query cache.

2 years agoConstrain conservative string lengths to array sizes [PR104119].
Martin Sebor [Thu, 3 Feb 2022 20:27:16 +0000 (13:27 -0700)]
Constrain conservative string lengths to array sizes [PR104119].

Resolves:
PR tree-optimization/104119 - unexpected -Wformat-overflow after strlen in ILP32 since Ranger integration

gcc/ChangeLog:

PR tree-optimization/104119
* gimple-ssa-sprintf.cc (struct directive): Change argument type.
(format_none): Same.
(format_percent): Same.
(format_integer): Same.
(format_floating): Same.
(get_string_length): Same.
(format_character): Same.
(format_string): Same.
(format_plain): Same.
(format_directive): Same.
(compute_format_length): Same.
(handle_printf_call): Same.
* tree-ssa-strlen.cc (get_range_strlen_dynamic): Same.   Call
get_maxbound.
(get_range_strlen_phi): Same.
(get_maxbound): New function.
(strlen_pass::get_len_or_size): Adjust to parameter change.
* tree-ssa-strlen.h (get_range_strlen_dynamic): Change argument type.

gcc/testsuite/ChangeLog:

PR tree-optimization/104119
* gcc.dg/tree-ssa/builtin-snprintf-13.c: New test.
* gcc.dg/tree-ssa/builtin-sprintf-warn-29.c: New test.

2 years agoFortran: reject simplifying TRANSFER for MOLD with storage size 0
Harald Anlauf [Tue, 1 Feb 2022 22:33:24 +0000 (23:33 +0100)]
Fortran: reject simplifying TRANSFER for MOLD with storage size 0

gcc/fortran/ChangeLog:

PR fortran/104311
* check.cc (gfc_calculate_transfer_sizes): Checks for case when
storage size of SOURCE is greater than zero while the storage size
of MOLD is zero and MOLD is an array shall not depend on SIZE.

gcc/testsuite/ChangeLog:

PR fortran/104311
* gfortran.dg/transfer_simplify_15.f90: New test.

2 years agoSpeed up fixincludes.
Martin Liska [Thu, 3 Feb 2022 14:49:43 +0000 (15:49 +0100)]
Speed up fixincludes.

In my case:
$ rm ./stmp-fixinc ; time make -j16

takes 17 seconds, where I can reduce it easily with the suggested
change. Then I get to 11.2 seconds.

The scripts searches ~2500 folders in my case with total 20K header
files.

fixincludes/ChangeLog:

* fixinc.in: Use mkdir -p rather that a loop.

2 years agors6000: Remove -m[no-]fold-gimple flag [PR103686]
Bill Schmidt [Thu, 3 Feb 2022 03:30:27 +0000 (21:30 -0600)]
rs6000: Remove -m[no-]fold-gimple flag [PR103686]

The -m[no-]fold-gimple flag was really intended primarily for internal
testing while implementing GIMPLE folding for rs6000 vector built-in
functions.  It ended up leaking into other places, causing problems such
as PR103686 identifies.  Let's remove it.

There are a number of tests in the testsuite that require adjustment.
Some specify -mfold-gimple directly, which is the default, so that is
handled by removing the option.  Others unnecessarily specify
-mno-fold-gimple, as the tests work fine without this.  Again that is
handled by removing the option.  There are a couple of extra variants of
tests specifically for -mno-fold-gimple; for those, we can just remove the
whole test.

gcc.target/powerpc/builtins-1.c was more problematic.  It was written in
such a way as to be extremely fragile.  For this one, I rewrote the whole
test in a different style, using individual functions to test each
built-in function.  These same tests are also largely covered by
builtins-1-be-folded.c and builtins-1-le-folded.c, so I chose to
explicitly make this test -mbig for simplicity, and use -O2 for clean code
generation.  I made some slight modifications to the expected instruction
counts as a result, and tested on both 32- and 64-bit.

2022-02-02  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
PR target/103686
* config/rs6000/rs6000-builtin.cc (rs6000_gimple_fold_builtin): Remove
test for !rs6000_fold_gimple.
* config/rs6000/rs6000.cc (rs6000_option_override_internal): Likewise.
* config/rs6000/rs6000.opt (mfold-gimple): Remove.

gcc/testsuite/
PR target/103686
* gcc.target/powerpc/builtins-1-be-folded.c: Remove -mfold-gimple
option.
* gcc.target/powerpc/builtins-1-le-folded.c: Likewise.
* gcc.target/powerpc/builtins-1.c: Rewrite to use small functions and
restrict to -O2 -mbig for predictability.  Adjust instruction counts.
* gcc.target/powerpc/builtins-5.c: Remove -mno-fold-gimple option.
* gcc.target/powerpc/p8-vec-xl-xst.c: Likewise.
* gcc.target/powerpc/pr83926.c: Likewise.
* gcc.target/powerpc/pr86731-nogimplefold-longlong.c: Delete.
* gcc.target/powerpc/pr86731-nogimplefold.c: Delete.
* gcc.target/powerpc/swaps-p8-17.c: Remove -mno-fold-gimple option.

2 years agors6000: Fix LE code gen for vec_cnt[lt]z_lsbb [PR95082]
Bill Schmidt [Thu, 3 Feb 2022 03:24:22 +0000 (21:24 -0600)]
rs6000: Fix LE code gen for vec_cnt[lt]z_lsbb [PR95082]

These built-ins were misimplemented as always having big-endian semantics.

2022-01-18  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
PR target/95082
* config/rs6000/rs6000-builtin.cc (rs6000_expand_builtin): Handle
endianness for vclzlsbb and vctzlsbb.
* config/rs6000/rs6000-builtins.def (VCLZLSBB_V16QI): Change
default pattern and indicate a different pattern will be used for
big endian.
(VCLZLSBB_V4SI): Likewise.
(VCLZLSBB_V8HI): Likewise.
(VCTZLSBB_V16QI): Likewise.
(VCTZLSBB_V4SI): Likewise.
(VCTZLSBB_V8HI): Likewise.

gcc/testsuite/
PR target/95082
* gcc.target/powerpc/vsu/vec-cntlz-lsbb-0.c: Restrict to -mbig.
* gcc.target/powerpc/vsu/vec-cntlz-lsbb-1.c: Likewise.
* gcc.target/powerpc/vsu/vec-cntlz-lsbb-3.c: New.
* gcc.target/powerpc/vsu/vec-cntlz-lsbb-4.c: New.
* gcc.target/powerpc/vsu/vec-cnttz-lsbb-0.c: Restrict to -mbig.
* gcc.target/powerpc/vsu/vec-cnttz-lsbb-1.c: Likewise.
* gcc.target/powerpc/vsu/vec-cnttz-lsbb-3.c: New.
* gcc.target/powerpc/vsu/vec-cnttz-lsbb-4.c: New.

2 years agors6000: Consolidate target built-ins code
Bill Schmidt [Thu, 3 Feb 2022 16:26:29 +0000 (10:26 -0600)]
rs6000: Consolidate target built-ins code

Continuing with the refactoring effort, this patch moves as much of the
target-specific built-in support code into a new file, rs6000-builtin.cc.
However, we can't easily move the overloading support code out of
rs6000-c.cc, because the build machinery understands that as a special file
to be included with the C and C++ front ends.

This patch is just a straightforward move, with one exception.  I found
that the builtin_mode_to_type[] array is no longer used, so I also removed
all code having to do with it.

The code in rs6000-builtin.cc is organized in related sections:
 - General support functions
 - Initialization support
 - GIMPLE folding support
 - Expansion support

Overloading support remains in rs6000-c.cc.

2022-02-03  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
* config.gcc (powerpc*-*-*): Add rs6000-builtin.o to extra_objs.
* config/rs6000/rs6000-builtin.cc: New file, containing code moved
from other files.
* config/rs6000/rs6000-call.cc (cpu_is_info): Move to
rs6000-builtin.cc.
(cpu_supports_info): Likewise.
(rs6000_type_string): Likewise.
(altivec_expand_predicate_builtin): Likewise.
(rs6000_htm_spr_icode): Likewise.
(altivec_expand_vec_init_builtin): Likewise.
(get_element_number): Likewise.
(altivec_expand_vec_set_builtin): Likewise.
(altivec_expand_vec_ext_builtin): Likewise.
(rs6000_invalid_builtin): Likewise.
(rs6000_fold_builtin): Likewise.
(fold_build_vec_cmp): Likewise.
(fold_compare_helper): Likewise.
(map_to_integral_tree_type): Likewise.
(fold_mergehl_helper): Likewise.
(fold_mergeeo_helper): Likewise.
(rs6000_builtin_valid_without_lhs): Likewise.
(rs6000_builtin_is_supported): Likewise.
(rs6000_gimple_fold_mma_builtin): Likewise.
(rs6000_gimple_fold_builtin): Likewise.
(rs6000_expand_ldst_mask): Likewise.
(cpu_expand_builtin): Likewise.
(elemrev_icode): Likewise.
(ldv_expand_builtin): Likewise.
(lxvrse_expand_builtin): Likewise.
(lxvrze_expand_builtin): Likewise.
(stv_expand_builtin): Likewise.
(mma_expand_builtin): Likewise.
(htm_spr_num): Likewise.
(htm_expand_builtin): Likewise.
(rs6000_expand_builtin): Likewise.
(rs6000_vector_type): Likewise.
(rs6000_init_builtins): Likewise.  Remove initialization of
builtin_mode_to_type entries.
(rs6000_builtin_decl): Move to rs6000-builtin.cc.
* config/rs6000/rs6000.cc (rs6000_builtin_mask_for_load): New
external declaration.
(rs6000_builtin_md_vectorized_function): Likewise.
(rs6000_builtin_reciprocal): Likewise.
(altivec_builtin_mask_for_load): Move to rs6000-builtin.cc.
(rs6000_builtin_types): Likewise.
(builtin_mode_to_type): Remove.
(rs6000_builtin_mask_for_load): Move to rs6000-builtin.cc.  Remove
static qualifier.
(rs6000_builtin_md_vectorized_function): Likewise.
(rs6000_builtin_reciprocal): Likewise.
* config/rs6000/rs6000.h (builtin_mode_to_type): Remove.
* config/rs6000/t-rs6000 (rs6000-builtin.o): New target.

2 years agomake `-Werror` optional in libatomic/libbacktrace/libgomp/libitm/libsanitizer
David Seifert [Thu, 3 Feb 2022 14:47:10 +0000 (15:47 +0100)]
make `-Werror` optional in libatomic/libbacktrace/libgomp/libitm/libsanitizer

* `-Werror` can cause issues when a more recent version of GCC compiles
  an older version:
  - https://bugs.gentoo.org/229059
  - https://bugs.gentoo.org/475350
  - https://bugs.gentoo.org/667104

libatomic/ChangeLog:

* configure.ac: Support --disable-werror.
* configure: Regenerate.

libbacktrace/ChangeLog:

* configure.ac: Support --disable-werror.
* configure: Regenerate.

libgomp/ChangeLog:

* configure.ac: Support --disable-werror.
* configure: Regenerate.

libitm/ChangeLog:

* configure.ac: Support --disable-werror.
* configure: Regenerate.

libsanitizer/ChangeLog:

* configure.ac: Support --disable-werror.
* aclocal.m4: Include also ../config/warnings.m4.
* libbacktrace/Makefile.am (WARN_FLAGS): Remove.
* configure: Regenerate.
* Makefile.in: Regenerate.
* asan/Makefile.in: Regenerate.
* hwasan/Makefile.in: Regenerate.
* interception/Makefile.in: Regenerate.
* libbacktrace/Makefile.in: Regenerate.
* lsan/Makefile.in: Regenerate.
* sanitizer_common/Makefile.in: Regenerate.
* tsan/Makefile.in: Regenerate.
* ubsan/Makefile.in: Regenerate.

Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
2 years agodebug/104337 - avoid messing with the abstract origin chain in NRV
Richard Biener [Thu, 3 Feb 2022 10:20:59 +0000 (11:20 +0100)]
debug/104337 - avoid messing with the abstract origin chain in NRV

The following avoids NRV from massaging DECL_ABSTRACT_ORIGIN after
variable creation since NRV runs _after_ the function was inlined and thus
affects the inlined variables copy indirectly.  We may adjust the abstract
origin of a variable only at the point we create it, not further along the
path since otherwise the (new) invariant that the abstract origin is always
the ultimate origin cannot be maintained.

The intent of what NRV does is OK I guess and it may improve the debug
experience.  But I also notice we do

  SET_DECL_VALUE_EXPR (found, result);
  DECL_HAS_VALUE_EXPR_P (found) = 1;

the code is there since the merge from tree-ssa which added tree-nrv.c.

Jakub added the DECL_VALUE_EXPR in g:938650d8fddb878f623e315f0b7fd94b217efa96
and Jason added the abstract origin setting conditional in g:7716876bbd3a

The follwoing takes the radical approach and remove the attempt
to "optimize" the debug info.

The gdb testsuites show no regressions.

2022-02-03  Richard Biener  <rguenther@suse.de>

PR debug/104337
* tree-nrv.cc (pass_nrv::execute): Remove tieing result and found
together via DECL_ABSTRACT_ORIGIN.

* gcc.dg/debug/pr104337.c: New testcase.

2 years agors6000: Unify error messages for built-in constant restrictions
Bill Schmidt [Thu, 3 Feb 2022 02:59:00 +0000 (20:59 -0600)]
rs6000: Unify error messages for built-in constant restrictions

We currently give different error messages for built-in functions that
violate range restrictions on their arguments, depending on whether we
record them as requiring an n-bit literal or a literal between two values.
It's better to be consistent.  Change the error message for the n-bit
literal to look like the other one.

2022-02-02  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
* config/rs6000/rs6000-call.cc (rs6000_expand_builtin): Revise error
message for RES_BITS case.

gcc/testsuite/
* gcc.target/powerpc/bfp/scalar-test-data-class-10.c: Adjust error
messages.
* gcc.target/powerpc/bfp/scalar-test-data-class-2.c: Likewise.
* gcc.target/powerpc/bfp/scalar-test-data-class-3.c: Likewise.
* gcc.target/powerpc/bfp/scalar-test-data-class-4.c: Likewise.
* gcc.target/powerpc/bfp/scalar-test-data-class-5.c: Likewise.
* gcc.target/powerpc/bfp/scalar-test-data-class-9.c: Likewise.
* gcc.target/powerpc/bfp/vec-test-data-class-4.c: Likewise.
* gcc.target/powerpc/bfp/vec-test-data-class-5.c: Likewise.
* gcc.target/powerpc/bfp/vec-test-data-class-6.c: Likewise.
* gcc.target/powerpc/bfp/vec-test-data-class-7.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-12.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-14.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-17.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-19.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-2.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-22.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-24.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-27.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-29.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-32.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-34.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-37.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-39.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-4.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-42.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-44.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-47.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-49.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-52.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-54.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-57.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-59.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-62.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-64.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-67.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-69.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-7.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-72.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-74.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-77.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-79.c: Likewise.
* gcc.target/powerpc/dfp/dtstsfi-9.c: Likewise.
* gcc.target/powerpc/pr80315-1.c: Likewise.
* gcc.target/powerpc/pr80315-2.c: Likewise.
* gcc.target/powerpc/pr80315-3.c: Likewise.
* gcc.target/powerpc/pr80315-4.c: Likewise.
* gcc.target/powerpc/pr82015.c: Likewise.
* gcc.target/powerpc/pr91903.c: Likewise.
* gcc.target/powerpc/test_fpscr_rn_builtin_error.c: Likewise.
* gcc.target/powerpc/vec-ternarylogic-10.c: Likewise.

2 years agoranger: fix small thinko in fur_list constructor
Aldy Hernandez [Thu, 3 Feb 2022 14:45:55 +0000 (15:45 +0100)]
ranger: fix small thinko in fur_list constructor

The fur_list constructor for two ranges is leaving [1] in an undefined
state.  The reason we haven't noticed is because after all the
shuffling in the last cycle there are no remaining users of it
(similarly for fur_list(unsigned, irange *)).

Since it's very late in the cycle, I would prefer to fix this, rather
than removing unused constructors altogether.  Besides, we have uses
of them queued up for the next release.

gcc/ChangeLog:

* gimple-range-fold.cc (fur_list::fur_list): Set m_local[1] correctly.

2 years agoarm: Fix up help.exp regression
Jakub Jelinek [Thu, 3 Feb 2022 13:34:21 +0000 (14:34 +0100)]
arm: Fix up help.exp regression

On Thu, Jan 20, 2022 at 11:27:20AM +0000, Richard Earnshaw via Gcc-patches wrote:
> gcc/ChangeLog:
>
>       * config/arm/arm.opt (mfix-cortex-a57-aes-1742098): New command-line
>       option.
>       (mfix-cortex-a72-aes-1655431): New option alias.

> --- a/gcc/config/arm/arm.opt
> +++ b/gcc/config/arm/arm.opt
> @@ -272,6 +272,16 @@ mfix-cmse-cve-2021-35465
>  Target Var(fix_vlldm) Init(2)
>  Mitigate issues with VLLDM on some M-profile devices (CVE-2021-35465).
>
> +mfix-cortex-a57-aes-1742098
> +Target Var(fix_aes_erratum_1742098) Init(2) Save
> +Mitigate issues with AES instructions on Cortex-A57 and Cortex-A72.
> +Arm erratum #1742098
> +
> +mfix-cortex-a72-aes-1655431
> +Target Alias(mfix-cortex-a57-aes-1742098)
> +Mitigate issues with AES instructions on Cortex-A57 and Cortex-A72.
> +Arm erratum #1655431
> +
>  munaligned-access
>  Target Var(unaligned_access) Init(2) Save
>  Enable unaligned word and halfword accesses to packed data.

This breaks:
Running /usr/src/gcc/gcc/testsuite/gcc.misc-tests/help.exp ...
FAIL: compiler driver --help=target option(s): "^ +-.*[^:.]$" absent from output: "  -mfix-cortex-a57-aes-1742098 Mitigate issues with AES instructions on Cortex-A57 and Cortex-A72. Arm erratum #1742098"

help.exp with help of lib/options.exp tests whether all non-empty descriptions of
options are terminated with . or :.

2022-02-03  Jakub Jelinek  <jakub@redhat.com>

* config/arm/arm.opt (mfix-cortex-a57-aes-1742098,
mfix-cortex-a72-aes-1655431): Ensure description ends with full stop.

2 years agoAssert that backedges are available in path solver.
Aldy Hernandez [Fri, 21 Jan 2022 12:04:20 +0000 (13:04 +0100)]
Assert that backedges are available in path solver.

gcc/ChangeLog:

* cfganal.cc (verify_marked_backedges): New.
* cfganal.h (verify_marked_backedges): New.
* gimple-range-path.cc (path_range_query::path_range_query):
Verify freshness of back edges.
* tree-ssa-loop-ch.cc (ch_base::copy_headers): Call
mark_dfs_back_edges.
* tree-ssa-threadbackward.cc (back_threader::back_threader): Move
path_range_query construction after backedges have been
updated.

2 years agoSkip gnat.dg/div_zero.adb on PowerPC
Eric Botcazou [Thu, 3 Feb 2022 12:12:37 +0000 (13:12 +0100)]
Skip gnat.dg/div_zero.adb on PowerPC

The hardware instruction does not trap on divide by zero there.

gcc/testsuite
PR tree-optimization/104356
* gnat.dg/div_zero.adb: Add dg-skip-if directive for PowerPC.

2 years agoaarch64: Remove struct_vect_25.c XFAILs
Richard Sandiford [Thu, 3 Feb 2022 10:44:01 +0000 (10:44 +0000)]
aarch64: Remove struct_vect_25.c XFAILs

At some point we started generating the intended code for
aarch64/sve/struct_vect_25.c.  This patch removes the xfails
and the scan-assembler-times that replaced the xfailed forms.

gcc/testsuite/
* gcc.target/aarch64/sve/struct_vect_25.c: Remove XFAILs.

2 years agoaarch64: Adjust tests after fix for PR102659
Richard Sandiford [Thu, 3 Feb 2022 10:44:01 +0000 (10:44 +0000)]
aarch64: Adjust tests after fix for PR102659

After the fix for PR102659, the vectoriser can no longer group
conditional accesses of the form:

  for (int i = 0; i < n; ++i)
    if (...)
      ...a[i * 2] + a[i * 2 + 1]...;

on LP64 targets.  It has to treat them as two independent
gathers instead.

This was causing failures in the sve mask_struct*.c tests.
The tests weren't really testing that int iterators could
be used, so this patch switches to pointer-sized iterators
instead.

gcc/testsuite/
* gcc.target/aarch64/sve/mask_struct_load_1.c: Use intptr_t
iterators instead of int iterators.
* gcc.target/aarch64/sve/mask_struct_load_2.c: Likewise.
* gcc.target/aarch64/sve/mask_struct_load_3.c: Likewise.
* gcc.target/aarch64/sve/mask_struct_load_4.c: Likewise.
* gcc.target/aarch64/sve/mask_struct_load_5.c: Likewise.
* gcc.target/aarch64/sve/mask_struct_load_6.c: Likewise.
* gcc.target/aarch64/sve/mask_struct_load_7.c: Likewise.
* gcc.target/aarch64/sve/mask_struct_load_8.c: Likewise.
* gcc.target/aarch64/sve/mask_struct_store_1.c: Likewise.
* gcc.target/aarch64/sve/mask_struct_store_2.c: Likewise.
* gcc.target/aarch64/sve/mask_struct_store_3.c: Likewise.
* gcc.target/aarch64/sve/mask_struct_store_4.c: Likewise.