official-gcc.git
4 hours agoDaily bump.mastertrunk
GCC Administrator [Sun, 22 Sep 2024 00:17:59 +0000 (22 00:17 +0000)]
Daily bump.

11 hours agofortran: Add -finline-intrinsics flag for MINLOC/MAXLOC [PR90608]
Mikael Morin [Sat, 21 Sep 2024 16:33:11 +0000 (21 18:33 +0200)]
fortran: Add -finline-intrinsics flag for MINLOC/MAXLOC [PR90608]

Introduce the -finline-intrinsics flag to control from the command line
whether to generate either inline code or calls to the functions from the
library, for the MINLOC and MAXLOC intrinsics.

The flag allows to specify inlining either independently for each intrinsic
(either MINLOC or MAXLOC), or all together.  For each intrinsic, a default
value is set if none was set.  The default value depends on the optimization
setting: inlining is avoided if not optimizing or if optimizing for size;
otherwise inlining is preferred.

There is no direct support for this behaviour provided by the .opt options
framework.  It is obtained by defining three different variants of the flag
(finline-intrinsics, fno-inline-intrinsics, finline-intrinsics=) all using
the same underlying option variable.  Each enum value (corresponding to an
intrinsic function) uses two identical bits, and the variable is initialized
with alternated bits, so that we can tell whether the value was set or not
by checking whether the two bits have different values.

PR fortran/90608

gcc/ChangeLog:

* flag-types.h (enum gfc_inlineable_intrinsics): New type.

gcc/fortran/ChangeLog:

* invoke.texi(finline-intrinsics): Document new flag.
* lang.opt (finline-intrinsics, finline-intrinsics=,
fno-inline-intrinsics): New flags.
* options.cc (gfc_post_options): If the option variable controlling
the inlining of MAXLOC (respectively MINLOC) has not been set, set
it or clear it depending on the optimization option variables.
* trans-intrinsic.cc (gfc_inline_intrinsic_function_p): Return false
if inlining for the intrinsic is disabled according to the option
variable.

gcc/testsuite/ChangeLog:

* gfortran.dg/minmaxloc_18.f90: New test.
* gfortran.dg/minmaxloc_18a.f90: New test.
* gfortran.dg/minmaxloc_18b.f90: New test.
* gfortran.dg/minmaxloc_18c.f90: New test.
* gfortran.dg/minmaxloc_18d.f90: New test.

11 hours agofortran: Continue MINLOC/MAXLOC second loop where the first stopped [PR90608]
Mikael Morin [Sat, 21 Sep 2024 16:33:04 +0000 (21 18:33 +0200)]
fortran: Continue MINLOC/MAXLOC second loop where the first stopped [PR90608]

Continue the second set of loops where the first one stopped in the
generated inline MINLOC/MAXLOC code in the cases where the generated code
contains two sets of loops.  This fixes a regression that was introduced
when enabling the generation of inline MINLOC/MAXLOC code with ARRAY of rank
greater than 1, no DIM argument, and either non-scalar MASK or floating-
point ARRAY.

In the cases where two sets of loops are generated as inline MINLOC/MAXLOC
code, we previously generated code such as (for rank 2 ARRAY, so with two
levels of nesting):

for (idx11 in lower1..upper1)
  {
    for (idx12 in lower2..upper2)
      {
        ...
        if (...)
          {
            ...
            goto second_loop;
          }
      }
  }
second_loop:
for (idx21 in lower1..upper1)
  {
    for (idx22 in lower2..upper2)
      {
        ...
      }
  }

which means we process the first elements twice, once in the first set
of loops and once in the second one.  This change avoids this duplicate
processing by using a conditional as lower bound for the second set of
loops, generating code like:

second_loop_entry = false;
for (idx11 in lower1..upper1)
  {
    for (idx12 in lower2..upper2)
      {
        ...
        if (...)
          {
            ...
            second_loop_entry = true;
            goto second_loop;
          }
      }
  }
second_loop:
for (idx21 in (second_loop_entry ? idx11 : lower1)..upper1)
  {
    for (idx22 in (second_loop_entry ? idx12 : lower2)..upper2)
      {
        ...
        second_loop_entry = false;
      }
  }

It was expected that the compiler optimizations would be able to remove the
state variable second_loop_entry.  It is the case if ARRAY has rank 1 (so
without loop nesting), the variable is removed and the loop bounds become
unconditional, which restores previously generated code, fully fixing the
regression.  For larger rank, unfortunately, the state variable and
conditional loop bounds remain, but those cases were previously using
library calls, so it's not a regression.

PR fortran/90608

gcc/fortran/ChangeLog:

* trans-intrinsic.cc (gfc_conv_intrinsic_minmaxloc): Generate a set
of index variables.  Set them using the loop indexes before leaving
the first set of loops.  Generate a new loop entry predicate.
Initialize it.  Set it before leaving the first set of loops.  Clear
it in the body of the second set of loops.  For the second set of
loops, update each loop lower bound to use the corresponding index
variable if the predicate variable is set.

11 hours agofortran: Inline non-character MINLOC/MAXLOC with no DIM [PR90608]
Mikael Morin [Sat, 21 Sep 2024 16:32:59 +0000 (21 18:32 +0200)]
fortran: Inline non-character MINLOC/MAXLOC with no DIM [PR90608]

Enable generation of inline MINLOC/MAXLOC code in the case where DIM
is not present, and either ARRAY is of floating point type or MASK is an
array.  Those cases are the remaining bits to fully support inlining of
non-CHARACTER MINLOC/MAXLOC without DIM.  They are treated together because
they generate similar code, the NANs for REAL types being handled a bit like
a second level of masking.  These are the cases for which we generate two
sets of loops.

This change affects the code generating the second loop, that was previously
accessible only in the cases ARRAY has rank 1 only.  The single variable
initialization and update are changed to apply to multiple variables, one
per dimension.

The code generated is as follows (if ARRAY has rank 2):

for (idx11 in lower1..upper1)
  {
    for (idx12 in lower2..upper2)
      {
...
if (...)
  {
    ...
    goto second_loop;
  }
      }
  }
second_loop:
for (idx21 in lower1..upper1)
  {
    for (idx22 in lower2..upper2)
      {
...
      }
  }

This code leads to processing the first elements redundantly, both in the
first set of loops and in the second one.  The loop over idx22 could
start from idx12 the first time it is run, but as it has to start from
lower2 for the rest of the runs, this change uses the same bounds for both
set of loops for simplicity.  In the rank 1 case, this makes the generated
code worse compared to the inline code that was generated before.  A later
change will introduce conditionals to avoid the duplicate processing and
restore the generated code in that case.

PR fortran/90608

gcc/fortran/ChangeLog:

* trans-intrinsic.cc (gfc_conv_intrinsic_minmaxloc): Initialize
and update all the variables.  Put the label and goto in the
outermost scalarizer loop.  Don't start the second loop where the
first stopped.
(gfc_inline_intrinsic_function_p): Also return TRUE for array MASK
or for any REAL type.

gcc/testsuite/ChangeLog:

* gfortran.dg/maxloc_bounds_5.f90: Additionally accept error
messages reported by the scalarizer.
* gfortran.dg/maxloc_bounds_6.f90: Ditto.

12 hours agofortran: Inline integral MINLOC/MAXLOC with no DIM and scalar MASK [PR90608]
Mikael Morin [Sat, 21 Sep 2024 16:32:51 +0000 (21 18:32 +0200)]
fortran: Inline integral MINLOC/MAXLOC with no DIM and scalar MASK [PR90608]

Enable the generation of inline code for MINLOC/MAXLOC when argument ARRAY
is of integral type, DIM is not present, and MASK is present and is scalar
(only absent MASK or rank 1 ARRAY were inlined before).

Scalar masks are implemented with a wrapping condition around the code one
would generate if MASK wasn't present, so they are easy to support once
inline code without MASK is working.

PR fortran/90608

gcc/fortran/ChangeLog:

* trans-intrinsic.cc (gfc_conv_intrinsic_minmaxloc): Generate
variable initialization for each dimension in the else branch of
the toplevel condition.
(gfc_inline_intrinsic_function_p): Return TRUE for scalar MASK.

gcc/testsuite/ChangeLog:

* gfortran.dg/maxloc_bounds_7.f90: Additionally accept the error message
reported by the scalarizer.

12 hours agofortran: Inline integral MINLOC/MAXLOC with no DIM and no MASK [PR90608]
Mikael Morin [Sat, 21 Sep 2024 16:32:44 +0000 (21 18:32 +0200)]
fortran: Inline integral MINLOC/MAXLOC with no DIM and no MASK [PR90608]

Enable generation of inline code for the MINLOC and MAXLOC intrinsic,
if the ARRAY argument is of integral type and of any rank (only the rank 1
case was previously inlined), and neither DIM nor MASK arguments are
present.

This needs a few adjustments in gfc_conv_intrinsic_minmaxloc,
mainly to replace the single variables POS and OFFSET, with collections
of variables, one variable per dimension each.

The restriction to integral ARRAY and absent MASK limits the scope of
the change to the cases where we generate single loop inline code.  The
code generation for the second loop is only accessible with ARRAY of rank
1, so it can continue using a single variable.  A later change will extend
inlining to the double loop cases.

There is some bounds checking code that was previously handled by the
library, and that needed some changes in the scalarizer to avoid regressing.
The bounds check code generation was already supported by the scalarizer,
but it was only applying to array reference sections, checking both
for array bound violation and for shape conformability between all the
involved arrays.  With this change, for MINLOC or MAXLOC, enable the
conformability check between all the scalarized arrays, and disable the
array bound violation check.

PR fortran/90608

gcc/fortran/ChangeLog:

* trans-array.cc (gfc_conv_ss_startstride): Set the MINLOC/MAXLOC
result upper bound using the rank of the ARRAY argument.  Ajdust
the error message for intrinsic result arrays.  Only check array
bounds for array references.  Move bound check decision code...
(bounds_check_needed): ... here as a new predicate.  Allow bound
check for MINLOC/MAXLOC intrinsic results.
* trans-intrinsic.cc (gfc_conv_intrinsic_minmaxloc): Change the
result array upper bound to the rank of ARRAY.  Update the NONEMPTY
variable to depend on the non-empty extent of every dimension.  Use
one variable per dimension instead of a single variable for the
position and the offset.  Update their declaration, initialization,
and update to affect the variable of each dimension.  Use the first
variable only in areas only accessed with rank 1 ARRAY argument.
Set every element of the result using its corresponding variable.
(gfc_inline_intrinsic_function_p): Return true for integral ARRAY
and absent DIM and MASK.

gcc/testsuite/ChangeLog:

* gfortran.dg/maxloc_bounds_4.f90: Additionally accept the error
message emitted by the scalarizer.

12 hours agofortran: Outline array bound check generation code
Mikael Morin [Sat, 21 Sep 2024 16:32:37 +0000 (21 18:32 +0200)]
fortran: Outline array bound check generation code

gcc/fortran/ChangeLog:

* trans-array.cc (gfc_conv_ss_startstride): Move array bound check
generation code...
(add_check_section_in_array_bounds): ... here as a new function.

12 hours agofortran: Remove MINLOC/MAXLOC frontend optimization
Mikael Morin [Sat, 21 Sep 2024 16:32:31 +0000 (21 18:32 +0200)]
fortran: Remove MINLOC/MAXLOC frontend optimization

Remove the frontend pass rewriting calls of MINLOC/MAXLOC without DIM to
calls with one-valued DIM enclosed in an array constructor.  This
transformation was circumventing the limitation of inline MINLOC/MAXLOC code
generation to scalar cases only, allowing inline code to be generated if
ARRAY had rank 1 and DIM was absent.  As MINLOC/MAXLOC has gained support of
inline code generation in that case, the limitation is no longer effective,
and the transformation no longer necessary.

gcc/fortran/ChangeLog:

* frontend-passes.cc (optimize_minmaxloc): Remove.
(optimize_expr): Remove dispatch to optimize_minmaxloc.

12 hours agofortran: Inline MINLOC/MAXLOC with no DIM and ARRAY of rank 1 [PR90608]
Mikael Morin [Sat, 21 Sep 2024 16:32:25 +0000 (21 18:32 +0200)]
fortran: Inline MINLOC/MAXLOC with no DIM and ARRAY of rank 1 [PR90608]

Enable inline code generation for the MINLOC and MAXLOC intrinsic, if the
DIM argument is not present and ARRAY has rank 1.  This case is similar to
the case where the result is scalar (DIM present and rank 1 ARRAY), which
already supports inline expansion of the intrinsic.  Both cases return
the same value, with the difference that the result is an array of size 1 if
DIM is absent, whereas it's a scalar if DIM  is present.  So all there is
to do for the new case to work is hook the inline expansion with the
scalarizer.

PR fortran/90608

gcc/fortran/ChangeLog:

* trans-array.cc (gfc_conv_ss_startstride): Set the scalarization
rank based on the MINLOC/MAXLOC rank if needed.  Call the inline
code generation and setup the scalarizer array descriptor info
in the MINLOC and MAXLOC cases.
* trans-intrinsic.cc (gfc_conv_intrinsic_minmaxloc): Return the
result array element if the scalarizer is setup and we are inside
the loops.  Restrict library function call dispatch to the case
where inline expansion is not supported.  Declare an array result
if the expression isn't scalar.  Initialize the array result single
element and return the result variable if the expression isn't
scalar.
(walk_inline_intrinsic_minmaxloc): New function.
(walk_inline_intrinsic_function): Add MINLOC and MAXLOC cases,
dispatching to walk_inline_intrinsic_minmaxloc.
(gfc_add_intrinsic_ss_code): Add MINLOC and MAXLOC cases.
(gfc_inline_intrinsic_function_p): Return true if ARRAY has rank 1,
regardless of DIM.

12 hours agofortran: Disable frontend passes for inlinable MINLOC/MAXLOC [PR90608]
Mikael Morin [Sat, 21 Sep 2024 16:32:19 +0000 (21 18:32 +0200)]
fortran: Disable frontend passes for inlinable MINLOC/MAXLOC [PR90608]

Disable rewriting of MINLOC/MAXLOC expressions for which inline code
generation is supported.  Update the gfc_inline_intrinsic_function_p
predicate (already existing) for that, with the current state of
MINLOC/MAXLOC inlining support, that is only the cases of a scalar
result and non-CHARACTER argument for now.

This change has no effect currently, as the MINLOC/MAXLOC front-end passes
only change expressions of rank 1, but the inlining control predicate
gfc_inline_intrinsic_function_p returns false for those.  However, later
changes will extend MINLOC/MAXLOC inline expansion support to array
expressions and update the inlining control predicate, and this will become
effective.

PR fortran/90608

gcc/fortran/ChangeLog:

