platform/upstream/gcc.git
3 years agolibstdc++: Fix brainwrong in path::_S_convert(T) [PR102743]
Jonathan Wakely [Thu, 14 Oct 2021 12:20:57 +0000 (13:20 +0100)]
libstdc++: Fix brainwrong in path::_S_convert(T) [PR102743]

This function was supposed to check whether the parameter's value type
is the same as path::value_type, and therefore needs no conversion.
Instead it checks whether the parameter is the same as its own value
type, which is never true. This means we incorrectly return a string
view for the case where T is path::string_type, instead of just
returning the string itself. The only place that happens is
path::_S_convert_loc for Windows, where we call _S_convert with a
std::wstring rvalue.

This fixes the condition in _S_convert(T).

libstdc++-v3/ChangeLog:

PR libstdc++/102743
* include/bits/fs_path.h (path::_S_convert(T)): Fix condition
for returning the same string unchanged.

3 years agolibstdc++: Use more descriptive feature test macro
Jonathan Wakely [Wed, 6 Oct 2021 19:03:50 +0000 (20:03 +0100)]
libstdc++: Use more descriptive feature test macro

The out-of-class definitions of the static constants are redundant if
the __cpp_inline_variables feature is supported, so use that macro to
decide whether to define them or not.

libstdc++-v3/ChangeLog:

* include/bits/regex.h: Check __cpp_inline_variables instead of
__cplusplus.

3 years agosve: optimize add reduction patterns
Tamar Christina [Thu, 14 Oct 2021 14:07:14 +0000 (15:07 +0100)]
sve: optimize add reduction patterns

The following loop does a conditional reduction using an add:

#include <stdint.h>

int32_t f (int32_t *restrict array, int len, int min)
{
  int32_t iSum = 0;

  for (int i=0; i<len; i++) {
    if (array[i] >= min)
       iSum += array[i];
  }
  return iSum;
}

for this we currently generate:

        mov     z1.b, #0
        mov     z2.s, w2
        mov     z3.d, z1.d
        ptrue   p2.b, all
        ld1w    z0.s, p0/z, [x0, x3, lsl 2]
        cmpge   p1.s, p2/z, z0.s, z2.s
        add     x3, x3, x4
        sel     z0.s, p1, z0.s, z3.s
        add     z1.s, p0/m, z1.s, z0.s
        whilelo p0.s, w3, w1

where the SEL is unneeded as it's selecting between 0 or a value.  This can be
optimized to just doing the conditional add on p1 instead of p0.  After this
patch we generate:

        mov     z2.s, w2
        mov     z0.b, #0
        ptrue   p1.b, all
        ld1w    z1.s, p0/z, [x0, x3, lsl 2]
        cmpge   p0.s, p0/z, z1.s, z2.s
        add     x3, x3, x4
        add     z0.s, p0/m, z0.s, z1.s
        whilelo p0.s, w3, w1

and so we drop the SEL and the 0 move.

gcc/ChangeLog:

* match.pd: New rule.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sve/pred-cond-reduc.c: New test.

3 years agoFix ICE in insert_access.
Jan Hubicka [Thu, 14 Oct 2021 13:48:01 +0000 (15:48 +0200)]
Fix ICE in insert_access.

gcc/ChangeLog:

PR ipa/102557
* ipa-modref-tree.h (modref_access_node::update2):
Also check that parm_offset is unchanged.
(modref_ref_node::insert_access): Fix updating of
parameter.

3 years agoAdd FIXME note to backward threader.
Aldy Hernandez [Thu, 14 Oct 2021 13:00:46 +0000 (15:00 +0200)]
Add FIXME note to backward threader.

There's a limitation in the path discovery bits in the backward
threader that I ran into recently and I'd like to document it so we
don't lose track of it.

Basically we stop looking if we find a threadable path through a PHI,
without taking into account that there could be multiple
paths through a PHI that resolve the path.  For example:

x_5 = PHI <10(4), 20(5), ...>
if (x_5 > 5)

I don't remember how we ended up skipping this, but it could existing
behavior from the old bits.  It probably skipped multiple threads
through a PHI since the generic copier couldn't re-using existing
threading paths anyhow.

Documenting for later fixing.

gcc/ChangeLog:

* tree-ssa-threadbackward.c (back_threader::resolve_phi): Add
FIXME note.

3 years agoFix predcom-3.c on arc-elf after vectorizer changes
Jeff Law [Thu, 14 Oct 2021 13:41:57 +0000 (09:41 -0400)]
Fix predcom-3.c on arc-elf after vectorizer changes

gcc/testsuite
* gcc.dg/tree-ssa/predcom-3.c: Disable vectorizer.

3 years agotree-optimization/102659 - really avoid undef overflow in if-conversion
Richard Biener [Thu, 14 Oct 2021 07:00:25 +0000 (09:00 +0200)]
tree-optimization/102659 - really avoid undef overflow in if-conversion

This plugs the remaining hole of POINTER_PLUS_EXPR with undefined
overflow.  Unfortunately we have to go through some lengths to
not put invariant conversions into the loop body since that confuses
the vectorizers gather/scatter discovery which relies on identifying
an invariant component of plus and minus expressions.  We can
emit those in the loop preheader but then we have to accept that
being non-empty when looking for the LOOP_VECTORIZED internal
function call in the vectorizer.

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

PR tree-optimization/102659
* tree-if-conv.c (if_convertible_gimple_assign_stmt_p): Also
rewrite pointer typed undefined overflow operations.
(predicate_statements): Likewise.  Make sure to emit invariant
conversions in the preheader.
* tree-vectorizer.c (vect_loop_vectorized_call): Look through
non-empty preheaders.
* tree-data-ref.c (dr_analyze_indices): Strip useless
conversions to the MEM_REF base type.

3 years agoEliminate AUTODETECT_VALUE usage in options.
Martin Liska [Tue, 12 Oct 2021 12:31:50 +0000 (14:31 +0200)]
Eliminate AUTODETECT_VALUE usage in options.

gcc/ChangeLog:

* common.opt: Stop using AUTODETECT_VALUE
and use EnabledBy where possible.
* opts.c: Enable OPT_fvar_tracking with optimize >= 1.
* toplev.c (AUTODETECT_VALUE): Remove macro.
(process_options): Simplify by using EnabledBy and
OPT_fvar_tracking.  Use OPTION_SET_P macro instead of
AUTODETECT_VALUE.

3 years agoaarch64: Fix pointer parameter type in LD1 Neon intrinsics
Jonathan Wright [Thu, 14 Oct 2021 09:39:32 +0000 (10:39 +0100)]
aarch64: Fix pointer parameter type in LD1 Neon intrinsics

The pointer parameter to load a vector of signed values should itself
be a signed type. This patch fixes two instances of this unsigned-
signed implicit conversion in arm_neon.h.

gcc/ChangeLog:

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

* config/aarch64/arm_neon.h (vld1_s8_x3): Use signed type for
pointer parameter.
(vld1_s32_x3): Likewise.

3 years agoDo not call range_on_path_entry for SSAs defined within the path
Aldy Hernandez [Thu, 14 Oct 2021 08:28:39 +0000 (10:28 +0200)]
Do not call range_on_path_entry for SSAs defined within the path

In the path solver, when requesting the range of an SSA for which we
know nothing, we ask the ranger for the range incoming to the path.
We do this by asking for all the incoming ranges to the path entry
block and unioning them.

The problem here is that we're asking for a range on path entry for an
SSA which *is* defined in the path, but for which we know nothing
about:

some_global.1_2 = some_global;
_3 = (char) some_global.1_2;

This request is causing us to ask for range_on_edge of _3 on the
incoming edges to the path.  This is a bit of nonsensical request
because _3 isn't live on entry to the path, so ranger correctly
returns UNDEFINED.  The proper thing is to avoid asking this in the
first place.

I have added a relevant assert, since it doesn't make sense to call
range_on_path_entry for SSAs defined within the path.

Tested on x86-64 Linux.

PR tree-optimization/102736

gcc/ChangeLog:

PR tree-optimization/102736
* gimple-range-path.cc (path_range_query::range_on_path_entry):
Assert that the requested range is defined outside the path.
(path_range_query::ssa_range_in_phi): Do not call
range_on_path_entry for SSA names that are defined within the
path.

gcc/testsuite/ChangeLog:

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

3 years agoDarwin: Update quotes in driver warning messages.
Iain Sandoe [Sun, 28 Mar 2021 19:50:09 +0000 (20:50 +0100)]
Darwin: Update quotes in driver warning messages.

This adds some missing quotes around options and option argument
terms in warning messages.  Avoid contractions in warning
messages.

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

* config/darwin-driver.c (darwin_find_version_from_kernel):
Quote internal identifiers and avoid contractions in
warnings.
(darwin_default_min_version): Likewise.
(darwin_driver_init): Likewise.

3 years agoipa-cp: Propagation boost for recursion generated values
Martin Jambor [Thu, 14 Oct 2021 12:02:49 +0000 (14:02 +0200)]
ipa-cp: Propagation boost for recursion generated values

Recursive call graph edges, even when they are hot and important for
the compiled program, can never have frequency bigger than one, even
when the actual time savings in the next recursion call are not
realized just once but depend on the depth of recursion.  The current
IPA-CP effect propagation code did not take that into account and just
used the frequency, thus severely underestimating the effect.

This patch artificially boosts values taking part in such calls.  If a
value feeds into itself through a recursive call, the frequency of the
edge is multiplied by a parameter with default value of 6, basically
assuming that the recursion will take place 6 times.  This value can
of course be subject to change.

Moreover, values which do not feed into themselves but which were
generated for a self-recursive call with an arithmetic
pass-function (aka the 548.exchange "hack" which however is generally
applicable for recursive functions which count the recursion depth in
a parameter) have the edge frequency multiplied as many times as there
are generated values in the chain.  In essence, we will assume they
are all useful.

This patch partially fixes the current situation when we fail to
optimize 548.exchange with PGO.  In the benchmark one recursive edge
count overwhelmingly dominates all other counts in the program and so
we fail to perform the first cloning (for the nonrecursive entry call)
because it looks totally insignificant.

gcc/ChangeLog:

2021-07-16  Martin Jambor  <mjambor@suse.cz>

* params.opt (ipa-cp-recursive-freq-factor): New.
* ipa-cp.c (ipcp_value): Switch to inline initialization.  New members
scc_no, self_recursion_generated_level, same_scc and
self_recursion_generated_p.
(ipcp_lattice::add_value): Replaced parameter unlimited with
same_lat_gen_level, usit it determine limit of values and store it to
the value.
(ipcp_lattice<valtype>::print): Dump the new fileds.
(allocate_and_init_ipcp_value): Take same_lat_gen_level as a new
parameter and store it to the new value.
(self_recursively_generated_p): Removed.
(propagate_vals_across_arith_jfunc): Use self_recursion_generated_p
instead of self_recursively_generated_p, store self generation level
to such values.
(value_topo_info<valtype>::add_val): Set scc_no.
(value_topo_info<valtype>::propagate_effects): Multiply frequencies of
recursively feeding values and self generated values by appropriate
new factors.

3 years agoaarch64: Remove redundant flag_vect_cost_model test
Richard Sandiford [Wed, 13 Oct 2021 18:32:36 +0000 (19:32 +0100)]
aarch64: Remove redundant flag_vect_cost_model test

The aarch64 version of add_stmt_cost has a redundant test
of flag_vect_cost_model.  The current structure was based
on the contemporaneous definition of default_add_stmt_cost,
but g:d6d1127249564146429009e0682f25bd58d7a791 later removed
the flag_vect_cost_model test from the default version.

