[committed] hppa: Don't clobber frame_pointer_rtx in expanders

2024-10-05 Thread John David Anglin
Tested on hppa-unknown-linux-gnu and hppa64-hp-hpux11.11.  Committed
to trunk.

Dave
---

hppa: Don't clobber frame_pointer_rtx in expanders

Noticed testing LRA.  Clobbers cause internal compiler errors.

2024-10-05  John David Anglin  

gcc/ChangeLog:

* config/pa/pa.md (nonlocal_goto): Don't clobber
frame_pointer_rtx.
(builtin_longjmp): Likewise.

diff --git a/gcc/config/pa/pa.md b/gcc/config/pa/pa.md
index f0520bb2c35..2f82b431c0c 100644
--- a/gcc/config/pa/pa.md
+++ b/gcc/config/pa/pa.md
@@ -7411,7 +7411,6 @@
   /* Ensure the frame pointer move is not optimized.  */
   emit_insn (gen_blockage ());
   emit_clobber (hard_frame_pointer_rtx);
-  emit_clobber (frame_pointer_rtx);
   emit_move_insn (hard_frame_pointer_rtx, fp);
 
   emit_use (hard_frame_pointer_rtx);
@@ -9202,7 +9201,6 @@ add,l %2,%3,%3\;bv,n %%r0(%3)"
   /* Ensure the frame pointer move is not optimized.  */
   emit_insn (gen_blockage ());
   emit_clobber (hard_frame_pointer_rtx);
-  emit_clobber (frame_pointer_rtx);
   emit_move_insn (hard_frame_pointer_rtx, fp);
 
   emit_use (hard_frame_pointer_rtx);


signature.asc
Description: PGP signature


[pushed] doc: Focus on DWARF for FreeBSD

2024-10-05 Thread Gerald Pfeifer
Pushed.

Gerald


gcc:
PR target/69374
* doc/install.texi (Specific) <*-*-freebsd*>: Focus on DWARF
only.
---
 gcc/doc/install.texi | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index 09559615bbf..b7c14e8b6f0 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -4086,9 +4086,7 @@ This configuration is intended for embedded systems.
 @anchor{x-x-freebsd}
 @heading *-*-freebsd*
 We support FreeBSD using the ELF file format with DWARF 2 debugging
-for all CPU architectures.  There are
-no known issues with mixing object files and libraries with different
-debugging formats.
+for all CPU architectures.
 
 We recommend bootstrapping against the latest GNU binutils or the
 version found in the @file{devel/binutils} port. This also has been
-- 
2.46.1


[RFC PATCH] RISC-V: Implement riscv_minimal_hwprobe_feature_bits

2024-10-05 Thread Yangyu Chen
This patch implements the riscv_minimal_hwprobe_feature_bits feature
for the RISC-V target. The feature bits are defined in the previous
patch [1] to provide bitmasks of ISA extensions that defined in RISC-V
C-API. Thus, we need a function to generate the feature bits for IFUNC
resolver to dispatch between different functions based on the hardware
features. The final version of the target_clones support on RISC-V is
still under development, I am working on it.

The minimal feature bits means to use the earliest extension appeard in
the Linux hwprobe to cover the given ISA string. To allow older kernels
without some implied extensions probe to run the FMV dispatcher
correctly.

For example, V implies Zve32x, but Zve32x appears in the Linux kernel
since v6.11. If we use isa string directly to generate FMV dispatcher
with functions with "arch=+v" extension, since we have V implied the
Zve32x, FMV dispatcher will check if the Zve32x extension is supported
by the host. If the Linux kernel is older than v6.11, the FMV dispatcher
will fail to detect the Zve32x extension even it already implies by the
V extension, thus making the FMV dispatcher fail to dispatch the correct
function.

Thus, we need to generate the minimal feature bits to cover the given
ISA string to allow the FMV dispatcher to work correctly on older
kernels.