* frontend-passes.cc (optimize_minmaxloc): Skip if we can generate
inline code for the unmodified expression.
* trans-intrinsic.cc (gfc_inline_intrinsic_function_p): Add
MINLOC and MAXLOC cases.

12 hours agofortran: Add tests covering inline MINLOC/MAXLOC without DIM [PR90608]
Mikael Morin [Sat, 21 Sep 2024 16:32:10 +0000 (21 18:32 +0200)]
fortran: Add tests covering inline MINLOC/MAXLOC without DIM [PR90608]

Add the tests covering the various cases for which we are about to implement
inline expansion of MINLOC and MAXLOC.  Those are cases where the DIM
argument is not present.

PR fortran/90608

gcc/testsuite/ChangeLog:

* gfortran.dg/ieee/maxloc_nan_1.f90: New test.
* gfortran.dg/ieee/minloc_nan_1.f90: New test.
* gfortran.dg/maxloc_7.f90: New test.
* gfortran.dg/maxloc_with_mask_1.f90: New test.
* gfortran.dg/minloc_8.f90: New test.
* gfortran.dg/minloc_with_mask_1.f90: New test.

18 hours agomodula2: Tidyup remove unnecessary parameters
Gaius Mulley [Sat, 21 Sep 2024 09:36:57 +0000 (21 10:36 +0100)]
modula2: Tidyup remove unnecessary parameters

This patch removes ununsed parameters from gm2-compiler/M2Comp.mod.

gcc/m2/ChangeLog:

* gm2-compiler/M2Comp.mod (GenerateDependencies): Remove
unused parameter.
(WriteDep): Remove parameter dep.
(WritePhoneDep): Ditto.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
27 hours agolibstdc++: fix C header include guards
Jason Merrill [Mon, 9 Sep 2024 16:35:37 +0000 (9 12:35 -0400)]
libstdc++: fix C header include guards

Ever since the c_global and c_compatibility directories were added in
r122533, the include guards have been oddly late in the files, with no
comment about why that might be either in the commit message or the files
themselves.  I don't see any justification for this; it seems like a
scripting error in creating these files based on the ones in include/c.

libstdc++-v3/ChangeLog:

* include/c_compatibility/ctype.h
* include/c_compatibility/errno.h
* include/c_compatibility/float.h
* include/c_compatibility/iso646.h
* include/c_compatibility/limits.h
* include/c_compatibility/locale.h
* include/c_compatibility/setjmp.h
* include/c_compatibility/signal.h
* include/c_compatibility/stdarg.h
* include/c_compatibility/stdbool.h
* include/c_compatibility/stddef.h
* include/c_compatibility/stdio.h
* include/c_compatibility/string.h
* include/c_compatibility/tgmath.h
* include/c_compatibility/time.h
* include/c_compatibility/uchar.h
* include/c_compatibility/wchar.h
* include/c_compatibility/wctype.h
* include/c_global/ccomplex
* include/c_global/cctype
* include/c_global/cerrno
* include/c_global/cfloat
* include/c_global/climits
* include/c_global/clocale
* include/c_global/cmath
* include/c_global/csetjmp
* include/c_global/csignal
* include/c_global/cstdalign
* include/c_global/cstdarg
* include/c_global/cstdbool
* include/c_global/cstdio
* include/c_global/cstdlib
* include/c_global/cstring
* include/c_global/ctgmath
* include/c_global/ctime
* include/c_global/cwchar
* include/c_global/cwctype: Move header guard before #includes.

28 hours agoDaily bump.
GCC Administrator [Sat, 21 Sep 2024 00:16:55 +0000 (21 00:16 +0000)]
Daily bump.

29 hours agodiagnostics: add HTML output format as a plugin [PR116792]
David Malcolm [Fri, 20 Sep 2024 22:51:56 +0000 (20 18:51 -0400)]
diagnostics: add HTML output format as a plugin [PR116792]

This patch adds an experimental diagnostics output format that
writes HTML.  It isn't ready yet for end-users, but seems worth
keeping in the tree as I refactor the diagnostics subsystem, to
ensure that this code still builds, and to verify that it's possible to
implement new diagnostic output formats via GCC plugins. Hence
this patch merely adds it to the testsuite as an example of a GCC
plugin, rather than exposing it as a feature for end-users.

gcc/testsuite/ChangeLog:
PR other/116792
* gcc.dg/plugin/diagnostic-test-xhtml-1.c: New test.
* gcc.dg/plugin/diagnostic_plugin_xhtml_format.c: New test plugin.
* gcc.dg/plugin/plugin.exp (plugin_test_list): Add the above.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
29 hours agoanalyzer: simplify dumps using tree_dump_pretty_printer [PR116613]
David Malcolm [Fri, 20 Sep 2024 22:51:55 +0000 (20 18:51 -0400)]
analyzer: simplify dumps using tree_dump_pretty_printer [PR116613]

There are numerous "dump" member functions in the analyzer with
copied-and-pasted logic.  Simplify them by moving the shared code
to a new class tree_dump_pretty_printer.

As well as reducing code duplication, this eliminates numerous
uses of pp_show_color (global_dc->m_printer), which should
ultimately help with supporting multiple diagnostic sinks.

No functional change intended.

gcc/analyzer/ChangeLog:
PR other/116613
* access-diagram.cc (access_range::dump): Simplify using
tree_dump_pretty_printer.
* call-details.cc (call_details::dump): Likewise.
* call-summary.cc (call_summary::dump): Likewise.
(call_summary_replay::dump): Likewise.
* checker-event.cc (checker_event::debug): Likewise.
* constraint-manager.cc (range::dump): Likewise.
(bounded_range::dump): Likewise.
(bounded_ranges::dump): Likewise.
(constraint_manager::dump): Likewise.
* engine.cc (exploded_node::dump): Likewise.
(exploded_path::dump): Likewise.
* program-point.cc (program_point::dump): Likewise.
* program-state.cc (extrinsic_state::dump_to_file): Likewise.
(sm_state_map::dump): Likewise.
(program_state::dump_to_file): Likewise.
* ranges.cc (symbolic_byte_offset::dump): Likewise.
(symbolic_byte_range::dump): Likewise.
* record-layout.cc (record_layout::dump): Likewise.
* region-model-reachability.cc (reachable_regions::dump):
Likewise.
* region-model.cc (region_to_value_map::dump): Likewise.
(region_model::dump): Likewise.
(model_merger::dump): Likewise.
* region.cc (region_offset::dump): Likewise.
(region::dump): Likewise.
* sm-malloc.cc (deallocator_set::dump): Likewise.
* store.cc (uncertainty_t::dump): Likewise.
(binding_key::dump): Likewise.
(bit_range::dump): Likewise.
(byte_range::dump): Likewise.
(binding_map::dump): Likewise.
(binding_cluster::dump): Likewise.
(store::dump): Likewise.
* supergraph.cc (superedge::dump): Likewise.
* svalue.cc (svalue::dump): Likewise.

gcc/ChangeLog:
PR other/116613
* text-art/dump.h (dump_to_file): Simplify using
tree_dump_pretty_printer.
* tree-diagnostic.h (class tree_dump_pretty_printer): New.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
29 hours agodiagnostics: isolate SARIF output's pretty_printer [PR116613]
David Malcolm [Fri, 20 Sep 2024 22:51:55 +0000 (20 18:51 -0400)]
diagnostics: isolate SARIF output's pretty_printer [PR116613]

Add an m_printer to sarif_builder and use throughout, rather than
using the context's printer.  For now this is the same printer, but
eventually this should help with transitioning to multiple output sinks.

No functional change intended.

gcc/ChangeLog:
PR other/116613
* diagnostic-format-sarif.cc (sarif_builder::m_printer): New
field.
(sarif_invocation::add_notification_for_ice): Drop context param.
(sarif_invocation::prepare_to_flush): Convert param from context
to builder.
(sarif_result::on_nested_diagnostic): Drop context param.  Use
builder's printer.
(sarif_result::on_diagram): Drop context param.
(sarif_ice_notification::sarif_ice_notification): Drop context
param.  Use builder's printer.
(sarif_builder::sarif_builder): Initialize m_printer.
(sarif_builder::on_report_diagnostic): Drop context param.  Use
builder's printer.
(sarif_builder::emit_diagram): Drop context param.
(sarif_builder::flush_to_object): Use this rather than context
for call to prepare_to_flush.
(sarif_builder::make_result_object): Drop context param.  Use
builder's printer.
(sarif_builder::make_reporting_descriptor_object_for_warning):
Drop context param.
(sarif_builder::make_message_object_for_diagram): Likewise.
Use builder's printer.
(sarif_output_format::on_report_diagnostic): Drop context param
from call to sarif_builder::on_report_diagnostic.
(sarif_output_format::on_diagram): Drop context param from call to
sarif_builder::emit_diagram.
* diagnostic.h (diagnostic_conetxt::get_client_data_hooks): Make const.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
29 hours agodiagnostics: convert text hooks to use diagnostic_text_output_format [PR116613]
David Malcolm [Fri, 20 Sep 2024 22:51:55 +0000 (20 18:51 -0400)]
diagnostics: convert text hooks to use diagnostic_text_output_format [PR116613]

The diagnostic_starter and diagnostic_finalizer callbacks and most of
their support subroutines are only used by the "text" output format.

Emphasize this and reduce the binding with diagnostic_context
by renaming the callbacks to add "_text" in their names, and converting
the first param from diagnostic_context * to
diagnostic_text_output_output &.  Update the various subroutines used
by diagnostic starter/finalizer callbacks to also take a
diagnostic_text_output_output & rather than a diagnostic_context *.
Move m_includes and m_last_seen from the context to the text output.

Use the text_output's get_printer () rather than the context's
m_printer, which should ease the transition to multiple output sinks.

No functional change intended.

gcc/c-family/ChangeLog:
PR other/116613
* c-opts.cc: Include "diagnostic-format-text.h".
(c_diagnostic_finalizer): Rename to...
(c_diagnostic_text_finalizer): ...this.  Convert first param
from diagnostic_context * to diagnostic_text_output_format & and
update accordingly.
(c_common_diagnostics_set_defaults): Update for renamings.

gcc/ChangeLog:
PR other/116613
* coretypes.h (class diagnostic_text_output_format): Add forward
decl.
* diagnostic-format-json.cc
(json_output_format::after_diagnostic): New.
* diagnostic-format-sarif.cc
(sarif_output_format::after_diagnostic): New.
* diagnostic-format-text.cc: Use pragmas to ignore -Wformat-diag.
(diagnostic_text_output_format::~diagnostic_text_output_format):
Use get_printer.  Clean up m_includes_seen here, rather than
in ~diagnostic_context.
(diagnostic_text_output_format::on_report_diagnostic):  Use
get_printer.  Update for callback renamings and pass *this
to them, rather than &m_context.
(diagnostic_text_output_format::after_diagnostic): New.
(diagnostic_text_output_format::includes_seen_p): Move here
from diagnostic_context/diagnostic.cc.
(diagnostic_text_output_format::get_location_text): New.
(maybe_line_and_column): Move here from diagnostic.cc and make
non-static.
(diagnostic_text_output_format::report_current_module): Move
here from diagnostic_context/diagnostic.cc.
(default_diagnostic_text_starter): Move here from diagnostic.cc,
renaming from default_diagnostic_starter.
(default_diagnostic_text_finalizer): Likewise, renaming from
default_diagnostic_finalizer.
* diagnostic-format-text.h
(diagnostic_text_output_format::diagnostic_text_output_format):
Initialize m_last_module and m_includes_seen.
(diagnostic_text_output_format::after_diagnostic): New decl.
(diagnostic_text_output_format::build_prefix): New decl.
(diagnostic_text_output_format::report_current_module): New decl.
(diagnostic_text_output_format::append_note): New decl.
(diagnostic_text_output_format::file_name_as_prefix): New decl.
(diagnostic_text_output_format::print_path): New decl.
(diagnostic_text_output_format::show_column_p): New decl.
(diagnostic_text_output_format::get_location_text): New decl.
(diagnostic_text_output_format::includes_seen_p): New decl.
(diagnostic_text_output_format::show_any_path): New decl.
(diagnostic_text_output_format::m_last_module): New field.
(diagnostic_text_output_format::m_includes_seen): New field.
* diagnostic-format.h
(diagnostic_output_format::after_diagnostic): New vfunc.
(diagnostic_output_format::get_context): New.
(diagnostic_output_format::get_diagram_theme): New.
* diagnostic-macro-unwinding.cc: Include
"diagnostic-format-text.h".
(maybe_unwind_expanded_macro_loc): Convert first param from
diagnostic_context * to diagnostic_text_output_format & and update
accordingly.
(virt_loc_aware_diagnostic_finalizer): Likewise.
* diagnostic-macro-unwinding.h
(virt_loc_aware_diagnostic_finalizer): Likewise.
(maybe_unwind_expanded_macro_loc): Likewise.
* diagnostic-path.cc: Include "diagnostic-format-text.h".
(path_label::path_label): Drop "ctxt" param and add "colorize"
and "allow_emojis" params.  Update initializations.
(path_label::get_text): Use m_colorize rather than querying
m_ctxt.m_printer.  Use m_allow_emojis rather than querying
m_ctxt's diagram theme.
(path_label::m_ctxt): Drop field.
(path_label::m_colorize): Drop field.
(path_label::m_allow_emojis): Drop field.
(event_range::event_range): Drop param "ctxt".  Add params
"colorize_labels" and "allow_emojis".
(event_range::print): Convert first param from
diagnostic_context & to diagnostic_text_output_format & and update
accordingly.
(path_summary::path_summary): Likewise.
(path_summary::print_swimlane_for_event_range): Likewise.
(print_path_summary_as_text): Likewise for 3rd param.
(diagnostic_context::print_path): Convert to...
(diagnostic_text_output_format::print_path): ...this.
(selftest::test_empty_path): Update to use a
diagnostic_text_output_format.
(selftest::test_intraprocedural_path): Likewise.
(selftest::test_interprocedural_path_1): Likewise.
(selftest::test_interprocedural_path_2): Likewise.
(selftest::test_recursion): Likewise.
(selftest::test_control_flow_1): Likewise.
(selftest::test_control_flow_2): Likewise.
(selftest::test_control_flow_3): Likewise.
(selftest::assert_cfg_edge_path_streq): Likewise.
(selftest::test_control_flow_5): Likewise.
(selftest::test_control_flow_6): Likewise.
* diagnostic.cc (file_name_as_prefix): Convert to...
(diagnostic_text_output_format::file_name_as_prefix): ...this.
(diagnostic_context::initialize): Update for renamings.
Move m_last_module and m_includes_seen into text output.
(diagnostic_context::finish): Likewise.
(diagnostic_context::get_location_text): Add "colorize" param.
(diagnostic_build_prefix): Convert to...
(diagnostic_text_output_format::build_prefix): ...this.
(diagnostic_context::includes_seen_p): Move from here to
diagnostic_text_output_format/diagnostic-format-text.cc.
(diagnostic_context::report_current_module): Likewise.
(diagnostic_context::show_any_path): Convert to...
(diagnostic_text_output_format::show_any_path): ...this.
(default_diagnostic_starter): Rename and move to
diagnostic-format-text.cc.
(default_diagnostic_start_span_fn): Pass colorize bool
to get_location_text.
(default_diagnostic_finalizer): Rename and move to
diagnostic-format-text.cc.
(diagnostic_context::report_diagnostic): Replace call to
show_any_path with call to new output format "after_diagnostic"
vfunc, moving show_any_path call to the text output format.
(diagnostic_append_note): Convert to...
(diagnostic_text_output_format::append_note): ...this.
(selftest::assert_location_text): Pass in false for colorization.
* diagnostic.h (diagnostic_starter_fn): Rename to...
(diagnostic_text_starter_fn): ...this.  Convert first param from
diagnostic_context * to diagnostic_text_output_format &.
(diagnostic_finalizer_fn, diagnostic_text_finalizer_fn): Likewise.
(diagnostic_context): Update friends for renamings.
(diagnostic_context::report_current_module): Move to text output
format.
(diagnostic_context::get_location_text): Add "colorize" bool.
(diagnostic_context::includes_seen_p): Move to text output format.
(diagnostic_context::show_any_path): Likewise.
(diagnostic_context::print_path): Likewise.
(diagnostic_context::m_text_callbacks): Update for renamings.
(diagnostic_context::m_last_module): Move to text output format.
(diagnostic_context::m_includes_seen): Likewise.
(diagnostic_starter): Rename to...
(diagnostic_text_starter): ...this and update return type.
(diagnostic_finalizer): Rename to...
(diagnostic_text_finalizer): ...this and update return type.
(diagnostic_report_current_module): Drop decl in favor of a member
function of diagnostic_text_output_format.
(diagnostic_append_note): Likewise.
(default_diagnostic_starter): Rename to...
(default_diagnostic_text_starter): ...this, updating type.
(default_diagnostic_finalizer): Rename to...
(default_diagnostic_text_finalizer): ...this, updating type.
(file_name_as_prefix): Drop decl.
* langhooks-def.h (lhd_print_error_function): Convert first param
from diagnostic_context * to diagnostic_text_output_format &.
* langhooks.cc: Include "diagnostic-format-text.h".
(lhd_print_error_function): Likewise.  Update accordingly
* langhooks.h (lang_hooks::print_error_function): Convert first
param from diagnostic_context * to
diagnostic_text_output_format &.
* tree-diagnostic.cc: Include "diagnostic-format-text.h".
(diagnostic_report_current_function): Convert first param from
diagnostic_context * to diagnostic_text_output_format & and update
accordingly.
(default_tree_diagnostic_starter): Rename to...
(default_tree_diagnostic_text_starter): ...this.  Convert first
param from diagnostic_context * to diagnostic_text_output_format &
and update accordingly.
(tree_diagnostics_defaults): Update for renamings.