gcc/
* config/aarch64/aarch64.c (aarch64_add_stmt_cost): Remove
redundant test for flag_vect_cost_model.

3 years agoAdd debug helpers for auto_bitmap.
Aldy Hernandez [Wed, 13 Oct 2021 08:04:39 +0000 (10:04 +0200)]
Add debug helpers for auto_bitmap.

Using debug() on an auto_bitmap from gdb doesn't work because the
implicit conversion from auto_bitmap to bitmap_head doesn't work
from within a debugging session.  This patch adds the convenience
functions for auto_bitmap.

gcc/ChangeLog:

* bitmap.c (debug): New overloaded function for auto_bitmaps.
* bitmap.h (debug): Same.

3 years agolibstdc++: Fix test for feature test macro
Jonathan Wakely [Wed, 13 Oct 2021 23:33:49 +0000 (00:33 +0100)]
libstdc++: Fix test for feature test macro

libstdc++-v3/ChangeLog:

* testsuite/20_util/is_layout_compatible/version.cc: Check
correct macro.

3 years agolibstdc++: Add missing constexpr to std::optional (P2231R1)
Jonathan Wakely [Wed, 13 Oct 2021 21:32:28 +0000 (22:32 +0100)]
libstdc++: Add missing constexpr to std::optional (P2231R1)

This implements the changes in P2231R1 which make std::optional fully
constexpr in C++20.

libstdc++-v3/ChangeLog:

* include/bits/stl_construct.h (_Construct): Use
std::construct_at when constant evaluated.
* include/std/optional (_Storage, _Optional_payload, optional):
Add constexpr as specified by P2231R1.
* include/std/version (__cpp_lib_optional): Update value for
C++20.
* testsuite/20_util/optional/requirements.cc: Check feature test
macro.
* testsuite/20_util/optional/constexpr/assign.cc: New test.
* testsuite/20_util/optional/constexpr/cons/conv.cc: New test.
* testsuite/20_util/optional/constexpr/modifiers.cc: New test.
* testsuite/20_util/optional/constexpr/swap.cc: New test.
* testsuite/20_util/optional/version.cc: New test.

3 years ago[Ada] reenable ada83 library unit renaming error
Alexandre Oliva [Thu, 14 Oct 2021 04:49:44 +0000 (01:49 -0300)]
[Ada] reenable ada83 library unit renaming error

for  gcc/ada/ChangeLog

* par-ch10.adb (P_Compilation_Unit): Reenable ada83 library
unit renaming test and error.

3 years agoAVX512FP16: Adjust builtin for mask complex fma
Hongyu Wang [Thu, 23 Sep 2021 05:52:16 +0000 (13:52 +0800)]
AVX512FP16: Adjust builtin for mask complex fma

Current mask/mask3 implementation for complex fma contains
duplicated parameter in macro, which may cause error at -O0.
Refactor macro implementation to builtins to avoid potential
error.

For round intrinsic with NO_ROUND as input, ix86_erase_embedded_rounding
erases embedded_rounding upspec but could break other emit_insn in
expanders. Skip those expanders with multiple emit_insn for this
function and check rounding in expander with subst.

gcc/ChangeLog:

* config/i386/avx512fp16intrin.h (_mm512_mask_fcmadd_pch):
Adjust builtin call.
(_mm512_mask3_fcmadd_pch): Likewise.
(_mm512_mask_fmadd_pch): Likewise
(_mm512_mask3_fmadd_pch): Likewise
(_mm512_mask_fcmadd_round_pch): Likewise
(_mm512_mask3_fcmadd_round_pch): Likewise
(_mm512_mask_fmadd_round_pch): Likewise
(_mm512_mask3_fmadd_round_pch): Likewise
(_mm_mask_fcmadd_sch): Likewise
(_mm_mask3_fcmadd_sch): Likewise
(_mm_mask_fmadd_sch): Likewise
(_mm_mask3_fmadd_sch): Likewise
(_mm_mask_fcmadd_round_sch): Likewise
(_mm_mask3_fcmadd_round_sch): Likewise
(_mm_mask_fmadd_round_sch): Likewise
(_mm_mask3_fmadd_round_sch): Likewise
(_mm_fcmadd_round_sch): Likewise
* config/i386/avx512fp16vlintrin.h (_mm_mask_fmadd_pch):
Adjust builtin call.
(_mm_mask3_fmadd_pch): Likewise
(_mm256_mask_fmadd_pch): Likewise
(_mm256_mask3_fmadd_pch): Likewise
(_mm_mask_fcmadd_pch): Likewise
(_mm_mask3_fcmadd_pch): Likewise
(_mm256_mask_fcmadd_pch): Likewise
(_mm256_mask3_fcmadd_pch): Likewise
* config/i386/i386-builtin.def: Add mask3 builtin for complex
fma, and adjust mask_builtin to corresponding expander.
* config/i386/i386-expand.c (ix86_expand_round_builtin):
Skip eraseing embedded rounding for expanders that emits
multiple insns.
* config/i386/sse.md (complexmove): New mode_attr.
(<avx512>_fmaddc_<mode>_mask1<round_expand_name>): New expander.
(<avx512>_fcmaddc_<mode>_mask1<round_expand_name>): Likewise.
(avx512fp16_fmaddcsh_v8hf_mask1<round_expand_name>): Likewise.
(avx512fp16_fcmaddcsh_v8hf_mask1<round_expand_name>): Likewise.
(avx512fp16_fcmaddcsh_v8hf_mask3<round_expand_name>): Likewise.
(avx512fp16_fmaddcsh_v8hf_mask3<round_expand_name>): Likewise.
* config/i386/subst.md (round_embedded_complex): New subst.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx-1.c: Add new mask3 builtins.
* gcc.target/i386/sse-13.c: Ditto.
* gcc.target/i386/sse-23.c: Ditto.
* gcc.target/i386/avx512fp16-vfcmaddcsh-1a.c: Add scanning for
mask/mask3 intrinsic.
* gcc.target/i386/avx512fp16-vfmaddcsh-1a.c: Ditto.
* gcc.target/i386/avx512fp16-vfcmaddcsh-1c.c: New test for
-mavx512vl.
* gcc.target/i386/avx512fp16-vfmaddcsh-1c.c: Ditto.

3 years agoAdjust testcase for O2 vectorization[Wuninitialized]
liuhongt [Wed, 13 Oct 2021 02:05:58 +0000 (10:05 +0800)]
Adjust testcase for O2 vectorization[Wuninitialized]

It looks like it's just the the location of the warning that's off,
the warning itself is still issued but it's swallowed by the
dg-prune-output directive.

Since the test was added to verify the fix for an ICE without
vectorization I think disabling vectorization should be fine.
Ideally, we would understand why the location is wrong so let's keep
this bug open and add a comment to the test referencing this bug.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wuninitialized-13.C: Add -fno-tree-vectorize.

3 years agoFix TARGET_SOFT_FLOAT patterns in pa.md
John David Anglin [Thu, 14 Oct 2021 00:57:32 +0000 (00:57 +0000)]
Fix TARGET_SOFT_FLOAT patterns in pa.md

2021-10-13  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

* config/pa/pa.md (cbranchsf4): Disable if TARGET_SOFT_FLOAT.
(cbranchdf4): Likewise.
Add missing move patterns for TARGET_SOFT_FLOAT.

3 years agoDaily bump.
GCC Administrator [Thu, 14 Oct 2021 00:16:31 +0000 (00:16 +0000)]
Daily bump.

3 years agolibstdc++: Fix regression in memory use when constructing paths
Jonathan Wakely [Wed, 13 Oct 2021 20:32:14 +0000 (21:32 +0100)]
libstdc++: Fix regression in memory use when constructing paths

The changes in r12-4381 were intended to reduce memory usage, but
replacing the __contiguous constant in __string_from_range with the new
__is_contiguous variable template caused a regression. The old code
checked is_pointer_v<decltype(std::__niter_base(__first))> but he new
code just checks is_pointer_v<_InputIterator>. This means that we no
longer recognise basic_string::iterator and vector::iterator as
contiguous, and so return a temporary basic_string instead of a
basic_string_view. This only affects C++17 mode, because the
std::contiguous_iterator concept is used in C++20 which gives the right
answer for __normal_iterator (and more types as well).

The fix is to specialize the new __is_contiguous variable template so it
is true for __normal_iterator<T*, C> specializations. The new partial
specializations are defined for C++20 too, because it should be cheaper
to match the partial specialization than to check whether the
std::contiguous_iterator concept is satisfied.

libstdc++-v3/ChangeLog:

* include/bits/fs_path.h (__detail::__is_contiguous): Add
partial specializations for pointers and __normal_iterator.

3 years agolibstdc++: Rename files with the wrong extensions
Jonathan Wakely [Wed, 13 Oct 2021 21:31:51 +0000 (22:31 +0100)]
libstdc++: Rename files with the wrong extensions

libstdc++-v3/ChangeLog:

* testsuite/27_io/filesystem/path/construct/102592.C: Moved to...
* testsuite/27_io/filesystem/path/construct/102592.cc: ...here.
* testsuite/28_regex/match_results/102667.C: Moved to...
* testsuite/28_regex/match_results/102667.cc: ...here.

3 years agolibstdc++: Refactor filesystem::path encoding conversions
Jonathan Wakely [Wed, 13 Oct 2021 16:19:57 +0000 (17:19 +0100)]
libstdc++: Refactor filesystem::path encoding conversions

Adjust the __detail::__effective_range overloads so they always return a
string or string view using std::char_traits, because we don't care
about the traits of an incoming string.

Use std::contiguous_iterator in the __effective_range(const Source&)
overload, to allow returning a basic_string_view in more cases. For the
non-contiguous casecl in both __effective_range and __string_from_range,
return a std::string instead of std::u8string when the value type of the
range is char8_t.  These changes avoid unnecessary basic_string
temporaries.

Also simplify __string_from_range(Iter, Iter) to not need
std::__to_address for the contiguous case.

Combine the _S_convert(string_type) and _S_convert(const T&) overloads
into a single _S_convert(T) function which also avoids the dangling
view problem of PR 102592 (should that recur somehow).

libstdc++-v3/ChangeLog:

* include/bits/fs_path.h (__detail::__is_contiguous): New
variable template to identify contiguous iterators.
(__detail::__unified_char8_t): New alias template to decide when
to treat char8_t as char without encoding conversion.
(__detail::__effective_range(const basic_string<C,T>&)): Use
std::char_traits<C> for returned string view.
(__detail::__effective_range(const basic_string_view<C,T>&)):
Likewise.
(__detail::__effective_range(const Source&)): Use
__is_contiguous to detect mode cases of contiguous iterators.
Use __unified_char8_t to return a std::string instead of
std::u8string.

3 years agolibstdc++: Fix dangling string_view in filesystem::path [PR102592]
Jonathan Wakely [Wed, 13 Oct 2021 16:02:59 +0000 (17:02 +0100)]
libstdc++: Fix dangling string_view in filesystem::path [PR102592]

When creating a path from a pair of non-contiguous iterators we pass the
iterators to _S_convert(Iter, Iter). That function passes the iterators
to __string_from_range to get a contiguous sequence of characters, and
then calls _S_convert(const C*, const C*) to perform the encoding
conversions. If the value type, C, is char8_t, then no conversion is
needed and the _S_convert<char8_t>(const char8_t*, const char8_t*)
specialization casts the pointer to const char* and returns a
std::string_view that refs to the char8_t sequence. However, that
sequence is owned by the std::u8string rvalue returned by
__string_from_range, which goes out of scope when _S_convert(Iter, Iter)
returns. That means the std::string_view is dangling and we get
undefined behaviour when parsing it as a path.