[1] 
https://patchwork.sourceware.org/project/gcc/patch/20241003182256.1765569-1-chenyan...@isrc.iscas.ac.cn/

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc
(struct riscv_ext_bitmask_table_t): New struct.
(riscv_minimal_hwprobe_feature_bits): New function.
* config/riscv/riscv-subset.h (GCC_RISCV_SUBSET_H):
(riscv_minimal_hwprobe_feature_bits): Declare the function.
* common/config/riscv/feature_bits.h: New file.
---
 gcc/common/config/riscv/feature_bits.h  |  33 ++
 gcc/common/config/riscv/riscv-common.cc | 144 
 gcc/config/riscv/riscv-subset.h |   4 +
 3 files changed, 181 insertions(+)
 create mode 100644 gcc/common/config/riscv/feature_bits.h

diff --git a/gcc/common/config/riscv/feature_bits.h 
b/gcc/common/config/riscv/feature_bits.h
new file mode 100644
index 000..c6c6d983edb
--- /dev/null
+++ b/gcc/common/config/riscv/feature_bits.h
@@ -0,0 +1,33 @@
+/* Definition of RISC-V feature bits corresponding to
+   libgcc/config/riscv/feature_bits.c
+   Copyright (C) 2024 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+.  */
+
+#define RISCV_FEATURE_BITS_LENGTH 2
+struct riscv_feature_bits {
+  unsigned length;
+  unsigned long long features[RISCV_FEATURE_BITS_LENGTH];
+};
+
+#define RISCV_VENDOR_FEATURE_BITS_LENGTH 1
+
+struct riscv_vendor_feature_bits {
+  unsigned vendorID;
+  unsigned length;
+  unsigned long long features[RISCV_VENDOR_FEATURE_BITS_LENGTH];
+};
diff --git a/gcc/common/config/riscv/riscv-common.cc 
b/gcc/common/config/riscv/riscv-common.cc
index bd42fd01532..9f343782ae6 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #include 
 #include 
+#include 
 
 #define INCLUDE_STRING
 #define INCLUDE_SET
@@ -1754,6 +1755,75 @@ static const riscv_ext_flag_table_t 
riscv_ext_flag_table[] =
   {NULL, NULL, 0}
 };
 