gcc/cp/ChangeLog:
PR other/116613
* cp-tree.h (cxx_print_error_function): Convert first param
from diagnostic_context * to diagnostic_text_output_format &.
* error.cc: Include "diagnostic-format-text.h".
(cxx_initialize_diagnostics): Update for renamings.
(cxx_print_error_function): Convert first param from
diagnostic_context * to diagnostic_text_output_format & and update
accordingly
(cp_diagnostic_starter): Rename to...
(cp_diagnostic_text_starter): ...this.  Convert first
param from diagnostic_context * to diagnostic_text_output_format &
and update accordingly.
(cp_print_error_function): Likewise.
(print_instantiation_full_context): Likewise.
(print_instantiation_partial_context_line): Likewise.
(print_instantiation_partial_context): Likewise.
(maybe_print_instantiation_context): Likewise.
(maybe_print_constexpr_context): Likewise.
(print_location): Likewise.
(print_constrained_decl_info): Likewise.
(print_concept_check_info): Likewise.
(print_constraint_context_head): Likewise.
(print_requires_expression_info): Likewise.
(maybe_print_single_constraint_context): Likewise.

gcc/fortran/ChangeLog:
PR other/116613
* error.cc: Include "diagnostic-format-text.h".
(gfc_diagnostic_starter): Rename to...
(gfc_diagnostic_text_starter): ...this.  Convert first
param from diagnostic_context * to diagnostic_text_output_format &
and update accordingly.
(gfc_diagnostic_finalizer, gfc_diagnostic_text_finalizer):
Likewise.
(gfc_diagnostics_init): Update for renamings.
(gfc_diagnostics_finish): Likewise.

gcc/jit/ChangeLog:
PR other/116613
* dummy-frontend.cc: Include "diagnostic-format-text.h".
(jit_begin_diagnostic): Convert first param from
diagnostic_context * to diagnostic_text_output_format &
(jit_end_diagnostic): Likewise.  Update accordingly.
(jit_langhook_init): Update for renamings.

gcc/rust/ChangeLog:
PR other/116613
* resolve/rust-ast-resolve-expr.cc
(funny_ice_finalizer): : Convert first param from
diagnostic_context * to diagnostic_text_output_format &.
(ResolveExpr::visit): Update for renaming.

gcc/testsuite/ChangeLog:
PR other/116613
* g++.dg/plugin/show_template_tree_color_plugin.c
(noop_starter_fn): Rename to...
(noop_text_starter_fn): ...this.  Update first param from dc to
text_output.
(plugin_init): Update for renamings.
* gcc.dg/plugin/diagnostic_group_plugin.c
(test_diagnostic_starter): Rename to...
(test_diagnostic_text_starter): ...this.  Update first param from
dc to text_output.
(plugin_init): Update for renaming.
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.c: Include
"diagnostic-format-text.h".
(custom_diagnostic_finalizer): Rename to...
(custom_diagnostic_text_finalizer): ...this.  Update first param
from dc to text_output.
(test_show_locus): Update for renamings.
* gcc.dg/plugin/location_overflow_plugin.c: Include
"diagnostic-format-text.h".
(original_finalizer): Rename to...
(original_text_finalizer): ...this and update type.
(verify_unpacked_ranges): Update first param from dc to
text_output.  Update for this and for renamings.
(verify_no_columns): Likewise.
(plugin_init): Update for renamings.

libcc1/ChangeLog:
PR other/116613
* context.cc: Include "diagnostic-format-text.h".
(plugin_print_error_function): Update first param from
diagnostic_context * to diagnostic_text_output_format &.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
29 hours agoanalyzer: remove redundant 'pp' [PR116613]
David Malcolm [Fri, 20 Sep 2024 22:51:55 +0000 (20 18:51 -0400)]
analyzer: remove redundant 'pp' [PR116613]

diagnostic_manager::emit_saved_diagnostic makes a useless clone
of global_dc->m_printer; remove it.

No functional change intended.

gcc/analyzer/ChangeLog:
PR other/116613
* diagnostic-manager.cc (diagnostic_manager::emit_saved_diagnostic):
Remove remove redundant 'pp'.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
29 hours agolibstdc++: Avoid forming T* in unique_ptr(auto_ptr<U>&&) constraints [PR116529]
Jonathan Wakely [Thu, 29 Aug 2024 12:47:15 +0000 (29 13:47 +0100)]
libstdc++: Avoid forming T* in unique_ptr(auto_ptr<U>&&) constraints [PR116529]

PR 116529 shows that std::unique_ptr<X&, D> is currently unusable
because the constructor taking std::auto_ptr (which is a non-standard
extension since C++17) tries to form the invalid type X&* during
overload resolution. We can use the `pointer` type in the constructor
constraints, instead of trying to form an invalid type. The
std::auto_ptr constructor can never actually match for the case where
element_type is a reference, so we just need it to produce a
substitution failure instead of being ill-formed.

LWG 4144 might make std::unique_ptr<X&, D> ill-formed, which would
invalidate this new test. We would have to remove this test in that
case. Using `pointer` in the constructor from std::auto_ptr would not be
needed to support the std::unique_ptr<X&, D> case, but would not cause
any harm either.

libstdc++-v3/ChangeLog:

PR libstdc++/116529
* include/bits/unique_ptr.h (unique_ptr(auto_ptr<U>&&)):
Use pointer instead of T*.
* testsuite/20_util/unique_ptr/creation/116529.cc: New test.

29 hours agolibstdc++: Document missing features for old std:string ABI [PR116777]
Jonathan Wakely [Fri, 20 Sep 2024 16:35:48 +0000 (20 17:35 +0100)]
libstdc++: Document missing features for old std:string ABI [PR116777]

There are several features that are not supported when using the old
std::string ABI. It's possible that PR 81967 will get fixed, but the
missing C++20 features almost certainly won't be. Document this in the
manual.

libstdc++-v3/ChangeLog:

PR libstdc++/116777
* doc/xml/manual/using.xml: Document features that are not
supported for the gcc4-compatible ABI.
* doc/html/manual/using_dual_abi.html: Regenerate.

31 hours agoc: fix crash when checking for compatibility of structures [PR116726]
Martin Uecker [Tue, 17 Sep 2024 09:37:29 +0000 (17 11:37 +0200)]
c: fix crash when checking for compatibility of structures [PR116726]

When checking for compatibility of structure or union types in
tagged_types_tu_compatible_p, restore the old value of the pointer to
the top of the temporary cache after recursively calling comptypes_internal
when looping over the members of a structure of union.  While the next
iteration of the loop overwrites the pointer, I missed the fact that it can
be accessed again when types of function arguments are compared as part
of recursive type checking and the function is entered again.

PR c/116726

gcc/c/ChangeLog:

* c-typeck.cc (tagged_types_tu_compatible_p): Restore value
of the cache after recursing into comptypes_internal.

gcc/testsuite/ChangeLog:

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

32 hours agoc++: CWG 2789 and reversed operator candidates
Patrick Palka [Fri, 20 Sep 2024 19:41:42 +0000 (20 15:41 -0400)]
c++: CWG 2789 and reversed operator candidates

As a follow-up to r15-3741-gee3efe06c9c49c, which was specifically
concerned with usings, it seems the CWG 2789 refinement should also
compare contexts of a reversed vs non-reversed (member) candidate
during operator overload resolution.

DR 2789

gcc/cp/ChangeLog:

* call.cc (cand_parms_match): Check for matching class contexts
even in the reversed case.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-memfun4.C: Adjust expected result
involving reversed candidate.

Reviewed-by: Jason Merrill <jason@redhat.com>
34 hours agomodula2: Remove unused parameter warnings seen in build
Gaius Mulley [Fri, 20 Sep 2024 18:05:16 +0000 (20 19:05 +0100)]
modula2: Remove unused parameter warnings seen in build

This patch removes unused parameters in gm2-compiler/M2Check.mod.
It also removes a --fixme-- and completes the missing code
which type checks unbounded arrays.  The patch also fixes a
build error seen when building m2/stage2/cc1gm2.

gcc/m2/ChangeLog:

* gm2-compiler/M2Check.mod (checkUnboundedArray): New
procedure function.
(checkUnboundedUnbounded): Ditto.
(checkUnbounded): Rewrite to check the unbounded data
type.
(checkPair): Add comment.
(doCheckPair): Add comment.
Remove tinfo parameter from the call to checkTypeKindViolation.
(checkTypeKindViolation): Remove ununsed parameter tinfo.
* gm2-libs-ch/UnixArgs.cc (GM2RTS.h): Remove include.
* gm2-libs-ch/m2rts.h (M2RTS_INIT): New define.
(M2RTS_DEP): Ditto.
(M2RTS_RegisterModule): New prototype.
(GM2RTS.h): Add include to the MC_M2 block.

gcc/testsuite/ChangeLog:

* gm2/iso/fail/testarrayunbounded2.mod: New test.
* gm2/iso/fail/testarrayunbounded3.mod: New test.
* gm2/iso/fail/testarrayunbounded4.mod: New test.
* gm2/iso/fail/testarrayunbounded5.mod: New test.
* gm2/iso/fail/testarrayunbounded6.mod: New test.
* gm2/iso/pass/testarrayunbounded.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
34 hours agoDaily bump.
GCC Administrator [Fri, 20 Sep 2024 17:36:00 +0000 (20 17:36 +0000)]
Daily bump.

35 hours agoc++: CWG 2789 and usings [PR116492]
Patrick Palka [Fri, 20 Sep 2024 16:33:13 +0000 (20 12:33 -0400)]
c++: CWG 2789 and usings [PR116492]

After CWG 2789, the "more constrained" tiebreaker for non-template
functions should exclude member functions that are defined in
different classes.  This patch implements this missing refinement.

In turn we can get rid of four-parameter version of object_parms_correspond
and call the main overload directly since now correspondence is only
only checked for members from the same class.

PR c++/116492
DR 2789

gcc/cp/ChangeLog:

* call.cc (object_parms_correspond): Remove.
(cand_parms_match): Return false for member functions that come
from different classes.  Adjust call to object_parms_correspond.
(joust): Update comment for the non-template "more constrained"
case.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-memfun4.C: Also compile in C++20 mode.
Expect ambiguity when candidates come from different classes.
* g++.dg/cpp2a/concepts-inherit-ctor12.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
36 hours agoc++: CWG 2273 and non-constructors
Patrick Palka [Fri, 20 Sep 2024 16:31:40 +0000 (20 12:31 -0400)]
c++: CWG 2273 and non-constructors

Our implementation of the CWG 2273 inheritedness tiebreaker seems to be
incorrectly considering all member functions introduced via using, not
just constructors.  This patch restricts the tiebreaker accordingly.

DR 2273

gcc/cp/ChangeLog:

* call.cc (joust): Restrict inheritedness tiebreaker to
constructors.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/using1.C: Expect ambiguity for non-constructor call.
* g++.dg/overload/using5.C: Likewise.

Reviewed-by: Jason Merrill <jason@redhat.com>
36 hours agoAArch64: Define VECTOR_STORE_FLAG_VALUE.
Tamar Christina [Fri, 20 Sep 2024 16:03:54 +0000 (20 17:03 +0100)]
AArch64: Define VECTOR_STORE_FLAG_VALUE.

This defines VECTOR_STORE_FLAG_VALUE to CONST1_RTX for AArch64
so we simplify vector comparisons in AArch64.

With this enabled

res:
        movi    v0.4s, 0
        cmeq    v0.4s, v0.4s, v0.4s
        ret

is simplified to:

res:
        mvni    v0.4s, 0
        ret

gcc/ChangeLog:

* config/aarch64/aarch64.h (VECTOR_STORE_FLAG_VALUE): New.

gcc/testsuite/ChangeLog:

* gcc.dg/rtl/aarch64/vector-eq.c: New test.

36 hours agotestsuite: Update commandline for PR116628.c to use neoverse-v2 [PR116628]
Tamar Christina [Fri, 20 Sep 2024 16:01:39 +0000 (20 17:01 +0100)]
testsuite: Update commandline for PR116628.c to use neoverse-v2 [PR116628]

The testcase for this tests needs Neoverse V2 to be used
since due to costing the other cost models don't pick this
particular SVE mode.

committed as obvious.

Thanks,
Tamar

gcc/testsuite/ChangeLog:

PR tree-optimization/116628
* gcc.dg/vect/pr116628.c: Update cmdline.

37 hours agoDarwin: Allow for as versions that need '-' for std in.
Iain Sandoe [Wed, 18 Sep 2024 16:46:32 +0000 (18 17:46 +0100)]
Darwin: Allow for as versions that need '-' for std in.

Recent versions of Xcode as require a dash to read from standard
input.  We can use this on all supported OS versions so make it
unconditional.  Patch from Mark Mentovai.

gcc/ChangeLog:

* config/darwin.h (AS_NEEDS_DASH_FOR_PIPED_INPUT): New.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
38 hours agoc++, coroutines: Rework the ramp codegen.
Iain Sandoe [Tue, 27 Aug 2024 15:38:10 +0000 (27 16:38 +0100)]
c++, coroutines: Rework the ramp codegen.

Now that we have separated the codegen of the ramp, actor and
destroy functions, we no longer need to manage the scopes for
variables manually.

This introduces a helper function that allows us to build a
local var with a DECL_VALUE_EXPR that relates to the coroutine
state frame entry.

This fixes a latent issue where we would generate guard vars
when exceptions were disabled.

gcc/cp/ChangeLog:

* coroutines.cc (coro_build_artificial_var_with_dve): New.
(coro_build_and_push_artificial_var): New.
(coro_build_and_push_artificial_var_with_dve): New.
(analyze_fn_parms): Ensure that frame entries cannot clash
with local variables.
(build_coroutine_frame_delete_expr): Amend comment.
(cp_coroutine_transform::build_ramp_function): Rework to
avoid manual management of variables and scopes.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
39 hours agoFall back to elementwise access for too spaced SLP single element interleaving
Richard Biener [Fri, 20 Sep 2024 10:17:22 +0000 (20 12:17 +0200)]
Fall back to elementwise access for too spaced SLP single element interleaving

gcc.dg/vect/vect-pr111779.c is a case where non-SLP manages to vectorize
using VMAT_ELEMENTWISE but SLP currently refuses because doing a regular
access with permutes would cause excess vector loads with at most one
element used.  The following makes us fall back to elementwise accesses
for that, too.

* tree-vect-stmts.cc (get_group_load_store_type): Fall back
to VMAT_ELEMENTWISE when single element interleaving of
a too large group.
(vectorizable_load): Do not try to verify load permutations
when using VMAT_ELEMENTWISE for single-lane SLP and fix code
generation for this case.

* gfortran.dg/vect/vect-8.f90: Allow one more vectorized loop.

39 hours agoHandle patterns as SLP roots of only live stmts
Richard Biener [Fri, 20 Sep 2024 11:35:49 +0000 (20 13:35 +0200)]
Handle patterns as SLP roots of only live stmts

gcc.dg/vect/vect-live-2.c shows it's important to handle live but
otherwise unused pattern stmts.

* tree-vect-slp.cc (vect_analyze_slp): Lookup patterns when
discovering from only-live roots.

40 hours agos390: Remove -m{,no-}lra option
Stefan Schulze Frielinghaus [Fri, 20 Sep 2024 11:53:08 +0000 (20 13:53 +0200)]
s390: Remove -m{,no-}lra option

Since the old reload pass is about to be removed and we defaulted to LRA
for over a decade, remove option -m{,no-}lra.

PR target/113953

gcc/ChangeLog:

* config/s390/s390.cc (s390_lra_p): Remove.
(TARGET_LRA_P): Remove.
* config/s390/s390.opt (mlra): Remove.
* config/s390/s390.opt.urls (mlra): Remove.

gcc/testsuite/ChangeLog:

* gcc.target/s390/TI-constants-nolra.c: Removed.
* gcc.target/s390/pr79895.c: Removed.

40 hours agotestsuite/116397 - avoid looking for "VEC_PERM_EXPR"
Richard Biener [Fri, 20 Sep 2024 11:47:34 +0000 (20 13:47 +0200)]
testsuite/116397 - avoid looking for "VEC_PERM_EXPR"

With SLP this token appears a lot, when looking for what gets code
generated instead look for " = VEC_PERM_EXPR"

PR testsuite/116397
* gcc.dg/vect/slp-reduc-3.c: Look for " = VEC_PERM_EXPR"
instead of "VEC_PERM_EXPR".

41 hours agoFix small thinko in IPA mod/ref pass
Eric Botcazou [Fri, 20 Sep 2024 10:32:13 +0000 (20 12:32 +0200)]
Fix small thinko in IPA mod/ref pass

When a memory copy operation is analyzed by analyze_ssa_name, if both the
load and store are made through the same SSA name, the store is overlooked.

gcc/
* ipa-modref.cc (modref_eaf_analysis::analyze_ssa_name): Always
process both the load and the store of a memory copy operation.

gcc/testsuite/
* gcc.dg/ipa/modref-4.c: New test.

45 hours agoOpenMP: Add get_device_from_uid/omp_get_uid_from_device routines
Tobias Burnus [Fri, 20 Sep 2024 07:25:33 +0000 (20 09:25 +0200)]
OpenMP: Add get_device_from_uid/omp_get_uid_from_device routines

Those TR13/OpenMP 6.0 routines permit a reproducible offloading to
a specific device by mapping an OpenMP device number to a
unique ID (UID). The GPU device UIDs should be universally unique,
the one for the host is not.

gcc/ChangeLog:

* omp-general.cc (omp_runtime_api_procname): Add
get_device_from_uid and omp_get_uid_from_device routines.

include/ChangeLog:

* cuda/cuda.h (cuDeviceGetUuid): Declare.
(cuDeviceGetUuid_v2): Add prototype.

libgomp/ChangeLog:

* config/gcn/target.c (omp_get_uid_from_device,
omp_get_device_from_uid): Add stub implementation.
* config/nvptx/target.c (omp_get_uid_from_device,
omp_get_device_from_uid): Likewise.
* fortran.c (omp_get_uid_from_device_,
omp_get_uid_from_device_8_): New functions.
* libgomp-plugin.h (GOMP_OFFLOAD_get_uid): Add prototype.
* libgomp.h (struct gomp_device_descr): Add 'uid' and 'get_uid_func'.
* libgomp.map (GOMP_6.0): New, includind the new UID routines.
* libgomp.texi (OpenMP Technical Report 13): Mark UID routines as 'Y'.
(Device Information Routines): Document new UID routines.
(Offload-Target Specifics): Document UID format.
* omp.h.in (omp_get_device_from_uid, omp_get_uid_from_device):
New prototype.
* omp_lib.f90.in (omp_get_device_from_uid, omp_get_uid_from_device):
New interface.
* omp_lib.h.in: Likewise.
* plugin/cuda-lib.def: Add cuDeviceGetUuid and cuDeviceGetUuid_v2 via
CUDA_ONE_CALL_MAYBE_NULL.
* plugin/plugin-gcn.c (GOMP_OFFLOAD_get_uid): New.
* plugin/plugin-nvptx.c (GOMP_OFFLOAD_get_uid): New.
* target.c (str_omp_initial_device): New static var.
(STR_OMP_DEV_PREFIX): Define.
(gomp_get_uid_for_device, omp_get_uid_from_device,
omp_get_device_from_uid): New.
(gomp_load_plugin_for_device): DLSYM_OPT the function 'get_uid'.
(gomp_target_init): Set the device's 'uid' field to NULL.
* testsuite/libgomp.c/device_uid.c: New test.
* testsuite/libgomp.fortran/device_uid.f90: New test.

45 hours agotestsuite: fix target-specific 'do-' typos
Sam James [Fri, 2 Aug 2024 05:32:55 +0000 (2 06:32 +0100)]
testsuite: fix target-specific 'do-' typos

Fix some target-specific 'do-' (rather than 'dg-') typos.

gcc/testsuite/ChangeLog:

* gcc.target/m68k/pr108640.c: Fix dg directive typo.
* gcc.target/m68k/pr110934.c: Ditto.
* gcc.target/m68k/pr82420.c: Ditto.
* gcc.target/powerpc/pr99708.c: Ditto.

45 hours agoi386: Fix up _mm_min_ss etc. handling of zeros and NaNs [PR116738]
Jakub Jelinek [Fri, 20 Sep 2024 07:14:29 +0000 (20 09:14 +0200)]
i386: Fix up _mm_min_ss etc. handling of zeros and NaNs [PR116738]

min/max patterns for intrinsics which on x86 result in the second
input operand if the two operands are both zeros or one or both of them
are a NaN shouldn't use SMIN/SMAX RTL, because that is similarly to
MIN_EXPR/MAX_EXPR undefined what will be the result in those cases.

The following patch adds an expander which uses either a new pattern with
UNSPEC_IEEE_M{AX,IN} or use the S{MIN,MAX} representation of the same.

2024-09-20  Uros Bizjak  <ubizjak@gmail.com>
    Jakub Jelinek  <jakub@redhat.com>

PR target/116738
* config/i386/subst.md (mask_scalar_operand_arg34,
mask_scalar_expand_op3, round_saeonly_scalar_mask_arg3): New
subst attributes.
* config/i386/sse.md
(<sse>_vm<code><mode>3<mask_scalar_name><round_saeonly_scalar_name>):
Change from define_insn to define_expand, rename the old define_insn
to ...
(*<sse>_vm<code><mode>3<mask_scalar_name><round_saeonly_scalar_name>):
... this.
(<sse>_ieee_vm<ieee_maxmin><mode>3<mask_scalar_name><round_saeonly_scalar_name>):
New define_insn.

* gcc.target/i386/sse-pr116738.c: New test.

45 hours agotestsuite/116784 - match up SLP scan and vectorized scan
Richard Biener [Fri, 20 Sep 2024 06:53:53 +0000 (20 08:53 +0200)]
testsuite/116784 - match up SLP scan and vectorized scan

The test used vect_perm_short for the vectorized scanning but
vect_perm3_short for whether that's done with SLP.  We're now
generally expecting SLP to be used - even as fallback, so the
following adjusts both to match up, fixing the powerpc64 reported
testsuite issue.

PR testsuite/116784
* gcc.dg/vect/slp-perm-9.c: Use vect_perm_short also for
the SLP check.

47 hours agotestsuite: debug: fix errant whitespace
Sam James [Fri, 20 Sep 2024 04:37:24 +0000 (20 05:37 +0100)]
testsuite: debug: fix errant whitespace

I added some whitespace unintentionally in r15-3723-g284c03ec79ec20,
fix that.

gcc/testsuite/ChangeLog:

* gcc.dg/debug/btf/btf-datasec-1.c: Fix whitespace.

47 hours agotestsuite: fix 'do-do' typos
Sam James [Wed, 14 Aug 2024 23:38:36 +0000 (15 00:38 +0100)]
testsuite: fix 'do-do' typos

Fix 'do-do' typos (should be 'dg-do'). No change in logs.

gcc/testsuite/ChangeLog:

* g++.dg/other/operator2.C: Fix dg-do directive.
* gcc.dg/Warray-bounds-67.c: Ditto.
* gcc.dg/cpp/builtin-macro-1.c: Ditto.
* gcc.dg/tree-ssa/builtin-snprintf-3.c: Ditto.
* obj-c++.dg/empty-private-1.mm: Ditto.

47 hours agoRemove PHI_RESULT_PTR and change some PHI_RESULT to be gimple_phi_result [PR116643]
Andrew Pinski [Thu, 19 Sep 2024 23:32:50 +0000 (19 16:32 -0700)]
Remove PHI_RESULT_PTR and change some PHI_RESULT to be gimple_phi_result [PR116643]

There was only a few uses PHI_RESULT_PTR so lets remove it and use gimple_phi_result_ptr
or gimple_phi_result directly instead.
Since I was modifying ssa-iterators.h for the use of PHI_RESULT_PTR, change the use
of PHI_RESULT there to be gimple_phi_result instead.

This also removes one extra indirection that was done for PHI_RESULT so stage2 building
should be slightly faster.

Bootstrapped and tested on x86_64-linux-gnu.

PR middle-end/116643

gcc/ChangeLog:

* ssa-iterators.h (single_phi_def): Use gimple_phi_result
instead of PHI_RESULT.
(op_iter_init_phidef): Use gimple_phi_result/gimple_phi_result_ptr
instead of PHI_RESULT/PHI_RESULT_PTR.
* tree-ssa-operands.h (PHI_RESULT_PTR): Remove.
(PHI_RESULT): Use gimple_phi_result directly.
(SET_PHI_RESULT): Use gimple_phi_result_ptr directly.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2 days agotestsuite: debug: fix dejagnu directive syntax
Sam James [Fri, 20 Sep 2024 03:00:32 +0000 (20 04:00 +0100)]
testsuite: debug: fix dejagnu directive syntax

In this case, they were all harmless in reality (no diff in test logs).

gcc/testsuite/ChangeLog:

* gcc.dg/debug/btf/btf-array-1.c: Fix dg-do directive syntax.
* gcc.dg/debug/btf/btf-bitfields-1.c: Ditto.
* gcc.dg/debug/btf/btf-bitfields-2.c: Ditto.
* gcc.dg/debug/btf/btf-datasec-1.c: Ditto.
* gcc.dg/debug/btf/btf-union-1.c: Ditto.
* gcc.dg/debug/ctf/ctf-anonymous-struct-1.c: Ditto.
* gcc.dg/debug/ctf/ctf-anonymous-union-1.c: Ditto.
* gcc.dg/debug/ctf/ctf-array-1.c: Ditto.
* gcc.dg/debug/ctf/ctf-array-2.c: Ditto.
* gcc.dg/debug/ctf/ctf-array-4.c: Ditto.
* gcc.dg/debug/ctf/ctf-array-5.c: Ditto.
* gcc.dg/debug/ctf/ctf-array-6.c: Ditto.
* gcc.dg/debug/ctf/ctf-attr-mode-1.c: Ditto.
* gcc.dg/debug/ctf/ctf-attr-used-1.c: Ditto.
* gcc.dg/debug/ctf/ctf-bitfields-1.c: Ditto.
* gcc.dg/debug/ctf/ctf-bitfields-2.c: Ditto.
* gcc.dg/debug/ctf/ctf-bitfields-3.c: Ditto.
* gcc.dg/debug/ctf/ctf-bitfields-4.c: Ditto.
* gcc.dg/debug/ctf/ctf-complex-1.c: Ditto.
* gcc.dg/debug/ctf/ctf-cvr-quals-1.c: Ditto.
* gcc.dg/debug/ctf/ctf-cvr-quals-2.c: Ditto.
* gcc.dg/debug/ctf/ctf-cvr-quals-3.c: Ditto.
* gcc.dg/debug/ctf/ctf-cvr-quals-4.c: Ditto.
* gcc.dg/debug/ctf/ctf-enum-1.c: Ditto.
* gcc.dg/debug/ctf/ctf-enum-2.c: Ditto.
* gcc.dg/debug/ctf/ctf-file-scope-1.c: Ditto.
* gcc.dg/debug/ctf/ctf-float-1.c: Ditto.
* gcc.dg/debug/ctf/ctf-forward-1.c: Ditto.
* gcc.dg/debug/ctf/ctf-forward-2.c: Ditto.
* gcc.dg/debug/ctf/ctf-func-index-1.c: Ditto.
* gcc.dg/debug/ctf/ctf-function-pointers-1.c: Ditto.
* gcc.dg/debug/ctf/ctf-function-pointers-2.c: Ditto.
* gcc.dg/debug/ctf/ctf-function-pointers-3.c: Ditto.
* gcc.dg/debug/ctf/ctf-function-pointers-4.c: Ditto.
* gcc.dg/debug/ctf/ctf-functions-1.c: Ditto.
* gcc.dg/debug/ctf/ctf-int-1.c: Ditto.
* gcc.dg/debug/ctf/ctf-objt-index-1.c: Ditto.
* gcc.dg/debug/ctf/ctf-pointers-1.c: Ditto.
* gcc.dg/debug/ctf/ctf-pointers-2.c: Ditto.
* gcc.dg/debug/ctf/ctf-preamble-1.c: Ditto.
* gcc.dg/debug/ctf/ctf-str-table-1.c: Ditto.
* gcc.dg/debug/ctf/ctf-struct-1.c: Ditto.
* gcc.dg/debug/ctf/ctf-struct-2.c: Ditto.
* gcc.dg/debug/ctf/ctf-struct-array-1.c: Ditto.
* gcc.dg/debug/ctf/ctf-struct-array-2.c: Ditto.
* gcc.dg/debug/ctf/ctf-typedef-1.c: Ditto.
* gcc.dg/debug/ctf/ctf-typedef-2.c: Ditto.
* gcc.dg/debug/ctf/ctf-typedef-3.c: Ditto.
* gcc.dg/debug/ctf/ctf-typedef-struct-1.c: Ditto.
* gcc.dg/debug/ctf/ctf-typedef-struct-2.c: Ditto.
* gcc.dg/debug/ctf/ctf-typedef-struct-3.c: Ditto.
* gcc.dg/debug/ctf/ctf-union-1.c: Ditto.
* gcc.dg/debug/ctf/ctf-variables-1.c: Ditto.
* gcc.dg/debug/ctf/ctf-variables-2.c: Ditto.
* gcc.dg/debug/ctf/ctf-variables-3.c: Ditto.

2 days agoc-family: regenerate c.opt.urls
Marek Polacek [Thu, 19 Sep 2024 22:55:18 +0000 (19 18:55 -0400)]
c-family: regenerate c.opt.urls

I forgot again.

gcc/c-family/ChangeLog:

* c.opt.urls: Regenerate.

2 days agoc++: deleting explicitly-defaulted functions [PR116162]
Marek Polacek [Mon, 9 Sep 2024 18:23:33 +0000 (9 14:23 -0400)]
c++: deleting explicitly-defaulted functions [PR116162]

This PR points out the we're not implementing [dcl.fct.def.default]
properly.  Consider e.g.

  struct C {
     C(const C&&) = default;
  };

where we wrongly emit an error, but the move ctor should be just =deleted.
According to [dcl.fct.def.default], if the type of the special member
function differs from the type of the corresponding special member function
that would have been implicitly declared in a way other than as allowed
by 2.1-4, the function is defined as deleted.  There's an exception for
assignment operators in which case the program is ill-formed.

clang++ has a warning for when we delete an explicitly-defaulted function
so this patch adds it too.

When the code is ill-formed, we emit an error in all modes.  Otherwise,
we emit a pedwarn in C++17 and a warning in C++20.

PR c++/116162

gcc/c-family/ChangeLog:

* c.opt (Wdefaulted-function-deleted): New.

gcc/cp/ChangeLog:

* class.cc (check_bases_and_members): Don't set DECL_DELETED_FN here,
leave it to defaulted_late_check.
* cp-tree.h (maybe_delete_defaulted_fn): Declare.
(defaulted_late_check): Add a tristate parameter.
* method.cc (maybe_delete_defaulted_fn): New.
(defaulted_late_check): Add a tristate parameter.  Call
maybe_delete_defaulted_fn instead of giving an error.

gcc/ChangeLog:

* doc/invoke.texi: Document -Wdefaulted-function-deleted.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/defaulted15.C: Add dg-warning/dg-error.
* g++.dg/cpp0x/defaulted51.C: Likewise.
* g++.dg/cpp0x/defaulted52.C: Likewise.
* g++.dg/cpp0x/defaulted53.C: Likewise.
* g++.dg/cpp0x/defaulted54.C: Likewise.
* g++.dg/cpp0x/defaulted56.C: Likewise.
* g++.dg/cpp0x/defaulted57.C: Likewise.
* g++.dg/cpp0x/defaulted58.C: Likewise.
* g++.dg/cpp0x/defaulted59.C: Likewise.
* g++.dg/cpp0x/defaulted63.C: New test.
* g++.dg/cpp0x/defaulted64.C: New test.
* g++.dg/cpp0x/defaulted65.C: New test.
* g++.dg/cpp0x/defaulted66.C: New test.
* g++.dg/cpp0x/defaulted67.C: New test.
* g++.dg/cpp0x/defaulted68.C: New test.
* g++.dg/cpp0x/defaulted69.C: New test.
* g++.dg/cpp23/defaulted1.C: New test.

2 days agoUpdate cpplib zh_CN.po
Joseph Myers [Thu, 19 Sep 2024 21:09:21 +0000 (19 21:09 +0000)]
Update cpplib zh_CN.po

* zh_CN.po: Update.

2 days agoUpdate gcc zh_CN.po
Joseph Myers [Thu, 19 Sep 2024 21:05:07 +0000 (19 21:05 +0000)]
Update gcc zh_CN.po

* zh_CN.po: Update.

2 days agodwarf2asm: Use constexpr for eh_data_format_name initialization for C++14
Jakub Jelinek [Thu, 19 Sep 2024 15:53:27 +0000 (19 17:53 +0200)]
dwarf2asm: Use constexpr for eh_data_format_name initialization for C++14

Similarly to the previous patch, dwarf2asm.cc had
HAVE_DESIGNATED_INITIALIZERS support, and as fallback a huge switch.
The switch from what I can see is expanded as a jump table with 256
label pointers and code at those labels then loads addresses of
string literals.
The following patch instead uses a table with 256 const char * pointers,
NULL for ICE, non-NULL for returning something, similarly to the
HAVE_DESIGNATED_INITIALIZERS case.

2024-09-19  Jakub Jelinek  <jakub@redhat.com>

* dwarf2asm.cc (eh_data_format_name): Use constexpr initialization
of format_names table for C++14 instead of a large switch.

2 days agoRISC-V: Add testcases for form 2 of signed scalar SAT_ADD
Pan Li [Fri, 13 Sep 2024 02:05:49 +0000 (13 10:05 +0800)]
RISC-V: Add testcases for form 2 of signed scalar SAT_ADD

This patch would like to add testcases of the signed scalar SAT_ADD
for form 2.  Aka:

Form 2:
  #define DEF_SAT_S_ADD_FMT_2(T, UT, MIN, MAX) \
  T __attribute__((noinline))                  \
  sat_s_add_##T##_fmt_2 (T x, T y)             \
  {                                            \
    T sum = (UT)x + (UT)y;                     \
    if ((x ^ y) < 0 || (sum ^ x) >= 0)         \
      return sum;                              \
    return x < 0 ? MIN : MAX;                  \
  }

DEF_SAT_S_ADD_FMT_2 (int64_t, uint64_t, INT64_MIN, INT64_MAX)

The below test are passed for this patch.
* The rv64gcv fully regression test.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat_arith.h: Add test helper macros.
* gcc.target/riscv/sat_s_add-5.c: New test.
* gcc.target/riscv/sat_s_add-6.c: New test.
* gcc.target/riscv/sat_s_add-7.c: New test.
* gcc.target/riscv/sat_s_add-8.c: New test.
* gcc.target/riscv/sat_s_add-run-5.c: New test.
* gcc.target/riscv/sat_s_add-run-6.c: New test.
* gcc.target/riscv/sat_s_add-run-7.c: New test.
* gcc.target/riscv/sat_s_add-run-8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 days agotree-optimization/116768 - wrong dependence analysis
Richard Biener [Thu, 19 Sep 2024 12:58:18 +0000 (19 14:58 +0200)]
tree-optimization/116768 - wrong dependence analysis

The following reverts a bogus fix done for PR101009 and instead makes
sure we get into the same_access_functions () case when computing
the distance vector for g[1] and g[1] where the constants ended up
having different types.  The generic code doesn't seem to handle
loop invariant dependences.  The special case gets us both
( 0 ) and ( 1 ) as distance vectors while formerly we got ( 1 ),
which the PR101009 fix changed to ( 0 ) with bad effects on other
cases as shown in this PR.

PR tree-optimization/116768
* tree-data-ref.cc (build_classic_dist_vector_1): Revert
PR101009 change.
* tree-chrec.cc (eq_evolutions_p): Make sure (sizetype)1
and (int)1 compare equal.

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

2 days agoFall back to single-lane SLP before falling back to no SLP
Richard Biener [Wed, 18 Sep 2024 10:41:25 +0000 (18 12:41 +0200)]
Fall back to single-lane SLP before falling back to no SLP

The following changes the fallback to disable SLP when any of the
discovered SLP instances failed to pass vectorization checking into
a fallback that emulates what no SLP would do with SLP - force
single-lane discovery for all instances.

The patch does not remove the final fallback to disable SLP but it
reduces the fallout from failing vectorization when any non-SLP
stmt survives analysis.

* tree-vectorizer.h (vect_analyze_slp): Add force_single_lane
parameter.
* tree-vect-slp.cc (vect_analyze_slp_instance): Remove
defaulting of force_single_lane.
(vect_build_slp_instance): Likewise.  Pass down appropriate
force_single_lane.
(vect_analyze_slp): Add force_sigle_lane parameter and pass
it down appropriately.
(vect_slp_analyze_bb_1): Always do multi-lane SLP.
* tree-vect-loop.cc (vect_analyze_loop_2): Track two SLP
modes and adjust accordingly.
(vect_analyze_loop_1): Save the SLP mode when unrolling.

* gcc.dg/vect/vect-outer-slp-1.c: Adjust.

2 days agolibstdc++: add #pragma diagnostic
Jason Merrill [Fri, 22 Dec 2023 18:20:35 +0000 (22 13:20 -0500)]
libstdc++: add #pragma diagnostic

The use of #pragma GCC system_header in libstdc++ has led to bugs going
undetected for a while due to the silencing of compiler warnings that would
have revealed them promptly, and also interferes with warnings about
problematic template instantiations induced by user code.

But removing it, or even compiling with -Wsystem-header, is also problematic
due to warnings about deliberate uses of extensions.

So this patch adds #pragma GCC diagnostic as needed to suppress these
warnings.

The change to acinclude.m4 changes -Wabi to warn only in comparison to ABI
19, to avoid lots of warnings that we now mangle concept requirements, which
are in any case still experimental.  I checked for any other changes against
ABI v15, and found only the <format> lambda mangling, which we can ignore.

This also enables -Wsystem-headers while building the library, so we see any
warnings not silenced by these #pragmas.

libstdc++-v3/ChangeLog:

* include/bits/algorithmfwd.h:
* include/bits/allocator.h:
* include/bits/codecvt.h:
* include/bits/concept_check.h:
* include/bits/cpp_type_traits.h:
* include/bits/hashtable.h:
* include/bits/iterator_concepts.h:
* include/bits/ostream_insert.h:
* include/bits/ranges_base.h:
* include/bits/regex_automaton.h:
* include/bits/std_abs.h:
* include/bits/stl_algo.h:
* include/c_compatibility/fenv.h:
* include/c_compatibility/inttypes.h:
* include/c_compatibility/stdint.h:
* include/ext/concurrence.h:
* include/ext/type_traits.h:
* testsuite/ext/type_traits/add_unsigned_floating_neg.cc:
* testsuite/ext/type_traits/add_unsigned_integer_neg.cc:
* testsuite/ext/type_traits/remove_unsigned_floating_neg.cc:
* testsuite/ext/type_traits/remove_unsigned_integer_neg.cc:
* include/bits/basic_ios.tcc:
* include/bits/basic_string.tcc:
* include/bits/fstream.tcc:
* include/bits/istream.tcc:
* include/bits/locale_classes.tcc:
* include/bits/locale_facets.tcc:
* include/bits/ostream.tcc:
* include/bits/regex_compiler.tcc:
* include/bits/sstream.tcc:
* include/bits/streambuf.tcc:
* configure: Regenerate.
* include/bits/c++config:
* include/c/cassert:
* include/c/cctype:
* include/c/cerrno:
* include/c/cfloat:
* include/c/climits:
* include/c/clocale:
* include/c/cmath:
* include/c/csetjmp:
* include/c/csignal:
* include/c/cstdarg:
* include/c/cstddef:
* include/c/cstdio:
* include/c/cstdlib:
* include/c/cstring:
* include/c/ctime:
* include/c/cwchar:
* include/c/cwctype:
* include/c_global/climits:
* include/c_global/cmath:
* include/c_global/cstddef:
* include/c_global/cstdlib:
* include/decimal/decimal:
* include/ext/rope:
* include/std/any:
* include/std/charconv:
* include/std/complex:
* include/std/coroutine:
* include/std/format:
* include/std/iomanip:
* include/std/limits:
* include/std/numbers:
* include/tr1/functional:
* include/tr1/tuple:
* include/tr1/type_traits:
* libsupc++/compare:
* libsupc++/new: Add #pragma GCC diagnostic to suppress
undesired warnings.
* acinclude.m4: Change -Wabi version from 2 to 19.

gcc/ChangeLog:

* ginclude/stdint-wrap.h: Add #pragma GCC diagnostic to suppress
undesired warnings.
* gsyslimits.h: Likewise.

2 days agoAlways dump generated distance vectors
Richard Biener [Thu, 19 Sep 2024 10:37:13 +0000 (19 12:37 +0200)]
Always dump generated distance vectors

There's special-casing for equal access functions which bypasses
printing the distance vectors.  The following makes sure we print
them always which helps debugging.

* tree-data-ref.cc (build_classic_dist_vector): Move
distance vector dumping to single caller ...
(subscript_dependence_tester): ... here, dumping always
when we succeed computing it.

2 days agotree-optimization/116573 - .SELECT_VL for SLP
Richard Biener [Tue, 17 Sep 2024 09:20:10 +0000 (17 11:20 +0200)]
tree-optimization/116573 - .SELECT_VL for SLP

The following restores the use of .SELECT_VL for testcases where it
is safe to use even when using SLP.  I've for now restricted it
to single-lane SLP plus optimistically allow store-lane nodes
and assume single-lane roots are not widened but at most to
load-lane who should be fine.

PR tree-optimization/116573
* tree-vect-loop.cc (vect_analyze_loop_2): Allow .SELECV_VL
for SLP but disable it when there's multi-lane instances.
* tree-vect-stmts.cc (vectorizable_store): Only compute the
ptr increment when generating code.
(vectorizable_load): Likewise.

2 days agoFortran: Break recursion building recursive types. [PR106606]
Andre Vehreschild [Fri, 23 Aug 2024 14:28:38 +0000 (23 16:28 +0200)]
Fortran: Break recursion building recursive types. [PR106606]

Build a derived type component's type only, when it is not already being
built and the component uses pointer semantics.

gcc/fortran/ChangeLog:

PR fortran/106606

* trans-types.cc (gfc_get_derived_type): Only build non-pointer
derived types as component's types when they are not yet built.

gcc/testsuite/ChangeLog:

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

2 days agoRISC-V: Fix vector SAT_ADD dump check due to middle-end change
Pan Li [Wed, 11 Sep 2024 06:17:30 +0000 (11 14:17 +0800)]
RISC-V: Fix vector SAT_ADD dump check due to middle-end change

This patch would like fix the dump check times of vector SAT_ADD.  The
middle-end change makes the match times from 2 to 4 times.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-21.c: Adjust
the dump check times from 2 to 4.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-22.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-23.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-24.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-25.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-26.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-27.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-28.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-29.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-30.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-31.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-32.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-5.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-6.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-7.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-8.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 days agoMatch: Support form 3 for scalar signed integer .SAT_ADD
Pan Li [Wed, 11 Sep 2024 02:06:18 +0000 (11 10:06 +0800)]
Match: Support form 3 for scalar signed integer .SAT_ADD

This patch would like to support the form 3 of the scalar signed
integer .SAT_ADD.  Aka below example:

Form 3:
  #define DEF_SAT_S_ADD_FMT_3(T, UT, MIN, MAX)           \
  T __attribute__((noinline))                            \
  sat_s_add_##T##_fmt_3 (T x, T y)                       \
  {                                                      \
    T sum;                                               \
    bool overflow = __builtin_add_overflow (x, y, &sum); \
    return overflow ? x < 0 ? MIN : MAX : sum;           \
  }

DEF_SAT_S_ADD_FMT_3(int8_t, uint8_t, INT8_MIN, INT8_MAX)

We can tell the difference before and after this patch if backend
implemented the ssadd<m>3 pattern similar as below.

Before this patch:
   4   â”‚ __attribute__((noinline))
   5   â”‚ int8_t sat_s_add_int8_t_fmt_3 (int8_t x, int8_t y)
   6   â”‚ {
   7   â”‚   signed char _1;
   8   â”‚   signed char _2;
   9   â”‚   int8_t _3;
  10   â”‚   __complex__ signed char _6;
  11   â”‚   _Bool _8;
  12   â”‚   signed char _9;
  13   â”‚   signed char _10;
  14   â”‚   signed char _11;
  15   â”‚
  16   â”‚ ;;   basic block 2, loop depth 0
  17   â”‚ ;;    pred:       ENTRY
  18   â”‚   _6 = .ADD_OVERFLOW (x_4(D), y_5(D));
  19   â”‚   _2 = IMAGPART_EXPR <_6>;
  20   â”‚   if (_2 != 0)
  21   â”‚     goto <bb 4>; [50.00%]
  22   â”‚   else
  23   â”‚     goto <bb 3>; [50.00%]
  24   â”‚ ;;    succ:       4
  25   â”‚ ;;                3
  26   â”‚
  27   â”‚ ;;   basic block 3, loop depth 0
  28   â”‚ ;;    pred:       2
  29   â”‚   _1 = REALPART_EXPR <_6>;
  30   â”‚   goto <bb 5>; [100.00%]
  31   â”‚ ;;    succ:       5
  32   â”‚
  33   â”‚ ;;   basic block 4, loop depth 0
  34   â”‚ ;;    pred:       2
  35   â”‚   _8 = x_4(D) < 0;
  36   â”‚   _9 = (signed char) _8;
  37   â”‚   _10 = -_9;
  38   â”‚   _11 = _10 ^ 127;
  39   â”‚ ;;    succ:       5
  40   â”‚
  41   â”‚ ;;   basic block 5, loop depth 0
  42   â”‚ ;;    pred:       3
  43   â”‚ ;;                4
  44   â”‚   # _3 = PHI <_1(3), _11(4)>
  45   â”‚   return _3;
  46   â”‚ ;;    succ:       EXIT
  47   â”‚
  48   â”‚ }

After this patch:
   4   â”‚ __attribute__((noinline))
   5   â”‚ int8_t sat_s_add_int8_t_fmt_3 (int8_t x, int8_t y)
   6   â”‚ {
   7   â”‚   int8_t _3;
   8   â”‚
   9   â”‚ ;;   basic block 2, loop depth 0
  10   â”‚ ;;    pred:       ENTRY
  11   â”‚   _3 = .SAT_ADD (x_4(D), y_5(D)); [tail call]
  12   â”‚   return _3;
  13   â”‚ ;;    succ:       EXIT
  14   â”‚
  15   â”‚ }

The below test suites are passed for this patch.
* The rv64gcv fully regression test.
* The x86 bootstrap test.
* The x86 fully regression test.

gcc/ChangeLog:

* match.pd: Add the form 3 of signed .SAT_ADD matching.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 days agoGenmatch: Refine the gen_phi_on_cond by match_cond_with_binary_phi
Pan Li [Wed, 11 Sep 2024 01:34:21 +0000 (11 09:34 +0800)]
Genmatch: Refine the gen_phi_on_cond by match_cond_with_binary_phi

This patch would like to leverage the match_cond_with_binary_phi to
match the phi on cond, and get the true/false arg if matched.  This
helps a lot to simplify the implementation of gen_phi_on_cond.

