platform/upstream/gcc.git
3 years agoopenmp: Add additional tests for declare variant in Fortran
Kwok Cheung Yeung [Mon, 18 Oct 2021 20:56:59 +0000 (13:56 -0700)]
openmp: Add additional tests for declare variant in Fortran

Add tests to check that explicitly specifying the containing procedure as the
base name for declare variant works.

2021-10-18  Kwok Cheung Yeung  <kcy@codesourcery.com>

gcc/testsuite/

* gfortran.dg/gomp/declare-variant-15.f90 (variant2, base2, test2):
Add tests.
* gfortran.dg/gomp/declare-variant-16.f90 (base2, variant2, test2):
Add tests.

3 years agoi386: Fix ICE in ix86_print_opreand_address [PR 102761]
Uros Bizjak [Mon, 18 Oct 2021 15:03:28 +0000 (17:03 +0200)]
i386: Fix ICE in ix86_print_opreand_address [PR 102761]

2021-10-18  Uroš Bizjak  <ubizjak@gmail.com>

PR target/102761

gcc/ChangeLog:

* config/i386/i386.c (ix86_print_operand_address):
Error out for non-address_operand asm operands.

gcc/testsuite/ChangeLog:

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

3 years agoc++: improve template/crash90.C
Jason Merrill [Mon, 18 Oct 2021 14:15:42 +0000 (10:15 -0400)]
c++: improve template/crash90.C

In r208350 I improved the diagnostic location of the initializer-list
pedwarn in C++98 mode on crash90.C, but didn't adjust the testcase to verify
the location, so reverting that change didn't break regression testing.

gcc/testsuite/ChangeLog:

* g++.dg/template/crash90.C: Check location of pedwarn.

3 years agoApply TLC to vect_supportable_dr_alignment
Richard Biener [Mon, 18 Oct 2021 13:02:49 +0000 (15:02 +0200)]
Apply TLC to vect_supportable_dr_alignment

This fixes handling of the return value of vect_supportable_dr_alignment
in multiple places.  We should use the enum type and not int for
storage and not auto-convert the enum return value to bool.  It also
commonizes the read/write path in vect_supportable_dr_alignment.

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

* tree-vect-data-refs.c (vect_peeling_hash_insert): Do
not auto-convert dr_alignment_support to bool.
(vect_peeling_supportable): Likewise.
(vect_enhance_data_refs_alignment): Likewise.
(vect_supportable_dr_alignment): Commonize read/write case.
* tree-vect-stmts.c (vect_get_store_cost): Use
dr_alignment_support, not int, for the vect_supportable_dr_alignment
result.
(vect_get_load_cost): Likewise.

3 years agotree-object-size: Avoid unnecessary processing of __builtin_object_size
Siddhesh Poyarekar [Mon, 18 Oct 2021 03:45:42 +0000 (09:15 +0530)]
tree-object-size: Avoid unnecessary processing of __builtin_object_size

This is a minor cleanup to bail out early if the result of
__builtin_object_size is not assigned to anything and avoid initializing
the object size arrays.

gcc/ChangeLog:

* tree-object-size.c (object_sizes_execute): Consolidate LHS
null check and do it early.

Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
3 years agoReduce the number of aligned_access_p calls
Richard Biener [Mon, 18 Oct 2021 11:54:34 +0000 (13:54 +0200)]
Reduce the number of aligned_access_p calls

This uses the computed alignment scheme in vectorizable_store
much like vectorizable_load does instead of re-querying
it via aligned_access_p.

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

* tree-vect-stmts.c (vectorizable_store): Use the
computed alignment scheme instead of querying
aligned_access_p.

3 years agoRemove redundant alignment scheme recomputation
Richard Biener [Mon, 18 Oct 2021 11:26:10 +0000 (13:26 +0200)]
Remove redundant alignment scheme recomputation

The following avoids the recomputation of the alignment scheme
which is already fully determined by get_load_store_type.

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

* tree-vect-stmts.c (vectorizable_store): Do not recompute
alignment scheme already determined by get_load_store_type.

3 years agoopenmp: Fix handling of numa_domains(1)
Jakub Jelinek [Mon, 18 Oct 2021 12:54:16 +0000 (14:54 +0200)]
openmp: Fix handling of numa_domains(1)

If numa-domains is used with num-places count, sometimes the function
could create more places than requested and crash.  This depended on the
content of /sys/devices/system/node/online file, e.g. if the file
contains
0-1,16-17
and all NUMA nodes contain at least one CPU in the cpuset of the program,
then numa_domains(2) or numa_domains(4) (or 5+) work fine while
numa_domains(1) or numa_domains(3) misbehave.  I.e. the function was able
to stop after reaching limit on the , separators (or trivially at the end),
but not within in the ranges.

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

* config/linux/affinity.c (gomp_affinity_init_numa_domains): Add
&& gomp_places_list_len < count after nfirst <= nlast loop condition.

3 years agoClone correct pass in class pass_thread_jumps_full.
Aldy Hernandez [Mon, 18 Oct 2021 11:53:50 +0000 (13:53 +0200)]
Clone correct pass in class pass_thread_jumps_full.

The pass_thread_jumps_full pass was cloning the wrong pass.

gcc/ChangeLog:

* tree-ssa-threadbackward.c (class pass_thread_jumps_full):
Clone corresponding pass.

3 years ago387-12.c: Require ia32 target instead of -m32
H.J. Lu [Mon, 18 Oct 2021 12:39:53 +0000 (05:39 -0700)]
387-12.c: Require ia32 target instead of -m32

On x86-64,

$ make check RUNTESTFLAGS="--target_board='unix{-m32,}'"

can be used to test both 64-bit and 32-bit targets.  Require ia32 target
instead of explicit -m32 for 32-bit only test.

* gcc.target/i386/387-12.c (dg-do compile): Require ia32.
(dg-options): Remove -m32.

3 years agoTry placing RTL folded constants in the constant pool.
Roger Sayle [Mon, 18 Oct 2021 11:15:40 +0000 (12:15 +0100)]
Try placing RTL folded constants in the constant pool.