+/* Types for recording extension to RISC-V C-API bitmask.  */
+struct riscv_ext_bitmask_table_t {
+  const char *ext;
+  int groupid;
+  int bit_position;
+};
+
+/* Mapping table between extension to RISC-V C-API extension bitmask.
+   This table should sort the extension by Linux hwprobe order to get the
+   minimal feature bits.  */
+static const riscv_ext_bitmask_table_t riscv_ext_bitmask_table[] =
+{
+  {"i",0,  8},
+  {"m",0, 12},
+  {"a",0,  0},
+  {"f",0,  5},
+  {"d",0,  3},
+  {"c",0,  2},
+  {"v",0, 21},
+  {"zba",  0, 27},
+  {"zbb",  0, 28},
+  {"zbs",  0, 33},
+  {"zicboz",   0, 37},
+  {"zbc",  0, 29},
+  {"zbkb", 0, 30},
+  {"zbkc", 0, 31},
+  {"zbkx", 0, 32},
+  {"zknd", 0, 41},
+  {"zkne", 0, 42},
+  {"zknh", 0, 43},
+  {"zksed",0

Re: [PATCH 2/2 v3] libstdc++: add std::is_virtual_base_of

2024-10-05 Thread Patrick Palka
On Fri, 2 Aug 2024, Jonathan Wakely wrote:

> On Fri, 2 Aug 2024 at 10:35, Giuseppe D'Angelo wrote:
> >
> > Hello,
> >
> > On 31/07/2024 00:55, Jonathan Wakely wrote:
> > > If __cpp_lib_is_virtual_base_of depends on __has_builtin, then that
> > > will do the right thing for #ifdef __cpp_lib_is_virtual_base_of in
> > > .
> >
> > Third time's the charm, I hope; clang trunk seems to like this.
> 
> Yup, this looks good now, thanks!
> 
> Once your patch to add the built-in is approved, we can add this.

Now that the built-in patch has been approved and pushed (as
r15-3993-g1b7cfa715c6c02) I went ahead and pushed this one as
r15-4087-g9fc5b8f956948e.  Thanks again!



Re: [PATCH 2/3] Release expanded template argument vector

2024-10-05 Thread Jason Merrill

On 10/4/24 11:00 AM, Patrick Palka wrote:

On Thu, 3 Oct 2024, Jason Merrill wrote:


On 10/3/24 12:38 PM, Jason Merrill wrote:

On 10/2/24 7:50 AM, Richard Biener wrote:

This reduces peak memory usage by 20% for a specific testcase.

Bootstrapped and tested on x86_64-unknown-linux-gnu.

It's very ugly so I'd appreciate suggestions on how to handle such
situations better?


I'm pushing this alternative patch, tested x86_64-pc-linux-gnu.


OK, apparently that was both too clever and not clever enough. Replacing it
with this one that's much closer to yours.

Jason



From: Jason Merrill 
Date: Thu, 3 Oct 2024 16:31:00 -0400
Subject: [PATCH] c++: free garbage vec in coerce_template_parms
To: gcc-patches@gcc.gnu.org

coerce_template_parms can create two different vecs for the inner template
arguments, new_inner_args and (potentially) the result of
expand_template_argument_pack.  One or the other, or possibly both, end up
being garbage: in the typical case, the expanded vec is garbage because it's
only used as the source for convert_template_argument.  In some dependent
cases, the new vec is garbage because we decide to return the original args
instead.  In these cases, ggc_free the garbage vec to reduce the memory
overhead of overload resolution.

gcc/cp/ChangeLog:

* pt.cc (coerce_template_parms): Free garbage vecs.

Co-authored-by: Richard Biener 
---
  gcc/cp/pt.cc | 10 +-
  1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 20affcd65a2..4ceae1d38de 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -9275,6 +9275,7 @@ coerce_template_parms (tree parms,
{
  /* We don't know how many args we have yet, just use the
 unconverted (and still packed) ones for now.  */
+ ggc_free (new_inner_args);
  new_inner_args = orig_inner_args;
  arg_idx = nargs;
  break;
@@ -9329,7 +9330,8 @@ coerce_template_parms (tree parms,
  = make_pack_expansion (conv, complain);
  
/* We don't know how many args we have yet, just

- use the unconverted ones for now.  */
+use the unconverted (but unpacked) ones for now.  */
+ ggc_free (new_inner_args);


I'm a bit worried about these ggc_frees.  If an earlier template
parameter is a constrained auto NTTP then new_inner_args/new_args could
have been captured by the satisfaction cache during coercion for that
argument, and so we'd be freeing a vector that's still live?


It seems like for e.g.

template  concept NotInt = !__is_same (T, int);
template  struct A { };
template  using B = A<'x', Ts...>;

we don't check satisfaction until after we're done coercing, because of

  if (processing_template_decl && context == adc_unify)
/* Constraints will be checked after deduction.  */;

in do_auto_deduction.

Jason



Re: [PATCH 1/2] gcc: make Valgrind errors fatal during bootstrap

2024-10-05 Thread Mark Wielaard
Hi (adding Philippe to CC who knows a bit more about Valgrind vs Ada),

On Sat, Oct 05, 2024 at 06:07:27AM +0100, Sam James wrote:
> Jeff Law  writes:
> 
> > On 10/2/24 8:39 PM, Sam James wrote:
> >> Valgrind doesn't error out by default which means bootstrap issues like
> >> in PR116945 can easily be missed: pass --exit-errorcode=1 to handle this.
> >> While here, also set --trace-children=yes to cover child processes
> >> of tools invoked during the build.
> >> Note that this only handles tools invoke during the build, it
> >> doesn't
> >> cover everything that --enable-checking=valgrind does.
> >> gcc/ChangeLog:
> >>PR other/116945
> >>PR other/116947
> >>* configure: Regenerate.
> >>* configure.ac (valgrind_cmd): Pass additional options.
> > But is this going to cause all bootstraps with Ada to fail?  That's
> > how I read 116945 which was closed as WONTFIX.  Or am I
> > mis-interpreting that BZ and its interaction with this patch?
> 
> No, you're right, I consider this on pause unless/until we figure out
> that bug -- I'm speaking with mjw about some ideas.

The problem as explained in the bug
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116945 is that we don't
understand what code is generated for the guard that checks whether
the value is undefined. I assume the 'Valid guard relies at least on
(partially) defined bits (but maybe it really is not deterministic?)

Depending on what the generated code actually looks like we can either
try to get memcheck more accurate, add valgrind annotations like in
ggc (but do we have an Ada variant of the valgrind.h macros?) or add a
suppression (where another wrinkle is that Valgrind doesn't seem to
demangle Ada symbols, https://bugs.kde.org/show_bug.cgi?id=445235).

Cheers,

Mark


Re: [PATCH] Fix PR middle-end/116933

2024-10-05 Thread Richard Biener



> Am 05.10.2024 um 10:22 schrieb Eric Botcazou :
> 
> Hi,
> 
> this polishes a few rough edges that prevent -ftrivial-auto-var-init=zero from
> working in Ada:
> 
>  - build_common_builtin_nodes declares BUILT_IN_CLEAR_PADDING with 3 instead
> of 2 parameters, now gimple_fold_builtin_clear_padding contains the assertion:
> 
>  gcc_assert (gimple_call_num_args (stmt) == 2)
> 
> This causes gimple_builtin_call_types_compatible_p to always return false in
> Ada (this works in C/C++ because yet another declaration is used AFAICS).
> 
>  - gimple_add_init_for_auto_var uses EXPR_LOCATION to fetch the location of a
> DECL notes, which always returns UNKNOWN_LOCATION.
> 
>  - the machinery attempts to initialize Out parameters, which is problematic.
> 
> Tested on x86-64/Linux, OK for the mainline?
> 

Ok

Richard 

> 
> 2024-10-05  Eric Botcazou  
> 
>PR middle-end/116933
>* gimplify.cc (gimple_add_init_for_auto_var): Use the correct macro
>to fetch the source location of the variable.
>* tree.c (common_builtin_nodes): Remove the 3rd parameter in the
>type of BUILT_IN_CLEAR_PADDING.
> 
> 
> 2024-10-05  Eric Botcazou  
> 
> ada/
>PR middle-end/116933
>* gcc-interface/decl.cc (gnat_to_gnu_entity) : Add
>the "uninitialized" attribute on Out parameters.
>* gcc-interface/utils.cc (gnat_internal_attributes): Add entry for
>the "uninitialized" attribute.
>(handle_uninitialized_attribute): New function.
> 
> 
> 2024-10-05  Eric Botcazou  
> 
> testsuite/
>* gnat.dg/auto_var_init.adb: New test.
> 
> 
> --
> Eric Botcazou
> 
> 


[PATCH v2] Add -ftime-report-wall

2024-10-05 Thread Andi Kleen
From: Andi Kleen 

Time vars normally use times(2) to get the user/sys/wall time, which is always a
system call. I don't think the system time is very useful because most overhead
is in user time. If we only use the wall (or monotonic) time modern OS have an
optimized path to get it directly from a CPU instruction like RDTSC
without system call, which is much faster.

Add a -ftime-report-wall option. It actually uses the POSIX monotonic time,
so strictly it's not wall clock, but it's still a reasonable name.

Comparing the overhead with tramp3d -O0:

  ./gcc/cc1plus -quiet  ../tsrc/tramp3d-v4.i ran
1.03 ± 0.00 times faster than ./gcc/cc1plus -quiet -ftime-report-wall 
../tsrc/tramp3d-v4.i
1.18 ± 0.00 times faster than ./gcc/cc1plus -quiet -ftime-report 
../tsrc/tramp3d-v4.i

-ftime-report costs 18% (excluding the output), while -ftime-report-wall
only costs 3%, so is nearly free. So it would be feasible for some build
system to always enable it and break down the build time into passes.

With -O2 it is a bit less pronounced but still visible:

  ./gcc/cc1plus -O2 -quiet  ../tsrc/tramp3d-v4.i ran
1.00 ± 0.00 times faster than ./gcc/cc1plus -O2 -quiet -ftime-report-wall 
../tsrc/tramp3d-v4.i
1.08 ± 0.01 times faster than ./gcc/cc1plus -O2 -quiet -ftime-report 
../tsrc/tramp3d-v4.i

The drawback is that if there is context switching with other programs
the time will be overestimated, however for the common case that the
system is not oversubscribed it is more accurate because each
measurement has less overhead.

Bootstrapped on x86_64-linux with full test suite run.

gcc/ChangeLog:

* common.opt (ftime-report-wall): Add.
* common.opt.urls: Regenerate.
* doc/invoke.texi: (ftime-report-wall): Document
* gcc.cc (try_generate_repro): Check for -ftime-report-wall.
* timevar.cc (get_time): Use clock_gettime if enabled.
(timer::print): Print only wall time for time_report_wall.
(make_json_for_timevar_time_def): Dito.
* toplev.cc (toplev::start_timevars): Check for time_report_wall.

gcc/testsuite/ChangeLog:

* g++.dg/ext/timevar3.C: New test.

---

v2: Adjust JSON/Sarif output too.
---
 gcc/common.opt  |  4 +++
 gcc/common.opt.urls |  3 +++
 gcc/doc/invoke.texi |  7 ++
 gcc/gcc.cc  |  3 ++-
 gcc/testsuite/g++.dg/ext/timevar3.C | 14 +++
 gcc/timevar.cc  | 38 +++--
 gcc/toplev.cc   |  3 ++-
 7 files changed, 62 insertions(+), 10 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/ext/timevar3.C

diff --git a/gcc/common.opt b/gcc/common.opt
index 12b25ff486de..a200a8a0bc45 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -3014,6 +3014,10 @@ ftime-report
 Common Var(time_report)
 Report the time taken by each compiler pass.
 
+ftime-report-wall
+Common Var(time_report_wall)
+Report the wall time taken by each compiler.
+
 ftime-report-details
 Common Var(time_report_details)
 Record times taken by sub-phases separately.
diff --git a/gcc/common.opt.urls b/gcc/common.opt.urls
index e31736cd9945..6e79a8f9390b 100644
--- a/gcc/common.opt.urls
+++ b/gcc/common.opt.urls
@@ -1378,6 +1378,9 @@ UrlSuffix(gcc/Optimize-Options.html#index-fthread-jumps)
 ftime-report
 UrlSuffix(gcc/Developer-Options.html#index-ftime-report)
 
+ftime-report-wall
+UrlSuffix(gcc/Developer-Options.html#index-ftime-report-wall)
+
 ftime-report-details
 UrlSuffix(gcc/Developer-Options.html#index-ftime-report-details)
 
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index d38c1feb86f7..8c11d12e7521 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -784,6 +784,7 @@ Objective-C and Objective-C++ Dialects}.
 -frandom-seed=@var{string}  -fsched-verbose=@var{n}
 -fsel-sched-verbose  -fsel-sched-dump-cfg  -fsel-sched-pipelining-verbose
 -fstats  -fstack-usage  -ftime-report  -ftime-report-details
+-ftime-report-wall
 -fvar-tracking-assignments-toggle  -gtoggle
 -print-file-name=@var{library}  -print-libgcc-file-name
 -print-multi-directory  -print-multi-lib  -print-multi-os-directory
@@ -21048,6 +21049,12 @@ slightly different place within the compiler.
 @item -ftime-report-details
 Record the time consumed by infrastructure parts separately for each pass.
 
+@opindex ftime-report-wall
+@item -ftime-report-wall
+Report statistics about compiler pass time consumpion, but only using wall
+time.  This is faster than @option{-ftime-report}, but can be more
+influenced by background jobs.
+
 @opindex fira-verbose
 @item -fira-verbose=@var{n}
 Control the verbosity of the dump file for the integrated register allocator.
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 16fed46fb35f..8d3046eb7874 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -7964,7 +7964,8 @@ try_generate_repro (const char **argv)
it might varry between invocations.  */
 else if (! strcmp (argv[nargs], "-quiet"))
   quiet = 1;
-e

[PATCH] Fix PR middle-end/116933

2024-10-05 Thread Eric Botcazou
Hi,

this polishes a few rough edges that prevent -ftrivial-auto-var-init=zero from 
working in Ada:

  - build_common_builtin_nodes declares BUILT_IN_CLEAR_PADDING with 3 instead 
of 2 parameters, now gimple_fold_builtin_clear_padding contains the assertion:

  gcc_assert (gimple_call_num_args (stmt) == 2)

This causes gimple_builtin_call_types_compatible_p to always return false in 
Ada (this works in C/C++ because yet another declaration is used AFAICS).

  - gimple_add_init_for_auto_var uses EXPR_LOCATION to fetch the location of a 
DECL notes, which always returns UNKNOWN_LOCATION.

  - the machinery attempts to initialize Out parameters, which is problematic.

Tested on x86-64/Linux, OK for the mainline?


2024-10-05  Eric Botcazou  

PR middle-end/116933
* gimplify.cc (gimple_add_init_for_auto_var): Use the correct macro
to fetch the source location of the variable.
* tree.c (common_builtin_nodes): Remove the 3rd parameter in the
type of BUILT_IN_CLEAR_PADDING.


2024-10-05  Eric Botcazou  

ada/
PR middle-end/116933
* gcc-interface/decl.cc (gnat_to_gnu_entity) : Add
the "uninitialized" attribute on Out parameters.
* gcc-interface/utils.cc (gnat_internal_attributes): Add entry for
the "uninitialized" attribute.
(handle_uninitialized_attribute): New function.


2024-10-05  Eric Botcazou  

testsuite/
* gnat.dg/auto_var_init.adb: New test.


-- 
Eric Botcazoudiff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index 4252e627b0c..880eaff8d0b 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -1563,6 +1563,13 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
 	  prepend_one_attribute_pragma (&attr_list,
 	Linker_Section_Pragma (gnat_entity));
 
+	/* Do not initialize Out parameters with -ftrivial-auto-var-init.  */
+	if (kind == E_Out_Parameter)
+	  prepend_one_attribute
+	(&attr_list, ATTR_MACHINE_ATTRIBUTE,
+	 get_identifier ("uninitialized"), NULL_TREE,
+	 gnat_entity);
+
 	/* Now create the variable or the constant and set various flags.  */
 	gnu_decl
 	  = create_var_decl (gnu_entity_name, gnu_ext_name, gnu_type,
diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc
index 60f36b1e50d..a88a23860d3 100644
--- a/gcc/ada/gcc-interface/utils.cc
+++ b/gcc/ada/gcc-interface/utils.cc
@@ -107,6 +107,7 @@ static tree handle_malloc_attribute (tree *, tree, tree, int, bool *);
 static tree handle_type_generic_attribute (tree *, tree, tree, int, bool *);
 static tree handle_flatten_attribute (tree *, tree, tree, int, bool *);
 static tree handle_used_attribute (tree *, tree, tree, int, bool *);
+static tree handle_uninitialized_attribute (tree *, tree, tree, int, bool *);
 static tree handle_cold_attribute (tree *, tree, tree, int, bool *);
 static tree handle_hot_attribute (tree *, tree, tree, int, bool *);
 static tree handle_simd_attribute (tree *, tree, tree, int, bool *);
@@ -214,6 +215,8 @@ static const attribute_spec gnat_internal_attributes[] =
 handle_flatten_attribute, NULL },
   { "used", 0, 0,  true,  false, false, false,
 handle_used_attribute, NULL },
+  { "uninitialized",0, 0,  true,  false, false, false,
+handle_uninitialized_attribute, NULL },
   { "cold", 0, 0,  true,  false, false, false,
 handle_cold_attribute, attr_cold_hot_exclusions },
   { "hot",  0, 0,  true,  false, false, false,
@@ -7171,6 +7174,30 @@ handle_used_attribute (tree *pnode, tree name, tree ARG_UNUSED (args),
   return NULL_TREE;
 }
 
+/* Handle an "uninitialized" attribute; arguments as in
+   struct attribute_spec.handler.  */
+
+static tree
+handle_uninitialized_attribute (tree *node, tree name, tree ARG_UNUSED (args),
+int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+  tree decl = *node;
+  if (!VAR_P (decl))
+{
+  warning (OPT_Wattributes, "%qE attribute ignored because %qD "
+	   "is not a variable", name, decl);
+  *no_add_attrs = true;
+}
+  else if (TREE_STATIC (decl) || DECL_EXTERNAL (decl))
+{
+  warning (OPT_Wattributes, "%qE attribute ignored because %qD "
+	   "is not a local variable", name, decl);
+  *no_add_attrs = true;
+}
+
+  return NULL_TREE;
+}
+
 /* Handle a "cold" and attribute; arguments as in
struct attribute_spec.handler.  */
 
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index ceb53e5d5bb..935f1251846 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -1993,17 +1993,14 @@ gimple_add_init_for_auto_var (tree decl,
 {
   gcc_assert (auto_var_p (decl));
   gcc_assert (init_type > AUTO_INIT_UNINITIALIZED);
-  location_t loc = EXPR_LOCATION (decl);
-  tree decl_size = TYPE_SIZE_UNIT (TREE_TYPE (decl));
 
-  tree init_type_node
-= build_int_cst (integer_type_node, (int) init_type);
+  const location_t loc = DECL_SOURCE_LOCATION (decl);
+  tree decl_size = TYPE_SIZE_UNIT (TREE_TYPE (decl));
+  tr

[PATCH][v2] Add single-lane SLP support to .GOMP_SIMD_LANE vectorization

2024-10-05 Thread Richard Biener
The following adds basic support for single-lane SLP .GOMP_SIMD_LANE
vectorization, in particular it enables SLP discovery.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

* tree-vect-slp.cc (no_arg_map): New.
(vect_get_operand_map): Handle IFN_GOMP_SIMD_LANE.
(vect_build_slp_tree_1): Likewise.
* tree-vect-stmts.cc (vectorizable_call): Handle single-lane SLP
for .GOMP_SIMD_LANE calls.
---
 gcc/tree-vect-slp.cc   | 11 +++
 gcc/tree-vect-stmts.cc | 26 --
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 2274d0e428e..125e69cf0eb 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -507,6 +507,7 @@ static const int cond_expr_maps[3][5] = {
   { 4, -2, -1, 1, 2 },
   { 4, -1, -2, 2, 1 }
 };
+static const int no_arg_map[] = { 0 };
 static const int arg0_map[] = { 1, 0 };
 static const int arg1_map[] = { 1, 1 };
 static const int arg2_map[] = { 1, 2 };
@@ -587,6 +588,9 @@ vect_get_operand_map (const gimple *stmt, bool 
gather_scatter_p = false,
  case IFN_CTZ:
return arg0_map;
 
+ case IFN_GOMP_SIMD_LANE:
+   return no_arg_map;
+
  default:
break;
  }
@@ -1175,6 +1179,8 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char 
*swap,
  ldst_p = true;
  rhs_code = CFN_MASK_STORE;
}
+ else if (cfn == CFN_GOMP_SIMD_LANE)
+   ;
  else if ((cfn != CFN_LAST
&& cfn != CFN_MASK_CALL
&& internal_fn_p (cfn)
@@ -1273,6 +1279,11 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char 
*swap,
  need_same_oprnds = true;
  first_op1 = gimple_call_arg (call_stmt, 1);
}
+ else if (rhs_code == CFN_GOMP_SIMD_LANE)
+   {
+ need_same_oprnds = true;
+ first_op1 = gimple_call_arg (call_stmt, 1);
+   }
}
   else
{
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 1ecf6532e54..6ce98b613e5 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -3392,7 +3392,7 @@ vectorizable_call (vec_info *vinfo,
   if (ifn == IFN_LAST && !fndecl)
 {
   if (cfn == CFN_GOMP_SIMD_LANE
- && !slp_node
+ && (!slp_node || SLP_TREE_LANES (slp_node) == 1)
  && loop_vinfo
  && LOOP_VINFO_LOOP (loop_vinfo)->simduid
  && TREE_CODE (gimple_call_arg (stmt, 0)) == SSA_NAME
@@ -3538,8 +3538,30 @@ vectorizable_call (vec_info *vinfo,
  /* Build argument list for the vectorized call.  */
  if (slp_node)
{
- vec vec_oprnds0;
+ if (cfn == CFN_GOMP_SIMD_LANE)
+   {
+ for (i = 0; i < SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node); ++i)
+   {
+ /* ???  For multi-lane SLP we'd need to build
+{ 0, 0, .., 1, 1, ... }.  */
+ tree cst = build_index_vector (vectype_out,
+i * nunits_out, 1);
+ tree new_var
+ = vect_get_new_ssa_name (vectype_out, vect_simple_var,
+  "cst_");
+ gimple *init_stmt = gimple_build_assign (new_var, cst);
+ vect_init_vector_1 (vinfo, stmt_info, init_stmt, NULL);
+ new_temp = make_ssa_name (vec_dest);
+ gimple *new_stmt
+   = gimple_build_assign (new_temp, new_var);
+ vect_finish_stmt_generation (vinfo, stmt_info, new_stmt,
+  gsi);
+ slp_node->push_vec_def (new_stmt);
+   }
+ continue;
+   }
 
+ vec vec_oprnds0;
  vect_get_slp_defs (vinfo, slp_node, &vec_defs);
  vec_oprnds0 = vec_defs[0];
 
-- 
2.43.0


[committed] hppa: Fix indirect_goto constraint

2024-10-05 Thread John David Anglin
Tested on hppa-unknown-linux-gnu and hppa64-hp-hpux11.11.  Commited
to active branches.

Dave
---

hppa: Fix indirect_goto constraint

Noticed testing LRA.

2024-10-05  John David Anglin  

gcc/ChangeLog:

* config/pa/pa.md: Fix indirect_got constraint.

diff --git a/gcc/config/pa/pa.md b/gcc/config/pa/pa.md
index f0520bb2c35..2f82b431c0c 100644
--- a/gcc/config/pa/pa.md
+++ b/gcc/config/pa/pa.md
@@ -7426,7 +7425,7 @@
 })
 
 (define_insn "indirect_goto"
-  [(unspec [(match_operand 0 "register_operand" "=r")] UNSPEC_GOTO)]
+  [(unspec [(match_operand 0 "register_operand" "r")] UNSPEC_GOTO)]
   "GET_MODE (operands[0]) == word_mode"
   "bv%* %%r0(%0)"
   [(set_attr "type" "branch")


signature.asc
Description: PGP signature