Before this patch:
basic_block _b1 = gimple_bb (_a1);
if (gimple_phi_num_args (_a1) == 2)
  {
    basic_block _pb_0_1 = EDGE_PRED (_b1, 0)->src;
    basic_block _pb_1_1 = EDGE_PRED (_b1, 1)->src;
    basic_block _db_1 = safe_dyn_cast <gcond *> (*gsi_last_bb (_pb_0_1)) ? _pb_0_1 : _pb_1_1;
    basic_block _other_db_1 = safe_dyn_cast <gcond *> (*gsi_last_bb (_pb_0_1)) ? _pb_1_1 : _pb_0_1;
    gcond *_ct_1 = safe_dyn_cast <gcond *> (*gsi_last_bb (_db_1));
    if (_ct_1 && EDGE_COUNT (_other_db_1->preds) == 1
        && EDGE_COUNT (_other_db_1->succs) == 1
        && EDGE_PRED (_other_db_1, 0)->src == _db_1)
        {
          tree _cond_lhs_1 = gimple_cond_lhs (_ct_1);
          tree _cond_rhs_1 = gimple_cond_rhs (_ct_1);
          tree _p0 = build2 (gimple_cond_code (_ct_1), boolean_type_node, _cond_lhs_1, _cond_rhs_1);
          bool _arg_0_is_true_1 = gimple_phi_arg_edge (_a1, 0)->flags & EDGE_TRUE_VALUE;
          tree _p1 = gimple_phi_arg_def (_a1, _arg_0_is_true_1 ? 0 : 1);
          tree _p2 = gimple_phi_arg_def (_a1, _arg_0_is_true_1 ? 1 : 0);
...

After this patch:
basic_block _b1 = gimple_bb (_a1);
tree _p1, _p2;
gcond *_cond_1 = match_cond_with_binary_phi (_a1, &_p1, &_p2);
if (_cond_1)
  {
    tree _cond_lhs_1 = gimple_cond_lhs (_cond_1);
    tree _cond_rhs_1 = gimple_cond_rhs (_cond_1);
    tree _p0 = build2 (gimple_cond_code (_cond_1), boolean_type_node, _cond_lhs_1, _cond_rhs_1);
...

The below test suites are passed for this patch.
* The rv64gcv fully regression test.
* The x86 bootstrap test.
* The x86 fully regression test.

gcc/ChangeLog:

* genmatch.cc (dt_operand::gen_phi_on_cond): Leverage the
match_cond_with_binary_phi API to get cond gimple, true and
false TREE arg.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 days agoFix deep copy allocatable components in coarrays. [PR85002]
Andre Vehreschild [Fri, 23 Aug 2024 07:07:09 +0000 (23 09:07 +0200)]
Fix deep copy allocatable components in coarrays. [PR85002]

Fix code for deep copy of allocatable components in derived type nested
structures generated, but not inserted when the copy had to be done in
a coarray.  Additionally fix a comment.

gcc/fortran/ChangeLog:

PR fortran/85002
* trans-array.cc (duplicate_allocatable_coarray): Allow adding
of deep copy code in the when-allocated case.  Add bounds
computation before condition, because coarrays need the bounds
also when not allocated.
(structure_alloc_comps): Duplication in the coarray case is done
already, omit it.  Add the deep-code when duplication a coarray.
* trans-expr.cc (gfc_trans_structure_assign): Fix comment.

gcc/testsuite/ChangeLog:

* gfortran.dg/coarray/alloc_comp_9.f90: New test.

2 days agoSVE intrinsics: Fold svmul with all-zero operands to zero vector
Jennifer Schmitz [Tue, 17 Sep 2024 07:15:38 +0000 (17 00:15 -0700)]
SVE intrinsics: Fold svmul with all-zero operands to zero vector

As recently implemented for svdiv, this patch folds svmul to a zero
vector if one of the operands is a zero vector. This transformation is
applied if at least one of the following conditions is met:
- the first operand is all zeros or
- the second operand is all zeros, and the predicate is ptrue or the
predication is _x or _z.

In contrast to constant folding, which was implemented in a previous
patch, this transformation is applied as soon as one of the operands is
a zero vector, while the other operand can be a variable.

The patch was bootstrapped and regtested on aarch64-linux-gnu, no regression.
OK for mainline?

Signed-off-by: Jennifer Schmitz <jschmitz@nvidia.com>
gcc/
* config/aarch64/aarch64-sve-builtins-base.cc (svmul_impl::fold):
Add folding of all-zero operands to zero vector.

gcc/testsuite/
* gcc.target/aarch64/sve/const_fold_mul_1.c: Adjust expected
outcome.
* gcc.target/aarch64/sve/fold_mul_zero.c: New test.

2 days agoaarch64: Define l1_cache_line_size for -mcpu=neoverse-v2
Kyrylo Tkachov [Wed, 11 Sep 2024 13:58:35 +0000 (11 06:58 -0700)]
aarch64: Define l1_cache_line_size for -mcpu=neoverse-v2

This is a small patch that sets the L1 cache line size for Neoverse V2.
Unlike the other cache-related constants in there this value is not used just
for SW prefetch generation (which we want to avoid for Neoverse V2 presently).
It's also used to set std::hardware_destructive_interference_size.
See the links and recent discussions in PR116662 for reference.
Some CPU tunings in aarch64 set this value to something useful, but for
generic tuning we use the conservative 256, which forces 256-byte alignment
in such atomic structures.  Using a smaller value can decrease the size of such
structs during layout and should not present an ABI problem as
std::hardware_destructive_interference_size is not intended to be used for structs
in an external interface, and GCC warns about such uses.
Another place where the L1 cache line size is used is in phiopt for
-fhoist-adjacent-loads where conditional accesses to adjacent struct members
can be speculatively loaded as long as they are within the same L1 cache line.
e.g.
struct S { int i; int j; };

int
bar (struct S *x, int y)
{
  int r;
  if (y)
    r = x->i;
  else
    r = x->j;
  return r;
}

The Neoverse V2 L1 cache line is 64 bytes according to the TRM, so set it to
that. The rest of the prefetch parameters inherit from the generic tuning so
we don't do anything extra for software prefeteches.

Bootstrapped and tested on aarch64-none-linux-gnu.

Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>
* config/aarch64/tuning_models/neoversev2.h (neoversev2_prefetch_tune):
Define.
(neoversev2_tunings): Use it.

2 days agoi386: Add ssemov2, sseicvt2 for some load instructions that use memory on operand2
Hu, Lin1 [Wed, 11 Sep 2024 02:10:40 +0000 (11 10:10 +0800)]
i386: Add ssemov2, sseicvt2 for some load instructions that use memory on operand2

The memory attr of some instructions should be 'load', but these are
'none', currently.

gcc/ChangeLog:

* config/i386/i386.md: Add ssemov2, sseicvt2.
* config/i386/sse.md (sse2_cvtsi2sd): Apply sseicvt2.
(sse2_cvtsi2sdq<round_name>): Ditto.
(vec_set<mode>_0): Apply ssemov2 for 4, 6.

2 days agoMatch: Add interface match_cond_with_binary_phi for true/false arg
Pan Li [Thu, 19 Sep 2024 03:03:33 +0000 (19 11:03 +0800)]
Match: Add interface match_cond_with_binary_phi for true/false arg

When matching the cond with 2 args phi node, we need to figure out
which arg of phi node comes from the true edge of cond block, as
well as the false edge.  This patch would like to add interface
to perform the action and return the true and false arg in TREE type.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.
* The x86 bootstrap test.
* The x86 fully regression test.

gcc/ChangeLog:

* gimple-match-head.cc (match_cond_with_binary_phi): Add new func
impl to match binary phi for true and false arg.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 days agodoc: Add more alias option and reorder Intel CPU -march documentation
Haochen Jiang [Wed, 18 Sep 2024 03:20:15 +0000 (18 11:20 +0800)]
doc: Add more alias option and reorder Intel CPU -march documentation

Since r15-3539, there are requests coming in to add other alias option
documentation. This patch will add all ot them, including corei7, corei7-avx,
core-avx-i, core-avx2, atom, slm, gracemont and emerarldrapids.

Also in the patch, I reordered that part of documentation, currently all
the CPUs/products are just all over the place. I regrouped them by
date-to-now products (since the very first CPU to latest Panther Lake), P-core
(since the clients become hybrid cores, starting from Sapphire Rapids) and
E-core (since Bonnell to latest Clearwater Forest).

And in the patch, I refined the product names in documentation.

gcc/ChangeLog:

* doc/invoke.texi: Add corei7, corei7-avx, core-avx-i,
core-avx2, atom, slm, gracemont and emerarldrapids. Reorder
the -march documentation by splitting them into date-to-now
products, P-core and E-core. Refine the product names in
documentation.

2 days agoi386: Enhance AVX10.2 convert tests
Haochen Jiang [Thu, 5 Sep 2024 03:27:33 +0000 (5 11:27 +0800)]
i386: Enhance AVX10.2 convert tests

For AVX10.2 convert tests, all of them are missing mask tests
previously, this patch will add them in the tests.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx10_2-512-vcvt2ps2phx-2.c: Enhance mask test.
* gcc.target/i386/avx10_2-512-vcvtbiasph2bf8-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvtbiasph2bf8s-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvtbiasph2hf8-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvtbiasph2hf8s-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvthf82ph-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvtne2ph2bf8-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvtne2ph2bf8s-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvtne2ph2hf8-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvtne2ph2hf8s-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvtneph2bf8-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvtneph2bf8s-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvtneph2hf8-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvtneph2hf8s-2.c: Ditto.
* gcc.target/i386/avx512f-helper.h: Fix a typo in macro define.

2 days agoi386: Add missing avx512f-mask-type.h include
Haochen Jiang [Sat, 14 Sep 2024 07:55:53 +0000 (14 15:55 +0800)]
i386: Add missing avx512f-mask-type.h include

Since commit r15-3594, we fixed the bugs in MASK_TYPE for AVX10.2
testcases, but we missed the following four.

The tests are not FAIL since the binutils part haven't been merged
yet, which leads to UNSUPPORTED test. But the avx512f-mask-type.h
needs to be included, otherwise, it will be compile error.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx10_2-512-vpdpbssd-2.c: Include
avx512f-mask-type.h.
* gcc.target/i386/avx10_2-vminmaxsd-2.c: Ditto.
* gcc.target/i386/avx10_2-vminmaxsh-2.c: Ditto.
* gcc.target/i386/avx10_2-vminmaxss-2.c: Ditto.

3 days agotestsuite/gcc.dg/pr84877.c: Add machinery to stabilize stack aligmnent
Hans-Peter Nilsson [Thu, 5 Sep 2024 15:02:23 +0000 (5 17:02 +0200)]
testsuite/gcc.dg/pr84877.c: Add machinery to stabilize stack aligmnent

This test awkwardly "blinks"; xfails and xpasses apparently
randomly for cris-elf using the "gdb simulator".  On
inspection, I see that the stack address depends on the
number of environment variables, deliberately passed to the
simulator, each adding the size of a pointer.

This test is IMHO important enough not to be just skipped
just because it blinks (fixing the actual problem is a
different task).

I guess a random non-16 stack-alignment could happen for
other targets as well, so let's try and add a generic
machinery to "stabilize" the test as failing, by allocating
a dynamic amount to make sure it's misaligned.  The most
target-dependent item here is an offset between the incoming
stack-pointer value (within main in the added framework) and
outgoing (within "xmain" as called from main when setting up
the p0 parameter).  I know there are other wonderful stack
shapes, but such targets would fall under the "complicated
situations"-label and are no worse off than before.

* gcc.dg/pr84877.c: Try to make the test result consistent by
misaligning the stack.

3 days agoDaily bump.
GCC Administrator [Thu, 19 Sep 2024 00:18:55 +0000 (19 00:18 +0000)]
Daily bump.

3 days agoRISC-V: Fix signed SAT_ADD test case for int64_t
Pan Li [Fri, 13 Sep 2024 01:16:48 +0000 (13 09:16 +0800)]
RISC-V: Fix signed SAT_ADD test case for int64_t

The int8_t test for signed SAT_ADD is sat_s_add-1.c, the sat_s_add-4.c
should be for int64_t.  Thus, update sat_s_add-4.c for int64_t type.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat_s_add-4.c: Update test for int64_t
instead of int8_t.

Signed-off-by: Pan Li <pan2.li@intel.com>
3 days agolibstdc++: add braces
Jason Merrill [Sun, 15 Sep 2024 09:48:46 +0000 (15 11:48 +0200)]
libstdc++: add braces

GCC compiles with -fno-exceptions, so __throw_exception_again is a no-op,
and compilation gives a -Wempty-body warning here, so let's wrap it as is
already done in a few other files.

libstdc++-v3/ChangeLog:

* include/bits/basic_ios.h: Add braces.

3 days ago[PATCH] configure: fix typos
Andrew Kreimer [Wed, 18 Sep 2024 17:50:58 +0000 (18 11:50 -0600)]
[PATCH] configure: fix typos

/
* configure.ac: Fix typos.
* configure: Rebuilt.

3 days agoc++: alias of decltype(lambda) is opaque [PR116714, PR107390]
Patrick Palka [Wed, 18 Sep 2024 17:50:43 +0000 (18 13:50 -0400)]
c++: alias of decltype(lambda) is opaque [PR116714, PR107390]

Here for

  using type = decltype([]{});
  static_assert(is_same_v<type, type>);

we strip the alias ahead of time during template argument coercion
which effectively transforms the template-id into

  is_same_v<decltype([]{}), decltype([]{})>

which is wrong because later substitution into the template-id will
produce two new lambdas with distinct types and cause is_same_v to
return false.

This demonstrates that such aliases should be considered opaque (a
notion that we recently introduced in r15-2331-g523836716137d0).
(An alternative solution might be to consider memoizing lambda-expr
substitution rather than always producing a new lambda, but this is
much simpler.)

PR c++/116714
PR c++/107390

gcc/cp/ChangeLog:

* pt.cc (dependent_opaque_alias_p): Also return true for a
decltype(lambda) alias.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/lambda-uneval18.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
3 days agojit: Ensure ssize_t is defined
Francois-Xavier Coudert [Sat, 11 May 2024 15:08:05 +0000 (11 17:08 +0200)]
jit: Ensure ssize_t is defined

On some targets it seems that ssize_t is not defined by any of the
headers transitively included by <stdio.h>.  This leads to a bootstrap
fail when jit is enabled.

gcc/jit/ChangeLog:

* libgccjit.h: Include <sys/types.h>

3 days agohppa: Add peephole2 optimizations for REG+D loads and stores
John David Anglin [Wed, 18 Sep 2024 15:02:32 +0000 (18 11:02 -0400)]
hppa: Add peephole2 optimizations for REG+D loads and stores

The PA 1.x architecture only supports long displacements in
integer loads and stores.  Floating-point loads and stores
only support short displacements.  As a result, we have to
wait until reload is complete before generating insns with
long displacements.

The PA 2.0 architecture supports long displacements in both
integer and floating-point loads and stores.

The peephole2 optimizations added in this change are only
enabled when 14-bit long displacements aren't supported for
floating-point loads and stores.

2024-09-18  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

* config/pa/pa.h (GENERAL_REGNO_P): Define.
* config/pa/pa.md: Add SImode and SFmode peephole2
patterns to generate loads and stores with long
displacements.

3 days ago[PATCH v3] RISC-V: Fixed incorrect semantic description in DF to DI pattern in the...
Jin Ma [Wed, 18 Sep 2024 14:56:23 +0000 (18 08:56 -0600)]
[PATCH v3] RISC-V: Fixed incorrect semantic description in DF to DI pattern in the Zfa extension on rv32.

gcc/ChangeLog:

* config/riscv/riscv.md: Change "truncate" to unspec for the Zfa extension on rv32.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/zfa-fmovh-fmovp-bug.c: New test.

3 days agocontrib: Set check-params-in-docs.py to skip tables of values of a param
Filip Kastl [Wed, 18 Sep 2024 14:38:30 +0000 (18 16:38 +0200)]
contrib: Set check-params-in-docs.py to skip tables of values of a param

Currently check-params-in-docs.py reports extra params being listed in
invoke.texi.  However, those aren't actual params but items in a table of
possible values of the aarch64-autove-preference param.

This patch changes check-params-in-docs.py to ignore similar tables.

contrib/ChangeLog:

* check-params-in-docs.py: Skip tables of values of a param.
Remove code that skips items beginning with a number.

Signed-off-by: Filip Kastl <fkastl@suse.cz>
3 days agoFail vectorization when not using SLP and --param vect-force-slp == 1
Richard Biener [Sun, 8 Sep 2024 09:21:19 +0000 (8 11:21 +0200)]
Fail vectorization when not using SLP and --param vect-force-slp == 1

The following adds --param vect-force-slp to enable the transition
to full SLP.  Full SLP is enforced during stmt analysis where it
detects failed SLP discovery and at loop analysis time where it
avoids analyzing a loop with SLP disabled.  Failure to SLP results
in vectorization to fail.

* params.opt (vect-force-slp): New param, default 0.
* doc/invoke.texi (--param vect-force-slp): Document.
* tree-vect-loop.cc (vect_analyze_loop_2): When analyzing
without SLP but --param vect-force-slp is 1 fail.
* tree-vect-stmts.cc (vect_analyze_stmt): Fail vectorization
for non-SLP stmts when --param vect-force-slp is 1.

3 days ago[PATCH 1/2] RISC-V: Fix the outer_code when calculating the cost of SET expression.
Xianmiao Qu [Wed, 18 Sep 2024 13:35:12 +0000 (18 07:35 -0600)]
[PATCH 1/2] RISC-V: Fix the outer_code when calculating the cost of SET expression.

I think it is a typo. When calculating the 'SET_SRC (x)' cost,
outer_code should be set to SET.

gcc/
* config/riscv/riscv.cc (riscv_rtx_costs): Fix the outer_code
when calculating the cost of SET expression.

3 days ago[PATCH] RISC-V: Fix th.extu operands exceeding range on rv32.
Xianmiao Qu [Wed, 18 Sep 2024 13:28:44 +0000 (18 07:28 -0600)]
[PATCH] RISC-V: Fix th.extu operands exceeding range on rv32.

The Combine Pass may generate zero_extract instructions that are out of range.
Drawing from other architectures like AArch64, we should impose restrictions
on the "*th_extu<mode>4" pattern.

gcc/
* config/riscv/thead.md (*th_extu<mode>4): Fix th.extu
operands exceeding range on rv32.

gcc/testsuite/
* gcc.target/riscv/xtheadbb-extu-4.c: New.

3 days ago[PATCH] RISC-V: Allow zero operand for DI variants of vssubu.vx
Bohan Lei [Wed, 18 Sep 2024 13:20:23 +0000 (18 07:20 -0600)]
[PATCH] RISC-V: Allow zero operand for DI variants of vssubu.vx

The RISC-V vector machine description relies on the helper function
`sew64_scalar_helper` to emit actual insns for the DI variants of
vssub.vx and vssubu.vx.  This works with vssub.vx, but can cause
problems with vssubu.vx with the scalar operand being constant zero,
because `has_vi_variant_p` returns false, and the operand will be taken
without being loaded into a reg.  The attached testcases can cause an
internal compiler error as a result.

Allowing a constant zero operand in those insns seems to be a simple
solution that only affects minimum existing code.

gcc/ChangeLog:

* config/riscv/vector.md: Allow zero operand for DI variants of
vssubu.vx

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/vssubu-1.c: New test.
* gcc.target/riscv/rvv/base/vssubu-2.c: New test.

3 days agoc++: -Wdangling-reference diagnostic
Jason Merrill [Mon, 16 Sep 2024 11:29:05 +0000 (16 13:29 +0200)]
c++: -Wdangling-reference diagnostic

The -Wdangling-reference diagnostic talks about the full-expression, but
prints one call, while the full-expression in a declaration is the entire
initialization.  It seems more useful to point out the temporary that the
compiler thinks we might be getting a dangling reference to.

gcc/cp/ChangeLog:

* call.cc (do_warn_dangling_reference): Return temporary
instead of the call it's passed to.
(maybe_warn_dangling_reference): Adjust diagnostic.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wdangling-reference1.C: Adjust diagnostic.

3 days agoc++: -Wdangling-reference and empty class [PR115361]
Jason Merrill [Sun, 15 Sep 2024 11:50:04 +0000 (15 13:50 +0200)]
c++: -Wdangling-reference and empty class [PR115361]

We can't have a dangling reference to an empty class unless it's
specifically to that class or one of its bases.  This was giving a
false positive on the _ExtractKey pattern in libstdc++ hashtable.h.

This also adjusts the order of arguments to reference_related_p, which
is relevant for empty classes (unlike scalars).

Several of the classes in the testsuite needed to gain data members to
continue to warn.

PR c++/115361

gcc/cp/ChangeLog:

* call.cc (do_warn_dangling_reference): Check is_empty_class.

gcc/testsuite/ChangeLog:

* g++.dg/ext/attr-no-dangling6.C
* g++.dg/ext/attr-no-dangling7.C
* g++.dg/ext/attr-no-dangling8.C
* g++.dg/ext/attr-no-dangling9.C
* g++.dg/warn/Wdangling-reference1.C
* g++.dg/warn/Wdangling-reference2.C
* g++.dg/warn/Wdangling-reference3.C: Make classes non-empty.
* g++.dg/warn/Wdangling-reference23.C: New test.

3 days agomatch.pd: Check trunc_mod vector obtap before folding.
Jennifer Schmitz [Thu, 5 Sep 2024 15:10:02 +0000 (5 08:10 -0700)]
match.pd: Check trunc_mod vector obtap before folding.

In the pattern X - (X / Y) * Y to X % Y, this patch guards the
simplification for vector types by a check for:
1) Support of the mod optab for vectors OR
2) Application before vector lowering for non-VL vectors.
This is to prevent reverting vectorization of modulo to div/mult/sub
if the target does not support vector mod optab.

The patch was bootstrapped and tested with no regression on
aarch64-linux-gnu and x86_64-linux-gnu.
OK for mainline?

Signed-off-by: Jennifer Schmitz <jschmitz@nvidia.com>
gcc/
PR tree-optimization/116569
* match.pd: Guard simplification to trunc_mod with check for
mod optab support.

gcc/testsuite/
PR tree-optimization/116569
* gcc.dg/torture/pr116569.c: New test.

3 days agoreload1.cc: rtl-optimization/116326 - Use RELOAD_ELIMINABLE_REGS.
Georg-Johann Lay [Fri, 6 Sep 2024 09:23:06 +0000 (6 11:23 +0200)]
reload1.cc: rtl-optimization/116326 - Use RELOAD_ELIMINABLE_REGS.

The new macro is required because reload and LRA are using different
representations for a multi-register frame pointer.  As ELIMINABLE_REGS
is used to initialize static const objects, it can't depend on -mlra.

PR rtl-optimization/116326
gcc/
* reload1.cc (reg_eliminate_1): Initialize from
RELOAD_ELIMINABLE_REGS if defined.
* config/avr/avr.h (RELOAD_ELIMINABLE_REGS): Copy from ELIMINABLE_REGS.
(ELIMINABLE_REGS): Don't mention sub-regnos of the frame pointer.
* doc/tm.texi.in (Eliminating Frame Pointer and Arg Pointer)
<RELOAD_ELIMINABLE_REGS>: Add documentation.
* doc/tm.texi: Rebuild.
gcc/testsuite/
* gcc.target/avr/torture/lra-pr116324.c: New test.
* gcc.target/avr/torture/lra-pr116325.c: New test.

3 days agoAVR: doc/install.texi - Update avr specific installation notes.
Georg-Johann Lay [Tue, 17 Sep 2024 09:26:19 +0000 (17 11:26 +0200)]
AVR: doc/install.texi - Update avr specific installation notes.

gcc/
* doc/install.texi (Host/Target specific installation notes for GCC)
[avr]: Update web links to AVR-LibC and AVR Options.
Remove outdated note about Binutils.

3 days agotree-optimization/116585 - SSA corruption with split_constant_offset
Richard Biener [Wed, 18 Sep 2024 07:52:55 +0000 (18 09:52 +0200)]
tree-optimization/116585 - SSA corruption with split_constant_offset

split_constant_offset when looking through SSA defs can end up
picking SSA leafs that are subject to abnormal coalescing.  This
can lead to downstream consumers to insert code based on the
result (like from dataref analysis) in places that violate constraints
for abnormal coalescing.  It's best to not expand defs whose operands
are subject to abnormal coalescing - and not either do something when
a subexpression has operands like that already.

PR tree-optimization/116585
* tree-data-ref.cc (split_constant_offset_1): When either
operand is subject to abnormal coalescing do no further
processing.

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

3 days agophiopt: C++ify cond_if_else_store_replacement
Andrew Pinski [Tue, 17 Sep 2024 22:03:21 +0000 (17 15:03 -0700)]
phiopt: C++ify cond_if_else_store_replacement

This C++ify cond_if_else_store_replacement by using range fors
and changing using a std::pair instead of 2 vecs.
I had a hard time understanding the code when there was 2 vecs
so having a vec of a pair makes it easier to understand the relationship
between the 2.

gcc/ChangeLog:

* tree-ssa-phiopt.cc (cond_if_else_store_replacement): Use
range fors and use one vec for then/else stores instead of 2.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
3 days agophiopt: Add some details dump to cselim
Andrew Pinski [Tue, 17 Sep 2024 21:26:54 +0000 (17 14:26 -0700)]
phiopt: Add some details dump to cselim

While trying to debug PR 116747, I noticed there was no dump
saying what was done. So this adds the debug dump and it helps
debug what is going on in PR 116747 too.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-ssa-phiopt.cc (cond_if_else_store_replacement_1): Add debug dump.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
4 days agoRISC-V: Implement SAT_ADD for signed integer vector
Pan Li [Thu, 12 Sep 2024 02:43:46 +0000 (12 10:43 +0800)]
RISC-V: Implement SAT_ADD for signed integer vector

This patch would like to implement the ssadd for vector integer.  Aka
form 1 of ssadd vector.

Form 1:
  #define DEF_VEC_SAT_S_ADD_FMT_1(T, UT, MIN, MAX)                     \
  void __attribute__((noinline))                                       \
  vec_sat_s_add_##T##_fmt_1 (T *out, T *op_1, T *op_2, unsigned limit) \
  {                                                                    \
    unsigned i;                                                        \
    for (i = 0; i < limit; i++)                                        \
      {                                                                \
        T x = op_1[i];                                                 \
        T y = op_2[i];                                                 \
        T sum = (UT)x + (UT)y;                                         \
        out[i] = (x ^ y) < 0                                           \
          ? sum                                                        \
          : (sum ^ x) >= 0                                             \
            ? sum                                                      \
            : x < 0 ? MIN : MAX;                                       \
      }                                                                \
  }

DEF_VEC_SAT_S_ADD_FMT_1(int64_t, uint64_t, INT64_MIN, INT64_MAX)

Before this patch:
vec_sat_s_add_int64_t_fmt_1:
  ...
  vsetvli  t1,zero,e64,m1,ta,mu
  vadd.vv  v3,v1,v2
  vxor.vv  v0,v1,v3
  vmslt.vi v0,v0,0
  vxor.vv  v2,v1,v2
  vmsge.vi v2,v2,0
  vmand.mm v0,v0,v2
  vsra.vx  v1,v1,t3
  vxor.vv  v3,v1,v4,v0.t
  ...

After this patch:
vec_sat_s_add_int64_t_fmt_1:
  ...
  vsetvli  a6,zero,e64,m1,ta,ma
  vsadd.vv v1,v1,v2
  ...

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

gcc/ChangeLog:

* config/riscv/autovec.md (ssadd<mode>3): Add new pattern for
signed integer vector SAT_ADD.
* config/riscv/riscv-protos.h (expand_vec_ssadd): Add new func
decl for vector ssadd expanding.
* config/riscv/riscv-v.cc (expand_vec_ssadd): Add new func impl
to expand vector ssadd pattern.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/binop/vec_sat_data.h: Add test
data for vector ssadd.
* gcc.target/riscv/rvv/autovec/vec_sat_arith.h: Add test helper
macros.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-1.c: New test.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-2.c: New test.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-3.c: New test.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-4.c: New test.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-1.c: New test.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-2.c: New test.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-3.c: New test.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-4.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
4 days agoPR 89213: Add better support for shifting vectors with 64-bit elements
Michael Meissner [Wed, 18 Sep 2024 01:05:27 +0000 (17 21:05 -0400)]
PR 89213: Add better support for shifting vectors with 64-bit elements

This patch fixes PR target/89213 to allow better code to be generated to do
constant shifts of V2DI/V2DF vectors.  Previously GCC would do constant shifts
of vectors with 64-bit elements by using:

XXSPLTIB 32,4
VEXTSB2D 0,0
VSRAD 2,2,0

I.e., the PowerPC does not have a VSPLTISD instruction to load -15..14 for the
64-bit shift count in one instruction.  Instead, it would need to load a byte
and then convert it to 64-bit.

With this patch, GCC now realizes that the vector shift instructions will look
at the bottom 6 bits for the shift count, and it can use either a VSPLTISW or
XXSPLTIB instruction to load the shift count.

2024-09-17  Michael Meissner  <meissner@linux.ibm.com>

gcc/

PR target/89213
* config/rs6000/altivec.md (UNSPEC_VECTOR_SHIFT): New unspec.
(VSHIFT_MODE): New mode iterator.
(vshift_code): New code iterator.
(vshift_attr): New code attribute.
(altivec_<mode>_<vshift_attr>_const): New pattern to optimize
vector long long/int shifts by a constant.
(altivec_<mode>_shift_const): New helper insn to load up a
constant used by the shift operation.
* config/rs6000/predicates.md (vector_shift_constant): New
predicate.

gcc/testsuite/

PR target/89213
* gcc.target/powerpc/pr89213.c: New test.
* gcc.target/powerpc/vec-rlmi-rlnm.c: Update instruction count.

4 days agoDaily bump.
GCC Administrator [Wed, 18 Sep 2024 00:16:55 +0000 (18 00:16 +0000)]
Daily bump.

4 days agoc++: fix constexpr cast from void* diag issue [PR116741]aoliva/heads/testbase
Marek Polacek [Tue, 17 Sep 2024 18:34:30 +0000 (17 14:34 -0400)]
c++: fix constexpr cast from void* diag issue [PR116741]

The result of build_fold_indirect_ref can be a COMPONENT_REF in
which case using DECL_SOURCE_LOCATION will crash.  Look at its op1
instead.

PR c++/116741

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_constant_expression) <case CONVERT_EXPR>: If
the result of build_fold_indirect_ref is a COMPONENT_REF, use its op1.
Check DECL_P before calling inform.