The same problem does not exist for the path members taking a "Source"
argument, because those functions all convert a non-contiguous range
into a basic_string<C> immediately, using __effective_range(__source).
That means that the rvalue string returned by that function is still in
scope for the full expression, so the string_view does not dangle.

The solution for the buggy functions is to do the same thing, and call
__string_from_range immediately, so that the returned rvalue is still in
scope for the lifetime of the string_view returned by _S_convert. To
avoid reintroducing the same problem, remove the _S_convert(Iter, Iter)
overload that calls __string_from_range and returns a dangling view.

libstdc++-v3/ChangeLog:

PR libstdc++/102592
* include/bits/fs_path.h (path::path(Iter, Iter, format))
(path::append(Iter, Iter), path::concat(Iter, Iter)): Call
__string_from_range directly, instead of two-argument overload
of _S_convert.
(path::_S_convert(Iter, Iter)): Remove.
* testsuite/27_io/filesystem/path/construct/102592.C: New test.

3 years agox86_64: Some SUBREG related optimization tweaks to i386 backend.
Roger Sayle [Wed, 13 Oct 2021 18:49:47 +0000 (19:49 +0100)]
x86_64: Some SUBREG related optimization tweaks to i386 backend.

This patch contains two SUBREG-related optimization enabling tweaks to
the x86 backend.

The first change, to ix86_expand_vector_extract, cures the strange
-march=cascadelake related non-determinism that affected my new test
cases last week.  Extracting a QImode or HImode element from an SSE
vector performs a zero-extension to SImode, which is currently
represented as:

(set (subreg:SI (reg:QI target)) (zero_extend:SI (...))

Unfortunately, the semantics of this RTL doesn't quite match what was
intended.  A set of a paradoxical subreg allows the high-bits to take
an arbitrary value (hence the non-determinism).  A more correct
representation should be:

(set (reg:SI temp) (zero_extend:SI (...))
(set (reg:QI target) (subreg:QI (reg:SI temp))

Optionally with the SUBREG rtx annotated as SUBREG_PROMOTED_VAR_P to
indicate that value is already zero-extended in the SUBREG_REG.

The second change is very similar, which is why I've included it in
this patch, where currently the early RTL optimizers can produce:

(set (reg:V?? hardreg) (subreg ...))

where this instruction may require a spill/reload from memory when
the modes aren't tieable.  Alas the presence of the hard register
prevents combine/gcse etc. optimizing this away, or reusing the result
which would increase the lifetime of the hard register before reload.

The solution is to treat vector hard registers the same way as the
x86 backend handles scalar hard registers, and only allow sets from
pseudos before register allocation, which is achieved by checking
ix86_hardreg_mov_ok.  Hence the above instruction is expanded and
maintained as:

(set (reg:V?? pseudo) (subreg ...))
(set (reg:V?? hardreg) (reg:V?? pseudo))

which allows the RTL optimizers freedom to optimize the SUBREG.

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

gcc/ChangeLog
* config/i386/i386-expand.c (ix86_expand_vector_move):  Use a
pseudo intermediate when moving a SUBREG into a hard register,
by checking ix86_hardreg_mov_ok.
(ix86_expand_vector_extract): Store zero-extended SImode
intermediate in a pseudo, then set target using a SUBREG_PROMOTED
annotated subreg.
* config/i386/sse.md (mov<VMOVE>_internal): Prevent CSE creating
complex (SUBREG) sets of (vector) hard registers before reload, by
checking ix86_hardreg_mov_ok.

3 years agoctfc: remove redundant comma in enumerator list
Indu Bhagat [Wed, 13 Oct 2021 17:01:38 +0000 (10:01 -0700)]
ctfc: remove redundant comma in enumerator list

This also helps get rid of warning

ctfc.h:215:18: warning: comma at end of enumerator list [-Wpedantic]
   CTF_DTU_D_SLICE,

gcc/ChangeLog:

* ctfc.h (enum ctf_dtu_d_union_enum): Remove redundant comma.

3 years agodwarf2ctf: fix typo in comment
Indu Bhagat [Wed, 13 Oct 2021 16:58:46 +0000 (09:58 -0700)]
dwarf2ctf: fix typo in comment

gcc/ChangeLog:

* dwarf2ctf.c (gen_ctf_array_type): Fix typo in comment.

3 years agoCheck to see if null pointer is dereferenceable [PR102630].
Martin Sebor [Wed, 13 Oct 2021 16:31:37 +0000 (10:31 -0600)]
Check to see if null pointer is dereferenceable [PR102630].

Resolves:
PR middle-end/102630 - Spurious -Warray-bounds with named address space

gcc/ChangeLog:

PR middle-end/102630
* pointer-query.cc (compute_objsize_r): Handle named address spaces.

gcc/testsuite/ChangeLog:

PR middle-end/102630
* gcc.target/i386/addr-space-2.c: Add -Wall.
* gcc.target/i386/addr-space-3.c: New test.

3 years agocollect2: Fix missing cleanups.
Iain Sandoe [Wed, 6 Oct 2021 13:58:33 +0000 (14:58 +0100)]
collect2: Fix missing cleanups.

The code that checks to see if objects have LTO content via
simple-object was not releasing resources, fixed thus.

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

* collect2.c (is_lto_object_file): Release simple-object
resources, close files.

3 years ago[arm] Fix MVE addressing modes for VLDR[BHW] and VSTR[BHW]
Andre Vieira [Wed, 13 Oct 2021 15:42:47 +0000 (16:42 +0100)]
[arm] Fix MVE addressing modes for VLDR[BHW] and VSTR[BHW]

The way we were previously dealing with addressing modes for MVE was preventing
the use of pre, post and offset addressing modes for the normal loads and
stores, including widening and narrowing.  This patch fixes that and
adds tests to ensure we are capable of using all the available addressing
modes.

gcc/ChangeLog:
2021-10-12  Andre Vieira  <andre.simoesdiasvieira@arm.com>

* config/arm/arm.c (thumb2_legitimate_address_p): Use VALID_MVE_MODE
when checking mve addressing modes.
(mve_vector_mem_operand): Fix the way we handle pre, post and offset
addressing modes.
(arm_print_operand): Fix printing of POST_ and PRE_MODIFY.
* config/arm/mve.md: Use mve_memory_operand predicate everywhere where
there is a single Ux constraint.

gcc/testsuite/ChangeLog:
2021-10-12  Andre Vieira  <andre.simoesdiasvieira@arm.com>

* gcc.target/arm/mve/mve.exp: Make it test main directory.
* gcc.target/arm/mve/mve_load_memory_modes.c: New test.
* gcc.target/arm/mve/mve_store_memory_modes.c: New test.

3 years agoAdd support for 32-bit hppa targets in muldi3 expander
John David Anglin [Wed, 13 Oct 2021 15:36:45 +0000 (15:36 +0000)]
Add support for 32-bit hppa targets in muldi3 expander

2021-10-13  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

* config/pa/pa.md (muldi3): Add support for inlining 64-bit
multiplication on 32-bit PA 1.1 and 2.0 targets.

3 years agogcov: make profile merging smarter
Martin Liska [Thu, 9 Sep 2021 11:02:24 +0000 (13:02 +0200)]
gcov: make profile merging smarter

Support merging of profiles that are built from a different .o files
but belong to the same source file. Moreover, a checksum is verified
during profile merging and so we can safely combine such profile.

PR gcov-profile/90364

gcc/ChangeLog:

* coverage.c (build_info): Emit checksum to the global variable.
(build_info_type): Add new field for checksum.
(coverage_obj_finish): Pass object_checksum.
(coverage_init): Use 0 as checksum for .gcno files.
* gcov-dump.c (dump_gcov_file): Dump also new checksum field.
* gcov.c (read_graph_file): Read also checksum.
* doc/invoke.texi: Document the behaviour change.

libgcc/ChangeLog:

* libgcov-driver.c (merge_one_data): Skip timestamp and verify
checksums.
(write_one_data): Write also checksum.
* libgcov-util.c (read_gcda_file): Read also checksum field.
* libgcov.h (struct gcov_info): Add new field.

3 years agoAdd GSI_LAST_NEW_STMT iterator update
Richard Biener [Wed, 13 Oct 2021 11:42:22 +0000 (13:42 +0200)]
Add GSI_LAST_NEW_STMT iterator update

Currently when adding a sequence before there's no way to get the
iterator placed at the last added stmt which results in convoluted
code in the if-conversion usecase.  The following adds
GSI_LAST_NEW_STMT and corrects one obvious mistake in
execute_update_addresses_taken as well as tries to avoid the
just filed PR102726 by biasing the enum values to be outside of
the boolean 0/1 range.

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

* gimple-iterator.h (gsi_iterator_update): Add GSI_LAST_NEW_STMT,
start at integer value 2.
* gimple-iterator.c (gsi_insert_seq_nodes_before): Update
the iterator for GSI_LAST_NEW_STMT.
(gsi_insert_seq_nodes_after): Likewise.
* tree-if-conv.c (predicate_statements): Use GSI_LAST_NEW_STMT.
* tree-ssa.c (execute_update_addresses_taken): Correct bogus
arguments to gsi_replace.

3 years agoFix handling of flag_rename_registers by a target.
Martin Liska [Tue, 12 Oct 2021 14:05:49 +0000 (16:05 +0200)]
Fix handling of flag_rename_registers by a target.

PR target/102688

gcc/ChangeLog:

* common.opt: Use EnabledBy instead of detection in
finish_options and process_options.
* opts.c (finish_options): Remove handling of
x_flag_unroll_all_loops.
* toplev.c (process_options): Likewise for flag_web and
flag_rename_registers.

3 years agotree-optimization/102659 - avoid undefined overflow after if-conversion
Richard Biener [Mon, 11 Oct 2021 10:27:10 +0000 (12:27 +0200)]
tree-optimization/102659 - avoid undefined overflow after if-conversion

The following makes sure to rewrite arithmetic with undefined behavior
on overflow to a well-defined variant when moving them to be always
executed as part of doing if-conversion for loop vectorization.

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

PR tree-optimization/102659
* tree-if-conv.c (need_to_rewrite_undefined): New flag.
(if_convertible_gimple_assign_stmt_p): Mark the loop for
rewrite when stmts with undefined behavior on integer
overflow appear.
(combine_blocks): Predicate also when we need to rewrite stmts.
(predicate_statements): Rewrite affected stmts to something
with well-defined behavior on overflow.
(tree_if_conversion): Initialize need_to_rewrite_undefined.

* gcc.dg/torture/pr69760.c: Adjust the testcase.
* gcc.target/i386/avx2-vect-mask-store-move1.c: Expect to move
the conversions to unsigned as well.

3 years agoFortran: dump-parse-tree.c fixes for OpenMP
Tobias Burnus [Wed, 13 Oct 2021 09:53:30 +0000 (11:53 +0200)]
Fortran: dump-parse-tree.c fixes for OpenMP

gcc/fortran/ChangeLog:

* dump-parse-tree.c (show_omp_clauses): Handle ancestor modifier,
avoid ICE for GFC_OMP_ATOMIC_SWAP.
* gfortran.h (gfc_omp_clauses): Change 'anecestor' into a bitfield.

3 years agolibstdc++: Ensure language linkage of std::__terminate()
Jonathan Wakely [Wed, 13 Oct 2021 09:35:44 +0000 (10:35 +0100)]
libstdc++: Ensure language linkage of std::__terminate()

This is needed because people still find it necessary to do:

  extern "C" {
  #include <stdlib.h>
  }

libstdc++-v3/ChangeLog:

* include/bits/c++config (__terminate): Add extern "C++".

3 years agoipa/102714 - IPA SRA eliding volatile
Richard Biener [Wed, 13 Oct 2021 07:13:36 +0000 (09:13 +0200)]
ipa/102714 - IPA SRA eliding volatile

The following fixes the volatileness check of IPA SRA which was
looking at the innermost reference when checking TREE_THIS_VOLATILE
but the reference to check is the outermost one.

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

PR ipa/102714
* ipa-sra.c (ptr_parm_has_nonarg_uses): Fix volatileness
check.

* gcc.dg/ipa/pr102714.c: New testcase.

3 years agodwarf2ctf: fix typo in comment
Jose E. Marchesi [Wed, 13 Oct 2021 08:07:37 +0000 (10:07 +0200)]
dwarf2ctf: fix typo in comment

gcc/ChangeLog:

* dwarf2ctf.c: Fix typo in comment.

3 years agors6000/test: Adjust test cases due to O2 vect [PR102658]
Kewen Lin [Wed, 13 Oct 2021 05:20:45 +0000 (00:20 -0500)]
rs6000/test: Adjust test cases due to O2 vect [PR102658]

Commit r12-4240 enables vectorization at O2, this patch is to
adjust some test cases for rs6000 port accordingly.

It simply adds -fno-tree-vectorize to retain original test points.

gcc/testsuite/ChangeLog:

PR testsuite/102658
* gcc.target/powerpc/dform-1.c: Adjust as vectorization enabled at O2.
* gcc.target/powerpc/dform-2.c: Likewise.
* gcc.target/powerpc/pr80510-2.c: Likewise.

3 years agoDaily bump.
GCC Administrator [Wed, 13 Oct 2021 00:16:22 +0000 (00:16 +0000)]
Daily bump.

3 years agoc-family: Support format checking C2X %b, %B formats
Joseph Myers [Tue, 12 Oct 2021 23:40:17 +0000 (23:40 +0000)]
c-family: Support format checking C2X %b, %B formats

C2X adds a %b printf format to print integers in binary (analogous to
%x, including %#b printing a leading 0b on nonzero integers), with
recommended practice for a corresponding %B (where %#B uses 0B instead
of 0b) where that doesn't conflict with existing implementation
extensions.  See N2630 for details (accepted for C2X, not yet in the
latest working draft).  There is also a scanf %b format.

Add corresponding format checking support (%b accepted by -std=c2x
-Wformat -pedantic, %B considered an extension to be diagnosed with
-Wformat -pedantic).  glibc support for the printf formats has been
proposed at
<https://sourceware.org/pipermail/libc-alpha/2021-October/131764.html>
(scanf support to be done in a separate patch).

Note that this does not add any support for these formats to the code
for bounding the amount of output produces by a printf function,
although that would also be useful.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

gcc/c-family/
* c-format.c (print_char_table): Add %b and %B formats.
(scan_char_table): Add %b format.
* c-format.h (T2X_UI, T2X_UL, T2X_ULL, T2X_US, T2X_UC, T2X_ST)
(T2X_UPD, T2X_UIM): New macros.

gcc/testsuite/
* gcc.dg/format/c11-printf-1.c, gcc.dg/format/c11-scanf-1.c,
gcc.dg/format/c2x-printf-1.c, gcc.dg/format/c2x-scanf-1.c,
gcc.dg/format/ext-9.c, gcc.dg/format/ext-10.c: New tests.

3 years agors6000: Fix vec_cpsgn parameter order (PR101985)
Bill Schmidt [Tue, 12 Oct 2021 22:37:16 +0000 (17:37 -0500)]
rs6000: Fix vec_cpsgn parameter order (PR101985)

The vec_cpsgn built-in function API differs in argument order from the
copysign<mode>3 convention.  Currently that pattern is incorrctly used to
implement vec_cpsgn.  Fix that by reversing the operand order of the
builtin while leaving the existing pattern in place to implement copysignf
for vector modes.

Part of the fix when using the new built-in support requires an adjustment
to a pending patch that replaces much of altivec.h with an automatically
generated file.

Also fix a bug in the new built-in overload infrastructure where we were
using the VSX form of the VEC_COPYSIGN built-in when we should default to
the VMX form.

2021-10-12  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
PR target/101985
* config/rs6000/altivec.h (vec_cpsgn): Swap operand order.
* config/rs6000/rs6000-overload.def (VEC_COPYSIGN): Use SKIP to
avoid generating an automatic #define of vec_cpsgn.  Use the
correct built-in for V4SFmode that doesn't depend on VSX.

gcc/testsuite/
PR target/101985
* gcc.target/powerpc/pr101985-1.c: New.
* gcc.target/powerpc/pr101985-2.c: New.

3 years agoMark certain subdirectories as missing TAGS targets.
Eric Gallager [Tue, 12 Oct 2021 20:55:21 +0000 (16:55 -0400)]
Mark certain subdirectories as missing TAGS targets.

The subdirectories in question are libcody,
libdecnumber, c++tools, libgcc, and libobjc.
This is progress towards allowing "make tags" to
work from the top-level directory; a few additional
changes may also be necessary, though.

ChangeLog:

* Makefile.def: Mark libcody, libdecnumber,
c++tools, libgcc, and libobjc as missing TAGS
targets.
* Makefile.in: Regenerate.

3 years agoi386: Improve workaround for PR82524 LRA limitation [PR85730]
Uros Bizjak [Tue, 12 Oct 2021 16:20:38 +0000 (18:20 +0200)]
i386: Improve workaround for PR82524 LRA limitation [PR85730]

As explained in PR82524, LRA is not able to reload strict_low_part inout
operand with matched input operand. The patch introduces a workaround,
where we allow LRA to generate an instruction with non-matched input operand
which is split post reload to an instruction that inserts non-matched input
operand to an inout operand and the instruction that uses matched operand.

The generated code improves from:

        movsbl  %dil, %edx
        movl    %edi, %eax
        sall    $3, %edx
        movb    %dl, %al

to:

        movl    %edi, %eax
        movb    %dil, %al
        salb    $3, %al

which is still not optimal, but the code is one instruction shorter and
does not use a temporary register.

2021-10-12  UroÅ¡ Bizjak  <ubizjak@gmail.com>

gcc/
PR target/85730
PR target/82524
* config/i386/i386.md (*add<mode>_1_slp): Rewrite as
define_insn_and_split pattern.  Add alternative 1 and split it
post reload to insert operand 1 into the low part of operand 0.
(*sub<mode>_1_slp): Ditto.
(*and<mode>_1_slp): Ditto.
(*<any_or:code><mode>_1_slp): Ditto.
(*ashl<mode>3_1_slp): Ditto.
(*<any_shiftrt:insn><mode>3_1_slp): Ditto.
(*<any_rotate:insn><mode>3_1_slp): Ditto.
(*neg<mode>_1_slp): New insn_and_split pattern.
(*one_cmpl<mode>_1_slp): Ditto.

gcc/testsuite/
PR target/85730
PR target/82524
* gcc.target/i386/pr85730.c: New test.

3 years agodoc: Update MinGW and mingw-64 download links.
David Edelsohn [Tue, 12 Oct 2021 15:48:05 +0000 (11:48 -0400)]
doc: Update MinGW and mingw-64 download links.

gcc/ChangeLog:

* doc/install.texi: Update MinGW and mingw-64 Binaries
download links.

3 years agolibstdc++: Fix test that fails for C++20
Jonathan Wakely [Tue, 12 Oct 2021 14:39:18 +0000 (15:39 +0100)]
libstdc++: Fix test that fails for C++20

Also restore the test for 'a < a' that was removed by r12-2537 because
it is ill-formed. We still want to test operator< for tuple, we just
need to not use std::nullptr_t in that tuple type.

libstdc++-v3/ChangeLog:

* testsuite/20_util/tuple/comparison_operators/overloaded.cc:
Restore test for operator<.
* testsuite/20_util/tuple/comparison_operators/overloaded2.cc:
Adjust expected errors for C++20.

3 years agolibstdc++: Fix move construction of std::tuple with array elements [PR101960]
Jonathan Wakely [Tue, 12 Oct 2021 14:09:50 +0000 (15:09 +0100)]
libstdc++: Fix move construction of std::tuple with array elements [PR101960]

The r12-3022 commit only fixed the case where an array is the last
element of the tuple. This fixes the other cases too. We can just define
the move constructor as defaulted, which does the right thing. Changing
the move constructor to be trivial would be an ABI break, but since the
last base class still has a non-trivial move constructor, defining the
derived ones as defaulted doesn't change anything.

libstdc++-v3/ChangeLog:

PR libstdc++/101960
* include/std/tuple (_Tuple_impl(_Tuple_impl&&)): Define as
defauled.
* testsuite/20_util/tuple/cons/101960.cc: Check tuples with
array elements before the last element.

3 years agolibstdc++: Improve diagnostics for misuses of output iterators
Jonathan Wakely [Wed, 29 Sep 2021 20:19:36 +0000 (21:19 +0100)]
libstdc++: Improve diagnostics for misuses of output iterators

This adds deleted overloads so that the errors for invalid uses of
std::advance and std::distance are easier to understand (see for example
PR 102181).

libstdc++-v3/ChangeLog:

* include/bits/stl_iterator_base_funcs.h (__advance): Add
deleted overload to improve diagnostics.
(__distance): Likewise.

3 years agodoc: Fix typos in alloc_size documentation
Daniel Le Duc Khoi Nguyen [Tue, 12 Oct 2021 14:52:35 +0000 (10:52 -0400)]
doc: Fix typos in alloc_size documentation

gcc/
* doc/extend.texi (Common Variable Attributes): Fix typos in
alloc_size documentation.

3 years ago[PATCH v2] libiberty: d-demangle: remove parenthesis where it is not needed
Luís Ferreira [Tue, 12 Oct 2021 14:40:20 +0000 (10:40 -0400)]
[PATCH v2] libiberty: d-demangle: remove parenthesis where it is not needed

libiberty/
* d-demangle.c (dlang_parse_qualified): Remove redudant parenthesis
around lhs and rhs of assignments.

3 years agolibgomp: Release device lock on cbuf error path
Julian Brown [Fri, 24 Sep 2021 11:18:40 +0000 (04:18 -0700)]
libgomp: Release device lock on cbuf error path

This patch releases the device lock on a sanity-checking error path in
transfer combining (cbuf) handling in libgomp:target.c.  This shouldn't
happen when handling well-formed mapping clauses, but erroneous clauses
can currently cause a hang if the condition triggers.

2021-12-10  Julian Brown  <julian@codesourcery.com>

libgomp/
* target.c (gomp_copy_host2dev): Release device lock on cbuf
error path.

3 years agotree-optimization/102696 - fix SLP discovery for failed BIT_FIELD_REF
Richard Biener [Tue, 12 Oct 2021 11:49:39 +0000 (13:49 +0200)]
tree-optimization/102696 - fix SLP discovery for failed BIT_FIELD_REF

This fixes a forgotten adjustment of matches[] when we fail SLP
discovery.

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

PR tree-optimization/102696
* tree-vect-slp.c (vect_build_slp_tree_2): Properly mark
the tree fatally failed when we reject a BIT_FIELD_REF.

* g++.dg/vect/pr102696.cc: New testcase.

3 years agotree-optimization/102572 - fix gathers with invariant mask
Richard Biener [Tue, 12 Oct 2021 11:42:08 +0000 (13:42 +0200)]
tree-optimization/102572 - fix gathers with invariant mask

This fixes the vector def gathering for invariant masks which
failed to pass in the desired vector type resulting in a non-mask
type to be generate.

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

PR tree-optimization/102572
* tree-vect-stmts.c (vect_build_gather_load_calls): When
gathering the vectorized defs for the mask pass in the
desired mask vector type so invariants will be handled
correctly.

* g++.dg/vect/pr102572.cc: New testcase.

3 years agosve: combine inverted masks into NOTs
Tamar Christina [Tue, 12 Oct 2021 10:34:06 +0000 (11:34 +0100)]
sve: combine inverted masks into NOTs

The following example

void f10(double * restrict z, double * restrict w, double * restrict x,
 double * restrict y, int n)
{
    for (int i = 0; i < n; i++) {
        z[i] = (w[i] > 0) ? x[i] + w[i] : y[i] - w[i];
    }
}

generates currently:

        ld1d    z1.d, p1/z, [x1, x5, lsl 3]
        fcmgt   p2.d, p1/z, z1.d, #0.0
        fcmgt   p0.d, p3/z, z1.d, #0.0
        ld1d    z2.d, p2/z, [x2, x5, lsl 3]
        bic     p0.b, p3/z, p1.b, p0.b
        ld1d    z0.d, p0/z, [x3, x5, lsl 3]

where a BIC is generated between p1 and p0 where a NOT would be better here
since we won't require the use of p3 and opens the pattern up to being CSEd.

After this patch using a 2 -> 2 split we generate:

        ld1d    z1.d, p0/z, [x1, x5, lsl 3]
        fcmgt   p2.d, p0/z, z1.d, #0.0
        not     p1.b, p0/z, p2.b

The additional scratch is needed such that we can CSE the two operations.  If
both statements wrote to the same register then CSE won't be able to CSE the
values if there are other statements in between that use the register.

A second pattern is needed to capture the nor case as combine will match the
longest sequence first.  So without this pattern we end up de-optimizing nor
and instead emit two nots.  I did not find a better way to do this.

gcc/ChangeLog:

* config/aarch64/aarch64-sve.md (*fcm<cmp_op><mode>_bic_combine,
*fcm<cmp_op><mode>_nor_combine, *fcmuo<mode>_bic_combine,
*fcmuo<mode>_nor_combine): New.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sve/pred-not-gen-1.c: New test.
* gcc.target/aarch64/sve/pred-not-gen-2.c: New test.
* gcc.target/aarch64/sve/pred-not-gen-3.c: New test.
* gcc.target/aarch64/sve/pred-not-gen-4.c: New test.

3 years agoFix PR target/102588
Eric Botcazou [Tue, 12 Oct 2021 09:20:42 +0000 (11:20 +0200)]
Fix PR target/102588

We need a 32-byte wide integer mode (OImode) in order to handle structure
returns in the 64-bit ABI.

gcc/
PR target/102588
* config/sparc/sparc-modes.def (OI): New integer mode.

3 years agoFortran version of libgomp.c-c++-common/icv-{3,4}.c
Tobias Burnus [Tue, 12 Oct 2021 08:54:18 +0000 (10:54 +0200)]
Fortran version of libgomp.c-c++-common/icv-{3,4}.c

This adds the Fortran testsuite coverage of
omp_{get_max,set_num}_threads and omp_{s,g}et_teams_thread_limit

libgomp/
* testsuite/libgomp.fortran/icv-3.f90: New.
* testsuite/libgomp.fortran/icv-4.f90: New.

3 years agoFortran: Various CLASS + assumed-rank fixed [PR102541]
Tobias Burnus [Tue, 12 Oct 2021 07:56:08 +0000 (09:56 +0200)]
Fortran: Various CLASS + assumed-rank fixed [PR102541]

Starting point was PR102541, were a previous patch caused an invalid
e->ref access for class. When testing, it turned out that for
CLASS to CLASS the code was never executed - additionally, issues
appeared for optional and a bogus error for -fcheck=all. In particular:

There were a bunch of issues related to optional CLASS, can have the
'attr.dummy' set in CLASS_DATA (sym) - but sometimes also in 'sym'!?!
Additionally, gfc_variable_attr could return pointer = 1 for nonpointers
when the expr is no longer "var" but "var%_data".

PR fortran/102541

gcc/fortran/ChangeLog:

* check.c (gfc_check_present): Handle optional CLASS.
* interface.c (gfc_compare_actual_formal): Likewise.
* trans-array.c (gfc_trans_g77_array): Likewise.
* trans-decl.c (gfc_build_dummy_array_decl): Likewise.
* trans-types.c (gfc_sym_type): Likewise.
* primary.c (gfc_variable_attr): Fixes for dummy and
pointer when 'class%_data' is passed.
* trans-expr.c (set_dtype_for_unallocated, gfc_conv_procedure_call):
For assumed-rank dummy, fix setting rank for dealloc/notassoc actual
and setting ubound to -1 for assumed-size actuals.

gcc/testsuite/ChangeLog:

* gfortran.dg/assumed_rank_24.f90: New test.

3 years agoopenmp: Avoid calling clear_type_padding_in_mask in the common case where there can...
Jakub Jelinek [Tue, 12 Oct 2021 07:37:25 +0000 (09:37 +0200)]
openmp: Avoid calling clear_type_padding_in_mask in the common case where there can't be any padding

We can use the clear_padding_type_may_have_padding_p function, which
is conservative for e.g. RECORD_TYPE/UNION_TYPE, but for the floating and
complex floating types is accurate.  clear_type_padding_in_mask is
more expensive because we need to allocate memory, fill it, call the function
which itself is more expensive and then analyze the memory, so for the
common case of float/double atomics or even long double on most targets
we can avoid that.

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

gcc/
* gimple-fold.h (clear_padding_type_may_have_padding_p): Declare.
* gimple-fold.c (clear_padding_type_may_have_padding_p): No longer
static.
gcc/c-family/
* c-omp.c (c_finish_omp_atomic): Use
clear_padding_type_may_have_padding_p.

3 years agoopenmp: Add documentation for omp_{get_max, set_num}_threads and omp_{s, g}et_teams_t...
Jakub Jelinek [Tue, 12 Oct 2021 07:35:43 +0000 (09:35 +0200)]
openmp: Add documentation for omp_{get_max, set_num}_threads and omp_{s, g}et_teams_thread_limit

This patch adds documentation for these new OpenMP 5.1 APIs as well as
two new environment variables - OMP_NUM_TEAMS and OMP_TEAMS_THREAD_LIMIT.

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

* libgomp.texi (omp_get_max_teams, omp_get_teams_thread_limit,
omp_set_num_teams, omp_set_teams_thread_limit, OMP_NUM_TEAMS,
OMP_TEAMS_THREAD_LIMIT): Document.

3 years agoopenmp: Fix up warnings on libgomp.info build
Jakub Jelinek [Tue, 12 Oct 2021 07:34:38 +0000 (09:34 +0200)]
openmp: Fix up warnings on libgomp.info build

When building libgomp documentation, I see
makeinfo --split-size=5000000  -I ../../../libgomp/../gcc/doc/include -I ../../../libgomp -o libgomp.info ../../../libgomp/libgomp.texi
../../../libgomp/libgomp.texi:503: warning: node next `omp_get_default_device' in menu `omp_get_device_num' and in sectioning `omp_get_dynamic' differ
../../../libgomp/libgomp.texi:528: warning: node prev `omp_get_dynamic' in menu `omp_get_device_num' and in sectioning `omp_get_default_device' differ
../../../libgomp/libgomp.texi:560: warning: node next `omp_get_initial_device' in menu `omp_get_level' and in sectioning `omp_get_device_num' differ
../../../libgomp/libgomp.texi:587: warning: node next `omp_get_device_num' in menu `omp_get_dynamic' and in sectioning `omp_get_level' differ
../../../libgomp/libgomp.texi:587: warning: node prev `omp_get_device_num' in menu `omp_get_default_device' and in sectioning `omp_get_initial_device' differ
../../../libgomp/libgomp.texi:615: warning: node prev `omp_get_level' in menu `omp_get_initial_device' and in sectioning `omp_get_device_num' differ
warnings.  This patch fixes those.

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

* libgomp.texi (omp_get_device_num): Move @node before omp_get_dynamic
to avoid makeinfo warnings.

3 years agoopenmp: Add testsuite coverage for omp_{get_max,set_num}_threads and omp_{s,g}et_team...
Jakub Jelinek [Tue, 12 Oct 2021 07:32:28 +0000 (09:32 +0200)]
openmp: Add testsuite coverage for omp_{get_max,set_num}_threads and omp_{s,g}et_teams_thread_limit

This adds (C/C++ only) testsuite coverage for these new OpenMP 5.1 APIs.

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

* testsuite/libgomp.c-c++-common/icv-3.c: New test.
* testsuite/libgomp.c-c++-common/icv-4.c: New test.

3 years agolibgomp: alloc* test fixes [PR102628, PR102668]
Jakub Jelinek [Tue, 12 Oct 2021 07:30:41 +0000 (09:30 +0200)]
libgomp: alloc* test fixes [PR102628, PR102668]

As reported, the alloc-9.c test and alloc-{1,2,3}.F* and alloc-11.f90
tests fail on powerpc64-linux with -m32.
The reason why it fails just there is that malloc doesn't guarantee there
128-bit alignment (historically glibc guaranteed 2 * sizeof (void *)
alignment from malloc).

There are two separate issues.
One is a thinko on my side.
In this part of alloc-9.c test (copied to alloc-11.f90), we have
2 allocators, a with pool size 1024B and alignment 16B and default fallback
and a2 with pool size 512B and alignment 32B and a as fallback allocator.
We start at no allocations in both at line 194 and do:
  p = (int *) omp_alloc (sizeof (int), a2);
// This succeeds in a2 and needs 4+overhead bytes (which includes the 32B alignment)
  p = (int *) omp_realloc (p, 420, a, a2);
// This allocates 420 bytes+overhead in a, with 16B alignment and deallocates the above
  q = (int *) omp_alloc (sizeof (int), a);
// This allocates 4+overhead bytes in a, with 16B alignment
  q = (int *) omp_realloc (q, 420, a2, a);
// This allocates 420+overhead in a2 with 32B alignment
  q = (int *) omp_realloc (q, 768, a2, a2);
// This attempts to reallocate, but as there are elevated alignment
// requirements doesn't try to just realloc (even if it wanted to try that
// a2 is almost full, with 512-420-overhead bytes left in it), so it
// tries to alloc in a2, but there is no space left in the pool, falls
// back to a, which already has 420+overhead bytes allocated in it and
// 1024-420-overhead bytes left and so fails too and fails to default
// non-pool allocator that allocates it, but doesn't guarantee alignment
// higher than malloc guarantees.
// But, the test expected 16B alignment.

So, I've slightly lowered the allocation sizes in that part of the test
420->320 and 768 -> 568, so that the last test still fails to allocate
in a2 (568 > 512-320-overhead) but succeeds in a as fallback, which was
the intent of the test.

Another thing is that alloc-1.F90 seems to be transcription of
libgomp.c-c++-common/alloc-1.c into Fortran, but alloc-1.c had:
  q = (int *) omp_alloc (768, a2);
  if ((((uintptr_t) q) % 16) != 0)
    abort ();
  q[0] = 7;
  q[767 / sizeof (int)] = 8;
  r = (int *) omp_alloc (512, a2);
  if ((((uintptr_t) r) % __alignof (int)) != 0)
    abort ();
there but Fortran has:
        cq = omp_alloc (768_c_size_t, a2)
        if (mod (transfer (cq, intptr), 16_c_intptr_t) /= 0) stop 12
        call c_f_pointer (cq, q, [768 / c_sizeof (i)])
        q(1) = 7
        q(768 / c_sizeof (i)) = 8
        cr = omp_alloc (512_c_size_t, a2)
        if (mod (transfer (cr, intptr), 16_c_intptr_t) /= 0) stop 13
I'm changing the latter to 4_c_intptr_t because other spots in the
testcase do that, Fortran sadly doesn't have c_alignof, but strictly
speaking it isn't correct, __alignof (int) could be on some architectures
smaller than 4.
So probably alloc-1.F90 etc. should also have
! { dg-additional-sources alloc-7.c }
! { dg-prune-output "command-line option '-fintrinsic-modules-path=.*' is valid for Fortran but not for C" }
and use get__alignof_int.

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

PR libgomp/102628
PR libgomp/102668
* testsuite/libgomp.c-c++-common/alloc-9.c (main): Decrease
allocation sizes from 420 to 320 and from 768 to 568.
* testsuite/libgomp.fortran/alloc-11.f90: Likewise.
* testsuite/libgomp.fortran/alloc-1.F90: Change expected alignment
for cr from 16 to 4.

3 years agovectorizer: Fix up -fsimd-cost-model= handling
Jakub Jelinek [Tue, 12 Oct 2021 07:28:10 +0000 (09:28 +0200)]
vectorizer: Fix up -fsimd-cost-model= handling

> * testsuite/libgomp.c++/scan-10.C: Add option -fvect-cost-model=cheap.

I don't think this is the right thing to do.
This just means that at some point between 2013 when -fsimd-cost-model has
been introduced and now -fsimd-cost-model= option at least partially stopped
working properly.
As documented, -fsimd-cost-model= overrides the -fvect-cost-model= setting
for OpenMP simd loops (loop->force_vectorize is true) if specified differently
from default.
In tree-vectorizer.h we have:
static inline bool
unlimited_cost_model (loop_p loop)
{
  if (loop != NULL && loop->force_vectorize
      && flag_simd_cost_model != VECT_COST_MODEL_DEFAULT)
    return flag_simd_cost_model == VECT_COST_MODEL_UNLIMITED;
  return (flag_vect_cost_model == VECT_COST_MODEL_UNLIMITED);
}
and use it in various places, but we also just use flag_vect_cost_model
in lots of places (and in one spot use flag_simd_cost_model, not sure if
we are sure it is a force_vectorize loop or what).

So, IMHO we should change the above inline function to
loop_cost_model and let it return the cost model and then just
reimplement unlimited_cost_model as
return loop_cost_model (loop) == VECT_COST_MODEL_UNLIMITED;
and then adjust the direct uses of the flag and revert these changes.

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

gcc/
* tree-vectorizer.h (loop_cost_model): New function.
(unlimited_cost_model): Use it.
* tree-vect-loop.c (vect_analyze_loop_costing): Use loop_cost_model
call instead of flag_vect_cost_model.
* tree-vect-data-refs.c (vect_enhance_data_refs_alignment): Likewise.
(vect_prune_runtime_alias_test_list): Likewise.  Also use it instead
of flag_simd_cost_model.
gcc/testsuite/
* gcc.dg/gomp/simd-2.c: Remove option -fvect-cost-model=cheap.
* gcc.dg/gomp/simd-3.c: Likewise.
libgomp/
* testsuite/libgomp.c/scan-11.c: Remove option -fvect-cost-model=cheap.
* testsuite/libgomp.c/scan-12.c: Likewise.
* testsuite/libgomp.c/scan-13.c: Likewise.
* testsuite/libgomp.c/scan-14.c: Likewise.
* testsuite/libgomp.c/scan-15.c: Likewise.
* testsuite/libgomp.c/scan-16.c: Likewise.
* testsuite/libgomp.c/scan-17.c: Likewise.
* testsuite/libgomp.c/scan-18.c: Likewise.
* testsuite/libgomp.c/scan-19.c: Likewise.
* testsuite/libgomp.c/scan-20.c: Likewise.
* testsuite/libgomp.c/scan-21.c: Likewise.
* testsuite/libgomp.c/scan-22.c: Likewise.
* testsuite/libgomp.c++/scan-9.C: Likewise.
* testsuite/libgomp.c++/scan-10.C: Likewise.
* testsuite/libgomp.c++/scan-11.C: Likewise.
* testsuite/libgomp.c++/scan-12.C: Likewise.
* testsuite/libgomp.c++/scan-13.C: Likewise.
* testsuite/libgomp.c++/scan-14.C: Likewise.
* testsuite/libgomp.c++/scan-15.C: Likewise.
* testsuite/libgomp.c++/scan-16.C: Likewise.

3 years agoSupport reduc_{plus,smax,smin,umax,umin}_scal_v4qi.
liuhongt [Sat, 9 Oct 2021 06:34:38 +0000 (14:34 +0800)]
Support reduc_{plus,smax,smin,umax,umin}_scal_v4qi.

gcc/ChangeLog

PR target/102483
* config/i386/i386-expand.c (emit_reduc_half): Handle
V4QImode.
* config/i386/mmx.md (reduc_<code>_scal_v4qi): New expander.
(reduc_plus_scal_v4qi): Ditto.

gcc/testsuite/ChangeLog

* gcc.target/i386/pr102483.c: New test.
* gcc.target/i386/pr102483-2.c: New test.

3 years agoAdjust testcase for O2 vectorization enabling
liuhongt [Mon, 11 Oct 2021 02:05:03 +0000 (10:05 +0800)]
Adjust testcase for O2 vectorization enabling

This issue was observed in rs6000 specific PR102658 as well.

I've looked into it a bit, it's caused by the "conditional store replacement" which
is originally disabled without vectorization as below code.

  /* If either vectorization or if-conversion is disabled then do
     not sink any stores.  */
  if (param_max_stores_to_sink == 0
      || (!flag_tree_loop_vectorize && !flag_tree_slp_vectorize)
      || !flag_tree_loop_if_convert)
    return false;

The new change makes the innermost loop look like

for (int c1 = 0; c1 <= 1499; c1 += 1) {
  if (c1 <= 500) {
     S_10(c0, c1);
  } else {
      S_9(c0, c1);
  }
  S_11(c0, c1);
}

and can not be splitted as:

for (int c1 = 0; c1 <= 500; c1 += 1)
  S_10(c0, c1);

for (int c1 = 501; c1 <= 1499; c1 += 1)
  S_9(c0, c1);

So instead of disabling vectorization, could we just disable this cs replacement
with parameter "--param max-stores-to-sink=0"?

I tested this proposal on ppc64le, it should work as well.

2021-10-11  Kewen Lin  <linkw@linux.ibm.com>

libgomp/ChangeLog:

* testsuite/libgomp.graphite/force-parallel-8.c: Add --param max-stores-to-sink=0.

3 years agors6000: Correct several errant dg-require-effective-target
Paul A. Clarke [Tue, 12 Oct 2021 03:40:39 +0000 (22:40 -0500)]
rs6000: Correct several errant dg-require-effective-target

I misspelled the dg-require-effective-target attribute "vsx_hw" in
recent commits, causing the effected tests to fail.  Correct the spelling.

2021-10-11  Paul A. Clarke  <pc@us.ibm.com>

gcc/testsuite
* gcc.target/powerpc/pr78102.c: Fix dg-require-effective-target.
* gcc.target/powerpc/sse4_1-packusdw.c: Likewise.
* gcc.target/powerpc/sse4_1-pmaxsb.c: Likewise.
* gcc.target/powerpc/sse4_1-pmaxsd.c: Likewise.
* gcc.target/powerpc/sse4_1-pmaxud.c: Likewise.
* gcc.target/powerpc/sse4_1-pmaxuw.c: Likewise.
* gcc.target/powerpc/sse4_1-pminsb.c: Likewise.
* gcc.target/powerpc/sse4_1-pminsd.c: Likewise.
* gcc.target/powerpc/sse4_1-pminud.c: Likewise.
* gcc.target/powerpc/sse4_1-pminuw.c: Likewise.
* gcc.target/powerpc/sse4_1-pmovsxbd.c: Likewise.
* gcc.target/powerpc/sse4_1-pmovsxbw.c: Likewise.
* gcc.target/powerpc/sse4_1-pmovsxwd.c: Likewise.
* gcc.target/powerpc/sse4_1-pmovzxbd.c: Likewise.
* gcc.target/powerpc/sse4_1-pmovzxbq.c: Likewise.
* gcc.target/powerpc/sse4_1-pmovzxbw.c: Likewise.
* gcc.target/powerpc/sse4_1-pmovzxdq.c: Likewise.
* gcc.target/powerpc/sse4_1-pmovzxwd.c: Likewise.
* gcc.target/powerpc/sse4_1-pmovzxwq.c: Likewise.
* gcc.target/powerpc/sse4_1-pmulld.c: Likewise.
* gcc.target/powerpc/sse4_2-pcmpgtq.c: Likewise.
* gcc.target/powerpc/sse4_1-phminposuw.c: Use correct
dg-require-effective-target.

3 years agors6000: Support more SSE4 "cmp", "mul", "pack" intrinsics
Paul A. Clarke [Sun, 8 Aug 2021 20:57:20 +0000 (15:57 -0500)]
rs6000: Support more SSE4 "cmp", "mul", "pack" intrinsics

Function signatures and decorations match gcc/config/i386/smmintrin.h.

Also, copy tests for:
- _mm_cmpeq_epi64
- _mm_mullo_epi32, _mm_mul_epi32
- _mm_packus_epi32
- _mm_cmpgt_epi64 (SSE4.2)

from gcc/testsuite/gcc.target/i386.

2021-10-11  Paul A. Clarke  <pc@us.ibm.com>

gcc
* config/rs6000/smmintrin.h (_mm_cmpeq_epi64, _mm_cmpgt_epi64,
_mm_mullo_epi32, _mm_mul_epi32, _mm_packus_epi32): New.
* config/rs6000/nmmintrin.h: Copy from i386, tweak to suit.

gcc/testsuite
* gcc.target/powerpc/pr78102.c: Copy from gcc.target/i386,
adjust dg directives to suit.
* gcc.target/powerpc/sse4_1-packusdw.c: Same.
* gcc.target/powerpc/sse4_1-pcmpeqq.c: Same.
* gcc.target/powerpc/sse4_1-pmuldq.c: Same.
* gcc.target/powerpc/sse4_1-pmulld.c: Same.
* gcc.target/powerpc/sse4_2-pcmpgtq.c: Same.
* gcc.target/powerpc/sse4_2-check.h: Copy from gcc.target/i386,
tweak to suit.

3 years agors6000: Support SSE4.1 "cvt" intrinsics
Paul A. Clarke [Thu, 22 Jul 2021 19:54:33 +0000 (12:54 -0700)]
rs6000: Support SSE4.1 "cvt" intrinsics

Function signatures and decorations match gcc/config/i386/smmintrin.h.

Also, copy tests for:
- _mm_cvtepi8_epi16, _mm_cvtepi8_epi32, _mm_cvtepi8_epi64
- _mm_cvtepi16_epi32, _mm_cvtepi16_epi64
- _mm_cvtepi32_epi64,
- _mm_cvtepu8_epi16, _mm_cvtepu8_epi32, _mm_cvtepu8_epi64
- _mm_cvtepu16_epi32, _mm_cvtepu16_epi64
- _mm_cvtepu32_epi64

from gcc/testsuite/gcc.target/i386.

sse4_1-pmovsxbd.c, sse4_1-pmovsxbq.c, and sse4_1-pmovsxbw.c were
modified from using "char" types to "signed char" types, because
the default is unsigned on powerpc.

2021-10-11  Paul A. Clarke  <pc@us.ibm.com>

gcc
* config/rs6000/smmintrin.h (_mm_cvtepi8_epi16, _mm_cvtepi8_epi32,
_mm_cvtepi8_epi64, _mm_cvtepi16_epi32, _mm_cvtepi16_epi64,
_mm_cvtepi32_epi64, _mm_cvtepu8_epi16, _mm_cvtepu8_epi32,
_mm_cvtepu8_epi64, _mm_cvtepu16_epi32, _mm_cvtepu16_epi64,
_mm_cvtepu32_epi64): New.

gcc/testsuite
* gcc.target/powerpc/sse4_1-pmovsxbd.c: Copy from gcc.target/i386,
adjust dg directives to suit.
* gcc.target/powerpc/sse4_1-pmovsxbq.c: Same.
* gcc.target/powerpc/sse4_1-pmovsxbw.c: Same.
* gcc.target/powerpc/sse4_1-pmovsxdq.c: Same.
* gcc.target/powerpc/sse4_1-pmovsxwd.c: Same.
* gcc.target/powerpc/sse4_1-pmovsxwq.c: Same.
* gcc.target/powerpc/sse4_1-pmovzxbd.c: Same.
* gcc.target/powerpc/sse4_1-pmovzxbq.c: Same.
* gcc.target/powerpc/sse4_1-pmovzxbw.c: Same.
* gcc.target/powerpc/sse4_1-pmovzxdq.c: Same.
* gcc.target/powerpc/sse4_1-pmovzxwd.c: Same.
* gcc.target/powerpc/sse4_1-pmovzxwq.c: Same.

3 years agors6000: Simplify some SSE4.1 "test" intrinsics
Paul A. Clarke [Wed, 21 Jul 2021 16:35:52 +0000 (09:35 -0700)]
rs6000: Simplify some SSE4.1 "test" intrinsics

Copy some simple redirections from i386 <smmintrin.h>, for:
- _mm_test_all_zeros
- _mm_test_all_ones
- _mm_test_mix_ones_zeros

2021-10-11  Paul A. Clarke  <pc@us.ibm.com>

gcc
* config/rs6000/smmintrin.h (_mm_test_all_zeros,
_mm_test_all_ones, _mm_test_mix_ones_zeros): Rewrite as macro.

3 years agors6000: Support SSE4.1 "min" and "max" intrinsics
Paul A. Clarke [Tue, 20 Jul 2021 16:20:43 +0000 (11:20 -0500)]
rs6000: Support SSE4.1 "min" and "max" intrinsics

Function signatures and decorations match gcc/config/i386/smmintrin.h.

Also, copy tests for _mm_min_epi8, _mm_min_epu16, _mm_min_epi32,
_mm_min_epu32, _mm_max_epi8, _mm_max_epu16, _mm_max_epi32, _mm_max_epu32
from gcc/testsuite/gcc.target/i386.

sse4_1-pmaxsb.c and sse4_1-pminsb.c were modified from using
"char" types to "signed char" types, because the default is unsigned on
powerpc.

2021-10-11  Paul A. Clarke  <pc@us.ibm.com>

gcc
* config/rs6000/smmintrin.h (_mm_min_epi8, _mm_min_epu16,
_mm_min_epi32, _mm_min_epu32, _mm_max_epi8, _mm_max_epu16,
_mm_max_epi32, _mm_max_epu32): New.

gcc/testsuite
* gcc.target/powerpc/sse4_1-pmaxsb.c: Copy from gcc.target/i386.
* gcc.target/powerpc/sse4_1-pmaxsd.c: Same.
* gcc.target/powerpc/sse4_1-pmaxud.c: Same.
* gcc.target/powerpc/sse4_1-pmaxuw.c: Same.
* gcc.target/powerpc/sse4_1-pminsb.c: Same.
* gcc.target/powerpc/sse4_1-pminsd.c: Same.
* gcc.target/powerpc/sse4_1-pminud.c: Same.
* gcc.target/powerpc/sse4_1-pminuw.c: Same.

3 years agoDaily bump.
GCC Administrator [Tue, 12 Oct 2021 00:17:02 +0000 (00:17 +0000)]
Daily bump.

3 years agoAdd obj-c++.srcman target to gcc/objcp/Makefile.
Eric Gallager [Sat, 9 Oct 2021 19:10:32 +0000 (15:10 -0400)]
Add obj-c++.srcman target to gcc/objcp/Makefile.

Closes #56604

Signed-off-by: Eric Gallager <egallager@gcc.gnu.org>
gcc/objcp/ChangeLog:
PR objc++/56604
* Make-lang.in: Add obj-c++.srcman: line.

3 years agoRevert accidental change in ipa-modref-tree.h
Jan Hubicka [Mon, 11 Oct 2021 19:58:43 +0000 (21:58 +0200)]
Revert accidental change in ipa-modref-tree.h

* ipa-modref-tree.h (struct modref_access_node): Revert
accidental change.
(struct modref_ref_node): Likewise.

3 years agolibstdc++: Add wrapper for internal uses of std::terminate
Jonathan Wakely [Fri, 8 Oct 2021 10:35:53 +0000 (11:35 +0100)]
libstdc++: Add wrapper for internal uses of std::terminate

This adds an inline wrapper for std::terminate that doesn't add the
declaration of std::terminate to namespace std. This allows the
library to terminate without including all of <exception>.

libstdc++-v3/ChangeLog:

* include/bits/atomic_timed_wait.h: Remove unused header.
* include/bits/c++config (std:__terminate): Define.
* include/bits/semaphore_base.h: Remove <exception> and use
__terminate instead of terminate.
* include/bits/std_thread.h: Likewise.
* libsupc++/eh_terminate.cc (std::terminate): Use qualified-id
to call __cxxabiv1::__terminate.

3 years agolibstdc++: Simplify std::basic_regex::assign
Jonathan Wakely [Mon, 11 Oct 2021 16:19:43 +0000 (17:19 +0100)]
libstdc++: Simplify std::basic_regex::assign

We know that if __is_contiguous_iterator is true then we have a pointer
or a __normal_iterator that wraps a pointer, so we don't need to use
std::__to_address.

libstdc++-v3/ChangeLog:

* include/bits/regex.h (basic_regex::assign(Iter, Iter)): Avoid
std::__to_address by using poitner directly or using base()
member of __normal_iterator.

3 years agolibstdc++: Fix std::numeric_limits::lowest() test for strict modes
Jonathan Wakely [Mon, 11 Oct 2021 12:28:32 +0000 (13:28 +0100)]
libstdc++: Fix std::numeric_limits::lowest() test for strict modes

This test uses std::is_integral to decide whether we are testing an
integral or floating-point type. But that fails for __int128 because
is_integral<__int128> is false in strict modes. By using
numeric_limits::is_integer instead we get the right answer for all types
that have a numeric_limits specialization.

We can also simplify the test by removing the unnecessary tag
dispatching.

libstdc++-v3/ChangeLog:

* testsuite/18_support/numeric_limits/lowest.cc: Use
numeric_limits<T>::is_integer instead of is_integral<T>::value.

3 years agolibstdc++: Add valid range assertions to std::basic_regex [PR89927]
Jonathan Wakely [Mon, 11 Oct 2021 11:08:59 +0000 (12:08 +0100)]
libstdc++: Add valid range assertions to std::basic_regex [PR89927]

This adds some debug assertions to basic_regex. They don't actually
diagnose the error in the PR yet, but I have another patch to make them
more effective.

Also change the __glibcxx_assert(false) consistency checks to include a
string literal that tells the user a bit more about why the process
aborted. We could consider adding a __glibcxx_bug or
__glibcxx_internal_error macro for this purpose, but ideally we'll never
hit such bugs anyway so it shouldn't be needed.

libstdc++-v3/ChangeLog:

PR libstdc++/89927
* include/bits/regex.h (basic_regex(const _Ch_type*, size_t)):
Add __glibcxx_requires_string_len assertion.
(basic_regex::assign(InputIterator, InputIterator)): Add
__glibcxx_requires_valid_range assertion.
* include/bits/regex_scanner.tcc (_Scanner::_M_advance())
(_Scanner::_M_scan_normal()): Use string literal in assertions.

3 years agolibstdc++: Fix std::match_results::end() for failed matches [PR102667]
Jonathan Wakely [Mon, 11 Oct 2021 08:07:15 +0000 (09:07 +0100)]
libstdc++: Fix std::match_results::end() for failed matches [PR102667]

The end() function needs to consider whether the underlying vector is
empty, not whether the match_results object is empty. That's because the
underlying vector will always contain at least three elements for a
match_results object that is "ready". It contains three extra elements
which are stored in the vector but are not considered part of sequence,
and so should not be part of the [begin(),end()) range.

libstdc++-v3/ChangeLog:

PR libstdc++/102667
* include/bits/regex.h (match_result::empty()): Optimize by
calling the base function directly.
(match_results::end()): Check _Base_type::empty() not empty().
* testsuite/28_regex/match_results/102667.C: New test.

3 years agoCommonize ipa-pta constraint generation for calls
Jan Hubicka [Mon, 11 Oct 2021 16:43:26 +0000 (18:43 +0200)]
Commonize ipa-pta constraint generation for calls

Commonize the three paths to produce constraints for function call
and makes it more flexible, so we can implement new features more easily.  Main
idea is to not special case pure and const since we can now describe all of
pure/const via their EAF flags (implicit_const_eaf_flags and
implicit_pure_eaf_flags) and info on existence of global memory loads/stores in
function which is readily available in the modref tree.

While rewriting the function, I dropped some of optimizations in the way we
generate constraints. Some of them we may want to add back, but I think the
constraint solver should be fast to get rid of them quickly, so it looks like
bit of premature optimization.

We now always produce one additional PTA variable (callescape) for things that
escape into function call and thus can be stored to parameters or global memory
(if modified). This is no longer the same as global escape in case function is
not reading global memory. It is also not same as call use, since we now
understand the fact that interposable functions may use parameter in a way that
is not releavnt for PTA (so we can not optimize out stores initializing the
memory, but we can be safe about fact that pointers stored does not escape).

Compared to previous code we now handle correctly EAF_NOT_RETURNED in all cases
(previously we did so only when all parameters had the flag) and also handle
NOCLOBBER in more cases (since we make difference between global escape and
call escape). Because I commonized code handling args and static chains, we
could now easily extend modref to also track flags for static chain and return
slot which I plan to do next.

Otherwise I put some effort into producing constraints that produce similar
solutions as before (so it is harder to debug differences). For example if
global memory is written one can simply move callescape to escape rather then
making everything escape by its own constraints, but it affects ipa-pta
testcases.

gcc/ChangeLog:

* ipa-modref-tree.h (modref_tree::global_access_p): New member
function.
* ipa-modref.c:
(implicint_const_eaf_flags,implicit_pure_eaf_flags,
ignore_stores_eaf_flags): Move to ipa-modref.h
(remove_useless_eaf_flags): Remove early exit on NOCLOBBER.
(modref_summary::global_memory_read_p): New member function.
(modref_summary::global_memory_written_p): New member function.
* ipa-modref.h (modref_summary::global_memory_read_p,
modref_summary::global_memory_written_p): Declare.
(implicint_const_eaf_flags,implicit_pure_eaf_flags,
ignore_stores_eaf_flags): move here.
* tree-ssa-structalias.c: Include ipa-modref-tree.h, ipa-modref.h
and attr-fnspec.h.
(handle_rhs_call): Rewrite.
(handle_call_arg): New function.
(determine_global_memory_access): New function.
(handle_const_call): Remove
(handle_pure_call): Remove
(find_func_aliases_for_call): Update use of handle_rhs_call.
(compute_points_to_sets): Handle global memory acccesses
selectively

gcc/testsuite/ChangeLog:

* gcc.dg/torture/ssa-pta-fn-1.c: Fix template; add noipa.
* gcc.dg/tree-ssa/pta-callused.c: Fix template.

3 years agoc++: Add testcase for already-fixed PR [PR102643]
Patrick Palka [Mon, 11 Oct 2021 16:33:30 +0000 (12:33 -0400)]
c++: Add testcase for already-fixed PR [PR102643]

Fixed with r12-1744.

PR c++/102643

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/class-deduction-alias11.C: New test.

3 years agodoc: improve -fsanitize=undefined description
Diane Meirowitz [Wed, 15 Sep 2021 21:03:00 +0000 (21:03 +0000)]
doc: improve -fsanitize=undefined description

gcc/ChangeLog:
* doc/invoke.texi: Add link to UndefinedBehaviorSanitizer
documentation, mention UBSAN_OPTIONS, similar to what is done
for AddressSanitizer.

3 years agoChangeLog: Remove incorrect PR reference
Jonathan Wakely [Mon, 11 Oct 2021 08:25:07 +0000 (09:25 +0100)]
ChangeLog: Remove incorrect PR reference

3 years agomiddle-end/102683 - fix .DEFERRED_INIT expansion
Richard Biener [Mon, 11 Oct 2021 12:31:59 +0000 (14:31 +0200)]
middle-end/102683 - fix .DEFERRED_INIT expansion

This avoids using an integer type for which we don't have an
approprate mode when expanding .DEFERRED_INIT to a non-memory
entity.

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

PR middle-end/102683
* internal-fn.c (expand_DEFERRED_INIT): Check for mode
availability before building an integer type for storage
purposes.

3 years agomiddle-end/101480 - overloaded global new/delete
Richard Biener [Mon, 11 Oct 2021 14:06:03 +0000 (16:06 +0200)]
middle-end/101480 - overloaded global new/delete

The following fixes the issue of ignoring side-effects on memory
from overloaded global new/delete operators by not marking them
as effectively 'const' apart from other explicitely specified
side-effects.

This will cause

FAIL: g++.dg/warn/Warray-bounds-16.C  -std=gnu++1? (test for excess errors)

because we now no longer statically see the initialization loop
never executes because the call to operator new can now clobber 'a.m'.
This seems to be an issue with the warning code and/or ranger so
I'm leaving this FAIL to be addressed as followup.

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

PR middle-end/101480
* gimple.c (gimple_call_fnspec): Do not mark operator new/delete
as const.

* g++.dg/torture/pr10148.C: New testcase.

3 years ago[Ada] Fix problematic import of type-generic GCC atomic builtin
Eric Botcazou [Fri, 8 Oct 2021 22:44:13 +0000 (00:44 +0200)]
[Ada] Fix problematic import of type-generic GCC atomic builtin

gcc/ada/

* gcc-interface/gigi.h (resolve_atomic_size): Declare.
(list_third): New inline function.
* gcc-interface/decl.c (type_for_atomic_builtin_p): New function.
(resolve_atomic_builtin): Likewise.
(gnat_to_gnu_subprog_type): Perform type resolution for most of
type-generic GCC atomic builtins and give an error for the rest.
* gcc-interface/utils2.c (resolve_atomic_size): Make public.

3 years ago[Ada] Tweak the warning about missing local raises
Eric Botcazou [Thu, 7 Oct 2021 15:34:21 +0000 (17:34 +0200)]
[Ada] Tweak the warning about missing local raises

gcc/ada/

* gcc-interface/trans.c (gnat_to_gnu) <N_Pop_Constraint_Error_Label>:
Given the warning only if No_Exception_Propagation is active.
<N_Pop_Storage_Error_Label>: Likewise.
<N_Pop_Program_Error_Label>: Likewise.

3 years ago[Ada] Fix for atomic wrongly rejected on object of discriminated type
Eric Botcazou [Tue, 28 Sep 2021 16:26:38 +0000 (18:26 +0200)]
[Ada] Fix for atomic wrongly rejected on object of discriminated type

gcc/ada/

* gcc-interface/decl.c (promote_object_alignment): Add GNU_SIZE
parameter and use it for the size of the object if not null.
(gnat_to_gnu_entity) <E_Variable>: Perform the automatic alignment
promotion for objects whose nominal subtype is of variable size.
(gnat_to_gnu_field): Adjust call to promote_object_alignment.

3 years ago[Ada] Fix incorrect size for pathological pass-by-copy parameters
Eric Botcazou [Mon, 27 Sep 2021 20:44:59 +0000 (22:44 +0200)]
[Ada] Fix incorrect size for pathological pass-by-copy parameters

gcc/ada/

* gcc-interface/decl.c (gnat_to_gnu_param): Strip padding types
only if the size does not change in the process.  Rename local
variable and add bypass for initialization procedures.

3 years ago[Ada] Runtime transition: System.Threads
Doug Rupp [Wed, 6 Oct 2021 20:03:56 +0000 (13:03 -0700)]
[Ada] Runtime transition: System.Threads

gcc/ada/

* libgnat/s-thread.ads: Fix comments.  Remove unused package
imports.
(Thread_Body_Exception_Exit): Remove Exception_Occurrence
parameter.
(ATSD): Declare type locally.
* libgnat/s-thread__ae653.adb: Fix comments.  Remove unused
package imports.  Remove package references to Stack_Limit
checking.
(Install_Handler): Remove.
(Set_Sec_Stack): Likewise.
(Thread_Body_Enter): Remove calls to Install_Handler and
Stack_Limit checking.
(Thread_Body_Exception_Exit): Remove Exception_Occurrence
parameter.
(Init_RTS): Call local Get_Sec_Stack.  Remove call to
Install_Handler.  Remove references to accessors for
Get_Sec_Stack and Set_Sec_Stack.  Remove OS check.
(Set_Sec_Stack): Remove.

3 years ago[Ada] Remove redundant guard in expansion of dispatching calls
Piotr Trojanek [Thu, 7 Oct 2021 17:59:09 +0000 (19:59 +0200)]
[Ada] Remove redundant guard in expansion of dispatching calls

gcc/ada/

* exp_ch3.adb (Make_Predefined_Primitive_Specs,
Predefined_Primitive_Bodies): Remove guard with restriction
No_Dispatching_Calls.

3 years ago[Ada] Valid postconditions incorrectly rejected.
Steve Baird [Fri, 1 Oct 2021 00:36:38 +0000 (17:36 -0700)]
[Ada] Valid postconditions incorrectly rejected.

gcc/ada/

* sem_attr.adb (Analyze_Attribute_Old_Result): Permit an
attribute reference inside a compiler-generated _Postconditions
procedure. In this case, Subp_Decl is assigned the declaration
of the enclosing subprogram.
* exp_util.adb (Insert_Actions): When climbing up the tree
looking for an insertion point, do not climb past an
N_Iterated_Component/Element_Association, since this could
result in inserting a reference to a loop parameter at a
location outside of the scope of that loop parameter. On the
other hand, be careful to preserve existing behavior in the case
of an N_Component_Association node.

3 years ago[Ada] Incorrect Dynamic_Predicate results for static arguments
Steve Baird [Mon, 4 Oct 2021 22:33:18 +0000 (15:33 -0700)]
[Ada] Incorrect Dynamic_Predicate results for static arguments

gcc/ada/

* exp_ch6.adb (Can_Fold_Predicate_Call): Do not attempt folding
if there is more than one predicate involved. Recall that
predicate aspect specification are additive, not overriding, and
that there are three different predicate
aspects (Dynamic_Predicate, Static_Predicate, and the
GNAT-defined Predicate aspect). These various ways of
introducing multiple predicates are all checked for.  A new
nested function, Augments_Other_Dynamic_Predicate, is
introduced.
* sem_ch4.adb
(Analyze_Indexed_Component_Form.Process_Function_Call): When
determining whether a name like "X (Some_Discrete_Type)" might
be interpreted as a slice, the answer should be "no" if the
type/subtype name denotes the current instance of type/subtype.

3 years ago[Ada] sigset_t is an unsigned long on RTEMS
Patrick Bernardi [Thu, 7 Oct 2021 21:19:01 +0000 (17:19 -0400)]
[Ada] sigset_t is an unsigned long on RTEMS

gcc/ada/

* libgnarl/s-osinte__rtems.ads: Change sigset_t to an unsigned
long.

3 years ago[Ada] RTEMS: use regular RTEMS API for minimum stack size calculation
Patrick Bernardi [Thu, 7 Oct 2021 15:21:24 +0000 (11:21 -0400)]
[Ada] RTEMS: use regular RTEMS API for minimum stack size calculation

gcc/ada/

* libgnat/s-parame__rtems.adb: use
_POSIX_Threads_Minimum_stack_size instead of
ada_pthread_minimum_stack_size.

3 years ago[Ada] Export No_Exception_Propagation_Active for use by gigi
Eric Botcazou [Wed, 6 Oct 2021 16:07:15 +0000 (18:07 +0200)]
[Ada] Export No_Exception_Propagation_Active for use by gigi

gcc/ada/

* fe.h (No_Exception_Propagation_Active): Declare.
* restrict.ads (No_Exception_Propagation_Active): Add WARNING line.

3 years ago[Ada] Warn about conversion with any predefined time types
Piotr Trojanek [Wed, 17 Feb 2021 22:55:59 +0000 (23:55 +0100)]
[Ada] Warn about conversion with any predefined time types

gcc/ada/

* sem_ch13.adb (Validate_Unchecked_Conversion): Simplify code
for detecting conversions with Ada.Calendar.Time type and extend
it to similar types in the Ada.Real_Time package.

3 years ago[Ada] Simplify membership tests with N_Generic_Declaration
Piotr Trojanek [Tue, 5 Oct 2021 12:12:46 +0000 (14:12 +0200)]
[Ada] Simplify membership tests with N_Generic_Declaration

gcc/ada/

* sem_ch10.adb, sem_prag.adb, sem_util.adb: Use
N_Generic_Declaration in membership tests.

3 years ago[Ada] Remove constant arguments
Etienne Servais [Wed, 29 Sep 2021 13:22:00 +0000 (15:22 +0200)]
[Ada] Remove constant arguments

gcc/ada/

* ali.adb (Get_Name): Ignore_Spaces is always False.
* bindo-graphs.adb (Set_Is_Existing_Source_Target_Relation): Val
is always True.
* cstand.adb (New_Standard_Entity): New_Node_Kind is always
N_Defininig_Identifier.
* exp_ch3.adb (Predef_Stream_Attr_Spec): For_Body is always
False.
* exp_dist.adb (Add_Parameter_To_NVList): RACW_Ctrl is always
False.
* gnatls.adb (Add_Directories): Prepend is always False.
* sem_ch10.adb, sem_ch10.ads (Load_Needed_Body): Do_Analyze is
always True.
* sem_ch3.adb, sem_ch3.ads (Process_Range_Expr_In_Decl):
R_Check_Off is always False.
* sem_elab.adb: (Info_Variable_Reference): Info_Msg is always
False, In_SPARK is always True.
(Set_Is_Traversed_Body, Set_Is_Saved_Construct,
Set_Is_Saved_Relation): Val is always True.
* treepr.adb (Visit_Descendant): No_Indent is always False.
(Print_Node): Fmt does not need such a big scope.