My recent attempts to come up with a testcase for my patch to evaluate
ss_plus in simplify-rtx.c, identified a missed optimization opportunity
(that's potentially a long-time regression): The RTL optimizers no longer
place constants in the constant pool.

The motivating x86_64 example is the simple program:

typedef char v8qi __attribute__ ((vector_size (8)));

v8qi foo()
{
  v8qi tx = { 1, 0, 0, 0, 0, 0, 0, 0 };
  v8qi ty = { 2, 0, 0, 0, 0, 0, 0, 0 };
  v8qi t = __builtin_ia32_paddsb(tx, ty);
  return t;
}

which (with my previous patch) currently results in:
foo: movq    .LC0(%rip), %xmm0
        movq    .LC1(%rip), %xmm1
        paddsb  %xmm1, %xmm0
        ret

even though the RTL contains the result in a REG_EQUAL note:

(insn 7 6 12 2 (set (reg:V8QI 83)
        (ss_plus:V8QI (reg:V8QI 84)
            (reg:V8QI 85))) "ssaddqi3.c":7:12 1419 {*mmx_ssaddv8qi3}
     (expr_list:REG_DEAD (reg:V8QI 85)
        (expr_list:REG_DEAD (reg:V8QI 84)
            (expr_list:REG_EQUAL (const_vector:V8QI [
                        (const_int 3 [0x3])
                        (const_int 0 [0]) repeated x7
                    ])
                (nil)))))

Together with the patch below, GCC will now generate the much
more sensible:
foo: movq    .LC2(%rip), %xmm0
        ret

My first approach was to look in cse.c (where the REG_EQUAL note gets
added) and notice that the constant pool handling functionality has been
unreachable for a while.  A quick search for constant_pool_entries_cost
shows that it's initialized to zero, but never set to a non-zero value,
meaning that force_const_mem is never called.  This functionality used
to work way back in 2003, but has been lost over time:
https://gcc.gnu.org/pipermail/gcc-patches/2003-October/116435.html

The changes to cse.c below restore this functionality (placing suitable
constants in the constant pool) with two significant refinements;
(i) it only attempts to do this if the function already uses a constant
pool (thanks to the availability of crtl->uses_constant_pool since 2003).
(ii) it allows different constants (i.e. modes) to have different costs,
so that floating point "doubles" and 64-bit, 128-bit, 256-bit and 512-bit
vectors don't all have the share the same cost.  Back in 2003, the
assumption was that everything in a constant pool had the same
cost, hence the global variable constant_pool_entries_cost.

Although this is a useful CSE fix, it turns out that it doesn't cure
my motivating problem above.  CSE only considers a single instruction,
so determines that it's cheaper to perform the ss_plus (COSTS_N_INSNS(1))
than read the result from the constant pool (COSTS_N_INSNS(2)).  It's
only when the other reads from the constant pool are also eliminated,
that this transformation is a win.  Hence a better place to perform
this transformation is in combine, where after failing to "recog" the
load of a suitable constant, it can retry after calling force_const_mem.
This achieves the desired transformation and allows the backend insn_cost
call-back to control whether or not using the constant pool is preferrable.

Alas, it's rare to change code generation without affecting something in
GCC's testsuite.  On x86_64-pc-linux-gnu there were two families of new
failures (and I'd predict similar benign fallout on other platforms).
One failure was gcc.target/i386/387-12.c (aka PR target/26915), where
the test is missing an explicit -m32 flag.  On i686, it's very reasonable
to materialize -1.0 using "fld1; fchs", but on x86_64-pc-linux-gnu we
currently generate the awkward:
testm1: fld1
        fchs
        fstpl   -8(%rsp)
        movsd   -8(%rsp), %xmm0
        ret

which combine now very reasonably simplifies to just:
testm1: movsd   .LC3(%rip), %xmm0
ret

The other class of x86_64-pc-linux-gnu failure was from materialization
of vector constants using vpbroadcast (e.g. gcc.target/i386/pr90773-17.c)
where the decision is finely balanced; the load of an integer register
with an immediate constant, followed by a vpbroadcast is deemed to be
COSTS_N_INSNS(2), whereas a load from the constant pool is also reported
as COSTS_N_INSNS(2).  My solution is to tweak the i386.c's rtx_costs
so that all other things being equal, an instruction (sequence) that
accesses memory is fractionally more expensive than one that doesn't.

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

gcc/ChangeLog
* combine.c (recog_for_combine): For an unrecognized move/set of
a constant, try force_const_mem to place it in the constant pool.
* cse.c (constant_pool_entries_cost, constant_pool_entries_regcost):
Delete global variables (that are no longer assigned a cost value).
(cse_insn): Simplify logic for deciding whether to place a folded
constant in the constant pool using force_const_mem.
(cse_main): Remove zero initialization of constant_pool_entries_cost
and constant_pool_entries_regcost.

* config/i386/i386.c (ix86_rtx_costs): Make memory accesses
fractionally more expensive, when optimizing for speed.

gcc/testsuite/ChangeLog
* gcc.target/i386/387-12.c: Add explicit -m32 option.

3 years agogcov: return proper exit code when error happens
Martin Liska [Mon, 18 Oct 2021 09:30:55 +0000 (11:30 +0200)]
gcov: return proper exit code when error happens

PR gcov-profile/102746
PR gcov-profile/102747

gcc/ChangeLog:

* gcov.c (main): Return return_code.
(output_gcov_file): Mark return_code when error happens.
(generate_results): Likewise.
(read_graph_file): Likewise.
(read_count_file): Likewise.

3 years agobfin: Popcount-related improvements to machine description.
Roger Sayle [Mon, 18 Oct 2021 10:56:56 +0000 (11:56 +0100)]
bfin: Popcount-related improvements to machine description.

Blackfin processors support a ONES instruction that implements a
32-bit popcount returning a 16-bit result.  This instruction was
previously described by GCC's bfin backend using an UNSPEC, which
this patch changes to use a popcount:SI rtx thats capture its semantics,
allowing it to evaluated and simplified at compile-time.  I've decided
to keep the instruction name the same (avoiding any changes to the
__builtin_bfin_ones machinery), but have provided popcountsi2 and
popcounthi2 expanders so that the middle-end can use this instruction
to implement __builtin_popcount (and __builtin_parity).

The new testcase ones.c
short foo ()
{
  int t = 5;
  short r = __builtin_bfin_ones(t);
  return r;
}

previously generated:
_foo:   nop;
        nop;
        R0 = 5 (X);
        R0.L = ONES R0;
        rts;

with this patch, now generates:
_foo:   nop;
        nop;
        nop;
        R0 = 2 (X);
        rts;

The new testcase popcount.c
int foo(int x)
{
  return __builtin_popcount(x);
}

previously generated:
_foo:   [--SP] = RETS;
        SP += -12;
        call ___popcountsi2;
        SP += 12;
        RETS = [SP++];
        rts;

now generates:
_foo:   nop;
        nop;
        R0.L = ONES R0;
        R0 = R0.L (Z);
        rts;

And the new testcase parity.c
int foo(int x)
{
  return __builtin_parity(x);
}

previously generated:
_foo: [--SP] = RETS;
        SP += -12;
        call ___paritysi2;
        SP += 12;
        RETS = [SP++];
        rts;

now generates:
_foo: nop;
        R1 = 1 (X);
        R0.L = ONES R0;
        R0 = R1 & R0;
        rts;

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

gcc/ChangeLog
* config/bfin/bfin.md (define_constants): Remove UNSPEC_ONES.
(define_insn "ones"): Replace UNSPEC_ONES with a truncate of
a popcount, allowing compile-time evaluation/simplification.
(popcountsi2, popcounthi2): New expanders using a "ones" insn.

gcc/testsuite/ChangeLog
* gcc.target/bfin/ones.c: New test case.
* gcc.target/bfin/parity.c: New test case.
* gcc.target/bfin/popcount.c: New test case.

3 years agotree-optimization/102788 - avoid spurious bool pattern fails
Richard Biener [Mon, 18 Oct 2021 08:31:19 +0000 (10:31 +0200)]
tree-optimization/102788 - avoid spurious bool pattern fails

Bool pattern recog is required for correctness since vectorized
compares otherwise produce -1 for true so any context where bool
is used as value and not as condition or mask needs to be replaced
with CMP ? 1 : 0.  When we fail to find a vector type for the
result of such use we may not simply elide such transform since
a new bool result can emerge when for example the cast_forwprop
pattern is applied.  So the following avoids failing of the
bool pattern recog process and instead not assign a vector type
for the stmt.

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

PR tree-optimization/102788
* tree-vect-patterns.c (vect_init_pattern_stmt): Allow
a NULL vectype.
(vect_pattern_recog_1): Likewise.
(vect_recog_bool_pattern): Continue matching the pattern
even if we do not have a vector type for a conversion
result.

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

3 years agoConstant fold SS_NEG and SS_ABS in simplify-rtx.c
Roger Sayle [Mon, 18 Oct 2021 10:51:07 +0000 (11:51 +0100)]
Constant fold SS_NEG and SS_ABS in simplify-rtx.c

This simple patch performs compile-time constant folding of
signed saturating negation and signed saturating absolute value
in the RTL optimizers.  Normally in two's complement arithmetic
the lowest representable signed value overflows on negation,
With these saturating operators they "saturate" to the maximum
representable signed value, so SS_NEG:QI -128 is 127, and
SS_ABS:HI -32768 is 32767.

On bfin-elf, the following two short functions:

short foo()
{
  short t = -32768;
  short r = __builtin_bfin_negate_fr1x16(t);
  return r;
}

int bar()
{
  int t = -2147483648;
  int r = __builtin_bfin_abs_fr1x32(t);
  return r;
}

currently compile to:
_foo: nop;
        nop;
        R0 = -32768 (X);
        R0 = -R0 (V);
        rts;

_bar: nop;
        R0 = -1 (X);
        R0 <<= 31;
        R0 = abs R0;
        rts;

but with this middle-end patch now compile to:

_foo: nop;
        nop;
        nop;
        R0 = 32767 (X);
        rts;

_bar: nop;
        nop;
        R0 = -1 (X);
        R0.H = 32767;
        rts;

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

gcc/ChangeLog
* simplify-rtx.c (simplify_const_unary_operation) [SS_NEG, SS_ABS]:
Evalute SS_NEG and SS_ABS of a constant argument.

gcc/testsuite/ChangeLog
* gcc.target/bfin/ssabs.c: New test case.
* gcc.target/bfin/ssneg.c: New test case.

3 years ago[sve] PR93183 - Add support for conditional neg.
prathamesh.kulkarni [Mon, 18 Oct 2021 10:14:06 +0000 (15:44 +0530)]
[sve] PR93183 - Add support for conditional neg.

gcc/ChangeLog:
PR target/93183
* gimple-match-head.c (try_conditional_simplification): Add case for single operand.
* internal-fn.def: Add entry for COND_NEG internal function.
* internal-fn.c (FOR_EACH_CODE_MAPPING): Add entry for
NEGATE_EXPR, COND_NEG mapping.
* optabs.def: Add entry for cond_neg_optab.
* match.pd (UNCOND_UNARY, COND_UNARY): New operator lists.
(vec_cond COND (foo A) B) -> (IFN_COND_FOO COND A B): New pattern.
(vec_cond COND B (foo A)) -> (IFN_COND_FOO ~COND A B): Likewise.

gcc/testsuite/ChangeLog:
PR target/93183
* gcc.target/aarch64/sve/cond_unary_4.c: Adjust.
* gcc.target/aarch64/sve/pr93183.c: New test.

3 years agogcc-changelog: update error message location
Martin Liska [Mon, 18 Oct 2021 08:44:11 +0000 (10:44 +0200)]
gcc-changelog: update error message location

contrib/ChangeLog:

* gcc-changelog/git_commit.py: Update location of
'bad parentheses wrapping'.
* gcc-changelog/test_email.py: Test it.

3 years agoStrlen pass refactoring.
Aldy Hernandez [Sat, 9 Oct 2021 17:26:32 +0000 (19:26 +0200)]
Strlen pass refactoring.

This refactors the strlen pass to avoid passing around as much state.
It is meant to be a start.  There's still some more refactoring
that could be done, especially in cleaning up the interface between
the strlen internals and the sprintf pass.

Tested on x86-64 Linux.

gcc/ChangeLog:

* tree-ssa-strlen.c (class strlen_pass): Rename from
strlen_dom_walker.
(handle_builtin_stxncpy_strncat): Move to strlen_pass.
(handle_assign): Same.
(adjust_last_stmt): Same.
(maybe_warn_overflow): Same.
(handle_builtin_strlen): Same.
(handle_builtin_strchr): Same.
(handle_builtin_strcpy): Same.
(handle_builtin_strncat): Same.
(handle_builtin_stxncpy_strncat): Same.
(handle_builtin_memcpy): Same.
(handle_builtin_strcat): Same.
(handle_alloc_call): Same.
(handle_builtin_memset): Same.
(handle_builtin_memcmp): Same.
(get_len_or_size): Same.
(strxcmp_eqz_result): Same.
(handle_builtin_string_cmp): Same.
(handle_pointer_plus): Same.
(count_nonzero_bytes_addr): Same.
(count_nonzero_bytes): Same.
(handle_store): Same.
(strlen_check_and_optimize_call): Same.
(handle_integral_assign): Same.
(check_and_optimize_stmt): Same.
(printf_strlen_execute): Rename strlen_dom_walker to strlen_pass.

3 years agoFortran: Fix Bind(C) Array-Descriptor Conversion
Tobias Burnus [Mon, 18 Oct 2021 07:51:36 +0000 (09:51 +0200)]
Fortran: Fix Bind(C) Array-Descriptor Conversion

gfortran uses internally a different array descriptor ("gfc") as
Fortran 2018 alias TS291113 defines for C interoperability via
ISO_Fortran_binding.h ("CFI").  Hence, when calling a C function
from Fortran, it has to be converted in the callee - and if a
BIND(C) procedure is written in Fortran, the CFI argument has
to be converted to gfc in order work with the rest of the FE
code and the library calls.

Before this patch, part was handled in the FE generated code and
other parts in libgfortran.  With this patch, all code is generated
and CFI is defined as proper type - visible in the debugger and to
the middle end - avoiding both alias issues and missed optimization
issues.

This patch also fixes issues like: intent(out) deallocation in
the bind(C) callee, using the CFI descriptor also for allocatable
and pointer scalars and for len=* character strings.
For 'select rank', it also optimizes the code + avoid accessing
uninitialized memory if the dummy argument is allocatable/a pointer.
It additionally rejects passing a descriptorless type(*) to an
assumed-rank dummy argument. [F2018:C711]

PR fortran/102086
PR fortran/92189
PR fortran/92621
PR fortran/101308
PR fortran/101309
PR fortran/101635
PR fortran/92482

gcc/fortran/ChangeLog:

* decl.c (gfc_verify_c_interop_param): Remove 'sorry' for
scalar allocatable/pointer and len=*.
* expr.c (is_CFI_desc): Return true for for those.
* gfortran.h (CFI_type_kind_shift, CFI_type_mask,
CFI_type_from_type_kind, CFI_VERSION, CFI_MAX_RANK,
CFI_attribute_pointer, CFI_attribute_allocatable,
CFI_attribute_other, CFI_type_Integer, CFI_type_Logical,
CFI_type_Real, CFI_type_Complex, CFI_type_Character,
CFI_type_ucs4_char, CFI_type_struct, CFI_type_cptr,
CFI_type_cfunptr, CFI_type_other): New #define.
* trans-array.c (CFI_FIELD_BASE_ADDR, CFI_FIELD_ELEM_LEN,
CFI_FIELD_VERSION, CFI_FIELD_RANK, CFI_FIELD_ATTRIBUTE,
CFI_FIELD_TYPE, CFI_FIELD_DIM, CFI_DIM_FIELD_LOWER_BOUND,
CFI_DIM_FIELD_EXTENT, CFI_DIM_FIELD_SM,
gfc_get_cfi_descriptor_field, gfc_get_cfi_desc_base_addr,
gfc_get_cfi_desc_elem_len, gfc_get_cfi_desc_version,
gfc_get_cfi_desc_rank, gfc_get_cfi_desc_type,
gfc_get_cfi_desc_attribute, gfc_get_cfi_dim_item,
gfc_get_cfi_dim_lbound, gfc_get_cfi_dim_extent, gfc_get_cfi_dim_sm):
New define/functions to access the CFI array descriptor.
(gfc_conv_descriptor_type): New function for the GFC descriptor.
(gfc_get_array_span): Handle expr of CFI descriptors and
assumed-type descriptors.
(gfc_trans_array_bounds): Remove 'static'.
(gfc_conv_expr_descriptor): For assumed type, use the dtype of
the actual argument.
(structure_alloc_comps): Remove ' ' inside tabs.
* trans-array.h (gfc_trans_array_bounds, gfc_conv_descriptor_type,
gfc_get_cfi_desc_base_addr, gfc_get_cfi_desc_elem_len,
gfc_get_cfi_desc_version, gfc_get_cfi_desc_rank,
gfc_get_cfi_desc_type, gfc_get_cfi_desc_attribute,
gfc_get_cfi_dim_lbound, gfc_get_cfi_dim_extent, gfc_get_cfi_dim_sm):
New prototypes.
* trans-decl.c (gfor_fndecl_cfi_to_gfc, gfor_fndecl_gfc_to_cfi):
Remove global vars.
(gfc_build_builtin_function_decls): Remove their initialization.
(gfc_get_symbol_decl, create_function_arglist,
gfc_trans_deferred_vars): Update for CFI.
(convert_CFI_desc): Remove and replace by ...
(gfc_conv_cfi_to_gfc): ... this function
(gfc_generate_function_code): Call it; create local GFC var for CFI.
* trans-expr.c (gfc_maybe_dereference_var): Handle CFI.
(gfc_conv_subref_array_arg): Handle the if-noncontigous-only copy in
when the result should be a descriptor.
(gfc_conv_gfc_desc_to_cfi_desc): Completely rewritten.
(gfc_conv_procedure_call): CFI fixes.
* trans-openmp.c (gfc_omp_is_optional_argument,
gfc_omp_check_optional_argument): Handle optional
CFI.
* trans-stmt.c (gfc_trans_select_rank_cases): Cleanup, avoid invalid
code for allocatable/pointer dummies, which cannot be assumed size.
* trans-types.c (gfc_cfi_descriptor_base): New global var.
(gfc_get_dtype_rank_type): Skip rank init for rank < 0.
(gfc_sym_type): Handle CFI dummies.
(gfc_get_function_type): Update call.
(gfc_get_cfi_dim_type, gfc_get_cfi_type): New.
* trans-types.h (gfc_sym_type): Update prototype.
(gfc_get_cfi_type): New prototype.
* trans.c (gfc_trans_runtime_check): Make conditions more consistent
to avoid '<logical> AND_THEN <long int>' in conditions.
* trans.h (gfor_fndecl_cfi_to_gfc, gfor_fndecl_gfc_to_cfi): Remove
global-var declaration.

libgfortran/ChangeLog:

* ISO_Fortran_binding.h (CFI_type_cfunptr): Make unique type again.
* runtime/ISO_Fortran_binding.c (cfi_desc_to_gfc_desc,
gfc_desc_to_cfi_desc): Add comment that those are no longer called
by new code.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/optional-bind-c.f90: New test.

gcc/testsuite/ChangeLog:

* gfortran.dg/ISO_Fortran_binding_4.f90: Extend testcase.
* gfortran.dg/PR100914.f90: Remove xfail.
* gfortran.dg/PR100915.c: Expect CFI_type_cfunptr.
* gfortran.dg/PR100915.f90: Handle CFI_type_cfunptr != CFI_type_cptr.
* gfortran.dg/PR93963.f90: Extend select-rank tests.
* gfortran.dg/bind-c-intent-out.f90: Change to dg-do run,
update scan-dump.
* gfortran.dg/bind_c_array_params_2.f90: Update/extend scan-dump.
* gfortran.dg/bind_c_char_10.f90: Update scan-dump.
* gfortran.dg/bind_c_char_8.f90: Remove dg-error "sorry".
* gfortran.dg/c-interop/allocatable-dummy.f90: Remove xfail.
* gfortran.dg/c-interop/c1255-1.f90: Likewise.
* gfortran.dg/c-interop/c407c-1.f90: Update dg-error.
* gfortran.dg/c-interop/cf-descriptor-5.f90: Remove xfail.
* gfortran.dg/c-interop/cf-out-descriptor-3.f90: Likewise.
* gfortran.dg/c-interop/cf-out-descriptor-4.f90: Likewise.
* gfortran.dg/c-interop/cf-out-descriptor-5.f90: Likewise.
* gfortran.dg/c-interop/contiguous-2.f90: Likewise.
* gfortran.dg/c-interop/contiguous-3.f90: Likewise.
* gfortran.dg/c-interop/deferred-character-1.f90: Likewise.
* gfortran.dg/c-interop/deferred-character-2.f90: Likewise.
* gfortran.dg/c-interop/fc-descriptor-3.f90: Likewise.
* gfortran.dg/c-interop/fc-descriptor-5.f90: Likewise.
* gfortran.dg/c-interop/fc-descriptor-6.f90: Likewise.
* gfortran.dg/c-interop/fc-out-descriptor-3.f90: Likewise.
* gfortran.dg/c-interop/fc-out-descriptor-4.f90: Likewise.
* gfortran.dg/c-interop/fc-out-descriptor-5.f90: Likewise.
* gfortran.dg/c-interop/fc-out-descriptor-6.f90: Likewise.
* gfortran.dg/c-interop/ff-descriptor-5.f90: Likewise.
* gfortran.dg/c-interop/ff-descriptor-6.f90: Likewise.
* gfortran.dg/c-interop/fc-descriptor-7.f90: Remove xfail + extend.
* gfortran.dg/c-interop/fc-descriptor-7-c.c: Update for changes.
* gfortran.dg/c-interop/shape.f90: Add implicit none.
* gfortran.dg/c-interop/typecodes-array-char-c.c: Add kind=4 char.
* gfortran.dg/c-interop/typecodes-array-char.f90: Likewise.
* gfortran.dg/c-interop/typecodes-array-float128.f90: Remove xfail.
* gfortran.dg/c-interop/typecodes-scalar-basic.f90: Likewise.
* gfortran.dg/c-interop/typecodes-scalar-float128.f90: Likewise.
* gfortran.dg/c-interop/typecodes-scalar-int128.f90: Likewise.
* gfortran.dg/c-interop/typecodes-scalar-longdouble.f90: Likewise.
* gfortran.dg/iso_c_binding_char_1.f90: Remove dg-error "sorry".
* gfortran.dg/pr93792.f90: Turn XFAIL into PASS.
* gfortran.dg/ISO_Fortran_binding_19.f90: New test.
* gfortran.dg/assumed_type_12.f90: New test.
* gfortran.dg/assumed_type_13.c: New test.
* gfortran.dg/assumed_type_13.f90: New test.
* gfortran.dg/bind-c-char-descr.f90: New test.
* gfortran.dg/bind-c-contiguous-1.c: New test.
* gfortran.dg/bind-c-contiguous-1.f90: New test.
* gfortran.dg/bind-c-contiguous-2.f90: New test.
* gfortran.dg/bind-c-contiguous-3.c: New test.
* gfortran.dg/bind-c-contiguous-3.f90: New test.
* gfortran.dg/bind-c-contiguous-4.c: New test.
* gfortran.dg/bind-c-contiguous-4.f90: New test.
* gfortran.dg/bind-c-contiguous-5.c: New test.
* gfortran.dg/bind-c-contiguous-5.f90: New test.

3 years agotree-optimization/102798 - avoid copying PTA info to old SSA names
Richard Biener [Mon, 18 Oct 2021 07:10:43 +0000 (09:10 +0200)]
tree-optimization/102798 - avoid copying PTA info to old SSA names

The vectorizer duplicates pointer-info to created pointer bases
but it has to avoid changing points-to info on existing SSA names
because there's now flow-sensitive info in there (pt->pt_null as
set from VRP).

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

PR tree-optimization/102798
* tree-vect-data-refs.c (vect_create_addr_base_for_vector_ref):
Only copy points-to info to newly generated SSA names.

* gcc.dg/pr102798.c: New testcase.

3 years agoRemove unused but set variables.
Martin Liska [Mon, 18 Oct 2021 07:27:10 +0000 (09:27 +0200)]
Remove unused but set variables.

Reported by clang13 -Wunused-but-set-variable:

gcc/ChangeLog:

* dbgcnt.c (dbg_cnt_process_opt): Remove unused but set variable.
* gcov.c (get_cycles_count): Likewise.
* lto-compress.c (lto_compression_zlib): Likewise.
(lto_uncompression_zlib): Likewise.
* targhooks.c (default_pch_valid_p): Likewise.

libcpp/ChangeLog:

* charset.c (convert_oct): Remove unused but set variable.

3 years agoFortran: Fix CLASS conversion check [PR102745]
Tobias Burnus [Mon, 18 Oct 2021 07:49:05 +0000 (09:49 +0200)]
Fortran: Fix CLASS conversion check [PR102745]

PR fortran/102745
gcc/fortran/ChangeLog
* intrinsic.c (gfc_convert_type_warn): Fix checks by checking CLASS
and do typcheck in correct order for type extension.
* misc.c (gfc_typename): Print proper not internal CLASS type name.

gcc/testsuite/ChangeLog
* gfortran.dg/class_72.f90: New.

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

3 years ago[PATCH] d-demangle: properly skip anonymous symbols
Luís Ferreira [Sun, 17 Oct 2021 22:34:25 +0000 (18:34 -0400)]
[PATCH] d-demangle: properly skip anonymous symbols

libiberty/
PR d/102618
* d-demangle.c (dlang_parse_qualified): Handle anonymous
symbols correctly.

* testsuite/d-demangle-expected: New tests to cover anonymous
symbols.

3 years agoAllow fully resolving backward jump threading passes.
Aldy Hernandez [Fri, 15 Oct 2021 12:46:32 +0000 (14:46 +0200)]
Allow fully resolving backward jump threading passes.

This refactors the backward threader pass so that it can be called in
either fully resolving mode, or in classic mode where any unknowns
default to VARYING.  Doing so opens the door for
"pass_thread_jumps_full" which has the resolving bits set.

This pass has not been added to the pipeline, but with it in place, we
can now experiment with it to see how to reduce the number of
jump threaders.  The first suspect will probably be enabling fully
resolving in the backward threader pass immediately preceeding VRP2,
and removing the VRP2 threader pass.  Now that VRP and the backward
threader are sharing a solver, and most of the threads get handcuffed
by cancel_threads(), we should have a variety of scenarios to try.

In the process, I have cleaned up things to make it trivial to see
what the difference between the 3 variants are (early jump
threading, quick jump threading without resolving SSAs, and fully
resolving jump threading).  Since I moved stuff around, it's probably
easier to just look at the last section in tree-ssa-threadbackward to
see how it's all laid out.

No functional changes as the new pass hasn't been added to the
pipeline.

gcc/ChangeLog:

* tree-pass.h (make_pass_thread_jumps_full): New.
* tree-ssa-threadbackward.c (pass_thread_jumps::gate): Inline.
(try_thread_blocks): Add resolve and speed arguments.
(pass_thread_jumps::execute): Inline.
(do_early_thread_jumps): New.
(do_thread_jumps): New.
(make_pass_thread_jumps): Move.
(pass_early_thread_jumps::gate): Inline.
(pass_early_thread_jumps::execute): Inline.
(class pass_thread_jumps_full): New.

3 years agoDaily bump.
GCC Administrator [Sun, 17 Oct 2021 00:16:20 +0000 (00:16 +0000)]
Daily bump.

3 years agogcc/configure: Check for powerpc64le*-*-freebsd*
Piotr Kubaj [Sat, 16 Oct 2021 02:09:05 +0000 (04:09 +0200)]
gcc/configure: Check for powerpc64le*-*-freebsd*

Only powerpc64-unknown-freebsd was checked for.

Signed-off-by: Piotr Kubaj <pkubaj@FreeBSD.org>
gcc/
* configure.ac: Treat powerpc64*-*-freebsd* the same as
powerpc64-*-freebsd*.
* configure: Regenerate.

3 years agoChange set_ptr_nonull to set_ptr_nonnull in comments
H.J. Lu [Sat, 16 Oct 2021 19:32:31 +0000 (12:32 -0700)]
Change set_ptr_nonull to set_ptr_nonnull in comments

* value-query.cc (get_ssa_name_ptr_info_nonnull): Change
set_ptr_nonull to set_ptr_nonnull in comments.

3 years agoFix wrong code in ldost-strlen-1.c
Jan Hubicka [Sat, 16 Oct 2021 12:45:06 +0000 (14:45 +0200)]
Fix wrong code in ldost-strlen-1.c

gcc/ChangeLog:

PR tree-optimization/102720
* tree-ssa-structalias.c (compute_points_to_sets): Fix producing
of call used and clobbered sets.

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

3 years agolibstdc++: Fix error in filesystem::path with Clang
Jonathan Wakely [Fri, 15 Oct 2021 22:27:54 +0000 (23:27 +0100)]
libstdc++: Fix error in filesystem::path with Clang

THis fixes teh following error seen with Clang:

error: function '_S_convert<std::basic_string_view<char8_t>>' with deduced
return type cannot be used before it is defined
          return string_type(_S_convert(std::u8string_view(__str)));
                             ^

libstdc++-v3/ChangeLog:

* include/bits/fs_path.h (path::_S_convert(T)): Avoid recursive
call to function with deduced return type.

3 years agolibstdc++: Define std::basic_string::resize_and_overwrite for C++23 (P1072R10)
Jonathan Wakely [Fri, 15 Oct 2021 21:01:25 +0000 (22:01 +0100)]
libstdc++: Define std::basic_string::resize_and_overwrite for C++23 (P1072R10)

A recently approved change for the C++23 working draft.

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h (__cpp_lib_string_resize_and_overwrite):
Define for C++23.
(basic_string::resize_and_overwrite): Declare.
* include/bits/basic_string.tcc (basic_string::resize_and_overwrite):
Define.
* include/std/version (__cpp_lib_resize_and_overwrite): Define
for C++23.
* testsuite/21_strings/basic_string/capacity/char/resize_and_overwrite.cc:
New test.

3 years agoc++: array cv-quals and template specialization [PR101402]
Jason Merrill [Tue, 28 Sep 2021 14:02:04 +0000 (10:02 -0400)]
c++: array cv-quals and template specialization [PR101402]

PRs 101402, 102033, etc. demonstrated that the fix for PR92010 wasn't
handling all cases of the CWG1001/1322 issue with parameter type qual
stripping and arrays with templates.  The problem turned out to be in
determine_specialization, which did an extra substitution without the 92010
fix and then complained that the result didn't match.

But just removing that wrong/redundant code meant that we were accepting
specializations with different numbers of parameters, because the code in
fn_type_unification that compares types in this case wasn't checking for
length mismatch.

After fixing that, I realized that fn_type_unification couldn't tell the
difference between variadic and non-variadic function types, because the
args array doesn't include the terminal void we use to indicate non-variadic
function type.  So I added it, and made the necessary adjustments.

Thanks to qingzhe "nick" huang <nickhuang99@hotmail.com> for the patch that
led me to dig more into this, and the extensive testcases.

PR c++/51851
PR c++/101402
PR c++/102033
PR c++/102034
PR c++/102039
PR c++/102044

gcc/cp/ChangeLog:

* pt.c (determine_specialization): Remove redundant code.
(fn_type_unification): Check for mismatched length.
(type_unification_real): Ignore terminal void.
(get_bindings): Don't stop at void_list_node.
* class.c (resolve_address_of_overloaded_function): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/template/fnspec2.C: New test.
* g++.dg/template/parm-cv1.C: New test.
* g++.dg/template/parm-cv2.C: New test.
* g++.dg/template/parm-cv3.C: New test.

3 years agoFortran: validate shape of arrays in constructors against declarations
Harald Anlauf [Fri, 15 Oct 2021 19:23:17 +0000 (21:23 +0200)]
Fortran: validate shape of arrays in constructors against declarations

gcc/fortran/ChangeLog:

PR fortran/102685
* decl.c (match_clist_expr): Set rank/shape of clist initializer
to match LHS.
* resolve.c (resolve_structure_cons): In a structure constructor,
compare shapes of array components against declared shape.

gcc/testsuite/ChangeLog:

PR fortran/102685
* gfortran.dg/derived_constructor_char_1.f90: Fix invalid code.
* gfortran.dg/pr70931.f90: Likewise.
* gfortran.dg/transfer_simplify_2.f90: Likewise.
* gfortran.dg/pr102685.f90: New test.

Co-authored-by: Tobias Burnus <tobias@codesourcery.com>
3 years agoDarwin: Update specs handling '-r'.
Iain Sandoe [Thu, 7 Oct 2021 12:55:48 +0000 (13:55 +0100)]
Darwin: Update specs handling '-r'.

We were not wrapping all the default libraries in checks for whether
they should be used.  We were also wasting a process launch calling
dsymutil for 'r' link lines (a NOP in practice).  Order the checks
that exclude linking from most likely to occur, downwards.

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

* config/darwin.h (LINK_COMMAND_SPEC_A): Update 'r' handling to
skip gomp and itm when r or nodefaultlibs is given.
(DSYMUTIL_SPEC): Do not call dsymutil for '-r' link lines.
Update ordering of exclusions, remove duplicate 'v' addition
(collect2 will add this from the main command line).

3 years agoDarwin: Revise handling of some driver opts.
Iain Sandoe [Fri, 14 Jun 2019 18:14:30 +0000 (19:14 +0100)]
Darwin: Revise handling of some driver opts.

Darwin has a user convenience feature where some linker options are exposed
at the driver level (so one can type '-all_load' instead of '-Wl,-all_load'
or '-Xlinker -all_load').  We retain this feature, but now these options are
all marked as 'Driver' and we process them as early as possible so that they
get allocated to the right toolchain command.  There are a couple of special
cases where these driver opts are used multiple times, or to control
operations on more than one command (e.g. dynamiclib).  These are handled
specially and we then add %<xxxx specs for the commands that _do not_ need
them.  NOTE: the ordering of 'shared' and 'dynamiclib' is significant, hence
they are placed out of alphabetical order at the start.  Likewise, we keep
a couple of cases where a negative option originally appeared after the
positive alternate, potentially overriding it.

When we report an error with %e, it seems necessary to strip the option
before doing so, otherwise it survives to the cc1 command line (%e does not
appear to abort the program before this).

Right now there is no mechanism to split up the 'variable portion' (%*) of
the matched spec string, so where we have some driver specs that take 2 or
3 arguments, these cannot be processed here, but are deferred until the
LINK_SPEC, where they are copied verbatim.

We have a 'safe' version of the macOS version string, that has been sanity-
checked and truncated to minor version.  If the 'tiny' (3rd) portion of the
value is not significant, it is better to use the safe one in version-compare().

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

* config/darwin-driver.c (darwin_driver_init): Revise comments, handle
filelist and framework options in specs instead of code.
* config/darwin.h (SUBTARGET_DRIVER_SELF_SPECS): Update to handle link
specs that are really driver ones.
(DARWIN_CC1_SPEC): Likewise.
(CPP_SPEC): Likewise.
(SYSROOT_SPEC): Append space.
(LINK_SYSROOT_SPEC): Remove most driver link specs.
(STANDARD_STARTFILE_PREFIX_2): Update link-related specs.
(STARTFILE_SPEC): Likewise.
(ASM_MMACOSX_VERSION_MIN_SPEC): Fix line wrap.
(ASM_SPEC): Update driver-related specs.
(ASM_FINAL_SPEC): Likewise.
* config/darwin.opt: Remove now unused option aliases.
* config/i386/darwin.h (EXTRA_ASM_OPTS): Ensure space after opt.
(ASM_SPEC): Update driver-related specs.

3 years agoAllow early sets of SSE hard registers from standard_sse_constant_p.
Roger Sayle [Fri, 15 Oct 2021 18:09:25 +0000 (19:09 +0100)]
Allow early sets of SSE hard registers from standard_sse_constant_p.

My previous patch, which was intended to reduce the differences seen by
the combination of -march=cascadelake and -m32, has additionally found
some more instances where this combination behaves differently to regular
x86_64-pc-linux-gnu.  The middle-end always, and backends usually, use
emit_move_insn to emit/expand move instructions allowing the backend
control over placing things in constant pools, adding REG_EQUAL notes,
and so on.  Several of the AVX512 built-in expanders bypass this logic,
and instead generate moves directly using emit_insn(gen_rtx_SET (dst,src)).

For example, i386-expand.c line 12004 contains:
      for (i = 0; i < 8; i++)
        emit_insn (gen_rtx_SET (xmm_regs[i], const0_rtx));

I suspect that in this case, loading of standard_sse_constant_p, my
change to require loading of likely spilled hard registers via a
pseudo is perhaps overly strict, so this patch/fix reallows these
immediate constants values to be loaded directly prior to reload.

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

gcc/ChangeLog
* config/i386/i386.c (ix86_hardreg_mov_ok): For vector modes,
allow standard_sse_constant_p immediate constants.

3 years agolibstdc++: Make non-propagating-cache fully constexpr [PR101263]
Jonathan Wakely [Fri, 15 Oct 2021 13:49:21 +0000 (14:49 +0100)]
libstdc++: Make non-propagating-cache fully constexpr [PR101263]

libstdc++-v3/ChangeLog:

PR libstdc++/101263
* include/std/ranges (__cached): New wrapper struct.
(__non_propagating_cache): Use __cached for contained value.
(__non_propagating_cache::_M_emplace_deref): Add constexpr. Use
std::construct_at instead of placement new.
* testsuite/std/ranges/adaptors/join.cc: Check constexpr works.

3 years agolibstdc++: Add missing constexpr to std::variant (P2231R1)
Jonathan Wakely [Thu, 14 Oct 2021 12:27:03 +0000 (13:27 +0100)]
libstdc++: Add missing constexpr to std::variant (P2231R1)

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

We need to replace placement new with std::construct_at, but that isn't
defined for C++17. Use std::_Construct instead, which forwards to
std::construct_at in C++20 mode (since the related changes to make
std::optional fully constexpr, in r12-4389).

We also need to replace the untyped char buffer in _Uninitialized with a
union, which can be accessed in constexpr functions. But the union needs
to have a non-trivial destructor if its variant type is non-trivial,
which means that the _Variadic_union also needs a non-trivial
destructor. This adds a constrained partial specialization of
_Variadic_union for the C++20-only case where a non-trivial destructor
is needed.

We can't use concepts to constrain the specialization (or the primary
template's destructor) in C++17, so retain the untyped char buffer
solution for C++17 mode.

libstdc++-v3/ChangeLog:

* include/std/variant (__cpp_lib_variant): Update value for
C++20.
(__variant_cast, __variant_construct): Add constexpr for C++20.
(__variant_construct_single, __construct_by_index) Likewise. Use
std::_Construct instead of placement new.
(_Uninitialized<T, false>) [__cplusplus >= 202002]: Replace
buffer with a union and define a destructor.
(_Variadic_union) [__cplusplus >= 202002]: Add a specialization
for non-trivial destruction.
(_Variant_storage::__index_of): New helper variable template.
(_Variant_storage::~_Variant_storage()): Add constexpr.
(_Variant_storage::_M_reset()): Likewise.
(_Copy_ctor_base, _Move_ctor_base): Likewise.
(_Copy_assign_base, _Move_assign_base): Likewise.
(variant, swap): Likewise.
* include/std/version (__cpp_lib_variant): Update value for
C++20.
* testsuite/20_util/optional/version.cc: Check for exact value
in C++17.
* testsuite/20_util/variant/87619.cc: Increase timeout for
C++20 mode.
* testsuite/20_util/variant/constexpr.cc: New test.
* testsuite/20_util/variant/version.cc: New test.

3 years agolibstdc++: Remove try/catch overhead in std::variant::emplace
Jonathan Wakely [Fri, 15 Oct 2021 09:58:56 +0000 (10:58 +0100)]
libstdc++: Remove try/catch overhead in std::variant::emplace

The __variant_construct_by_index helper function sets the new index
before constructing the new object. This means that if the construction
throws then the exception needs to be caught, so the index can be reset
to variant_npos, and then the exception rethrown. This means callers are
responsible for restoring the variant's invariants and they need the
overhead of a catch handler and a rethrow.

If we don't set the index until after construction completes then the
invariant is never broken, and callers can ignore the exception and let
it propagate. The callers all call _M_reset() first, which sets index to
variant_npos as required while the variant is valueless.

We need to be slightly careful here, because changing the order of
operations in __variant_construct_by_index and removing the try-block
from variant::emplace<I> changes an implicit ABI contract between those
two functions. If the linker were to create an executable containing an
instantiation of the old __variant_construct_by_index and an
instantiation of the new variant::emplace<I> code then we would have a
combination that breaks the invariant and doesn't have the exception
handling to restore it. To avoid this problem, we can rename the
__variant_construct_by_index function so that the new emplace<I> code
calls a new symbol, and is unaffected by the behaviour of the old
symbol.

libstdc++-v3/ChangeLog:

* include/std/variant (__detail::__variant::__get_storage):
Remove unused function.
(__variant_construct_by_index): Set index after construction is
complete. Rename to ...
(__detail::__variant::__construct_by_index): ... this.
(variant): Use new name for __variant_construct_by_index friend
declaration. Remove __get_storage friend declaration.
(variant::emplace): Use new name and remove try-blocks.

3 years agolibstdc++: Remove unused functions in std::variant implementation
Jonathan Wakely [Fri, 15 Oct 2021 10:52:08 +0000 (11:52 +0100)]
libstdc++: Remove unused functions in std::variant implementation

These functions aren't used, and accessing the storage as a void* isn't
compatible with C++20 constexpr requirements anyway, so we're unlikely
to ever start using them in future.

libstdc++-v3/ChangeLog:

* include/std/variant (_Variant_storage::_M_storage()): Remove.
(__detail::__variant::__get_storage): Remove.
(variant): Remove friend declaration of __get_storage.

3 years agoDarwin, D: Fix D bootstrap, include tm-dwarf2.h.
Iain Sandoe [Fri, 15 Oct 2021 16:23:08 +0000 (17:23 +0100)]
Darwin, D: Fix D bootstrap, include tm-dwarf2.h.

After r12-4432-g7bfe7d634f60b0a9 Darwin fails to bootstrap with D
enabled since there is no definition of either DWARF2_DEBUG_INFO or
PREFERRED_DEBUGGING_TYPE.

Fixed here by adding the tm-dwarf2.h file to tm_d_file for Darwin.

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

* config.gcc: Add tm-dwarf2.h to tm_d-file.

3 years agoRanger : Do not process abnormal ssa-names.
Andrew MacLeod [Thu, 7 Oct 2021 14:12:29 +0000 (10:12 -0400)]
Ranger : Do not process abnormal ssa-names.

* gimple-range-fold.h (gimple_range_ssa_p): Don't process names
that occur in abnormal phis.
* gimple-range.cc (gimple_ranger::range_on_edge): Return false for
abnormal and EH edges.
* gimple-ssa-evrp.c (rvrp_folder::value_of_expr): Ditto.
(rvrp_folder::value_on_edge): Ditto.
(rvrp_folder::value_of_stmt): Ditto.
(hybrid_folder::value_of_expr): Ditto for ranger queries.
(hybrid_folder::value_on_edge): Ditto.
(hybrid_folder::value_of_stmt): Ditto.
* value-query.cc (gimple_range_global): Always return a range if
the type is supported.

3 years agoopenmp: Improve testsuite/libgomp.c/affinity-1.c testcase
Jakub Jelinek [Fri, 15 Oct 2021 15:19:54 +0000 (17:19 +0200)]
openmp: Improve testsuite/libgomp.c/affinity-1.c testcase

I've noticed that while I have added hopefully sufficient test coverage
for the case where one uses simple number or !number as p-interval,
I haven't added any coverage for number:len:stride or number:len.

This patch adds that.

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

* testsuite/libgomp.c/affinity-1.c (struct places): Change name field
type from char [50] to const char *.
(places_array): Add a testcase for simplified syntax place followed
by length or length and stride.

3 years agoConsistently use "rG" constraint for copy instruction in move patterns
John David Anglin [Fri, 15 Oct 2021 14:50:30 +0000 (14:50 +0000)]
Consistently use "rG" constraint for copy instruction in move patterns

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

gcc/ChangeLog:

* config/pa/pa.md: Consistently use "rG" constraint for copy
instruction in move patterns.

3 years agoopenmp: Handle OpenMP 5.1 simplified OMP_PLACES syntax
Jakub Jelinek [Fri, 15 Oct 2021 14:35:57 +0000 (16:35 +0200)]
openmp: Handle OpenMP 5.1 simplified OMP_PLACES syntax

In addition to adding ll_caches and numa_domain abstract names
to OMP_PLACES syntax, OpenMP 5.1 also added one syntax simplification:
https://github.com/OpenMP/spec/issues/2080
https://github.com/OpenMP/spec/pull/2081
in particular that in the grammar place non-terminal is now
not only { res-list } but also res (i.e. a non-negative integer),
which stands as a shortcut for { res }
So, one can specify OMP_PLACES=0,4,8,12 with the meaning
OMP_PLACES={0},{4},{8},{12} or OMP_PLACES=0:4 instead of OMP_PLACES={0}:4
or OMP_PLACES={0},{1},{2},{3} etc.

This patch implements that.

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

* env.c (parse_one_place): Handle non-negative-number the same
as { non-negative-number }.  Reject even !number:1 and
!number:1:stride or !place:1 or !place:1:stride instead of just
length other than 1.
* libgomp.texi (OpenMP 5.1): Document OMP_PLACES syntax extensions
and OMP_NUM_TEAMS/OMP_TEAMS_THREAD_LIMIT and
omp_{set_num,get_max}_teams/omp_{s,g}et_teams_thread_limit features
as implemented.
* testsuite/libgomp.c/affinity-1.c: Add a test for the 5.1 place
simplified syntax.

3 years agoopenmp: Fix up strtoul and strtoull uses in libgomp
Jakub Jelinek [Fri, 15 Oct 2021 14:28:34 +0000 (16:28 +0200)]
openmp: Fix up strtoul and strtoull uses in libgomp

Yesterday when working on numa_domains, I've noticed because of a bug
in my patch a hang on a large NUMA machine.  I've fixed the bug, but
also discovered that the hang was a result of making wrong assumptions
about strtoul/strtoull.  All the uses were for portability setting
errno = 0 before the calls and treating non-zero errno after the call
as invalid input, but for the case where there are no valid digits at
all strtoul may set errno to EINVAL, but doesn't have to and with
glibc doesn't do that.  So, this patch goes through all the strtoul calls
and next to errno != 0 checks adds also endptr == startptr check.
Haven't done it in places where we immediately reject strtoul returning 0
the same as we reject errno != 0, because strtoul must return 0 in the
case where it sets endptr to the start pointer.  In some spots the code
was using errno = 0; x = strtoul (p, &p, 10); if (errno) { /*invalid*/ }
and those spots had to be changed to
errno = 0; x = strtoul (p, &end, 10); if (errno || end == p) { /*invalid*/ }
p = end;

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

* env.c (parse_schedule): For strtoul or strtoull calls which don't
clearly reject return value 0 as invalid handle the case where end
pointer is the same as first argument as invalid.
(parse_unsigned_long_1): Likewise.
(parse_one_place): Likewise.
(parse_places_var): Likewise.
(parse_stacksize): Likewise.
(parse_spincount): Likewise.
(parse_affinity): Likewise.
(parse_gomp_openacc_dim): Likewise.  Avoid strict aliasing violation.
Make code valid C89.
* config/linux/affinity.c (gomp_affinity_find_last_cache_level):
For strtoul calls which don't clearly reject return value 0 as
invalid handle the case where end pointer is the same as first
argument as invalid.
(gomp_affinity_init_level_1): Likewise.
(gomp_affinity_init_numa_domains): Likewise.
* config/rtems/proc.c (parse_thread_pools): Likewise.

3 years agoopenmp: Fix up handling of OMP_PLACES=threads(1)
Jakub Jelinek [Fri, 15 Oct 2021 14:25:25 +0000 (16:25 +0200)]
openmp: Fix up handling of OMP_PLACES=threads(1)

When writing the places-*.c tests, I've noticed that we mishandle threads
abstract name with specified num-places if num-places isn't a multiple of
number of hw threads in a core.  It then happily ignores the maximum count
and overwrites for the remaining hw threads in a core further places that
haven't been allocated.

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

* config/linux/affinity.c (gomp_affinity_init_level_1): For level 1
after creating count places clean up and return immediately.
* testsuite/libgomp.c/places-6.c: New test.
* testsuite/libgomp.c/places-7.c: New test.
* testsuite/libgomp.c/places-8.c: New test.
* testsuite/libgomp.c/places-9.c: New test.
* testsuite/libgomp.c/places-10.c: New test.

3 years agoamdgcn: fix up offload debug linking with LLVM 13
Andrew Stubbs [Wed, 13 Oct 2021 10:53:42 +0000 (11:53 +0100)]
amdgcn: fix up offload debug linking with LLVM 13

Between LLVM 9 and LLVM 13 the attribute works differently in several ways,
and this needs to be allowed for in GCC and mkoffload independently.

This patch fixes up mkoffload when debug info is enabled, which is made more
complicated because the configure tests checks whether the attribute option
is accepted silently, but does not check if the assembler actually sets the
ELF flags for that attribute, and mkoffload needs to mimick that behaviour
exactly. The patch therefore removes some of the conditionals.

gcc/ChangeLog:

* config/gcn/gcn-hsa.h (S_FIJI): Set unconditionally.
(S_900): Likewise.
(S_906): Likewise.
* config/gcn/gcn.c: Hard code SRAM ECC settings for old architectures.
* config/gcn/mkoffload.c (ELFABIVERSION_AMDGPU_HSA): Rename to ...
(ELFABIVERSION_AMDGPU_HSA_V3): ... this.
(ELFABIVERSION_AMDGPU_HSA_V4): New.
(SET_SRAM_ECC_UNSUPPORTED): New.
(copy_early_debug_info): Create elf flags to match the other objects.
(main): Just let the attribute flags pass through.

3 years agotree-optimization/102752: Fix determining precission of reduction_var
Stefan Schulze Frielinghaus [Fri, 15 Oct 2021 11:52:49 +0000 (13:52 +0200)]
tree-optimization/102752: Fix determining precission of reduction_var

While determining the precission of reduction_var an SSA_NAME instead of
its TREE_TYPE is used.  Streamlined with other TREE_TYPE (reduction_var)
uses.

gcc/ChangeLog:

* tree-loop-distribution.c (reduction_var_overflows_first):
Pass the type of reduction_var as first argument as it is also
done for the load type.
(loop_distribution::transform_reduction_loop): Add missing
TREE_TYPE while determining precission of reduction_var.

3 years agoMake signness explicit in tree-ssa/pr102736.c
Aldy Hernandez [Fri, 15 Oct 2021 10:53:32 +0000 (12:53 +0200)]
Make signness explicit in tree-ssa/pr102736.c

This test is failing on ppc64* due to different default signness for
chars.

Tested on x86-64 Linux and ppc64le Linux.

PR testsuite/pr102751

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/pr102736.c: Make sign explicit.

3 years agoopenmp: Add support for OMP_PLACES=numa_domains
Jakub Jelinek [Fri, 15 Oct 2021 10:16:50 +0000 (12:16 +0200)]
openmp: Add support for OMP_PLACES=numa_domains

This adds support for numa_domains abstract name in OMP_PLACES, also new
in OpenMP 5.1.

Way to test this is
OMP_PLACES=numa_domains OMP_DISPLAY_ENV=true LD_PRELOAD=.libs/libgomp.so.1 /bin/true
and see what it prints on OMP_PLACES line.
For non-NUMA machines it should print a single place that covers all CPUs,
for NUMA machine one place for each NUMA node with corresponding CPUs.

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

* env.c (parse_places_var): Handle numa_domains as level 5.
* config/linux/affinity.c (gomp_affinity_init_numa_domains): New
function.
(gomp_affinity_init_level): Use it instead of
gomp_affinity_init_level_1 for level == 5.
* testsuite/libgomp.c/places-5.c: New test.

3 years agoopenmp: Add support for OMP_PLACES=ll_caches
Jakub Jelinek [Fri, 15 Oct 2021 10:06:51 +0000 (12:06 +0200)]
openmp: Add support for OMP_PLACES=ll_caches

This patch implements support for ll_caches abstract name in OMP_PLACES,
which stands for places where logical cpus in each place share the last
level cache.

This seems to work fine for me on x86 and kernel sources show that it is
in common code, but on some machines on CompileFarm the files I'm using,
i.e.
/sys/devices/system/cpu/cpuN/cache/indexN/level
/sys/devices/system/cpu/cpuN/cache/indexN/shared_cpu_list
don't exist, is that because they have too old kernel and newer kernels
are fine or should I implement some fallback methods (which)?
E.g. on gcc112.fsffrance.org I see just shared_cpu_map and not shared_cpu_list
(with shared_cpu_map being harder to parse) and on another box I didn't even
see the cache subdirectories.

Way to test this is
OMP_PLACES=ll_caches OMP_DISPLAY_ENV=true LD_PRELOAD=.libs/libgomp.so.1 /bin/true
and see what it prints on OMP_PLACES line.

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

* env.c (parse_places_var): Handle ll_caches as level 4.
* config/linux/affinity.c (gomp_affinity_find_last_cache_level): New
function.
(gomp_affinity_init_level_1): Handle level 4 as logical cpus sharing
last level cache.
(gomp_affinity_init_level): Likewise.
* testsuite/libgomp.c/places-1.c: New test.
* testsuite/libgomp.c/places-2.c: New test.
* testsuite/libgomp.c/places-3.c: New test.
* testsuite/libgomp.c/places-4.c: New test.

3 years agoAlways default to DWARF2_DEBUG if not specified, warn about deprecated STABS
Richard Biener [Fri, 10 Sep 2021 09:25:21 +0000 (11:25 +0200)]
Always default to DWARF2_DEBUG if not specified, warn about deprecated STABS

This makes defaults.h choose DWARF2_DEBUG if PREFERRED_DEBUGGING_TYPE
is not specified by the target and errors out if DWARF DWARF is not supported.

It also makes us warn when STABS is enabled but not the preferred
debugging type and removes the corresponding diagnostic from the Ada frontend.
The warnings are pruned from the testsuite output via prune_gcc_output.

The following target configurations now explicitely default to STABS:
 pdp11-*-*   pdp11 is a.out, dwarf support is difficult
 hppa[12]*-*-hpux10*  does not support DWARF
 hppa[12]*-*-hpux11*  likewise
note that the hppa configs have been deprecated.

Targets with DWARF support will now see
> ./cc1 -quiet t.c -gstabs
t.c: warning: STABS debugging information is obsolete and not supported anymore

that is, -gstabs will still generate STABS but use will be diagnosed
on targets where DWARF is available.

I have built all targets from contrib/config-list.mk to make sure we
don't run into the #error and the following makes the STABS usage
explicit for pdp11 and hppa with SOM.

This completes the series of deprecating STABS for GCC 12.

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

gcc/
* defaults.h (PREFERRED_DEBUGGING_TYPE): Choose DWARF2_DEBUG
when not set.
* toplev.c (process_options): Warn when STABS debugging is
enabled but not the preferred format.
* config/pa/som.h (PREFERRED_DEBUGGING_TYPE): Define to
DBX_DEBUG.
* config/pdp11/pdp11.h (PREFERRED_DEBUGGING_TYPE): Likewise.

gcc/ada/
* gcc-interface/misc.c (gnat_post_options): Do not warn
about DBX_DEBUG use here.

gcc/testsuite/
* lib/prune.exp: Prune STABS obsoletion message.

3 years agoc/102763 - fix ICE with invalid input to GIMPLE FE
Richard Biener [Fri, 15 Oct 2021 06:52:08 +0000 (08:52 +0200)]
c/102763 - fix ICE with invalid input to GIMPLE FE

This fixes an ICE for the failure to verify we're dereferencing a
pointer before throwing that at build_simple_mem_ref.

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

PR c/102763
gcc/c/
* gimple-parser.c
(c_parser_gimple_postfix_expression_after_primary): Check
for a pointer do be dereferenced by ->.

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

3 years agoipa/102762 - fix ICE with invalid __builtin_va_arg_pack () use
Richard Biener [Fri, 15 Oct 2021 06:41:57 +0000 (08:41 +0200)]
ipa/102762 - fix ICE with invalid __builtin_va_arg_pack () use

We have to be careful to not break the argument space calculation.
If there's not enough arguments just do not append any.

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

PR ipa/102762
* tree-inline.c (copy_bb): Avoid underflowing nargs.

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

3 years agoAVX512FP16: Enhance vector shuffle builtins
Hongyu Wang [Mon, 30 Aug 2021 07:18:35 +0000 (15:18 +0800)]
AVX512FP16: Enhance vector shuffle builtins

Support HFmode vector shuffle by creating HImode subreg when
expanding permutation expr.

gcc/ChangeLog:

* config/i386/i386-expand.c (ix86_expand_vec_perm): Convert
HFmode input operand to HImode.
(ix86_vectorize_vec_perm_const): Likewise.
* config/i386/sse.md (*avx512bw_permvar_truncv16siv16hi_1_hf):
New define_insn.
(*avx512f_permvar_truncv8siv8hi_1_hf):
Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx512fp16-builtin_shuffle-1.c: New test.
* gcc.target/i386/avx512fp16-pr101846.c: Ditto.
* gcc.target/i386/avx512fp16-pr94680.c: Ditto.

3 years agomiddle-end/102682 - avoid invalid subreg on the LHS
Richard Biener [Mon, 11 Oct 2021 12:08:52 +0000 (14:08 +0200)]
middle-end/102682 - avoid invalid subreg on the LHS

The following avoids generating

(insn 6 5 7 2 (set (subreg:OI (concatn/v:TI [
                    (reg:DI 92 [ buffer ])
                    (reg:DI 93 [ buffer+8 ])
                ]) 0)
        (subreg:OI (reg/v:V8SI 85 [ __x ]) 0)) "t.ii":76:21 74 {*movoi_internal_avx}
     (nil))

via store_bit_field_1 when we try to store excess data into
a register allocated temporary.  The case was supposed to

      /* Use the subreg machinery either to narrow OP0 to the required
         words...

but the check ensured only an register-aligned but not a large
enough piece.  The following adds such missed check which ends up
decomposing the set to

(insn 6 5 7 (set (subreg:DI (reg/v:TI 84 [ buffer ]) 0)
        (subreg:DI (reg/v:V8SI 85 [ __x ]) 0)) "t.ii":76:21 -1
     (nil))

(insn 7 6 0 (set (subreg:DI (reg/v:TI 84 [ buffer ]) 8)
        (subreg:DI (reg/v:V8SI 85 [ __x ]) 8)) "t.ii":76:21 -1
     (nil))

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

PR middle-end/102682
* expmed.c (store_bit_field_1): Ensure a LHS subreg would
not create a paradoxical subreg.

3 years agoAVX512FP16: Fix ICE for 2 v4hf vector concat
Hongyu Wang [Fri, 15 Oct 2021 02:58:16 +0000 (10:58 +0800)]
AVX512FP16: Fix ICE for 2 v4hf vector concat

For V4HFmode, doing vector concat like

__builtin_shufflevector (a, b, {0, 1, 2, 3, 4, 5, 6, 7})

could trigger ICE since it is not handled in ix86_vector_init ().

Handle HFmode like HImode to avoid such ICE.

gcc/ChangeLog:

* config/i386/i386-expand.c (ix86_expand_vector_init):
For half_vector concat for HFmode, handle them like HImode.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx512fp16-v4hf-concat.c: New test.

3 years agoAVX512FP16: Fix testcase for complex intrinsic
Hongyu Wang [Fri, 15 Oct 2021 02:23:38 +0000 (10:23 +0800)]
AVX512FP16: Fix testcase for complex intrinsic

-march=cascadelake which contains -mavx512vl produces unmatched scan
for vf[c]maddcsh test, so add -mno-avx512vl to vf[c]maddcsh-1a.c.

Also add scan for vblendmps to vf[c]maddcph tests to check correctness.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx512fp16-vfcmaddcph-1a.c: Add scan for
vblendmps.
* gcc.target/i386/avx512fp16-vfmaddcph-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-vfcmaddcph-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-vfmaddcph-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vfmaddcsh-1a.c: Add -mno-avx512vl.
* gcc.target/i386/avx512fp16-vfcmaddcsh-1a.c: Likewise.

3 years agoc++: instantiate less for constant folding
Jason Merrill [Thu, 14 Oct 2021 02:04:53 +0000 (22:04 -0400)]
c++: instantiate less for constant folding

I've been experimenting with a change to make all inline functions
implicitly constexpr; this revealed that we are instantiating too
aggressively for speculative constant evaluation, leading to ordering
difficulties with e.g. is_a_helper<cgraph_node*>::test.  This patch tries to
avoid such instantiation until we actually need the function definition to
determine whether a call is constant, by limiting the initial instantiation
of all used functions to manifestly-constant-evaluated expressions, and
checking whether the function arguments are constant before instantiating
the function.

This change resulted in a change in the diagnostics for a few library tests
due to instantiating the function with the static_assert later (during
constant evaluation) than we did before (during instantiation of the
intermediate function).

gcc/cp/ChangeLog:

* constexpr.c (cxx_bind_parameters_in_call): Replace
new_call parameter with fun.
(cxx_eval_call_expression): Call it before instantiation.
(cxx_eval_outermost_constant_expr): Only instantiate fns
when manifestly_const_eval.
* typeck2.c (check_narrowing): This context is manifestly
constant-evaluated.

libstdc++-v3/ChangeLog:

* testsuite/20_util/integer_comparisons/greater_equal_neg.cc:
* testsuite/20_util/integer_comparisons/greater_neg.cc:
* testsuite/20_util/integer_comparisons/less_equal_neg.cc:
Adjust expected message.
* testsuite/lib/prune.exp: Prune 'in constexpr expansion'.

gcc/testsuite/ChangeLog:

* g++.dg/ext/vla22.C: Don't expect a narrowing error.
* g++.dg/cpp0x/constexpr-inst1.C: New test.

3 years agoAdd target int128 to testcase.
Andrew MacLeod [Fri, 15 Oct 2021 00:32:53 +0000 (20:32 -0400)]
Add target int128 to testcase.

gcc/testsuite
* gcc.dg/pr102738.c: Add target int128.

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

3 years agoAdd ability to use full resolving path solver in the backward threader.
Aldy Hernandez [Thu, 14 Oct 2021 13:01:49 +0000 (15:01 +0200)]
Add ability to use full resolving path solver in the backward threader.

The path solver runs in two modes: a quick mode which assumes any unknown
SSA names are VARYING, and a fully resolving mode using the ranger.

The backward threader currently uses the quick mode, because the fully
resolving mode was not available initially.  Since we now have the ability
in the solver (used by the hybrid threader), I thought it'd be useful to
have the knob for when the time comes.

Note that enabling the fully resolving mode will require some experimenting,
as enabling it would likely render other jump threading passes irrelevant
(VRP threading comes to mind).

There should be no functional changes as the resolver is set to false.

Tested on x86-64 Linux.

gcc/ChangeLog:

* tree-ssa-threadbackward.c (class back_threader): Add m_resolve.
(back_threader::back_threader): Same.
(back_threader::resolve_phi): Try to solve without looking back if
possible.
(back_threader::find_paths_to_names): Same.
(try_thread_blocks): Pass resolve argument to back threader.
(pass_early_thread_jumps::execute): Same.

3 years agoCleanup --params for backward threader.
Aldy Hernandez [Thu, 14 Oct 2021 14:15:04 +0000 (16:15 +0200)]
Cleanup --params for backward threader.

The new backward threader makes some of the --param knobs used to
control it questionable at best or no longer applicable at worst.

The fsm-maximum-phi-arguments param is unused and can be removed.

The max-fsm-thread-length param is block based which is a bit redundant,
since we already restrict paths based on instruction estimates.

The max-fsm-thread-paths restricts the total number of threadable paths
in a function.  We probably don't need this.  Besides, the forward
threader has no such restriction.

Tested on x86-64 Linux.

gcc/ChangeLog:

* doc/invoke.texi: Remove max-fsm-thread-length,
max-fsm-thread-paths, and fsm-maximum-phi-arguments.
* params.opt: Same.
* tree-ssa-threadbackward.c (back_threader::back_threader): Remove
argument.
(back_threader_registry::back_threader_registry): Same.
(back_threader_profitability::profitable_path_p): Remove
param_max_fsm_thread-length.
(back_threader_registry::register_path): Remove
m_max_allowable_paths.

3 years agoMinor cleanups to backward threader.
Aldy Hernandez [Thu, 14 Oct 2021 14:14:34 +0000 (16:14 +0200)]
Minor cleanups to backward threader.

Tested on x86-64 Linux.

gcc/ChangeLog:

* tree-ssa-threadbackward.c (class back_threader): Make m_imports
an auto_bitmap.
(back_threader::~back_threader): Do not release m_path.

3 years agolibstdc++: Simplify variant access functions
Jonathan Wakely [Thu, 14 Oct 2021 19:37:38 +0000 (20:37 +0100)]
libstdc++: Simplify variant access functions

libstdc++-v3/ChangeLog:

* include/std/variant (__variant::__get(in_place_index_t<N>, U&&)):
Rename to __get_n and remove first argument. Replace pair of
overloads with a single function using 'if constexpr'.
(__variant::__get(Variant&&)): Adjust to use __get_n.

3 years agolibstdc++: Make filesystem::path(path&&) always noexcept
Jonathan Wakely [Thu, 14 Oct 2021 12:58:02 +0000 (13:58 +0100)]
libstdc++: Make filesystem::path(path&&) always noexcept

Since r12-4065 std::basic_string is always nothrow-move-constructible,
so filesystem::path is too.

That also means that path::_S_convert(T) is noexcept when returning its
argument, because T is either a basci_string or basic_string_view, and
will be moved into the return value.

libstdc++-v3/ChangeLog:

* include/bits/fs_path.h (path(path&&)): Make unconditionally
noexcept.
(path::_S_convert(T)): Add condtional noexcept.

3 years agoc-family: Support DFP printf/scanf formats for C2X
Joseph Myers [Thu, 14 Oct 2021 20:56:29 +0000 (20:56 +0000)]
c-family: Support DFP printf/scanf formats for C2X

When I enabled various decimal floating-point features for C2X /
stopped them being diagnosed with -pedantic for C2X, I missed the
format checking support.  The DFP printf and scanf formats are
included in C2X.  Thus, adjust the data for those formats so that they
are no longer diagnosed with -std=c2x -Wformat -pedantic.

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

gcc/c-family/
* c-format.c (printf_length_specs, scanf_length_specs)
(print_char_table, scan_char_table): Support DFP formats for C2X.
* c-format.h (TEX_D32, TEX_D64, TEX_D128): Remove.
(T2X_D32, T2X_D64, T2X_D128): New macros.

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

3 years agolibgcc: Add a backchain fallback to _Unwind_Backtrace() on PowerPC
Raphael Moreira Zinsly [Tue, 5 Oct 2021 18:32:52 +0000 (15:32 -0300)]
libgcc: Add a backchain fallback to _Unwind_Backtrace() on PowerPC

Without dwarf2 unwind tables available _Unwind_Backtrace() is not
able to return the full backtrace.
This patch adds a fallback function on powerpc to get the backtrace
by doing a backchain, this code was originally at glibc.

libgcc/ChangeLog:

* config/rs6000/linux-unwind.h (struct rt_sigframe): Move it to
outside of get_regs() in order to use it in another function, this
is done twice: for __powerpc64__ and for !__powerpc64__.
(struct trace_arg): New struct.
(struct layout): New struct.
(ppc_backchain_fallback): New function.
* unwind.inc (_Unwind_Backtrace): Look for _URC_NORMAL_STOP code
state and call MD_BACKCHAIN_FALLBACK.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/unwind-backchain.c: New test.

3 years agoFortran: generate error message for negative elements in SHAPE array
Harald Anlauf [Thu, 14 Oct 2021 18:19:50 +0000 (20:19 +0200)]
Fortran: generate error message for negative elements in SHAPE array

gcc/fortran/ChangeLog:

PR fortran/102717
* simplify.c (gfc_simplify_reshape): Replace assert by error
message for negative elements in SHAPE array.

gcc/testsuite/ChangeLog:

PR fortran/102717
* gfortran.dg/reshape_shape_2.f90: New test.

3 years agoFortran: fix order of checks for the SHAPE intrinsic
Harald Anlauf [Thu, 14 Oct 2021 18:18:14 +0000 (20:18 +0200)]
Fortran: fix order of checks for the SHAPE intrinsic

gcc/fortran/ChangeLog:

PR fortran/102716
* check.c (gfc_check_shape): Reorder checks so that invalid KIND
arguments can be detected.

gcc/testsuite/ChangeLog:

PR fortran/102716
* gfortran.dg/shape_10.f90: New test.

3 years agoSimplification for right shift.
Andrew MacLeod [Thu, 14 Oct 2021 14:43:58 +0000 (10:43 -0400)]
Simplification for right shift.

When the first operand of a signed right shift is zero or negative one, the
RHS doesn't matter and the shift can be converted to a copy.

PR tree-optimization/102738
gcc/
* vr-values.c (simplify_using_ranges::simplify): Handle RSHIFT_EXPR.

gcc/testsuite
* gcc.dg/pr102738.c: New.

3 years agoopenmp: Mark declare variant directive in documentation as supported in Fortran
Kwok Cheung Yeung [Thu, 14 Oct 2021 16:29:13 +0000 (09:29 -0700)]
openmp: Mark declare variant directive in documentation as supported in Fortran

2021-10-14  Kwok Cheung Yeung  <kcy@codesourcery.com>

libgomp/
* libgomp.texi (OpenMP 5.0): Update entry for declare variant
directive.

3 years agolibiberty: d-demangle: Add test case for function literals
Luís Ferreira [Thu, 14 Oct 2021 16:24:51 +0000 (12:24 -0400)]
libiberty: d-demangle: Add test case for function literals

libiberty/ChangeLog:

* testsuite/d-demangle-expected: Add test case for function literals.

3 years agolibiberty: d-demangle: add test cases for simple special mangles
Luís Ferreira [Thu, 14 Oct 2021 16:22:57 +0000 (12:22 -0400)]
libiberty: d-demangle: add test cases for simple special mangles

libiberty/ChangeLog:

* testsuite/d-demangle-expected: Add test cases for simple special
mangles.

3 years agoopenmp, fortran: Add support for OpenMP declare variant directive in Fortran
Kwok Cheung Yeung [Thu, 14 Oct 2021 14:57:12 +0000 (07:57 -0700)]
openmp, fortran: Add support for OpenMP declare variant directive in Fortran

2021-10-14  Kwok Cheung Yeung  <kcy@codesourcery.com>

gcc/c-family/

* c-omp.c (c_omp_check_context_selector): Rename to
omp_check_context_selector and move to omp-general.c.
(c_omp_mark_declare_variant): Rename to omp_mark_declare_variant and
move to omp-general.c.

gcc/c/

* c-parser.c (c_finish_omp_declare_variant): Change call from
c_omp_check_context_selector to omp_check_context_selector. Change
call from c_omp_mark_declare_variant to omp_mark_declare_variant.

gcc/cp/

* decl.c (omp_declare_variant_finalize_one): Change call from
c_omp_mark_declare_variant to omp_mark_declare_variant.
* parser.c (cp_finish_omp_declare_variant): Change call from
c_omp_check_context_selector to omp_check_context_selector.

gcc/fortran/

* gfortran.h (enum gfc_statement): Add ST_OMP_DECLARE_VARIANT.
(enum gfc_omp_trait_property_kind): New.
(struct gfc_omp_trait_property): New.
(gfc_get_omp_trait_property): New macro.
(struct gfc_omp_selector): New.
(gfc_get_omp_selector): New macro.
(struct gfc_omp_set_selector): New.
(gfc_get_omp_set_selector): New macro.
(struct gfc_omp_declare_variant): New.
(gfc_get_omp_declare_variant): New macro.
(struct gfc_namespace): Add omp_declare_variant field.
(gfc_free_omp_declare_variant_list): New prototype.
* match.h (gfc_match_omp_declare_variant): New prototype.
* openmp.c (gfc_free_omp_trait_property_list): New.
(gfc_free_omp_selector_list): New.
(gfc_free_omp_set_selector_list): New.
(gfc_free_omp_declare_variant_list): New.
(gfc_match_omp_clauses): Add extra optional argument.  Handle end of
clauses for context selectors.
(omp_construct_selectors, omp_device_selectors,
omp_implementation_selectors, omp_user_selectors): New.
(gfc_match_omp_context_selector): New.
(gfc_match_omp_context_selector_specification): New.
(gfc_match_omp_declare_variant): New.
* parse.c: Include tree-core.h and omp-general.h.
(decode_omp_directive): Handle 'declare variant'.
(case_omp_decl): Include ST_OMP_DECLARE_VARIANT.
(gfc_ascii_statement): Handle ST_OMP_DECLARE_VARIANT.
(gfc_parse_file): Initialize omp_requires_mask.
* symbol.c (gfc_free_namespace): Call
gfc_free_omp_declare_variant_list.
* trans-decl.c (gfc_get_extern_function_decl): Call
gfc_trans_omp_declare_variant.
(gfc_create_function_decl): Call gfc_trans_omp_declare_variant.
* trans-openmp.c (gfc_trans_omp_declare_variant): New.
* trans-stmt.h (gfc_trans_omp_declare_variant): New prototype.

gcc/

* omp-general.c (omp_check_context_selector):  Move from c-omp.c.
(omp_mark_declare_variant): Move from c-omp.c.
(omp_context_name_list_prop): Update for Fortran strings.
* omp-general.h (omp_check_context_selector): New prototype.
(omp_mark_declare_variant): New prototype.

gcc/testsuite/

* gfortran.dg/gomp/declare-variant-1.f90: New test.
* gfortran.dg/gomp/declare-variant-10.f90: New test.
* gfortran.dg/gomp/declare-variant-11.f90: New test.
* gfortran.dg/gomp/declare-variant-12.f90: New test.
* gfortran.dg/gomp/declare-variant-13.f90: New test.
* gfortran.dg/gomp/declare-variant-14.f90: New test.
* gfortran.dg/gomp/declare-variant-15.f90: New test.
* gfortran.dg/gomp/declare-variant-16.f90: New test.
* gfortran.dg/gomp/declare-variant-17.f90: New test.
* gfortran.dg/gomp/declare-variant-18.f90: New test.
* gfortran.dg/gomp/declare-variant-19.f90: New test.
* gfortran.dg/gomp/declare-variant-2.f90: New test.
* gfortran.dg/gomp/declare-variant-2a.f90: New test.
* gfortran.dg/gomp/declare-variant-3.f90: New test.
* gfortran.dg/gomp/declare-variant-4.f90: New test.
* gfortran.dg/gomp/declare-variant-5.f90: New test.
* gfortran.dg/gomp/declare-variant-6.f90: New test.
* gfortran.dg/gomp/declare-variant-7.f90: New test.
* gfortran.dg/gomp/declare-variant-8.f90: New test.
* gfortran.dg/gomp/declare-variant-9.f90: New test.

libgomp/

* testsuite/libgomp.fortran/declare-variant-1.f90: New test.

3 years agors6000: Fix memory leak in rs6000_density_test
Richard Sandiford [Thu, 14 Oct 2021 15:35:42 +0000 (16:35 +0100)]
rs6000: Fix memory leak in rs6000_density_test

rs6000_density_test has an early exit test between a call
to get_loop_body and the corresponding free.  This would
lead to a memory leak if the early exit is taken.

gcc/
* config/rs6000/rs6000.c (rs6000_density_test): Move early
exit test further up the function.

3 years agoarm: Remove add_stmt_cost hook
Richard Sandiford [Thu, 14 Oct 2021 15:35:41 +0000 (16:35 +0100)]
arm: Remove add_stmt_cost hook

The arm implementation of add_stmt_cost was added alongside
arm_builtin_vectorization_cost.  At that time it was necessary
to override the latter when overriding the former, since
default_add_stmt_cost didn't indirect through the
builtin_vectorization_cost target hook:

      int stmt_cost = default_builtin_vectorization_cost (kind, vectype,
                                                          misalign);

That was fixed by:

| 2014-06-06  Bingfeng Mei  <bmei@broadcom.com>
|
|      * targhooks.c (default_add_stmt_cost): Call target specific
|      hook instead of default one.

so the arm definition of add_stmt_cost is now equivalent
to the default.

gcc/
* config/arm/arm.c (arm_add_stmt_cost): Delete.
(TARGET_VECTORIZE_ADD_STMT_COST): Delete.

3 years agoAdd forgotten documentation of param ipa-cp-recursive-freq-factor
Martin Jambor [Thu, 14 Oct 2021 15:00:35 +0000 (17:00 +0200)]
Add forgotten documentation of param ipa-cp-recursive-freq-factor

Martin Liška has noticed that I forgot to document the recently added
parameter in the invoke.texi documentation.  This patch fixes it.

Tested by running make info and make pdf and examining the output.

gcc/ChangeLog:

2021-10-14  Martin Jambor  <mjambor@suse.cz>

* doc/invoke.texi (Optimize Options): Add entry for
ipa-cp-recursive-freq-factor.

3 years agoFix mips testsuite fallout from vectorizer changes
Jeff Law [Thu, 14 Oct 2021 14:49:05 +0000 (10:49 -0400)]
Fix mips testsuite fallout from vectorizer changes

gcc/testsuite
* gcc.target/mips/msa-insert-split.c: Turn off vectorizer.

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.