gcc/testsuite/ChangeLog:

* g++.dg/cpp26/constexpr-voidptr4.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
4 days agoc++: ICE with -Wtautological-compare in template [PR116534]
Marek Polacek [Thu, 29 Aug 2024 14:40:50 +0000 (29 10:40 -0400)]
c++: ICE with -Wtautological-compare in template [PR116534]

Pre r14-4793, we'd call warn_tautological_cmp -> operand_equal_p
with operands wrapped in NON_DEPENDENT_EXPR, which works, since
o_e_p bails for codes it doesn't know.  But now we pass operands
not encapsulated in NON_DEPENDENT_EXPR, and crash, because the
template tree for &a[x] has null DECL_FIELD_OFFSET.

This patch extends r12-7797 to cover the case when DECL_FIELD_OFFSET
is null.

PR c++/116534

gcc/ChangeLog:

* fold-const.cc (operand_compare::operand_equal_p): If either
field's DECL_FIELD_OFFSET is null, compare the fields with ==.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wtautological-compare4.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
4 days agoc++: crash with anon VAR_DECL [PR116676]
Marek Polacek [Mon, 16 Sep 2024 20:42:38 +0000 (16 16:42 -0400)]
c++: crash with anon VAR_DECL [PR116676]

r12-3495 added maybe_warn_about_constant_value which will crash if
it gets a nameless VAR_DECL, which is what happens in this PR.

We created this VAR_DECL in cp_parser_decomposition_declaration.

PR c++/116676

gcc/cp/ChangeLog:

* constexpr.cc (maybe_warn_about_constant_value): Check DECL_NAME.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/constexpr-116676.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
4 days agoSVE intrinsics: Fold svdiv with all-zero operands to zero vector
Jennifer Schmitz [Mon, 2 Sep 2024 13:46:57 +0000 (2 06:46 -0700)]
SVE intrinsics: Fold svdiv with all-zero operands to zero vector

This patch folds svdiv where one of the operands is all-zeros to a zero
vector, if one of the following conditions holds:
- the dividend is all zeros or
- the divisor is all zeros, and the predicate is ptrue or the predication
is _x or _z.
This case was not covered by the recent patch that implemented constant
folding, because that covered only cases where both operands are
constant vectors. Here, the operation is folded as soon as one of the operands
is a constant zero vector.
Folding of divison by 0 to return 0 is in accordance with
the semantics of sdiv and udiv.

The patch was bootstrapped and regtested on aarch64-linux-gnu, no regression.
OK for mainline?

Signed-off-by: Jennifer Schmitz <jschmitz@nvidia.com>
gcc/
* config/aarch64/aarch64-sve-builtins-base.cc (svdiv_impl::fold):
Add folding of all-zero operands to zero vector.

gcc/testsuite/
* gcc.target/aarch64/sve/fold_div_zero.c: New test.
* gcc.target/aarch64/sve/const_fold_div_1.c: Adjust expected
outcome.

5 days agoDaily bump.
GCC Administrator [Tue, 17 Sep 2024 00:17:21 +0000 (17 00:17 +0000)]
Daily bump.

5 days agoaarch64: Improve vector constant generation using SVE INDEX instruction [PR113328]
Pengxuan Zheng [Wed, 11 Sep 2024 00:59:46 +0000 (10 17:59 -0700)]
aarch64: Improve vector constant generation using SVE INDEX instruction [PR113328]

SVE's INDEX instruction can be used to populate vectors by values starting from
"base" and incremented by "step" for each subsequent value. We can take
advantage of it to generate vector constants if TARGET_SVE is available and the
base and step values are within [-16, 15].

For example, with the following function:

typedef int v4si __attribute__ ((vector_size (16)));
v4si
f_v4si (void)
{
  return (v4si){ 0, 1, 2, 3 };
}

GCC currently generates:

f_v4si:
adrp    x0, .LC4
ldr     q0, [x0, #:lo12:.LC4]
ret

.LC4:
.word   0
.word   1
.word   2
.word   3

With this patch, we generate an INDEX instruction instead if TARGET_SVE is
available.

f_v4si:
index   z0.s, #0, #1
ret

PR target/113328

gcc/ChangeLog:

* config/aarch64/aarch64.cc (aarch64_simd_valid_immediate): Improve
handling of some ADVSIMD vectors by using SVE's INDEX if TARGET_SVE is
available.
(aarch64_output_simd_mov_immediate): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sve/acle/general/dupq_1.c: Update test to use
SVE's INDEX instruction.
* gcc.target/aarch64/sve/acle/general/dupq_2.c: Likewise.
* gcc.target/aarch64/sve/acle/general/dupq_3.c: Likewise.
* gcc.target/aarch64/sve/acle/general/dupq_4.c: Likewise.
* gcc.target/aarch64/sve/vec_init_3.c: New test.

Signed-off-by: Pengxuan Zheng <quic_pzheng@quicinc.com>
5 days agomodula2: gcc/m2/Make-lang.in fix includes during bootstrap build
Gaius Mulley [Mon, 16 Sep 2024 17:18:11 +0000 (16 18:18 +0100)]
modula2: gcc/m2/Make-lang.in fix includes during bootstrap build

This patch fixes the include directories used when building objects in
gm2-compiler-boot.  It adds the missing gm2-gcc directory and uses a
new variable GM2_BOOT_INCLUDES for all gm2-compiler-boot rules.

gcc/m2/ChangeLog:

* Make-lang.in (GM2_BOOT_INCLUDES): New variable.
(m2/gm2-compiler-boot/M2GCCDeclare.o): Rewrite to use
GM2_BOOT_INCLUDES.
(m2/gm2-compiler-boot/M2Error.o): Ditto.
(m2/gm2-compiler-boot/%.o): Ditto.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
5 days agoAVR: Update weblinks to AVR-LibC.
Georg-Johann Lay [Mon, 16 Sep 2024 15:23:00 +0000 (16 17:23 +0200)]
AVR: Update weblinks to AVR-LibC.

AVR-LibC has moved to GitHub, adjust web links:
https://github.com/avrdudes/avr-libc (project)
https://avrdudes.github.io/avr-libc/avr-libc-user-manual (wwwdocs)

gcc/
* doc/invoke.texi (AVR Options): Update AVR-LibC weblink from
nongnu.org to https://github.com/avrdudes/avr-libc
* doc/extend.texi (AVR Named Address Spaces): Same.
(AVR Function Attributes): Same.
* doc/install.texi (Cross-Compiler-Specific Options, AVR): Same.